android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / ww8 / WW8Sttbf.hxx
blobc061362bf829c86cb90910f79d22493432e11d92
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
23 #include <memory>
24 #include <vector>
26 #include <rtl/ustring.hxx>
27 #include <IDocumentExternalData.hxx>
29 class SvStream;
31 namespace ww8
34 class WW8Struct : public ::sw::ExternalData
36 std::shared_ptr<sal_uInt8> m_pData;
37 sal_uInt32 mn_offset;
38 sal_uInt32 mn_size;
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;
45 sal_uInt8 getU8(sal_uInt32 nOffset);
47 sal_uInt16 getU16(sal_uInt32 nOffset)
48 { return getU8(nOffset) + (getU8(nOffset + 1) << 8); }
50 OUString getUString(sal_uInt32 nOffset, sal_Int32 nCount);
53 template <class T>
54 class WW8Sttb : public WW8Struct
56 typedef std::shared_ptr< void > ExtraPointer_t;
57 bool m_bDoubleByteCharacters;
58 std::vector<OUString> m_Strings;
59 std::vector< ExtraPointer_t > m_Extras;
61 public:
62 WW8Sttb(SvStream& rSt, sal_Int32 nPos, sal_uInt32 nSize);
63 virtual ~WW8Sttb() override;
65 std::vector<OUString> & getStrings()
67 return m_Strings;
71 template <class T>
72 WW8Sttb<T>::WW8Sttb(SvStream& rSt, sal_Int32 nPos, sal_uInt32 nSize)
73 : WW8Struct(rSt, nPos, nSize), m_bDoubleByteCharacters(false)
75 sal_uInt32 nOffset = 0;
77 if (getU16(nOffset) == 0xffff)
79 m_bDoubleByteCharacters = true;
80 nOffset += 2;
83 sal_uInt16 nCount = getU16(nOffset);
84 sal_uInt16 ncbExtra = getU16(nOffset + 2);
86 nOffset += 4;
87 for (sal_uInt16 i = 0; i < nCount; i++)
89 if (m_bDoubleByteCharacters)
91 sal_uInt16 nStrLen = getU16(nOffset);
93 m_Strings.push_back(getUString(nOffset +2, nStrLen));
95 nOffset += 2 + 2 * nStrLen;
97 else
99 sal_uInt8 nStrLen = getU8(nOffset);
101 m_Strings.push_back(getUString(nOffset, nStrLen));
103 nOffset += 1 + nStrLen;
106 if (ncbExtra > 0)
108 ExtraPointer_t pExtra = std::make_shared<T>(this, nOffset, ncbExtra);
109 m_Extras.push_back(pExtra);
111 nOffset += ncbExtra;
116 template <class T>
117 WW8Sttb<T>::~WW8Sttb()
122 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WW8STTBF_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */