1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "precompile.h"
31 #include <comphelper/newarray.hxx>
38 { MAXSTYLENAME
= 20 };
40 #define DATA ((StyleData *)style)
44 char name
[MAXSTYLENAME
+ 1];
49 static char buffer
[MAXSTYLENAME
+ 1];
51 HWPStyle::HWPStyle(void)
58 HWPStyle::~HWPStyle(void)
65 int HWPStyle::Num(void) const
71 char *HWPStyle::GetName(int n
) const
73 if (!(n
>= 0 && n
< nstyles
))
79 void HWPStyle::SetName(int n
, char *name
)
81 if (n
>= 0 && n
< nstyles
)
84 strncpy(DATA
[n
].name
, name
, MAXSTYLENAME
);
91 CharShape
*HWPStyle::GetCharShape(int n
) const
93 if (!(n
>= 0 && n
< nstyles
))
95 return &DATA
[n
].cshape
;
99 void HWPStyle::SetCharShape(int n
, CharShape
* cshapep
)
101 if (n
>= 0 && n
< nstyles
)
104 DATA
[n
].cshape
= *cshapep
;
106 memset(&DATA
[n
].cshape
, 0, sizeof(CharShape
));
111 ParaShape
*HWPStyle::GetParaShape(int n
) const
113 if (!(n
>= 0 && n
< nstyles
))
115 return &DATA
[n
].pshape
;
119 void HWPStyle::SetParaShape(int n
, ParaShape
* pshapep
)
121 if (n
>= 0 && n
< nstyles
)
124 DATA
[n
].pshape
= *pshapep
;
126 memset(&DATA
[n
].pshape
, 0, sizeof(ParaShape
));
131 bool HWPStyle::Read(HWPFile
& hwpf
)
136 hwpf
.Read2b(&nstyles
, 1);
137 style
= ::comphelper::newArray_null
<StyleData
>(nstyles
);
141 for (int ii
= 0; ii
< nstyles
; ii
++)
143 hwpf
.ReadBlock(buffer
, MAXSTYLENAME
);
148 SetCharShape(ii
, &cshape
);
149 SetParaShape(ii
, &pshape
);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */