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