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 <tools/stream.hxx>
22 #include <sot/storage.hxx>
23 #include <sot/formats.hxx>
25 #include <sfx2/mieclip.hxx>
26 #include <sfx2/sfxuno.hxx>
28 MSE40HTMLClipFormatObj::~MSE40HTMLClipFormatObj()
33 SvStream
* MSE40HTMLClipFormatObj::IsValid( SvStream
& rStream
)
37 delete pStrm
, pStrm
= 0;
39 OString sLine
, sVersion
;
40 sal_Int32 nStt
= -1, nEnd
= -1, nFragStart
= -1, nFragEnd
= -1;
43 rStream
.Seek(STREAM_SEEK_TO_BEGIN
);
46 if( rStream
.ReadLine( sLine
) &&
47 sLine
.getToken( 0, ':', nIndex
) == "Version" )
49 sVersion
= sLine
.copy( nIndex
);
50 while( rStream
.ReadLine( sLine
) )
53 OString
sTmp(sLine
.getToken(0, ':', nIndex
));
54 if (sTmp
== "StartHTML")
55 nStt
= sLine
.copy(nIndex
).toInt32();
56 else if (sTmp
== "EndHTML")
57 nEnd
= sLine
.copy(nIndex
).toInt32();
58 else if (sTmp
== "StartFragment")
59 nFragStart
= sLine
.copy(nIndex
).toInt32();
60 else if (sTmp
== "EndFragment")
61 nFragEnd
= sLine
.copy(nIndex
).toInt32();
62 else if (sTmp
== "SourceURL")
63 sBaseURL
= OStringToOUString( sLine
.copy(nIndex
), RTL_TEXTENCODING_UTF8
);
65 if (nEnd
>= 0 && nStt
>= 0 &&
66 (!sBaseURL
.isEmpty() || rStream
.Tell() >= static_cast<sal_Size
>(nStt
)))
78 pStrm
= new SvMemoryStream( ( nEnd
- nStt
< 0x10000l
81 pStrm
->WriteStream( rStream
);
82 pStrm
->SetStreamSize( nEnd
- nStt
+ 1L );
83 pStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
87 if (nFragStart
> 0 && nFragEnd
> 0 && nFragEnd
> nFragStart
)
89 sal_uIntPtr nSize
= static_cast<sal_uIntPtr
>(nFragEnd
- nFragStart
+ 1);
92 rStream
.Seek(nFragStart
);
93 pStrm
= new SvMemoryStream(nSize
);
94 pStrm
->WriteStream( rStream
);
95 pStrm
->SetStreamSize(nSize
);
96 pStrm
->Seek(STREAM_SEEK_TO_BEGIN
);
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */