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 .
22 #include <sfx2/tabdlg.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/customweld.hxx>
32 #define CATEGORY_NONE 0xFFFF
34 /**************************************************************************/
36 void SetFontStyle(std::u16string_view rStyleName
, vcl::Font
&rFont
);
38 /**************************************************************************/
40 class SmPrintOptionsTabPage final
: public SfxTabPage
42 std::unique_ptr
<weld::CheckButton
> m_xTitle
;
43 std::unique_ptr
<weld::Widget
> m_xTitleImg
;
44 std::unique_ptr
<weld::CheckButton
> m_xText
;
45 std::unique_ptr
<weld::Widget
> m_xTextImg
;
46 std::unique_ptr
<weld::CheckButton
> m_xFrame
;
47 std::unique_ptr
<weld::Widget
> m_xFrameImg
;
48 std::unique_ptr
<weld::RadioButton
> m_xSizeNormal
;
49 std::unique_ptr
<weld::RadioButton
> m_xSizeScaled
;
50 std::unique_ptr
<weld::RadioButton
> m_xSizeZoomed
;
51 std::unique_ptr
<weld::Widget
> m_xLockPrintImg
;
52 std::unique_ptr
<weld::MetricSpinButton
> m_xZoom
;
53 std::unique_ptr
<weld::CheckButton
> m_xEnableInlineEdit
;
54 std::unique_ptr
<weld::Widget
> m_xEnableInlineEditImg
;
55 std::unique_ptr
<weld::CheckButton
> m_xNoRightSpaces
;
56 std::unique_ptr
<weld::Widget
> m_xNoRightSpacesImg
;
57 std::unique_ptr
<weld::CheckButton
> m_xSaveOnlyUsedSymbols
;
58 std::unique_ptr
<weld::Widget
> m_xSaveOnlyUsedSymbolsImg
;
59 std::unique_ptr
<weld::CheckButton
> m_xAutoCloseBrackets
;
60 std::unique_ptr
<weld::Widget
> m_xAutoCloseBracketsImg
;
61 std::unique_ptr
<weld::MetricSpinButton
> m_xSmZoom
;
62 std::unique_ptr
<weld::Widget
> m_xSmZoomImg
;
64 DECL_LINK(SizeButtonClickHdl
, weld::Toggleable
&, void);
66 virtual bool FillItemSet(SfxItemSet
* rSet
) override
;
67 virtual void Reset(const SfxItemSet
* rSet
) override
;
70 static std::unique_ptr
<SfxTabPage
> Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
);
72 SmPrintOptionsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rOptions
);
73 virtual ~SmPrintOptionsTabPage() override
;
75 virtual OUString
GetAllStrings() override
;
78 /**************************************************************************/
80 class SmShowFont final
: public weld::CustomWidgetController
82 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
90 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
91 void SetFont(const vcl::Font
& rFont
);
94 class SmFontDialog
: public weld::GenericDialogController
97 SmShowFont m_aShowFont
;
98 std::unique_ptr
<weld::EntryTreeView
> m_xFontBox
;
99 std::unique_ptr
<weld::Widget
> m_xAttrFrame
;
100 std::unique_ptr
<weld::CheckButton
> m_xBoldCheckBox
;
101 std::unique_ptr
<weld::CheckButton
> m_xItalicCheckBox
;
102 std::unique_ptr
<weld::CustomWeld
> m_xShowFont
;
104 DECL_LINK(FontSelectHdl
, weld::ComboBox
&, void);
105 DECL_LINK(AttrChangeHdl
, weld::Toggleable
&, void);
108 SmFontDialog(weld::Window
* pParent
, OutputDevice
*pFntListDevice
, bool bHideCheckboxes
);
109 virtual ~SmFontDialog() override
;
111 const vcl::Font
& GetFont() const
115 void SetFont(const vcl::Font
&rFont
);
118 /**************************************************************************/
120 class SmFontSizeDialog final
: public weld::GenericDialogController
122 std::unique_ptr
<weld::MetricSpinButton
> m_xBaseSize
;
123 std::unique_ptr
<weld::MetricSpinButton
> m_xTextSize
;
124 std::unique_ptr
<weld::MetricSpinButton
> m_xIndexSize
;
125 std::unique_ptr
<weld::MetricSpinButton
> m_xFunctionSize
;
126 std::unique_ptr
<weld::MetricSpinButton
> m_xOperatorSize
;
127 std::unique_ptr
<weld::MetricSpinButton
> m_xBorderSize
;
128 std::unique_ptr
<weld::Button
> m_xDefaultButton
;
130 DECL_LINK(DefaultButtonClickHdl
, weld::Button
&, void);
133 SmFontSizeDialog(weld::Window
*pParent
);
134 virtual ~SmFontSizeDialog() override
;
136 void ReadFrom(const SmFormat
&rFormat
);
137 void WriteTo (SmFormat
&rFormat
) const;
140 /**************************************************************************/
142 class SmFontTypeDialog final
: public weld::GenericDialogController
144 VclPtr
<OutputDevice
> pFontListDev
;
146 std::unique_ptr
<SmFontPickListBox
> m_xMathFont
;
147 std::unique_ptr
<SmFontPickListBox
> m_xVariableFont
;
148 std::unique_ptr
<SmFontPickListBox
> m_xFunctionFont
;
149 std::unique_ptr
<SmFontPickListBox
> m_xNumberFont
;
150 std::unique_ptr
<SmFontPickListBox
> m_xTextFont
;
151 std::unique_ptr
<SmFontPickListBox
> m_xSerifFont
;
152 std::unique_ptr
<SmFontPickListBox
> m_xSansFont
;
153 std::unique_ptr
<SmFontPickListBox
> m_xFixedFont
;
154 std::unique_ptr
<weld::MenuButton
> m_xMenuButton
;
155 std::unique_ptr
<weld::Button
> m_xDefaultButton
;
157 DECL_LINK(MenuSelectHdl
, const OUString
&, void);
158 DECL_LINK(DefaultButtonClickHdl
, weld::Button
&, void);
161 SmFontTypeDialog(weld::Window
* pParent
, OutputDevice
*pFntListDevice
);
162 virtual ~SmFontTypeDialog() override
;
164 void ReadFrom(const SmFormat
&rFormat
);
165 void WriteTo (SmFormat
&rFormat
) const;
168 /**************************************************************************/
170 #define NOCATEGORIES 10
176 std::unique_ptr
<weld::Widget
> Graphics
[4]; /* regular bitmaps */
177 sal_uInt16 Minimum
[4];
178 sal_uInt16 Maximum
[4];
182 SmCategoryDesc(weld::Builder
& rBuilder
, sal_uInt16 nCategoryIdx
);
185 const OUString
& GetName() const { return Name
; }
186 const OUString
& GetString(sal_uInt16 Index
) const { return Strings
[Index
]; }
187 sal_uInt16
GetMinimum(sal_uInt16 Index
) { return Minimum
[Index
]; }
188 sal_uInt16
GetMaximum(sal_uInt16 Index
) { return Maximum
[Index
]; }
189 sal_uInt16
GetValue(sal_uInt16 Index
) const { return Value
[Index
]; }
190 void SetValue(sal_uInt16 Index
, sal_uInt16 nVal
) { Value
[Index
] = nVal
;}
192 weld::Widget
* GetGraphic(sal_uInt16 Index
) const
194 return Graphics
[Index
].get();
198 class SmDistanceDialog final
: public weld::GenericDialogController
200 std::unique_ptr
<weld::Frame
> m_xFrame
;
201 std::unique_ptr
<weld::Label
> m_xFixedText1
;
202 std::unique_ptr
<weld::MetricSpinButton
> m_xMetricField1
;
203 std::unique_ptr
<weld::Label
> m_xFixedText2
;
204 std::unique_ptr
<weld::MetricSpinButton
> m_xMetricField2
;
205 std::unique_ptr
<weld::Label
> m_xFixedText3
;
206 std::unique_ptr
<weld::MetricSpinButton
> m_xMetricField3
;
207 std::unique_ptr
<weld::CheckButton
> m_xCheckBox1
;
208 std::unique_ptr
<weld::Label
> m_xFixedText4
;
209 std::unique_ptr
<weld::MetricSpinButton
> m_xMetricField4
;
210 std::unique_ptr
<weld::MenuButton
> m_xMenuButton
;
211 std::unique_ptr
<weld::Button
> m_xDefaultButton
;
212 std::unique_ptr
<weld::Widget
> m_xBitmap
;
214 weld::Widget
* m_pCurrentImage
;
216 std::unique_ptr
<SmCategoryDesc
> m_xCategories
[NOCATEGORIES
];
217 sal_uInt16 nActiveCategory
;
218 bool bScaleAllBrackets
;
220 DECL_LINK(GetFocusHdl
, weld::Widget
&, void);
221 DECL_LINK(MenuSelectHdl
, const OUString
&, void);
222 DECL_LINK(DefaultButtonClickHdl
, weld::Button
&, void);
223 DECL_LINK(CheckBoxClickHdl
, weld::Toggleable
&, void);
225 void SetCategory(sal_uInt16 Category
);
228 SmDistanceDialog(weld::Window
*pParent
);
229 virtual ~SmDistanceDialog() override
;
231 void ReadFrom(const SmFormat
&rFormat
);
232 void WriteTo (SmFormat
&rFormat
);
235 /**************************************************************************/
238 class SmAlignDialog final
: public weld::GenericDialogController
240 std::unique_ptr
<weld::RadioButton
> m_xLeft
;
241 std::unique_ptr
<weld::RadioButton
> m_xCenter
;
242 std::unique_ptr
<weld::RadioButton
> m_xRight
;
243 std::unique_ptr
<weld::Button
> m_xDefaultButton
;
245 DECL_LINK(DefaultButtonClickHdl
, weld::Button
&, void);
248 SmAlignDialog(weld::Window
*pParent
);
249 virtual ~SmAlignDialog() override
;
251 void ReadFrom(const SmFormat
&rFormat
);
252 void WriteTo (SmFormat
&rFormat
) const;
255 /**************************************************************************/
257 class SmShowSymbolSet final
: public weld::CustomWidgetController
259 SmViewShell
&m_rViewShell
;
261 SymbolPtrVec_t aSymbolSet
;
262 Link
<SmShowSymbolSet
&,void> aSelectHdlLink
;
263 Link
<SmShowSymbolSet
&,void> aDblClickHdlLink
;
265 sal_Int32 nRows
, nColumns
;
266 tools::Long nXOffset
, nYOffset
;
267 sal_uInt16 nSelectSymbol
;
268 std::unique_ptr
<weld::ScrolledWindow
> m_xScrolledWindow
;
270 void SetScrollBarRange();
271 Point
OffsetPoint(const Point
&rPoint
) const;
273 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
274 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
275 virtual bool KeyInput(const KeyEvent
& rKEvt
) override
;
276 virtual void Resize() override
;
278 DECL_LINK(ScrollHdl
, weld::ScrolledWindow
&, void);
281 SmShowSymbolSet(std::unique_ptr
<weld::ScrolledWindow
> pScrolledWindow
, SmViewShell
&rViewShell
);
283 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
285 CustomWidgetController::SetDrawingArea(pDrawingArea
);
286 m_aOldSize
= Size(pDrawingArea
->get_approximate_digit_width() * 27,
287 pDrawingArea
->get_text_height() * 9);
288 pDrawingArea
->set_size_request(m_aOldSize
.Width(), m_aOldSize
.Height());
289 SetOutputSizePixel(m_aOldSize
);
290 calccols(pDrawingArea
->get_ref_device());
293 void calccols(const vcl::RenderContext
& rRenderContext
);
294 void SelectSymbol(sal_uInt16 nSymbol
);
295 sal_uInt16
GetSelectSymbol() const { return nSelectSymbol
; }
296 void SetSymbolSet(const SymbolPtrVec_t
& rSymbolSet
);
297 void SetSelectHdl(const Link
<SmShowSymbolSet
&,void>& rLink
) { aSelectHdlLink
= rLink
; }
298 void SetDblClickHdl(const Link
<SmShowSymbolSet
&,void>& rLink
) { aDblClickHdlLink
= rLink
; }
301 class SmShowSymbol final
: public weld::CustomWidgetController
304 SmViewShell
&m_rViewShell
;
308 Link
<SmShowSymbol
&,void> aDblClickHdlLink
;
310 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
311 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
313 void setFontSize(vcl::Font
&rFont
) const;
316 SmShowSymbol(SmViewShell
&rViewShell
);
318 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
320 CustomWidgetController::SetDrawingArea(pDrawingArea
);
321 pDrawingArea
->set_size_request(pDrawingArea
->get_approximate_digit_width() * 27,
322 pDrawingArea
->get_text_height() * 9);
325 void SetText(const OUString
& rText
) { m_aText
= rText
; }
326 const OUString
& GetText() const { return m_aText
; }
328 void SetFont(const vcl::Font
& rFont
) { m_aFont
= rFont
; }
329 const vcl::Font
& GetFont() const { return m_aFont
; }
331 void SetSymbol(const SmSym
*pSymbol
);
332 void SetDblClickHdl(const Link
<SmShowSymbol
&,void> &rLink
) { aDblClickHdlLink
= rLink
; }
335 class SmSymbolDialog final
: public weld::GenericDialogController
337 SmViewShell
&m_rViewSh
;
338 SmSymbolManager
&m_rSymbolMgr
;
340 OUString m_aSymbolSetName
;
341 SymbolPtrVec_t m_aSymbolSet
;
343 VclPtr
<OutputDevice
> m_pFontListDev
;
345 SmShowSymbol m_aSymbolDisplay
;
347 std::unique_ptr
<weld::ComboBox
> m_xSymbolSets
;
348 std::unique_ptr
<SmShowSymbolSet
> m_xSymbolSetDisplay
;
349 std::unique_ptr
<weld::CustomWeld
> m_xSymbolSetDisplayArea
;
350 std::unique_ptr
<weld::Label
> m_xSymbolName
;
351 std::unique_ptr
<weld::CustomWeld
> m_xSymbolDisplay
;
352 std::unique_ptr
<weld::Button
> m_xGetBtn
;
353 std::unique_ptr
<weld::Button
> m_xEditBtn
;
355 DECL_LINK(SymbolSetChangeHdl
, weld::ComboBox
&, void);
356 DECL_LINK(SymbolChangeHdl
, SmShowSymbolSet
&, void);
357 DECL_LINK(SymbolDblClickHdl
, SmShowSymbol
&, void);
358 DECL_LINK(SymbolDblClickHdl2
, SmShowSymbolSet
&, void);
359 DECL_LINK(EditClickHdl
, weld::Button
&, void);
360 DECL_LINK(GetClickHdl
, weld::Button
&, void);
361 void SymbolDblClickHdl();
363 void FillSymbolSets();
364 const SmSym
*GetSymbol() const;
367 SmSymbolDialog(weld::Window
* pParent
, OutputDevice
*pFntListDevice
,
368 SmSymbolManager
&rSymbolMgr
, SmViewShell
&rViewShell
);
369 virtual ~SmSymbolDialog() override
;
371 bool SelectSymbolSet(const OUString
&rSymbolSetName
);
372 void SelectSymbol(sal_uInt16 nSymbolPos
);
375 class SmShowChar final
: public weld::CustomWidgetController
381 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
382 virtual void Resize() override
;
389 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
391 CustomWidgetController::SetDrawingArea(pDrawingArea
);
392 pDrawingArea
->set_size_request(pDrawingArea
->get_approximate_digit_width() * 7,
393 pDrawingArea
->get_text_height() * 3);
396 void SetSymbol(const SmSym
*pSym
);
397 void SetSymbol(sal_UCS4 cChar
, const vcl::Font
&rFont
);
398 void SetText(const OUString
& rText
) { m_aText
= rText
; }
399 const OUString
& GetText() const { return m_aText
; }
400 void SetFont(const vcl::Font
& rFont
) { m_aFont
= rFont
; }
401 const vcl::Font
& GetFont() const { return m_aFont
; }
404 class SmSymDefineDialog final
: public weld::GenericDialogController
406 VclPtr
<VirtualDevice
> m_xVirDev
;
407 SmSymbolManager m_aSymbolMgrCopy
;
408 SmSymbolManager
& m_rSymbolMgr
;
409 SmShowChar m_aOldSymbolDisplay
;
410 SmShowChar m_aSymbolDisplay
;
411 std::unique_ptr
<SmSym
> m_xOrigSymbol
;
412 std::unique_ptr
<SubsetMap
> m_xSubsetMap
;
413 std::unique_ptr
<FontList
> m_xFontList
;
414 std::unique_ptr
<weld::ComboBox
> m_xOldSymbols
;
415 std::unique_ptr
<weld::ComboBox
> m_xOldSymbolSets
;
416 std::unique_ptr
<weld::ComboBox
> m_xSymbols
;
417 std::unique_ptr
<weld::ComboBox
> m_xSymbolSets
;
418 std::unique_ptr
<weld::ComboBox
> m_xFonts
;
419 std::unique_ptr
<weld::ComboBox
> m_xFontsSubsetLB
;
420 std::unique_ptr
<weld::ComboBox
> m_xStyles
;
421 std::unique_ptr
<weld::Label
> m_xOldSymbolName
;
422 std::unique_ptr
<weld::Label
> m_xOldSymbolSetName
;
423 std::unique_ptr
<weld::Label
> m_xSymbolName
;
424 std::unique_ptr
<weld::Label
> m_xSymbolSetName
;
425 std::unique_ptr
<weld::Button
> m_xAddBtn
;
426 std::unique_ptr
<weld::Button
> m_xChangeBtn
;
427 std::unique_ptr
<weld::Button
> m_xDeleteBtn
;
428 std::unique_ptr
<weld::CustomWeld
> m_xOldSymbolDisplay
;
429 std::unique_ptr
<weld::CustomWeld
> m_xSymbolDisplay
;
430 std::unique_ptr
<SvxShowCharSet
> m_xCharsetDisplay
;
431 std::unique_ptr
<weld::CustomWeld
> m_xCharsetDisplayArea
;
433 DECL_LINK(OldSymbolChangeHdl
, weld::ComboBox
&, void);
434 DECL_LINK(OldSymbolSetChangeHdl
, weld::ComboBox
&, void);
435 DECL_LINK(ModifyHdl
, weld::ComboBox
&, void);
436 DECL_LINK(FontChangeHdl
, weld::ComboBox
&, void);
437 DECL_LINK(SubsetChangeHdl
, weld::ComboBox
&, void);
438 DECL_LINK(StyleChangeHdl
, weld::ComboBox
&, void);
439 DECL_LINK(CharHighlightHdl
, SvxShowCharSet
*, void);
440 DECL_LINK(AddClickHdl
, weld::Button
&, void);
441 DECL_LINK(ChangeClickHdl
, weld::Button
&, void);
442 DECL_LINK(DeleteClickHdl
, weld::Button
&, void);
444 void FillSymbols(weld::ComboBox
& rComboBox
, bool bDeleteText
= true);
445 void FillSymbolSets(weld::ComboBox
& rComboBox
, bool bDeleteText
= true);
449 void SetSymbolSetManager(const SmSymbolManager
&rMgr
);
450 void SetFont(const OUString
&rFontName
, std::u16string_view rStyleName
);
451 void SetOrigSymbol(const SmSym
*pSymbol
, const OUString
&rSymbolSetName
);
452 void UpdateButtons();
454 bool SelectSymbolSet(weld::ComboBox
&rComboBox
, std::u16string_view rSymbolSetName
,
456 bool SelectSymbol(weld::ComboBox
& rComboBox
, const OUString
&rSymbolName
,
458 bool SelectFont(const OUString
&rFontName
, bool bApplyFont
);
459 bool SelectStyle(const OUString
&rStyleName
, bool bApplyFont
);
461 SmSym
* GetSymbol(const weld::ComboBox
& rComboBox
);
462 const SmSym
* GetSymbol(const weld::ComboBox
& rComboBox
) const
464 return const_cast<SmSymDefineDialog
*>(this)->GetSymbol(rComboBox
);
468 SmSymDefineDialog(weld::Window
*pParent
, OutputDevice
*pFntListDevice
, SmSymbolManager
&rMgr
);
469 virtual ~SmSymDefineDialog() override
;
471 virtual short run() override
;
473 void SelectOldSymbolSet(std::u16string_view rSymbolSetName
)
475 SelectSymbolSet(*m_xOldSymbolSets
, rSymbolSetName
, false);
478 void SelectOldSymbol(const OUString
&rSymbolName
)
480 SelectSymbol(*m_xOldSymbols
, rSymbolName
, false);
483 bool SelectSymbolSet(std::u16string_view rSymbolSetName
)
485 return SelectSymbolSet(*m_xSymbolSets
, rSymbolSetName
, false);
488 bool SelectSymbol(const OUString
&rSymbolName
)
490 return SelectSymbol(*m_xSymbols
, rSymbolName
, false);
493 bool SelectFont(const OUString
&rFontName
) { return SelectFont(rFontName
, true); }
494 bool SelectStyle(const OUString
&rStyleName
) { return SelectStyle(rStyleName
, true); };
495 void SelectChar(sal_Unicode cChar
);
498 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */