30 #include <osl/diagnose.h>
34 #include <navicfg.hxx>
43 #include <strings.hrc>
44 #include <bitmaps.hlst>
48 #include <uiobject.hxx>
59 OUStringBuffer aEntry(rEntry);
60 for (sal_Int32
i = 0;
i < rEntry.getLength(); ++
i)
61 if(aEntry[
i] == 10 || aEntry[
i] == 9)
64 return aEntry.makeStringAndClear();
83 if(nMove > 1 && nLastOutlinePos < nTarget)
87 nMove -= nLastOutlinePos - nSource;
89 if( nMove < 1 || nLastOutlinePos < nTarget )
109 int nEntryIdx = rBox.get_active();
112 while (nEntryIdx-- && pView)
119 m_xContentTree->ShowHiddenShell():
120 m_xContentTree->ShowActualView();
163 const sal_uInt16 nPageCnt = pSh->
GetPageCnt();
164 sal_uInt16 nPhyPage, nVirPage;
176 SwView *pView = GetCreateView();
183 bool bFocusToDoc =
false;
184 if (rCommand ==
".uno:ScrollToPrevious" || rCommand ==
".uno:ScrollToNext")
186 bool *pbNext =
new bool(
true);
187 if (rCommand ==
".uno:ScrollToPrevious")
189 pView->MoveNavigationHdl(pbNext);
191 else if (rCommand ==
"root")
193 m_xContentTree->ToggleToRoot();
195 else if (rCommand ==
"listbox")
211 else if (rCommand ==
"footer")
224 else if (rCommand ==
"header")
237 else if (rCommand ==
"anchor")
261 else if (rCommand ==
"reminder")
265 else if (rCommand ==
"chapterdown" ||
266 rCommand ==
"movedown" ||
267 rCommand ==
"chapterup" ||
268 rCommand ==
"moveup" ||
269 rCommand ==
"promote" ||
270 rCommand ==
"demote" ||
274 m_xGlobalTree->ExecCommand(rCommand);
279 bool bOutlineWithChildren = (
KEY_MOD1 != m_xContent6ToolBox->get_modifier_state());
280 m_xContentTree->ExecCommand(rCommand, bOutlineWithChildren);
283 else if (rCommand ==
"contenttoggle" || rCommand ==
"globaltoggle")
286 bool bGlobalMode = IsGlobalMode();
287 m_pConfig->SetGlobalActive(bGlobalMode);
288 m_xGlobalToolBox->set_item_active(
"globaltoggle", bGlobalMode);
289 m_xContent1ToolBox->set_item_active(
"contenttoggle", bGlobalMode);
291 else if (rCommand ==
"save")
295 m_xGlobalToolBox->set_item_active(rCommand, !bSave);
297 else if (rCommand ==
"dragmode")
298 m_xContent6ToolBox->set_menu_item_active(
"dragmode", !m_xContent6ToolBox->get_menu_item_active(
"dragmode"));
299 else if (rCommand ==
"headings")
300 m_xContent5ToolBox->set_menu_item_active(
"headings", !m_xContent5ToolBox->get_menu_item_active(
"headings"));
301 else if (rCommand ==
"update")
302 m_xGlobalToolBox->set_menu_item_active(
"update", !m_xGlobalToolBox->get_menu_item_active(
"update"));
303 else if (rCommand ==
"insert")
304 m_xGlobalToolBox->set_menu_item_active(
"insert", !m_xGlobalToolBox->get_menu_item_active(
"insert"));
315 if (!m_xGlobalToolBox->get_menu_item_active(rCommand))
318 if (rCommand ==
"update")
319 m_xGlobalTree->TbxMenuHdl(rCommand, *m_xUpdateMenu);
320 else if (rCommand ==
"insert")
321 m_xGlobalTree->TbxMenuHdl(rCommand, *m_xInsertMenu);
326 if (!m_xContent6ToolBox->get_menu_item_active(rCommand))
329 if (rCommand !=
"dragmode")
332 switch (m_nRegionMode)
335 m_xDragModeMenu->set_active(
"hyperlink",
true);
338 m_xDragModeMenu->set_active(
"link",
true);
341 m_xDragModeMenu->set_active(
"copy",
true);
348 if (rIdent ==
"hyperlink")
350 else if (rIdent ==
"link")
352 else if (rIdent ==
"copy")
358 m_xGlobalTree->ExecuteContextMenuAction(rIdent);
363 if (!m_xContent5ToolBox->get_menu_item_active(rCommand))
366 if (rCommand ==
"headings")
367 m_xHeadingsMenu->set_active(OString::number(m_xContentTree->GetOutlineLevel()),
true);
386 sal_uInt16 nNewPage =
m_xEdit->get_value();
415 pNav->InvalidateChildSizeCache();
416 Size aOptimalSize(pNav->GetOptimalSize());
417 Size aNewSize(pNav->GetOutputSizePixel());
420 pNav->SetOutputSizePixel(aNewSize);
444 pNav->InvalidateChildSizeCache();
445 Size aOptimalSize(pNav->GetOptimalSize());
446 Size aNewSize(pNav->GetOutputSizePixel());
447 aNewSize.
setHeight( aOptimalSize.Height() );
449 pNav->SetOutputSizePixel(aNewSize);
469 const css::uno::Reference<css::frame::XFrame>& rxFrame,
472 if( pParent ==
nullptr )
473 throw css::lang::IllegalArgumentException(
"no parent window given to SwNavigationPI::Create",
nullptr, 0);
475 throw css::lang::IllegalArgumentException(
"no XFrame given to SwNavigationPI::Create",
nullptr, 0);
476 if( pBindings ==
nullptr )
477 throw css::lang::IllegalArgumentException(
"no SfxBindings given to SwNavigationPI::Create",
nullptr, 0);
478 return std::make_unique<SwNavigationPI>(pParent, rxFrame, pBindings,
nullptr);
482 const css::uno::Reference<css::frame::XFrame>& rxFrame,
484 :
PanelLayout(pParent,
"NavigatorPanel",
"modules/swriter/ui/navigatorpanel.ui")
485 , m_aDocFullName(SID_DOCFULLNAME, *_pBindings, *this)
487 , m_xContent1ToolBox(m_xBuilder->weld_toolbar(
"content1"))
488 , m_xContent2ToolBox(m_xBuilder->weld_toolbar(
"content2"))
489 , m_xContent3ToolBox(m_xBuilder->weld_toolbar(
"content3"))
490 , m_xContent4ToolBox(m_xBuilder->weld_toolbar(
"content4"))
491 , m_xContent5ToolBox(m_xBuilder->weld_toolbar(
"content5"))
492 , m_xContent6ToolBox(m_xBuilder->weld_toolbar(
"content6"))
495 , m_xHeadingsMenu(m_xBuilder->weld_menu(
"headingsmenu"))
496 , m_xDragModeMenu(m_xBuilder->weld_menu(
"dragmodemenu"))
497 , m_xUpdateMenu(m_xBuilder->weld_menu(
"updatemenu"))
498 , m_xInsertMenu(m_xBuilder->weld_menu(
"insertmenu"))
499 , m_xGlobalToolBox(m_xBuilder->weld_toolbar(
"global"))
500 , m_xEdit(m_xBuilder->weld_spin_button(
"spinbutton"))
501 , m_xContentBox(m_xBuilder->weld_widget(
"contentbox"))
502 , m_xContentTree(new
SwContentTree(m_xBuilder->weld_tree_view(
"contenttree"), this))
503 , m_xGlobalBox(m_xBuilder->weld_widget(
"globalbox"))
504 , m_xGlobalTree(new
SwGlobalTree(m_xBuilder->weld_tree_view(
"globaltree"), this))
505 , m_xDocListBox(m_xBuilder->weld_combo_box(
"documents"))
506 , m_xNavigatorDlg(pNavigatorDlg)
507 , m_pContentView(nullptr)
508 , m_pContentWrtShell(nullptr)
509 , m_pActContView(nullptr)
510 , m_pCreateView(nullptr)
511 , m_pConfig(
SW_MOD()->GetNavigationConfig())
512 , m_rBindings(*_pBindings)
514 , m_bIsZoomedIn(false)
515 , m_bGlobalMode(false)
538 m_xEdit->set_help_id(
"modules/swriter/ui/navigatorpanel/numericfield");
545 const char* REGIONNAME_ARY[] =
552 const char* REGIONMODE_ARY[] =
615 if (bFloatingNavigator)
618 else if (bFloatingNavigator)
653 (*m_pxObjectShell)->DoClose();
686 if (nSID == SID_DOCFULLNAME)
751 if (rHint.
GetId() == SfxHintId::Dying)
759 if (
const SfxEventHint* pHint = dynamic_cast<const SfxEventHint*>(&rHint))
762 if (eEventId == SfxEventHintId::OpenDoc)
784 if (!rMenuId.isEmpty())
785 m_xContentTree->SetOutlineLevel(rMenuId.toUInt32());
796 bool bDisable = pActView ==
nullptr;
800 sal_Int32 nConstPos = 0;
811 OUString sEntry = pDoc->
GetTitle() +
" (";
812 if (pView == pActView)
822 if (pConstView && pView == pConstView)
835 GetDocShell()->GetTitle() +
869 m_xContentTree->clear();
871 OSL_ENSURE(m_pContentView,
"no SwView");
873 m_pContentWrtShell = m_pContentView->GetWrtShellPtr();
875 m_pContentWrtShell =
nullptr;
885 if( rData.
HasFormat( nFormat = SotClipboardFormatId::FILE_LIST ))
889 sFileName = aFileList.
GetFile( 0 );
891 else if( rData.
HasFormat( nFormat = SotClipboardFormatId::STRING ) ||
892 rData.
HasFormat( nFormat = SotClipboardFormatId::SIMPLE_FILE ) ||
893 rData.
HasFormat( nFormat = SotClipboardFormatId::FILENAME ))
897 else if( rData.
HasFormat( nFormat = SotClipboardFormatId::SOLK ) ||
898 rData.
HasFormat( nFormat = SotClipboardFormatId::NETSCAPE_BOOKMARK )||
899 rData.
HasFormat( nFormat = SotClipboardFormatId::FILECONTENT ) ||
900 rData.
HasFormat( nFormat = SotClipboardFormatId::FILEGRPDESCRIPTOR ) ||
901 rData.
HasFormat( nFormat = SotClipboardFormatId::UNIFORMRESOURCELOCATOR ))
905 sFileName = aBkmk.
GetURL();
907 if( !sFileName.isEmpty() )
917 (
m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
918 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::STRING ) ||
919 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
920 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK )||
921 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILECONTENT ) ||
922 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) ||
923 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
924 m_xContentTree->IsDropFormatSupported( SotClipboardFormatId::FILENAME )))
937 if (sFileName.isEmpty())
945 if (-1 != sFileName.indexOf(
'#'))
956 (*m_pxObjectShell)->DoClose();
964 SID_OPENDOC, SfxCallMode::ASYNCHRON,
965 { &aFileItem, &aOptionsItem, &aLink });
979 sImageId = RID_BMP_DROP_REGION;
982 sImageId = RID_BMP_DROP_LINK;
985 sImageId = RID_BMP_DROP_COPY;
1061 m_pCreateView->GetEditWin().GrabFocus();
1067 if (m_aPageChgIdle.IsActive())
1068 m_aPageChgIdle.Stop();
1069 m_aPageChgIdle.Start();
1120 m_xNavi->m_xContentTree->SetRootType(nRootType);
1121 m_xNavi->m_xContent5ToolBox->set_item_active(
"root",
true);
1124 m_xNavi->m_xContentTree->set_selection_mode(SelectionMode::Multiple);
1138 if (nStateChange == StateChangedType::InitShow)
std::unique_ptr< weld::Widget > m_xContentBox
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OString stripEnd(const OString &rIn, char c)
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
::sfx2::sidebar::ControllerItem m_aPageStats
SwNavigationConfig * m_pConfig
std::unique_ptr< weld::Menu > m_xUpdateMenu
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 * >())
bool IsGlobalActive() const
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
bool EndPg(bool bSelect=false)
#define HID_NAVIGATOR_GLOBAL_TOOLBOX
void SetMinOutputSizePixel(const Size &rSize)
constexpr sal_uInt16 KEY_MOD1
OUString GetTitle(sal_uInt16 nMaxLen=0) const
virtual ~SwNavigationPI() override
void SetRegionDropMode(RegionMode nNewMode)
bool GotoNextFootnoteAnchor()
std::unique_ptr< weld::Widget > m_xGlobalBox
bool IsAllProtect() const
void SetGlobalMode(bool bSet)
std::vector< SwNode * >::difference_type difference_type
SfxDispatcher * GetDispatcher()
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
SwNavigatorWin(SfxBindings *_pBindings, SfxChildWindow *_pMgr, vcl::Window *pParent)
std::unique_ptr< weld::Menu > m_xHeadingsMenu
SwWrtShell * GetActiveWrtShell()
std::unique_ptr< weld::Toolbar > m_xContent1ToolBox
std::unique_ptr< weld::Toolbar > m_xGlobalToolBox
std::unique_ptr< weld::Toolbar > m_xContent6ToolBox
void GetPageNum(sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, bool bAtCursorPos=true, const bool bCalcFrame=true)
void SetWindow(const VclPtr< vcl::Window > &p)
bool GotoFootnoteAnchor()
jump from footnote to anchor
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
#define HID_NAVIGATOR_TOOLBOX
void Invalidate(sal_uInt16 nId)
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk)
bool GotoHeaderText()
jump from the content to the header
virtual SfxObjectShell * GetObjectShell() override
bool HasFormat(SotClipboardFormatId nFormat) const
static void lcl_UnSelectFrame(SwWrtShell *pSh)
SwWrtShell & GetWrtShell() const
bool MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren, bool bKillPams=true)
SfxApplication * SfxGetpApp()
Used by the UI to modify the document model.
std::unique_ptr< weld::Toolbar > m_xContent4ToolBox
Reference< XNameAccess > m_xContainer
const SwView & GetView() const
std::unique_ptr< weld::ComboBox > m_xDocListBox
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 (...
::sfx2::sidebar::ControllerItem m_aDocFullName
bool GotoFootnoteText()
jump from content to footnote
bool IsGlblDocSaveLinks() const
TreeListBox for content indicator.
ContentTypeId GetRootType() const
static OUString CreateDropFileName(TransferableDataHelper &rData)
std::unique_ptr< SwContentTree > m_xContentTree
SwWrtShell * m_pContentWrtShell
RegionMode GetRegionMode() const
constexpr OUStringLiteral aData
#define SAL_N_ELEMENTS(arr)
IMPL_LINK(SwNavigationPI, DocListBoxSelectHdl, weld::ComboBox &, rBox, void)
virtual void StateChanged(StateChangedType nStateChange) override
std::unique_ptr< SwGlobalTree > m_xGlobalTree
static constexpr auto npos
IMPL_LINK_NOARG(SwNavigationPI, SetFocusChildHdl, weld::Container &, void)
static OUString CleanEntry(const OUString &rEntry)
std::unique_ptr< weld::Menu > m_xDragModeMenu
SwNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem *pState) override
#define HID_NAVIGATOR_LISTBOX
SfxBindings & GetBindings()
bool IsGlobalMode() const
FrameTypeFlags
values can be combined via logical or
std::unique_ptr< weld::Toolbar > m_xContent5ToolBox
OUString m_sContentFileName
static SwView * GetFirstView()
std::unique_ptr< weld::Toolbar > m_xContent3ToolBox
OUString GetFile(size_t nIndex) const
virtual void dispose() override
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
OUString SwResId(const char *pId)
SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel=UCHAR_MAX, SwPaM *pPaM=nullptr)
search "outline position" before previous outline node at given level
VclPtr< SfxNavigator > m_xNavigatorDlg
SfxViewShell * GetViewShell() const
SFX_IMPL_DOCKINGWINDOW(SwNavigatorWrapper, SID_NAVIGATOR)
SwDocShell * GetDocShell()
virtual weld::Window * GetFrameWeld() const override
virtual void StateChanged(StateChangedType nStateChange) override
std::unique_ptr< ToolbarUnoDispatcher > m_xContent2Dispatch
bool SttPg(bool bSelect=false)
bool GotoPrevFootnoteAnchor()
SwView * GetCreateView() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SwWrtShell * GetWrtShellPtr() const
SwNavigationPI(weld::Widget *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *_pBindings, SfxNavigator *pNavigatorDlg)
void Initialize(SfxChildWinInfo *pInfo)
SfxViewFrame * GetFrame() const
void MoveCursor(bool bWithSelect=false)
constexpr tools::Long Height() const
bool IsCursorPtAtEnd() const
std::unique_ptr< weld::Toolbar > m_xContent2ToolBox
bool IsHelpDocument() const
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
sal_Int32 GetOutlineLevel() const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList)
void GotoOutline(SwOutlineNodes::size_type nIdx)
const OUString & GetURL() const
void SetInvokeHandler(const Link< Timer *, void > &rLink)
static SwView * GetNextView(SwView const *)
SfxBindings & m_rBindings
void setHeight(tools::Long nHeight)
bool GotoPage(sal_uInt16 nPage, bool bRecord)
virtual weld::Window * GetFrameWeld() const
reference_type * get() const
void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget)
void SetPriority(TaskPriority ePriority)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
std::unique_ptr< weld::SpinButton > m_xEdit
bool MoveOutlinePara(SwOutlineNodes::difference_type nOffset)
void SetRegionMode(RegionMode nSet)
bool Detect(bool bExtendedInfo=false)
std::vector< SwNode * >::size_type size_type
virtual void dispose() override
std::unique_ptr< SwNavigationPI > m_xNavi
#define FN_FOOTNOTE_TO_ANCHOR
std::unique_ptr< weld::Menu > m_xInsertMenu
std::unique_ptr< ToolbarUnoDispatcher > m_xContent3Dispatch
void SetReadOnlyUI(bool bReadOnly=true)
std::unique_ptr< weld::Container > m_xContainer
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
bool IsFrameSelected() const
void SetGlblDocSaveLinks(bool bFlag)
std::unique_ptr< SfxObjectShellLock > m_pxObjectShell
bool ParentIsFloatingWindow(vcl::Window *pParent)
bool GotoFooterText()
jump from the content to the footer
virtual ~SwNavigatorWin() override
bool IsGlobalDoc() const
Interfaces for GlobalDocument.