1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "precompile.h"
22 #include <comphelper/newarray.hxx>
29 { MAXSTYLENAME
= 20 };
31 #define DATA static_cast<StyleData *>(style)
35 char name
[MAXSTYLENAME
+ 1];
40 static char buffer
[MAXSTYLENAME
+ 1];
58 char *HWPStyle::GetName(int n
) const
60 if (!(n
>= 0 && n
< nstyles
))
66 void HWPStyle::SetName(int n
, char *name
)
68 if (n
>= 0 && n
< nstyles
)
71 strncpy(DATA
[n
].name
, name
, MAXSTYLENAME
);
78 CharShape
*HWPStyle::GetCharShape(int n
) const
80 if (!(n
>= 0 && n
< nstyles
))
82 return &DATA
[n
].cshape
;
86 void HWPStyle::SetCharShape(int n
, CharShape
* cshapep
)
88 if (n
>= 0 && n
< nstyles
)
91 DATA
[n
].cshape
= *cshapep
;
93 memset(&DATA
[n
].cshape
, 0, sizeof(CharShape
));
98 ParaShape
*HWPStyle::GetParaShape(int n
) const
100 if (!(n
>= 0 && n
< nstyles
))
102 return &DATA
[n
].pshape
;
106 void HWPStyle::SetParaShape(int n
, ParaShape
* pshapep
)
108 if (n
>= 0 && n
< nstyles
)
111 DATA
[n
].pshape
= *pshapep
;
113 memset(&DATA
[n
].pshape
, 0, sizeof(ParaShape
));
118 bool HWPStyle::Read(HWPFile
& hwpf
)
123 hwpf
.Read2b(&nstyles
, 1);
124 style
= ::comphelper::newArray_null
<StyleData
>(nstyles
);
128 for (int ii
= 0; ii
< nstyles
; ii
++)
130 hwpf
.ReadBlock(buffer
, MAXSTYLENAME
);
135 SetCharShape(ii
, &cshape
);
136 SetParaShape(ii
, &pshape
);
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */