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: hstyle.cpp,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 /* $Id: hstyle.cpp,v 1.3 2008-04-10 12:07:14 rt Exp $ */
33 #include "precompile.h"
40 { MAXSTYLENAME
= 20 };
42 #define DATA ((StyleData *)style)
46 char name
[MAXSTYLENAME
+ 1];
51 static char buffer
[MAXSTYLENAME
+ 1];
53 HWPStyle::HWPStyle(void)
60 HWPStyle::~HWPStyle(void)
67 int HWPStyle::Num(void) const
73 char *HWPStyle::GetName(int n
) const
75 if (!(n
>= 0 && n
< nstyles
))
81 void HWPStyle::SetName(int n
, char *name
)
83 if (n
>= 0 && n
< nstyles
)
86 strncpy(DATA
[n
].name
, name
, MAXSTYLENAME
);
93 CharShape
*HWPStyle::GetCharShape(int n
) const
95 if (!(n
>= 0 && n
< nstyles
))
97 return &DATA
[n
].cshape
;
101 void HWPStyle::SetCharShape(int n
, CharShape
* cshapep
)
103 if (n
>= 0 && n
< nstyles
)
106 DATA
[n
].cshape
= *cshapep
;
108 memset(&DATA
[n
].cshape
, 0, sizeof(CharShape
));
113 ParaShape
*HWPStyle::GetParaShape(int n
) const
115 if (!(n
>= 0 && n
< nstyles
))
117 return &DATA
[n
].pshape
;
121 void HWPStyle::SetParaShape(int n
, ParaShape
* pshapep
)
123 if (n
>= 0 && n
< nstyles
)
126 DATA
[n
].pshape
= *pshapep
;
128 memset(&DATA
[n
].pshape
, 0, sizeof(ParaShape
));
133 bool HWPStyle::Read(HWPFile
& hwpf
)
138 hwpf
.Read2b(&nstyles
, 1);
139 style
= new StyleData
[nstyles
];
143 for (int ii
= 0; ii
< nstyles
; ii
++)
145 hwpf
.ReadBlock(buffer
, MAXSTYLENAME
);
150 SetCharShape(ii
, &cshape
);
151 SetParaShape(ii
, &pshape
);