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 <sal/config.h>
23 #include "smdllapi.hxx"
25 #include <o3tl/unit_conversion.hxx>
26 #include <sal/log.hxx>
27 #include <vcl/font.hxx>
28 #include <vcl/weld.hxx>
29 #include <tools/fract.hxx>
30 #include <tools/mapunit.hxx>
35 SmViewShell
* SmGetActiveView();
41 bool IsItalic( const vcl::Font
&rFont
);
42 bool IsBold( const vcl::Font
&rFont
);
44 class SM_DLLPUBLIC SmFace final
: public vcl::Font
46 tools::Long nBorderWidth
;
52 Font(), nBorderWidth(-1) { Impl_Init(); }
53 explicit SmFace(const Font
& rFont
) :
54 Font(rFont
), nBorderWidth(-1) { Impl_Init(); }
55 SmFace(const OUString
& rName
, const Size
& rSize
) :
56 Font(rName
, rSize
), nBorderWidth(-1) { Impl_Init(); }
58 SmFace(const SmFace
&rFace
) :
59 Font(rFace
), nBorderWidth(-1) { Impl_Init(); }
61 // overloaded version in order to supply a min value
62 // for font size (height). (Also used in ctor's to do so.)
63 void SetSize(const Size
& rSize
);
65 void SetBorderWidth(tools::Long nWidth
) { nBorderWidth
= nWidth
; }
66 tools::Long
GetBorderWidth() const;
67 tools::Long
GetDefaultBorderWidth() const { return GetFontSize().Height() / 20 ; }
68 void FreezeBorderWidth() { nBorderWidth
= GetDefaultBorderWidth(); }
70 SmFace
& operator = (const SmFace
&rFace
);
73 SmFace
& operator *= (SmFace
&rFace
, const Fraction
&rFrac
);
85 std::deque
<vcl::Font
> aFontVec
;
88 explicit SmFontPickList(sal_uInt16 nMax
= 5) : nMaxItems(nMax
) {}
89 virtual ~SmFontPickList() { Clear(); }
91 virtual void Insert(const vcl::Font
&rFont
);
94 vcl::Font
Get(sal_uInt16 nPos
= 0) const;
96 SmFontPickList
& operator = (const SmFontPickList
& rList
);
98 void ReadFrom(const SmFontDialog
& rDialog
);
99 void WriteTo(SmFontDialog
& rDialog
) const;
106 class SmFontPickListBox final
: public SmFontPickList
109 std::unique_ptr
<weld::ComboBox
> m_xWidget
;
111 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
114 SmFontPickListBox(std::unique_ptr
<weld::ComboBox
> pWidget
);
115 SmFontPickListBox
& operator = (const SmFontPickList
& rList
);
116 virtual void Insert(const vcl::Font
&rFont
) override
;
119 // Math used to use 100ths of MM by default, but now uses twips
120 // which seems to improve (subpixel) positioning.
121 inline MapUnit
SmMapUnit()
123 return MapUnit::MapTwip
;
125 inline o3tl::Length
SmO3tlLengthUnit()
127 return o3tl::Length::twip
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */