39 #include <strings.hrc>
41 #include <osl/diagnose.h>
55 struct TextBlockInfo_Impl
60 TextBlockInfo_Impl(OUString
const& rTitle, OUString
const& rLongName, OUString
const& rGroupName)
61 : sTitle(rTitle), sLongName(rLongName), sGroupName(rGroupName) {}
77 sShortName = pDlg->GetCurrShortName();
80 pDlg.disposeAndClear();
87 if( !sName.isEmpty() || !sShortName.isEmpty() )
95 OUString sGroup(rGrp);
102 bool bPathEqual =
false;
103 if(!bAlwaysCreateNew)
106 const OUString sCurBase = aTemp.
getBase();
107 aTemp.removeSegment();
111 for (
size_t nPath = 0; nPath < rPathArr.size(); ++nPath)
113 if (sCurEntryPath == rPathArr[nPath])
115 nCurrentPath =
static_cast<sal_uInt16
>(nPath);
119 const OUString sPath = sGroup.getToken(1,
GLOS_DELIM);
120 sal_uInt16 nComparePath =
static_cast<sal_uInt16
>(sPath.toInt32());
121 if(nCurrentPath == nComparePath &&
127 if(!bAlwaysCreateNew && bPathEqual)
148 if (pGroup && !pGroup->GetError())
150 *pTitle = pGroup->GetName();
151 if (pTitle->isEmpty())
154 pGroup->SetName(*pTitle);
174 OUString sOldGroup(rOld);
182 pGroup->SetName(rNewTitle);
187 OUString sNewGroup(rNew);
200 OUString sGroup(rGrpName);
207 if (
pCurGrp->GetName() == sGroup)
223 OSL_ENSURE(nId <
GetGlossaryCnt(),
"Text building block array over-indexed.");
224 return pCurGrp->GetLongName( nId );
229 OSL_ENSURE(nId <
GetGlossaryCnt(),
"Text building block array over-indexed.");
230 return pCurGrp->GetShortName( nId );
242 if( nIdx != sal_uInt16(-1) )
255 bool bRet = pBlock->
GetIndex( rShortName ) != sal_uInt16(-1);
263 bool bCreateGroup,
bool bNoAttr)
276 OUString* pOnlyText =
nullptr;
280 pOnlyText = &sOnlyText;
287 if(nSuccess == sal_uInt16(-1) )
290 VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_ERR_INSERT_GLOS)));
295 return nSuccess != sal_uInt16(-1);
311 sal_uInt16 nIdx = pGlossary->
GetIndex( rShortName );
312 if( nIdx != sal_uInt16(-1) )
313 pGlossary->
Delete( nIdx );
325 OUString sGroupName( (*fnGetCurrGroup)() );
357 std::unique_ptr<SwTextBlocks> pGlossary)
359 std::vector<TextBlockInfo_Impl> aFoundArr;
360 OUString aShortName( rShortName );
361 bool bCancel =
false;
367 if( nFound == sal_uInt16(-1) )
372 for(
size_t i = 0;
i < nGroupCount; ++
i)
376 if(sGroupName == pGlossary->GetName())
382 for(sal_uInt16 j = 0; j < nBlockCount; j++)
386 if( rSCmp.isEqual( rShortName, sShortName ))
388 aFoundArr.emplace_back(sTitle, sLongName, sGroupName);
393 if( !aFoundArr.empty() )
396 if (1 == aFoundArr.size())
398 TextBlockInfo_Impl&
rData = aFoundArr.front();
399 pGlossary = pGlossaries->
GetGroupDoc(rData.sGroupName);
400 nFound = pGlossary->GetIndex( aShortName );
406 for(
const TextBlockInfo_Impl &
i : aFoundArr)
408 pDlg->InsertGlos(
i.sTitle,
i.sLongName);
410 pDlg->SelectEntryPos(0);
411 const sal_Int32 nRet =
RET_OK == pDlg->Execute() ?
412 pDlg->GetSelectedIdx() :
414 pDlg.disposeAndClear();
417 TextBlockInfo_Impl&
rData = aFoundArr[nRet];
418 pGlossary = pGlossaries->
GetGroupDoc(rData.sGroupName);
419 nFound = pGlossary->GetIndex( aShortName );
423 nFound = sal_uInt16(-1);
431 if( nFound == sal_uInt16(-1) )
437 const sal_Int32 nMaxLen = 50;
440 aShortName = OUString::Concat(aShortName.subView(0, nMaxLen)) +
" ...";
442 OUString aTmp(
SwResId(STR_NOGLOS));
443 aTmp = aTmp.replaceFirst(
"%1", aShortName);
445 VclMessageType::Info, VclButtonsType::Ok,
456 GetMacros( aShortName, aStartMacro, aEndMacro, pGlossary.get() );
504 GetMacros( rName, aStartMacro, aEndMacro, pGlos );
546 aMacroTable.
Insert( SvMacroItemId::SwStartInsGlossary, *pStart);
548 aMacroTable.
Insert( SvMacroItemId::SwEndInsGlossary, *pEnd);
549 sal_uInt16 nIdx = pGlos->
GetIndex( rShortName );
571 SvxMacro *pMacro = aMacroTable.
Get( SvMacroItemId::SwStartInsGlossary );
575 pMacro = aMacroTable.
Get( SvMacroItemId::SwEndInsGlossary );
589 pViewFrame( pVwFrame ),
600 const OUString& rNewName )
607 sal_uInt16 nIdx = pGlossary->
GetIndex( rOldShort );
608 sal_uInt16 nOldLongIdx = pGlossary->
GetLongIndex( rNewName );
609 sal_uInt16 nOldIdx = pGlossary->
GetIndex( rNewShortName );
612 (nOldLongIdx ==
USHRT_MAX || nOldLongIdx == nIdx )&&
613 (nOldIdx ==
USHRT_MAX || nOldIdx == nIdx ))
615 pGlossary->
Rename( nIdx, &rNewShortName, &rNewName );
635 const bool bRet = !pGlossary || pGlossary->
IsReadOnly();
661 bool bRet = pTransfer->CopyGlossary( *pGlossary, rShortName );
670 if( !rName.isEmpty() )
672 std::shared_ptr<const SfxFilter> pFilter;
673 std::unique_ptr<SfxMedium> pMed(
new SfxMedium( rName, StreamMode::READ,
nullptr,
nullptr ));
675 pMed->UseInteractionHandler(
true );
676 if (!aMatcher.
GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE))
679 pMed->SetFilter( pFilter );
void InsertGlossary(SwTextBlocks &rGlossary, const OUString &)
Glossary from glossary document in current document.
OUString(* GlossaryGetCurrGroup)()
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
SvxMacro & Insert(SvMacroItemId nEvent, const SvxMacro &rMacro)
sal_uInt16 GetBlockCount(size_t nGroup)
static SvxAutoCorrCfg & Get()
bool Rename(const OUString &rOldShortName, const OUString &rNewShortName, const OUString &rNewName)
bool ReadGlossaries(const Reader &, SwTextBlocks &, bool bSaveRelFiles)
sal_uInt16 MakeGlossary(SwTextBlocks &rToFill, const OUString &rName, const OUString &rShortName, bool bSaveRelFile, const OUString *pOnlyText)
Make current selection glossary and insert into glossary document including styles.
OUString getBase(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetGlossaryShortName(const OUString &rName)
void GetSelectedText(OUString &rBuf, ParaBreakType nHndlParaBreak=ParaBreakType::ToBlank)
Query text within selection.
std::unique_ptr< SwTextBlocks > pCurGrp
sal_uInt16 GetGlossaryCnt() const
SwDocShellRef EditGroupDoc(const OUString &rGrpName, const OUString &rShortName, bool bShow=true)
bool DelGlossary(const OUString &)
const ContentProperties & rData
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
void UpdateInputFields(SwInputFieldList *pLst=nullptr)
std::unique_ptr< SwTextBlocks > GetGroupDoc(const OUString &rName, bool bCreate=false)
void Rename(sal_uInt16, const OUString *, const OUString *)
bool FindGroupName(OUString &rGroup)
ErrCode const & GetError() const
SwGlossaries & rStatGlossaries
size_t GetGroupCnt() const
Used by the UI to modify the document model.
const SwView & GetView() const
virtual VclPtr< AbstractGlossaryDlg > CreateGlossaryDlg(SfxViewFrame *pViewFrame, SwGlossaryHdl *pGlosHdl, SwWrtShell *pWrtShell)=0
Reader * GetReader(const OUString &rFltName)
Return reader based on the name.
void SetMacros(const OUString &rName, const SvxMacro *pStart, const SvxMacro *pEnd, SwTextBlocks *pGlossary=nullptr)
bool PrvWrd(bool bSelect=false)
void SetCurGroup(const OUString &aGrp, bool bApi=false, bool bAlwaysCreateNew=false)
OUString GetBlockLongName(size_t nGroup, sal_uInt16 nBlock)
OUString GetGroupName(size_t nPos)
SW_DLLPUBLIC SwGlossaries * GetGlossaries()
OUString GetBlockShortName(size_t nGroup, sal_uInt16 nBlock)
bool DelGroupDoc(const OUString &)
void ExecMacro(const SvxMacro &rMacro, OUString *pRet=nullptr, SbxArray *pArgs=nullptr)
SAL_DLLPRIVATE bool Expand(weld::Window *pParent, const OUString &rShortName, SwGlossaries *pGlossaries, std::unique_ptr< SwTextBlocks > pGlossary)
OUString GetGlossaryName(sal_uInt16)
bool DelGroup(const OUString &)
SwGlossaryHdl(SfxViewFrame *pViewFrame, SwWrtShell *)
bool HasSelection() const
OUString GetGroupTitle(size_t nPos)
static SwGlossaryList * pGlossaryList
bool CopyToClipboard(SwWrtShell &rSh, const OUString &rShortName)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static std::unique_ptr< SwGlossaries > pGlossaries
bool ExpandGlossary(weld::Window *pParent)
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
sal_uInt16 GetLongIndex(const OUString &) const
bool IsInWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) const
bool IsReadOnly(const OUString *=nullptr) const
static SwAbstractDialogFactory * Create()
OUString GetGroupName(size_t, OUString *pTitle)
OUString SwResId(const char *pId)
bool IsSaveRelFile() const
virtual OUString GetCurrGrpName() const =0
void NewGroup(OUString &rGroupName, const OUString &rTitle)
bool IsSearchInAllCategories() const
bool InsertGlossary(const OUString &rName)
bool GetMacroTable(sal_uInt16 nIdx, SvxMacroTableDtor &rMacroTable)
bool HasShortName(const OUString &rShortName) const
const SvxMacro * Get(SvMacroItemId nEvent) const
OUString const & GetGroupName(size_t)
weld::Window * GetFrameWeld() const
SfxViewFrame * pViewFrame
std::vector< OUString > const & GetPathArray() const
bool RenameGroupDoc(const OUString &sOldGroup, OUString &sNewGroup, const OUString &rNewTitle)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
OUString GetSelText() const
get selected text of a node at current cursor
sal_uInt16 GetIndex(const OUString &) const
void GetMacros(const OUString &rShortName, SvxMacro &rStart, SvxMacro &rEnd, SwTextBlocks *pGlossary=nullptr)
OUString GetShortName(sal_uInt16) const
void RenameGroup(const OUString &rOld, OUString &rNew, const OUString &rNewTitle)
bool SetMacroTable(sal_uInt16 nIdx, const SvxMacroTableDtor &rMacroTable)
virtual VclPtr< AbstractSwSelGlossaryDlg > CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName)=0
bool FindGroupName(OUString &rGroup)
void StartAllAction()
For all views of this document.
bool NewGlossary(const OUString &rName, const OUString &rShortName, bool bApiCall=false, bool bNoAttr=false)
bool NewGroupDoc(OUString &rGroupName, const OUString &rTitle)
bool HasGlossaries(const Reader &)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
bool ImportGlossaries(const OUString &rName)
SwGlossaryList * GetGlossaryList()