LibreOffice Module sw (master)  1
SwStyleNameMapper.hxx
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 #ifndef INCLUDED_SW_INC_SWSTYLENAMEMAPPER_HXX
20 #define INCLUDED_SW_INC_SWSTYLENAMEMAPPER_HXX
21 
22 #include <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include "SwGetPoolIdFromName.hxx"
25 #include "swdllapi.h"
26 
27 #include <unordered_map>
28 #include <vector>
29 
74 typedef std::unordered_map<OUString, sal_uInt16> NameToIdHash;
75 
76 class SwStyleNameMapper final
77 {
78  friend void InitCore();
79  friend void FinitCore();
80 
81  // UI Name tables
82  static std::vector<OUString> *s_pTextUINameArray,
95  // Programmatic Name tables
109 
111  *s_pCharUIMap,
112  *s_pPageUIMap,
113  *s_pFrameUIMap,
117 
125 
126  static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName);
127  static const OUString& getNameFromId(sal_uInt16 nId, const OUString &rName,
128  bool bProgName);
129  static const NameToIdHash& getHashTable ( SwGetPoolIdFromName, bool bProgName );
130 #ifdef _NEED_TO_DEBUG_MAPPING
131  static void testNameTable( SwGetPoolIdFromName const nFamily, sal_uInt16 const nStartIndex, sal_uInt16 const nEndIndex );
132 #endif
133 
134 public:
135  // This gets the UI Name from the programmatic name
136  static const OUString& GetUIName(const OUString& rName, SwGetPoolIdFromName);
137  static void FillUIName(const OUString& rName, OUString& rFillName,
139 
140  // Get the programmatic Name from the UI name
141  static const OUString& GetProgName(const OUString& rName,
143  static void FillProgName(const OUString& rName, OUString& rFillName,
145 
146  // This gets the UI Name from the Pool ID
147  SW_DLLPUBLIC static void FillUIName(sal_uInt16 nId, OUString& rFillName);
148  SW_DLLPUBLIC static const OUString& GetUIName(sal_uInt16 nId,
149  const OUString& rName);
150 
151  // This gets the programmatic Name from the Pool ID
152  static void FillProgName(sal_uInt16 nId, OUString& rFillName);
153  SW_DLLPUBLIC static const OUString& GetProgName(sal_uInt16 nId,
154  const OUString& rName);
155 
156  // This gets the PoolId from the UI Name
157  SW_DLLPUBLIC static sal_uInt16 GetPoolIdFromUIName(const OUString& rName,
159 
160  // Get the Pool ID from the programmatic name
161  static sal_uInt16 GetPoolIdFromProgName(const OUString& rName,
163 
164  // used to convert the 4 special ExtraProg/UINames for
165  // RES_POOLCOLL_LABEL_DRAWING, RES_POOLCOLL_LABEL_ABB,
166  // RES_POOLCOLL_LABEL_TABLE, RES_POOLCOLL_LABEL_FRAME
167  // forth and back.
168  // Non-matching names remain unchanged.
169  SW_DLLPUBLIC static const OUString GetSpecialExtraProgName(
170  const OUString& rExtraUIName);
171  static const OUString GetSpecialExtraUIName(const OUString& rExtraProgName);
172 
173  static const std::vector<OUString>& GetTextUINameArray();
174  static const std::vector<OUString>& GetListsUINameArray();
175  static const std::vector<OUString>& GetExtraUINameArray();
176  static const std::vector<OUString>& GetRegisterUINameArray();
177  static const std::vector<OUString>& GetDocUINameArray();
178  static const std::vector<OUString>& GetHTMLUINameArray();
179  static const std::vector<OUString>& GetFrameFormatUINameArray();
180  static const std::vector<OUString>& GetChrFormatUINameArray();
181  static const std::vector<OUString>& GetHTMLChrFormatUINameArray();
182  static const std::vector<OUString>& GetPageDescUINameArray();
183  static const std::vector<OUString>& GetNumRuleUINameArray();
184  static const std::vector<OUString>& GetTableStyleUINameArray();
185  static const std::vector<OUString>& GetCellStyleUINameArray();
186 
187  static const std::vector<OUString>& GetTextProgNameArray();
188  static const std::vector<OUString>& GetListsProgNameArray();
189  static const std::vector<OUString>& GetExtraProgNameArray();
190  static const std::vector<OUString>& GetRegisterProgNameArray();
191  static const std::vector<OUString>& GetDocProgNameArray();
192  static const std::vector<OUString>& GetHTMLProgNameArray();
193  static const std::vector<OUString>& GetFrameFormatProgNameArray();
194  static const std::vector<OUString>& GetChrFormatProgNameArray();
195  static const std::vector<OUString>& GetHTMLChrFormatProgNameArray();
196  static const std::vector<OUString>& GetPageDescProgNameArray();
197  static const std::vector<OUString>& GetNumRuleProgNameArray();
198  static const std::vector<OUString>& GetTableStyleProgNameArray();
199  static const std::vector<OUString>& GetCellStyleProgNameArray();
200 };
201 #endif // _NAME_MAPPER_HXX
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static NameToIdHash * s_pTableStyleProgMap
static NameToIdHash * s_pNumRuleUIMap
static NameToIdHash * s_pCharProgMap
static const std::vector< OUString > & GetDocProgNameArray()
static NameToIdHash * s_pCellStyleProgMap
static const std::vector< OUString > & GetListsUINameArray()
static std::vector< OUString > * s_pTableStyleProgNameArray
static const std::vector< OUString > & GetTableStyleUINameArray()
static const std::vector< OUString > & GetFrameFormatUINameArray()
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetExtraProgNameArray()
static const std::vector< OUString > & GetTextProgNameArray()
static const NameToIdHash & getHashTable(SwGetPoolIdFromName, bool bProgName)
static const std::vector< OUString > & GetHTMLUINameArray()
static std::vector< OUString > * s_pTableStyleUINameArray
friend void InitCore()
Definition: init.cxx:460
static const OUString GetSpecialExtraUIName(const OUString &rExtraProgName)
static std::vector< OUString > * s_pExtraProgNameArray
static NameToIdHash * s_pFrameUIMap
static NameToIdHash * s_pNumRuleProgMap
static std::vector< OUString > * s_pListsProgNameArray
static const std::vector< OUString > & GetChrFormatProgNameArray()
static const std::vector< OUString > & GetPageDescUINameArray()
static std::vector< OUString > * s_pHTMLChrFormatUINameArray
static const std::vector< OUString > & GetDocUINameArray()
static const std::vector< OUString > & GetListsProgNameArray()
static const std::vector< OUString > & GetRegisterProgNameArray()
static std::vector< OUString > * s_pPageDescUINameArray
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static SW_DLLPUBLIC const OUString GetSpecialExtraProgName(const OUString &rExtraUIName)
static const std::vector< OUString > & GetHTMLChrFormatProgNameArray()
static const OUString & getNameFromId(sal_uInt16 nId, const OUString &rName, bool bProgName)
static NameToIdHash * s_pCharUIMap
static const std::vector< OUString > & GetHTMLProgNameArray()
static std::vector< OUString > * s_pFrameFormatProgNameArray
static std::vector< OUString > * s_pRegisterUINameArray
static std::vector< OUString > * s_pTextProgNameArray
std::unordered_map< OUString, sal_uInt16 > NameToIdHash
This class holds all data about the names of styles used in the user interface (UI names...
static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
static std::vector< OUString > * s_pHTMLProgNameArray
static NameToIdHash * s_pFrameProgMap
static const std::vector< OUString > & GetCellStyleProgNameArray()
returns an empty array because Cell Names aren't translated
friend void FinitCore()
Definition: init.cxx:676
static std::vector< OUString > * s_pDocUINameArray
static NameToIdHash * s_pParaProgMap
static NameToIdHash * s_pTableStyleUIMap
static NameToIdHash * s_pPageProgMap
static const std::vector< OUString > & GetNumRuleUINameArray()
static std::vector< OUString > * s_pHTMLChrFormatProgNameArray
static const std::vector< OUString > & GetHTMLChrFormatUINameArray()
static std::vector< OUString > * s_pCellStyleProgNameArray
static const std::vector< OUString > & GetChrFormatUINameArray()
static const std::vector< OUString > & GetExtraUINameArray()
static std::vector< OUString > * s_pExtraUINameArray
static std::vector< OUString > * s_pDocProgNameArray
static std::vector< OUString > * s_pFrameFormatUINameArray
static std::vector< OUString > * s_pTextUINameArray
static std::vector< OUString > * s_pRegisterProgNameArray
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static std::vector< OUString > * s_pChrFormatProgNameArray
static const std::vector< OUString > & GetRegisterUINameArray()
static std::vector< OUString > * s_pPageDescProgNameArray
static std::vector< OUString > * s_pCellStyleUINameArray
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetCellStyleUINameArray()
returns an empty array because Cell Names aren't translated
static NameToIdHash * s_pPageUIMap
SwGetPoolIdFromName
static std::vector< OUString > * s_pListsUINameArray
static std::vector< OUString > * s_pNumRuleProgNameArray
static const std::vector< OUString > & GetNumRuleProgNameArray()
static const std::vector< OUString > & GetTableStyleProgNameArray()
static std::vector< OUString > * s_pNumRuleUINameArray
static const std::vector< OUString > & GetPageDescProgNameArray()
static NameToIdHash * s_pParaUIMap
static std::vector< OUString > * s_pChrFormatUINameArray
static NameToIdHash * s_pCellStyleUIMap
static const std::vector< OUString > & GetTextUINameArray()
static const std::vector< OUString > & GetFrameFormatProgNameArray()
static std::vector< OUString > * s_pHTMLUINameArray
static sal_uInt16 GetPoolIdFromProgName(const OUString &rName, SwGetPoolIdFromName)
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)