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 static const struct ConditionMap
29 {
30         char const* aInternal;
31         XMLTokenEnum const nExternal;
32         int const         aValue;
33 } g_ConditionMap[] =
34 {
35     { "TableHeader",            XML_TABLE_HEADER,   -1 },
36     { "Table",                  XML_TABLE,          -1 },
37     { "Frame",                  XML_TEXT_BOX,       -1 }, // FIXME - Not in ODF spec
38     { "Section",                XML_SECTION,        -1 },
39     { "Footnote",               XML_FOOTNOTE,       -1 },
40     { "Endnote",                XML_ENDNOTE,        -1 },
41     { "Header",                 XML_HEADER,         -1 },
42     { "Footer",                 XML_FOOTER,         -1 },
43     { "OutlineLevel1",          XML_OUTLINE_LEVEL,   1 },
44     { "OutlineLevel2",          XML_OUTLINE_LEVEL,   2 },
45     { "OutlineLevel3",          XML_OUTLINE_LEVEL,   3 },
46     { "OutlineLevel4",          XML_OUTLINE_LEVEL,   4 },
47     { "OutlineLevel5",          XML_OUTLINE_LEVEL,   5 },
48     { "OutlineLevel6",          XML_OUTLINE_LEVEL,   6 },
49     { "OutlineLevel7",          XML_OUTLINE_LEVEL,   7 },
50     { "OutlineLevel8",          XML_OUTLINE_LEVEL,   8 },
51     { "OutlineLevel9",          XML_OUTLINE_LEVEL,   9 },
52     { "OutlineLevel10",         XML_OUTLINE_LEVEL,  10 },
53     { "NumberingLevel1",        XML_LIST_LEVEL,      1 },
54     { "NumberingLevel2",        XML_LIST_LEVEL,      2 },
55     { "NumberingLevel3",        XML_LIST_LEVEL,      3 },
56     { "NumberingLevel4",        XML_LIST_LEVEL,      4 },
57     { "NumberingLevel5",        XML_LIST_LEVEL,      5 },
58     { "NumberingLevel6",        XML_LIST_LEVEL,      6 },
59     { "NumberingLevel7",        XML_LIST_LEVEL,      7 },
60     { "NumberingLevel8",        XML_LIST_LEVEL,      8 },
61     { "NumberingLevel9",        XML_LIST_LEVEL,      9 },
62     { "NumberingLevel10",       XML_LIST_LEVEL,     10 }
63 };
64 
GetParaStyleCondExternal(OUString const & internal)65 OUString GetParaStyleCondExternal( OUString const &internal)
66 {
67     for (size_t i = 0; i < SAL_N_ELEMENTS(g_ConditionMap); ++i)
68     {
69         if (internal.compareToAscii( g_ConditionMap[i].aInternal ) == 0)
70         {
71             OUString aResult = GetXMLToken( g_ConditionMap[i].nExternal ) +
72                     "()";
73             if (g_ConditionMap[i].aValue != -1)
74             {
75                 aResult += "=" +
76                     OUString::number( g_ConditionMap[i].aValue );
77             }
78             return aResult;
79         }
80     }
81     assert(!"GetParaStyleCondExternal: model has unknown style condition");
82     return OUString();
83 }
84 
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
86