LibreOffice Module starmath (master) 1
utility.hxx
Go to the documentation of this file.
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 <sal/config.h>
23#include "smdllapi.hxx"
24
25#include <comphelper/lok.hxx>
27#include <sal/log.hxx>
28#include <vcl/font.hxx>
29#include <vcl/weld.hxx>
30#include <tools/fract.hxx>
31#include <tools/mapunit.hxx>
32#include <deque>
33
34
35class SmViewShell;
37
38
39// SmFace
40
41
42bool IsItalic( const vcl::Font &rFont );
43bool IsBold( const vcl::Font &rFont );
44
45class SM_DLLPUBLIC SmFace final : public vcl::Font
46{
48
49 void Impl_Init();
50
51public:
53 Font(), nBorderWidth(-1) { Impl_Init(); }
54 SmFace(const Font& rFont) :
55 Font(rFont), nBorderWidth(-1) { Impl_Init(); }
56 SmFace(const OUString& rName, const Size& rSize) :
57 Font(rName, rSize), nBorderWidth(-1) { Impl_Init(); }
58
59 SmFace(const SmFace &rFace) :
60 Font(rFace), nBorderWidth(-1) { Impl_Init(); }
61
62 // overloaded version in order to supply a min value
63 // for font size (height). (Also used in ctor's to do so.)
64 void SetSize(const Size& rSize);
65
66 void SetBorderWidth(tools::Long nWidth) { nBorderWidth = nWidth; }
67 tools::Long GetBorderWidth() const;
69 void FreezeBorderWidth() { nBorderWidth = GetDefaultBorderWidth(); }
70
71 SmFace & operator = (const SmFace &rFace);
72};
73
74SmFace & operator *= (SmFace &rFace, const Fraction &rFrac);
75
76
77// SmFontPickList
78
79
80class SmFontDialog;
81
83{
84protected:
85 sal_uInt16 nMaxItems;
86 std::deque<vcl::Font> aFontVec;
87
88public:
89 explicit SmFontPickList(sal_uInt16 nMax = 5) : nMaxItems(nMax) {}
90 virtual ~SmFontPickList() { Clear(); }
91
92 virtual void Insert(const vcl::Font &rFont);
93
94 void Clear();
95 vcl::Font Get(sal_uInt16 nPos = 0) const;
96
98
99 void ReadFrom(const SmFontDialog& rDialog);
100 void WriteTo(SmFontDialog& rDialog) const;
101};
102
103
104// SmFontPickListBox
105
106
108{
109private:
110 std::unique_ptr<weld::ComboBox> m_xWidget;
111
112 DECL_LINK(SelectHdl, weld::ComboBox&, void);
113
114public:
115 SmFontPickListBox(std::unique_ptr<weld::ComboBox> pWidget);
117 virtual void Insert(const vcl::Font &rFont) override;
118};
119
120// Math uses 100ths of MM by default, but lok needs twips everywhere
122{
123 return comphelper::LibreOfficeKit::isActive() ? MapUnit::MapTwip : MapUnit::Map100thMM;
124}
126{
128}
129
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr int nBorderWidth
constexpr tools::Long Height() const
SmFace(const OUString &rName, const Size &rSize)
Definition: utility.hxx:56
SmFace()
Definition: utility.hxx:52
tools::Long nBorderWidth
Definition: utility.hxx:47
SmFace(const SmFace &rFace)
Definition: utility.hxx:59
void SetBorderWidth(tools::Long nWidth)
Definition: utility.hxx:66
SmFace(const Font &rFont)
Definition: utility.hxx:54
tools::Long GetDefaultBorderWidth() const
Definition: utility.hxx:68
void FreezeBorderWidth()
Definition: utility.hxx:69
SmFontPickListBox(std::unique_ptr< weld::ComboBox > pWidget)
Definition: utility.cxx:127
virtual void Insert(const vcl::Font &rFont) override
Definition: utility.cxx:161
SmFontPickListBox & operator=(const SmFontPickList &rList)
Definition: utility.cxx:148
DECL_LINK(SelectHdl, weld::ComboBox &, void)
std::unique_ptr< weld::ComboBox > m_xWidget
Definition: utility.hxx:110
void Clear()
Definition: utility.cxx:49
void ReadFrom(const SmFontDialog &rDialog)
Definition: utility.cxx:114
virtual ~SmFontPickList()
Definition: utility.hxx:90
vcl::Font Get(sal_uInt16 nPos=0) const
Definition: utility.cxx:63
void WriteTo(SmFontDialog &rDialog) const
Definition: utility.cxx:119
SmFontPickList(sal_uInt16 nMax=5)
Definition: utility.hxx:89
std::deque< vcl::Font > aFontVec
Definition: utility.hxx:86
virtual void Insert(const vcl::Font &rFont)
Definition: utility.cxx:97
sal_uInt16 nMaxItems
Definition: utility.hxx:85
SmFontPickList & operator=(const SmFontPickList &rList)
Definition: utility.cxx:54
const Size & GetFontSize() const
Font & operator=(const Font &)
MapUnit
long Long
#define SM_DLLPUBLIC
Definition: smdllapi.hxx:17
MapUnit SmMapUnit()
Definition: utility.hxx:121
o3tl::Length SmO3tlLengthUnit()
Definition: utility.hxx:125
bool IsItalic(const vcl::Font &rFont)
Definition: utility.cxx:176
SmFace & operator*=(SmFace &rFace, const Fraction &rFrac)
Definition: utility.cxx:234
bool IsBold(const vcl::Font &rFont)
Definition: utility.cxx:184
SmViewShell * SmGetActiveView()
! Since this method is based on the current focus it is somewhat ! unreliable and may return unexpect...
Definition: utility.cxx:33