svgwriter.cxx (4c98811d) | svgwriter.cxx (cb0a2370) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 882 unchanged lines hidden (view full) --- 891 { 892 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False ); 893 mrExport.GetDocHandler()->characters( aGlyph ); 894 } 895 896 if( bCont ) 897 { 898 // #118796# do NOT access pDXArray, it may be zero (!) | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 882 unchanged lines hidden (view full) --- 891 { 892 SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False ); 893 mrExport.GetDocHandler()->characters( aGlyph ); 894 } 895 896 if( bCont ) 897 { 898 // #118796# do NOT access pDXArray, it may be zero (!) |
899 nX = aPos.X() + pDX[ nCurPos - 1 ]; | 899 sal_Int32 nWidth = pDX[ nCurPos - 1 ]; 900 if ( bApplyMapping ) 901 nWidth = ImplMap( nWidth ); 902 nX = aPos.X() + nWidth; |
900 } 901 } 902 } 903 } 904 } 905 else 906 { 907 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) ); --- 59 unchanged lines hidden (view full) --- 967 if( !!aBmpEx ) 968 { 969 SvMemoryStream aOStm( 65535, 65535 ); 970 971 if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE ) 972 { 973 Point aPt; 974 Size aSz; | 903 } 904 } 905 } 906 } 907 } 908 else 909 { 910 mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) ); --- 59 unchanged lines hidden (view full) --- 970 if( !!aBmpEx ) 971 { 972 SvMemoryStream aOStm( 65535, 65535 ); 973 974 if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE ) 975 { 976 Point aPt; 977 Size aSz; |
975 ::rtl::OUString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell(), RTL_TEXTENCODING_ASCII_US ); | 978 979 // #119735# Do not copy the stream data to a ::rtl::OUString any longer, this is not needed and 980 // (of course) throws many exceptions with the used RTL_TEXTENCODING_ASCII_US. Keeping that line 981 // to show what I'm talking about 982 // ::rtl::OUString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell(), RTL_TEXTENCODING_ASCII_US ); 983 const sal_Char* pImageData = (sal_Char*)aOStm.GetData(); 984 const sal_uInt32 nImageDataLength = aOStm.Tell(); |
976 REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( mrExport.GetDocHandler(), NMSP_UNO::UNO_QUERY ); 977 978 if( bApplyMapping ) 979 { 980 ImplMap( rPt, aPt ); 981 ImplMap( rSz, aSz ); 982 } 983 else --- 34 unchanged lines hidden (view full) --- 1018 aString += ::rtl::OUString::valueOf( aSz.Height() ); 1019 aString += B2UCONST( "\" " ); 1020 1021 aString += ::rtl::OUString::createFromAscii( aXMLAttrXLinkHRef ); 1022 aString += B2UCONST( "=\"data:image/png;base64," ); 1023 1024 xExtDocHandler->unknown( aString ); 1025 | 985 REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( mrExport.GetDocHandler(), NMSP_UNO::UNO_QUERY ); 986 987 if( bApplyMapping ) 988 { 989 ImplMap( rPt, aPt ); 990 ImplMap( rSz, aSz ); 991 } 992 else --- 34 unchanged lines hidden (view full) --- 1027 aString += ::rtl::OUString::valueOf( aSz.Height() ); 1028 aString += B2UCONST( "\" " ); 1029 1030 aString += ::rtl::OUString::createFromAscii( aXMLAttrXLinkHRef ); 1031 aString += B2UCONST( "=\"data:image/png;base64," ); 1032 1033 xExtDocHandler->unknown( aString ); 1034 |
1026 const sal_uInt32 nQuadCount = aImageData.getLength() / 3; 1027 const sal_uInt32 nRest = aImageData.getLength() % 3; | 1035 // #119735# 1036 const sal_uInt32 nQuadCount = nImageDataLength / 3; 1037 const sal_uInt32 nRest = nImageDataLength % 3; |
1028 1029 if( nQuadCount || nRest ) 1030 { 1031 sal_Int32 nBufLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 ); | 1038 1039 if( nQuadCount || nRest ) 1040 { 1041 sal_Int32 nBufLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 ); |
1032 const sal_Unicode* pSrc = (const sal_Unicode*) aImageData; | 1042 const sal_Char* pSrc = pImageData; 1043 |
1033 sal_Unicode* pBuffer = new sal_Unicode[ nBufLen * sizeof( sal_Unicode ) ]; 1034 sal_Unicode* pTmpDst = pBuffer; 1035 1036 for( sal_uInt32 i = 0; i < nQuadCount; ++i ) 1037 { 1038 const sal_Int32 nA = *pSrc++; 1039 const sal_Int32 nB = *pSrc++; 1040 const sal_Int32 nC = *pSrc++; --- 810 unchanged lines hidden (view full) --- 1851 { 1852 ImplWriteShape( *mapCurShape ); 1853 mapCurShape.reset(); 1854 } 1855 1856 ImplReleaseContext(); 1857 mpVDev->Pop(); 1858} | 1044 sal_Unicode* pBuffer = new sal_Unicode[ nBufLen * sizeof( sal_Unicode ) ]; 1045 sal_Unicode* pTmpDst = pBuffer; 1046 1047 for( sal_uInt32 i = 0; i < nQuadCount; ++i ) 1048 { 1049 const sal_Int32 nA = *pSrc++; 1050 const sal_Int32 nB = *pSrc++; 1051 const sal_Int32 nC = *pSrc++; --- 810 unchanged lines hidden (view full) --- 1862 { 1863 ImplWriteShape( *mapCurShape ); 1864 mapCurShape.reset(); 1865 } 1866 1867 ImplReleaseContext(); 1868 mpVDev->Pop(); 1869} |
1870 1871// ------------- 1872// - SVGWriter - 1873// ------------- 1874 1875SVGWriter::SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) : 1876 mxFact( rxMgr ) 1877{ 1878} 1879 1880// ----------------------------------------------------------------------------- 1881 1882SVGWriter::~SVGWriter() 1883{ 1884} 1885 1886// ----------------------------------------------------------------------------- 1887 1888 1889ANY SAL_CALL SVGWriter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException ) 1890{ 1891 const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGWriter* >( this ) ) ); 1892 1893 return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) ); 1894} 1895 1896// ----------------------------------------------------------------------------- 1897 1898void SAL_CALL SVGWriter::acquire() throw() 1899{ 1900 OWeakObject::acquire(); 1901} 1902 1903// ----------------------------------------------------------------------------- 1904 1905void SAL_CALL SVGWriter::release() throw() 1906{ 1907 OWeakObject::release(); 1908} 1909 1910// ----------------------------------------------------------------------------- 1911 1912void SAL_CALL SVGWriter::write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler, 1913 const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException ) 1914{ 1915 SvMemoryStream aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ ); 1916 GDIMetaFile aMtf; 1917 1918 aMemStm.SetCompressMode( COMPRESSMODE_FULL ); 1919 aMemStm >> aMtf; 1920 1921 const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxDocHandler ); 1922 const Sequence< PropertyValue > aFilterData; 1923 1924 SVGExport* pWriter = new SVGExport( mxFact, xDocumentHandler, aFilterData ); 1925 1926 pWriter->writeMtf( aMtf ); 1927 delete pWriter; 1928} 1929 1930// ----------------------------------------------------------------------------- 1931 1932#define SVG_WRITER_SERVICE_NAME "com.sun.star.svg.SVGWriter" 1933#define SVG_WRITER_IMPLEMENTATION_NAME "com.sun.star.comp.Draw.SVGWriter" 1934 1935rtl::OUString SVGWriter_getImplementationName() 1936 throw (RuntimeException) 1937{ 1938 return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( SVG_WRITER_IMPLEMENTATION_NAME ) ); 1939} 1940 1941// ----------------------------------------------------------------------------- 1942 1943Sequence< sal_Int8 > SAL_CALL SVGWriter_getImplementationId() 1944 throw(RuntimeException) 1945{ 1946 static const ::cppu::OImplementationId aId; 1947 1948 return( aId.getImplementationId() ); 1949} 1950 1951// ----------------------------------------------------------------------------- 1952 1953Sequence< rtl::OUString > SAL_CALL SVGWriter_getSupportedServiceNames() 1954 throw (RuntimeException) 1955{ 1956 Sequence< rtl::OUString > aRet( 1 ); 1957 1958 aRet.getArray()[ 0 ] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SVG_WRITER_SERVICE_NAME ) ); 1959 1960 return aRet; 1961} 1962 1963// ----------------------------------------------------------------------------- 1964 1965Reference< XInterface > SAL_CALL SVGWriter_createInstance( const Reference< XMultiServiceFactory > & rSMgr ) 1966 throw( Exception ) 1967{ 1968 return( static_cast< cppu::OWeakObject* >( new SVGWriter( rSMgr ) ) ); 1969} 1970 |
|