1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <tools/stream.hxx>
30 #include <tools/cachestr.hxx>
32 #include <sot/storage.hxx>
33 #include <sot/formats.hxx>
35 #include <sfx2/mieclip.hxx>
36 #include <sfx2/sfxuno.hxx>
38 MSE40HTMLClipFormatObj::~MSE40HTMLClipFormatObj()
43 SvStream
* MSE40HTMLClipFormatObj::IsValid( SvStream
& rStream
)
47 delete pStrm
, pStrm
= 0;
49 rtl::OString sLine
, sVersion
;
50 sal_Int32 nStt
= -1, nEnd
= -1, nFragStart
= -1, nFragEnd
= -1;
53 rStream
.Seek(STREAM_SEEK_TO_BEGIN
);
56 if( rStream
.ReadLine( sLine
) &&
57 sLine
.getToken( 0, ':', nIndex
) == "Version" )
59 sVersion
= sLine
.copy( nIndex
);
60 while( rStream
.ReadLine( sLine
) )
63 rtl::OString
sTmp(sLine
.getToken(0, ':', nIndex
));
64 if (sTmp
.equalsL(RTL_CONSTASCII_STRINGPARAM("StartHTML")))
65 nStt
= sLine
.copy(nIndex
).toInt32();
66 else if (sTmp
.equalsL(RTL_CONSTASCII_STRINGPARAM("EndHTML")))
67 nEnd
= sLine
.copy(nIndex
).toInt32();
68 else if (sTmp
.equalsL(RTL_CONSTASCII_STRINGPARAM("StartFragment")))
69 nFragStart
= sLine
.copy(nIndex
).toInt32();
70 else if (sTmp
.equalsL(RTL_CONSTASCII_STRINGPARAM("EndFragment")))
71 nFragEnd
= sLine
.copy(nIndex
).toInt32();
72 else if (sTmp
.equalsL(RTL_CONSTASCII_STRINGPARAM("SourceURL")))
73 sBaseURL
= S2U(sLine
.copy(nIndex
));
75 if (nEnd
>= 0 && nStt
>= 0 &&
76 (sBaseURL
.Len() || rStream
.Tell() >= static_cast<sal_Size
>(nStt
)))
88 pStrm
= new SvCacheStream( ( nEnd
- nStt
< 0x10000l
92 pStrm
->SetStreamSize( nEnd
- nStt
+ 1L );
93 pStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
97 if (nFragStart
> 0 && nFragEnd
> 0 && nFragEnd
> nFragStart
)
99 sal_uIntPtr nSize
= static_cast<sal_uIntPtr
>(nFragEnd
- nFragStart
+ 1);
100 if (nSize
< 0x10000L
)
102 rStream
.Seek(nFragStart
);
103 pStrm
= new SvCacheStream(nSize
);
105 pStrm
->SetStreamSize(nSize
);
106 pStrm
->Seek(STREAM_SEEK_TO_BEGIN
);
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */