LibreOffice Module xmloff (master)  1
prstylecond.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 <rtl/ustring.hxx>
21 #include <prstylecond.hxx>
22 #include <xmloff/xmltoken.hxx>
23 
24 using namespace ::xmloff::token;
25 
26 // note: keep this in sync with the list of conditions in sw/source/uibase/chrdlg/ccoll.cxx
27 
28 namespace {
29 
30 struct ConditionMap
31 {
32  char const* aInternal;
33  XMLTokenEnum nExternal;
34  int aValue;
35 };
36 
37 }
38 
39 const ConditionMap g_ConditionMap[] =
40 {
41  { "TableHeader", XML_TABLE_HEADER, -1 },
42  { "Table", XML_TABLE, -1 },
43  { "Frame", XML_TEXT_BOX, -1 }, // FIXME - Not in ODF spec
44  { "Section", XML_SECTION, -1 },
45  { "Footnote", XML_FOOTNOTE, -1 },
46  { "Endnote", XML_ENDNOTE, -1 },
47  { "Header", XML_HEADER, -1 },
48  { "Footer", XML_FOOTER, -1 },
49  { "OutlineLevel1", XML_OUTLINE_LEVEL, 1 },
50  { "OutlineLevel2", XML_OUTLINE_LEVEL, 2 },
51  { "OutlineLevel3", XML_OUTLINE_LEVEL, 3 },
52  { "OutlineLevel4", XML_OUTLINE_LEVEL, 4 },
53  { "OutlineLevel5", XML_OUTLINE_LEVEL, 5 },
54  { "OutlineLevel6", XML_OUTLINE_LEVEL, 6 },
55  { "OutlineLevel7", XML_OUTLINE_LEVEL, 7 },
56  { "OutlineLevel8", XML_OUTLINE_LEVEL, 8 },
57  { "OutlineLevel9", XML_OUTLINE_LEVEL, 9 },
58  { "OutlineLevel10", XML_OUTLINE_LEVEL, 10 },
59  { "NumberingLevel1", XML_LIST_LEVEL, 1 },
60  { "NumberingLevel2", XML_LIST_LEVEL, 2 },
61  { "NumberingLevel3", XML_LIST_LEVEL, 3 },
62  { "NumberingLevel4", XML_LIST_LEVEL, 4 },
63  { "NumberingLevel5", XML_LIST_LEVEL, 5 },
64  { "NumberingLevel6", XML_LIST_LEVEL, 6 },
65  { "NumberingLevel7", XML_LIST_LEVEL, 7 },
66  { "NumberingLevel8", XML_LIST_LEVEL, 8 },
67  { "NumberingLevel9", XML_LIST_LEVEL, 9 },
68  { "NumberingLevel10", XML_LIST_LEVEL, 10 }
69 };
70 
71 OUString GetParaStyleCondExternal( OUString const &internal)
72 {
73  for (size_t i = 0; i < SAL_N_ELEMENTS(g_ConditionMap); ++i)
74  {
75  if (internal.compareToAscii( g_ConditionMap[i].aInternal ) == 0)
76  {
77  OUString aResult = GetXMLToken( g_ConditionMap[i].nExternal ) +
78  "()";
79  if (g_ConditionMap[i].aValue != -1)
80  {
81  aResult += "=" +
82  OUString::number( g_ConditionMap[i].aValue );
83  }
84  return aResult;
85  }
86  }
87  assert(!"GetParaStyleCondExternal: model has unknown style condition");
88  return OUString();
89 }
90 
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetParaStyleCondExternal(OUString const &internal)
Definition: prstylecond.cxx:71
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
#define SAL_N_ELEMENTS(arr)
int i
const ConditionMap g_ConditionMap[]
Definition: prstylecond.cxx:39
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3372
Handling of tokens in XML: