diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 09:22:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 11:21:22 +0200 |
commit | f45ff1a7147e6a9479c669f082dd74349c6bcb4b (patch) | |
tree | 9ec5eee03fe7bbc5e026318efd6dcca3502d4696 /vcl/source/filter | |
parent | 58937aa4a50ecd681382f03331340da4c843b01e (diff) |
loplugin:flatten in vcl
Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/filter')
-rw-r--r-- | vcl/source/filter/FilterConfigCache.cxx | 106 | ||||
-rw-r--r-- | vcl/source/filter/FilterConfigItem.cxx | 148 | ||||
-rw-r--r-- | vcl/source/filter/igif/gifread.cxx | 34 | ||||
-rw-r--r-- | vcl/source/filter/jpeg/JpegReader.cxx | 22 | ||||
-rw-r--r-- | vcl/source/filter/png/pngwrite.cxx | 232 | ||||
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 186 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 1136 |
7 files changed, 932 insertions, 932 deletions
diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 5321ea2599c5..797466366d2a 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -157,61 +157,61 @@ void FilterConfigCache::ImplInit() Reference< XNameAccess > xTypeAccess ( openConfig("types" ), UNO_QUERY ); Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY ); - if ( xTypeAccess.is() && xFilterAccess.is() ) + if ( !(xTypeAccess.is() && xFilterAccess.is()) ) + return; + + const Sequence< OUString > lAllFilter = xFilterAccess->getElementNames(); + + for ( const OUString& sInternalFilterName : lAllFilter ) { - const Sequence< OUString > lAllFilter = xFilterAccess->getElementNames(); + Reference< XPropertySet > xFilterSet; + xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet; + if (!xFilterSet.is()) + continue; + + FilterConfigCacheEntry aEntry; + + aEntry.sInternalFilterName = sInternalFilterName; + xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType; + xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName; + xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType; + Sequence< OUString > lFlags; + xFilterSet->getPropertyValue(SFLAGS) >>= lFlags; + if (lFlags.getLength()!=1 || lFlags[0].isEmpty()) + continue; + if (lFlags[0].equalsIgnoreAsciiCase("import")) + aEntry.nFlags = 1; + else if (lFlags[0].equalsIgnoreAsciiCase("export")) + aEntry.nFlags = 2; + + OUString sFormatName; + xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName; + aEntry.CreateFilterName( sFormatName ); + + Reference< XPropertySet > xTypeSet; + xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet; + if (!xTypeSet.is()) + continue; + + xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType; + css::uno::Sequence<OUString> tmp; + if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp) + aEntry.lExtensionList = comphelper::sequenceToContainer<std::vector<OUString>>(tmp); + + // The first extension will be used + // to generate our internal FilterType ( BMP, WMF ... ) + OUString aExtension( aEntry.GetShortName() ); + if (aExtension.getLength() != 3) + continue; - for ( const OUString& sInternalFilterName : lAllFilter ) - { - Reference< XPropertySet > xFilterSet; - xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet; - if (!xFilterSet.is()) - continue; - - FilterConfigCacheEntry aEntry; - - aEntry.sInternalFilterName = sInternalFilterName; - xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType; - xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName; - xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType; - Sequence< OUString > lFlags; - xFilterSet->getPropertyValue(SFLAGS) >>= lFlags; - if (lFlags.getLength()!=1 || lFlags[0].isEmpty()) - continue; - if (lFlags[0].equalsIgnoreAsciiCase("import")) - aEntry.nFlags = 1; - else if (lFlags[0].equalsIgnoreAsciiCase("export")) - aEntry.nFlags = 2; - - OUString sFormatName; - xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName; - aEntry.CreateFilterName( sFormatName ); - - Reference< XPropertySet > xTypeSet; - xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet; - if (!xTypeSet.is()) - continue; - - xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType; - css::uno::Sequence<OUString> tmp; - if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp) - aEntry.lExtensionList = comphelper::sequenceToContainer<std::vector<OUString>>(tmp); - - // The first extension will be used - // to generate our internal FilterType ( BMP, WMF ... ) - OUString aExtension( aEntry.GetShortName() ); - if (aExtension.getLength() != 3) - continue; - - if ( aEntry.nFlags & 1 ) - aImport.push_back( aEntry ); - if ( aEntry.nFlags & 2 ) - aExport.push_back( aEntry ); - - // bFilterEntryCreated!? - if (!( aEntry.nFlags & 3 )) - continue; //? Entry was already inserted ... but following code will be suppressed?! - } + if ( aEntry.nFlags & 1 ) + aImport.push_back( aEntry ); + if ( aEntry.nFlags & 2 ) + aExport.push_back( aEntry ); + + // bFilterEntryCreated!? + if (!( aEntry.nFlags & 3 )) + continue; //? Entry was already inserted ... but following code will be suppressed?! } }; diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx index 41c9ec401064..a81102321388 100644 --- a/vcl/source/filter/FilterConfigItem.cxx +++ b/vcl/source/filter/FilterConfigItem.cxx @@ -105,28 +105,28 @@ void FilterConfigItem::ImpInitTree( const OUString& rSubTree ) Reference< XMultiServiceFactory > xCfgProv = theDefaultProvider::get( xContext ); OUString sTree = "/org.openoffice." + rSubTree; - if ( ImpIsTreeAvailable(xCfgProv, sTree) ) - { - // creation arguments: nodepath - PropertyValue aPathArgument; - aPathArgument.Name = "nodepath"; - aPathArgument.Value <<= sTree; + if ( !ImpIsTreeAvailable(xCfgProv, sTree) ) + return; - Sequence< Any > aArguments( 1 ); - aArguments[ 0 ] <<= aPathArgument; + // creation arguments: nodepath + PropertyValue aPathArgument; + aPathArgument.Name = "nodepath"; + aPathArgument.Value <<= sTree; - try - { - xUpdatableView = xCfgProv->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - aArguments ); - if ( xUpdatableView.is() ) - xPropSet.set( xUpdatableView, UNO_QUERY ); - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); - } + Sequence< Any > aArguments( 1 ); + aArguments[ 0 ] <<= aPathArgument; + + try + { + xUpdatableView = xCfgProv->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationUpdateAccess", + aArguments ); + if ( xUpdatableView.is() ) + xPropSet.set( xUpdatableView, UNO_QUERY ); + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); } } @@ -158,23 +158,23 @@ FilterConfigItem::~FilterConfigItem() void FilterConfigItem::WriteModifiedConfig() { - if ( xUpdatableView.is() ) + if ( !xUpdatableView.is() ) + return; + + if ( !(xPropSet.is() && bModified) ) + return; + + Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY ); + if ( xUpdateControl.is() ) { - if ( xPropSet.is() && bModified ) + try { - Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY ); - if ( xUpdateControl.is() ) - { - try - { - xUpdateControl->commitChanges(); - bModified = false; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not update configuration data" ); - } - } + xUpdateControl->commitChanges(); + bModified = false; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not update configuration data" ); } } } @@ -316,27 +316,27 @@ void FilterConfigItem::WriteBool( const OUString& rKey, bool bNewValue ) aBool.Value <<= bNewValue; WritePropertyValue( aFilterData, aBool ); - if ( xPropSet.is() ) + if ( !xPropSet.is() ) + return; + + Any aAny; + if ( !ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + return; + + bool bOldValue(true); + if ( !(aAny >>= bOldValue) ) + return; + + if ( bOldValue != bNewValue ) { - Any aAny; - if ( ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + try { - bool bOldValue(true); - if ( aAny >>= bOldValue ) - { - if ( bOldValue != bNewValue ) - { - try - { - xPropSet->setPropertyValue( rKey, Any(bNewValue) ); - bModified = true; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::WriteBool - could not set PropertyValue" ); - } - } - } + xPropSet->setPropertyValue( rKey, Any(bNewValue) ); + bModified = true; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::WriteBool - could not set PropertyValue" ); } } } @@ -348,28 +348,28 @@ void FilterConfigItem::WriteInt32( const OUString& rKey, sal_Int32 nNewValue ) aInt32.Value <<= nNewValue; WritePropertyValue( aFilterData, aInt32 ); - if ( xPropSet.is() ) - { - Any aAny; + if ( !xPropSet.is() ) + return; + + Any aAny; - if ( ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + if ( !ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + return; + + sal_Int32 nOldValue = 0; + if ( !(aAny >>= nOldValue) ) + return; + + if ( nOldValue != nNewValue ) + { + try { - sal_Int32 nOldValue = 0; - if ( aAny >>= nOldValue ) - { - if ( nOldValue != nNewValue ) - { - try - { - xPropSet->setPropertyValue( rKey, Any(nNewValue) ); - bModified = true; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::WriteInt32 - could not set PropertyValue" ); - } - } - } + xPropSet->setPropertyValue( rKey, Any(nNewValue) ); + bModified = true; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::WriteInt32 - could not set PropertyValue" ); } } } diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 47d9acb53c2a..045a6de0571e 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -302,27 +302,27 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount ) std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ nLen ]); std::size_t nRead = rIStm.ReadBytes(pBuf.get(), nLen); nCount = nRead/3UL; - if( NO_PENDING( rIStm ) ) - { - sal_uInt8* pTmp = pBuf.get(); + if( !(NO_PENDING( rIStm )) ) + return; - for (sal_uLong i = 0; i < nCount; ++i) - { - BitmapColor& rColor = (*pPal)[i]; + sal_uInt8* pTmp = pBuf.get(); - rColor.SetRed( *pTmp++ ); - rColor.SetGreen( *pTmp++ ); - rColor.SetBlue( *pTmp++ ); - } + for (sal_uLong i = 0; i < nCount; ++i) + { + BitmapColor& rColor = (*pPal)[i]; - // if possible accommodate some standard colours - if( nCount < 256 ) - { - (*pPal)[ 255UL ] = COL_WHITE; + rColor.SetRed( *pTmp++ ); + rColor.SetGreen( *pTmp++ ); + rColor.SetBlue( *pTmp++ ); + } - if( nCount < 255 ) - (*pPal)[ 254UL ] = COL_BLACK; - } + // if possible accommodate some standard colours + if( nCount < 256 ) + { + (*pPal)[ 255UL ] = COL_WHITE; + + if( nCount < 255 ) + (*pPal)[ 254UL ] = COL_BLACK; } } diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index df7374770463..cd378f4a855f 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -113,20 +113,20 @@ static void skip_input_data (j_decompress_ptr cinfo, long numberOfBytes) * it doesn't work on pipes. Not clear that being smart is worth * any trouble anyway --- large skips are infrequent. */ - if (numberOfBytes > 0) + if (numberOfBytes <= 0) + return; + + while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) { - while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) - { - numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); - (void) fill_input_buffer(cinfo); + numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); + (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return false, - * so suspension need not be handled. - */ - } - source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); - source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); + /* note we assume that fill_input_buffer will never return false, + * so suspension need not be handled. + */ } + source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); + source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); } static void term_source (j_decompress_ptr) diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx index 8190c1efd38a..720a5d10f3cb 100644 --- a/vcl/source/filter/png/pngwrite.cxx +++ b/vcl/source/filter/png/pngwrite.cxx @@ -112,136 +112,116 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBitmapEx, , mnBBP(0) , mbTrueAlpha(false) { - if (!rBitmapEx.IsEmpty()) - { - BitmapEx aBitmapEx; + if (rBitmapEx.IsEmpty()) + return; - if (rBitmapEx.GetBitmap().GetBitCount() == 32) - { - if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx)) - return; - } - else - { - aBitmapEx = rBitmapEx; - } + BitmapEx aBitmapEx; - Bitmap aBmp(aBitmapEx.GetBitmap()); + if (rBitmapEx.GetBitmap().GetBitCount() == 32) + { + if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx)) + return; + } + else + { + aBitmapEx = rBitmapEx; + } - mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max(); + Bitmap aBmp(aBitmapEx.GetBitmap()); - if (pFilterData) + mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max(); + + if (pFilterData) + { + for (const auto& rPropVal : *pFilterData) { - for (const auto& rPropVal : *pFilterData) + if (rPropVal.Name == "Compression") + rPropVal.Value >>= mnCompLevel; + else if (rPropVal.Name == "Interlaced") + rPropVal.Value >>= mnInterlaced; + else if (rPropVal.Name == "MaxChunkSize") { - if (rPropVal.Name == "Compression") - rPropVal.Value >>= mnCompLevel; - else if (rPropVal.Name == "Interlaced") - rPropVal.Value >>= mnInterlaced; - else if (rPropVal.Name == "MaxChunkSize") - { - sal_Int32 nVal = 0; - if (rPropVal.Value >>= nVal) - mnMaxChunkSize = static_cast<sal_uInt32>(nVal); - } + sal_Int32 nVal = 0; + if (rPropVal.Value >>= nVal) + mnMaxChunkSize = static_cast<sal_uInt32>(nVal); } } - mnBitsPerPixel = static_cast<sal_uInt8>(aBmp.GetBitCount()); + } + mnBitsPerPixel = static_cast<sal_uInt8>(aBmp.GetBitCount()); - if (aBitmapEx.IsTransparent()) + if (aBitmapEx.IsTransparent()) + { + if (mnBitsPerPixel <= 8 && aBitmapEx.IsAlpha()) { - if (mnBitsPerPixel <= 8 && aBitmapEx.IsAlpha()) - { - aBmp.Convert( BmpConversion::N24Bit ); - mnBitsPerPixel = 24; - } + aBmp.Convert( BmpConversion::N24Bit ); + mnBitsPerPixel = 24; + } - if (mnBitsPerPixel <= 8) // transparent palette + if (mnBitsPerPixel <= 8) // transparent palette + { + aBmp.Convert(BmpConversion::N8BitTrans); + aBmp.Replace(aBitmapEx.GetMask(), BMP_COL_TRANS); + mnBitsPerPixel = 8; + mpAccess = Bitmap::ScopedReadAccess(aBmp); + if (mpAccess) { - aBmp.Convert(BmpConversion::N8BitTrans); - aBmp.Replace(aBitmapEx.GetMask(), BMP_COL_TRANS); - mnBitsPerPixel = 8; - mpAccess = Bitmap::ScopedReadAccess(aBmp); - if (mpAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWritePalette(); - ImplWriteTransparent(); - ImplWriteIDAT(); - } - mpAccess.reset(); - } - else + if (ImplWriteHeader()) { - mbStatus = false; + ImplWritepHYs(aBitmapEx); + ImplWritePalette(); + ImplWriteTransparent(); + ImplWriteIDAT(); } + mpAccess.reset(); } else { - mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel - if (mpAccess) + mbStatus = false; + } + } + else + { + mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel + if (mpAccess) + { + mbTrueAlpha = aBitmapEx.IsAlpha(); + if (mbTrueAlpha) { - mbTrueAlpha = aBitmapEx.IsAlpha(); - if (mbTrueAlpha) + AlphaMask aMask(aBitmapEx.GetAlpha()); + mpMaskAccess = aMask.AcquireReadAccess(); + if (mpMaskAccess) { - AlphaMask aMask(aBitmapEx.GetAlpha()); - mpMaskAccess = aMask.AcquireReadAccess(); - if (mpMaskAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWriteIDAT(); - } - aMask.ReleaseAccess(mpMaskAccess); - mpMaskAccess = nullptr; - } - else + if (ImplWriteHeader()) { - mbStatus = false; + ImplWritepHYs(aBitmapEx); + ImplWriteIDAT(); } + aMask.ReleaseAccess(mpMaskAccess); + mpMaskAccess = nullptr; } else { - Bitmap aMask(aBitmapEx.GetMask()); - mpMaskAccess = aMask.AcquireReadAccess(); - if (mpMaskAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWriteIDAT(); - } - Bitmap::ReleaseAccess(mpMaskAccess); - mpMaskAccess = nullptr; - } - else - { - mbStatus = false; - } + mbStatus = false; } - mpAccess.reset(); } else { - mbStatus = false; - } - } - } - else - { - mpAccess = Bitmap::ScopedReadAccess(aBmp); // palette + RGB without alphachannel - if (mpAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - if (mpAccess->HasPalette()) - ImplWritePalette(); - - ImplWriteIDAT(); + Bitmap aMask(aBitmapEx.GetMask()); + mpMaskAccess = aMask.AcquireReadAccess(); + if (mpMaskAccess) + { + if (ImplWriteHeader()) + { + ImplWritepHYs(aBitmapEx); + ImplWriteIDAT(); + } + Bitmap::ReleaseAccess(mpMaskAccess); + mpMaskAccess = nullptr; + } + else + { + mbStatus = false; + } } mpAccess.reset(); } @@ -250,12 +230,32 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBitmapEx, mbStatus = false; } } + } + else + { + mpAccess = Bitmap::ScopedReadAccess(aBmp); // palette + RGB without alphachannel + if (mpAccess) + { + if (ImplWriteHeader()) + { + ImplWritepHYs(aBitmapEx); + if (mpAccess->HasPalette()) + ImplWritePalette(); - if (mbStatus) + ImplWriteIDAT(); + } + mpAccess.reset(); + } + else { - ImplOpenChunk(PNGCHUNK_IEND); // create an IEND chunk + mbStatus = false; } } + + if (mbStatus) + { + ImplOpenChunk(PNGCHUNK_IEND); // create an IEND chunk + } } bool PNGWriterImpl::Write(SvStream& rOStm) @@ -359,19 +359,19 @@ void PNGWriterImpl::ImplWriteTransparent() void PNGWriterImpl::ImplWritepHYs(const BitmapEx& rBmpEx) { - if (rBmpEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM) - { - Size aPrefSize(rBmpEx.GetPrefSize()); + if (rBmpEx.GetPrefMapMode().GetMapUnit() != MapUnit::Map100thMM) + return; - if (aPrefSize.Width() && aPrefSize.Height() && mnWidth && mnHeight) - { - ImplOpenChunk(PNGCHUNK_pHYs); - sal_uInt32 nPrefSizeX = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Width()) / mnWidth) + 0.5); - sal_uInt32 nPrefSizeY = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Height()) / mnHeight) + 0.5); - ImplWriteChunk(nPrefSizeX); - ImplWriteChunk(nPrefSizeY); - ImplWriteChunk(sal_uInt8(1)); // nMapUnit - } + Size aPrefSize(rBmpEx.GetPrefSize()); + + if (aPrefSize.Width() && aPrefSize.Height() && mnWidth && mnHeight) + { + ImplOpenChunk(PNGCHUNK_pHYs); + sal_uInt32 nPrefSizeX = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Width()) / mnWidth) + 0.5); + sal_uInt32 nPrefSizeY = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Height()) / mnHeight) + 0.5); + ImplWriteChunk(nPrefSizeX); + ImplWriteChunk(nPrefSizeY); + ImplWriteChunk(sal_uInt8(1)); // nMapUnit } } diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 0204999672dc..e02fa107d233 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -415,37 +415,37 @@ bool EMFWriter::ImplPrepareHandleSelect( sal_uInt32& rHandle, sal_uLong nSelectT void EMFWriter::ImplCheckLineAttr() { - if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) ) - { - sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5; + if( !(mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT )) ) + return; - ImplBeginRecord( WIN_EMR_CREATEPEN ); - m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( 0/*nWidth*/ ).WriteUInt32( 0/*nHeight*/ ); - ImplWriteColor( maVDev->GetLineColor() ); - ImplEndRecord(); + sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5; - ImplBeginRecord( WIN_EMR_SELECTOBJECT ); - m_rStm.WriteUInt32( mnLineHandle ); - ImplEndRecord(); - } + ImplBeginRecord( WIN_EMR_CREATEPEN ); + m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( 0/*nWidth*/ ).WriteUInt32( 0/*nHeight*/ ); + ImplWriteColor( maVDev->GetLineColor() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + m_rStm.WriteUInt32( mnLineHandle ); + ImplEndRecord(); } void EMFWriter::ImplCheckFillAttr() { - if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) ) - { - sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1; + if( !(mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT )) ) + return; - ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); - m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle ); - ImplWriteColor( maVDev->GetFillColor() ); - m_rStm.WriteUInt32( 0/*nPatternStyle*/ ); - ImplEndRecord(); + sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1; - ImplBeginRecord( WIN_EMR_SELECTOBJECT ); - m_rStm.WriteUInt32( mnFillHandle ); - ImplEndRecord(); - } + ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); + m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle ); + ImplWriteColor( maVDev->GetFillColor() ); + m_rStm.WriteUInt32( 0/*nPatternStyle*/ ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + m_rStm.WriteUInt32( mnFillHandle ); + ImplEndRecord(); } void EMFWriter::ImplCheckTextAttr() @@ -618,26 +618,26 @@ void EMFWriter::ImplWriteRect( const tools::Rectangle& rRect ) void EMFWriter::ImplWritePolygonRecord( const tools::Polygon& rPoly, bool bClose ) { - if( rPoly.GetSize() ) + if( !rPoly.GetSize() ) + return; + + if( rPoly.HasFlags() ) + ImplWritePath( rPoly, bClose ); + else { - if( rPoly.HasFlags() ) - ImplWritePath( rPoly, bClose ); - else - { - if( bClose ) - ImplCheckFillAttr(); + if( bClose ) + ImplCheckFillAttr(); - ImplCheckLineAttr(); + ImplCheckLineAttr(); - ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE ); - ImplWriteRect( rPoly.GetBoundRect() ); - m_rStm.WriteUInt32( rPoly.GetSize() ); + ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE ); + ImplWriteRect( rPoly.GetBoundRect() ); + m_rStm.WriteUInt32( rPoly.GetSize() ); - for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ ) - ImplWritePoint( rPoly[ i ] ); + for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ ) + ImplWritePoint( rPoly[ i ] ); - ImplEndRecord(); - } + ImplEndRecord(); } } @@ -645,46 +645,46 @@ void EMFWriter::ImplWritePolyPolygonRecord( const tools::PolyPolygon& rPolyPoly { sal_uInt16 n, i, nPolyCount = rPolyPoly.Count(); - if( nPolyCount ) + if( !nPolyCount ) + return; + + if( 1 == nPolyCount ) + ImplWritePolygonRecord( rPolyPoly[ 0 ], true ); + else { - if( 1 == nPolyCount ) - ImplWritePolygonRecord( rPolyPoly[ 0 ], true ); - else - { - bool bHasFlags = false; - sal_uInt32 nTotalPoints = 0; + bool bHasFlags = false; + sal_uInt32 nTotalPoints = 0; - for( i = 0; i < nPolyCount; i++ ) - { - nTotalPoints += rPolyPoly[ i ].GetSize(); - if ( rPolyPoly[ i ].HasFlags() ) - bHasFlags = true; - } - if( nTotalPoints ) + for( i = 0; i < nPolyCount; i++ ) + { + nTotalPoints += rPolyPoly[ i ].GetSize(); + if ( rPolyPoly[ i ].HasFlags() ) + bHasFlags = true; + } + if( nTotalPoints ) + { + if ( bHasFlags ) + ImplWritePath( rPolyPoly, true ); + else { - if ( bHasFlags ) - ImplWritePath( rPolyPoly, true ); - else - { - ImplCheckFillAttr(); - ImplCheckLineAttr(); + ImplCheckFillAttr(); + ImplCheckLineAttr(); - ImplBeginRecord( WIN_EMR_POLYPOLYGON ); - ImplWriteRect( rPolyPoly.GetBoundRect() ); - m_rStm.WriteUInt32( nPolyCount ).WriteUInt32( nTotalPoints ); + ImplBeginRecord( WIN_EMR_POLYPOLYGON ); + ImplWriteRect( rPolyPoly.GetBoundRect() ); + m_rStm.WriteUInt32( nPolyCount ).WriteUInt32( nTotalPoints ); - for( i = 0; i < nPolyCount; i++ ) - m_rStm.WriteUInt32( rPolyPoly[ i ].GetSize() ); + for( i = 0; i < nPolyCount; i++ ) + m_rStm.WriteUInt32( rPolyPoly[ i ].GetSize() ); - for( i = 0; i < nPolyCount; i++ ) - { - const tools::Polygon& rPoly = rPolyPoly[ i ]; + for( i = 0; i < nPolyCount; i++ ) + { + const tools::Polygon& rPoly = rPolyPoly[ i ]; - for( n = 0; n < rPoly.GetSize(); n++ ) - ImplWritePoint( rPoly[ n ] ); - } - ImplEndRecord(); + for( n = 0; n < rPoly.GetSize(); n++ ) + ImplWritePoint( rPoly[ n ] ); } + ImplEndRecord(); } } } @@ -911,38 +911,38 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - if(rLinePolygon.count()) - { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; + if(!rLinePolygon.count()) + return; - rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - if(aLinePolyPolygon.count()) + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + for(auto const& rB2DPolygon : aLinePolyPolygon) { - for(auto const& rB2DPolygon : aLinePolyPolygon) - { - ImplWritePolygonRecord( tools::Polygon(rB2DPolygon), false ); - } + ImplWritePolygonRecord( tools::Polygon(rB2DPolygon), false ); } + } - if(aFillPolyPolygon.count()) - { - const Color aOldLineColor(maVDev->GetLineColor()); - const Color aOldFillColor(maVDev->GetFillColor()); + if(!aFillPolyPolygon.count()) + return; - maVDev->SetLineColor(); - maVDev->SetFillColor(aOldLineColor); + const Color aOldLineColor(maVDev->GetLineColor()); + const Color aOldFillColor(maVDev->GetFillColor()); - for(auto const& rB2DPolygon : aFillPolyPolygon) - { - ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) )); - } + maVDev->SetLineColor(); + maVDev->SetFillColor(aOldLineColor); - maVDev->SetLineColor(aOldLineColor); - maVDev->SetFillColor(aOldFillColor); - } + for(auto const& rB2DPolygon : aFillPolyPolygon) + { + ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) )); } + + maVDev->SetLineColor(aOldLineColor); + maVDev->SetFillColor(aOldFillColor); } void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index d9fa0d61ffe1..3e0d048c925a 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -164,24 +164,24 @@ WMFWriter::WMFWriter() void WMFWriter::MayCallback() { - if ( xStatusIndicator.is() ) - { - sal_uLong nPercent; + if ( !xStatusIndicator.is() ) + return; - // we simply assume that 16386 actions match to a bitmap - // (normally a metafile either contains only actions or some bitmaps and - // almost no actions. In which case the ratio is less important) + sal_uLong nPercent; - nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions) - *100 - /((nNumberOfBitmaps<<14)+nNumberOfActions); + // we simply assume that 16386 actions match to a bitmap + // (normally a metafile either contains only actions or some bitmaps and + // almost no actions. In which case the ratio is less important) - if ( nPercent >= nLastPercent + 3 ) - { - nLastPercent = nPercent; - if( nPercent <= 100 ) - xStatusIndicator->setValue( nPercent ); - } + nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions) + *100 + /((nNumberOfBitmaps<<14)+nNumberOfActions); + + if ( nPercent >= nLastPercent + 3 ) + { + nLastPercent = nPercent; + if( nPercent <= 100 ) + xStatusIndicator->setValue( nPercent ); } } @@ -942,684 +942,684 @@ void WMFWriter::SetAllAttr() eDstHorTextAlign = eSrcHorTextAlign; WMFRecord_SetTextAlign( eDstTextAlign, eDstHorTextAlign ); } - if ( aDstFont != aSrcFont ) + if ( aDstFont == aSrcFont ) + return; + + pVirDev->SetFont(aSrcFont); + if ( aDstFont.GetFamilyName() != aSrcFont.GetFamilyName() ) { - pVirDev->SetFont(aSrcFont); - if ( aDstFont.GetFamilyName() != aSrcFont.GetFamilyName() ) + FontCharMapRef xFontCharMap; + if ( pVirDev->GetFontCharMap( xFontCharMap ) ) { - FontCharMapRef xFontCharMap; - if ( pVirDev->GetFontCharMap( xFontCharMap ) ) - { - if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 ) - aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); - else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) - aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); - } + if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 ) + aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); + else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) + aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); } - - aDstFont = aSrcFont; - CreateSelectDeleteFont(aDstFont); } + + aDstFont = aSrcFont; + CreateSelectDeleteFont(aDstFont); } void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - if(rLinePolygon.count()) - { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; + if(!rLinePolygon.count()) + return; - rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - if(aLinePolyPolygon.count()) - { - aSrcLineInfo = rInfo; - SetLineAndFillAttr(); + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); - for(auto const& rB2DPolygon : aLinePolyPolygon) - { - WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) ); - } - } + if(aLinePolyPolygon.count()) + { + aSrcLineInfo = rInfo; + SetLineAndFillAttr(); - if(aFillPolyPolygon.count()) + for(auto const& rB2DPolygon : aLinePolyPolygon) { - const Color aOldLineColor(aSrcLineColor); - const Color aOldFillColor(aSrcFillColor); + WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) ); + } + } - aSrcLineColor = COL_TRANSPARENT; - aSrcFillColor = aOldLineColor; - SetLineAndFillAttr(); + if(!aFillPolyPolygon.count()) + return; - for(auto const& rB2DPolygon : aFillPolyPolygon) - { - WMFRecord_Polygon( tools::Polygon(rB2DPolygon) ); - } + const Color aOldLineColor(aSrcLineColor); + const Color aOldFillColor(aSrcFillColor); - aSrcLineColor = aOldLineColor; - aSrcFillColor = aOldFillColor; - SetLineAndFillAttr(); - } + aSrcLineColor = COL_TRANSPARENT; + aSrcFillColor = aOldLineColor; + SetLineAndFillAttr(); + + for(auto const& rB2DPolygon : aFillPolyPolygon) + { + WMFRecord_Polygon( tools::Polygon(rB2DPolygon) ); } + + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + SetLineAndFillAttr(); } void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) { - if( bStatus ) - { - size_t nACount = rMTF.GetActionSize(); + if( !bStatus ) + return; + + size_t nACount = rMTF.GetActionSize(); - WMFRecord_SetStretchBltMode(); + WMFRecord_SetStretchBltMode(); - for( size_t nA = 0; nA < nACount; nA++ ) + for( size_t nA = 0; nA < nACount; nA++ ) + { + MetaAction* pMA = rMTF.GetAction( nA ); + + switch( pMA->GetType() ) { - MetaAction* pMA = rMTF.GetAction( nA ); + case MetaActionType::PIXEL: + { + const MetaPixelAction* pA = static_cast<const MetaPixelAction *>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() ); + } + break; + + case MetaActionType::POINT: + { + const MetaPointAction* pA = static_cast<const MetaPointAction*>(pMA); + const Point& rPt = pA->GetPoint(); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_MoveTo( rPt); + WMFRecord_LineTo( rPt ); + } + break; - switch( pMA->GetType() ) + case MetaActionType::LINE: { - case MetaActionType::PIXEL: + const MetaLineAction* pA = static_cast<const MetaLineAction *>(pMA); + if(pA->GetLineInfo().IsDefault()) { - const MetaPixelAction* pA = static_cast<const MetaPixelAction *>(pMA); - aSrcLineInfo = LineInfo(); + aSrcLineInfo = pA->GetLineInfo(); SetLineAndFillAttr(); - WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() ); + WMFRecord_MoveTo( pA->GetStartPoint() ); + WMFRecord_LineTo( pA->GetEndPoint() ); } - break; - - case MetaActionType::POINT: + else { - const MetaPointAction* pA = static_cast<const MetaPointAction*>(pMA); - const Point& rPt = pA->GetPoint(); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_MoveTo( rPt); - WMFRecord_LineTo( rPt ); + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); } - break; + } + break; + + case MetaActionType::RECT: + { + const MetaRectAction* pA = static_cast<const MetaRectAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Rectangle( pA->GetRect() ); + } + break; + + case MetaActionType::ROUNDRECT: + { + const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); + } + break; + + case MetaActionType::ELLIPSE: + { + const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Ellipse( pA->GetRect() ); + } + break; - case MetaActionType::LINE: + case MetaActionType::ARC: + { + const MetaArcAction* pA = static_cast<const MetaArcAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() ); + } + break; + + case MetaActionType::PIE: + { + const MetaPieAction* pA = static_cast<const MetaPieAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case MetaActionType::CHORD: + { + const MetaChordAction* pA = static_cast<const MetaChordAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case MetaActionType::POLYLINE: + { + const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pMA); + const tools::Polygon& rPoly = pA->GetPolygon(); + + if( rPoly.GetSize() ) { - const MetaLineAction* pA = static_cast<const MetaLineAction *>(pMA); if(pA->GetLineInfo().IsDefault()) { aSrcLineInfo = pA->GetLineInfo(); SetLineAndFillAttr(); - WMFRecord_MoveTo( pA->GetStartPoint() ); - WMFRecord_LineTo( pA->GetEndPoint() ); + WMFRecord_PolyLine( rPoly ); } else { // LineInfo used; handle Dash/Dot and fat lines - basegfx::B2DPolygon aPolygon; - aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); - aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); - HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); } } - break; - - case MetaActionType::RECT: - { - const MetaRectAction* pA = static_cast<const MetaRectAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Rectangle( pA->GetRect() ); - } - break; - - case MetaActionType::ROUNDRECT: - { - const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); - } - break; + } + break; - case MetaActionType::ELLIPSE: - { - const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Ellipse( pA->GetRect() ); - } - break; + case MetaActionType::POLYGON: + { + const MetaPolygonAction* pA = static_cast<const MetaPolygonAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Polygon( pA->GetPolygon() ); + } + break; - case MetaActionType::ARC: - { - const MetaArcAction* pA = static_cast<const MetaArcAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() ); - } - break; + case MetaActionType::POLYPOLYGON: + { + const MetaPolyPolygonAction* pA = static_cast<const MetaPolyPolygonAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_PolyPolygon( pA->GetPolyPolygon() ); + } + break; - case MetaActionType::PIE: - { - const MetaPieAction* pA = static_cast<const MetaPieAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); - } - break; + case MetaActionType::TEXTRECT: + { + const MetaTextRectAction * pA = static_cast<const MetaTextRectAction*>(pMA); + OUString aTemp( pA->GetText() ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + + Point aPos( pA->GetRect().TopLeft() ); + if ( !WMFRecord_Escape_Unicode( aPos, aTemp, nullptr ) ) + WMFRecord_TextOut( aPos, aTemp ); + } + break; - case MetaActionType::CHORD: - { - const MetaChordAction* pA = static_cast<const MetaChordAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); - } - break; + case MetaActionType::TEXT: + { + const MetaTextAction * pA = static_cast<const MetaTextAction*>(pMA); + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, nullptr ) ) + WMFRecord_TextOut( pA->GetPoint(), aTemp ); + } + break; - case MetaActionType::POLYLINE: - { - const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pMA); - const tools::Polygon& rPoly = pA->GetPolygon(); + case MetaActionType::TEXTARRAY: + { + const MetaTextArrayAction* pA = static_cast<const MetaTextArrayAction*>(pMA); - if( rPoly.GetSize() ) - { - if(pA->GetLineInfo().IsDefault()) - { - aSrcLineInfo = pA->GetLineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyLine( rPoly ); - } - else - { - // LineInfo used; handle Dash/Dot and fat lines - HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); - } - } - } - break; + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) ) + WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() ); + } + break; - case MetaActionType::POLYGON: - { - const MetaPolygonAction* pA = static_cast<const MetaPolygonAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Polygon( pA->GetPolygon() ); - } - break; + case MetaActionType::STRETCHTEXT: + { + const MetaStretchTextAction* pA = static_cast<const MetaStretchTextAction *>(pMA); + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - case MetaActionType::POLYPOLYGON: + pVirDev->SetFont( aSrcFont ); + const sal_Int32 nLen = aTemp.getLength(); + std::unique_ptr<long[]> pDXAry(nLen ? new long[ nLen ] : nullptr); + const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, pDXAry.get() ); + if (nLen && nNormSize == 0) { - const MetaPolyPolygonAction* pA = static_cast<const MetaPolyPolygonAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyPolygon( pA->GetPolyPolygon() ); + OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); } - break; - - case MetaActionType::TEXTRECT: + else { - const MetaTextRectAction * pA = static_cast<const MetaTextRectAction*>(pMA); - OUString aTemp( pA->GetText() ); + for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) + pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; + if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) + pDXAry.reset(); aSrcLineInfo = LineInfo(); SetAllAttr(); - - Point aPos( pA->GetRect().TopLeft() ); - if ( !WMFRecord_Escape_Unicode( aPos, aTemp, nullptr ) ) - WMFRecord_TextOut( aPos, aTemp ); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry.get() ) ) + WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry.get() ); } - break; + } + break; - case MetaActionType::TEXT: - { - const MetaTextAction * pA = static_cast<const MetaTextAction*>(pMA); - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, nullptr ) ) - WMFRecord_TextOut( pA->GetPoint(), aTemp ); - } - break; + case MetaActionType::BMP: + { + const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pMA); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); + } + break; - case MetaActionType::TEXTARRAY: - { - const MetaTextArrayAction* pA = static_cast<const MetaTextArrayAction*>(pMA); + case MetaActionType::BMPSCALE: + { + const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pMA); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + } + break; - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) ) - WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() ); - } - break; + case MetaActionType::BMPSCALEPART: + { + const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pMA); + Bitmap aTmp( pA->GetBitmap() ); - case MetaActionType::STRETCHTEXT: - { - const MetaStretchTextAction* pA = static_cast<const MetaStretchTextAction *>(pMA); - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - - pVirDev->SetFont( aSrcFont ); - const sal_Int32 nLen = aTemp.getLength(); - std::unique_ptr<long[]> pDXAry(nLen ? new long[ nLen ] : nullptr); - const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, pDXAry.get() ); - if (nLen && nNormSize == 0) - { - OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); - } - else - { - for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) - pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; - if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) - pDXAry.reset(); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry.get() ) ) - WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry.get() ); - } - } - break; + if( aTmp.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); + } + break; - case MetaActionType::BMP: - { - const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pMA); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); - } - break; + case MetaActionType::BMPEX: + { + const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA); + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - case MetaActionType::BMPSCALE: + if( !!aMsk ) { - const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pMA); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND ); } - break; - - case MetaActionType::BMPSCALEPART: - { - const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pMA); - Bitmap aTmp( pA->GetBitmap() ); + else + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + } + break; - if( aTmp.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); - } - break; + case MetaActionType::BMPEXSCALE: + { + const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA); + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - case MetaActionType::BMPEX: + if( !!aMsk ) { - const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND ); } - break; - - case MetaActionType::BMPEXSCALE: - { - const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + else + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp ); + } + break; - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp ); - } - break; + case MetaActionType::BMPEXSCALEPART: + { + const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA); + BitmapEx aBmpEx( pA->GetBitmapEx() ); + aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + Bitmap aMsk( aBmpEx.GetMask() ); - case MetaActionType::BMPEXSCALEPART: + if( !!aMsk ) { - const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA); - BitmapEx aBmpEx( pA->GetBitmapEx() ); - aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); - Bitmap aBmp( aBmpEx.GetBitmap() ); - Bitmap aMsk( aBmpEx.GetMask() ); - - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND ); } - break; + else + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp ); + } + break; - case MetaActionType::GRADIENT: - { - const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA); - GDIMetaFile aTmpMtf; + case MetaActionType::GRADIENT: + { + const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA); + GDIMetaFile aTmpMtf; - pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); - WriteRecords( aTmpMtf ); - } - break; + pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::HATCH: - { - const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA); - GDIMetaFile aTmpMtf; + case MetaActionType::HATCH: + { + const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA); + GDIMetaFile aTmpMtf; - pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); - WriteRecords( aTmpMtf ); - } - break; + pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::WALLPAPER: - { - const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA); - const Color& rColor = pA->GetWallpaper().GetColor(); - const Color aOldLineColor( aSrcLineColor ); - const Color aOldFillColor( aSrcFillColor ); + case MetaActionType::WALLPAPER: + { + const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA); + const Color& rColor = pA->GetWallpaper().GetColor(); + const Color aOldLineColor( aSrcLineColor ); + const Color aOldFillColor( aSrcFillColor ); + + aSrcLineColor = rColor; + aSrcFillColor = rColor; + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Rectangle( pA->GetRect() ); + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + } + break; - aSrcLineColor = rColor; - aSrcFillColor = rColor; - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Rectangle( pA->GetRect() ); - aSrcLineColor = aOldLineColor; - aSrcFillColor = aOldFillColor; - } - break; + case MetaActionType::ISECTRECTCLIPREGION: + { + const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA); + WMFRecord_IntersectClipRect( pA->GetRect() ); + } + break; - case MetaActionType::ISECTRECTCLIPREGION: - { - const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA); - WMFRecord_IntersectClipRect( pA->GetRect() ); - } - break; + case MetaActionType::LINECOLOR: + { + const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA); - case MetaActionType::LINECOLOR: - { - const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcLineColor = pA->GetColor(); + else + aSrcLineColor = COL_TRANSPARENT; + } + break; - if( pA->IsSetting() ) - aSrcLineColor = pA->GetColor(); - else - aSrcLineColor = COL_TRANSPARENT; - } - break; + case MetaActionType::FILLCOLOR: + { + const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA); - case MetaActionType::FILLCOLOR: - { - const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcFillColor = pA->GetColor(); + else + aSrcFillColor = COL_TRANSPARENT; + } + break; - if( pA->IsSetting() ) - aSrcFillColor = pA->GetColor(); - else - aSrcFillColor = COL_TRANSPARENT; - } - break; + case MetaActionType::TEXTCOLOR: + { + const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA); + aSrcTextColor = pA->GetColor(); + } + break; - case MetaActionType::TEXTCOLOR: - { - const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA); - aSrcTextColor = pA->GetColor(); - } - break; + case MetaActionType::TEXTFILLCOLOR: + { + const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcFont.SetFillColor( pA->GetColor() ); + else + aSrcFont.SetFillColor( COL_TRANSPARENT ); + } + break; - case MetaActionType::TEXTFILLCOLOR: - { - const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA); - if( pA->IsSetting() ) - aSrcFont.SetFillColor( pA->GetColor() ); - else - aSrcFont.SetFillColor( COL_TRANSPARENT ); - } - break; + case MetaActionType::TEXTALIGN: + { + const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA); + eSrcTextAlign = pA->GetTextAlign(); + } + break; - case MetaActionType::TEXTALIGN: - { - const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA); - eSrcTextAlign = pA->GetTextAlign(); - } - break; + case MetaActionType::MAPMODE: + { + const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA); - case MetaActionType::MAPMODE: + if (aSrcMapMode!=pA->GetMapMode()) { - const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA); - - if (aSrcMapMode!=pA->GetMapMode()) + if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative ) { - if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative ) - { - const MapMode& aMM = pA->GetMapMode(); - Fraction aScaleX = aMM.GetScaleX(); - Fraction aScaleY = aMM.GetScaleY(); - - Point aOrigin = aSrcMapMode.GetOrigin(); - BigInt aX( aOrigin.X() ); - aX *= BigInt( aScaleX.GetDenominator() ); - if( aOrigin.X() >= 0 ) - if( aScaleX.GetNumerator() >= 0 ) - aX += BigInt( aScaleX.GetNumerator()/2 ); - else - aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); + const MapMode& aMM = pA->GetMapMode(); + Fraction aScaleX = aMM.GetScaleX(); + Fraction aScaleY = aMM.GetScaleY(); + + Point aOrigin = aSrcMapMode.GetOrigin(); + BigInt aX( aOrigin.X() ); + aX *= BigInt( aScaleX.GetDenominator() ); + if( aOrigin.X() >= 0 ) + if( aScaleX.GetNumerator() >= 0 ) + aX += BigInt( aScaleX.GetNumerator()/2 ); else - if( aScaleX.GetNumerator() >= 0 ) - aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); - else - aX += BigInt( aScaleX.GetNumerator()/2 ); - aX /= BigInt( aScaleX.GetNumerator() ); - aOrigin.setX( static_cast<long>(aX) + aMM.GetOrigin().X() ); - BigInt aY( aOrigin.Y() ); - aY *= BigInt( aScaleY.GetDenominator() ); - if( aOrigin.Y() >= 0 ) - if( aScaleY.GetNumerator() >= 0 ) - aY += BigInt( aScaleY.GetNumerator()/2 ); - else - aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); + aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); + else + if( aScaleX.GetNumerator() >= 0 ) + aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); + else + aX += BigInt( aScaleX.GetNumerator()/2 ); + aX /= BigInt( aScaleX.GetNumerator() ); + aOrigin.setX( static_cast<long>(aX) + aMM.GetOrigin().X() ); + BigInt aY( aOrigin.Y() ); + aY *= BigInt( aScaleY.GetDenominator() ); + if( aOrigin.Y() >= 0 ) + if( aScaleY.GetNumerator() >= 0 ) + aY += BigInt( aScaleY.GetNumerator()/2 ); else - if( aScaleY.GetNumerator() >= 0 ) - aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); - else - aY += BigInt( aScaleY.GetNumerator()/2 ); - aY /= BigInt( aScaleY.GetNumerator() ); - aOrigin.setY( static_cast<long>(aY) + aMM.GetOrigin().Y() ); - aSrcMapMode.SetOrigin( aOrigin ); - - aScaleX *= aSrcMapMode.GetScaleX(); - aScaleY *= aSrcMapMode.GetScaleY(); - aSrcMapMode.SetScaleX( aScaleX ); - aSrcMapMode.SetScaleY( aScaleY ); - } + aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); else - aSrcMapMode=pA->GetMapMode(); + if( aScaleY.GetNumerator() >= 0 ) + aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); + else + aY += BigInt( aScaleY.GetNumerator()/2 ); + aY /= BigInt( aScaleY.GetNumerator() ); + aOrigin.setY( static_cast<long>(aY) + aMM.GetOrigin().Y() ); + aSrcMapMode.SetOrigin( aOrigin ); + + aScaleX *= aSrcMapMode.GetScaleX(); + aScaleY *= aSrcMapMode.GetScaleY(); + aSrcMapMode.SetScaleX( aScaleX ); + aSrcMapMode.SetScaleY( aScaleY ); } + else + aSrcMapMode=pA->GetMapMode(); } - break; + } + break; - case MetaActionType::FONT: - { - const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA); - aSrcFont = pA->GetFont(); + case MetaActionType::FONT: + { + const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA); + aSrcFont = pA->GetFont(); - if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW) - || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) ) - { - aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); - } - eSrcTextAlign = aSrcFont.GetAlignment(); - aSrcTextColor = aSrcFont.GetColor(); - aSrcFont.SetAlignment( ALIGN_BASELINE ); - aSrcFont.SetColor( COL_WHITE ); + if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW) + || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) ) + { + aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); } - break; + eSrcTextAlign = aSrcFont.GetAlignment(); + aSrcTextColor = aSrcFont.GetColor(); + aSrcFont.SetAlignment( ALIGN_BASELINE ); + aSrcFont.SetColor( COL_WHITE ); + } + break; - case MetaActionType::PUSH: - { - const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA); - - WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember; - pAt->nFlags = pA->GetFlags(); - pAt->aClipRegion = aSrcClipRegion; - pAt->aLineColor=aSrcLineColor; - pAt->aFillColor=aSrcFillColor; - pAt->eRasterOp=eSrcRasterOp; - pAt->aFont=aSrcFont; - pAt->eTextAlign=eSrcTextAlign; - pAt->aTextColor=aSrcTextColor; - pAt->aMapMode=aSrcMapMode; - pAt->aLineInfo=aDstLineInfo; - pAt->pSucc=pAttrStack; - pAttrStack=pAt; - - SetAllAttr(); // update ( now all source attributes are equal to the destination attributes ) - WMFRecord_SaveDC(); + case MetaActionType::PUSH: + { + const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA); + + WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember; + pAt->nFlags = pA->GetFlags(); + pAt->aClipRegion = aSrcClipRegion; + pAt->aLineColor=aSrcLineColor; + pAt->aFillColor=aSrcFillColor; + pAt->eRasterOp=eSrcRasterOp; + pAt->aFont=aSrcFont; + pAt->eTextAlign=eSrcTextAlign; + pAt->aTextColor=aSrcTextColor; + pAt->aMapMode=aSrcMapMode; + pAt->aLineInfo=aDstLineInfo; + pAt->pSucc=pAttrStack; + pAttrStack=pAt; + + SetAllAttr(); // update ( now all source attributes are equal to the destination attributes ) + WMFRecord_SaveDC(); - } - break; + } + break; - case MetaActionType::POP: - { - WMFWriterAttrStackMember * pAt=pAttrStack; + case MetaActionType::POP: + { + WMFWriterAttrStackMember * pAt=pAttrStack; - if( pAt ) - { - aDstLineInfo = pAt->aLineInfo; - aDstLineColor = pAt->aLineColor; - if ( pAt->nFlags & PushFlags::LINECOLOR ) - aSrcLineColor = pAt->aLineColor; - aDstFillColor = pAt->aFillColor; - if ( pAt->nFlags & PushFlags::FILLCOLOR ) - aSrcFillColor = pAt->aFillColor; - eDstROP2 = pAt->eRasterOp; - if ( pAt->nFlags & PushFlags::RASTEROP ) - eSrcRasterOp = pAt->eRasterOp; - aDstFont = pAt->aFont; - if ( pAt->nFlags & PushFlags::FONT ) - aSrcFont = pAt->aFont; - eDstTextAlign = pAt->eTextAlign; - if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTALIGN ) ) - eSrcTextAlign = pAt->eTextAlign; - aDstTextColor = pAt->aTextColor; - if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTCOLOR ) ) - aSrcTextColor = pAt->aTextColor; - if ( pAt->nFlags & PushFlags::MAPMODE ) - aSrcMapMode = pAt->aMapMode; - aDstClipRegion = pAt->aClipRegion; - if ( pAt->nFlags & PushFlags::CLIPREGION ) - aSrcClipRegion = pAt->aClipRegion; - - WMFRecord_RestoreDC(); - pAttrStack = pAt->pSucc; - delete pAt; - } + if( pAt ) + { + aDstLineInfo = pAt->aLineInfo; + aDstLineColor = pAt->aLineColor; + if ( pAt->nFlags & PushFlags::LINECOLOR ) + aSrcLineColor = pAt->aLineColor; + aDstFillColor = pAt->aFillColor; + if ( pAt->nFlags & PushFlags::FILLCOLOR ) + aSrcFillColor = pAt->aFillColor; + eDstROP2 = pAt->eRasterOp; + if ( pAt->nFlags & PushFlags::RASTEROP ) + eSrcRasterOp = pAt->eRasterOp; + aDstFont = pAt->aFont; + if ( pAt->nFlags & PushFlags::FONT ) + aSrcFont = pAt->aFont; + eDstTextAlign = pAt->eTextAlign; + if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTALIGN ) ) + eSrcTextAlign = pAt->eTextAlign; + aDstTextColor = pAt->aTextColor; + if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTCOLOR ) ) + aSrcTextColor = pAt->aTextColor; + if ( pAt->nFlags & PushFlags::MAPMODE ) + aSrcMapMode = pAt->aMapMode; + aDstClipRegion = pAt->aClipRegion; + if ( pAt->nFlags & PushFlags::CLIPREGION ) + aSrcClipRegion = pAt->aClipRegion; + + WMFRecord_RestoreDC(); + pAttrStack = pAt->pSucc; + delete pAt; } - break; + } + break; - case MetaActionType::EPS : - { - const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA); - const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() ); + case MetaActionType::EPS : + { + const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA); + const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() ); - size_t nCount = aGDIMetaFile.GetActionSize(); - for ( size_t i = 0; i < nCount; i++ ) + size_t nCount = aGDIMetaFile.GetActionSize(); + for ( size_t i = 0; i < nCount; i++ ) + { + const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i ); + if ( pMetaAct->GetType() == MetaActionType::BMPSCALE ) { - const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i ); - if ( pMetaAct->GetType() == MetaActionType::BMPSCALE ) - { - const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); - break; - } + const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); + break; } } - break; + } + break; - case MetaActionType::RASTEROP: - { - const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA); - eSrcRasterOp=pA->GetRasterOp(); - } - break; + case MetaActionType::RASTEROP: + { + const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA); + eSrcRasterOp=pA->GetRasterOp(); + } + break; - case MetaActionType::Transparent: - { - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() ); - } - break; + case MetaActionType::Transparent: + { + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() ); + } + break; - case MetaActionType::FLOATTRANSPARENT: - { - const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA); + case MetaActionType::FLOATTRANSPARENT: + { + const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA); - GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); - Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); - const Size aSrcSize( aTmpMtf.GetPrefSize() ); - const Point aDestPt( pA->GetPoint() ); - const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; - long nMoveX, nMoveY; + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); + Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); + const Size aSrcSize( aTmpMtf.GetPrefSize() ); + const Point aDestPt( pA->GetPoint() ); + const Size aDestSize( pA->GetSize() ); + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; + long nMoveX, nMoveY; - aSrcLineInfo = LineInfo(); - SetAllAttr(); + aSrcLineInfo = LineInfo(); + SetAllAttr(); - if( fScaleX != 1.0 || fScaleY != 1.0 ) - { - aTmpMtf.Scale( fScaleX, fScaleY ); - aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) ); - aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) ); - } + if( fScaleX != 1.0 || fScaleY != 1.0 ) + { + aTmpMtf.Scale( fScaleX, fScaleY ); + aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) ); + aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) ); + } - nMoveX = aDestPt.X() - aSrcPt.X(); - nMoveY = aDestPt.Y() - aSrcPt.Y(); + nMoveX = aDestPt.X() - aSrcPt.X(); + nMoveY = aDestPt.Y() - aSrcPt.Y(); - if( nMoveX || nMoveY ) - aTmpMtf.Move( nMoveX, nMoveY ); + if( nMoveX || nMoveY ) + aTmpMtf.Move( nMoveX, nMoveY ); - WriteRecords( aTmpMtf ); - } - break; + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::LAYOUTMODE: + case MetaActionType::LAYOUTMODE: + { + ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode(); + eSrcHorTextAlign = 0; // TA_LEFT + if ((nLayoutMode & ComplexTextLayoutFlags::BiDiRtl) != ComplexTextLayoutFlags::Default) { - ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode(); - eSrcHorTextAlign = 0; // TA_LEFT - if ((nLayoutMode & ComplexTextLayoutFlags::BiDiRtl) != ComplexTextLayoutFlags::Default) - { - eSrcHorTextAlign = W_TA_RIGHT | W_TA_RTLREADING; - } - if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginRight) != ComplexTextLayoutFlags::Default) - eSrcHorTextAlign |= W_TA_RIGHT; - else if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginLeft) != ComplexTextLayoutFlags::Default) - eSrcHorTextAlign &= ~W_TA_RIGHT; - break; + eSrcHorTextAlign = W_TA_RIGHT | W_TA_RTLREADING; } - - case MetaActionType::CLIPREGION: - case MetaActionType::TEXTLANGUAGE: - case MetaActionType::COMMENT: - // Explicitly ignored cases - break; - - default: - // TODO: Implement more cases as necessary. Let's not bother with a warning. + if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginRight) != ComplexTextLayoutFlags::Default) + eSrcHorTextAlign |= W_TA_RIGHT; + else if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginLeft) != ComplexTextLayoutFlags::Default) + eSrcHorTextAlign &= ~W_TA_RIGHT; break; } - nWrittenActions++; - MayCallback(); - - if (pWMF->GetError()) - bStatus=false; + case MetaActionType::CLIPREGION: + case MetaActionType::TEXTLANGUAGE: + case MetaActionType::COMMENT: + // Explicitly ignored cases + break; - if(!bStatus) - break; + default: + // TODO: Implement more cases as necessary. Let's not bother with a warning. + break; } + + nWrittenActions++; + MayCallback(); + + if (pWMF->GetError()) + bStatus=false; + + if(!bStatus) + break; } } |