40 #include <com/sun/star/beans/PropertyValue.hpp>
41 #include <com/sun/star/io/XSeekable.hpp>
42 #include <com/sun/star/graphic/GraphicProvider.hpp>
43 #include <com/sun/star/graphic/XGraphicProvider.hpp>
44 #include <com/sun/star/beans/XMaterialHolder.hpp>
69 playMetafile( aTmpMtf,
nullptr, i_rContext, i_pDummyVDev );
80 Point aPoint( i_rPoint );
81 Size aSize( i_rSize );
87 if( aSize.
Width() < 0 )
90 aPoint.AdjustX( -(aSize.
Width()) );
96 aPoint.AdjustY( -(aSize.
Height()) );
102 aBitmapEx.
Mirror( nMirrorFlags );
105 bool bIsJpeg =
false, bIsPng =
false;
116 && aBmpSize.getHeight() > 50)
120 const double fBmpPixelX = aBmpSize.Width();
121 const double fBmpPixelY = aBmpSize.Height();
122 const double fMaxPixelX
125 const double fMaxPixelY
130 if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) ||
131 ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) &&
132 ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) )
136 const double fBmpWH = fBmpPixelX / fBmpPixelY;
137 const double fMaxWH = fMaxPixelX / fMaxPixelY;
139 if( fBmpWH < fMaxWH )
144 else if( fBmpWH > 0.0 )
163 if ( !(aSizePixel.Width() && aSizePixel.Height()) )
173 if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
174 bUseJPGCompression =
false;
176 auto pStrm=std::make_shared<SvMemoryStream>();
179 bool bTrueColorJPG =
true;
180 if ( bUseJPGCompression )
186 const auto& rCacheEntry=m_aPDFBmpCache.find(
188 if ( rCacheEntry != m_aPDFBmpCache.end() )
190 m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second,
true, aSizePixel,
195 sal_uInt32 nZippedFileSize = 0;
202 nZippedFileSize = aTemp.
TellEnd();
216 uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW );
218 uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) );
219 uno::Reference< graphic::XGraphic > xGraphic( aGraphic.
GetXGraphic() );
220 uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() );
221 uno::Sequence< beans::PropertyValue > aOutMediaProperties{
226 xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties );
228 if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize )
230 bUseJPGCompression =
false;
236 xSeekable->seek( 0 );
239 uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) );
242 sal_Int16 nBitsPerPixel = 24;
243 if ( xPropSet->getPropertyValue(
"BitsPerPixel") >>= nBitsPerPixel )
245 bTrueColorJPG = nBitsPerPixel != 8;
250 catch( uno::Exception& )
252 bUseJPGCompression =
false;
255 if ( bUseJPGCompression )
257 m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel,
tools::Rectangle( aPoint, aSize ), aAlphaMask, i_Graphic );
258 if (!aBitmapEx.
IsAlpha() && bTrueColorJPG)
261 m_aPDFBmpCache.insert(
265 else if ( aBitmapEx.
IsAlpha() )
266 m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
268 m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.
GetBitmap(), i_Graphic );
274 bool bAssertionFired(
false );
280 pDummyVDev = xPrivateDevice.
get();
288 if ( !i_pOutDevData || !i_pOutDevData->
PlaySyncPageAct( m_rOuterFace,
i, aMtf ) )
305 m_rOuterFace.DrawPixel( pA->
GetPoint() );
322 m_rOuterFace.DrawRect( pA->
GetRect() );
336 m_rOuterFace.DrawEllipse( pA->
GetRect() );
372 m_rOuterFace.DrawPolyLine( pA->
GetPolygon() );
391 m_rOuterFace.DrawGradient( pA->
GetRect(), rGradient );
396 implWriteGradient( aPolyPoly, rGradient, pDummyVDev, i_rContext );
409 implWriteGradient( pA->
GetPolyPolygon(), rGradient, pDummyVDev, i_rContext );
440 const sal_uInt16 nTransPercent = aTransCol.
GetLuminance() * 100 / 255;
441 m_rOuterFace.BeginTransparencyGroup();
444 Point aMtfOrigin(aTmpMtf.GetPrefMapMode().GetOrigin());
445 if (rPos != aMtfOrigin)
446 aTmpMtf.Move(rPos.X() - aMtfOrigin.X(), rPos.Y() - aMtfOrigin.Y());
448 playMetafile( aTmpMtf,
nullptr, i_rContext, pDummyVDev );
449 m_rOuterFace.EndTransparencyGroup(
tools::Rectangle( rPos, rSize ), nTransPercent );
457 sal_Int32 nMaxBmpDPI(300);
466 if ( nPixelX && nPixelY )
468 Size aDstSizePixel( nPixelX, nPixelY );
470 if( xVDev->SetOutputSizePixel( aDstSizePixel ) )
478 xVDev->SetMapMode( aMapMode );
479 Size aDstSize( xVDev->PixelToLogic( aDstSizePixel ) );
481 Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() );
482 if ( aMtfOrigin.X() || aMtfOrigin.Y() )
483 aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() );
484 double fScaleX =
static_cast<double>(aDstSize.Width()) / static_cast<double>(aTmpMtf.GetPrefSize().Width());
485 double fScaleY =
static_cast<double>(aDstSize.Height()) / static_cast<double>(aTmpMtf.GetPrefSize().Height());
486 if( fScaleX != 1.0 || fScaleY != 1.0 )
487 aTmpMtf.Scale( fScaleX, fScaleY );
488 aTmpMtf.SetPrefMapMode( aMapMode );
492 aTmpMtf.Play(*xVDev, aPoint, aDstSize);
495 xVDev->EnableMapMode(
false );
496 aPaint = xVDev->GetBitmap( aPoint, aDstSizePixel );
497 xVDev->EnableMapMode();
506 aTmpMtf.Play(*xVDev, aPoint, aDstSize);
508 xVDev->EnableMapMode(
false );
509 aMask = xVDev->GetBitmap( aPoint, aDstSizePixel );
510 xVDev->EnableMapMode();
514 xVDev->DrawGradient(
tools::Rectangle( aPoint, aDstSize ), rTransparenceGradient );
516 xVDev->EnableMapMode(
false );
517 xVDev->DrawMask( aPoint, aDstSizePixel, aMask,
COL_WHITE );
518 aAlpha = xVDev->GetBitmap( aPoint, aDstSizePixel );
521 implWriteBitmapEx( rPos, rSize,
BitmapEx( aPaint, aAlpha ), aGraphic, pDummyVDev, i_rContext );
536 MapMode aMapMode( aSubstitute.GetPrefMapMode() );
538 aMapMode.SetScaleX(
Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
539 aMapMode.SetScaleY(
Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
542 m_rOuterFace.SetMapMode( aMapMode );
544 playMetafile( aSubstitute,
nullptr, i_rContext, pDummyVDev );
555 if( pA->
GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_BEGIN"))
560 while( !bDone && ( ++
i < nCount ) )
565 pGradAction = static_cast<const MetaGradientExAction*>(pAction);
567 ( static_cast<const MetaCommentAction*>(pAction)->GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_END")) )
591 bool bSkipSequence =
false;
594 if( pA->
GetComment() ==
"XPATHSTROKE_SEQ_BEGIN" )
596 sSeqEnd = OString(
"XPATHSTROKE_SEQ_END");
613 bSkipSequence =
true;
614 if ( aStartArrow.
Count() || aEndArrow.
Count() )
615 bSkipSequence =
false;
616 if ( !aDashArray.empty() && ( fStrokeWidth != 0.0 ) && ( fTransparency == 0.0 ) )
617 bSkipSequence =
false;
645 && fStrokeWidth > 0.0)
648 const sal_uInt16 nPoints(aPath.
GetSize());
649 const bool bCurve(aPath.
HasFlags());
651 for(sal_uInt16
a(0);
a + 1 < nPoints;
a++)
654 && PolyFlags::Normal != aPath.
GetFlags(
a + 1)
656 && PolyFlags::Normal != aPath.
GetFlags(
a + 2)
662 m_rOuterFace.DrawPolyLine( aSnippet, aInfo );
669 m_rOuterFace.DrawPolyLine( aSnippet, aInfo );
675 m_rOuterFace.DrawPolyLine( aPath, aInfo );
679 else if ( pA->
GetComment() ==
"XPATHFILL_SEQ_BEGIN" )
681 sSeqEnd = OString(
"XPATHFILL_SEQ_END");
688 if ( fTransparency == 0.0 )
693 bSkipSequence =
true;
694 m_rOuterFace.DrawPolyPolygon( aPath );
696 else if ( fTransparency == 1.0 )
697 bSkipSequence =
true;
702 while( ++
i < nCount )
707 OString sComment( static_cast<const MetaCommentAction*>(pAction)->GetComment() );
708 if (sComment == sSeqEnd)
719 m_rOuterFace.SetFillColor( pMA->
GetColor() );
721 m_rOuterFace.SetFillColor();
735 aBitmapEx.GetPrefMapMode(), pDummyVDev->
GetMapMode() ) );
736 if( ! ( aSize.Width() && aSize.Height() ) )
737 aSize = pDummyVDev->
PixelToLogic( aBitmapEx.GetSizePixel() );
740 implWriteBitmapEx( pA->
GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
754 const MetaBmpScalePartAction* pA =
static_cast<const MetaBmpScalePartAction*
>(pAction);
755 BitmapEx aBitmapEx( pA->GetBitmap() );
758 implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
767 aBitmapEx.GetPrefMapMode(), pDummyVDev->
GetMapMode() ) );
769 implWriteBitmapEx( pA->
GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
783 const MetaBmpExScalePartAction* pA =
static_cast<const MetaBmpExScalePartAction*
>(pAction);
784 BitmapEx aBitmapEx( pA->GetBitmapEx() );
787 implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
795 SAL_WARN(
"vcl",
"MetaMask...Action not supported yet" );
815 const MetaTextArrayAction* pA =
static_cast<const MetaTextArrayAction*
>(pAction);
816 m_rOuterFace.DrawTextArray( pA->GetPoint(), pA->GetText(), pA->GetDXArray(), pA->GetIndex(), pA->GetLen() );
846 m_rOuterFace.SetClipRegion( aReg.GetAsB2DPolyPolygon() );
850 m_rOuterFace.SetClipRegion();
857 m_rOuterFace.IntersectClipRegion( pA->
GetRect() );
865 m_rOuterFace.IntersectClipRegion( aReg.GetAsB2DPolyPolygon() );
879 m_rOuterFace.SetMapMode( pDummyVDev->
GetMapMode() );
888 m_rOuterFace.SetLineColor( pA->
GetColor() );
890 m_rOuterFace.SetLineColor();
899 m_rOuterFace.SetFillColor( pA->
GetColor() );
901 m_rOuterFace.SetFillColor();
910 m_rOuterFace.SetTextLineColor( pA->
GetColor() );
912 m_rOuterFace.SetTextLineColor();
921 m_rOuterFace.SetOverlineColor( pA->
GetColor() );
923 m_rOuterFace.SetOverlineColor();
932 m_rOuterFace.SetTextFillColor( pA->
GetColor() );
934 m_rOuterFace.SetTextFillColor();
941 m_rOuterFace.SetTextColor( pA->
GetColor() );
964 m_rOuterFace.Push( pA->
GetFlags() );
991 const MetaWallpaperAction* pA =
static_cast<const MetaWallpaperAction*
>(pAction);
992 m_rOuterFace.DrawWallpaper( pA->GetRect(), pA->GetWallpaper() );
1012 if( !bAssertionFired )
1014 bAssertionFired =
true;
1015 SAL_WARN(
"vcl",
"PDFExport::ImplWriteActions: deprecated and unsupported MetaAction encountered " << static_cast<int>(nType) );
1044 maID =
reinterpret_cast< sal_IntPtr
>(
this);
1045 while( sTransporters.find( maID ) != sTransporters.end() )
1047 sTransporters[ maID ] =
this;
1052 sTransporters.erase( maID );
1053 SAL_INFO(
"vcl",
"EncHashTransporter freed" );
1066 return uno::Any( sal_Int64(maID) );
1069 static EncHashTransporter* getEncHashTransporter(
const uno::Reference< beans::XMaterialHolder >& );
1080 uno::Any aMat( xRef->getMaterial() );
1084 std::map< sal_IntPtr, EncHashTransporter* >::iterator it = sTransporters.find( static_cast<sal_IntPtr>(nMat) );
1085 if( it != sTransporters.end() )
1086 pResult = it->second;
1097 m_bEncryptThisStream =
true;
1098 sal_Int32
i = m_nKeyLength;
1105 m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5));
1109 rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength,
nullptr, 0 );
1117 sal_Int32
i = m_nKeyLength;
1125 m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5));
1128 rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength,
nullptr, 0 );
1136 const OUString& i_rUserPassword
1139 uno::Reference< beans::XMaterialHolder > xResult;
1140 if( !i_rOwnerPassword.isEmpty() || !i_rUserPassword.isEmpty() )
1143 xResult = pTransporter;
1147 padPassword( i_rOwnerPassword.isEmpty() ? i_rUserPassword : i_rOwnerPassword, aPadOPW );
1148 padPassword( i_rUserPassword, aPadUPW );
1150 if( computeODictionaryValue( aPadOPW, aPadUPW, pTransporter->getOValue(),
SECUR_128BIT_KEY ) )
1158 rtl_secureZeroMemory (aPadOPW,
sizeof(aPadOPW));
1159 rtl_secureZeroMemory (aPadUPW,
sizeof(aPadUPW));
1166 bool bSuccess =
false;
1170 sal_Int32 nKeyLength = 0, nRC4KeyLength = 0;
1171 sal_Int32 nAccessPermissions = computeAccessPermissions(
m_aContext.Encryption, nKeyLength, nRC4KeyLength );
1173 bSuccess = computeUDictionaryValue( pTransporter,
m_aContext.Encryption, nKeyLength, nAccessPermissions );
1185 sal_Int32& o_rKeyLength, sal_Int32& o_rRC4KeyLength )
1194 sal_Int32 nAccessPermissions = 0xfffff0c0;
1197 o_rRC4KeyLength = 16;
1203 nAccessPermissions |= ( i_rProperties.
CanAddOrModify ) ? 1 << 5 : 0;
1206 nAccessPermissions |= ( i_rProperties.
CanAssemble ) ? 1 << 10 : 0;
1207 nAccessPermissions |= ( i_rProperties.
CanPrintFull ) ? 1 << 11 : 0;
1208 return nAccessPermissions;
1223 sal_Int32 nCurrentChar;
1225 for( nCurrentChar = 0; nCurrentChar < nToCopy; nCurrentChar++ )
1226 o_pPaddedPW[nCurrentChar] = static_cast<sal_uInt8>( aString[nCurrentChar] );
1231 o_pPaddedPW[i] = s_nPadString[y];
1246 bool bSuccess =
true;
1247 ::std::vector<unsigned char> nMD5Sum;
1254 if( ! io_rProperties.
OValue.empty() )
1261 nPerm[0] =
static_cast<sal_uInt8>(i_nAccessPermissions);
1262 nPerm[1] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 8 );
1263 nPerm[2] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 16 );
1264 nPerm[3] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 24 );
1266 pDigest->
update(nPerm,
sizeof(nPerm));
1274 for (sal_Int32
i = 0;
i < 50;
i++)
1303 std::vector< sal_uInt8 >& io_rOValue,
1304 sal_Int32 i_nKeyLength
1307 bool bSuccess =
true;
1311 rtlCipher aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1323 for (i = 0; i < 50; i++)
1331 if (rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1332 nMD5Sum.data(), i_nKeyLength ,
nullptr, 0 )
1333 == rtl_Cipher_E_None)
1337 io_rOValue.data(), sal_Int32(io_rOValue.size()) );
1345 for( i = 1; i <= 19; i++ )
1347 for( y = 0; y <
sizeof( nLocalKey ); y++ )
1348 nLocalKey[y] = static_cast<sal_uInt8>( nMD5Sum[y] ^ i );
1350 if (rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1352 != rtl_Cipher_E_None)
1357 rtl_cipher_encodeARCFOUR( aCipher, io_rOValue.data(), sal_Int32(io_rOValue.size()),
1358 io_rOValue.data(), sal_Int32(io_rOValue.size()) );
1370 rtl_cipher_destroyARCFOUR( aCipher );
1382 sal_Int32 i_nKeyLength,
1383 sal_Int32 i_nAccessPermissions
1386 bool bSuccess =
true;
1391 rtlCipher aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1395 if( computeEncryptionKey( i_pTransporter, io_rProperties, i_nAccessPermissions ) )
1398 for( sal_Int32
i = i_nKeyLength,
y = 0;
y < 5 ;
y++ )
1406 aDigest.
update(s_nPadString,
sizeof(s_nPadString));
1409 ::std::vector<unsigned char>
const nMD5Sum(aDigest.
finalize());
1411 rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1413 rtl_cipher_encodeARCFOUR( aCipher, nMD5Sum.data(), nMD5Sum.size(),
1420 for( i = 1; i <= 19; i++ )
1422 for( y = 0; y <
sizeof( nLocalKey ) ; y++ )
1423 nLocalKey[y] = static_cast<sal_uInt8>( io_rProperties.
EncryptionKey[y] ^ i );
1425 rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1439 rtl_cipher_destroyARCFOUR( aCipher );
1442 io_rProperties.
UValue.clear();
1450 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
1451 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1454 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1455 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1456 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1458 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1461 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1463 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1464 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1465 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1470 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1471 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1472 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1473 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1478 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1479 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1480 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1481 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1484 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1485 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8,
1490 return (i_pLine[ i_nIndex/8 ] & (0x80 >> (i_nIndex&7))) != 0;
1498 const sal_uInt8 * pByte = i_pLine + (nIndex/8);
1506 while( nBitInByte != 8 )
1508 if( (nByte & nMask) != (i_bSet ? nMask : 0) )
1509 return std::min(nIndex, i_nW);
1536 while( nByte == nRunByte )
1550 nIndex += pRunTable[nByte];
1553 return std::min(nIndex, i_nW);
1558 if (i_nStartIndex < 0)
1566 if (i_nStartIndex < 0)
1569 const bool bSet = i_nStartIndex < i_nW &&
isSet(i_pLine, i_nStartIndex);
1586 void flush() { mnNextBitPos = 8; mnBuffer = 0; }
1595 writeBuffer( &io_rState.
getByte(), 1 );
1598 assert(i_nLength < 9);
1599 static const unsigned int msbmask[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
1604 writeBuffer( &io_rState.
getByte(), 1 );
1613 sal_uInt32 mnEncodedPixels;
1614 sal_uInt32 mnCodeBits;
1838 const PixelCode* pTable = i_bWhitePixel ? WhitePixelCodes :
BlackPixelCodes;
1840 while( i_nSpan > 2623 )
1843 putG4Bits( pTable[103].mnCodeBits, pTable[103].mnCode, io_rState );
1844 i_nSpan -= pTable[103].mnEncodedPixels;
1849 sal_uInt32 nTabIndex = 63 + (i_nSpan >> 6);
1850 OSL_ASSERT( pTable[nTabIndex].mnEncodedPixels == static_cast<sal_uInt32>(64*(i_nSpan >> 6)) );
1851 putG4Bits( pTable[nTabIndex].mnCodeBits, pTable[nTabIndex].mnCode, io_rState );
1852 i_nSpan -= pTable[nTabIndex].mnEncodedPixels;
1854 putG4Bits( pTable[i_nSpan].mnCodeBits, pTable[i_nSpan].mnCode, io_rState );
1861 if( nW <= 0 || nH <= 0 )
1869 std::unique_ptr<sal_uInt8[]> pFirstRefLine(
new sal_uInt8[nW/8 + 1]);
1870 memset(pFirstRefLine.get(), 0, nW/8 + 1);
1871 Scanline pRefLine = pFirstRefLine.get();
1876 bool bRunSet = (*pCurLine & 0x80) != 0;
1877 bool bRefSet = (*pRefLine & 0x80) != 0;
1880 for( ; nLineIndex < nW; )
1883 if( nRefIndex2 >= nRunIndex1 )
1886 if( -3 <= nDiff && nDiff <= 3 )
1890 sal_uInt32 mnCodeBits;
1892 } VerticalCodes[7] = {
1905 putG4Bits( VerticalCodes[nDiff].mnCodeBits, VerticalCodes[nDiff].mnCode, aBitState );
1906 nLineIndex = nRunIndex1;
1911 putG4Bits( 3, 0x1, aBitState );
1913 bool bWhiteFirst = ( nLineIndex + nRunIndex1 == 0 || !
isSet( pCurLine, nLineIndex ) );
1914 putG4Span( nRunIndex1 - nLineIndex, bWhiteFirst, aBitState );
1915 putG4Span( nRunIndex2 - nRunIndex1, ! bWhiteFirst, aBitState );
1916 nLineIndex = nRunIndex2;
1921 putG4Bits( 4, 0x1, aBitState );
1922 nLineIndex = nRefIndex2;
1924 if( nLineIndex < nW )
1926 bool bSet =
isSet( pCurLine, nLineIndex );
1927 nRunIndex1 =
findBitRun( pCurLine, nLineIndex, nW, bSet );
1928 nRefIndex1 =
findBitRun( pRefLine, nLineIndex, nW, ! bSet );
1929 nRefIndex1 =
findBitRun( pRefLine, nRefIndex1, nW, bSet );
1934 pRefLine = pCurLine;
1937 putG4Bits( 12, 1, aBitState );
1938 putG4Bits( 12, 1, aBitState );
1941 writeBuffer( &aBitState.
getByte(), 1 );
1954 case GradientStyle::Linear:
1955 case GradientStyle::Axial:
1968 if (bNewFontLists && AcquireGraphics())
1970 ReleaseFontCollection();
1977 if (bNewFontLists && AcquireGraphics())
1979 SetFontCollectionFromSVData();
1980 ResetNewFontCache();
void EnableOutput(bool bEnable=true)
constexpr sal_Int32 SECUR_128BIT_KEY
void writeG4Stream(BitmapReadAccess const *i_pBitmap)
DrawTextFlags GetStyle() const
static bool isSet(const Scanline i_pLine, tools::Long i_nIndex)
tools::Long Height() const
::std::unique_ptr<::comphelper::Hash > m_pDigest
GradientStyle GetStyle() const
LanguageType GetTextLanguage() const
void implWriteBitmapEx(const Point &rPoint, const Size &rSize, const BitmapEx &rBitmapEx, const Graphic &i_pGraphic, VirtualDevice const *pDummyVDev, const vcl::PDFWriter::PlayMetafileContext &)
void setWidth(tools::Long nWidth)
void implWriteGradient(const tools::PolyPolygon &rPolyPoly, const Gradient &rGradient, VirtualDevice *pDummyVDev, const vcl::PDFWriter::PlayMetafileContext &)
static void padPassword(std::u16string_view i_rPassword, sal_uInt8 *o_pPaddedPW)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
bool PlaySyncPageAct(PDFWriter &rWriter, sal_uInt32 &rCurGDIMtfAction, const GDIMetaFile &rMtf)
static bool computeUDictionaryValue(EncHashTransporter *i_pTransporter, vcl::PDFWriter::PDFEncryptionProperties &io_rProperties, sal_Int32 i_nKeyLength, sal_Int32 i_nAccessPermissions)
std::unique_ptr< sal_Int32[]> pData
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
static EncHashTransporter * getEncHashTransporter(const uno::Reference< beans::XMaterialHolder > &)
static tools::Long findBitRun(const Scanline i_pLine, tools::Long i_nStartIndex, tools::Long i_nW, bool i_bSet)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
sal_uInt8 GetLuminance() const
Connect segments by a filled round arc.
Encapsulates geometry and associated attributes of a graphical 'pen stroke'.
bool CanExtractForAccessibility
vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override
Perform actual rect clip against outdev dimensions, to generate empty clips whenever one of the value...
sal_uInt16 GetBitCount() const
#define STREAM_SEEK_TO_END
const MapMode & GetMapMode() const
const tools::Long unsetRun[256]
const PixelCode WhitePixelCodes[]
const OUString & GetText() const
bool m_bTransparenciesWereRemoved
GfxLinkType
GfxLink graphic types that are supported by GfxLink.
SvStreamCompressFlags GetCompressMode() const
static bool computeODictionaryValue(const sal_uInt8 *i_pPaddedOwnerPassword, const sal_uInt8 *i_pPaddedUserPassword, std::vector< sal_uInt8 > &io_rOValue, sal_Int32 i_nKeyLength)
bool Convert(BmpConversion eConversion)
Convert bitmap format.
BitmapChecksum GetChecksum() const
CapType getCapType() const
Get the style in which open stroke ends are drawn.
virtual sal_uInt64 TellEnd() override
constexpr tools::Long Width() const
void disposeAndReset(reference_type *pBody)
Assignment that releases the last reference.
virtual uno::Any SAL_CALL getMaterial() override
Play a metafile like an outputdevice would do.
static tools::Long findBitRunImpl(const Scanline i_pLine, tools::Long i_nStartIndex, tools::Long i_nW, bool i_bSet)
const OUString & GetText() const
constexpr sal_Int32 MAXIMUM_RC4_KEY_LENGTH
Scanline GetScanline(tools::Long nY) const
Fill with a specified solid color.
bool prepareEncryption(const css::uno::Reference< css::beans::XMaterialHolder > &)
double getTransparency() const
Get stroke transparency.
double getMiterLimit() const
Get the maximum length of mitered joins.
static bool computeEncryptionKey(EncHashTransporter *, vcl::PDFWriter::PDFEncryptionProperties &io_rProperties, sal_Int32 i_nAccessPermissions)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::vector< sal_uInt8 > DocumentIdentifier
FontLineStyle GetUnderline() const
static sal_Int32 computeAccessPermissions(const vcl::PDFWriter::PDFEncryptionProperties &i_rProperties, sal_Int32 &o_rKeyLength, sal_Int32 &o_rRC4KeyLength)
void ImplClearFontData(bool bNewFontLists) override
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
std::vector< sal_uInt8 > maOValue
vcl::PixelFormat getPixelFormat() const
int m_nMaxImageResolution
Half-square cap at the line end, the center lying at the end point.
tools::Long GetWidth() const
GraphicType GetType() const
const Point & GetPoint() const
tools::Long FRound(double fVal)
void drawLine(VirtualDevice *dev, Point const &orig, Point const &dest, Size const &pSize)
draws a line from orig to dest knowing penSize
Perform no join, leads to visible gaps between thick line segments.
const Color & GetColor() const
void SetOrigin(const Point &rOrigin)
sal_uInt32 GetWidth() const
void AddGradientActions(tools::Rectangle const &rRect, GDIMetaFile &rMetaFile)
tools::Long Width() const
bool m_bOnlyLosslessCompression
const OUString & GetText() const
void getPath(tools::Polygon &) const
Query path to stroke.
std::vector< sal_uInt8 > EncryptionKey
void putG4Bits(sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState &io_rState)
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
std::vector< sal_uInt8 > & getOValue()
void SetVersion(sal_Int32 n)
GfxLink GetGfxLink() const
FillType getFillType() const
Get fill type used.
void getStartArrow(tools::PolyPolygon &) const
Get the polygon that is put at the start of the line.
FontStrikeout GetStrikeout() const
constexpr sal_Int32 MD5_DIGEST_SIZE
sal_uInt16 GetSteps() const
::comphelper::Hash * getUDigest()
const Color & GetStartColor() const
const PixelCode BlackPixelCodes[]
Bitmap GetBitmap(Color aTransparentReplaceColor) const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
static bool lcl_canUsePDFAxialShading(const Gradient &rGradient)
const Point & GetPoint() const
const Color & GetColor() const
constexpr sal_Int32 ENCRYPTED_PWD_SIZE
void getDashArray(DashArray &) const
Get an array of "on" and "off" lengths for stroke dashing.
void SetTextAlign(TextAlign eAlign)
AlphaMask GetAlpha() const
void ImplRefreshFontData(bool bNewFontLists) override
Connect segments by a direct straight line.
::std::vector< double > DashArray
constexpr tools::Long Height() const
void update(const unsigned char *pInput, size_t length)
const Point & GetStartPoint() const
double getTransparency() const
Get stroke transparency.
GfxLinkType GetType() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
#define SAL_INFO(area, stream)
void checkAndEnableStreamEncryption(sal_Int32 nObject)
const Color & GetEndColor() const
Half-round cap at the line end, the center lying at the end point.
Reference< XComponentContext > getProcessComponentContext()
virtual void ImplClearFontData(bool bNewFontLists)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
void DrawHatchLine_DrawLine(const Point &rStartPoint, const Point &rEndPoint) override
double getStrokeWidth() const
Get width of the stroke.
const Color & GetColor() const
FillRule getFillRule() const
Get fill rule used.
FontLineStyle GetOverline() const
static std::vector< unsigned char > calculateHash(const unsigned char *pInput, size_t length, HashType eType)
void setHeight(tools::Long nHeight)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
JoinType getJoinType() const
Get the style in which the stroke segments are joined.
std::vector< double > m_aDashArray
reference_type * get() const
Get the body.
#define SAL_WARN(area, stream)
Encapsulates geometry and associated attributes of a filled area.
TextAlign GetTextAlign() const
void SetCompressMode(SvStreamCompressFlags nNewMode)
const Graphic & GetCurrentGraphic() const
void getEndArrow(tools::PolyPolygon &) const
Get the polygon that is put at the end of the line.
void getPath(tools::PolyPolygon &) const
Query path to fill.
static std::map< sal_IntPtr, EncHashTransporter * > sTransporters
const sal_uInt8 & getByte() const
const Size & GetSizePixel() const
static css::uno::Reference< css::beans::XMaterialHolder > initEncryption(const OUString &i_rOwnerPassword, const OUString &i_rUserPassword)
Reference< XComponentContext > m_aContext
Extend segment edges, until they cross.
std::vector< unsigned char > finalize()
std::vector< sal_uInt8 > UValue
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
void enableStringEncryption(sal_Int32 nObject)
const tools::Long setRun[256]
const tools::Rectangle & GetRect() const
sal_Int32 GetIndex() const
sal_Int32 GetIndex() const
virtual ~EncHashTransporter() override
std::vector< sal_uInt8 > OValue
void playMetafile(const GDIMetaFile &, vcl::PDFExtOutDevData *, const vcl::PDFWriter::PlayMetafileContext &, VirtualDevice *pDummyDev=nullptr)
void putG4Span(tools::Long i_nSpan, bool i_bWhitePixel, BitStreamState &io_rState)