Kaydet (Commit) 568e1b97 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

When pasting from other apps, fall back on Fragment span.

We need to handle fragment span in case the HTML span is not provided
by the source application.  According to the MS spec it is allowed.

The old code assumed that the source app would always provide an
HTML span.  Apparently some apps don't, and only provides a fragment
span.
üst c0022716
......@@ -44,12 +44,12 @@ MSE40HTMLClipFormatObj::~MSE40HTMLClipFormatObj()
SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
{
sal_Bool bRet = sal_False;
bool bRet = false;
if( pStrm )
delete pStrm, pStrm = 0;
rtl::OString sLine, sVersion;
sal_uIntPtr nStt = 0, nEnd = 0;
sal_Int32 nStt = -1, nEnd = -1, nFragStart = -1, nFragEnd = -1;
sal_Int32 nIndex = 0;
rStream.Seek(STREAM_SEEK_TO_BEGIN);
......@@ -64,16 +64,20 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
nIndex = 0;
rtl::OString sTmp(sLine.getToken(0, ':', nIndex));
if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM("StartHTML")))
nStt = (sal_uIntPtr)(sLine.copy(nIndex).toInt32());
nStt = sLine.copy(nIndex).toInt32();
else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM("EndHTML")))
nEnd = (sal_uIntPtr)(sLine.copy(nIndex).toInt32());
nEnd = sLine.copy(nIndex).toInt32();
else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM("StartFragment")))
nFragStart = sLine.copy(nIndex).toInt32();
else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM("EndFragment")))
nFragEnd = sLine.copy(nIndex).toInt32();
else if (sTmp.equalsL(RTL_CONSTASCII_STRINGPARAM("SourceURL")))
sBaseURL = S2U(sLine.copy(nIndex));
if( nEnd && nStt &&
( sBaseURL.Len() || rStream.Tell() >= nStt ))
if (nEnd >= 0 && nStt >= 0 &&
(sBaseURL.Len() || rStream.Tell() >= static_cast<sal_Size>(nStt)))
{
bRet = sal_True;
bRet = true;
break;
}
}
......@@ -89,9 +93,24 @@ SvStream* MSE40HTMLClipFormatObj::IsValid( SvStream& rStream )
*pStrm << rStream;
pStrm->SetStreamSize( nEnd - nStt + 1L );
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
return pStrm;
}
return pStrm;
if (nFragStart > 0 && nFragEnd > 0 && nFragEnd > nFragStart)
{
sal_uIntPtr nSize = static_cast<sal_uIntPtr>(nFragEnd - nFragStart + 1);
if (nSize < 0x10000L)
{
rStream.Seek(nFragStart);
pStrm = new SvCacheStream(nSize);
*pStrm << rStream;
pStrm->SetStreamSize(nSize);
pStrm->Seek(STREAM_SEEK_TO_BEGIN);
return pStrm;
}
}
return NULL;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment