LibreOffice Module drawinglayer (master) 1
fontattribute.cxx
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
21#include <rtl/ustring.hxx>
22#include <utility>
23
25{
27{
28public:
30 OUString maFamilyName; // Font Family Name
31 OUString maStyleName; // Font Style Name
32 sal_uInt16 mnWeight; // Font weight
33
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;
41
42 ImpFontAttribute(OUString aFamilyName, OUString aStyleName, sal_uInt16 nWeight, bool bSymbol,
43 bool bVertical, bool bItalic, bool bMonospaced, bool bOutline, bool bRTL,
44 bool bBiDiStrong)
45 : maFamilyName(std::move(aFamilyName))
46 , maStyleName(std::move(aStyleName))
47 , mnWeight(nWeight)
48 , mbSymbol(bSymbol)
49 , mbVertical(bVertical)
50 , mbItalic(bItalic)
51 , mbOutline(bOutline)
52 , mbRTL(bRTL)
53 , mbBiDiStrong(bBiDiStrong)
54 , mbMonospaced(bMonospaced)
55 {
56 }
57
59 : mnWeight(0)
60 , mbSymbol(false)
61 , mbVertical(false)
62 , mbItalic(false)
63 , mbOutline(false)
64 , mbRTL(false)
65 , mbBiDiStrong(false)
66 , mbMonospaced(false)
67 {
68 }
69
70 // data read access
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; }
81
82 bool operator==(const ImpFontAttribute& rCompare) const
83 {
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());
90 }
91};
92
93namespace
94{
95FontAttribute::ImplType& theGlobalDefault()
96{
97 static FontAttribute::ImplType SINGLETON;
98 return SINGLETON;
99}
100}
101
102FontAttribute::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))
107{
108}
109
111 : mpFontAttribute(theGlobalDefault())
112{
113}
114
116
118
120
122
124
125bool FontAttribute::operator==(const FontAttribute& rCandidate) const
126{
127 return rCandidate.mpFontAttribute == mpFontAttribute;
128}
129
130const OUString& FontAttribute::getFamilyName() const { return mpFontAttribute->getFamilyName(); }
131
132const OUString& FontAttribute::getStyleName() const { return mpFontAttribute->getStyleName(); }
133
134sal_uInt16 FontAttribute::getWeight() const { return mpFontAttribute->getWeight(); }
135
136bool FontAttribute::getSymbol() const { return mpFontAttribute->getSymbol(); }
137
138bool FontAttribute::getVertical() const { return mpFontAttribute->getVertical(); }
139
140bool FontAttribute::getItalic() const { return mpFontAttribute->getItalic(); }
141
142bool FontAttribute::getOutline() const { return mpFontAttribute->getOutline(); }
143
144bool FontAttribute::getRTL() const { return mpFontAttribute->getRTL(); }
145
146bool FontAttribute::getBiDiStrong() const { return mpFontAttribute->getBiDiStrong(); }
147
148bool FontAttribute::getMonospaced() const { return mpFontAttribute->getMonospaced(); }
149
150} // end of namespace
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const FontAttribute &rCandidate) const
const OUString & getStyleName() const
const OUString & getFamilyName() const
data read access
FontAttribute & operator=(const FontAttribute &)
o3tl::cow_wrapper< ImpFontAttribute > ImplType
bool operator==(const ImpFontAttribute &rCompare) const
ImpFontAttribute(OUString aFamilyName, OUString aStyleName, sal_uInt16 nWeight, bool bSymbol, bool bVertical, bool bItalic, bool bMonospaced, bool bOutline, bool bRTL, bool bBiDiStrong)
FontAttribute