33 #include <osl/diagnose.h>
42 #include <section.hxx>
50 #include <strings.hrc>
51 #include <bitmaps.hlst>
57 #define GLOBAL_UPDATE_TIMEOUT 2000
63 class SwGlobalFrameListener_Impl :
public SfxListener
67 explicit SwGlobalFrameListener_Impl(
SfxViewFrame& rFrame)
75 bool IsValid()
const {
return m_bValid;}
82 if( rHint.
GetId() == SfxHintId::Dying)
91 IDX_STR_EDIT_CONTENT = 1,
92 IDX_STR_EDIT_INSERT = 2,
96 IDX_STR_INSERT_TEXT = 6,
98 IDX_STR_UPDATE_SEL = 8,
99 IDX_STR_UPDATE_INDEX = 9,
100 IDX_STR_UPDATE_LINK = 10,
101 IDX_STR_UPDATE_ALL = 11,
102 IDX_STR_BROKEN_LINK = 12,
103 IDX_STR_EDIT_LINK = 13
128 , m_aDropTargetHelper(*this)
130 , m_aUpdateTimer(
"SwGlobalTree m_aUpdateTimer")
131 , m_pActiveShell(nullptr)
162 , m_rTreeView(rTreeView)
171 std::unique_ptr<weld::TreeIter> xDropEntry(rWidget.
make_iterator());
183 weld::fromId<const SwGlblDocContent*>(rWidget.
get_id(*xDropEntry)) :
185 if( aData.
HasFormat( SotClipboardFormatId::FILE_LIST ))
189 int nAbsContPos = xDropEntry ?
196 aData.
GetFileList( SotClipboardFormatId::FILE_LIST, aFileList );
197 for (
size_t n = aFileList.
Count();
n--; )
208 if(nEntryCount < aTempContents.
size())
212 pCnt = aTempContents[ nAbsContPos ].get();
217 else if( !(sFileName =
261 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
265 if (m_pActiveShell && !m_pActiveShell->GetView().GetDocShell()->IsReadOnly())
268 std::unique_ptr<weld::Menu> xPopup = xBuilder->weld_menu(
"navmenu");
279 xPopup->set_sensitive(
"insertnewfile",
bool(nEnableFlags & MenuEnableFlags::InsertFile));
283 xPopup->set_sensitive(
"insert",
bool(nEnableFlags & MenuEnableFlags::InsertIdx));
288 if (!sCommand.isEmpty())
289 ExecuteContextMenuAction(sCommand);
299 if (rCommand ==
"insert")
303 rMenu.
set_sensitive(
"insertnewfile",
bool(nEnableFlags & MenuEnableFlags::InsertFile));
306 else if (rCommand ==
"update")
314 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
315 bool bEntry =
m_xTreeView->get_selected(xEntry.get());
319 std::unique_ptr<weld::TreeIter> xPrevEntry;
320 bool bPrevEntry =
false;
323 xPrevEntry =
m_xTreeView->make_iterator(xEntry.get());
324 bPrevEntry =
m_xTreeView->iter_previous(*xPrevEntry);
328 if(nSelCount == 1 || !nEntryCount)
339 else if(!nEntryCount)
360 sEntry = m_aContextStrings[IDX_STR_BROKEN_LINK] + sEntry;
373 int nSelCount =
m_xTreeView->count_selected_rows();
375 int nAbsPos = nSel != -1 ? nSel : 0;
379 pNavi->
m_xGlobalToolBox->set_item_sensitive(
"edit", nSelCount == 1 && !bReadonly);
380 pNavi->
m_xGlobalToolBox->set_item_sensitive(
"insert", nSelCount <= 1 && !bReadonly);
383 nSelCount == 1 && nAbsPos && !bReadonly);
385 nSelCount == 1 && nAbsPos < m_xTreeView->n_children() - 1 && !bReadonly);
393 int nDest = pDropEntry ?
m_xTreeView->get_iter_index_in_parent(*pDropEntry)
410 bool bHandled =
false;
418 GetParentWindow()->ToggleTree();
432 std::unique_ptr<weld::TreeIter> xEntry =
m_xTreeView->make_iterator();
433 bool bEntry =
m_xTreeView->get_iter_first(*xEntry);
434 for (
size_t i = 0;
i < nCount && bEntry;
i++)
444 assert(bEntry ||
i == nCount - 1);
449 int nOldSelEntry =
m_xTreeView->get_selected_index();
452 if (nOldSelEntry != -1)
455 nSelPos = nOldSelEntry;
463 for (
size_t i = 0;
i < nCount; ++
i)
479 aImage = RID_BMP_NAVI_INDEX;
486 aImage = RID_BMP_DROP_REGION;
492 if (!aImage.isEmpty())
498 if (sEntry == sEntryName)
521 else if ( !pFileName->isEmpty() )
523 aFileNames.realloc(1);
527 aFileNames.getArray()[0]
535 sal_uInt16 nSlot = 0;
569 bool bUpdateHard =
false;
576 std::unique_ptr<SwGlblDocContent> pContCopy;
580 sal_uInt16 nSlot = 0;
581 if (rSelectedPopupEntry ==
"updatesel")
602 else if (rSelectedPopupEntry ==
"updateindex")
607 else if (rSelectedPopupEntry ==
"updatelinks" || rSelectedPopupEntry ==
"updateall")
610 if (rSelectedPopupEntry ==
"updateall")
615 else if (rSelectedPopupEntry ==
"editcontent")
617 OSL_ENSURE(pCont,
"edit without entry ? " );
623 else if (rSelectedPopupEntry ==
"editlink")
625 OSL_ENSURE(pCont,
"edit without entry ? " );
634 else if (rSelectedPopupEntry ==
"deleteentry")
639 std::vector<int> aRows =
m_xTreeView->get_selected_rows();
640 std::sort(aRows.begin(), aRows.end());
642 std::unique_ptr<SwGlblDocContents> pTempContents;
644 for (
auto iter = aRows.rbegin(); iter != aRows.rend(); ++iter)
652 pTempContents.reset();
656 else if (rSelectedPopupEntry ==
"insertindex")
665 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
682 m_pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert );
687 else if (rSelectedPopupEntry ==
"insertfile")
693 else if (rSelectedPopupEntry ==
"insertnewfile")
696 SwGlobalFrameListener_Impl aFrameListener(*pGlobFrame);
700 SwDocShell::Factory().GetFilterContainer()->
GetName());
704 SfxCallMode::SYNCHRON, { &aFactory }));
713 SID_SAVEASDOC, SfxCallMode::SYNCHRON ));
719 if(aFrameListener.IsValid() && !sNewFile.isEmpty())
730 pCont = nEntry != -1 ? weld::fromId<SwGlblDocContent*>(
m_xTreeView->get_id(nEntry)) :
nullptr;
752 else if (rSelectedPopupEntry ==
"inserttext")
763 else if (rSelectedPopupEntry ==
"update")
776 if (m_pActiveShell && m_pActiveShell->GetView().GetEditWin().HasFocus())
793 if (pActiveShellCurrSection)
795 const SwSection* pSection = pActiveShellCurrSection;
855 if (rCmd ==
"movedown")
858 bMove = nEntryCount > nSource + 1;
861 else if (rCmd ==
"moveup")
863 bMove = 0 != nSource;
902 aTempContents.
size() != nChildren)
909 for(
size_t i = 0;
i < aTempContents.
size() && !bCopy;
i++)
954 while( !bFound && pCurr )
974 ExecuteList(SID_OPENDOC, SfxCallMode::ASYNCHRON,
975 { &aURL, &aReadOnly, &aReferer, &aTargetFrameName });
988 m_pActiveShell->GetView().GetEditWin().GrabFocus();
1008 sal_Int32 nFiles = _rFiles.getLength();
1014 bool bMove = _pContent ==
nullptr;
1015 const OUString* pFileNames = _rFiles.getConstArray();
1028 nAnchorContent = nContent;
1034 for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile )
1039 OSL_ENSURE(aTempContents.
size() > (nAnchorContent + nFile),
"invalid anchor content -> last insertion failed");
1040 if ( aTempContents.
size() > (nAnchorContent + nFile) )
1041 pAnchorContent = aTempContents[nAnchorContent + nFile].get();
1043 pAnchorContent = aTempContents.
back().get();
1044 OUString sFileName(pFileNames[nFile]);
1050 OUString sTempSectionName(sSectionName);
1051 sal_uInt16 nAddNumber = 0;
1054 while ( nCount < nSectCount )
1062 sTempSectionName = sSectionName +
":" + OUString::number( nAddNumber );
1069 sSectionName = sTempSectionName;
1072 aSectionData.SetProtectFlag(
true);
1073 aSectionData.SetHidden(
false);
1075 aSectionData.SetLinkFileName(sFileName);
1077 aSectionData.SetLinkFilePassword( OUString() );
1099 if ( aMedList.empty() )
1103 OUString* pFileNames = aFileNames.getArray();
1105 for (
const std::unique_ptr<SfxMedium>& pMed : aMedList)
1111 + pMed->GetFilter()->GetFilterName()
1113 pFileNames[nPos++] = sFileName;
1115 InsertRegion( m_pDocContent.get(), aFileNames );
1116 m_pDocContent.reset();
1122 if (rHint.
GetId() == SfxHintId::SwNavigatorUpdateTracking)
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
MenuEnableFlags GetEnableFlags() const
virtual int get_iter_index_in_parent(const TreeIter &rIter) const =0
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const Value & back() const
void EditContent(const SwGlblDocContent *pCont)
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
void SplitNode(bool bAutoFormat=false)
void TbxMenuHdl(std::string_view rCommand, weld::Menu &rMenu)
SwNavigationPI * GetParentWindow()
bool MoveGlobalDocContent(const SwGlblDocContents &rArr, size_t nFromPos, size_t nToPos, size_t nNewPos)
void MoveSelectionTo(const weld::TreeIter *pDropTarget)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
const TranslateId GLOBAL_CONTEXT_ARY[]
sfx2::LinkManager & GetLinkManager()
SfxFrame * GetFrame() const
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
static OUString CreateDropFileName(const TransferableDataHelper &rData)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SfxDispatcher * GetDispatcher()
std::unique_ptr< SwGlblDocContents > m_pSwGlblDocContents
#define GLOBAL_CONTEXT_COUNT
const sal_Unicode cTokenSeparator
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
virtual TreeView * get_drag_source() const =0
SwGlobalTree & m_rTreeView
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
std::unique_ptr< weld::Toolbar > m_xGlobalToolBox
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
sal_uInt16 GetCode() const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SwSection * GetParent() const
OUString const & GetLinkFileName() const
virtual SfxObjectShell * GetObjectShell() override
virtual short Execute()=0
virtual void Notify(SfxBroadcaster &rBC, SfxHint const &rHint) override
bool HasFormat(SotClipboardFormatId nFormat) const
const SwWrtShell * GetActiveWrtShell() const
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const =0
SwWrtShell & GetWrtShell() const
const SwSection * GetCurrSection() const
Used by the UI to modify the document model.
OUString SwResId(TranslateId aId)
IMPL_STATIC_LINK_NOARG(SwGlobalTree, ShowFrameHdl, void *, void)
#define GLOBAL_UPDATE_TIMEOUT
const SwView & GetView() const
bool GotoNextTOXBase(const OUString *pName=nullptr)
bool GotoPrevTOXBase(const OUString *=nullptr)
jump to previous index
virtual int n_children() const =0
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList) const
SwGlobalTreeDropTarget(SwGlobalTree &rTreeView)
virtual OUString get_id(int pos) const =0
SfxViewFrame * GetCurrentViewFrame() const
sal_uInt16 GetModifier() const
virtual OUString GetName() const override
void UpdateTableOf(const SwTOXBase &rTOX, const SfxItemSet *pSet=nullptr)
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
void GotoContent(const SwGlblDocContent *)
SfxItemPool & GetPool() const
void ExecCommand(std::string_view rCmd)
constexpr OUStringLiteral aData
std::unique_ptr< sfx2::DocumentInserter > m_pDocInserter
bool Up(bool bSelect, sal_uInt16 nCount=1, bool bBasicCall=false)
SwNavigationPI * m_pDialog
constexpr OStringLiteral HID_NAVIGATOR_GLOB_TREELIST
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode)=0
const OUString & GetSectionName() const
void DeleteGlobalDocContent(const SwGlblDocContents &rArr, size_t nPos)
static void SetShowShell(const SfxObjectShell *pSet)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
virtual void Start(bool bStartTimer=true) override
void ExecuteContextMenuAction(std::string_view rSelectedPopupEntry)
IMPL_LINK_NOARG(SwGlobalTree, SelectHdl, weld::TreeView &, void)
OUString GetFile(size_t nIndex) const
static SwAbstractDialogFactory * Create()
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
constexpr sal_uInt16 KEY_MOD2
void SetTimeout(sal_uInt64 nTimeoutMs)
const OUString & GetTitle() const
void GetGlobalDocContent(SwGlblDocContents &rArr) const
void GotoGlobalDocContent(const SwGlblDocContent &rPos)
SwDocShell * GetDocShell()
void InsertRegion(const SwGlblDocContent *_pContent, const css::uno::Sequence< OUString > &_rFiles)
constexpr sal_uInt16 KEY_RETURN
virtual weld::Window * GetFrameWeld() const override
SwView * GetCreateView() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const SwTOXBase * GetTOX() const
size_t GetSectionFormatCount() const
virtual const SfxItemSet * GetOutputItemSet() const =0
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
OUString toId(const void *pValue)
SwWrtShell * m_pActiveShell
void InsertGlobalDocContent(const SwGlblDocContent &rPos, SwSectionData &rNew)
SwWrtShell * GetWrtShellPtr() const
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
void UpdateAllLinks(bool bAskUpdate, bool bUpdateGrfLinks, weld::Window *pParentWin)
GlobalDocContentType GetType() const
Query contents.
std::unique_ptr< weld::TreeView > m_xTreeView
void OpenDoc(const SwGlblDocContent *)
bool IsConnectFlag() const
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
const SwSection * GetSection() const
const INetURLObject & GetURLObject() const
static const SfxObjectShell * s_pShowShell
void Display(bool bOnlyUpdateUserData=false)
std::unique_ptr< weld::TreeView > m_xTreeView
void SetInvokeHandler(const Link< Timer *, void > &rLink)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
bool IsDropFormatSupported(SotClipboardFormatId nFormat) const
SwNodeOffset GetDocPos() const
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
IMPL_LINK(SwGlobalTree, CommandHdl, const CommandEvent &, rCEvt, bool)
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
weld::TreeView & get_widget()
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
#define FN_PARAM_TOX_TYPE
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
OUString m_aContextStrings[GLOBAL_CONTEXT_COUNT]
SwGlobalTree(std::unique_ptr< weld::TreeView > xTreeView, SwNavigationPI *pDialog)
std::unique_ptr< SwGlblDocContent > m_pDocContent
bool Detect(bool bExtendedInfo=false)
virtual CurTOXType GetCurrentTOXType() const =0
#define FN_INSERT_MULTI_TOX
virtual SwTOXDescription & GetTOXDescription(CurTOXType eTOXTypes)=0
Built on top of SwWrtShell, provides functionality to insert, update or perform other actions on vari...
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
bool UpdateOrInsertTOX(const SwTOXDescription &rDesc, SwTOXBase **ppBase, const SfxItemSet *pSet)
const OUString & GetTOXName() const
::std::vector< std::unique_ptr< SfxMedium > > SfxMediumList
void EndAction(const bool bIdleEnd=false)
SfxMedium * GetMedium() const