1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWUICNTTAB_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_SWUICNTTAB_HXX
22 #include <sfx2/tabdlg.hxx>
23 #include <svx/langbox.hxx>
24 #include <vcl/idle.hxx>
25 #include <vcl/weld.hxx>
26 #include <vcl/customweld.hxx>
33 class IndexEntryResource
;
34 class IndexEntrySupplierWrapper
;
38 class SwTOXEntryTabPage
;
39 class SwOneExampleFrame
;
42 namespace com::sun::star
{
49 struct SwIndexSections_Impl
51 css::uno::Reference
< css::text::XTextSection
> xContainerSection
;
52 css::uno::Reference
< css::text::XDocumentIndex
> xDocumentIndex
;
55 class SwMultiTOXTabDialog final
: public SfxTabDialogController
57 std::unique_ptr
<SwTOXMgr
> m_pMgr
;
58 SwWrtShell
& m_rWrtShell
;
62 std::unique_ptr
<SwForm
> m_pForm
;
63 std::unique_ptr
<SwTOXDescription
> m_pDescription
;
64 std::optional
<SwIndexSections_Impl
> m_oIndexSections
;
66 std::vector
<TypeData
> m_vTypeData
;
68 SwTOXBase
* m_pParamTOXBase
;
70 CurTOXType m_eCurrentTOXType
;
72 OUString m_sUserDefinedIndex
;
73 sal_uInt16 m_nInitialTOXType
;
76 bool m_bExampleCreated
;
79 std::unique_ptr
<SwOneExampleFrame
> m_xExampleFrame
;
80 std::unique_ptr
<weld::CheckButton
> m_xShowExampleCB
;
81 std::unique_ptr
<weld::CustomWeld
> m_xExampleFrameWin
;
83 virtual short Ok() override
;
84 std::unique_ptr
<SwTOXDescription
> CreateTOXDescFromTOXBase(const SwTOXBase
*pCurTOX
);
87 DECL_LINK(CreateExample_Hdl
, SwOneExampleFrame
&, void);
88 DECL_LINK(ShowPreviewHdl
, weld::Toggleable
&, void);
91 SwMultiTOXTabDialog(weld::Widget
* pParent
, const SfxItemSet
& rSet
,
93 SwTOXBase
* pCurTOX
, sal_uInt16 nToxType
,
95 virtual ~SwMultiTOXTabDialog() override
;
97 virtual void PageCreated(const OUString
& rId
, SfxTabPage
&rPage
) override
;
99 SwForm
* GetForm(CurTOXType eType
);
101 const CurTOXType
& GetCurrentTOXType() const { return m_eCurrentTOXType
;}
102 void SetCurrentTOXType(const CurTOXType
& eSet
)
104 m_eCurrentTOXType
= eSet
;
107 bool IsTOXEditMode() const { return m_bEditTOX
;}
109 SwWrtShell
& GetWrtShell() {return m_rWrtShell
;}
111 SwTOXDescription
& GetTOXDescription(CurTOXType eTOXTypes
);
112 void CreateOrUpdateExample(
113 TOXTypes nTOXIndex
, sal_uInt16 nPage
= 0, sal_uInt16 nCurLevel
= USHRT_MAX
);
115 static bool IsNoNum(SwWrtShell
& rSh
, const OUString
& rName
);
118 class SwTOXSelectTabPage final
: public SfxTabPage
120 std::unique_ptr
<IndexEntryResource
> m_pIndexRes
;
122 OUString m_aStyleArr
[MAXLEVEL
];
123 OUString m_sAutoMarkURL
;
124 OUString m_sAutoMarkType
;
125 OUString m_sAddStyleUser
;
126 OUString m_sAddStyleContent
;
128 std::unique_ptr
<const IndexEntrySupplierWrapper
> m_pIndexEntryWrapper
;
130 bool m_bWaitingInitialSettings
;
132 std::unique_ptr
<weld::Entry
> m_xTitleED
;
133 std::unique_ptr
<weld::Label
> m_xTypeFT
;
134 std::unique_ptr
<weld::ComboBox
> m_xTypeLB
;
135 std::unique_ptr
<weld::CheckButton
> m_xReadOnlyCB
;
136 std::unique_ptr
<weld::CheckButton
> m_xTitleToggleCB
;
138 std::unique_ptr
<weld::Widget
> m_xAreaFrame
;
139 std::unique_ptr
<weld::ComboBox
> m_xAreaLB
;
140 std::unique_ptr
<weld::Widget
> m_xLevelFT
; //content, user
141 std::unique_ptr
<weld::SpinButton
> m_xLevelNF
; //content, user
144 std::unique_ptr
<weld::Widget
> m_xCreateFrame
; // content, user, illustration
145 std::unique_ptr
<weld::CheckButton
> m_xFromHeadingsCB
;
146 std::unique_ptr
<weld::CheckButton
> m_xStylesCB
;
147 std::unique_ptr
<weld::CheckButton
> m_xAddStylesCB
;
148 std::unique_ptr
<weld::Button
> m_xAddStylesPB
;
150 std::unique_ptr
<weld::CheckButton
> m_xFromTablesCB
;
151 std::unique_ptr
<weld::CheckButton
> m_xFromFramesCB
;
152 std::unique_ptr
<weld::CheckButton
> m_xFromGraphicsCB
;
153 std::unique_ptr
<weld::CheckButton
> m_xFromOLECB
;
154 std::unique_ptr
<weld::CheckButton
> m_xLevelFromChapterCB
;
156 //illustration + table
157 std::unique_ptr
<weld::RadioButton
> m_xFromCaptionsRB
;
158 std::unique_ptr
<weld::RadioButton
> m_xFromObjectNamesRB
;
160 //illustration and tables
161 std::unique_ptr
<weld::Label
> m_xCaptionSequenceFT
;
162 std::unique_ptr
<weld::ComboBox
> m_xCaptionSequenceLB
;
163 std::unique_ptr
<weld::Label
> m_xDisplayTypeFT
;
164 std::unique_ptr
<weld::ComboBox
> m_xDisplayTypeLB
;
165 std::unique_ptr
<weld::CheckButton
> m_xParaStyleCB
;
166 std::unique_ptr
<weld::ComboBox
> m_xParaStyleLB
;
168 //all but illustration and table
169 std::unique_ptr
<weld::CheckButton
> m_xTOXMarksCB
;
172 std::unique_ptr
<weld::Widget
> m_xIdxOptionsFrame
;
173 std::unique_ptr
<weld::CheckButton
> m_xCollectSameCB
;
174 std::unique_ptr
<weld::CheckButton
> m_xUseFFCB
;
175 std::unique_ptr
<weld::CheckButton
> m_xUseDashCB
;
176 std::unique_ptr
<weld::CheckButton
> m_xCaseSensitiveCB
;
177 std::unique_ptr
<weld::CheckButton
> m_xInitialCapsCB
;
178 std::unique_ptr
<weld::CheckButton
> m_xKeyAsEntryCB
;
179 std::unique_ptr
<weld::CheckButton
> m_xFromFileCB
;
180 std::unique_ptr
<weld::MenuButton
> m_xAutoMarkPB
;
183 std::unique_ptr
<weld::TreeView
> m_xFromObjCLB
;
184 std::unique_ptr
<weld::Widget
> m_xFromObjFrame
;
186 std::unique_ptr
<weld::CheckButton
> m_xSequenceCB
;
187 std::unique_ptr
<weld::ComboBox
> m_xBracketLB
;
188 std::unique_ptr
<weld::Widget
> m_xAuthorityFrame
;
191 std::unique_ptr
<weld::Widget
> m_xSortFrame
;
192 std::unique_ptr
<SvxLanguageBox
> m_xLanguageLB
;
193 std::unique_ptr
<weld::ComboBox
> m_xSortAlgorithmLB
;
195 DECL_LINK(TOXTypeHdl
, weld::ComboBox
&, void );
196 DECL_LINK(AddStylesHdl
, weld::Button
&, void );
197 DECL_LINK(MenuEnableHdl
, weld::Toggleable
&, void);
198 DECL_LINK(MenuExecuteHdl
, const OUString
&, void);
199 DECL_LINK(LanguageListBoxHdl
, weld::ComboBox
&, void);
200 void LanguageHdl(const weld::ComboBox
*);
201 DECL_LINK(CheckBoxHdl
, weld::Toggleable
&, void );
202 DECL_LINK(RadioButtonHdl
, weld::Toggleable
&, void);
203 DECL_LINK(ModifyEntryHdl
, weld::Entry
&, void);
204 DECL_LINK(ModifySpinHdl
, weld::SpinButton
&, void);
205 DECL_LINK(ModifyListBoxHdl
, weld::ComboBox
&, void);
208 void ApplyTOXDescription();
209 void FillTOXDescription();
212 SwTOXSelectTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rAttrSet
);
213 virtual ~SwTOXSelectTabPage() override
;
215 virtual bool FillItemSet( SfxItemSet
* ) override
;
216 virtual void Reset( const SfxItemSet
* ) override
;
218 virtual void ActivatePage( const SfxItemSet
& ) override
;
219 virtual DeactivateRC
DeactivatePage( SfxItemSet
* pSet
) override
;
221 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
222 const SfxItemSet
* rAttrSet
);
224 void SelectType(TOXTypes eSet
); //preset TOXType, GlobalDoc
225 void SetWrtShell(SwWrtShell
const & rSh
);
233 OUString m_aButtonTexts
[TOKEN_END
]; // Text of the buttons
234 OUString m_aButtonHelpTexts
[TOKEN_END
]; // QuickHelpText of the buttons
235 OUString m_sCharStyle
;
236 Link
<SwFormToken
&,void> m_aButtonSelectedHdl
;
237 SwTOXWidget
* m_pActiveCtrl
;
238 Link
<LinkParamNone
*,void> m_aModifyHdl
;
239 OUString m_sAccessibleName
;
240 OUString m_sAdditionalAccnameString1
;
241 OUString m_sAdditionalAccnameString2
;
242 OUString m_sAdditionalAccnameString3
;
244 Idle m_aAdjustPositionsIdle
;
246 SwTOXEntryTabPage
* m_pParent
;
247 std::unique_ptr
<weld::Container
> m_xParentWidget
;
248 std::unique_ptr
<weld::Builder
> m_xBuilder
;
249 std::unique_ptr
<weld::Container
> m_xContainer
;
250 std::unique_ptr
<weld::Button
> m_xLeftScrollWin
;
251 std::unique_ptr
<weld::Grid
> m_xCtrlParentWin
;
252 std::unique_ptr
<weld::ScrolledWindow
> m_xScrollWin
;
253 std::unique_ptr
<weld::Button
> m_xRightScrollWin
;
254 std::vector
<std::unique_ptr
<SwTOXWidget
>> m_aControlList
;
256 DECL_LINK(EditResize
, SwTOXEdit
&, void);
257 DECL_LINK(NextItemHdl
, SwTOXEdit
&, void);
258 DECL_LINK(TbxFocusHdl
, SwTOXWidget
&, void);
259 DECL_LINK(NextItemBtnHdl
, SwTOXButton
&, void);
260 DECL_LINK(TbxFocusBtnHdl
, SwTOXWidget
&, void);
261 DECL_LINK(ScrollBtnHdl
, weld::Button
&, void);
262 DECL_LINK(ScrollHdl
, weld::ScrolledWindow
&, void);
263 DECL_LINK(AdjustPositionsHdl
, const Size
&, void);
265 void SetActiveControl(SwTOXWidget
* pSet
, bool bGrabFocus
= true);
267 SwTOXWidget
* InsertItem(const OUString
& rText
, const SwFormToken
& aToken
);
268 void AdjustPositions();
269 void AdjustScrolling();
270 void MoveControls(tools::Long nOffset
);
273 SwTokenWindow(std::unique_ptr
<weld::Container
> xParent
);
274 weld::Grid
* get_child_container() { return m_xCtrlParentWin
.get(); }
277 void SetTabPage(SwTOXEntryTabPage
*pParent
) { m_pParent
= pParent
; }
279 void SetForm(SwForm
& rForm
, sal_uInt16 nLevel
, bool bGrabFocus
= true);
280 sal_uInt16
GetLastLevel()const {return m_nLevel
;};
282 bool IsValid() const {return m_bValid
;}
284 void SetInvalid() {m_bValid
= false;}
286 OUString
GetPattern() const;
288 void SetButtonSelectedHdl(const Link
<SwFormToken
&,void>& rLink
)
289 { m_aButtonSelectedHdl
= rLink
;}
291 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rLink
){m_aModifyHdl
= rLink
;}
293 SwTOXWidget
* GetActiveControl() { return m_pActiveCtrl
; }
295 void InsertAtSelection(const SwFormToken
& aToken
);
296 void RemoveControl(const SwTOXButton
* pDel
, bool bInternalCall
= false);
298 bool Contains(FormTokenType
) const;
300 //helper for pattern buttons and edits
301 OUString
CreateQuickHelp(const SwFormToken
& rToken
);
303 void SetFocus2theAllBtn();
305 sal_uInt32
GetControlIndex(FormTokenType eType
) const;
308 class SwTOXEntryTabPage final
: public SfxTabPage
310 OUString m_sDelimStr
;
311 OUString m_sLevelStr
;
312 OUString m_sAuthTypeStr
;
314 OUString m_sNoCharStyle
;
315 SwForm
* m_pCurrentForm
;
317 CurTOXType m_aLastTOXType
;
320 std::unique_ptr
<weld::Label
> m_xTypeFT
;
321 std::unique_ptr
<weld::Label
> m_xLevelFT
;
322 std::unique_ptr
<weld::TreeView
> m_xLevelLB
;
323 std::unique_ptr
<weld::Button
> m_xAllLevelsPB
;
324 std::unique_ptr
<weld::Button
> m_xEntryNoPB
;
325 std::unique_ptr
<weld::Button
> m_xEntryPB
;
326 std::unique_ptr
<weld::Button
> m_xTabPB
;
327 std::unique_ptr
<weld::Button
> m_xChapterInfoPB
;
328 std::unique_ptr
<weld::Button
> m_xPageNoPB
;
329 std::unique_ptr
<weld::Button
> m_xHyperLinkPB
;
330 std::unique_ptr
<weld::Widget
> m_xFieldBox
;
331 std::unique_ptr
<weld::ComboBox
> m_xAuthFieldsLB
;
332 std::unique_ptr
<weld::Button
> m_xAuthInsertPB
;
333 std::unique_ptr
<weld::Button
> m_xAuthRemovePB
;
334 std::unique_ptr
<weld::ComboBox
> m_xCharStyleLB
; // character style of the current token
335 std::unique_ptr
<weld::Button
> m_xEditStylePB
;
336 std::unique_ptr
<weld::Label
> m_xChapterEntryFT
;
337 std::unique_ptr
<weld::ComboBox
> m_xChapterEntryLB
; // type of chapter info
338 std::unique_ptr
<weld::Label
> m_xNumberFormatFT
;
339 std::unique_ptr
<weld::ComboBox
> m_xNumberFormatLB
; //!< format for numbering (E#)
340 std::unique_ptr
<weld::Label
> m_xEntryOutlineLevelFT
; //!< Fixed text, for i53420
341 std::unique_ptr
<weld::SpinButton
> m_xEntryOutlineLevelNF
; //!< level to evaluate outline level to, for i53420
342 std::unique_ptr
<weld::Label
> m_xFillCharFT
;
343 std::unique_ptr
<weld::ComboBox
> m_xFillCharCB
; // fill char for tab stop
344 std::unique_ptr
<weld::Label
> m_xTabPosFT
;
345 std::unique_ptr
<weld::MetricSpinButton
> m_xTabPosMF
; // tab stop position
346 std::unique_ptr
<weld::CheckButton
> m_xAutoRightCB
;
347 std::unique_ptr
<weld::Widget
> m_xFormatFrame
;
348 std::unique_ptr
<weld::Label
> m_xMainEntryStyleFT
;
349 std::unique_ptr
<weld::ComboBox
> m_xMainEntryStyleLB
; // character style of main entries in indexes
350 std::unique_ptr
<weld::CheckButton
> m_xAlphaDelimCB
;
351 std::unique_ptr
<weld::CheckButton
> m_xCommaSeparatedCB
;
352 std::unique_ptr
<weld::CheckButton
> m_xRelToStyleCB
; // position relative to the right margin of the para style
353 std::unique_ptr
<weld::Widget
> m_xSortingFrame
;
354 std::unique_ptr
<weld::RadioButton
> m_xSortDocPosRB
;
355 std::unique_ptr
<weld::RadioButton
> m_xSortContentRB
;
356 std::unique_ptr
<weld::Widget
> m_xSortKeyFrame
;
357 std::unique_ptr
<weld::ComboBox
> m_xFirstKeyLB
;
358 std::unique_ptr
<weld::ToggleButton
> m_xFirstSortUpRB
;
359 std::unique_ptr
<weld::ToggleButton
> m_xFirstSortDownRB
;
360 std::unique_ptr
<weld::ComboBox
> m_xSecondKeyLB
;
361 std::unique_ptr
<weld::ToggleButton
> m_xSecondSortUpRB
;
362 std::unique_ptr
<weld::ToggleButton
> m_xSecondSortDownRB
;
363 std::unique_ptr
<weld::ComboBox
> m_xThirdKeyLB
;
364 std::unique_ptr
<weld::ToggleButton
> m_xThirdSortUpRB
;
365 std::unique_ptr
<weld::ToggleButton
> m_xThirdSortDownRB
;
366 std::unique_ptr
<SwTokenWindow
> m_xTokenWIN
;
368 DECL_LINK(StyleSelectHdl
, weld::ComboBox
&, void);
369 DECL_LINK(EditStyleHdl
, weld::Button
&, void);
370 DECL_LINK(InsertTokenHdl
, weld::Button
&, void);
371 DECL_LINK(LevelHdl
, weld::TreeView
&, void);
372 DECL_LINK(AutoRightHdl
, weld::Toggleable
&, void);
373 DECL_LINK(TokenSelectedHdl
, SwFormToken
&, void);
374 DECL_LINK(TabPosHdl
, weld::MetricSpinButton
&, void);
375 DECL_LINK(FillCharHdl
, weld::ComboBox
&, void);
376 DECL_LINK(RemoveInsertAuthHdl
, weld::Button
&, void);
377 DECL_LINK(SortKeyHdl
, weld::Toggleable
&, void);
378 DECL_LINK(ChapterInfoHdl
, weld::ComboBox
&, void);
379 DECL_LINK(ChapterInfoOutlineHdl
, weld::SpinButton
&, void);
380 DECL_LINK(NumberFormatHdl
, weld::ComboBox
&, void);
381 DECL_LINK(ToggleHdl
, weld::Toggleable
&, void);
383 DECL_LINK(AllLevelsHdl
, weld::Button
&, void);
385 void WriteBackLevel();
386 void UpdateDescriptor();
387 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
388 void OnModify(bool bAllLevels
);
389 DECL_LINK(ModifyClickHdl
, weld::Toggleable
&, void);
391 void ShowHideControls(int eType
);
392 void LevelHdlImpl(weld::TreeView
& rBox
, bool bGrabFocus
);
395 SwTOXEntryTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rAttrSet
);
396 virtual ~SwTOXEntryTabPage() override
;
398 virtual bool FillItemSet( SfxItemSet
* ) override
;
399 virtual void Reset( const SfxItemSet
* ) override
;
400 virtual void ActivatePage( const SfxItemSet
& ) override
;
401 virtual DeactivateRC
DeactivatePage( SfxItemSet
* pSet
) override
;
403 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
404 const SfxItemSet
* rAttrSet
);
405 void SetWrtShell(SwWrtShell
& rSh
);
407 void PreTokenButtonRemoved(const SwFormToken
& rToken
);
408 void SetFocus2theAllBtn();
411 class SwTOXStylesTabPage final
: public SfxTabPage
413 std::unique_ptr
<SwForm
> m_pCurrentForm
;
415 std::unique_ptr
<weld::TreeView
> m_xLevelLB
;
416 std::unique_ptr
<weld::Button
> m_xAssignBT
;
417 std::unique_ptr
<weld::TreeView
> m_xParaLayLB
;
418 std::unique_ptr
<weld::Button
> m_xStdBT
;
419 std::unique_ptr
<weld::Button
> m_xEditStyleBT
;
421 DECL_LINK(EditStyleHdl
, weld::Button
&, void);
422 DECL_LINK(StdHdl
, weld::Button
&, void);
423 DECL_LINK(EnableSelectHdl
, weld::TreeView
&, void);
424 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
425 DECL_LINK(AssignHdl
, weld::Button
&, void);
430 SwMultiTOXTabDialog
* pDlg
= static_cast<SwMultiTOXTabDialog
*>(GetDialogController());
431 return *pDlg
->GetForm(pDlg
->GetCurrentTOXType());
435 SwTOXStylesTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rAttrSet
);
436 virtual ~SwTOXStylesTabPage() override
;
438 virtual bool FillItemSet( SfxItemSet
* ) override
;
439 virtual void Reset( const SfxItemSet
* ) override
;
441 virtual void ActivatePage( const SfxItemSet
& ) override
;
442 virtual DeactivateRC
DeactivatePage( SfxItemSet
* pSet
) override
;
444 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
,
445 const SfxItemSet
* rAttrSet
);
449 #endif // INCLUDED_SW_SOURCE_UIBASE_INC_SWUICNTTAB_HXX
451 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */