LibreOffice Module sw (master) 1
WW8Sttbf.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
21#define INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
22
23#include <memory>
24#include <vector>
25
26#include <rtl/ustring.hxx>
28
29class SvStream;
30
31namespace ww8
32{
33
35 {
36 std::shared_ptr<sal_uInt8> m_pData;
37 sal_uInt32 mn_offset;
38 sal_uInt32 mn_size;
39
40 public:
41 WW8Struct(SvStream& rSt, sal_uInt32 nPos, sal_uInt32 nSize);
42 WW8Struct(WW8Struct const * pStruct, sal_uInt32 nPos, sal_uInt32 nSize);
43 virtual ~WW8Struct() override;
44
45 sal_uInt8 getU8(sal_uInt32 nOffset);
46
47 sal_uInt16 getU16(sal_uInt32 nOffset)
48 { return getU8(nOffset) + (getU8(nOffset + 1) << 8); }
49
50 OUString getUString(sal_uInt32 nOffset, sal_Int32 nCount);
51 };
52
53 template <class T>
54 class WW8Sttb : public WW8Struct
55 {
56 typedef std::shared_ptr< void > ExtraPointer_t;
58 std::vector<OUString> m_Strings;
59 std::vector< ExtraPointer_t > m_Extras;
60
61 public:
62 WW8Sttb(SvStream& rSt, sal_Int32 nPos, sal_uInt32 nSize);
63 virtual ~WW8Sttb() override;
64
65 std::vector<OUString> & getStrings()
66 {
67 return m_Strings;
68 }
69 };
70
71 template <class T>
72 WW8Sttb<T>::WW8Sttb(SvStream& rSt, sal_Int32 nPos, sal_uInt32 nSize)
73 : WW8Struct(rSt, nPos, nSize), m_bDoubleByteCharacters(false)
74 {
75 sal_uInt32 nOffset = 0;
76
77 if (getU16(nOffset) == 0xffff)
78 {
80 nOffset += 2;
81 }
82
83 sal_uInt16 nCount = getU16(nOffset);
84 sal_uInt16 ncbExtra = getU16(nOffset + 2);
85
86 nOffset += 4;
87 for (sal_uInt16 i = 0; i < nCount; i++)
88 {
90 {
91 sal_uInt16 nStrLen = getU16(nOffset);
92
93 m_Strings.push_back(getUString(nOffset +2, nStrLen));
94
95 nOffset += 2 + 2 * nStrLen;
96 }
97 else
98 {
99 sal_uInt8 nStrLen = getU8(nOffset);
100
101 m_Strings.push_back(getUString(nOffset, nStrLen));
102
103 nOffset += 1 + nStrLen;
104 }
105
106 if (ncbExtra > 0)
107 {
108 ExtraPointer_t pExtra = std::make_shared<T>(this, nOffset, ncbExtra);
109 m_Extras.push_back(pExtra);
110
111 nOffset += ncbExtra;
112 }
113 }
114 }
115
116 template <class T>
118 {
119 }
120}
121
122#endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 getU8(sal_uInt32 nOffset)
Definition: WW8Sttbf.cxx:58
std::shared_ptr< sal_uInt8 > m_pData
Definition: WW8Sttbf.hxx:36
sal_uInt16 getU16(sal_uInt32 nOffset)
Definition: WW8Sttbf.hxx:47
virtual ~WW8Struct() override
Definition: WW8Sttbf.cxx:54
WW8Struct(SvStream &rSt, sal_uInt32 nPos, sal_uInt32 nSize)
Definition: WW8Sttbf.cxx:35
sal_uInt32 mn_offset
Definition: WW8Sttbf.hxx:37
OUString getUString(sal_uInt32 nOffset, sal_Int32 nCount)
Definition: WW8Sttbf.cxx:70
sal_uInt32 mn_size
Definition: WW8Sttbf.hxx:38
std::vector< OUString > m_Strings
Definition: WW8Sttbf.hxx:58
std::shared_ptr< void > ExtraPointer_t
Definition: WW8Sttbf.hxx:56
std::vector< OUString > & getStrings()
Definition: WW8Sttbf.hxx:65
WW8Sttb(SvStream &rSt, sal_Int32 nPos, sal_uInt32 nSize)
Definition: WW8Sttbf.hxx:72
bool m_bDoubleByteCharacters
Definition: WW8Sttbf.hxx:57
virtual ~WW8Sttb() override
Definition: WW8Sttbf.hxx:117
std::vector< ExtraPointer_t > m_Extras
Definition: WW8Sttbf.hxx:59
int nCount
sal_uInt16 nPos
int i
unsigned char sal_uInt8