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 <comphelper/lok.hxx>
26 #include <o3tl/unit_conversion.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>
36 SmViewShell
* SmGetActiveView();
42 bool IsItalic( const vcl::Font
&rFont
);
43 bool IsBold( const vcl::Font
&rFont
);
45 class SM_DLLPUBLIC SmFace final
: public vcl::Font
47 tools::Long nBorderWidth
;
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(); }
59 SmFace(const SmFace
&rFace
) :
60 Font(rFace
), nBorderWidth(-1) { Impl_Init(); }
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
);
66 void SetBorderWidth(tools::Long nWidth
) { nBorderWidth
= nWidth
; }
67 tools::Long
GetBorderWidth() const;
68 tools::Long
GetDefaultBorderWidth() const { return GetFontSize().Height() / 20 ; }
69 void FreezeBorderWidth() { nBorderWidth
= GetDefaultBorderWidth(); }
71 SmFace
& operator = (const SmFace
&rFace
);
74 SmFace
& operator *= (SmFace
&rFace
, const Fraction
&rFrac
);
86 std::deque
<vcl::Font
> aFontVec
;
89 explicit SmFontPickList(sal_uInt16 nMax
= 5) : nMaxItems(nMax
) {}
90 virtual ~SmFontPickList() { Clear(); }
92 virtual void Insert(const vcl::Font
&rFont
);
95 vcl::Font
Get(sal_uInt16 nPos
= 0) const;
97 SmFontPickList
& operator = (const SmFontPickList
& rList
);
99 void ReadFrom(const SmFontDialog
& rDialog
);
100 void WriteTo(SmFontDialog
& rDialog
) const;
107 class SmFontPickListBox final
: public SmFontPickList
110 std::unique_ptr
<weld::ComboBox
> m_xWidget
;
112 DECL_LINK(SelectHdl
, weld::ComboBox
&, void);
115 SmFontPickListBox(std::unique_ptr
<weld::ComboBox
> pWidget
);
116 SmFontPickListBox
& operator = (const SmFontPickList
& rList
);
117 virtual void Insert(const vcl::Font
&rFont
) override
;
120 // Math uses 100ths of MM by default, but lok needs twips everywhere
121 inline MapUnit
SmMapUnit()
123 return comphelper::LibreOfficeKit::isActive() ? MapUnit::MapTwip
: MapUnit::Map100thMM
;
125 inline o3tl::Length
SmO3tlLengthUnit()
127 return comphelper::LibreOfficeKit::isActive() ? o3tl::Length::twip
: o3tl::Length::mm100
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */