32#include <osl/diagnose.h>
51#include <bitmaps.hlst>
57#include <drawview.hxx>
80 RID_BMP_CONTENT_TABLE,
81 RID_BMP_CONTENT_RANGENAME,
82 RID_BMP_CONTENT_DBAREA,
83 RID_BMP_CONTENT_GRAPHIC,
84 RID_BMP_CONTENT_OLEOBJECT,
86 RID_BMP_CONTENT_AREALINK,
87 RID_BMP_CONTENT_DRAWING
96 while ( pObjSh && !pSh )
122 : m_xTreeView(
std::move(xTreeView))
123 , m_xScratchIter(m_xTreeView->make_iterator())
125 , pParentWindow(pNavigatorDlg)
128 , pHiddenDocument(nullptr)
129 , bIsInNavigatorDlg(false)
131 , m_nAsyncMouseReleaseId(nullptr)
151 m_xTreeView->set_selection_mode( SelectionMode::Single );
170 SCSTR_CONTENT_RANGENAME,
171 SCSTR_CONTENT_DBAREA,
172 SCSTR_CONTENT_GRAPHIC,
173 SCSTR_CONTENT_OLEOBJECT,
175 SCSTR_CONTENT_AREALINK,
176 SCSTR_CONTENT_DRAWING
223 if (!pParent ||
m_xTreeView->iter_has_child(*pParent))
242 OSL_FAIL(
"InsertContent without parent");
254 std::unique_ptr<weld::TreeIter> xParent(
m_xTreeView->make_iterator(pEntry));
275 std::unique_ptr<weld::TreeIter> xIterEntry(
m_xTreeView->make_iterator(xParent.get()));
276 bool bIterEntry =
m_xTreeView->iter_children(*xIterEntry);
277 while (!bFound && bIterEntry)
279 if (
m_xTreeView->iter_compare(*pEntry, *xIterEntry) == 0)
281 rnChildIndex = nEntry;
284 bIterEntry =
m_xTreeView->iter_next_sibling(*xIterEntry);
311 pData->GetArea(aRange);
322 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
323 if (!m_xTreeView->get_cursor(xEntry.get()))
325 GetEntryIndexes(
nType, nChild, xEntry.get());
332 OUString aText(m_xTreeView->get_text(*xEntry));
334 if ( !aManualDoc.isEmpty() )
335 pParentWindow->SetCurrentDoc( aManualDoc );
344 StoreNavigatorSettings();
345 pParentWindow->SetCurrentTableStr( aText );
350 pParentWindow->SetCurrentCellStr( aText );
360 if (!aRangeStr.isEmpty())
361 pParentWindow->SetCurrentCellStr( aRangeStr );
368 pParentWindow->SetCurrentObject( aText );
374 pParentWindow->SetCurrentTable( aPos.
Tab() );
375 pParentWindow->SetCurrentCell( aPos.
Col(), aPos.
Row() );
383 if (
pLink && pSrcDoc)
387 pParentWindow->SetCurrentCellStr( aRangeStr );
408 LaunchAsyncStoreNavigatorSettings();
414 m_nAsyncMouseReleaseId =
nullptr;
415 StoreNavigatorSettings();
433 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
434 if (!m_xTreeView->get_cursor(xEntry.get()))
440 GetEntryIndexes(
nType, nChild, xEntry.get());
444 if (m_xTreeView->get_row_expanded(*xEntry))
445 m_xTreeView->collapse_row(*xEntry);
447 m_xTreeView->expand_row(*xEntry);
450 ContentDoubleClickHdl(*m_xTreeView);
460 if ( bIsInNavigatorDlg )
467 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
468 if (!m_xTreeView->get_cursor(xEntry.get()))
470 GetEntryIndexes(
nType, nChild, xEntry.get());
476 OUString aText(m_xTreeView->get_text(*xEntry));
477 if (!aManualDoc.isEmpty())
478 pParentWindow->SetCurrentDoc( aManualDoc );
492 bool bHasMakredObject =
false;
494 std::unique_ptr<weld::TreeIter> xBeginEntry(m_xTreeView->make_iterator(pParent));
495 bool bBeginEntry =
false;
497 bBeginEntry = m_xTreeView->iter_children(*xBeginEntry);
500 OUString aTempText(m_xTreeView->get_text(*xBeginEntry));
503 bHasMakredObject =
true;
506 bBeginEntry = m_xTreeView->iter_next(*xBeginEntry);
508 if (!bHasMakredObject && pScTabViewShell)
523 StoreNavigatorSettings();
525 LaunchAsyncStoreNavigatorSettings();
535 switch ( rCEvt.GetCommand() )
537 case CommandEventId::ContextMenu:
541 std::unique_ptr<weld::Menu> xPop(xBuilder->weld_menu(
"contextmenu"));
542 std::unique_ptr<weld::Menu> xDropMenu(xBuilder->weld_menu(
"dragmodesubmenu"));
544 switch (pParentWindow->GetDropMode())
547 xDropMenu->set_active(
"hyperlink",
true);
550 xDropMenu->set_active(
"link",
true);
553 xDropMenu->set_active(
"copy",
true);
558 std::unique_ptr<weld::Menu> xDocMenu(xBuilder->weld_menu(
"displaymenu"));
567 if (
dynamic_cast<const ScDocShell*
>( pSh) !=
nullptr )
570 OUString aEntry =
aName;
571 if ( pSh == pCurrentSh )
572 aEntry += pParentWindow->aStrActive;
574 aEntry += pParentWindow->aStrNotActive;
576 sId =
"document" + OUString::number(
i);
577 xDocMenu->append_radio(
sId, aEntry);
578 if ( !bHiddenDoc &&
aName == aManualDoc )
585 sId =
"document" + OUString::number(
i);
586 xDocMenu->append_radio(
sId, pParentWindow->aStrActiveWin);
587 if (!bHiddenDoc && aManualDoc.isEmpty())
590 if ( !aHiddenTitle.isEmpty() )
592 OUString aEntry = aHiddenTitle + pParentWindow->aStrHidden;
594 sId =
"document" + OUString::number(
i);
595 xDocMenu->append_radio(
sId, aEntry);
599 xDocMenu->set_active(sActive,
true);
601 OUString sIdent = xPop->popup_at_rect(m_xTreeView.get(),
tools::Rectangle(rCEvt.GetMousePosPixel(),
Size(1, 1)));
602 if (sIdent ==
"hyperlink")
603 pParentWindow->SetDropMode(0);
604 else if (sIdent ==
"link")
605 pParentWindow->SetDropMode(1);
606 else if (sIdent ==
"copy")
607 pParentWindow->SetDropMode(2);
608 else if (sIdent.startsWith(
"document"))
610 OUString
aName = xDocMenu->get_label(sIdent);
625 std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator(&rEntry));
626 if (!m_xTreeView->iter_parent(*xParent))
631 aHelpText = OUString::number(m_xTreeView->iter_n_children(rEntry)) +
632 " " + m_xTreeView->get_text(rEntry);
636 aHelpText = m_xTreeView->get_text(rEntry);
640 auto nIndex = GetChildIndex(&rEntry);
646 aHelpText =
pLink->GetFile();
734OUString createLocalRangeName(std::u16string_view rName, std::u16string_view rTableName)
736 return OUString::Concat(rName) +
" (" + rTableName +
")";
750 std::set<OUString> aSet;
752 for (
const auto& rEntry : *pRangeNames)
754 if (rEntry.second->IsValidReference(aDummy))
755 aSet.
insert(rEntry.second->GetName());
760 if (pLocalRangeName && !pLocalRangeName->
empty())
764 for (
const auto& rEntry : *pLocalRangeName)
766 if (rEntry.second->IsValidReference(aDummy))
767 aSet.insert(createLocalRangeName(rEntry.second->GetName(), aTableName));
772 for (
const auto& rItem : aSet)
789 for (
const auto& rxDB : rDBs)
791 const OUString& aStrName = rxDB->GetName();
799 switch ( nContentType )
802 bRet = ( nObjIdentifier == SdrObjKind::Graphic );
805 bRet = ( nObjIdentifier == SdrObjKind::OLE2 );
808 bRet = ( nObjIdentifier != SdrObjKind::Graphic && nObjIdentifier != SdrObjKind::OLE2 );
811 OSL_FAIL(
"unknown content type");
841 std::vector<OUString> aNames;
843 for (
SCTAB nTab=0; nTab<nTabCount; nTab++)
845 SdrPage* pPage = pDrawLayer->
GetPage(
static_cast<sal_uInt16
>(nTab));
846 OSL_ENSURE(pPage,
"Page ?");
856 if (!
aName.isEmpty())
857 aNames.push_back(
aName);
860 SAL_WARN(
"sc",
"too many tree nodes, ignoring the rest");
869 assert(pParent &&
"InsertContent without parent");
872 m_xTreeView->set_text(rIter, aNames[nIndex], 0);
873 m_xTreeView->set_sensitive(rIter, true);
902 OSL_ENSURE(pLinkManager,
"no LinkManager on document?");
903 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->
GetLinks();
904 sal_uInt16
nCount = rLinks.size();
908 if (
auto pScAreaLink =
dynamic_cast<const ScAreaLink*
>( pBase))
923 OSL_ENSURE(pLinkManager,
"no LinkManager on document?");
924 const ::sfx2::SvBaseLinks& rLinks = pLinkManager->
GetLinks();
925 sal_uInt16
nCount = rLinks.size();
929 if (
auto pAreaLink =
dynamic_cast<const ScAreaLink*
>( pBase))
937 OSL_FAIL(
"link not found");
943 return rNote.
GetText().replace(
'\n',
' ');
956 std::vector<sc::NoteEntry>
aEntries;
986 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
989 std::vector<sc::NoteEntry>
aEntries;
993 const ScPostIt* pNote = rEntry.mpNote;
1016 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
1017 bool bEntry =
m_xTreeView->iter_children(*xEntry);
1025 if (pDrawLayer && pShell)
1028 for (
SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
1030 SdrPage* pPage = pDrawLayer->
GetPage(
static_cast<sal_uInt16
>(nTab));
1031 OSL_ENSURE(pPage,
"Page ?");
1064 bool bFound =
false;
1072 if (
p &&
p->IsValidReference(rRange))
1087 p->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
1088 rRange =
ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
1099 bool bDisallow =
true;
1107 SdrObjKind nDrawId = bOle ? SdrObjKind::OLE2 : ( bGraf ? SdrObjKind::Graphic : SdrObjKind::Group );
1123 if(SdrObjKind::OLE2 ==
pObject->GetObjIdentifier())
1126 aDragShellRef->DoInitNew();
1140 pTransferObj->SetDragSourceObj( *
pObject, nTab );
1143 SC_MOD()->SetDragObject(
nullptr, pTransferObj.get() );
1157 bool bDisallow =
true;
1170 rSrcDoc.
CopyToClip(aClipParam, pClipDoc.get(), &aMark,
false,
false);
1180 pTransferObj->SetDragSource( pSrcShell, aMark );
1181 pTransferObj->SetDragSourceFlags( nFlags );
1183 SC_MOD()->SetDragObject( pTransferObj.get(),
nullptr );
1196 rUnsetDragIcon =
true;
1198 StoreNavigatorSettings();
1200 bool bDisallow =
true;
1202 std::unique_ptr<ScDocumentLoader> pDocLoader;
1209 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
1210 if (!m_xTreeView->get_cursor(xEntry.get()))
1213 GetEntryIndexes(
nType, nChild, xEntry.get());
1221 OUString aText(m_xTreeView->get_text(*xEntry));
1226 aDocName = aHiddenName;
1239 bool bDoLinkTrans =
false;
1243 sal_uInt16 nDropMode = pParentWindow->GetDropMode();
1244 switch ( nDropMode )
1248 OUString aUrl = aDocName +
"#" + aText;
1252 if (!aDocName.isEmpty())
1260 bDoLinkTrans =
true;
1265 if ( !aDocName.isEmpty() )
1272 pScMod->
SetDragLink( aDocName, aText, OUString() );
1273 bDoLinkTrans =
true;
1277 pScMod->
SetDragLink( aDocName, OUString(), aText );
1278 bDoLinkTrans =
true;
1292 OUString aFilter, aOptions;
1293 OUString
aURL = aHiddenName;
1295 if (!pDocLoader->IsError())
1296 pSrcShell = pDocLoader->GetDocShell();
1299 pSrcShell = GetManualOrCurrent();
1315 if ( rSrcDoc.
GetTable( aText, nTab ) )
1336 if (!aLinkURL.isEmpty())
1337 m_xTransferObj->SetLinkURL(aLinkURL, aLinkText);
1351 OUString aDocName = rUrl;
1352 sal_Int32
nPos = aDocName.indexOf(
'#');
1354 aDocName = aDocName.copy(0,
nPos);
1356 OUString
aURL = aDocName;
1357 OUString aFilter, aOptions;
1393 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
1396 std::unique_ptr<weld::TreeIter> xParent(
m_xTreeView->make_iterator(xEntry.get()));
1426 bool bRefreshed =
false;
1481 OUString aRealName = rName;
1482 sal_Int32 nLen = rName.getLength();
1485 aRealName = rName.copy( 0, nActiveStart );
1488 aRealName = rName.copy( 0, nNotActiveStart );
1490 bool bLoaded =
false;
1495 while ( pSh && !bLoaded )
1497 if (
dynamic_cast<const ScDocShell*
>( pSh) !=
nullptr )
1498 if ( pSh->
GetTitle() == aRealName )
1515 OSL_FAIL(
"SelectDoc: not found");
1523 if (pParent || !
m_xTreeView->iter_has_child(*pParent))
1526 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
1527 bool bEntry =
m_xTreeView->iter_children(*xEntry);
1586 if( nRootSel == nEntry )
1588 std::unique_ptr<weld::TreeIter> xEntry;
1621 std::unique_ptr<weld::TreeIter> xCurEntry(
m_xTreeView->make_iterator());
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void SelectEntryByName(const ScContentId nRoot, std::u16string_view rName)
ScDocument * pHiddenDocument
const ScAreaLink * GetLink(sal_uLong nIndex)
ScContentTree(std::unique_ptr< weld::TreeView > xTreeView, ScNavigatorDlg *pNavigatorDlg)
std::unique_ptr< weld::TreeIter > m_xScratchIter
void ClearType(ScContentId nType)
std::unique_ptr< weld::TreeView > m_xTreeView
void LaunchAsyncStoreNavigatorSettings()
ImplSVEvent * m_nAsyncMouseReleaseId
void StoreNavigatorSettings()
Stores the current listbox state in the navigator settings.
void GetDrawNames(ScContentId nType)
void ApplyNavigatorSettings()
Applies the navigator settings to the listbox.
bool NoteStringsChanged()
void InsertContent(ScContentId nType, const OUString &rValue)
void Refresh(ScContentId nType=ScContentId::ROOT)
o3tl::enumarray< ScContentId, sal_uInt16 > pPosList
void SelectDoc(const OUString &rName)
sal_uLong GetChildIndex(const weld::TreeIter *pEntry) const
Returns the child index of the specified listbox entry.
o3tl::enumarray< ScContentId, std::unique_ptr< weld::TreeIter > > m_aRootNodes
ScDocShell * GetManualOrCurrent()
void SetRootType(ScContentId nNew)
static bool IsPartOfType(ScContentId nContentType, SdrObjKind nObjIdentifier)
rtl::Reference< ScLinkTransferObj > m_xTransferObj
void SetManualDoc(const OUString &rName)
ScNavigatorDlg * pParentWindow
void InitRoot(ScContentId nType)
void GetEntryIndexes(ScContentId &rnRootIndex, sal_uLong &rnChildIndex, const weld::TreeIter *pEntry) const
Returns the indexes of the specified listbox entry.
ScDocument * GetSourceDocument()
void LoadFile(const OUString &rUrl)
ScAddress GetNotePos(sal_uLong nIndex)
bool DrawNamesChanged(ScContentId nType)
Stores global named database ranges.
ScDBData * findByUpperName(const OUString &rName)
const ScDocument & GetDocument() const
OUString GetTitle() const
ScDocument * GetDocument()
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void CopyToClip(const ScClipParam &rClipParam, ScDocument *pClipDoc, const ScMarkData *pMarks, bool bKeepScenarioFlags, bool bIncludeObjects)
SC_DLLPUBLIC void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
ScAddress GetNotePosition(size_t nIndex) const
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
SfxObjectShell * GetDocumentShell() const
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
bool HasSelectedBlockMatrixFragment(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScMarkData &rMark) const
SC_DLLPUBLIC SCTAB GetTableCount() const
static OUString GetVisibleName(const SdrObject *pObj)
static void SetGlobalDrawPersist(SfxObjectShell *pPersist)
SdrObject * GetNamedObject(std::u16string_view rName, SdrObjKind nId, SCTAB &rFoundTab) const
void SelectCurrentViewObject(std::u16string_view rName)
SdrObject * GetObjectByName(std::u16string_view rName)
bool GetObjectIsMarked(const SdrObject *pObject)
static SC_DLLPUBLIC const CharClass & getCharClass()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectTable(SCTAB nTab, bool bNew)
void SetMarkArea(const ScRange &rRange)
void SetDragLink(const OUString &rDoc, const OUString &rTab, const OUString &rArea)
void SetDragJump(ScDocument *pLocalDoc, const OUString &rTarget, const OUString &rText)
static ScNavigatorSettings * GetNavigatorSettings()
static ScTabViewShell * GetTabViewShell()
void GetDocNames(const OUString *pSelEntry)
static void ReleaseFocus()
Contains settings of the navigator listbox.
bool IsExpanded(ScContentId nIndex) const
ScContentId GetRootSelected() const
sal_uLong GetChildSelected() const
void SetRootSelected(ScContentId nIndex)
void SetChildSelected(sal_uLong nIndex)
void SetExpanded(ScContentId nIndex, bool bExpand)
void SetRootType(ScContentId nNew)
Additional class containing cell annotation data.
OUString GetText() const
Returns the caption text of this note.
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
void SetDrawShell(bool bActive)
ScViewData & GetViewData()
ScDrawView * GetScDrawView()
virtual std::unique_ptr< SdrModel > CreateMarkedObjModel() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrPageView * ShowSdrPage(SdrPage *pPage) override
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
const INetURLObject & GetURLObject() const
const OUString & GetName() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxMedium * GetMedium() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
virtual SfxObjectShell * GetObjectShell() override
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
const SvBaseLinks & GetLinks() const
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void enable_drag_source(rtl::Reference< TransferDataContainer > &rTransferable, sal_uInt8 eDNDConstants)=0
constexpr rtl::OUStringConstExpr aContentBmps[]
IMPL_LINK_NOARG(ScContentTree, ContentDoubleClickHdl, weld::TreeView &, bool)
static OUString lcl_GetDBAreaRange(const ScDocument *pDoc, const OUString &rDBName)
const ScContentId pTypeList[int(ScContentId::LAST)+1]
static bool lcl_DoDragObject(ScDocShell *pSrcShell, std::u16string_view rName, ScContentId nType, weld::TreeView &rTreeView)
const TranslateId SCSTR_CONTENT_ARY[]
IMPL_LINK(ScContentTree, KeyInputHdl, const KeyEvent &, rKEvt, bool)
static OUString lcl_NoteString(const ScPostIt &rNote)
constexpr int MAX_TREE_NODES
static bool lcl_GetRange(const ScDocument &rDoc, ScContentId nType, const OUString &rName, ScRange &rRange)
static bool lcl_DoDragCells(ScDocShell *pSrcShell, const ScRange &rRange, ScDragSrc nFlags, weld::TreeView &rTreeView)
const sal_uLong SC_CONTENT_NOCHILD
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
ScXMLEditAttributeMap::Entry const aEntries[]
EmbeddedObjectRef * pObject
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_F5
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
OUString ScResId(TranslateId aId)
This struct stores general clipboard parameters associated with a ScDocument instance created in clip...