lok: Hide file linking in section
[LibreOffice.git] / sw / inc / SwStyleNameMapper.hxx
blob139f09c974dbbfa0bf59471b954fc9d1c934c1fd
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 .
19 #ifndef INCLUDED_SW_INC_SWSTYLENAMEMAPPER_HXX
20 #define INCLUDED_SW_INC_SWSTYLENAMEMAPPER_HXX
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include "SwGetPoolIdFromName.hxx"
25 #include "swdllapi.h"
27 #include <unordered_map>
28 #include <vector>
30 /** This class holds all data about the names of styles used in the user
31 * interface (UI names...these are localised into different languages).
32 * These UI names are loaded from the resource files on demand.
34 * It also holds all information about the 'Programmatic' names of styles
35 * which remain static (and are hardcoded in the corresponding cxx file)
36 * for all languages.
38 * This class also provides static functions which can be used for the
39 * following conversions:
41 * 1. Programmatic Name -> UI Name
42 * 2. Programmatic Name -> Pool ID
43 * 3. UI Name -> Programmatic Name
44 * 4. UI Name -> Pool ID
45 * 5. Pool ID -> UI Name
46 * 6. Pool ID -> Programmatic Name
48 * The relationship of these tables to the style families is as follows:
50 * 1. Paragraph contains the Text, Lists, Extra, Register, Doc and HTML
51 * name arrays.
52 * 2. Character contains the ChrFormat and HTMLChrFormat name arrays.
53 * 3. Page contains the PageDesc name array.
54 * 4. Frame contains the FrameFormat name array.
55 * 5. Numbering Rule contains the NumRule name array.
58 /**
59 * There is a further complication that came to light later. If someone enters
60 * a user-defined style name which is the same as a programmatic name, this
61 * name clash must be handled.
63 * Therefore, when there is a danger of a nameclash, the boolean bDisambiguate
64 * must be set to true in the SwStyleNameMapper call (it defaults to false).
65 * This will cause the following to happen:
67 * If the UI style name either equals a programmatic name or already ends
68 * with " (user)", then it must append " (user)" to the end.
70 * When a programmatic name is being converted to a UI name, if it ends in
71 * " (user)", we simply remove it.
74 typedef std::unordered_map<OUString, sal_uInt16> NameToIdHash;
76 class SwStyleNameMapper final
78 friend void InitCore();
79 friend void FinitCore();
81 static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName);
82 static const OUString& getNameFromId(sal_uInt16 nId, const OUString &rName,
83 bool bProgName);
84 static const NameToIdHash& getHashTable ( SwGetPoolIdFromName, bool bProgName );
85 #ifdef _NEED_TO_DEBUG_MAPPING
86 static void testNameTable( SwGetPoolIdFromName const nFamily, sal_uInt16 const nStartIndex, sal_uInt16 const nEndIndex );
87 #endif
89 public:
90 // This gets the UI Name from the programmatic name
91 static const OUString& GetUIName(const OUString& rName, SwGetPoolIdFromName);
92 static void FillUIName(const OUString& rName, OUString& rFillName,
93 SwGetPoolIdFromName);
95 // Get the programmatic Name from the UI name
96 static const OUString& GetProgName(const OUString& rName,
97 SwGetPoolIdFromName);
98 static void FillProgName(const OUString& rName, OUString& rFillName,
99 SwGetPoolIdFromName);
101 // This gets the UI Name from the Pool ID
102 SW_DLLPUBLIC static void FillUIName(sal_uInt16 nId, OUString& rFillName);
103 SW_DLLPUBLIC static const OUString& GetUIName(sal_uInt16 nId,
104 const OUString& rName);
106 // This gets the programmatic Name from the Pool ID
107 static void FillProgName(sal_uInt16 nId, OUString& rFillName);
108 SW_DLLPUBLIC static const OUString& GetProgName(sal_uInt16 nId,
109 const OUString& rName);
111 // This gets the PoolId from the UI Name
112 SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromUIName(const OUString& rName,
113 SwGetPoolIdFromName);
115 // Get the Pool ID from the programmatic name
116 static sal_uInt16 GetPoolIdFromProgName(const OUString& rName,
117 SwGetPoolIdFromName);
119 // used to convert the 4 special ExtraProg/UINames for
120 // RES_POOLCOLL_LABEL_DRAWING, RES_POOLCOLL_LABEL_ABB,
121 // RES_POOLCOLL_LABEL_TABLE, RES_POOLCOLL_LABEL_FRAME
122 // forth and back.
123 // Non-matching names remain unchanged.
124 SW_DLLPUBLIC static const OUString & GetSpecialExtraProgName(
125 const OUString& rExtraUIName);
126 static const OUString & GetSpecialExtraUIName(const OUString& rExtraProgName);
128 static const std::vector<OUString>& GetTextUINameArray();
129 static const std::vector<OUString>& GetListsUINameArray();
130 static const std::vector<OUString>& GetExtraUINameArray();
131 static const std::vector<OUString>& GetRegisterUINameArray();
132 static const std::vector<OUString>& GetDocUINameArray();
133 static const std::vector<OUString>& GetHTMLUINameArray();
134 static const std::vector<OUString>& GetFrameFormatUINameArray();
135 static const std::vector<OUString>& GetChrFormatUINameArray();
136 static const std::vector<OUString>& GetHTMLChrFormatUINameArray();
137 static const std::vector<OUString>& GetPageDescUINameArray();
138 static const std::vector<OUString>& GetNumRuleUINameArray();
139 static const std::vector<OUString>& GetTableStyleUINameArray();
140 static const std::vector<OUString>& GetCellStyleUINameArray();
142 static const std::vector<OUString>& GetTextProgNameArray();
143 static const std::vector<OUString>& GetListsProgNameArray();
144 static const std::vector<OUString>& GetExtraProgNameArray();
145 static const std::vector<OUString>& GetRegisterProgNameArray();
146 static const std::vector<OUString>& GetDocProgNameArray();
147 static const std::vector<OUString>& GetHTMLProgNameArray();
148 static const std::vector<OUString>& GetFrameFormatProgNameArray();
149 static const std::vector<OUString>& GetChrFormatProgNameArray();
150 static const std::vector<OUString>& GetHTMLChrFormatProgNameArray();
151 static const std::vector<OUString>& GetPageDescProgNameArray();
152 static const std::vector<OUString>& GetNumRuleProgNameArray();
153 static const std::vector<OUString>& GetTableStyleProgNameArray();
154 static const std::vector<OUString>& GetCellStyleProgNameArray();
156 #endif // _NAME_MAPPER_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */