diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-16 17:27:16 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-09-17 00:05:16 -0400 |
commit | 568e1b979451e29483d06dabebef7ac17b416841 (patch) | |
tree | 73f0b7f7ae6c4beb9ab5a50a3c035b83fd1aa503 /sfx2 | |
parent | c0022716105b9935ae16d3817191c546d3f8e0da (diff) |
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.
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/bastyp/mieclip.cxx | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/sfx2/source/bastyp/mieclip.cxx b/sfx2/source/bastyp/mieclip.cxx index badd2003f3c8..8d0c354c7d19 100644 --- a/sfx2/source/bastyp/mieclip.cxx +++ b/sfx2/source/bastyp/mieclip.cxx @@ -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: */ |