30#include <osl/diagnose.h>
44#include <bitmaps.hlst>
61 OUStringBuffer aEntry(rEntry);
62 for (sal_Int32
i = 0;
i < rEntry.getLength(); ++
i)
63 if(aEntry[
i] == 10 || aEntry[
i] == 9)
66 return aEntry.makeStringAndClear();
85 if(nMove > 1 && nLastOutlinePos < nTarget)
89 nMove -= nLastOutlinePos - nSource;
91 if( nMove < 1 || nLastOutlinePos < nTarget )
111 int nEntryIdx = rBox.get_active();
114 while (nEntryIdx-- && pView)
121 m_xContentTree->ShowHiddenShell():
122 m_xContentTree->ShowActualView();
143 m_xContentTree->SelectContentType(rComboBox.get_active_text());
183 const sal_uInt16 nPageCnt = pSh->
GetPageCnt();
184 sal_uInt16 nPhyPage, nVirPage;
196 SwView *pView = GetCreateView();
203 bool bFocusToDoc =
false;
204 if (rCommand ==
".uno:ScrollToPrevious" || rCommand ==
".uno:ScrollToNext")
206 bool *pbNext =
new bool(
true);
207 if (rCommand ==
".uno:ScrollToPrevious")
209 pView->MoveNavigationHdl(pbNext);
211 else if (rCommand ==
"root")
213 m_xContentTree->ToggleToRoot();
215 else if (rCommand ==
"listbox")
231 else if (rCommand ==
"footer")
244 else if (rCommand ==
"header")
257 else if (rCommand ==
"anchor")
281 else if (rCommand ==
"reminder")
285 else if (rCommand ==
"chapterdown" ||
286 rCommand ==
"movedown" ||
287 rCommand ==
"chapterup" ||
288 rCommand ==
"moveup" ||
289 rCommand ==
"promote" ||
290 rCommand ==
"demote" ||
294 m_xGlobalTree->ExecCommand(rCommand);
299 bool bOutlineWithChildren = (
KEY_MOD1 != m_xContent6ToolBox->get_modifier_state());
300 m_xContentTree->ExecCommand(rCommand, bOutlineWithChildren);
303 else if (rCommand ==
"contenttoggle" || rCommand ==
"globaltoggle")
306 bool bGlobalMode = IsGlobalMode();
307 m_pConfig->SetGlobalActive(bGlobalMode);
308 m_xGlobalToolBox->set_item_active(
"globaltoggle", bGlobalMode);
309 m_xContent1ToolBox->set_item_active(
"contenttoggle", bGlobalMode);
311 else if (rCommand ==
"save")
315 m_xGlobalToolBox->set_item_active(rCommand, !bSave);
317 else if (rCommand ==
"dragmode")
318 m_xContent6ToolBox->set_menu_item_active(
"dragmode", !m_xContent6ToolBox->get_menu_item_active(
"dragmode"));
319 else if (rCommand ==
"headings")
320 m_xContent5ToolBox->set_menu_item_active(
"headings", !m_xContent5ToolBox->get_menu_item_active(
"headings"));
321 else if (rCommand ==
"update")
322 m_xGlobalToolBox->set_menu_item_active(
"update", !m_xGlobalToolBox->get_menu_item_active(
"update"));
323 else if (rCommand ==
"insert")
324 m_xGlobalToolBox->set_menu_item_active(
"insert", !m_xGlobalToolBox->get_menu_item_active(
"insert"));
335 if (!m_xGlobalToolBox->get_menu_item_active(rCommand))
338 if (rCommand ==
"update")
339 m_xGlobalTree->TbxMenuHdl(rCommand, *m_xUpdateMenu);
340 else if (rCommand ==
"insert")
341 m_xGlobalTree->TbxMenuHdl(rCommand, *m_xInsertMenu);
346 if (!m_xContent6ToolBox->get_menu_item_active(rCommand))
349 if (rCommand !=
"dragmode")
352 switch (m_nRegionMode)
354 case RegionMode::NONE:
355 m_xDragModeMenu->set_active(
"hyperlink",
true);
357 case RegionMode::LINK:
358 m_xDragModeMenu->set_active(
"link",
true);
360 case RegionMode::EMBEDDED:
361 m_xDragModeMenu->set_active(
"copy",
true);
368 if (rIdent ==
"hyperlink")
369 SetRegionDropMode(RegionMode::NONE);
370 else if (rIdent ==
"link")
371 SetRegionDropMode(RegionMode::LINK);
372 else if (rIdent ==
"copy")
373 SetRegionDropMode(RegionMode::EMBEDDED);
378 m_xGlobalTree->ExecuteContextMenuAction(rIdent);
383 if (!m_xContent5ToolBox->get_menu_item_active(rCommand))
386 if (rCommand ==
"headings")
387 m_xHeadingsMenu->set_active(OString::number(m_xContentTree->GetOutlineLevel()),
true);
406 sal_uInt16 nNewPage =
m_xEdit->get_value();
435 pNav->InvalidateChildSizeCache();
436 Size aOptimalSize(pNav->GetOptimalSize());
437 Size aNewSize(pNav->GetOutputSizePixel());
440 pNav->SetOutputSizePixel(aNewSize);
464 pNav->InvalidateChildSizeCache();
465 Size aOptimalSize(pNav->GetOptimalSize());
466 Size aNewSize(pNav->GetOutputSizePixel());
469 pNav->SetOutputSizePixel(aNewSize);
489 const css::uno::Reference<css::frame::XFrame>& rxFrame,
492 if( pParent ==
nullptr )
493 throw css::lang::IllegalArgumentException(
"no parent window given to SwNavigationPI::Create",
nullptr, 0);
495 throw css::lang::IllegalArgumentException(
"no XFrame given to SwNavigationPI::Create",
nullptr, 0);
496 if( pBindings ==
nullptr )
497 throw css::lang::IllegalArgumentException(
"no SfxBindings given to SwNavigationPI::Create",
nullptr, 0);
498 return std::make_unique<SwNavigationPI>(pParent, rxFrame, pBindings,
nullptr);
502 const css::uno::Reference<css::frame::XFrame>& rxFrame,
504 :
PanelLayout(pParent,
"NavigatorPanel",
"modules/swriter/ui/navigatorpanel.ui")
505 , m_aDocFullName(SID_DOCFULLNAME, *_pBindings, *this)
507 , m_xContent1ToolBox(m_xBuilder->weld_toolbar(
"content1"))
508 , m_xContent2ToolBox(m_xBuilder->weld_toolbar(
"content2"))
509 , m_xContent3ToolBox(m_xBuilder->weld_toolbar(
"content3"))
510 , m_xContent4ToolBox(m_xBuilder->weld_toolbar(
"content4"))
511 , m_xContent5ToolBox(m_xBuilder->weld_toolbar(
"content5"))
512 , m_xContent6ToolBox(m_xBuilder->weld_toolbar(
"content6"))
515 , m_xHeadingsMenu(m_xBuilder->weld_menu(
"headingsmenu"))
516 , m_xDragModeMenu(m_xBuilder->weld_menu(
"dragmodemenu"))
517 , m_xUpdateMenu(m_xBuilder->weld_menu(
"updatemenu"))
518 , m_xInsertMenu(m_xBuilder->weld_menu(
"insertmenu"))
519 , m_xGlobalToolBox(m_xBuilder->weld_toolbar(
"global"))
520 , m_xEdit(m_xBuilder->weld_spin_button(
"spinbutton"))
521 , m_xContentBox(m_xBuilder->weld_widget(
"contentbox"))
522 , m_xContentTree(new
SwContentTree(m_xBuilder->weld_tree_view(
"contenttree"), this))
523 , m_xGlobalBox(m_xBuilder->weld_widget(
"globalbox"))
524 , m_xGlobalTree(new
SwGlobalTree(m_xBuilder->weld_tree_view(
"globaltree"), this))
525 , m_xDocListBox(m_xBuilder->weld_combo_box(
"documents"))
526 , m_aPageChgIdle(
"SwNavigationPI m_aPageChgIdle")
527 , m_xNavigatorDlg(pNavigatorDlg)
528 , m_pContentView(nullptr)
529 , m_pContentWrtShell(nullptr)
530 , m_pActContView(nullptr)
531 , m_pCreateView(nullptr)
532 , m_pConfig(
SW_MOD()->GetNavigationConfig())
533 , m_rBindings(*_pBindings)
535 , m_bIsZoomedIn(false)
536 , m_bGlobalMode(false)
544 assert(pToolBoxControl);
591 m_xEdit->set_help_id(
"modules/swriter/ui/navigatorpanel/numericfield");
613 static_assert(
SAL_N_ELEMENTS(REGIONNAME_ARY) ==
static_cast<sal_uInt16
>(RegionMode::EMBEDDED) + 1,
"### unexpected size!");
615 for (sal_uInt16
i = 0; i <= static_cast<sal_uInt16>(RegionMode::EMBEDDED); ++
i)
671 if (bFloatingNavigator)
674 else if (bFloatingNavigator)
709 (*m_oObjectShell)->DoClose();
742 if (nSID == SID_DOCFULLNAME)
804 if (rHint.
GetId() == SfxHintId::Dying)
816 if (eEventId == SfxEventHintId::OpenDoc)
838 if (!rMenuId.isEmpty())
839 m_xContentTree->SetOutlineLevel(rMenuId.toUInt32());
850 bool bDisable = pActView ==
nullptr;
854 sal_Int32 nConstPos = 0;
865 OUString sEntry = pDoc->
GetTitle() +
" (";
866 if (pView == pActView)
876 if (pConstView && pView == pConstView)
889 GetDocShell()->GetTitle() +
923 m_xContentTree->clear();
925 OSL_ENSURE(m_pContentView,
"no SwView");
927 m_pContentWrtShell = m_pContentView->GetWrtShellPtr();
929 m_pContentWrtShell =
nullptr;
939 if( rData.
HasFormat( nFormat = SotClipboardFormatId::FILE_LIST ))
943 sFileName = aFileList.
GetFile( 0 );
945 else if( rData.
HasFormat( nFormat = SotClipboardFormatId::STRING ) ||
946 rData.
HasFormat( nFormat = SotClipboardFormatId::SIMPLE_FILE ) ||
947 rData.
HasFormat( nFormat = SotClipboardFormatId::FILENAME ))
949 (void)rData.
GetString(nFormat, sFileName);
951 else if( rData.
HasFormat( nFormat = SotClipboardFormatId::SOLK ) ||
952 rData.
HasFormat( nFormat = SotClipboardFormatId::NETSCAPE_BOOKMARK )||
953 rData.
HasFormat( nFormat = SotClipboardFormatId::FILECONTENT ) ||
954 rData.
HasFormat( nFormat = SotClipboardFormatId::FILEGRPDESCRIPTOR ) ||
955 rData.
HasFormat( nFormat = SotClipboardFormatId::UNIFORMRESOURCELOCATOR ))
959 sFileName = aBkmk.
GetURL();
961 if( !sFileName.isEmpty() )
971 (
m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
972 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::STRING ) ||
973 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
974 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK )||
975 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILECONTENT ) ||
976 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) ||
977 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
978 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILENAME )))
991 if (sFileName.isEmpty())
999 if (-1 != sFileName.indexOf(
'#'))
1010 (*m_oObjectShell)->DoClose();
1018 pView->GetViewFrame().GetDispatcher()->ExecuteList(
1019 SID_OPENDOC, SfxCallMode::ASYNCHRON,
1020 { &aFileItem, &aOptionsItem, &aLink });
1033 case RegionMode::NONE:
1034 sImageId = RID_BMP_DROP_REGION;
1036 case RegionMode::LINK:
1037 sImageId = RID_BMP_DROP_LINK;
1039 case RegionMode::EMBEDDED:
1040 sImageId = RID_BMP_DROP_COPY;
1125 m_pCreateView->GetEditWin().GrabFocus();
1131 if (m_aPageChgIdle.IsActive())
1132 m_aPageChgIdle.Stop();
1133 m_aPageChgIdle.Start();
1191 if (nStateChange == StateChangedType::InitShow)
SfxApplication * SfxGetpApp()
SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent)
OUString GetFile(size_t nIndex) const
bool Detect(bool bExtendedInfo=false)
const OUString & GetURL() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual weld::Window * GetFrameWeld() const
std::unique_ptr< weld::Container > m_xContainer
void Invalidate(sal_uInt16 nId)
void SetWindow(const VclPtr< vcl::Window > &p)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual void StateChanged(StateChangedType nStateChange) override
virtual void dispose() override
void SetMinOutputSizePixel(const Size &rSize)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
void SetReadOnlyUI(bool bReadOnly=true)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
bool IsHelpDocument() const
SfxViewFrame * GetFrame() const
SfxViewShell * GetViewShell() const
SfxViewFrame * GetFrame() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
virtual SfxObjectShell * GetObjectShell() override
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
void setHeight(tools::Long nHeight)
TreeListBox for content indicator.
bool GotoNextFootnoteAnchor()
bool GotoHeaderText()
jump from the content to the header
void MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren, bool bKillPams=true)
void GetPageNum(sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, bool bAtCursorPos=true, const bool bCalcFrame=true)
bool GotoFootnoteText()
jump from content to footnote
bool GotoPrevFootnoteAnchor()
SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel=UCHAR_MAX, SwPaM *pPaM=nullptr)
search "outline position" before previous outline node at given level
bool IsCursorPtAtEnd() const
bool GotoFooterText()
jump from the content to the footer
bool IsAllProtect() const
void SetGlblDocSaveLinks(bool bFlag)
bool IsGlblDocSaveLinks() const
bool IsOutlineMovable(SwOutlineNodes::size_type nIdx) const
May an outline be moved or copied? Check whether it's in text body, not in table, and not read-only (...
bool MoveOutlinePara(SwOutlineNodes::difference_type nOffset)
bool IsGlobalDoc() const
Interfaces for GlobalDocument.
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
bool IsFrameSelected() const
static SwView * GetNextView(SwView const *)
static SwView * GetFirstView()
sal_Int32 GetOutlineLevel() const
sal_Int32 GetOutlineTracking() const
bool IsGlobalActive() const
RegionMode GetRegionMode() const
bool IsContentTypeTrack(ContentTypeId eCntTypeId)
void SetRegionMode(RegionMode nSet)
ContentTypeId GetRootType() const
SfxBindings & m_rBindings
SwNavigationPI(weld::Widget *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *_pBindings, SfxNavigator *pNavigatorDlg)
std::unique_ptr< weld::Widget > m_xGlobalBox
virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem *pState) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
void SetGlobalMode(bool bSet)
weld::ComboBox * m_pNavigateByComboBox
std::unique_ptr< weld::Toolbar > m_xContent4ToolBox
SwView * GetCreateView() const
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
bool IsGlobalMode() const
std::optional< SfxObjectShellLock > m_oObjectShell
static OUString CreateDropFileName(const TransferableDataHelper &rData)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
virtual ~SwNavigationPI() override
std::unique_ptr< weld::Toolbar > m_xContent1ToolBox
std::unique_ptr< weld::Toolbar > m_xGlobalToolBox
std::unique_ptr< weld::Toolbar > m_xContent2ToolBox
std::unique_ptr< ToolbarUnoDispatcher > m_xContent3Dispatch
std::unique_ptr< weld::SpinButton > m_xEdit
std::unique_ptr< SwContentTree > m_xContentTree
void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget)
std::unique_ptr< weld::Menu > m_xDragModeMenu
std::unique_ptr< weld::Menu > m_xUpdateMenu
std::unique_ptr< weld::Toolbar > m_xContent3ToolBox
SwNavigationConfig * m_pConfig
virtual weld::Window * GetFrameWeld() const override
std::unique_ptr< weld::Toolbar > m_xContent5ToolBox
::sfx2::sidebar::ControllerItem m_aDocFullName
VclPtr< SfxNavigator > m_xNavigatorDlg
static OUString CleanEntry(const OUString &rEntry)
void SelectNavigateByContentType(const OUString &rContentTypeName)
void SetRegionDropMode(RegionMode nNewMode)
SwWrtShell * m_pContentWrtShell
std::unique_ptr< weld::Menu > m_xInsertMenu
std::unique_ptr< weld::Menu > m_xHeadingsMenu
std::unique_ptr< SwGlobalTree > m_xGlobalTree
OUString m_sContentFileName
std::unique_ptr< ToolbarUnoDispatcher > m_xContent2Dispatch
std::unique_ptr< weld::Widget > m_xContentBox
::sfx2::sidebar::ControllerItem m_aPageStats
std::unique_ptr< weld::ComboBox > m_xDocListBox
std::unique_ptr< weld::Toolbar > m_xContent6ToolBox
virtual void dispose() override
SwNavigatorWin(SfxBindings *_pBindings, SfxChildWindow *_pMgr, vcl::Window *pParent, SfxChildWinInfo *pInfo)
virtual ~SwNavigatorWin() override
virtual void StateChanged(StateChangedType nStateChange) override
std::unique_ptr< SwNavigationPI > m_xNavi
SwNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
static constexpr auto npos
SwWrtShell & GetWrtShell() const
SwWrtShell * GetWrtShellPtr() const
SwDocShell * GetDocShell()
Used by the UI to modify the document model.
bool EndPg(bool bSelect=false)
bool GotoPage(sal_uInt16 nPage, bool bRecord)
bool SttPg(bool bSelect=false)
void GotoFootnoteAnchor(const SwTextFootnote &rTextFootnote)
void GotoOutline(SwOutlineNodes::size_type nIdx)
void MoveCursor(bool bWithSelect=false)
const SwView & GetView() const
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList) const
bool HasFormat(SotClipboardFormatId nFormat) const
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk) const
reference_type * get() const
std::vector< Value >::difference_type difference_type
std::vector< Value >::size_type size_type
virtual int find_text(const OUString &rStr) const=0
virtual OUString get_active_id() const=0
virtual void set_active(int pos)=0
void connect_changed(const Link< ComboBox &, void > &rLink)
#define FN_FOOTNOTE_TO_ANCHOR
FrameTypeFlags
values can be combined via logical or
constexpr OStringLiteral HID_NAVIGATOR_LISTBOX
constexpr OStringLiteral HID_NAVIGATOR_GLOBAL_TOOLBOX
constexpr OStringLiteral HID_NAVIGATOR_TOOLBOX
constexpr sal_uInt16 KEY_MOD1
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
constexpr OUStringLiteral aData
OString stripEnd(const OString &rIn, char c)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IMPL_LINK(SwNavigationPI, DocListBoxSelectHdl, weld::ComboBox &, rBox, void)
static void lcl_UnSelectFrame(SwWrtShell *pSh)
SFX_IMPL_DOCKINGWINDOW(SwNavigatorWrapper, SID_NAVIGATOR)
IMPL_LINK_NOARG(SwNavigationPI, SetFocusChildHdl, weld::Container &, void)
Reference< XNameAccess > m_xContainer
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
Reference< XController > xController
OUString SwResId(TranslateId aId)
constexpr sal_uInt8 MAXLEVEL