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 <functional>
23 #include <algorithm>
24 #include <rtl/ustring.hxx>
25 #include <osl/diagnose.h>
26 
27 namespace
28 {
29  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( SAL_N_ELEMENTS(stiName) == ww::stiMax, "WrongSizeOfArray" );
127 
128  return stiName;
129  }
130 }
131 
132 namespace ww
133 {
134  const sal_Char* GetEnglishNameFromSti(sti eSti) throw()
135  {
136  if (eSti >= stiMax)
137  return nullptr;
138  else
139  return GetStiNames()[eSti];
140  }
141 
142  bool StandardStiIsCharStyle(sti eSti) throw()
143  {
144  switch (eSti)
145  {
146  case stiFootnoteRef:
147  case stiAtnRef:
148  case stiLnn:
149  case stiPgn:
150  case stiEdnRef:
151  case stiNormalChar:
152  return true;
153  default:
154  return false;
155  }
156  }
157 
159  {
160  if (stc == 0)
161  return stiNormal;
162  else if (stc < 222)
163  return stiUser;
164  else
165  {
166  static const sti aMapping[] =
167  {
174  };
175  return aMapping[stc-222];
176  }
177  }
178 }
179 
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: wwstyles.hxx:25
const sal_Char * GetEnglishNameFromSti(sti eSti)
Find the WinWord english name from a sti index.
Definition: styles.cxx:134
char sal_Char
sti GetCanonicalStiFromStc(sal_uInt8 stc)
Find the WinWord sti index of an old <= Word2 stc (style code)
Definition: styles.cxx:158
#define SAL_N_ELEMENTS(arr)
sti
Definition: wwstyles.hxx:27
unsigned char sal_uInt8
bool StandardStiIsCharStyle(sti eSti)
Determine if the WinWord sti is standard Character Style.
Definition: styles.cxx:142