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 .
21 #include "bundles.hxx"
25 void Bundle::SetColor( sal_uInt32 nColor
)
36 FontEntry
* CGMFList::GetFontEntry( sal_uInt32 nIndex
)
38 sal_uInt32 nInd
= nIndex
;
41 return ( nInd
< aFontEntryList
.size() ) ? &aFontEntryList
[nInd
] : nullptr;
44 static sal_Int8
* ImplSearchEntry( sal_Int8
* pSource
, sal_Int8
const * pDest
, sal_uInt32 nComp
, sal_uInt32 nSize
)
46 while ( nComp
-- >= nSize
)
49 for ( i
= 0; i
< nSize
; i
++ )
51 if ( ( pSource
[i
]&~0x20 ) != ( pDest
[i
]&~0x20 ) )
61 void CGMFList::InsertName( sal_uInt8
const * pSource
, sal_uInt32 nSize
)
63 FontEntry
* pFontEntry
;
64 if (nFontNameCount
== aFontEntryList
.size())
66 aFontEntryList
.push_back(FontEntry());
67 pFontEntry
= &aFontEntryList
.back();
71 pFontEntry
= &aFontEntryList
[nFontNameCount
];
78 std::vector
<sal_Int8
> aBuf(pSource
, pSource
+ nSize
);
79 sal_Int8
* pFound
= ImplSearchEntry(aBuf
.data(), reinterpret_cast<sal_Int8
const *>("ITALIC"), nSize
, 6);
82 pFontEntry
->nFontType
|= 1;
83 sal_uInt32 nPrev
= pFound
- aBuf
.data();
84 sal_uInt32 nToCopyOfs
= 6;
85 if ( nPrev
&& ( pFound
[ -1 ] == '-' || pFound
[ -1 ] == ' ' ) )
91 sal_uInt32 nToCopy
= nSize
- nToCopyOfs
- nPrev
;
94 memmove( pFound
, pFound
+ nToCopyOfs
, nToCopy
);
98 pFound
= ImplSearchEntry(aBuf
.data(), reinterpret_cast<sal_Int8
const *>("BOLD"), nSize
, 4);
101 pFontEntry
->nFontType
|= 2;
103 sal_uInt32 nPrev
= pFound
- aBuf
.data();
104 sal_uInt32 nToCopyOfs
= 4;
105 if ( nPrev
&& ( pFound
[ -1 ] == '-' || pFound
[ -1 ] == ' ' ) )
111 sal_uInt32 nToCopy
= nSize
- nToCopyOfs
- nPrev
;
114 memmove( pFound
, pFound
+ nToCopyOfs
, nToCopy
);
118 pFontEntry
->aFontName
.assign(aBuf
.data(), aBuf
.data() + nSize
);
121 void CGMFList::InsertCharSet( sal_uInt8
const * pSource
, sal_uInt32 nSize
)
123 FontEntry
* pFontEntry
;
124 if (nCharSetCount
== aFontEntryList
.size())
126 aFontEntryList
.push_back(FontEntry());
127 pFontEntry
= &aFontEntryList
.back();
131 pFontEntry
= &aFontEntryList
[nCharSetCount
];
138 pFontEntry
->aCharSetValue
.assign(pSource
, pSource
+ nSize
);
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */