Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/starmath/inc/dialog.hxx
Line
Count
Source (jump to first uncovered line)
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
20
#pragma once
21
22
#include <sfx2/tabdlg.hxx>
23
#include <vcl/outdev.hxx>
24
#include <vcl/customweld.hxx>
25
#include "symbol.hxx"
26
27
class SubsetMap;
28
class SmFormat;
29
class FontList;
30
class SvxShowCharSet;
31
32
0
#define CATEGORY_NONE   0xFFFF
33
34
/**************************************************************************/
35
36
void SetFontStyle(std::u16string_view rStyleName, vcl::Font &rFont);
37
38
/**************************************************************************/
39
40
class SmPrintOptionsTabPage final : public SfxTabPage
41
{
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;
63
64
    DECL_LINK(SizeButtonClickHdl, weld::Toggleable&, void);
65
66
    virtual bool    FillItemSet(SfxItemSet* rSet) override;
67
    virtual void    Reset(const SfxItemSet* rSet) override;
68
69
public:
70
    static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
71
72
    SmPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions);
73
    virtual ~SmPrintOptionsTabPage() override;
74
75
    virtual OUString GetAllStrings() override;
76
};
77
78
/**************************************************************************/
79
80
class SmShowFont final : public weld::CustomWidgetController
81
{
82
    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
83
84
    vcl::Font maFont;
85
86
public:
87
    SmShowFont()
88
0
    {
89
0
    }
90
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
91
    void SetFont(const vcl::Font& rFont);
92
};
93
94
class SmFontDialog : public weld::GenericDialogController
95
{
96
    vcl::Font maFont;
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;
103
104
    DECL_LINK(FontSelectHdl, weld::ComboBox&, void);
105
    DECL_LINK(AttrChangeHdl, weld::Toggleable&, void);
106
107
public:
108
    SmFontDialog(weld::Window* pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
109
    virtual ~SmFontDialog() override;
110
111
    const vcl::Font& GetFont() const
112
0
    {
113
0
        return maFont;
114
0
    }
115
    void SetFont(const vcl::Font &rFont);
116
};
117
118
/**************************************************************************/
119
120
class SmFontSizeDialog final : public weld::GenericDialogController
121
{
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;
129
130
    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
131
132
public:
133
    SmFontSizeDialog(weld::Window *pParent);
134
    virtual ~SmFontSizeDialog() override;
135
136
    void ReadFrom(const SmFormat &rFormat);
137
    void WriteTo (SmFormat &rFormat) const;
138
};
139
140
/**************************************************************************/
141
142
class SmFontTypeDialog final : public weld::GenericDialogController
143
{
144
    VclPtr<OutputDevice> pFontListDev;
145
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;
156
157
    DECL_LINK(MenuSelectHdl, const OUString&, void);
158
    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
159
160
public:
161
    SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice);
162
    virtual ~SmFontTypeDialog() override;
163
164
    void ReadFrom(const SmFormat &rFormat);
165
    void WriteTo (SmFormat &rFormat) const;
166
};
167
168
/**************************************************************************/
169
170
0
#define NOCATEGORIES    10
171
172
class SmCategoryDesc
173
{
174
    OUString Name;
175
    OUString Strings[4];
176
    std::unique_ptr<weld::Widget> Graphics[4];    /* regular bitmaps */
177
    sal_uInt16 Minimum[4];
178
    sal_uInt16 Maximum[4];
179
    sal_uInt16 Value[4];
180
181
public:
182
    SmCategoryDesc(weld::Builder& rBuilder, sal_uInt16 nCategoryIdx);
183
    ~SmCategoryDesc();
184
185
0
    const OUString& GetName() const                 { return Name; }
186
0
    const OUString& GetString(sal_uInt16 Index) const   { return Strings[Index];  }
187
0
    sal_uInt16          GetMinimum(sal_uInt16 Index)        { return Minimum[Index]; }
188
0
    sal_uInt16          GetMaximum(sal_uInt16 Index)        { return Maximum[Index]; }
189
0
    sal_uInt16          GetValue(sal_uInt16 Index) const    { return Value[Index]; }
190
0
    void            SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
191
192
    weld::Widget* GetGraphic(sal_uInt16 Index) const
193
0
    {
194
0
        return Graphics[Index].get();
195
0
    }
196
};
197
198
class SmDistanceDialog final : public weld::GenericDialogController
199
{
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;
213
214
    weld::Widget* m_pCurrentImage;
215
216
    std::unique_ptr<SmCategoryDesc> m_xCategories[NOCATEGORIES];
217
    sal_uInt16          nActiveCategory;
218
    bool            bScaleAllBrackets;
219
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);
224
225
    void    SetCategory(sal_uInt16 Category);
226
227
public:
228
    SmDistanceDialog(weld::Window *pParent);
229
    virtual ~SmDistanceDialog() override;
230
231
    void ReadFrom(const SmFormat &rFormat);
232
    void WriteTo (SmFormat &rFormat);
233
};
234
235
/**************************************************************************/
236
237
238
class SmAlignDialog final : public weld::GenericDialogController
239
{
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;
244
245
    DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
246
247
public:
248
    SmAlignDialog(weld::Window *pParent);
249
    virtual ~SmAlignDialog() override;
250
251
    void ReadFrom(const SmFormat &rFormat);
252
    void WriteTo (SmFormat &rFormat) const;
253
};
254
255
/**************************************************************************/
256
257
class SmShowSymbolSet final : public weld::CustomWidgetController
258
{
259
    SmViewShell &m_rViewShell;
260
    Size m_aOldSize;
261
    SymbolPtrVec_t aSymbolSet;
262
    Link<SmShowSymbolSet&,void> aSelectHdlLink;
263
    Link<SmShowSymbolSet&,void> aDblClickHdlLink;
264
    tools::Long        nLen;
265
    sal_Int32      nRows, nColumns;
266
    tools::Long        nXOffset, nYOffset;
267
    sal_uInt16  nSelectSymbol;
268
    std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
269
270
    void SetScrollBarRange();
271
    Point OffsetPoint(const Point &rPoint) const;
272
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;
277
278
    DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
279
280
public:
281
    SmShowSymbolSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow, SmViewShell &rViewShell);
282
283
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
284
0
    {
285
0
        CustomWidgetController::SetDrawingArea(pDrawingArea);
286
0
        m_aOldSize = Size(pDrawingArea->get_approximate_digit_width() * 27,
287
0
                          pDrawingArea->get_text_height() * 9);
288
0
        pDrawingArea->set_size_request(m_aOldSize.Width(), m_aOldSize.Height());
289
0
        SetOutputSizePixel(m_aOldSize);
290
0
        calccols(pDrawingArea->get_ref_device());
291
0
    }
292
293
    void calccols(const vcl::RenderContext& rRenderContext);
294
    void    SelectSymbol(sal_uInt16 nSymbol);
295
0
    sal_uInt16  GetSelectSymbol() const { return nSelectSymbol; }
296
    void SetSymbolSet(const SymbolPtrVec_t & rSymbolSet);
297
0
    void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; }
298
0
    void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; }
299
};
300
301
class SmShowSymbol final : public weld::CustomWidgetController
302
{
303
private:
304
    SmViewShell &m_rViewShell;
305
    vcl::Font m_aFont;
306
    OUString m_aText;
307
308
    Link<SmShowSymbol&,void> aDblClickHdlLink;
309
310
    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
311
    virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
312
313
    void setFontSize(vcl::Font &rFont) const;
314
315
public:
316
    SmShowSymbol(SmViewShell &rViewShell);
317
318
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
319
0
    {
320
0
        CustomWidgetController::SetDrawingArea(pDrawingArea);
321
0
        pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
322
0
                                       pDrawingArea->get_text_height() * 9);
323
0
    }
324
325
0
    void SetText(const OUString& rText) { m_aText = rText; }
326
0
    const OUString& GetText() const { return m_aText; }
327
328
0
    void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
329
0
    const vcl::Font& GetFont() const { return m_aFont; }
330
331
    void    SetSymbol(const SmSym *pSymbol);
332
0
    void    SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; }
333
};
334
335
class SmSymbolDialog final : public weld::GenericDialogController
336
{
337
    SmViewShell        &m_rViewSh;
338
    SmSymbolManager    &m_rSymbolMgr;
339
340
    OUString       m_aSymbolSetName;
341
    SymbolPtrVec_t      m_aSymbolSet;
342
343
    VclPtr<OutputDevice> m_pFontListDev;
344
345
    SmShowSymbol m_aSymbolDisplay;
346
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;
354
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();
362
363
    void            FillSymbolSets();
364
    const SmSym    *GetSymbol() const;
365
366
public:
367
    SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice,
368
            SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
369
    virtual ~SmSymbolDialog() override;
370
371
    bool    SelectSymbolSet(const OUString &rSymbolSetName);
372
    void    SelectSymbol(sal_uInt16 nSymbolPos);
373
};
374
375
class SmShowChar final : public weld::CustomWidgetController
376
{
377
private:
378
    OUString m_aText;
379
    vcl::Font m_aFont;
380
381
    virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
382
    virtual void Resize() override;
383
384
public:
385
    SmShowChar()
386
0
    {
387
0
    }
388
389
    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
390
0
    {
391
0
        CustomWidgetController::SetDrawingArea(pDrawingArea);
392
0
        pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7,
393
0
                                       pDrawingArea->get_text_height() * 3);
394
0
    }
395
396
    void SetSymbol(const SmSym *pSym);
397
    void SetSymbol(sal_UCS4 cChar, const vcl::Font &rFont);
398
0
    void SetText(const OUString& rText) { m_aText = rText; }
399
0
    const OUString& GetText() const { return m_aText; }
400
0
    void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
401
0
    const vcl::Font& GetFont() const { return m_aFont; }
402
};
403
404
class SmSymDefineDialog final : public weld::GenericDialogController
405
{
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;
432
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);
443
444
    void    FillSymbols(weld::ComboBox& rComboBox, bool bDeleteText = true);
445
    void    FillSymbolSets(weld::ComboBox& rComboBox, bool bDeleteText = true);
446
    void    FillFonts();
447
    void    FillStyles();
448
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();
453
454
    bool    SelectSymbolSet(weld::ComboBox &rComboBox, std::u16string_view rSymbolSetName,
455
                            bool bDeleteText);
456
    bool    SelectSymbol(weld::ComboBox& rComboBox, const OUString &rSymbolName,
457
                            bool bDeleteText);
458
    bool    SelectFont(const OUString &rFontName, bool bApplyFont);
459
    bool    SelectStyle(const OUString &rStyleName, bool bApplyFont);
460
461
    SmSym* GetSymbol(const weld::ComboBox& rComboBox);
462
    const SmSym* GetSymbol(const weld::ComboBox& rComboBox) const
463
0
    {
464
0
        return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
465
0
    }
466
467
public:
468
    SmSymDefineDialog(weld::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
469
    virtual ~SmSymDefineDialog() override;
470
471
    virtual short run() override;
472
473
    void SelectOldSymbolSet(std::u16string_view rSymbolSetName)
474
0
    {
475
0
        SelectSymbolSet(*m_xOldSymbolSets, rSymbolSetName, false);
476
0
    }
477
478
    void SelectOldSymbol(const OUString &rSymbolName)
479
0
    {
480
0
        SelectSymbol(*m_xOldSymbols, rSymbolName, false);
481
0
    }
482
483
    bool SelectSymbolSet(std::u16string_view rSymbolSetName)
484
0
    {
485
0
        return SelectSymbolSet(*m_xSymbolSets, rSymbolSetName, false);
486
0
    }
487
488
    bool SelectSymbol(const OUString &rSymbolName)
489
0
    {
490
0
        return SelectSymbol(*m_xSymbols, rSymbolName, false);
491
0
    }
492
493
0
    bool        SelectFont(const OUString &rFontName)   { return SelectFont(rFontName, true); }
494
0
    bool        SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
495
    void        SelectChar(sal_Unicode cChar);
496
};
497
498
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */