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: ThemeTable.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 #ifndef INCLUDED_FONTTABLE_HXX
32 #include <ThemeTable.hxx>
34 #ifndef INCLUDED_RESOURCESIDS
35 #include <doctok/resourceids.hxx>
36 #include <ooxml/resourceids.hxx>
40 namespace writerfilter
{
44 struct ThemeTable_Impl
47 m_currentThemeFontId(0),
48 m_currentFontThemeEntry() {}
49 std::map
<sal_uInt32
, std::map
<sal_uInt32
, ::rtl::OUString
> > m_themeFontMap
;
50 sal_uInt32 m_currentThemeFontId
;
51 std::map
<sal_uInt32
, ::rtl::OUString
> m_currentFontThemeEntry
;
54 ThemeTable::ThemeTable() :
55 m_pImpl( new ThemeTable_Impl
)
57 // printf("ThemeTable::ThemeTable()\n");
60 ThemeTable::~ThemeTable()
65 void ThemeTable::attribute(Id Name
, Value
& val
)
67 // int nIntValue = val.getInt();
68 ::rtl::OUString sValue
= val
.getString();
69 // printf ( "ThemeTable::attribute(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)Name, (unsigned int)nIntValue, ::rtl::OUStringToOString(sValue, RTL_TEXTENCODING_DONTKNOW).getStr());
70 /* WRITERFILTERSTATUS: table: ThemeTable_attributedata */
73 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
74 case NS_ooxml::LN_CT_TextFont_typeface
:
75 if (sValue
.getLength())
76 m_pImpl
->m_currentFontThemeEntry
[m_pImpl
->m_currentThemeFontId
] = sValue
;
84 void ThemeTable::sprm(Sprm
& rSprm
)
86 sal_uInt32 nSprmId
= rSprm
.getId();
89 Value::Pointer_t pValue
= rSprm
.getValue();
90 sal_Int32 nIntValue
= pValue
->getInt();
92 rtl::OUString sStringValue
= pValue
->getString();
94 // printf ( "ThemeTable::sprm(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)nSprmId, (unsigned int)nIntValue, ::rtl::OUStringToOString(sStringValue, RTL_TEXTENCODING_DONTKNOW).getStr());
96 /* WRITERFILTERSTATUS: table: ThemeTable_sprm */
99 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
100 case NS_ooxml::LN_CT_BaseStyles_fontScheme
:
102 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
103 if( pProperties
.get())
104 pProperties
->resolve(*this);
107 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
108 case NS_ooxml::LN_CT_FontScheme_majorFont
:
109 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
110 case NS_ooxml::LN_CT_FontScheme_minorFont
:
112 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
113 m_pImpl
->m_currentFontThemeEntry
= std::map
<sal_uInt32
, rtl::OUString
>();
114 if( pProperties
.get())
115 pProperties
->resolve(*this);
116 m_pImpl
->m_themeFontMap
[nSprmId
] = m_pImpl
->m_currentFontThemeEntry
;
119 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
120 case NS_ooxml::LN_CT_FontCollection_latin
:
121 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
122 case NS_ooxml::LN_CT_FontCollection_ea
:
123 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
124 case NS_ooxml::LN_CT_FontCollection_cs
:
126 m_pImpl
->m_currentThemeFontId
= nSprmId
;
127 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
128 if( pProperties
.get())
129 pProperties
->resolve(*this);
138 void ThemeTable::entry(int /*pos*/, writerfilter::Reference
<Properties
>::Pointer_t ref
)
140 // printf ( "ThemeTable::entry\n");
144 const ::rtl::OUString
ThemeTable::getFontNameForTheme(const Id id
) const
146 std::map
<sal_uInt32
, ::rtl::OUString
> tmpThemeFontMap
;
149 case NS_ooxml::LN_Value_ST_Theme_majorEastAsia
:
150 case NS_ooxml::LN_Value_ST_Theme_majorBidi
:
151 case NS_ooxml::LN_Value_ST_Theme_majorAscii
:
152 case NS_ooxml::LN_Value_ST_Theme_majorHAnsi
:
153 tmpThemeFontMap
= m_pImpl
->m_themeFontMap
[NS_ooxml::LN_CT_FontScheme_majorFont
];
155 case NS_ooxml::LN_Value_ST_Theme_minorEastAsia
:
156 case NS_ooxml::LN_Value_ST_Theme_minorBidi
:
157 case NS_ooxml::LN_Value_ST_Theme_minorAscii
:
158 case NS_ooxml::LN_Value_ST_Theme_minorHAnsi
:
159 tmpThemeFontMap
= m_pImpl
->m_themeFontMap
[NS_ooxml::LN_CT_FontScheme_minorFont
];
162 return ::rtl::OUString();
167 case NS_ooxml::LN_Value_ST_Theme_majorAscii
:
168 case NS_ooxml::LN_Value_ST_Theme_majorHAnsi
:
169 case NS_ooxml::LN_Value_ST_Theme_minorAscii
:
170 case NS_ooxml::LN_Value_ST_Theme_minorHAnsi
:
172 std::map
<sal_uInt32
, ::rtl::OUString
>::const_iterator Iter
= tmpThemeFontMap
.find(NS_ooxml::LN_CT_FontCollection_latin
);
173 if (Iter
!= tmpThemeFontMap
.end())
174 return (Iter
)->second
;
175 return ::rtl::OUString();
177 case NS_ooxml::LN_Value_ST_Theme_majorBidi
:
178 case NS_ooxml::LN_Value_ST_Theme_minorBidi
:
180 std::map
<sal_uInt32
, ::rtl::OUString
>::const_iterator Iter
= tmpThemeFontMap
.find(NS_ooxml::LN_CT_FontCollection_cs
);
181 if (Iter
!= tmpThemeFontMap
.end())
182 return (Iter
)->second
;
183 return ::rtl::OUString();
185 case NS_ooxml::LN_Value_ST_Theme_majorEastAsia
:
186 case NS_ooxml::LN_Value_ST_Theme_minorEastAsia
:
188 std::map
<sal_uInt32
, ::rtl::OUString
>::const_iterator Iter
= tmpThemeFontMap
.find(NS_ooxml::LN_CT_FontCollection_ea
);
189 if (Iter
!= tmpThemeFontMap
.end())
190 return (Iter
)->second
;
191 return ::rtl::OUString();
194 return ::rtl::OUString();
199 } //namespace writerfilter