View | Details | Raw Unified | Return to issue 76649
Collapse All | Expand All

(-)openoffice.org.orig/sc/source/filter/html/htmlpars.cxx (-44 / +2 lines)
Lines 157-183 Link Here
157
    SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
157
    SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
158
    BOOL bLoading = pObjSh && pObjSh->IsLoading();
158
    BOOL bLoading = pObjSh && pObjSh->IsLoading();
159
159
160
    SvKeyValueIteratorRef xValues;
160
    SvKeyValueIterator* pAttributes = bLoading ? pObjSh->GetHeaderAttributes() : 0;
161
    SvKeyValueIterator* pAttributes = NULL;
162
    if ( bLoading )
163
        pAttributes = pObjSh->GetHeaderAttributes();
164
    else
165
    {
166
        //  When not loading, set up fake http headers to force the SfxHTMLParser to use UTF8
167
        //  (used when pasting from clipboard)
168
169
        const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
170
        if( pCharSet )
171
        {
172
            String aContentType = String::CreateFromAscii( "text/html; charset=" );
173
            aContentType.AppendAscii( pCharSet );
174
175
            xValues = new SvKeyValueIterator;
176
            xValues->Append( SvKeyValue( String::CreateFromAscii( OOO_STRING_SVTOOLS_HTML_META_content_type ), aContentType ) );
177
            pAttributes = xValues;
178
        }
179
    }
180
181
    ULONG nErr = pEdit->Read( rStream, rBaseURL, EE_FORMAT_HTML, pAttributes );
161
    ULONG nErr = pEdit->Read( rStream, rBaseURL, EE_FORMAT_HTML, pAttributes );
182
162
183
    pEdit->SetImportHdl( aOldLink );
163
    pEdit->SetImportHdl( aOldLink );
Lines 2796-2825 Link Here
2796
2776
2797
ULONG ScHTMLQueryParser::Read( SvStream& rStrm, const String& rBaseURL  )
2777
ULONG ScHTMLQueryParser::Read( SvStream& rStrm, const String& rBaseURL  )
2798
{
2778
{
2799
    SvKeyValueIteratorRef xValues;
2800
    SvKeyValueIterator* pAttributes = 0;
2801
2802
    SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
2779
    SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
2803
    if( pObjSh && pObjSh->IsLoading() )
2780
    SvKeyValueIterator* pAttributes = (pObjSh && pObjSh->IsLoading()) ? pObjSh->GetHeaderAttributes() : 0;
2804
    {
2805
        pAttributes = pObjSh->GetHeaderAttributes();
2806
    }
2807
    else
2808
    {
2809
        /*  When not loading, set up fake HTTP headers to force the SfxHTMLParser
2810
            to use UTF8 (used when pasting from clipboard) */
2811
        const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
2812
        if( pCharSet )
2813
        {
2814
            String aContentType = String::CreateFromAscii( "text/html; charset=" );
2815
            aContentType.AppendAscii( pCharSet );
2816
2817
            xValues = new SvKeyValueIterator;
2818
            xValues->Append( SvKeyValue( String::CreateFromAscii( OOO_STRING_SVTOOLS_HTML_META_content_type ), aContentType ) );
2819
            pAttributes = xValues;
2820
        }
2821
    }
2822
2823
    Link aOldLink = pEdit->GetImportHdl();
2781
    Link aOldLink = pEdit->GetImportHdl();
2824
    pEdit->SetImportHdl( LINK( this, ScHTMLQueryParser, HTMLImportHdl ) );
2782
    pEdit->SetImportHdl( LINK( this, ScHTMLQueryParser, HTMLImportHdl ) );
2825
    ULONG nErr = pEdit->Read( rStrm, rBaseURL, EE_FORMAT_HTML, pAttributes );
2783
    ULONG nErr = pEdit->Read( rStrm, rBaseURL, EE_FORMAT_HTML, pAttributes );
(-)openoffice.org.orig/sw/source/filter/html/swhtml.cxx (-5 / +3 lines)
Lines 491-497 Link Here
491
	bOldIsHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE);
491
	bOldIsHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE);
492
	pDoc->set(IDocumentSettingAccess::HTML_MODE, true);
492
	pDoc->set(IDocumentSettingAccess::HTML_MODE, true);
493
493
494
    pCSS1Parser = new SwCSS1Parser( pDoc, aFontHeights, sBaseURL, IsNewDoc() );
494
	pCSS1Parser = new SwCSS1Parser( pDoc, aFontHeights, sBaseURL, IsNewDoc() );
495
	pCSS1Parser->SetIgnoreFontFamily( pHtmlOptions->IsIgnoreFontFamily() );
495
	pCSS1Parser->SetIgnoreFontFamily( pHtmlOptions->IsIgnoreFontFamily() );
496
496
497
	if( bReadUTF8 )
497
	if( bReadUTF8 )
Lines 501-510 Link Here
501
	else
501
	else
502
	{
502
	{
503
		SwDocShell *pDocSh = pDoc->GetDocShell();
503
		SwDocShell *pDocSh = pDoc->GetDocShell();
504
		SvKeyValueIterator *pHeaderAttrs =
504
		SvKeyValueIterator *pHeaderAttrs = (pDocSh && pDocSh->IsLoading()) ? pDocSh->GetHeaderAttributes() : 0;
505
			pDocSh->GetHeaderAttributes();
505
		SetEncodingByHTTPHeader( pHeaderAttrs );
506
		if( pHeaderAttrs )
507
			SetEncodingByHTTPHeader( pHeaderAttrs );
508
	}
506
	}
509
	pCSS1Parser->SetDfltEncoding( gsl_getSystemTextEncoding() );
507
	pCSS1Parser->SetDfltEncoding( gsl_getSystemTextEncoding() );
510
508
(-)openoffice.org.orig/sfx2/source/bastyp/sfxhtml.cxx (-1 / +22 lines)
Lines 53-62 Link Here
53
#include <tools/tenccvt.hxx>
53
#include <tools/tenccvt.hxx>
54
54
55
#include <sfx2/sfxhtml.hxx>
55
#include <sfx2/sfxhtml.hxx>
56
#include <sfx2/objsh.hxx>
57
#include <sfx2/docfile.hxx>
56
58
57
#include <com/sun/star/beans/XPropertyContainer.hpp>
59
#include <com/sun/star/beans/XPropertyContainer.hpp>
58
60
59
60
using namespace ::com::sun::star;
61
using namespace ::com::sun::star;
61
62
62
63
Lines 381-386 Link Here
381
BOOL SfxHTMLParser::SetEncodingByHTTPHeader(
382
BOOL SfxHTMLParser::SetEncodingByHTTPHeader(
382
								SvKeyValueIterator *pHTTPHeader )
383
								SvKeyValueIterator *pHTTPHeader )
383
{
384
{
385
	SvKeyValueIteratorRef xValues;
386
    /*  
387
	 *  When not loading, set up fake HTTP headers to force the
388
	 *  SfxHTMLParser to use UTF8 (used when pasting from clipboard) 
389
	 */
390
	SfxObjectShell* pObjSh = !pHTTPHeader ? SfxObjectShell::Current() : 0;
391
	if( pObjSh && !pObjSh->IsLoading() )
392
	{
393
		const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
394
		if( pCharSet )
395
		{
396
			String aContentType = String::CreateFromAscii( "text/html; charset=" );
397
			aContentType.AppendAscii( pCharSet );
398
399
			xValues = new SvKeyValueIterator;
400
			xValues->Append( SvKeyValue( String::CreateFromAscii( sHTML_META_content_type ), aContentType ) );
401
			pHTTPHeader = xValues;
402
		}
403
	}
404
384
	BOOL bRet = FALSE;
405
	BOOL bRet = FALSE;
385
    rtl_TextEncoding eEnc = SfxHTMLParser::GetEncodingByHttpHeader( pHTTPHeader );
406
    rtl_TextEncoding eEnc = SfxHTMLParser::GetEncodingByHttpHeader( pHTTPHeader );
386
    if(RTL_TEXTENCODING_DONTKNOW != eEnc)
407
    if(RTL_TEXTENCODING_DONTKNOW != eEnc)
(-)openoffice.org.orig/svx/source/editeng/eehtml.cxx (-2 / +1 lines)
Lines 72-79 Link Here
72
	nNumberingLevel = 0;
72
	nNumberingLevel = 0;
73
	bFieldsInserted = FALSE;
73
	bFieldsInserted = FALSE;
74
74
75
    if ( pHTTPHeaderAttrs )
75
	SetEncodingByHTTPHeader( pHTTPHeaderAttrs );
76
		SetEncodingByHTTPHeader( pHTTPHeaderAttrs );
77
}
76
}
78
77
79
EditHTMLParser::~EditHTMLParser()
78
EditHTMLParser::~EditHTMLParser()

Return to issue 76649