Line data Source code
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 "../inc/wwstyles.hxx"
21 :
22 : #include <functional>
23 : #include <algorithm>
24 : #include "rtl/ustring.hxx"
25 : #include "staticassert.hxx"
26 :
27 : namespace
28 : {
29 15 : const sal_Char **GetStiNames() throw()
30 : {
31 : static const sal_Char *stiName[] =
32 : {
33 : "Normal",
34 : "Heading 1",
35 : "Heading 2",
36 : "Heading 3",
37 : "Heading 4",
38 : "Heading 5",
39 : "Heading 6",
40 : "Heading 7",
41 : "Heading 8",
42 : "Heading 9",
43 : "Index 1",
44 : "Index 2",
45 : "Index 3",
46 : "Index 4",
47 : "Index 5",
48 : "Index 6",
49 : "Index 7",
50 : "Index 8",
51 : "Index 9",
52 : "TOC 1",
53 : "TOC 2",
54 : "TOC 3",
55 : "TOC 4",
56 : "TOC 5",
57 : "TOC 6",
58 : "TOC 7",
59 : "TOC 8",
60 : "TOC 9",
61 : "Normal Indent",
62 : "Footnote Text",
63 : "Annotation Text",
64 : "Header",
65 : "Footer",
66 : "Index Heading",
67 : "Caption",
68 : "Table of Figures",
69 : "Envelope Address",
70 : "Envelope Return",
71 : "Footnote Reference",
72 : "Annotation Reference",
73 : "Line Number",
74 : "Page Number",
75 : "Endnote Reference",
76 : "Endnote Text",
77 : "Table of Authorities",
78 : "Macro Text",
79 : "TOA Heading",
80 : "List",
81 : "List 2",
82 : "List 3",
83 : "List 4",
84 : "List 5",
85 : "List Bullet",
86 : "List Bullet 2",
87 : "List Bullet 3",
88 : "List Bullet 4",
89 : "List Bullet 5",
90 : "List Number",
91 : "List Number 2",
92 : "List Number 3",
93 : "List Number 4",
94 : "List Number 5",
95 : "Title",
96 : "Closing",
97 : "Signature",
98 : "Default Paragraph Font",
99 : "Body Text",
100 : "Body Text Indent",
101 : "List Continue",
102 : "List Continue 2",
103 : "List Continue 3",
104 : "List Continue 4",
105 : "List Continue 5",
106 : "Message Header",
107 : "Subtitle",
108 : "Salutation",
109 : "Date",
110 : "Body Text First Indent",
111 : "Body Text First Indent 2",
112 : "Note Heading",
113 : "Body Text 2",
114 : "Body Text 3",
115 : "Body Text Indent 2",
116 : "Body Text Indent 3",
117 : "Block Text",
118 : "Hyperlink",
119 : "Followed Hyperlink",
120 : "Strong",
121 : "Emphasis",
122 : "Document Map",
123 : "Plain Text"
124 : };
125 :
126 : OSL_ENSURE( (sizeof (stiName) / sizeof (stiName[0])) == ww::stiMax, "WrongSizeOfArray" );
127 :
128 15 : return stiName;
129 : }
130 : }
131 :
132 : namespace ww
133 : {
134 15 : const sal_Char* GetEnglishNameFromSti(sti eSti) throw()
135 : {
136 15 : if (eSti >= stiMax)
137 0 : return 0;
138 : else
139 15 : return GetStiNames()[eSti];
140 : }
141 :
142 15 : bool StandardStiIsCharStyle(sti eSti) throw()
143 : {
144 15 : switch (eSti)
145 : {
146 : case stiFtnRef:
147 : case stiAtnRef:
148 : case stiLnn:
149 : case stiPgn:
150 : case stiEdnRef:
151 : case stiNormalChar:
152 1 : return true;
153 : default:
154 14 : return false;
155 : }
156 : }
157 :
158 30 : sti GetCanonicalStiFromStc(sal_uInt8 stc) throw()
159 : {
160 30 : if (stc == 0)
161 2 : return stiNormal;
162 28 : else if (stc < 222)
163 0 : return stiUser;
164 : else
165 : {
166 : static const sti aMapping[] =
167 : {
168 : stiNil, stiAtnRef, stiAtnText, stiToc8, stiToc7, stiToc6,
169 : stiToc5, stiToc4, stiToc3, stiToc2, stiToc1, stiIndex7,
170 : stiIndex6, stiIndex5, stiIndex4, stiIndex3, stiIndex2,
171 : stiIndex1, stiLnn, stiIndexHeading, stiFooter, stiHeader,
172 : stiFtnRef, stiFtnText, stiLev9, stiLev8, stiLev7, stiLev6,
173 : stiLev5, stiLev4, stiLev3, stiLev2, stiLev1, stiNormIndent
174 : };
175 28 : return aMapping[stc-222];
176 : }
177 : }
178 : }
179 :
180 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|