bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / filter / ww8 / styles.cxx
blob5d1f1b1fae7454f3585152e84d22a14f7a25bff2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "../inc/wwstyles.hxx"
23 #include <functional> //std::unary_function
24 #include <algorithm> //std::find_if
25 #include <tools/string.hxx> //do we have to...
27 #include "staticassert.hxx" //StaticAssert
29 namespace
31 class SameName: public std::unary_function<const sal_Char*, bool>
33 private:
34 const String &mrName;
35 public:
36 explicit SameName(const String &rName) : mrName(rName) {}
37 bool operator() (const sal_Char *pEntry) const
38 { return mrName.EqualsAscii(pEntry); }
41 const sal_Char **GetStiNames() throw()
43 static const sal_Char *stiName[] =
45 "Normal",
46 "Heading 1",
47 "Heading 2",
48 "Heading 3",
49 "Heading 4",
50 "Heading 5",
51 "Heading 6",
52 "Heading 7",
53 "Heading 8",
54 "Heading 9",
55 "Index 1",
56 "Index 2",
57 "Index 3",
58 "Index 4",
59 "Index 5",
60 "Index 6",
61 "Index 7",
62 "Index 8",
63 "Index 9",
64 "TOC 1",
65 "TOC 2",
66 "TOC 3",
67 "TOC 4",
68 "TOC 5",
69 "TOC 6",
70 "TOC 7",
71 "TOC 8",
72 "TOC 9",
73 "Normal Indent",
74 "Footnote Text",
75 "Annotation Text",
76 "Header",
77 "Footer",
78 "Index Heading",
79 "Caption",
80 "Table of Figures",
81 "Envelope Address",
82 "Envelope Return",
83 "Footnote Reference",
84 "Annotation Reference",
85 "Line Number",
86 "Page Number",
87 "Endnote Reference",
88 "Endnote Text",
89 "Table of Authorities",
90 "Macro Text",
91 "TOA Heading",
92 "List",
93 "List 2",
94 "List 3",
95 "List 4",
96 "List 5",
97 "List Bullet",
98 "List Bullet 2",
99 "List Bullet 3",
100 "List Bullet 4",
101 "List Bullet 5",
102 "List Number",
103 "List Number 2",
104 "List Number 3",
105 "List Number 4",
106 "List Number 5",
107 "Title",
108 "Closing",
109 "Signature",
110 "Default Paragraph Font",
111 "Body Text",
112 "Body Text Indent",
113 "List Continue",
114 "List Continue 2",
115 "List Continue 3",
116 "List Continue 4",
117 "List Continue 5",
118 "Message Header",
119 "Subtitle",
120 "Salutation",
121 "Date",
122 "Body Text First Indent",
123 "Body Text First Indent 2",
124 "Note Heading",
125 "Body Text 2",
126 "Body Text 3",
127 "Body Text Indent 2",
128 "Body Text Indent 3",
129 "Block Text",
130 "Hyperlink",
131 "Followed Hyperlink",
132 "Strong",
133 "Emphasis",
134 "Document Map",
135 "Plain Text"
138 OSL_ENSURE( (sizeof (stiName) / sizeof (stiName[0])) == ww::stiMax, "WrongSizeOfArray" );
140 return stiName;
144 namespace ww
146 const sal_Char* GetEnglishNameFromSti(sti eSti) throw()
148 if (eSti >= stiMax)
149 return 0;
150 else
151 return GetStiNames()[eSti];
154 bool StandardStiIsCharStyle(sti eSti) throw()
156 switch (eSti)
158 case stiFtnRef:
159 case stiAtnRef:
160 case stiLnn:
161 case stiPgn:
162 case stiEdnRef:
163 case stiNormalChar:
164 return true;
165 default:
166 return false;
170 sti GetCanonicalStiFromStc(sal_uInt8 stc) throw()
172 if (stc == 0)
173 return stiNormal;
174 else if (stc < 222)
175 return stiUser;
176 else
178 static sti aMapping[] =
180 stiNil, stiAtnRef, stiAtnText, stiToc8, stiToc7, stiToc6,
181 stiToc5, stiToc4, stiToc3, stiToc2, stiToc1, stiIndex7,
182 stiIndex6, stiIndex5, stiIndex4, stiIndex3, stiIndex2,
183 stiIndex1, stiLnn, stiIndexHeading, stiFooter, stiHeader,
184 stiFtnRef, stiFtnText, stiLev9, stiLev8, stiLev7, stiLev6,
185 stiLev5, stiLev4, stiLev3, stiLev2, stiLev1, stiNormIndent
187 return aMapping[stc-222];
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */