summaryrefslogtreecommitdiff
path: root/xmloff/source/text/XMLTextFrameContext.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-02-28 15:56:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-03-02 07:44:26 +0100
commit0cf5d0fa5e1a7d5dafa7e899e065edb042764f44 (patch)
tree32eea22346cc65464a477882f39257f1931dec73 /xmloff/source/text/XMLTextFrameContext.cxx
parent201a7652092c6a7796a59e6ddee144e4f0c9ece9 (diff)
don't rely on parser ::characters callback only firing once
which is true for the old parser, but not always so for the FastParser. So pre-emptively fix some stuff Change-Id: I405834f1dfd28c98cae87b6de38d238f723edafd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89712 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/text/XMLTextFrameContext.cxx')
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx89
1 files changed, 46 insertions, 43 deletions
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index e8b04539dd81..7eb3b2b14109 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -360,6 +360,7 @@ class XMLTextFrameContext_Impl : public SvXMLImportContext
OUString sFilterService;
OUString sBase64CharsLeft;
OUString sTblName;
+ OUStringBuffer maUrlBuffer;
ParamMap aParamMap;
@@ -1110,6 +1111,50 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
void XMLTextFrameContext_Impl::EndElement()
{
+ if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
+ XML_TEXT_FRAME_GRAPHIC == nType) &&
+ !xPropSet.is() && !bCreateFailed )
+ {
+ OUString sTrimmedChars = maUrlBuffer.makeStringAndClear().trim();
+ if( !sTrimmedChars.isEmpty() )
+ {
+ if( !xBase64Stream.is() )
+ {
+ if( XML_TEXT_FRAME_GRAPHIC == nType )
+ {
+ xBase64Stream =
+ GetImport().GetStreamForGraphicObjectURLFromBase64();
+ }
+ else
+ {
+ xBase64Stream =
+ GetImport().GetStreamForEmbeddedObjectURLFromBase64();
+ }
+ if( xBase64Stream.is() )
+ bOwnBase64Stream = true;
+ }
+ if( bOwnBase64Stream && xBase64Stream.is() )
+ {
+ OUString sChars;
+ if( !sBase64CharsLeft.isEmpty() )
+ {
+ sChars = sBase64CharsLeft + sTrimmedChars;
+ sBase64CharsLeft.clear();
+ }
+ else
+ {
+ sChars = sTrimmedChars;
+ }
+ Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
+ sal_Int32 nCharsDecoded =
+ ::comphelper::Base64::decodeSomeChars( aBuffer, sChars );
+ xBase64Stream->writeBytes( aBuffer );
+ if( nCharsDecoded != sChars.getLength() )
+ sBase64CharsLeft = sChars.copy( nCharsDecoded );
+ }
+ }
+ }
+
CreateIfNotThere();
if( xOldTextCursor.is() )
@@ -1209,49 +1254,7 @@ SvXMLImportContextRef XMLTextFrameContext_Impl::CreateChildContext(
void XMLTextFrameContext_Impl::Characters( const OUString& rChars )
{
- if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
- XML_TEXT_FRAME_GRAPHIC == nType) &&
- !xPropSet.is() && !bCreateFailed )
- {
- OUString sTrimmedChars( rChars. trim() );
- if( !sTrimmedChars.isEmpty() )
- {
- if( !xBase64Stream.is() )
- {
- if( XML_TEXT_FRAME_GRAPHIC == nType )
- {
- xBase64Stream =
- GetImport().GetStreamForGraphicObjectURLFromBase64();
- }
- else
- {
- xBase64Stream =
- GetImport().GetStreamForEmbeddedObjectURLFromBase64();
- }
- if( xBase64Stream.is() )
- bOwnBase64Stream = true;
- }
- if( bOwnBase64Stream && xBase64Stream.is() )
- {
- OUString sChars;
- if( !sBase64CharsLeft.isEmpty() )
- {
- sChars = sBase64CharsLeft + sTrimmedChars;
- sBase64CharsLeft.clear();
- }
- else
- {
- sChars = sTrimmedChars;
- }
- Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
- sal_Int32 nCharsDecoded =
- ::comphelper::Base64::decodeSomeChars( aBuffer, sChars );
- xBase64Stream->writeBytes( aBuffer );
- if( nCharsDecoded != sChars.getLength() )
- sBase64CharsLeft = sChars.copy( nCharsDecoded );
- }
- }
- }
+ maUrlBuffer.append(rChars);
}
void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,