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 )
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());
325 GetEntryIndexes(
nType, nChild, xEntry.get());
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());
440 GetEntryIndexes(
nType, nChild, xEntry.get());
460 if ( bIsInNavigatorDlg )
467 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
470 GetEntryIndexes(
nType, nChild, xEntry.get());
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.toUtf8(),
true);
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));
631 aHelpText = OUString::number(
m_xTreeView->iter_n_children(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 OUString aText = rNote.
GetText();
945 while ( (nAt = aText.indexOf(
'\n' )) != -1 )
946 aText = aText.replaceAt( nAt, 1,
u" " );
960 std::vector<sc::NoteEntry>
aEntries;
990 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
993 std::vector<sc::NoteEntry>
aEntries;
997 const ScPostIt* pNote = rEntry.mpNote;
1020 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
1021 bool bEntry =
m_xTreeView->iter_children(*xEntry);
1029 if (pDrawLayer && pShell)
1032 for (
SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
1034 SdrPage* pPage = pDrawLayer->
GetPage(
static_cast<sal_uInt16
>(nTab));
1035 OSL_ENSURE(pPage,
"Page ?");
1068 bool bFound =
false;
1076 if (
p &&
p->IsValidReference(rRange))
1091 p->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
1092 rRange =
ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab);
1103 bool bDisallow =
true;
1111 SdrObjKind nDrawId = bOle ? SdrObjKind::OLE2 : ( bGraf ? SdrObjKind::Graphic : SdrObjKind::Group );
1127 if(SdrObjKind::OLE2 ==
pObject->GetObjIdentifier())
1130 aDragShellRef->DoInitNew();
1144 pTransferObj->SetDragSourceObj( *
pObject, nTab );
1147 SC_MOD()->SetDragObject(
nullptr, pTransferObj.get() );
1161 bool bDisallow =
true;
1174 rSrcDoc.
CopyToClip(aClipParam, pClipDoc.get(), &aMark,
false,
false);
1184 pTransferObj->SetDragSource( pSrcShell, aMark );
1185 pTransferObj->SetDragSourceFlags( nFlags );
1187 SC_MOD()->SetDragObject( pTransferObj.get(),
nullptr );
1200 rUnsetDragIcon =
true;
1202 StoreNavigatorSettings();
1204 bool bDisallow =
true;
1206 std::unique_ptr<ScDocumentLoader> pDocLoader;
1213 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
1217 GetEntryIndexes(
nType, nChild, xEntry.get());
1230 aDocName = aHiddenName;
1243 bool bDoLinkTrans =
false;
1247 sal_uInt16 nDropMode = pParentWindow->GetDropMode();
1248 switch ( nDropMode )
1252 OUString aUrl = aDocName +
"#" + aText;
1256 if (!aDocName.isEmpty())
1264 bDoLinkTrans =
true;
1269 if ( !aDocName.isEmpty() )
1276 pScMod->
SetDragLink( aDocName, aText, OUString() );
1277 bDoLinkTrans =
true;
1281 pScMod->
SetDragLink( aDocName, OUString(), aText );
1282 bDoLinkTrans =
true;
1296 OUString aFilter, aOptions;
1297 OUString
aURL = aHiddenName;
1299 if (!pDocLoader->IsError())
1300 pSrcShell = pDocLoader->GetDocShell();
1303 pSrcShell = GetManualOrCurrent();
1319 if ( rSrcDoc.
GetTable( aText, nTab ) )
1340 if (!aLinkURL.isEmpty())
1341 m_xTransferObj->SetLinkURL(aLinkURL, aLinkText);
1355 OUString aDocName = rUrl;
1356 sal_Int32
nPos = aDocName.indexOf(
'#');
1358 aDocName = aDocName.copy(0,
nPos);
1360 OUString
aURL = aDocName;
1361 OUString aFilter, aOptions;
1397 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator());
1400 std::unique_ptr<weld::TreeIter> xParent(
m_xTreeView->make_iterator(xEntry.get()));
1430 bool bRefreshed =
false;
1485 OUString aRealName = rName;
1486 sal_Int32 nLen = rName.getLength();
1489 aRealName = rName.copy( 0, nActiveStart );
1492 aRealName = rName.copy( 0, nNotActiveStart );
1494 bool bLoaded =
false;
1499 while ( pSh && !bLoaded )
1501 if (
dynamic_cast<const ScDocShell*
>( pSh) !=
nullptr )
1502 if ( pSh->
GetTitle() == aRealName )
1519 OSL_FAIL(
"SelectDoc: not found");
1527 if (pParent || !
m_xTreeView->iter_has_child(*pParent))
1530 std::unique_ptr<weld::TreeIter> xEntry(
m_xTreeView->make_iterator(pParent));
1531 bool bEntry =
m_xTreeView->iter_children(*xEntry);
1590 if( nRootSel == nEntry )
1592 std::unique_ptr<weld::TreeIter> xEntry;
1625 std::unique_ptr<weld::TreeIter> xCurEntry(
m_xTreeView->make_iterator());
std::unique_ptr< weld::TreeView > m_xTreeView
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
SdrModel * GetModel() const
SdrPageView * GetSdrPageView() const
const INetURLObject & GetURLObject() const
const OUString & GetName() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
static 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 SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static SfxObjectShell * Current()
virtual SfxObjectShell * GetObjectShell() override
SfxViewFrame * GetViewFrame() const
static SfxViewShell * Current()
const SvBaseLinks & GetLinks() const
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void enable_drag_source(rtl::Reference< TransferDataContainer > &rTransferrable, 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...