39 #include <strings.hrc>
54 struct TextBlockInfo_Impl
59 TextBlockInfo_Impl(OUString
const& rTitle, OUString
const& rLongName, OUString
const& rGroupName)
60 : sTitle(rTitle), sLongName(rLongName), sGroupName(rGroupName) {}
76 sShortName = pDlg->GetCurrShortName();
79 pDlg.disposeAndClear();
86 if( !sName.isEmpty() || !sShortName.isEmpty() )
94 OUString sGroup(rGrp);
101 bool bPathEqual =
false;
102 if(!bAlwaysCreateNew)
105 const OUString sCurBase = aTemp.
getBase();
106 aTemp.removeSegment();
110 for (
size_t nPath = 0; nPath < rPathArr.size(); ++nPath)
112 if (sCurEntryPath == rPathArr[nPath])
114 nCurrentPath =
static_cast<sal_uInt16
>(nPath);
118 const OUString sPath = sGroup.getToken(1,
GLOS_DELIM);
119 sal_uInt16 nComparePath =
static_cast<sal_uInt16
>(sPath.toInt32());
120 if(nCurrentPath == nComparePath &&
126 if(!bAlwaysCreateNew && bPathEqual)
147 if (pGroup && !pGroup->GetError())
149 *pTitle = pGroup->GetName();
150 if (pTitle->isEmpty())
153 pGroup->SetName(*pTitle);
173 OUString sOldGroup(rOld);
181 pGroup->SetName(rNewTitle);
186 OUString sNewGroup(rNew);
199 OUString sGroup(rGrpName);
206 if (
pCurGrp->GetName() == sGroup)
222 OSL_ENSURE(nId <
GetGlossaryCnt(),
"Text building block array over-indexed.");
223 return pCurGrp->GetLongName( nId );
228 OSL_ENSURE(nId <
GetGlossaryCnt(),
"Text building block array over-indexed.");
229 return pCurGrp->GetShortName( nId );
241 if( nIdx != sal_uInt16(-1) )
254 bool bRet = pBlock->
GetIndex( rShortName ) != sal_uInt16(-1);
262 bool bCreateGroup,
bool bNoAttr)
275 OUString* pOnlyText =
nullptr;
279 pOnlyText = &sOnlyText;
286 if(nSuccess == sal_uInt16(-1) )
289 VclMessageType::Info, VclButtonsType::Ok,
SwResId(STR_ERR_INSERT_GLOS)));
294 return nSuccess != sal_uInt16(-1);
310 sal_uInt16 nIdx = pGlossary->
GetIndex( rShortName );
311 if( nIdx != sal_uInt16(-1) )
312 pGlossary->
Delete( nIdx );
324 OUString sGroupName( (*fnGetCurrGroup)() );
356 std::unique_ptr<SwTextBlocks> pGlossary)
358 std::vector<TextBlockInfo_Impl> aFoundArr;
359 OUString aShortName( rShortName );
360 bool bCancel =
false;
366 if( nFound == sal_uInt16(-1) )
371 for(
size_t i = 0;
i < nGroupCount; ++
i)
375 if(sGroupName == pGlossary->GetName())
381 for(sal_uInt16 j = 0; j < nBlockCount; j++)
385 if( rSCmp.isEqual( rShortName, sShortName ))
387 aFoundArr.emplace_back(sTitle, sLongName, sGroupName);
392 if( !aFoundArr.empty() )
395 if (1 == aFoundArr.size())
397 TextBlockInfo_Impl&
rData = aFoundArr.front();
398 pGlossary = pGlossaries->
GetGroupDoc(rData.sGroupName);
399 nFound = pGlossary->GetIndex( aShortName );
405 for(
const TextBlockInfo_Impl &
i : aFoundArr)
407 pDlg->InsertGlos(
i.sTitle,
i.sLongName);
409 pDlg->SelectEntryPos(0);
410 const sal_Int32 nRet =
RET_OK == pDlg->Execute() ?
411 pDlg->GetSelectedIdx() :
413 pDlg.disposeAndClear();
416 TextBlockInfo_Impl&
rData = aFoundArr[nRet];
417 pGlossary = pGlossaries->
GetGroupDoc(rData.sGroupName);
418 nFound = pGlossary->GetIndex( aShortName );
422 nFound = sal_uInt16(-1);
430 if( nFound == sal_uInt16(-1) )
436 const sal_Int32 nMaxLen = 50;
439 aShortName = OUString::Concat(aShortName.subView(0, nMaxLen)) +
" ...";
441 OUString aTmp(
SwResId(STR_NOGLOS));
442 aTmp = aTmp.replaceFirst(
"%1", aShortName);
444 VclMessageType::Info, VclButtonsType::Ok,
455 GetMacros( aShortName, aStartMacro, aEndMacro, pGlossary.get() );
503 GetMacros( rName, aStartMacro, aEndMacro, pGlos );
545 aMacroTable.
Insert( SvMacroItemId::SwStartInsGlossary, *pStart);
547 aMacroTable.
Insert( SvMacroItemId::SwEndInsGlossary, *pEnd);
548 sal_uInt16 nIdx = pGlos->
GetIndex( rShortName );
570 SvxMacro *pMacro = aMacroTable.
Get( SvMacroItemId::SwStartInsGlossary );
574 pMacro = aMacroTable.
Get( SvMacroItemId::SwEndInsGlossary );
588 pViewFrame( pVwFrame ),
599 const OUString& rNewName )
606 sal_uInt16 nIdx = pGlossary->
GetIndex( rOldShort );
607 sal_uInt16 nOldLongIdx = pGlossary->
GetLongIndex( rNewName );
608 sal_uInt16 nOldIdx = pGlossary->
GetIndex( rNewShortName );
611 (nOldLongIdx ==
USHRT_MAX || nOldLongIdx == nIdx )&&
612 (nOldIdx ==
USHRT_MAX || nOldIdx == nIdx ))
614 pGlossary->
Rename( nIdx, &rNewShortName, &rNewName );
634 const bool bRet = !pGlossary || pGlossary->
IsReadOnly();
660 bool bRet = pTransfer->CopyGlossary( *pGlossary, rShortName );
669 if( !rName.isEmpty() )
671 std::shared_ptr<const SfxFilter> pFilter;
672 std::unique_ptr<SfxMedium> pMed(
new SfxMedium( rName, StreamMode::READ,
nullptr,
nullptr ));
674 pMed->UseInteractionHandler(
true );
675 if (!aMatcher.
GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE))
678 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()