39 #include <com/sun/star/beans/PropertyValue.hpp>
40 #include <com/sun/star/io/XSeekable.hpp>
41 #include <com/sun/star/graphic/GraphicProvider.hpp>
42 #include <com/sun/star/graphic/XGraphicProvider.hpp>
43 #include <com/sun/star/beans/XMaterialHolder.hpp>
66 playMetafile( aTmpMtf,
nullptr, i_rContext, i_pDummyVDev );
77 Point aPoint( i_rPoint );
78 Size aSize( i_rSize );
84 if( aSize.
Width() < 0 )
87 aPoint.AdjustX( -(aSize.
Width()) );
93 aPoint.AdjustY( -(aSize.
Height()) );
99 aBitmapEx.
Mirror( nMirrorFlags );
102 bool bIsJpeg =
false, bIsPng =
false;
113 && aBmpSize.getHeight() > 50)
117 const double fBmpPixelX = aBmpSize.Width();
118 const double fBmpPixelY = aBmpSize.Height();
123 if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) ||
124 ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) &&
125 ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) )
129 const double fBmpWH = fBmpPixelX / fBmpPixelY;
130 const double fMaxWH = fMaxPixelX / fMaxPixelY;
132 if( fBmpWH < fMaxWH )
137 else if( fBmpWH > 0.0 )
156 if ( !(aSizePixel.Width() && aSizePixel.Height()) )
169 if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
170 bUseJPGCompression =
false;
172 auto pStrm=std::make_shared<SvMemoryStream>();
175 bool bTrueColorJPG =
true;
176 if ( bUseJPGCompression )
182 const auto& rCacheEntry=m_aPDFBmpCache.find(
184 if ( rCacheEntry != m_aPDFBmpCache.end() )
186 m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second,
true, aSizePixel,
191 sal_uInt32 nZippedFileSize = 0;
198 nZippedFileSize = aTemp.
TellEnd();
210 aFilterData[ 0 ].Name =
"Quality";
212 aFilterData[ 1 ].Name =
"ColorMode";
213 aFilterData[ 1 ].Value <<= sal_Int32(0);
218 uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW );
220 uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) );
222 uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() );
223 uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 );
224 aOutMediaProperties[0].Name =
"OutputStream";
225 aOutMediaProperties[0].Value <<= xOut;
226 aOutMediaProperties[1].Name =
"MimeType";
227 aOutMediaProperties[1].Value <<= OUString(
"image/jpeg");
228 aOutMediaProperties[2].Name =
"FilterData";
229 aOutMediaProperties[2].Value <<= aFilterData;
230 xGraphicProvider->storeGraphic(
xGraphic, aOutMediaProperties );
232 if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize )
234 bUseJPGCompression =
false;
240 xSeekable->seek( 0 );
242 aArgs[ 0 ].Name =
"InputStream";
243 aArgs[ 0 ].Value <<= xStream;
244 uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) );
247 sal_Int16 nBitsPerPixel = 24;
248 if ( xPropSet->getPropertyValue(
"BitsPerPixel") >>= nBitsPerPixel )
250 bTrueColorJPG = nBitsPerPixel != 8;
255 catch( uno::Exception& )
257 bUseJPGCompression =
false;
260 if ( bUseJPGCompression )
262 m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel,
tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
266 m_aPDFBmpCache.insert(
271 m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
273 m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.
GetBitmap(), i_Graphic );
279 bool bAssertionFired(
false );
285 pDummyVDev = xPrivateDevice.
get();
293 if ( !i_pOutDevData || !i_pOutDevData->
PlaySyncPageAct( m_rOuterFace,
i, aMtf ) )
302 const MetaPixelAction* pA =
static_cast<const MetaPixelAction*
>(pAction);
303 m_rOuterFace.DrawPixel( pA->GetPoint(), pA->GetColor() );
310 m_rOuterFace.DrawPixel( pA->
GetPoint() );
327 m_rOuterFace.DrawRect( pA->
GetRect() );
333 const MetaRoundRectAction* pA =
static_cast<const MetaRoundRectAction*
>(pAction);
334 m_rOuterFace.DrawRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() );
340 const MetaEllipseAction* pA =
static_cast<const MetaEllipseAction*
>(pAction);
341 m_rOuterFace.DrawEllipse( pA->GetRect() );
347 const MetaArcAction* pA =
static_cast<const MetaArcAction*
>(pAction);
348 m_rOuterFace.DrawArc( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
354 const MetaArcAction* pA =
static_cast<const MetaArcAction*
>(pAction);
355 m_rOuterFace.DrawPie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
361 const MetaChordAction* pA =
static_cast<const MetaChordAction*
>(pAction);
362 m_rOuterFace.DrawChord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() );
368 const MetaPolygonAction* pA =
static_cast<const MetaPolygonAction*
>(pAction);
369 m_rOuterFace.DrawPolygon( pA->GetPolygon() );
375 const MetaPolyLineAction* pA =
static_cast<const MetaPolyLineAction*
>(pAction);
376 if ( pA->GetLineInfo().IsDefault() )
377 m_rOuterFace.DrawPolyLine( pA->GetPolygon() );
379 m_rOuterFace.DrawPolyLine( pA->GetPolygon(), pA->GetLineInfo() );
385 const MetaPolyPolygonAction* pA =
static_cast<const MetaPolyPolygonAction*
>(pAction);
386 m_rOuterFace.DrawPolyPolygon( pA->GetPolyPolygon() );
396 m_rOuterFace.DrawGradient( pA->
GetRect(), rGradient );
401 implWriteGradient( aPolyPoly, rGradient, pDummyVDev, i_rContext );
408 const MetaGradientExAction* pA =
static_cast<const MetaGradientExAction*
>(pAction);
409 const Gradient& rGradient = pA->GetGradient();
412 m_rOuterFace.DrawGradient( pA->GetPolyPolygon(), rGradient );
414 implWriteGradient( pA->GetPolyPolygon(), rGradient, pDummyVDev, i_rContext );
445 const sal_uInt16 nTransPercent = aTransCol.
GetLuminance() * 100 / 255;
446 m_rOuterFace.BeginTransparencyGroup();
447 playMetafile( aTmpMtf,
nullptr, i_rContext, pDummyVDev );
448 m_rOuterFace.EndTransparencyGroup(
tools::Rectangle( rPos, rSize ), nTransPercent );
456 sal_Int32 nMaxBmpDPI(300);
463 const sal_Int32 nPixelX =
static_cast<sal_Int32
>(
static_cast<double>(aDstSizeTwip.
Width()) * static_cast<double>(nMaxBmpDPI) / 1440.0);
464 const sal_Int32 nPixelY =
static_cast<sal_Int32
>(
static_cast<double>(aDstSizeTwip.
Height()) * static_cast<double>(nMaxBmpDPI) / 1440.0);
465 if ( nPixelX && nPixelY )
467 Size aDstSizePixel( nPixelX, nPixelY );
469 if( xVDev->SetOutputSizePixel( aDstSizePixel ) )
477 xVDev->SetMapMode( aMapMode );
478 Size aDstSize( xVDev->PixelToLogic( aDstSizePixel ) );
480 Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() );
481 if ( aMtfOrigin.X() || aMtfOrigin.Y() )
482 aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() );
483 double fScaleX =
static_cast<double>(aDstSize.Width()) / static_cast<double>(aTmpMtf.GetPrefSize().Width());
484 double fScaleY =
static_cast<double>(aDstSize.Height()) / static_cast<double>(aTmpMtf.GetPrefSize().Height());
485 if( fScaleX != 1.0 || fScaleY != 1.0 )
486 aTmpMtf.Scale( fScaleX, fScaleY );
487 aTmpMtf.SetPrefMapMode( aMapMode );
491 aTmpMtf.Play( xVDev.
get(), aPoint, aDstSize );
494 xVDev->EnableMapMode(
false );
495 aPaint = xVDev->GetBitmap( aPoint, aDstSizePixel );
496 xVDev->EnableMapMode();
505 aTmpMtf.Play( xVDev.
get(), aPoint, aDstSize );
507 xVDev->EnableMapMode(
false );
508 aMask = xVDev->GetBitmap( aPoint, aDstSizePixel );
509 xVDev->EnableMapMode();
513 xVDev->DrawGradient(
tools::Rectangle( aPoint, aDstSize ), rTransparenceGradient );
515 xVDev->EnableMapMode(
false );
516 xVDev->DrawMask( aPoint, aDstSizePixel, aMask,
COL_WHITE );
517 aAlpha = xVDev->GetBitmap( aPoint, aDstSizePixel );
520 implWriteBitmapEx( rPos, rSize,
BitmapEx( aPaint, aAlpha ), aGraphic, pDummyVDev, i_rContext );
535 MapMode aMapMode( aSubstitute.GetPrefMapMode() );
537 aMapMode.SetScaleX(
Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
538 aMapMode.SetScaleY(
Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
541 m_rOuterFace.SetMapMode( aMapMode );
543 playMetafile( aSubstitute,
nullptr, i_rContext, pDummyVDev );
554 if( pA->
GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_BEGIN"))
556 const MetaGradientExAction* pGradAction =
nullptr;
559 while( !bDone && ( ++
i < nCount ) )
564 pGradAction = static_cast<const MetaGradientExAction*>(pAction);
566 ( static_cast<const MetaCommentAction*>(pAction)->GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_END")) )
576 m_rOuterFace.DrawGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient() );
580 implWriteGradient( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), pDummyVDev, i_rContext );
590 bool bSkipSequence =
false;
593 if( pA->
GetComment() ==
"XPATHSTROKE_SEQ_BEGIN" )
595 sSeqEnd = OString(
"XPATHSTROKE_SEQ_END");
612 bSkipSequence =
true;
613 if ( aStartArrow.
Count() || aEndArrow.
Count() )
614 bSkipSequence =
false;
615 if ( !aDashArray.empty() && ( fStrokeWidth != 0.0 ) && ( fTransparency == 0.0 ) )
616 bSkipSequence =
false;
644 && fStrokeWidth > 0.0)
647 const sal_uInt16 nPoints(aPath.
GetSize());
648 const bool bCurve(aPath.
HasFlags());
650 for(sal_uInt16
a(0);
a + 1 < nPoints;
a++)
653 && PolyFlags::Normal != aPath.
GetFlags(
a + 1)
655 && PolyFlags::Normal != aPath.
GetFlags(
a + 2)
661 m_rOuterFace.DrawPolyLine( aSnippet, aInfo );
668 m_rOuterFace.DrawPolyLine( aSnippet, aInfo );
674 m_rOuterFace.DrawPolyLine( aPath, aInfo );
678 else if ( pA->
GetComment() ==
"XPATHFILL_SEQ_BEGIN" )
680 sSeqEnd = OString(
"XPATHFILL_SEQ_END");
687 if ( fTransparency == 0.0 )
692 bSkipSequence =
true;
693 m_rOuterFace.DrawPolyPolygon( aPath );
695 else if ( fTransparency == 1.0 )
696 bSkipSequence =
true;
701 while( ++
i < nCount )
706 OString sComment( static_cast<const MetaCommentAction*>(pAction)->GetComment() );
707 if (sComment == sSeqEnd)
718 m_rOuterFace.SetFillColor( pMA->
GetColor() );
720 m_rOuterFace.SetFillColor();
734 aBitmapEx.GetPrefMapMode(), pDummyVDev->
GetMapMode() ) );
735 if( ! ( aSize.Width() && aSize.Height() ) )
736 aSize = pDummyVDev->
PixelToLogic( aBitmapEx.GetSizePixel() );
739 implWriteBitmapEx( pA->
GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
753 const MetaBmpScalePartAction* pA =
static_cast<const MetaBmpScalePartAction*
>(pAction);
754 BitmapEx aBitmapEx( pA->GetBitmap() );
757 implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
766 aBitmapEx.GetPrefMapMode(), pDummyVDev->
GetMapMode() ) );
768 implWriteBitmapEx( pA->
GetPoint(), aSize, aBitmapEx, aGraphic, pDummyVDev, i_rContext );
782 const MetaBmpExScalePartAction* pA =
static_cast<const MetaBmpExScalePartAction*
>(pAction);
783 BitmapEx aBitmapEx( pA->GetBitmapEx() );
786 implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext );
794 SAL_WARN(
"vcl",
"MetaMask...Action not supported yet" );
814 const MetaTextArrayAction* pA =
static_cast<const MetaTextArrayAction*
>(pAction);
815 m_rOuterFace.DrawTextArray( pA->GetPoint(), pA->GetText(), pA->GetDXArray(), pA->GetIndex(), pA->GetLen() );
836 const MetaClipRegionAction* pA =
static_cast<const MetaClipRegionAction*
>(pAction);
838 if( pA->IsClipping() )
840 if( pA->GetRegion().IsEmpty() )
845 m_rOuterFace.SetClipRegion( aReg.GetAsB2DPolyPolygon() );
849 m_rOuterFace.SetClipRegion();
855 const MetaISectRectClipRegionAction* pA =
static_cast<const MetaISectRectClipRegionAction*
>(pAction);
856 m_rOuterFace.IntersectClipRegion( pA->GetRect() );
862 const MetaISectRegionClipRegionAction* pA =
static_cast<const MetaISectRegionClipRegionAction*
>(pAction);
864 m_rOuterFace.IntersectClipRegion( aReg.GetAsB2DPolyPolygon() );
870 const MetaMoveClipRegionAction* pA =
static_cast<const MetaMoveClipRegionAction*
>(pAction);
871 m_rOuterFace.MoveClipRegion( pA->GetHorzMove(), pA->GetVertMove() );
878 m_rOuterFace.SetMapMode( pDummyVDev->
GetMapMode() );
887 m_rOuterFace.SetLineColor( pA->
GetColor() );
889 m_rOuterFace.SetLineColor();
898 m_rOuterFace.SetFillColor( pA->
GetColor() );
900 m_rOuterFace.SetFillColor();
906 const MetaTextLineColorAction* pA =
static_cast<const MetaTextLineColorAction*
>(pAction);
908 if( pA->IsSetting() )
909 m_rOuterFace.SetTextLineColor( pA->GetColor() );
911 m_rOuterFace.SetTextLineColor();
917 const MetaOverlineColorAction* pA =
static_cast<const MetaOverlineColorAction*
>(pAction);
919 if( pA->IsSetting() )
920 m_rOuterFace.SetOverlineColor( pA->GetColor() );
922 m_rOuterFace.SetOverlineColor();
928 const MetaTextFillColorAction* pA =
static_cast<const MetaTextFillColorAction*
>(pAction);
930 if( pA->IsSetting() )
931 m_rOuterFace.SetTextFillColor( pA->GetColor() );
933 m_rOuterFace.SetTextFillColor();
939 const MetaTextColorAction* pA =
static_cast<const MetaTextColorAction*
>(pAction);
940 m_rOuterFace.SetTextColor( pA->GetColor() );
946 const MetaTextAlignAction* pA =
static_cast<const MetaTextAlignAction*
>(pAction);
947 m_rOuterFace.SetTextAlign( pA->GetTextAlign() );
953 const MetaFontAction* pA =
static_cast<const MetaFontAction*
>(pAction);
954 m_rOuterFace.SetFont( pA->GetFont() );
960 const MetaPushAction* pA =
static_cast<const MetaPushAction*
>(pAction);
962 pDummyVDev->
Push( pA->GetFlags() );
963 m_rOuterFace.Push( pA->GetFlags() );
976 const MetaLayoutModeAction* pA =
static_cast<const MetaLayoutModeAction*
>(pAction);
977 m_rOuterFace.SetLayoutMode( pA->GetLayoutMode() );
983 const MetaTextLanguageAction* pA =
static_cast<const MetaTextLanguageAction*
>(pAction);
984 m_rOuterFace.SetDigitLanguage( pA->GetTextLanguage() );
990 const MetaWallpaperAction* pA =
static_cast<const MetaWallpaperAction*
>(pAction);
991 m_rOuterFace.DrawWallpaper( pA->GetRect(), pA->GetWallpaper() );
1011 if( !bAssertionFired )
1013 bAssertionFired =
true;
1014 SAL_WARN(
"vcl",
"PDFExport::ImplWriteActions: deprecated and unsupported MetaAction encountered " << static_cast<int>(nType) );
1043 maID =
reinterpret_cast< sal_IntPtr
>(
this);
1044 while( sTransporters.find( maID ) != sTransporters.end() )
1046 sTransporters[ maID ] =
this;
1051 sTransporters.erase( maID );
1052 SAL_INFO(
"vcl",
"EncHashTransporter freed" );
1065 return uno::makeAny( sal_Int64(maID) );
1068 static EncHashTransporter* getEncHashTransporter(
const uno::Reference< beans::XMaterialHolder >& );
1079 uno::Any aMat( xRef->getMaterial() );
1083 std::map< sal_IntPtr, EncHashTransporter* >::iterator it = sTransporters.find( static_cast<sal_IntPtr>(nMat) );
1084 if( it != sTransporters.end() )
1085 pResult = it->second;
1096 m_bEncryptThisStream =
true;
1097 sal_Int32
i = m_nKeyLength;
1104 m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5));
1108 rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength,
nullptr, 0 );
1116 sal_Int32
i = m_nKeyLength;
1124 m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5));
1127 rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength,
nullptr, 0 );
1135 const OUString& i_rUserPassword
1138 uno::Reference< beans::XMaterialHolder > xResult;
1139 if( !i_rOwnerPassword.isEmpty() || !i_rUserPassword.isEmpty() )
1142 xResult = pTransporter;
1146 padPassword( i_rOwnerPassword.isEmpty() ? i_rUserPassword : i_rOwnerPassword, aPadOPW );
1147 padPassword( i_rUserPassword, aPadUPW );
1157 rtl_secureZeroMemory (aPadOPW,
sizeof(aPadOPW));
1158 rtl_secureZeroMemory (aPadUPW,
sizeof(aPadUPW));
1165 bool bSuccess =
false;
1169 sal_Int32 nKeyLength = 0, nRC4KeyLength = 0;
1170 sal_Int32 nAccessPermissions = computeAccessPermissions(
m_aContext.Encryption, nKeyLength, nRC4KeyLength );
1172 bSuccess = computeUDictionaryValue( pTransporter,
m_aContext.Encryption, nKeyLength, nAccessPermissions );
1184 sal_Int32& o_rKeyLength, sal_Int32& o_rRC4KeyLength )
1193 sal_Int32 nAccessPermissions = 0xfffff0c0;
1196 o_rRC4KeyLength = 16;
1202 nAccessPermissions |= ( i_rProperties.
CanAddOrModify ) ? 1 << 5 : 0;
1205 nAccessPermissions |= ( i_rProperties.
CanAssemble ) ? 1 << 10 : 0;
1206 nAccessPermissions |= ( i_rProperties.
CanPrintFull ) ? 1 << 11 : 0;
1207 return nAccessPermissions;
1222 sal_Int32 nCurrentChar;
1224 for( nCurrentChar = 0; nCurrentChar < nToCopy; nCurrentChar++ )
1225 o_pPaddedPW[nCurrentChar] = static_cast<sal_uInt8>( aString[nCurrentChar] );
1230 o_pPaddedPW[i] = s_nPadString[y];
1245 bool bSuccess =
true;
1246 ::std::vector<unsigned char> nMD5Sum;
1253 if( ! io_rProperties.
OValue.empty() )
1260 nPerm[0] =
static_cast<sal_uInt8>(i_nAccessPermissions);
1261 nPerm[1] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 8 );
1262 nPerm[2] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 16 );
1263 nPerm[3] =
static_cast<sal_uInt8>( i_nAccessPermissions >> 24 );
1265 pDigest->
update(nPerm,
sizeof(nPerm));
1273 for (sal_Int32
i = 0;
i < 50;
i++)
1302 std::vector< sal_uInt8 >& io_rOValue,
1303 sal_Int32 i_nKeyLength
1306 bool bSuccess =
true;
1310 rtlCipher aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1322 for (i = 0; i < 50; i++)
1330 if (rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1331 nMD5Sum.data(), i_nKeyLength ,
nullptr, 0 )
1332 == rtl_Cipher_E_None)
1336 io_rOValue.data(), sal_Int32(io_rOValue.size()) );
1344 for( i = 1; i <= 19; i++ )
1346 for( y = 0; y <
sizeof( nLocalKey ); y++ )
1347 nLocalKey[y] = static_cast<sal_uInt8>( nMD5Sum[y] ^ i );
1349 if (rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1351 != rtl_Cipher_E_None)
1356 rtl_cipher_encodeARCFOUR( aCipher, io_rOValue.data(), sal_Int32(io_rOValue.size()),
1357 io_rOValue.data(), sal_Int32(io_rOValue.size()) );
1369 rtl_cipher_destroyARCFOUR( aCipher );
1381 sal_Int32 i_nKeyLength,
1382 sal_Int32 i_nAccessPermissions
1385 bool bSuccess =
true;
1390 rtlCipher aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1394 if( computeEncryptionKey( i_pTransporter, io_rProperties, i_nAccessPermissions ) )
1397 for( sal_Int32
i = i_nKeyLength,
y = 0;
y < 5 ;
y++ )
1405 aDigest.
update(s_nPadString,
sizeof(s_nPadString));
1408 ::std::vector<unsigned char>
const nMD5Sum(aDigest.
finalize());
1410 rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1412 rtl_cipher_encodeARCFOUR( aCipher, nMD5Sum.data(), nMD5Sum.size(),
1419 for( i = 1; i <= 19; i++ )
1421 for( y = 0; y <
sizeof( nLocalKey ) ; y++ )
1422 nLocalKey[y] = static_cast<sal_uInt8>( io_rProperties.
EncryptionKey[y] ^ i );
1424 rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode,
1438 rtl_cipher_destroyARCFOUR( aCipher );
1441 io_rProperties.
UValue.clear();
1449 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
1450 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1453 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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,
1469 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1483 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1484 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8,
1489 return (i_pLine[ i_nIndex/8 ] & (0x80 >> (i_nIndex&7))) != 0;
1497 const sal_uInt8 * pByte = i_pLine + (nIndex/8);
1505 while( nBitInByte != 8 )
1507 if( (nByte & nMask) != (i_bSet ? nMask : 0) )
1508 return std::min(nIndex, i_nW);
1535 while( nByte == nRunByte )
1549 nIndex += pRunTable[nByte];
1552 return std::min(nIndex, i_nW);
1557 if (i_nStartIndex < 0)
1565 if (i_nStartIndex < 0)
1568 const bool bSet = i_nStartIndex < i_nW &&
isSet(i_pLine, i_nStartIndex);
1585 void flush() { mnNextBitPos = 8; mnBuffer = 0; }
1594 writeBuffer( &io_rState.
getByte(), 1 );
1598 static const unsigned int msbmask[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
1603 writeBuffer( &io_rState.
getByte(), 1 );
1612 sal_uInt32 mnEncodedPixels;
1613 sal_uInt32 mnCodeBits;
1837 const PixelCode* pTable = i_bWhitePixel ? WhitePixelCodes :
BlackPixelCodes;
1839 while( i_nSpan > 2623 )
1842 putG4Bits( pTable[103].mnCodeBits, pTable[103].mnCode, io_rState );
1843 i_nSpan -= pTable[103].mnEncodedPixels;
1848 sal_uInt32 nTabIndex = 63 + (i_nSpan >> 6);
1849 OSL_ASSERT( pTable[nTabIndex].mnEncodedPixels == static_cast<sal_uInt32>(64*(i_nSpan >> 6)) );
1850 putG4Bits( pTable[nTabIndex].mnCodeBits, pTable[nTabIndex].mnCode, io_rState );
1851 i_nSpan -= pTable[nTabIndex].mnEncodedPixels;
1853 putG4Bits( pTable[i_nSpan].mnCodeBits, pTable[i_nSpan].mnCode, io_rState );
1860 if( nW <= 0 || nH <= 0 )
1868 std::unique_ptr<sal_uInt8[]> pFirstRefLine(
new sal_uInt8[nW/8 + 1]);
1869 memset(pFirstRefLine.get(), 0, nW/8 + 1);
1870 Scanline pRefLine = pFirstRefLine.get();
1875 bool bRunSet = (*pCurLine & 0x80) != 0;
1876 bool bRefSet = (*pRefLine & 0x80) != 0;
1879 for( ; nLineIndex < nW; )
1882 if( nRefIndex2 >= nRunIndex1 )
1885 if( -3 <= nDiff && nDiff <= 3 )
1889 sal_uInt32 mnCodeBits;
1891 } VerticalCodes[7] = {
1904 putG4Bits( VerticalCodes[nDiff].mnCodeBits, VerticalCodes[nDiff].mnCode, aBitState );
1905 nLineIndex = nRunIndex1;
1910 putG4Bits( 3, 0x1, aBitState );
1912 bool bWhiteFirst = ( nLineIndex + nRunIndex1 == 0 || !
isSet( pCurLine, nLineIndex ) );
1913 putG4Span( nRunIndex1 - nLineIndex, bWhiteFirst, aBitState );
1914 putG4Span( nRunIndex2 - nRunIndex1, ! bWhiteFirst, aBitState );
1915 nLineIndex = nRunIndex2;
1920 putG4Bits( 4, 0x1, aBitState );
1921 nLineIndex = nRefIndex2;
1923 if( nLineIndex < nW )
1925 bool bSet =
isSet( pCurLine, nLineIndex );
1926 nRunIndex1 =
findBitRun( pCurLine, nLineIndex, nW, bSet );
1927 nRefIndex1 =
findBitRun( pRefLine, nLineIndex, nW, ! bSet );
1928 nRefIndex1 =
findBitRun( pRefLine, nRefIndex1, nW, bSet );
1933 pRefLine = pCurLine;
1936 putG4Bits( 12, 1, aBitState );
1937 putG4Bits( 12, 1, aBitState );
1940 writeBuffer( &aBitState.
getByte(), 1 );
1953 case GradientStyle::Linear:
1954 case GradientStyle::Axial:
1967 if (bNewFontLists && AcquireGraphics())
1969 ReleaseFontCollection();
1976 if (bNewFontLists && AcquireGraphics())
1978 SetFontCollectionFromSVData();
1979 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
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)
std::unique_ptr< ContentProperties > pData
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)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
static EncHashTransporter * getEncHashTransporter(const uno::Reference< beans::XMaterialHolder > &)
Bitmap const & GetBitmap() const
static tools::Long findBitRun(const Scanline i_pLine, tools::Long i_nStartIndex, tools::Long i_nW, bool i_bSet)
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
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
CapType getCapType() const
Get the style in which open stroke ends are drawn.
virtual sal_uInt64 TellEnd() override
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
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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
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)
Perform no join, leads to visible gaps between thick line segments.
void SetOrigin(const Point &rOrigin)
sal_uInt32 GetWidth() const
tools::Long Width() const
tools::Long Width() const
bool m_bOnlyLosslessCompression
const OUString & GetText() const
void getPath(tools::Polygon &) const
Query path to stroke.
void AddGradientActions(const tools::Rectangle &rRect, const Gradient &rGradient, GDIMetaFile &rMtf)
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
bool IsTransparent() 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
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
static bool lcl_canUsePDFAxialShading(const Gradient &rGradient)
const Point & GetPoint() const
constexpr sal_Int32 ENCRYPTED_PWD_SIZE
void getDashArray(DashArray &) const
Get an array of "on" and "off" lengths for stroke dashing.
AlphaMask GetAlpha() const
void ImplRefreshFontData(bool bNewFontLists) override
Connect segments by a direct straight line.
::std::vector< double > DashArray
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.
tools::Long Height() const
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.
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)
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.
sal_uInt16 GetBitCount() 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
void Push(PushFlags nFlags=PushFlags::ALL)
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
Reference< XGraphic > xGraphic
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)