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 .
21 #include <svtools/ctrlbox.hxx>
22 #include <svtools/valueset.hxx>
23 #include <sfx2/basedlgs.hxx>
24 #include <sfx2/tabdlg.hxx>
25 #include <svx/colorbox.hxx>
26 #include <svx/frmdirlbox.hxx>
29 #include "prcntfld.hxx"
31 const int nMaxCols
= 99;
36 class SwColumnDlg final
: public SfxDialogController
38 SwWrtShell
& m_rWrtShell
;
39 std::unique_ptr
<SwColumnPage
> m_xTabPage
;
40 std::unique_ptr
<SfxItemSet
> m_pPageSet
;
41 std::unique_ptr
<SfxItemSet
> m_pSectionSet
;
42 std::unique_ptr
<SfxItemSet
> m_pSelectionSet
;
43 SfxItemSet
* m_pFrameSet
;
45 tools::Long m_nOldSelection
;
46 tools::Long m_nSelectionWidth
;
47 tools::Long m_nPageWidth
;
49 bool m_bPageChanged
: 1;
50 bool m_bSectionChanged
: 1;
51 bool m_bSelSectionChanged
: 1;
52 bool m_bFrameChanged
: 1;
54 std::unique_ptr
<weld::Container
> m_xContentArea
;
55 std::unique_ptr
<weld::Button
> m_xOkButton
;
57 DECL_LINK(ObjectListBoxHdl
, weld::ComboBox
&, void);
58 DECL_LINK(OkHdl
, weld::Button
&, void);
59 void ObjectHdl(const weld::ComboBox
*);
60 SfxItemSet
* EvalCurrentSelection(void);
63 SwColumnDlg(weld::Window
* pParent
, SwWrtShell
& rSh
);
64 virtual ~SwColumnDlg() override
;
67 class ColumnValueSet final
: public ValueSet
74 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
76 ValueSet::SetDrawingArea(pDrawingArea
);
77 SetStyle(WB_TABSTOP
| WB_ITEMBORDER
| WB_DOUBLEBORDER
);
79 virtual void UserDraw(const UserDrawEvent
& rUDEvt
) override
;
80 virtual void StyleUpdated() override
;
83 // column dialog now as TabPage
84 class SwColumnPage final
: public SfxTabPage
86 std::unique_ptr
<SwColMgr
> m_xColMgr
;
88 sal_uInt16 m_nFirstVis
;
90 tools::Long m_nColWidth
[nMaxCols
];
91 tools::Long m_nColDist
[nMaxCols
];
92 SwPercentField
* m_pModifiedField
;
94 std::map
<weld::MetricSpinButton
*, SwPercentField
*> m_aPercentFieldsMap
;
101 ColumnValueSet m_aDefaultVS
;
102 SwColExample m_aPgeExampleWN
;
103 SwColumnOnlyExample m_aFrameExampleWN
;
105 std::unique_ptr
<weld::SpinButton
> m_xCLNrEdt
;
106 std::unique_ptr
<weld::CheckButton
> m_xBalanceColsCB
;
107 std::unique_ptr
<weld::Button
> m_xBtnBack
;
108 std::unique_ptr
<weld::Label
> m_xLbl1
;
109 std::unique_ptr
<weld::Label
> m_xLbl2
;
110 std::unique_ptr
<weld::Label
> m_xLbl3
;
111 std::unique_ptr
<weld::Button
> m_xBtnNext
;
112 std::unique_ptr
<weld::CheckButton
> m_xAutoWidthBox
;
113 std::unique_ptr
<weld::Label
> m_xLineTypeLbl
;
114 std::unique_ptr
<weld::Label
> m_xLineWidthLbl
;
115 std::unique_ptr
<weld::MetricSpinButton
> m_xLineWidthEdit
;
116 std::unique_ptr
<weld::Label
> m_xLineColorLbl
;
117 std::unique_ptr
<weld::Label
> m_xLineHeightLbl
;
118 std::unique_ptr
<weld::MetricSpinButton
> m_xLineHeightEdit
;
119 std::unique_ptr
<weld::Label
> m_xLinePosLbl
;
120 std::unique_ptr
<weld::ComboBox
> m_xLinePosDLB
;
121 std::unique_ptr
<weld::Label
> m_xTextDirectionFT
;
122 std::unique_ptr
<svx::FrameDirectionListBox
> m_xTextDirectionLB
;
123 std::unique_ptr
<ColorListBox
> m_xLineColorDLB
;
124 std::unique_ptr
<SvtLineListBox
> m_xLineTypeDLB
;
125 std::unique_ptr
<SwPercentField
> m_xEd1
;
126 std::unique_ptr
<SwPercentField
> m_xEd2
;
127 std::unique_ptr
<SwPercentField
> m_xEd3
;
128 std::unique_ptr
<SwPercentField
> m_xDistEd1
;
129 std::unique_ptr
<SwPercentField
> m_xDistEd2
;
130 std::unique_ptr
<weld::CustomWeld
> m_xDefaultVS
;
132 std::unique_ptr
<weld::CustomWeld
> m_xPgeExampleWN
;
133 std::unique_ptr
<weld::CustomWeld
> m_xFrameExampleWN
;
135 std::unique_ptr
<weld::Label
> m_xApplyToFT
;
136 std::unique_ptr
<weld::ComboBox
> m_xApplyToLB
;
139 DECL_LINK(ColModify
, weld::SpinButton
&, void);
140 void ColModify(bool bForceColReset
);
141 DECL_LINK(GapModify
, weld::MetricSpinButton
&, void);
142 DECL_LINK(EdModify
, weld::MetricSpinButton
&, void);
143 DECL_LINK(AutoWidthHdl
, weld::Toggleable
&, void );
144 DECL_LINK(SetDefaultsHdl
, ValueSet
*, void);
146 DECL_LINK(Up
, weld::Button
&, void);
147 DECL_LINK(Down
, weld::Button
&, void);
148 DECL_LINK(UpdateColMgr
, weld::MetricSpinButton
&, void);
149 DECL_LINK(UpdateColMgrListBox
, weld::ComboBox
&, void);
150 DECL_LINK(UpdateColMgrLineBox
, SvtLineListBox
&, void);
151 DECL_LINK(UpdateColMgrColorBox
, ColorListBox
&, void);
154 void Update(const weld::MetricSpinButton
* pInteractiveField
);
157 void ResetColWidth();
158 void SetLabels( sal_uInt16 nVis
);
160 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
161 virtual DeactivateRC
DeactivatePage(SfxItemSet
*pSet
) override
;
163 void connectPercentField(SwPercentField
&rWrap
);
165 bool isLineNotNone() const;
167 static const WhichRangesContainer s_aPageRg
;
170 SwColumnPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
);
171 virtual ~SwColumnPage() override
;
173 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
);
174 static WhichRangesContainer
GetRanges() { return s_aPageRg
; }
176 virtual bool FillItemSet(SfxItemSet
*rSet
) override
;
177 virtual void Reset(const SfxItemSet
*rSet
) override
;
179 void SetFrameMode(bool bMod
);
180 void SetPageWidth(tools::Long nPageWidth
);
182 void SetFormatUsed(bool bFormatUsed
)
184 m_bFormat
= bFormatUsed
;
187 void ShowBalance(bool bShow
)
189 m_xBalanceColsCB
->set_visible(bShow
);
192 void SetInSection(bool bSet
);
194 void ActivateColumnControl()
196 m_xCLNrEdt
->grab_focus();
199 weld::Label
* GetApplyLabel() { return m_xApplyToFT
.get(); }
200 weld::ComboBox
* GetApplyComboBox() { return m_xApplyToLB
.get(); }
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */