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_SWUICNTTAB_HXX 20 #define INCLUDED_SW_SOURCE_UIBASE_INC_SWUICNTTAB_HXX 21 22 #include <sfx2/tabdlg.hxx> 23 #include <svx/langbox.hxx> 24 #include <vcl/weld.hxx> 25 #include <vcl/customweld.hxx> 26 27 #include <tox.hxx> 28 #include "toxmgr.hxx" 29 #include "cnttab.hxx" 30 #include <vector> 31 32 class IndexEntryResource; 33 class IndexEntrySupplierWrapper; 34 class SwTOXWidget; 35 class SwTOXEdit; 36 class SwTOXButton; 37 class SwTOXEntryTabPage; 38 class SwOneExampleFrame; 39 class SwWrtShell; 40 41 namespace com{namespace sun{namespace star{ 42 namespace text{ 43 class XTextSection; 44 class XDocumentIndex; 45 } 46 }}} 47 48 struct SwIndexSections_Impl 49 { 50 css::uno::Reference< css::text::XTextSection > xContainerSection; 51 css::uno::Reference< css::text::XDocumentIndex > xDocumentIndex; 52 }; 53 54 class SwMultiTOXTabDialog : public SfxTabDialogController 55 { 56 std::unique_ptr<SwTOXMgr> m_pMgr; 57 SwWrtShell& m_rWrtShell; 58 59 struct TypeData 60 { 61 std::unique_ptr<SwForm> m_pForm; 62 std::unique_ptr<SwTOXDescription> m_pDescription; 63 std::unique_ptr<SwIndexSections_Impl> m_pxIndexSections; 64 }; 65 std::vector<TypeData> m_vTypeData; 66 67 SwTOXBase* m_pParamTOXBase; 68 69 CurTOXType m_eCurrentTOXType; 70 71 OUString const m_sUserDefinedIndex; 72 sal_uInt16 const m_nInitialTOXType; 73 74 bool m_bEditTOX; 75 bool m_bExampleCreated; 76 bool const m_bGlobalFlag; 77 78 std::unique_ptr<SwOneExampleFrame> m_xExampleFrame; 79 std::unique_ptr<weld::CheckButton> m_xShowExampleCB; 80 std::unique_ptr<weld::CustomWeld> m_xExampleFrameWin; 81 82 virtual short Ok() override; 83 std::unique_ptr<SwTOXDescription> CreateTOXDescFromTOXBase(const SwTOXBase*pCurTOX); 84 85 DECL_LINK(CreateExample_Hdl, SwOneExampleFrame&, void); 86 DECL_LINK(ShowPreviewHdl, weld::ToggleButton&, void); 87 88 public: 89 SwMultiTOXTabDialog(weld::Window* pParent, const SfxItemSet& rSet, 90 SwWrtShell &rShell, 91 SwTOXBase* pCurTOX, sal_uInt16 nToxType, 92 bool bGlobal); 93 virtual ~SwMultiTOXTabDialog() override; 94 95 virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; 96 97 SwForm* GetForm(CurTOXType eType); 98 GetCurrentTOXType() const99 const CurTOXType& GetCurrentTOXType() const { return m_eCurrentTOXType;} SetCurrentTOXType(const CurTOXType & eSet)100 void SetCurrentTOXType(const CurTOXType& eSet) 101 { 102 m_eCurrentTOXType = eSet; 103 } 104 IsTOXEditMode() const105 bool IsTOXEditMode() const { return m_bEditTOX;} 106 GetWrtShell()107 SwWrtShell& GetWrtShell() {return m_rWrtShell;} 108 109 SwTOXDescription& GetTOXDescription(CurTOXType eTOXTypes); 110 void CreateOrUpdateExample( 111 TOXTypes nTOXIndex, sal_uInt16 nPage = 0, sal_uInt16 nCurLevel = USHRT_MAX); 112 113 static bool IsNoNum(SwWrtShell& rSh, const OUString& rName); 114 }; 115 116 class SwTOXSelectTabPage : public SfxTabPage 117 { 118 std::unique_ptr<IndexEntryResource> pIndexRes; 119 120 OUString aStyleArr[MAXLEVEL]; 121 OUString sAutoMarkURL; 122 OUString const sAutoMarkType; 123 OUString sAddStyleUser; 124 OUString sAddStyleContent; 125 126 std::unique_ptr<const IndexEntrySupplierWrapper> pIndexEntryWrapper; 127 128 bool m_bWaitingInitialSettings; 129 130 std::unique_ptr<weld::Entry> m_xTitleED; 131 std::unique_ptr<weld::Label> m_xTypeFT; 132 std::unique_ptr<weld::ComboBox> m_xTypeLB; 133 std::unique_ptr<weld::CheckButton> m_xReadOnlyCB; 134 135 std::unique_ptr<weld::Widget> m_xAreaFrame; 136 std::unique_ptr<weld::ComboBox> m_xAreaLB; 137 std::unique_ptr<weld::Widget> m_xLevelFT; //content, user 138 std::unique_ptr<weld::SpinButton> m_xLevelNF; //content, user 139 140 //content 141 std::unique_ptr<weld::Widget> m_xCreateFrame; // content, user, illustration 142 std::unique_ptr<weld::CheckButton> m_xFromHeadingsCB; 143 std::unique_ptr<weld::CheckButton> m_xStylesCB; 144 std::unique_ptr<weld::CheckButton> m_xAddStylesCB; 145 std::unique_ptr<weld::Button> m_xAddStylesPB; 146 //user 147 std::unique_ptr<weld::CheckButton> m_xFromTablesCB; 148 std::unique_ptr<weld::CheckButton> m_xFromFramesCB; 149 std::unique_ptr<weld::CheckButton> m_xFromGraphicsCB; 150 std::unique_ptr<weld::CheckButton> m_xFromOLECB; 151 std::unique_ptr<weld::CheckButton> m_xLevelFromChapterCB; 152 153 //illustration + table 154 std::unique_ptr<weld::RadioButton> m_xFromCaptionsRB; 155 std::unique_ptr<weld::RadioButton> m_xFromObjectNamesRB; 156 157 //illustration and tables 158 std::unique_ptr<weld::Label> m_xCaptionSequenceFT; 159 std::unique_ptr<weld::ComboBox> m_xCaptionSequenceLB; 160 std::unique_ptr<weld::Label> m_xDisplayTypeFT; 161 std::unique_ptr<weld::ComboBox> m_xDisplayTypeLB; 162 163 //all but illustration and table 164 std::unique_ptr<weld::CheckButton> m_xTOXMarksCB; 165 166 //index only 167 std::unique_ptr<weld::Widget> m_xIdxOptionsFrame; 168 std::unique_ptr<weld::CheckButton> m_xCollectSameCB; 169 std::unique_ptr<weld::CheckButton> m_xUseFFCB; 170 std::unique_ptr<weld::CheckButton> m_xUseDashCB; 171 std::unique_ptr<weld::CheckButton> m_xCaseSensitiveCB; 172 std::unique_ptr<weld::CheckButton> m_xInitialCapsCB; 173 std::unique_ptr<weld::CheckButton> m_xKeyAsEntryCB; 174 std::unique_ptr<weld::CheckButton> m_xFromFileCB; 175 std::unique_ptr<weld::MenuButton> m_xAutoMarkPB; 176 177 // object only 178 std::unique_ptr<weld::TreeView> m_xFromObjCLB; 179 std::unique_ptr<weld::Widget> m_xFromObjFrame; 180 181 std::unique_ptr<weld::CheckButton> m_xSequenceCB; 182 std::unique_ptr<weld::ComboBox> m_xBracketLB; 183 std::unique_ptr<weld::Widget> m_xAuthorityFrame; 184 185 //all 186 std::unique_ptr<weld::Widget> m_xSortFrame; 187 std::unique_ptr<SvxLanguageBox> m_xLanguageLB; 188 std::unique_ptr<weld::ComboBox> m_xSortAlgorithmLB; 189 190 DECL_LINK(TOXTypeHdl, weld::ComboBox&, void ); 191 DECL_LINK(AddStylesHdl, weld::Button&, void ); 192 DECL_LINK(MenuEnableHdl, weld::ToggleButton&, void); 193 DECL_LINK(MenuExecuteHdl, const OString&, void); 194 DECL_LINK(LanguageListBoxHdl, weld::ComboBox&, void); 195 void LanguageHdl(const weld::ComboBox*); 196 DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void ); 197 DECL_LINK(RadioButtonHdl, weld::ToggleButton&, void); 198 DECL_LINK(ModifyEntryHdl, weld::Entry&, void); 199 DECL_LINK(ModifySpinHdl, weld::SpinButton&, void); 200 DECL_LINK(ModifyListBoxHdl, weld::ComboBox&, void); 201 202 void ModifyHdl(); 203 void ApplyTOXDescription(); 204 void FillTOXDescription(); 205 206 public: 207 SwTOXSelectTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttrSet); 208 virtual ~SwTOXSelectTabPage() override; 209 210 virtual bool FillItemSet( SfxItemSet* ) override; 211 virtual void Reset( const SfxItemSet* ) override; 212 213 virtual void ActivatePage( const SfxItemSet& ) override; 214 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; 215 216 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 217 const SfxItemSet* rAttrSet); 218 219 void SelectType(TOXTypes eSet); //preset TOXType, GlobalDoc 220 void SetWrtShell(SwWrtShell const & rSh); 221 }; 222 223 class SwTokenWindow 224 { 225 SwForm* m_pForm; 226 sal_uInt16 m_nLevel; 227 bool m_bValid; 228 OUString m_aButtonTexts[TOKEN_END]; // Text of the buttons 229 OUString m_aButtonHelpTexts[TOKEN_END]; // QuickHelpText of the buttons 230 OUString const m_sCharStyle; 231 Link<SwFormToken&,void> m_aButtonSelectedHdl; 232 SwTOXWidget* m_pActiveCtrl; 233 Link<LinkParamNone*,void> m_aModifyHdl; 234 OUString m_sAccessibleName; 235 OUString m_sAdditionalAccnameString1; 236 OUString m_sAdditionalAccnameString2; 237 OUString m_sAdditionalAccnameString3; 238 239 Idle m_aAdjustPositionsIdle; 240 241 SwTOXEntryTabPage* m_pParent; 242 std::unique_ptr<weld::Container> m_xParentWidget; 243 std::unique_ptr<weld::Builder> m_xBuilder; 244 std::unique_ptr<weld::Container> m_xContainer; 245 std::unique_ptr<weld::Button> m_xLeftScrollWin; 246 std::unique_ptr<weld::Container> m_xCtrlParentWin; 247 std::unique_ptr<weld::ScrolledWindow> m_xScrollWin; 248 std::unique_ptr<weld::Button> m_xRightScrollWin; 249 std::vector<std::unique_ptr<SwTOXWidget>> m_aControlList; 250 251 DECL_LINK(EditResize, SwTOXEdit&, void); 252 DECL_LINK(NextItemHdl, SwTOXEdit&, void); 253 DECL_LINK(TbxFocusHdl, SwTOXWidget&, void); 254 DECL_LINK(NextItemBtnHdl, SwTOXButton&, void); 255 DECL_LINK(TbxFocusBtnHdl, SwTOXWidget&, void); 256 DECL_LINK(ScrollBtnHdl, weld::Button&, void); 257 DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); 258 DECL_LINK(AdjustPositionsHdl, const Size&, void); 259 260 void SetActiveControl(SwTOXWidget* pSet); 261 262 SwTOXWidget* InsertItem(const OUString& rText, const SwFormToken& aToken); 263 void AdjustPositions(); 264 void AdjustScrolling(); 265 void MoveControls(long nOffset); 266 267 public: 268 SwTokenWindow(std::unique_ptr<weld::Container> xParent); get_child_container()269 weld::Container* get_child_container() { return m_xCtrlParentWin.get(); } 270 ~SwTokenWindow(); 271 SetTabPage(SwTOXEntryTabPage * pParent)272 void SetTabPage(SwTOXEntryTabPage *pParent) { m_pParent = pParent; } 273 274 void SetForm(SwForm& rForm, sal_uInt16 nLevel); GetLastLevel() const275 sal_uInt16 GetLastLevel()const {return m_nLevel;}; 276 IsValid() const277 bool IsValid() const {return m_bValid;} 278 SetInvalid()279 void SetInvalid() {m_bValid = false;} 280 281 OUString GetPattern() const; 282 SetButtonSelectedHdl(const Link<SwFormToken &,void> & rLink)283 void SetButtonSelectedHdl(const Link<SwFormToken&,void>& rLink) 284 { m_aButtonSelectedHdl = rLink;} 285 SetModifyHdl(const Link<LinkParamNone *,void> & rLink)286 void SetModifyHdl(const Link<LinkParamNone*,void>& rLink){m_aModifyHdl = rLink;} 287 GetActiveControl()288 SwTOXWidget* GetActiveControl() { return m_pActiveCtrl; } 289 290 void InsertAtSelection(const SwFormToken& aToken); 291 void RemoveControl(const SwTOXButton* pDel, bool bInternalCall = false); 292 293 bool Contains(FormTokenType) const; 294 295 //helper for pattern buttons and edits 296 OUString CreateQuickHelp(const SwFormToken& rToken); 297 298 void SetFocus2theAllBtn(); 299 private: 300 sal_uInt32 GetControlIndex(FormTokenType eType) const; 301 }; 302 303 class SwTOXEntryTabPage : public SfxTabPage 304 { 305 OUString const sDelimStr; 306 OUString sLevelStr; 307 OUString sAuthTypeStr; 308 309 OUString const sNoCharStyle; 310 SwForm* m_pCurrentForm; 311 312 CurTOXType aLastTOXType; 313 bool bInLevelHdl; 314 315 std::unique_ptr<weld::Label> m_xTypeFT; 316 std::unique_ptr<weld::Label> m_xLevelFT; 317 std::unique_ptr<weld::TreeView> m_xLevelLB; 318 std::unique_ptr<weld::Button> m_xAllLevelsPB; 319 std::unique_ptr<weld::Button> m_xEntryNoPB; 320 std::unique_ptr<weld::Button> m_xEntryPB; 321 std::unique_ptr<weld::Button> m_xTabPB; 322 std::unique_ptr<weld::Button> m_xChapterInfoPB; 323 std::unique_ptr<weld::Button> m_xPageNoPB; 324 std::unique_ptr<weld::Button> m_xHyperLinkPB; 325 std::unique_ptr<weld::ComboBox> m_xAuthFieldsLB; 326 std::unique_ptr<weld::Button> m_xAuthInsertPB; 327 std::unique_ptr<weld::Button> m_xAuthRemovePB; 328 std::unique_ptr<weld::ComboBox> m_xCharStyleLB; // character style of the current token 329 std::unique_ptr<weld::Button> m_xEditStylePB; 330 std::unique_ptr<weld::Label> m_xChapterEntryFT; 331 std::unique_ptr<weld::ComboBox> m_xChapterEntryLB; // type of chapter info 332 std::unique_ptr<weld::Label> m_xNumberFormatFT; 333 std::unique_ptr<weld::ComboBox> m_xNumberFormatLB; //!< format for numbering (E#) 334 std::unique_ptr<weld::Label> m_xEntryOutlineLevelFT; //!< Fixed text, for i53420 335 std::unique_ptr<weld::SpinButton> m_xEntryOutlineLevelNF; //!< level to evaluate outline level to, for i53420 336 std::unique_ptr<weld::Label> m_xFillCharFT; 337 std::unique_ptr<weld::ComboBox> m_xFillCharCB; // fill char for tab stop 338 std::unique_ptr<weld::Label> m_xTabPosFT; 339 std::unique_ptr<weld::MetricSpinButton> m_xTabPosMF; // tab stop position 340 std::unique_ptr<weld::CheckButton> m_xAutoRightCB; 341 std::unique_ptr<weld::Widget> m_xFormatFrame; 342 std::unique_ptr<weld::Label> m_xMainEntryStyleFT; 343 std::unique_ptr<weld::ComboBox> m_xMainEntryStyleLB; // character style of main entries in indexes 344 std::unique_ptr<weld::CheckButton> m_xAlphaDelimCB; 345 std::unique_ptr<weld::CheckButton> m_xCommaSeparatedCB; 346 std::unique_ptr<weld::CheckButton> m_xRelToStyleCB; // position relative to the right margin of the para style 347 std::unique_ptr<weld::Widget> m_xSortingFrame; 348 std::unique_ptr<weld::RadioButton> m_xSortDocPosRB; 349 std::unique_ptr<weld::RadioButton> m_xSortContentRB; 350 std::unique_ptr<weld::Widget> m_xSortKeyFrame; 351 std::unique_ptr<weld::ComboBox> m_xFirstKeyLB; 352 std::unique_ptr<weld::RadioButton> m_xFirstSortUpRB; 353 std::unique_ptr<weld::RadioButton> m_xFirstSortDownRB; 354 std::unique_ptr<weld::ComboBox> m_xSecondKeyLB; 355 std::unique_ptr<weld::RadioButton> m_xSecondSortUpRB; 356 std::unique_ptr<weld::RadioButton> m_xSecondSortDownRB; 357 std::unique_ptr<weld::ComboBox> m_xThirdKeyLB; 358 std::unique_ptr<weld::RadioButton> m_xThirdSortUpRB; 359 std::unique_ptr<weld::RadioButton> m_xThirdSortDownRB; 360 std::unique_ptr<SwTokenWindow> m_xTokenWIN; 361 362 DECL_LINK(StyleSelectHdl, weld::ComboBox&, void); 363 DECL_LINK(EditStyleHdl, weld::Button&, void); 364 DECL_LINK(InsertTokenHdl, weld::Button&, void); 365 DECL_LINK(LevelHdl, weld::TreeView&, void); 366 DECL_LINK(AutoRightHdl, weld::ToggleButton&, void); 367 DECL_LINK(TokenSelectedHdl, SwFormToken&, void); 368 DECL_LINK(TabPosHdl, weld::MetricSpinButton&, void); 369 DECL_LINK(FillCharHdl, weld::ComboBox&, void); 370 DECL_LINK(RemoveInsertAuthHdl, weld::Button&, void); 371 DECL_LINK(SortKeyHdl, weld::ToggleButton&, void); 372 DECL_LINK(ChapterInfoHdl, weld::ComboBox&, void); 373 DECL_LINK(ChapterInfoOutlineHdl, weld::SpinButton&, void); 374 DECL_LINK(NumberFormatHdl, weld::ComboBox&, void); 375 376 DECL_LINK(AllLevelsHdl, weld::Button&, void); 377 378 void WriteBackLevel(); 379 void UpdateDescriptor(); 380 DECL_LINK(ModifyHdl, LinkParamNone*, void); 381 void OnModify(bool bAllLevels); 382 DECL_LINK(ModifyClickHdl, weld::ToggleButton&, void); 383 384 public: 385 SwTOXEntryTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttrSet); 386 virtual ~SwTOXEntryTabPage() override; 387 388 virtual bool FillItemSet( SfxItemSet* ) override; 389 virtual void Reset( const SfxItemSet* ) override; 390 virtual void ActivatePage( const SfxItemSet& ) override; 391 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; 392 393 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 394 const SfxItemSet* rAttrSet); 395 void SetWrtShell(SwWrtShell& rSh); 396 397 void PreTokenButtonRemoved(const SwFormToken& rToken); 398 void SetFocus2theAllBtn(); 399 }; 400 401 class SwTOXStylesTabPage : public SfxTabPage 402 { 403 std::unique_ptr<SwForm> m_pCurrentForm; 404 405 std::unique_ptr<weld::TreeView> m_xLevelLB; 406 std::unique_ptr<weld::Button> m_xAssignBT; 407 std::unique_ptr<weld::TreeView> m_xParaLayLB; 408 std::unique_ptr<weld::Button> m_xStdBT; 409 std::unique_ptr<weld::Button> m_xEditStyleBT; 410 411 DECL_LINK(EditStyleHdl, weld::Button&, void); 412 DECL_LINK(StdHdl, weld::Button&, void); 413 DECL_LINK(EnableSelectHdl, weld::TreeView&, void); 414 DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); 415 DECL_LINK(AssignHdl, weld::Button&, void); 416 void Modify(); 417 GetForm()418 SwForm& GetForm() 419 { 420 SwMultiTOXTabDialog* pDlg = static_cast<SwMultiTOXTabDialog*>(GetDialogController()); 421 return *pDlg->GetForm(pDlg->GetCurrentTOXType()); 422 } 423 424 public: 425 SwTOXStylesTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttrSet); 426 virtual ~SwTOXStylesTabPage() override; 427 428 virtual bool FillItemSet( SfxItemSet* ) override; 429 virtual void Reset( const SfxItemSet* ) override; 430 431 virtual void ActivatePage( const SfxItemSet& ) override; 432 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; 433 434 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, 435 const SfxItemSet* rAttrSet); 436 437 }; 438 439 #endif // INCLUDED_SW_SOURCE_UIBASE_INC_SWUICNTTAB_HXX 440 441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 442