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 .
20 #include <drawinglayer/attribute/fontattribute.hxx>
21 #include <rtl/ustring.hxx>
24 namespace drawinglayer::attribute
26 class ImpFontAttribute
30 OUString maFamilyName
; // Font Family Name
31 OUString maStyleName
; // Font Style Name
32 sal_uInt16 mnWeight
; // Font weight
34 bool mbSymbol
: 1; // Symbol Font Flag
35 bool mbVertical
: 1; // Vertical Text Flag
36 bool mbItalic
: 1; // Italic Flag
37 bool mbOutline
: 1; // Outline Flag
38 bool mbRTL
: 1; // RTL Flag
39 bool mbBiDiStrong
: 1; // BiDi Flag
40 bool mbMonospaced
: 1;
42 ImpFontAttribute(OUString aFamilyName
, OUString aStyleName
, sal_uInt16 nWeight
, bool bSymbol
,
43 bool bVertical
, bool bItalic
, bool bMonospaced
, bool bOutline
, bool bRTL
,
45 : maFamilyName(std::move(aFamilyName
))
46 , maStyleName(std::move(aStyleName
))
49 , mbVertical(bVertical
)
53 , mbBiDiStrong(bBiDiStrong
)
54 , mbMonospaced(bMonospaced
)
71 const OUString
& getFamilyName() const { return maFamilyName
; }
72 const OUString
& getStyleName() const { return maStyleName
; }
73 sal_uInt16
getWeight() const { return mnWeight
; }
74 bool getSymbol() const { return mbSymbol
; }
75 bool getVertical() const { return mbVertical
; }
76 bool getItalic() const { return mbItalic
; }
77 bool getOutline() const { return mbOutline
; }
78 bool getRTL() const { return mbRTL
; }
79 bool getBiDiStrong() const { return mbBiDiStrong
; }
80 bool getMonospaced() const { return mbMonospaced
; }
82 bool operator==(const ImpFontAttribute
& rCompare
) const
84 return (getFamilyName() == rCompare
.getFamilyName()
85 && getStyleName() == rCompare
.getStyleName() && getWeight() == rCompare
.getWeight()
86 && getSymbol() == rCompare
.getSymbol() && getVertical() == rCompare
.getVertical()
87 && getItalic() == rCompare
.getItalic() && getOutline() == rCompare
.getOutline()
88 && getRTL() == rCompare
.getRTL() && getBiDiStrong() == rCompare
.getBiDiStrong()
89 && getMonospaced() == rCompare
.getMonospaced());
95 FontAttribute::ImplType
& theGlobalDefault()
97 static FontAttribute::ImplType SINGLETON
;
102 FontAttribute::FontAttribute(const OUString
& rFamilyName
, const OUString
& rStyleName
,
103 sal_uInt16 nWeight
, bool bSymbol
, bool bVertical
, bool bItalic
,
104 bool bMonospaced
, bool bOutline
, bool bRTL
, bool bBiDiStrong
)
105 : mpFontAttribute(ImpFontAttribute(rFamilyName
, rStyleName
, nWeight
, bSymbol
, bVertical
,
106 bItalic
, bMonospaced
, bOutline
, bRTL
, bBiDiStrong
))
110 FontAttribute::FontAttribute()
111 : mpFontAttribute(theGlobalDefault())
115 FontAttribute::FontAttribute(const FontAttribute
&) = default;
117 FontAttribute::FontAttribute(FontAttribute
&&) = default;
119 FontAttribute::~FontAttribute() = default;
121 FontAttribute
& FontAttribute::operator=(const FontAttribute
&) = default;
123 FontAttribute
& FontAttribute::operator=(FontAttribute
&&) = default;
125 bool FontAttribute::operator==(const FontAttribute
& rCandidate
) const
127 return rCandidate
.mpFontAttribute
== mpFontAttribute
;
130 const OUString
& FontAttribute::getFamilyName() const { return mpFontAttribute
->getFamilyName(); }
132 const OUString
& FontAttribute::getStyleName() const { return mpFontAttribute
->getStyleName(); }
134 sal_uInt16
FontAttribute::getWeight() const { return mpFontAttribute
->getWeight(); }
136 bool FontAttribute::getSymbol() const { return mpFontAttribute
->getSymbol(); }
138 bool FontAttribute::getVertical() const { return mpFontAttribute
->getVertical(); }
140 bool FontAttribute::getItalic() const { return mpFontAttribute
->getItalic(); }
142 bool FontAttribute::getOutline() const { return mpFontAttribute
->getOutline(); }
144 bool FontAttribute::getRTL() const { return mpFontAttribute
->getRTL(); }
146 bool FontAttribute::getBiDiStrong() const { return mpFontAttribute
->getBiDiStrong(); }
148 bool FontAttribute::getMonospaced() const { return mpFontAttribute
->getMonospaced(); }
150 } // end of namespace
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */