LibreOffice Module sw (master) 1
styles.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
20#include <wwstyles.hxx>
21
22#include <osl/diagnose.h>
23
24namespace
25{
26 // Keep in sync with StyleSheetTable::ConvertStyleName
27 const char **GetStiNames() noexcept
28 {
29 // Matches enum ww::sti in sw/source/filter/inc/wwstyles.hxx
30 static const char *stiName[] =
31 {
32 "Normal", // stiNormal
33 "Heading 1", // stiLev1
34 "Heading 2", // stiLev2
35 "Heading 3", // stiLev3
36 "Heading 4", // stiLev4
37 "Heading 5", // stiLev5
38 "Heading 6", // stiLev6
39 "Heading 7", // stiLev7
40 "Heading 8", // stiLev8
41 "Heading 9", // stiLev9
42 "Index 1", // stiIndex1
43 "Index 2", // stiIndex2
44 "Index 3", // stiIndex3
45 "Index 4", // stiIndex4
46 "Index 5", // stiIndex5
47 "Index 6", // stiIndex6
48 "Index 7", // stiIndex7
49 "Index 8", // stiIndex8
50 "Index 9", // stiIndex9
51 "TOC 1", // stiToc1
52 "TOC 2", // stiToc2
53 "TOC 3", // stiToc3
54 "TOC 4", // stiToc4
55 "TOC 5", // stiToc5
56 "TOC 6", // stiToc6
57 "TOC 7", // stiToc7
58 "TOC 8", // stiToc8
59 "TOC 9", // stiToc9
60 "Normal Indent", // stiNormIndent
61 "Footnote Text", // stiFootnoteText
62 "Annotation Text", // stiAtnText
63 "Header", // stiHeader
64 "Footer", // stiFooter
65 "Index Heading", // stiIndexHeading
66 "Caption", // stiCaption
67 "Table of Figures", // stiToCaption
68 "Envelope Address", // stiEnvAddr
69 "Envelope Return", // stiEnvRet
70 "Footnote Reference", // stiFootnoteRef
71 "Annotation Reference", // stiAtnRef
72 "Line Number", // stiLnn
73 "Page Number", // stiPgn
74 "Endnote Reference", // stiEdnRef
75 "Endnote Text", // stiEdnText
76 "Table of Authorities", // stiToa
77 "Macro Text", // stiMacro
78 "TOC Heading", // stiToaHeading - tdf143726
79 "List", // stiList
80 "List Bullet", // stiListBullet
81 "List Number", // stiListNumber
82 "List 2", // stiList2
83 "List 3", // stiList3
84 "List 4", // stiList4
85 "List 5", // stiList5
86 "List Bullet 2", // stiListBullet2
87 "List Bullet 3", // stiListBullet3
88 "List Bullet 4", // stiListBullet4
89 "List Bullet 5", // stiListBullet5
90 "List Number 2", // stiListNumber2
91 "List Number 3", // stiListNumber3
92 "List Number 4", // stiListNumber4
93 "List Number 5", // stiListNumber5
94 "Title", // stiTitle
95 "Closing", // stiClosing
96 "Signature", // stiSignature
97 "Default Paragraph Font", // stiNormalChar
98 "Body Text", // stiBodyText
99 "Body Text Indent", // stiBodyTextInd1
100 "List Continue", // stiListCont
101 "List Continue 2", // stiListCont2
102 "List Continue 3", // stiListCont3
103 "List Continue 4", // stiListCont4
104 "List Continue 5", // stiListCont5
105 "Message Header", // stiMsgHeader
106 "Subtitle", // stiSubtitle
107 "Salutation", // stiSalutation
108 "Date", // stiDate
109 "Body Text First Indent", // stiBodyText1I
110 "Body Text First Indent 2", // stiBodyText1I2
111 "Note Heading", // stiNoteHeading
112 "Body Text 2", // stiBodyText2
113 "Body Text 3", // stiBodyText3
114 "Body Text Indent 2", // stiBodyTextInd2
115 "Body Text Indent 3", // stiBodyTextInd3
116 "Block Text", // stiBlockQuote
117 "Hyperlink", // stiHyperlink
118 "FollowedHyperlink", // stiHyperlinkFollowed
119 "Strong", // stiStrong
120 "Emphasis", // stiEmphasis
121 "Document Map", // stiNavPane
122 "Plain Text", // stiPlainText
123 };
124
125 static_assert(SAL_N_ELEMENTS(stiName) == ww::stiMax, "WrongSizeOfArray");
126
127 return stiName;
128 }
129}
130
131namespace ww
132{
133 const char* GetEnglishNameFromSti(sti eSti) noexcept
134 {
135 if (eSti >= stiMax)
136 return nullptr;
137 else
138 return GetStiNames()[eSti];
139 }
140
141 bool StandardStiIsCharStyle(sti eSti) noexcept
142 {
143 switch (eSti)
144 {
145 case stiFootnoteRef:
146 case stiAtnRef:
147 case stiLnn:
148 case stiPgn:
149 case stiEdnRef:
150 case stiNormalChar:
151 return true;
152 default:
153 return false;
154 }
155 }
156
158 {
159 if (stc == 0)
160 return stiNormal;
161 else if (stc < 222)
162 return stiUser;
163 else
164 {
165 static const sti aMapping[] =
166 {
173 };
174 return aMapping[stc-222];
175 }
176 }
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_N_ELEMENTS(arr)
@HTML
const char * GetEnglishNameFromSti(sti eSti) noexcept
Find the WinWord english name from a sti index.
Definition: styles.cxx:133
sti
Definition: wwstyles.hxx:29
@ stiToc6
Definition: wwstyles.hxx:58
@ stiLev7
Definition: wwstyles.hxx:37
@ stiNormal
Definition: wwstyles.hxx:30
@ stiAtnText
Definition: wwstyles.hxx:66
@ stiLev4
Definition: wwstyles.hxx:34
@ stiIndex1
Definition: wwstyles.hxx:42
@ stiLev2
Definition: wwstyles.hxx:32
@ stiUser
Definition: wwstyles.hxx:133
@ stiNormIndent
Definition: wwstyles.hxx:64
@ stiMax
Definition: wwstyles.hxx:132
@ stiLev3
Definition: wwstyles.hxx:33
@ stiNormalChar
Definition: wwstyles.hxx:101
@ stiIndex2
Definition: wwstyles.hxx:43
@ stiIndexHeading
Definition: wwstyles.hxx:69
@ stiToc7
Definition: wwstyles.hxx:59
@ stiLev9
Definition: wwstyles.hxx:39
@ stiFootnoteText
Definition: wwstyles.hxx:65
@ stiToc8
Definition: wwstyles.hxx:60
@ stiIndex7
Definition: wwstyles.hxx:48
@ stiIndex6
Definition: wwstyles.hxx:47
@ stiEdnRef
Definition: wwstyles.hxx:78
@ stiLev5
Definition: wwstyles.hxx:35
@ stiIndex3
Definition: wwstyles.hxx:44
@ stiHeader
Definition: wwstyles.hxx:67
@ stiFooter
Definition: wwstyles.hxx:68
@ stiToc1
Definition: wwstyles.hxx:53
@ stiLnn
Definition: wwstyles.hxx:76
@ stiToc5
Definition: wwstyles.hxx:57
@ stiToc3
Definition: wwstyles.hxx:55
@ stiToc2
Definition: wwstyles.hxx:54
@ stiLev6
Definition: wwstyles.hxx:36
@ stiLev8
Definition: wwstyles.hxx:38
@ stiLev1
Definition: wwstyles.hxx:31
@ stiIndex5
Definition: wwstyles.hxx:46
@ stiToc4
Definition: wwstyles.hxx:56
@ stiPgn
Definition: wwstyles.hxx:77
@ stiIndex4
Definition: wwstyles.hxx:45
@ stiFootnoteRef
Definition: wwstyles.hxx:74
@ stiAtnRef
Definition: wwstyles.hxx:75
@ stiNil
Definition: wwstyles.hxx:134
bool StandardStiIsCharStyle(sti eSti) noexcept
Determine if the WinWord sti is standard Character Style.
Definition: styles.cxx:141
sti GetCanonicalStiFromStc(sal_uInt8 stc) noexcept
Find the WinWord sti index of an old <= Word2 stc (style code)
Definition: styles.cxx:157
unsigned char sal_uInt8