1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: styles.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
35 #include "../inc/wwstyles.hxx"
37 #include <functional> //std::unary_function
38 #include <algorithm> //std::find_if
39 #include <tools/string.hxx> //do we have to...
41 #include <tools/debug.hxx>
42 # include "staticassert.hxx" //StaticAssert
46 class SameName
: public std::unary_function
<const sal_Char
*, bool>
51 explicit SameName(const String
&rName
) : mrName(rName
) {}
52 bool operator() (const sal_Char
*pEntry
) const
53 { return mrName
.EqualsAscii(pEntry
); }
56 const sal_Char
**GetStiNames() throw()
58 static const sal_Char
*stiName
[] =
99 "Annotation Reference",
104 "Table of Authorities",
125 "Default Paragraph Font",
137 "Body Text First Indent",
138 "Body Text First Indent 2",
142 "Body Text Indent 2",
143 "Body Text Indent 3",
146 "Followed Hyperlink",
153 DBG_ASSERT( (sizeof(stiName
) / sizeof(stiName
[0])) == ww::stiMax
, "WrongSizeOfArray" );
161 //Original code/idea by Takashi Ono for CJK
162 sti
GetCanonicalStiFromEnglishName(const String
&rName
) throw()
164 typedef const sal_Char
** myIter
;
166 myIter aBegin
= GetStiNames();
168 std::advance(aEnd
, stiMax
);
169 myIter aIter
= std::find_if(aBegin
, aEnd
, SameName(rName
));
171 eRet
= static_cast<sti
>(std::distance(aBegin
, aIter
));
175 const sal_Char
* GetEnglishNameFromSti(sti eSti
) throw()
180 return GetStiNames()[eSti
];
183 bool StandardStiIsCharStyle(sti eSti
) throw()
199 sti
GetCanonicalStiFromStc(sal_uInt8 stc
) throw()
207 static sti aMapping
[] =
209 stiNil
, stiAtnRef
, stiAtnText
, stiToc8
, stiToc7
, stiToc6
,
210 stiToc5
, stiToc4
, stiToc3
, stiToc2
, stiToc1
, stiIndex7
,
211 stiIndex6
, stiIndex5
, stiIndex4
, stiIndex3
, stiIndex2
,
212 stiIndex1
, stiLnn
, stiIndexHeading
, stiFooter
, stiHeader
,
213 stiFtnRef
, stiFtnText
, stiLev9
, stiLev8
, stiLev7
, stiLev6
,
214 stiLev5
, stiLev4
, stiLev3
, stiLev2
, stiLev1
, stiNormIndent
216 return aMapping
[stc
-222];
221 /* vi:set tabstop=4 shiftwidth=4 expandtab: */