update dev300-m57
[ooovba.git] / lotuswordpro / source / filter / lwpcharacterstyle.cxx
blobf8d0c883509e1113e0c49f9816069e2281874e0f
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
56 * @file
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
60 * Change History
61 Jan 2005 Created
62 ************************************************************************/
64 #include "lwpcharacterstyle.hxx"
65 #include "lwpfilehdr.hxx"
66 #include "lwptools.hxx"
67 #include "lwpoverride.hxx"
68 #include "lwpatomholder.hxx"
69 #include "lwpfont.hxx"
70 #include "lwpfoundry.hxx"
71 #include "lwpcharborderoverride.hxx"
73 /*class LwpTextStyle*/
74 LwpTextStyle::LwpTextStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
75 : LwpDLNFPVList(objHdr, pStrm),
76 m_nFontID(0), m_nFinalFontID(0), m_nCSFlags(0), m_nUseCount(0),
77 m_pDescription(new LwpAtomHolder), m_pLangOverride(new LwpTextLanguageOverride),
78 m_pTxtAttrOverride(new LwpTextAttributeOverride),
79 m_pCharacterBorderOverride(new LwpCharacterBorderOverride),
80 m_pAmikakeOverride(new LwpAmikakeOverride),
81 m_nStyleDefinition(0), m_nKey(0)
85 void LwpTextStyle::Read()
87 LwpDLNFPVList::Read();
88 ReadCommon();
91 LwpTextStyle::~LwpTextStyle()
93 if (m_pDescription)
95 delete m_pDescription;
97 if (m_pLangOverride)
99 delete m_pLangOverride;
101 if (m_pTxtAttrOverride)
103 delete m_pTxtAttrOverride;
105 if (m_pCharacterBorderOverride)
107 delete m_pCharacterBorderOverride;
109 if (m_pAmikakeOverride)
111 delete m_pAmikakeOverride;
115 void LwpTextStyle::ReadCommon()
117 m_pObjStrm->QuickRead(&m_nFontID, 4);
118 m_pObjStrm->QuickRead(&m_nFinalFontID, 4);
119 m_pObjStrm->QuickRead(&m_nCSFlags, 2);
120 m_pObjStrm->QuickRead(&m_nUseCount, 4);
122 m_pDescription->Read(m_pObjStrm);
124 m_pLangOverride->Read(m_pObjStrm);
125 m_pTxtAttrOverride->Read(m_pObjStrm);
126 //#ifdef AMIKAKE
127 if (LwpFileHeader::m_nFileRevision < 0x000B)
129 m_pCharacterBorderOverride->Read(m_pObjStrm);
130 m_pAmikakeOverride->Read(m_pObjStrm);
132 else
134 m_CharacterBorder.ReadIndexed(m_pObjStrm);
135 m_Amikake.ReadIndexed(m_pObjStrm);
137 //#endif
138 sal_uInt16 nCount = 6;
139 if (LwpFileHeader::m_nFileRevision > 0x0005)
141 m_pObjStrm->QuickRead(&nCount, 2);
144 m_FaceStyle.ReadIndexed(m_pObjStrm);
146 if (nCount > 1)
148 m_SizeStyle.ReadIndexed(m_pObjStrm);
149 m_AttributeStyle.ReadIndexed(m_pObjStrm);
150 m_FontStyle.ReadIndexed(m_pObjStrm);
151 m_CharacterBorderStyle.ReadIndexed(m_pObjStrm);
152 m_AmikakeStyle.ReadIndexed(m_pObjStrm);
155 if (m_pObjStrm->CheckExtra())
157 m_pObjStrm->QuickRead(&m_nStyleDefinition, 4);
159 if (m_pObjStrm->CheckExtra())
161 m_pObjStrm->QuickRead(&m_nKey, 2);
162 m_pObjStrm->SkipExtra();
168 #include "xfilter/xfparastyle.hxx"
169 #include "xfilter/xffont.hxx"
171 void LwpTextStyle::RegisterStyle()
173 if (!m_pFoundry)
175 assert(false);
176 return;
179 XFTextStyle* pStyle = new XFTextStyle();
181 //Set name
182 OUString styleName = GetName()->str();
183 pStyle->SetStyleName(styleName);
185 //Create font
186 LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
187 XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
188 pStyle->SetFont(pFont);
190 //Set other properties if needed
192 //Add style
193 LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
194 pStyleMgr->AddStyle(*GetObjectID(), pStyle);
198 /*class LwpCharacterStyle*/
199 LwpCharacterStyle::LwpCharacterStyle(LwpObjectHeader& objHdr, LwpSvStream* pStrm) :
200 LwpTextStyle(objHdr, pStrm)
204 void LwpCharacterStyle::Read()
206 LwpTextStyle::Read();