1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_NAVIPI_HXX 20 #define INCLUDED_SW_SOURCE_UIBASE_INC_NAVIPI_HXX 21 22 #include <vcl/idle.hxx> 23 #include <svl/lstner.hxx> 24 #include <vcl/transfer.hxx> 25 #include <sfx2/childwin.hxx> 26 #include <sfx2/objsh.hxx> 27 #include <sfx2/sidebar/ControllerItem.hxx> 28 #include <sfx2/navigat.hxx> 29 #include <sfx2/weldutils.hxx> 30 #include <sfx2/sidebar/PanelLayout.hxx> 31 #include "conttree.hxx" 32 #include <ndarr.hxx> 33 #include <memory> 34 #include <optional> 35 36 class SwWrtShell; 37 class SfxBindings; 38 class SwNavigationConfig; 39 class SwView; 40 41 class SwNavigationPI final : public PanelLayout 42 , public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface 43 , public SfxListener 44 { 45 friend class SwNavigatorWin; 46 friend class SwContentTree; 47 friend class SwGlobalTree; 48 friend class SwView; 49 50 ::sfx2::sidebar::ControllerItem m_aDocFullName; 51 ::sfx2::sidebar::ControllerItem m_aPageStats; 52 ::sfx2::sidebar::ControllerItem m_aNavElement; 53 54 css::uno::Reference<css::frame::XFrame> m_xFrame; 55 56 std::unique_ptr<weld::Toolbar> m_xContent1ToolBox; 57 std::unique_ptr<weld::Toolbar> m_xContent2ToolBox; 58 std::unique_ptr<weld::Toolbar> m_xContent3ToolBox; 59 std::unique_ptr<weld::Toolbar> m_xContent4ToolBox; 60 std::unique_ptr<weld::Toolbar> m_xContent5ToolBox; 61 std::unique_ptr<weld::Toolbar> m_xContent6ToolBox; 62 std::unique_ptr<ToolbarUnoDispatcher> m_xContent2Dispatch; 63 std::unique_ptr<ToolbarUnoDispatcher> m_xContent3Dispatch; 64 std::unique_ptr<weld::Menu> m_xHeadingsMenu; 65 std::unique_ptr<weld::Menu> m_xUpdateMenu; 66 std::unique_ptr<weld::Menu> m_xInsertMenu; 67 std::unique_ptr<weld::Toolbar> m_xGlobalToolBox; 68 std::unique_ptr<weld::SpinButton> m_xGotoPageSpinButton; 69 std::unique_ptr<weld::Widget> m_xContentBox; 70 std::unique_ptr<SwContentTree> m_xContentTree; 71 std::unique_ptr<weld::Widget> m_xGlobalBox; 72 std::unique_ptr<SwGlobalTree> m_xGlobalTree; 73 std::unique_ptr<weld::ComboBox> m_xDocListBox; 74 OUString m_sContentFileName; 75 76 VclPtr<SfxNavigator> m_xNavigatorDlg; 77 78 std::optional<SfxObjectShellLock> m_oObjectShell; 79 SwView *m_pContentView; 80 SwWrtShell *m_pContentWrtShell; 81 SwView *m_pActContView; 82 SwView *m_pCreateView; 83 84 SwNavigationConfig *m_pConfig; 85 SfxBindings &m_rBindings; 86 87 Size m_aExpandedSize; 88 89 bool m_bIsZoomedIn : 1; 90 bool m_bGlobalMode : 1; 91 92 weld::ComboBox* m_pNavigateByComboBox; 93 94 std::unique_ptr<weld::Toolbar> m_xHeadingsContentFunctionsToolbar; 95 std::unique_ptr<weld::Toolbar> m_xDeleteFunctionToolbar; 96 std::unordered_map<ContentTypeId, std::unique_ptr<weld::Toolbar>> m_aContentTypeUnoToolbarMap; 97 std::unordered_map<ContentTypeId, std::unique_ptr<ToolbarUnoDispatcher>> m_aContentTypeToolbarUnoDispatcherMap; 98 std::unordered_map<ContentTypeId, std::unique_ptr<weld::Toolbar>> m_aContentUnoToolbarMap; 99 std::unordered_map<ContentTypeId, std::unique_ptr<ToolbarUnoDispatcher>> m_aContentToolbarUnoDispatcherMap; 100 void InitContentFunctionsToolbar(); 101 void UpdateContentFunctionsToolbar(); 102 DECL_LINK(ContentFunctionsToolbarSelectHdl, const OUString&, void ); 103 IsZoomedIn() const104 bool IsZoomedIn() const {return m_bIsZoomedIn;} 105 void ZoomOut(); 106 void ZoomIn(); 107 108 void FillBox(); 109 110 DECL_LINK( DocListBoxSelectHdl, weld::ComboBox&, void ); 111 DECL_LINK( ToolBoxSelectHdl, const OUString&, void ); 112 DECL_LINK( ToolBoxClickHdl, const OUString&, void ); 113 DECL_LINK( ToolBox5DropdownClickHdl, const OUString&, void ); 114 DECL_LINK( DoneLink, SfxPoolItem const *, void ); 115 DECL_LINK( HeadingsMenuSelectHdl, const OUString&, void ); 116 DECL_LINK( GlobalMenuSelectHdl, const OUString&, void ); 117 DECL_LINK( SetFocusChildHdl, weld::Container&, void ); 118 DECL_LINK( NavigateByComboBoxSelectHdl, weld::ComboBox&, void ); 119 DECL_LINK(GotoPageSpinButtonValueChangedHdl, weld::SpinButton&, void); 120 121 void UpdateInitShow(); 122 123 // release ObjectShellLock early enough for app end 124 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; 125 126 void ToggleTree(); SetGlobalMode(bool bSet)127 void SetGlobalMode(bool bSet) {m_bGlobalMode = bSet;} 128 129 void UpdateNavigateBy(); 130 131 void SetContent3And4ToolBoxVisibility(); 132 133 public: 134 135 static std::unique_ptr<PanelLayout> Create(weld::Widget* pParent, 136 const css::uno::Reference< css::frame::XFrame >& rxFrame, 137 SfxBindings* pBindings); 138 SwNavigationPI(weld::Widget* pParent, 139 const css::uno::Reference< css::frame::XFrame >& rxFrame, 140 SfxBindings* _pBindings, SfxNavigator* pNavigatorDlg); 141 virtual ~SwNavigationPI() override; 142 143 void UpdateListBox(); 144 void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget); 145 146 virtual void NotifyItemUpdate(const sal_uInt16 nSId, 147 const SfxItemState eState, 148 const SfxPoolItem* pState) override; 149 GetControlState(const sal_uInt16,boost::property_tree::ptree &)150 virtual void GetControlState(const sal_uInt16 /*nSId*/, 151 boost::property_tree::ptree& /*rState*/) override {}; 152 153 static OUString CreateDropFileName( const TransferableDataHelper& rData ); 154 static OUString CleanEntry(const OUString& rEntry); 155 156 sal_Int8 AcceptDrop(); 157 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 158 159 bool IsGlobalDoc() const; IsGlobalMode() const160 bool IsGlobalMode() const {return m_bGlobalMode;} 161 162 SwView* GetCreateView() const; 163 164 virtual weld::Window* GetFrameWeld() const override; 165 166 void SelectNavigateByContentType(const OUString& rContentTypeName); 167 }; 168 169 class SwNavigatorWin : public SfxNavigator 170 { 171 friend class SwView; 172 private: 173 std::unique_ptr<SwNavigationPI> m_xNavi; 174 public: 175 SwNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, 176 vcl::Window* pParent, SfxChildWinInfo* pInfo); 177 virtual void StateChanged(StateChangedType nStateChange) override; dispose()178 virtual void dispose() override 179 { 180 m_xNavi.reset(); 181 SfxNavigator::dispose(); 182 } ~SwNavigatorWin()183 virtual ~SwNavigatorWin() override 184 { 185 disposeOnce(); 186 } 187 }; 188 189 class SwNavigatorWrapper final : public SfxNavigatorWrapper 190 { 191 public: 192 SwNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId, 193 SfxBindings* pBindings, SfxChildWinInfo* pInfo); 194 SFX_DECL_CHILDWINDOW_WITHID(SwNavigatorWrapper); 195 }; 196 197 #endif 198 199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 200
