21#include <config_crypto.h>
38#include <com/sun/star/io/XOutputStream.hpp>
39#include <com/sun/star/util/URL.hpp>
40#include <com/sun/star/util/URLTransformer.hpp>
49#include <officecfg/Office/Common.hxx>
50#include <osl/file.hxx>
51#include <osl/thread.h>
52#include <rtl/digest.h>
54#include <rtl/ustrbuf.hxx>
88#include <textlayout.hxx>
96#include <frozen/bits/defines.h>
97#include <frozen/bits/elsa_std.h>
98#include <frozen/map.h>
100using namespace::com::sun::star;
107constexpr sal_Int32 nLog10Divisor = 3;
108constexpr double fDivisor = 1000.0;
110constexpr double pixelToPoint(
double px)
112 return px / fDivisor;
117 return sal_Int32(pt * fDivisor);
120void appendObjectID(sal_Int32 nObjectID, OStringBuffer & aLine)
122 aLine.append(nObjectID);
123 aLine.append(
" 0 obj\n");
126void appendObjectReference(sal_Int32 nObjectID, OStringBuffer & aLine)
128 aLine.append(nObjectID);
129 aLine.append(
" 0 R ");
132void appendHex(
sal_Int8 nInt, OStringBuffer& rBuffer)
134 static const char pHexDigits[] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
135 '8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
136 rBuffer.append( pHexDigits[ (nInt >> 4) & 15 ] );
137 rBuffer.append( pHexDigits[ nInt & 15 ] );
140void appendName( std::u16string_view rStr, OStringBuffer& rBuffer )
145 int nLen =
aStr.getLength();
146 for(
int i = 0;
i < nLen;
i++ )
155 if( (aStr[i] >=
'A' && aStr[i] <=
'Z' ) ||
156 (aStr[i] >=
'a' && aStr[i] <=
'z' ) ||
157 (aStr[i] >=
'0' && aStr[i] <=
'9' ) ||
160 rBuffer.append( aStr[i] );
164 rBuffer.append(
'#' );
165 appendHex(
static_cast<sal_Int8>(aStr[i]), rBuffer );
170void appendName(
const char* pStr, OStringBuffer& rBuffer )
173 while( pStr && *pStr )
175 if( (*pStr >=
'A' && *pStr <=
'Z' ) ||
176 (*pStr >=
'a' && *pStr <=
'z' ) ||
177 (*pStr >=
'0' && *pStr <=
'9' ) ||
180 rBuffer.append( *pStr );
184 rBuffer.append(
'#' );
185 appendHex(
static_cast<sal_Int8>(*pStr), rBuffer );
192void appendLiteralString(
const char* pStr, sal_Int32 nLength, OStringBuffer& rBuffer )
199 rBuffer.append(
"\\n" );
202 rBuffer.append(
"\\r" );
205 rBuffer.append(
"\\t" );
208 rBuffer.append(
"\\b" );
211 rBuffer.append(
"\\f" );
216 rBuffer.append(
"\\" );
217 rBuffer.append(
static_cast<char>(*pStr) );
220 rBuffer.append(
static_cast<char>(*pStr) );
251void appendDestinationName(
const OUString& rString, OStringBuffer& rBuffer )
254 sal_Int32 nLen = rString.getLength();
255 for(
int i = 0;
i < nLen;
i++ )
258 if( (aChar >=
'0' && aChar <=
'9' ) ||
259 (aChar >=
'a' && aChar <=
'z' ) ||
260 (aChar >=
'A' && aChar <=
'Z' ) ||
263 rBuffer.append(
static_cast<char>(aChar));
269 appendHex( aValueHigh, rBuffer );
270 appendHex(
static_cast<sal_Int8>(aChar & 255 ), rBuffer );
281 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
282 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A
288template <
class GEOMETRY >
289GEOMETRY lcl_convert(
const MapMode& _rSource,
const MapMode& _rDest,
OutputDevice* _pPixelConversion,
const GEOMETRY& _rObject )
292 if ( MapUnit::MapPixel == _rSource.
GetMapUnit() )
294 aPoint = _pPixelConversion->
PixelToLogic( _rObject, _rDest );
303void removePlaceholderSE(std::vector<PDFStructureElement> & rStructure, PDFStructureElement& rEle);
309 rBuffer.append(
"FEFF" );
311 sal_Int32 nLen = rString.getLength();
312 for(
int i = 0;
i < nLen;
i++ )
315 appendHex(
static_cast<sal_Int8>(aChar >> 8), rBuffer );
316 appendHex(
static_cast<sal_Int8>(aChar & 255 ), rBuffer );
326 const OUString& rName = i_rControl.
Name;
328 int nLen =
aStr.getLength();
330 OStringBuffer
aBuffer( rName.getLength()+64 );
331 for(
int i = 0;
i < nLen;
i++ )
346 OString aFullName(
aBuffer.makeStringAndClear() );
349 sal_Int32 nTokenIndex = 0, nLastTokenIndex = 0;
350 OString aPartialName;
354 nLastTokenIndex = nTokenIndex;
355 aPartialName = aFullName.getToken( 0,
'.', nTokenIndex );
356 if( nTokenIndex != -1 )
360 aDomain = aFullName.copy( 0, nTokenIndex-1 );
361 std::unordered_map< OString, sal_Int32 >::const_iterator it =
m_aFieldNameMap.find( aDomain );
369 m_aWidgets[nNewWidget].m_aName = aPartialName;
373 if( nLastTokenIndex > 0 )
377 OString aParentDomain( aDomain.copy( 0, nLastTokenIndex-1 ) );
382 OSL_ENSURE( it->second < sal_Int32(
m_aWidgets.size()),
"invalid field number entry" );
383 if( it->second < sal_Int32(
m_aWidgets.size()) )
402 aPartialName = aFullName.copy( aFullName.lastIndexOf(
'.' )+1 );
403 if( nLastTokenIndex > 0 )
405 aDomain = aFullName.copy( 0, nLastTokenIndex-1 );
406 aFullName = aDomain +
"." + aPartialName;
409 aFullName = aPartialName;
413 }
while( nTokenIndex != -1 );
416 if( !aDomain.isEmpty() )
418 std::unordered_map< OString, sal_Int32 >::const_iterator it =
m_aFieldNameMap.find( aDomain );
426 m_aWidgets[it->second].m_aKidsIndex.push_back( i_nWidgetIndex );
431 if( aPartialName.isEmpty() )
436 aPartialName =
"RadioGroup" +
440 aPartialName = OString(
"Widget" );
445 std::unordered_map<OString, sal_Int32>::iterator it =
m_aFieldNameMap.find( aFullName );
449 std::unordered_map< OString, sal_Int32 >::const_iterator check_it;
454 aTry = aFullName +
"_" + OString::number(nTry++);
459 aPartialName = aFullName.copy( aFullName.lastIndexOf(
'.' )+1 );
466 m_aWidgets[i_nWidgetIndex].m_aName = aPartialName;
472void appendFixedInt( sal_Int32 nValue, OStringBuffer& rBuffer )
476 rBuffer.append(
'-' );
479 sal_Int32 nFactor = 1, nDiv = nLog10Divisor;
483 sal_Int32 nInt =
nValue / nFactor;
484 rBuffer.append( nInt );
485 if (nFactor > 1 && nValue % nFactor)
487 rBuffer.append(
'.' );
491 rBuffer.append((nValue / nFactor) % 10);
493 while (nFactor > 1 && nValue % nFactor);
498void appendDouble(
double fValue, OStringBuffer& rBuffer, sal_Int32 nPrecision = 10 )
507 sal_Int64 nInt =
static_cast<sal_Int64
>(fValue);
508 fValue -=
static_cast<double>(nInt);
510 if( rtl::math::approxEqual(fValue, 1.0) || log10( 1.0-fValue ) <= -nPrecision )
518 fValue *= pow( 10.0,
static_cast<double>(nPrecision) );
519 nFrac =
static_cast<sal_Int64
>(fValue);
521 if( bNeg && ( nInt || nFrac ) )
522 rBuffer.append(
'-' );
523 rBuffer.append( nInt );
528 rBuffer.append(
'.' );
529 sal_Int64 nBound =
static_cast<sal_Int64
>(pow( 10.0, nPrecision - 1.0 )+0.5);
530 for ( i = 0; (
i < nPrecision ) && nFrac;
i++ )
532 sal_Int64 nNumb = nFrac / nBound;
533 nFrac -= nNumb * nBound;
534 rBuffer.append( nNumb );
539void appendColor(
const Color& rColor, OStringBuffer& rBuffer,
bool bConvertToGrey )
542 if( rColor == COL_TRANSPARENT )
548 appendDouble(
static_cast<double>(cByte) / 255.0, rBuffer );
552 appendDouble(
static_cast<double>(rColor.
GetRed()) / 255.0, rBuffer );
553 rBuffer.append(
' ' );
554 appendDouble(
static_cast<double>(rColor.
GetGreen()) / 255.0, rBuffer );
555 rBuffer.append(
' ' );
556 appendDouble(
static_cast<double>(rColor.
GetBlue()) / 255.0, rBuffer );
567 appendColor( rColor, rBuffer, bGrey );
568 rBuffer.append( bGrey ?
" G" :
" RG" );
577 appendColor( rColor, rBuffer, bGrey );
578 rBuffer.append( bGrey ?
" g" :
" rg" );
585void appendPdfTimeDate(OStringBuffer & rBuffer,
586 sal_Int16 year, sal_uInt16 month, sal_uInt16 day, sal_uInt16 hours, sal_uInt16 minutes, sal_uInt16 seconds, sal_Int32 tzDelta)
588 rBuffer.append(
"D:");
589 rBuffer.append(
char(
'0' + ((year / 1000) % 10)));
590 rBuffer.append(
char(
'0' + ((year / 100) % 10)));
591 rBuffer.append(
char(
'0' + ((year / 10) % 10)));
592 rBuffer.append(
char(
'0' + (year % 10)));
593 rBuffer.append(
char(
'0' + ((month / 10) % 10)));
594 rBuffer.append(
char(
'0' + (month % 10)));
595 rBuffer.append(
char(
'0' + ((day / 10) % 10)));
596 rBuffer.append(
char(
'0' + (day % 10)));
597 rBuffer.append(
char(
'0' + ((hours / 10) % 10)));
598 rBuffer.append(
char(
'0' + (hours % 10)));
599 rBuffer.append(
char(
'0' + ((minutes / 10) % 10)));
600 rBuffer.append(
char(
'0' + (minutes % 10)));
601 rBuffer.append(
char(
'0' + ((seconds / 10) % 10)));
602 rBuffer.append(
char(
'0' + (seconds % 10)));
618 rBuffer.append(
char(
'0' + ((tzDelta / 36000) % 10)));
619 rBuffer.append(
char(
'0' + ((tzDelta / 3600) % 10)));
621 rBuffer.append(
char(
'0' + ((tzDelta / 600) % 6)));
622 rBuffer.append(
char(
'0' + ((tzDelta / 60) % 10)));
630 m_pWriter( pWriter ),
631 m_nPageWidth( nPageWidth ),
632 m_nPageHeight( nPageHeight ),
634 m_eOrientation( eOrientation ),
636 m_nStreamLengthObject( 0 ),
637 m_nBeginStreamPos( 0 ),
648 m_nUserUnit = std::ceil(std::max(nPageWidth, nPageHeight) / 14400.0);
661 m_pWriter->emitComment(
"PDFWriterImpl::PDFPage::beginStream, +");
671 +
" 0 obj\n<</Length "
675 aLine.append(
"/Filter/FlateDecode" );
676 aLine.append(
">>\nstream\n" );
693 sal_uInt64 nEndStreamPos;
694 if (osl::File::E_None !=
m_pWriter->m_aFile.getPos(nEndStreamPos))
701 if( !
m_pWriter->writeBuffer(
"\nendstream\nendobj\n\n" ) )
723 "<</Type/Page/Parent "
724 + OString::number(nParentObject)
727 + OString::number(
m_pWriter->getResourceDictObj())
731 aLine.append(
"/MediaBox[0 0 "
738 aLine.append(
"\n/UserUnit " + OString::number(
m_nUserUnit));
749 aLine.append(
"/Annots[\n" );
750 for(
int i = 0;
i < nAnnots;
i++ )
754 aLine.append( ((
i+1)%15) ?
" " :
"\n" );
756 aLine.append(
"]\n" );
757 if (PDFWriter::PDFVersion::PDF_1_5 <= m_pWriter->
m_aContext.Version)
760 aLine.append(
"/Tabs/S\n" );
765 OStringBuffer aStructParents( 1024 );
766 aStructParents.append(
"[ " );
768 for(
int i = 0;
i < nParents;
i++ )
772 aStructParents.append( ((
i%10) == 9) ?
"\n" :
" " );
774 aStructParents.append(
"]" );
775 m_pWriter->m_aStructParentTree.push_back( aStructParents.makeStringAndClear() );
777 aLine.append(
"/StructParents "
778 + OString::number( sal_Int32(
m_pWriter->m_aStructParentTree.size()-1) )
784 aLine.append(
"/Trans<</D " );
785 appendDouble(
static_cast<double>(
m_nTransTime)/1000.0, aLine, 3 );
786 aLine.append(
"\n" );
787 const char *pStyle =
nullptr, *pDm =
nullptr, *pM =
nullptr, *pDi =
nullptr;
791 pStyle =
"Split"; pDm =
"H"; pM =
"I";
break;
793 pStyle =
"Split"; pDm =
"H"; pM =
"O";
break;
795 pStyle =
"Split"; pDm =
"V"; pM =
"I";
break;
797 pStyle =
"Split"; pDm =
"V"; pM =
"O";
break;
799 pStyle =
"Blinds"; pDm =
"H";
break;
801 pStyle =
"Blinds"; pDm =
"V";
break;
803 pStyle =
"Box"; pM =
"I";
break;
805 pStyle =
"Box"; pM =
"O";
break;
807 pStyle =
"Wipe"; pDi =
"0";
break;
809 pStyle =
"Wipe"; pDi =
"90";
break;
811 pStyle =
"Wipe"; pDi =
"180";
break;
813 pStyle =
"Wipe"; pDi =
"270";
break;
815 pStyle =
"Dissolve";
break;
822 aLine.append( OString::Concat(
"/S/") + pStyle +
"\n" );
826 aLine.append( OString::Concat(
"/Dm/") + pDm +
"\n" );
830 aLine.append( OString::Concat(
"/M/") + pM +
"\n" );
834 aLine.append( OString::Concat(
"/Di ") + pDi +
"\n" );
836 aLine.append(
">>\n" );
839 aLine.append(
"/Contents" );
841 if( nStreamObjects > 1 )
845 aLine.append(
" " + OString::number(
i ) +
" 0 R" );
847 if( nStreamObjects > 1 )
849 aLine.append(
">>\nendobj\n\n" );
855 Point aPoint( lcl_convert(
m_pWriter->m_aGraphicsStack.front().m_aMapMode,
862 appendFixedInt(
nValue, rBuffer );
864 rBuffer.append(
' ' );
868 appendFixedInt(
nValue, rBuffer );
873 double fValue = pixelToPoint(rPoint.
getX());
875 appendDouble( fValue, rBuffer, nLog10Divisor );
876 rBuffer.append(
' ' );
878 appendDouble( fValue, rBuffer, nLog10Divisor );
884 rBuffer.append(
' ' );
886 rBuffer.append(
' ' );
888 rBuffer.append(
" re" );
893 Point aLL = lcl_convert(
m_pWriter->m_aGraphicsStack.front().m_aMapMode,
898 Size aSize = lcl_convert(
m_pWriter->m_aGraphicsStack.front().m_aMapMode,
910 sal_uInt16 nPoints = rPoly.
GetSize();
914 sal_uInt32 nBufLen = rBuffer.getLength();
920 rBuffer.append(
" m\n" );
921 for( sal_uInt16
i = 1;
i < nPoints;
i++ )
923 if( pFlagArray && pFlagArray[
i] == PolyFlags::Control && nPoints-
i > 2 )
926 SAL_WARN_IF( pFlagArray[
i+1] != PolyFlags::Control || pFlagArray[
i+2] == PolyFlags::Control,
"vcl.pdfwriter",
"unexpected sequence of control points" );
928 rBuffer.append(
" " );
930 rBuffer.append(
" " );
932 rBuffer.append(
" c" );
939 rBuffer.append(
" l" );
941 if( (rBuffer.getLength() - nBufLen) > 65 )
943 rBuffer.append(
"\n" );
944 nBufLen = rBuffer.getLength();
947 rBuffer.append(
" " );
950 rBuffer.append(
"h\n" );
965 rBuffer.append(
' ' );
967 rBuffer.append(
' ' );
969 rBuffer.append(
" re\n" );
972 sal_uInt32 nPoints = aPoly.
count();
976 sal_uInt32 nBufLen = rBuffer.getLength();
979 rBuffer.append(
" m\n" );
980 for( sal_uInt32
i = 1;
i <= nPoints;
i++ )
985 sal_uInt32 nLastPoint =
i-1;
991 rBuffer.append(
' ' );
993 rBuffer.append(
' ' );
995 rBuffer.append(
" c" );
1000 rBuffer.append(
' ' );
1002 rBuffer.append(
" y" );
1007 rBuffer.append(
' ' );
1009 rBuffer.append(
" v" );
1014 rBuffer.append(
" l" );
1016 if( (rBuffer.getLength() - nBufLen) > 65 )
1018 rBuffer.append(
"\n" );
1019 nBufLen = rBuffer.getLength();
1022 rBuffer.append(
" " );
1025 rBuffer.append(
"h\n" );
1030 sal_uInt16 nPolygons = rPolyPoly.
Count();
1031 for( sal_uInt16
n = 0;
n < nPolygons;
n++ )
1037 for(
auto const& rPolygon : rPolyPoly)
1046 rBuffer.append(
'-' );
1049 Size aSize( lcl_convert(
m_pWriter->m_aGraphicsStack.front().m_aMapMode,
1057 appendFixedInt(
nValue, rBuffer );
1062 Size aSize( lcl_convert(
m_pWriter->m_aGraphicsStack.front().m_aMapMode,
1065 Size( 1000, 1000 ) ) );
1066 fLength *= pixelToPoint(
static_cast<double>(bVertical ? aSize.
Height() : aSize.
Width()) / 1000.0);
1067 appendDouble( fLength, rBuffer, nPrecision );
1072 if(
LineStyle::Dash == rInfo.GetStyle() && rInfo.GetDashLen() != rInfo.GetDotLen())
1076 if(2 * (rInfo.GetDashCount() + rInfo.GetDotCount()) > 10)
1088 if(css::drawing::LineCap_BUTT != rInfo.GetLineCap())
1096 rBuffer.append(
"[ " );
1097 if( rInfo.GetDashLen() == rInfo.GetDotLen() )
1100 rBuffer.append(
' ' );
1102 rBuffer.append(
' ' );
1106 for(
int n = 0;
n < rInfo.GetDashCount();
n++ )
1109 rBuffer.append(
' ' );
1111 rBuffer.append(
' ' );
1113 for(
int m = 0;
m < rInfo.GetDotCount();
m++ )
1116 rBuffer.append(
' ' );
1118 rBuffer.append(
' ' );
1121 rBuffer.append(
"] 0 d\n" );
1124 if( rInfo.GetWidth() > 1 )
1127 rBuffer.append(
" w\n" );
1129 else if( rInfo.GetWidth() == 0 )
1132 appendDouble( 72.0/
double(
m_pWriter->GetDPIX()), rBuffer );
1133 rBuffer.append(
" w\n" );
1146 rBuffer.append(
"0 " );
1148 rBuffer.append(
" m\n" );
1149 for( sal_Int32
n = 0;
n < nWidth; )
1153 rBuffer.append(
' ' );
1155 rBuffer.append(
' ' );
1158 rBuffer.append(
' ' );
1160 rBuffer.append(
" v " );
1165 rBuffer.append(
' ' );
1167 rBuffer.append(
' ' );
1170 rBuffer.append(
' ' );
1172 rBuffer.append(
" v\n" );
1175 rBuffer.append(
"S\n" );
1180 appendDouble(rMatrix.
get(0), rBuffer);
1181 rBuffer.append(
' ');
1182 appendDouble(rMatrix.
get(1), rBuffer);
1183 rBuffer.append(
' ');
1184 appendDouble(rMatrix.
get(2), rBuffer);
1185 rBuffer.append(
' ');
1186 appendDouble(rMatrix.
get(3), rBuffer);
1187 rBuffer.append(
' ');
1204 const css::uno::Reference< css::beans::XMaterialHolder >& xEnc,
1208 m_aWidgetStyleSettings(
Application::GetSettings().GetStyleSettings()),
1209 m_nCurrentStructElement( 0 ),
1210 m_bEmitStructure( true ),
1212 m_aPDFBmpCache(
utl::ConfigManager::IsFuzzing() ? 15 :
1213 officecfg::Office::Common::VCL::PDFExportImageCacheSize::
get()),
1214 m_nCurrentPage( -1 ),
1215 m_nCatalogObject(0),
1216 m_nSignatureObject( -1 ),
1217 m_nSignatureContentOffset( 0 ),
1218 m_nSignatureLastByteRangeNoOffset( 0 ),
1219 m_nResourceDict( -1 ),
1220 m_nFontDictObject( -1 ),
1225 m_aCipher( nullptr ),
1228 m_bEncryptThisStream( false ),
1229 m_nAccessPermissions(0),
1230 m_bIsPDF_A1( false ),
1231 m_bIsPDF_A2( false ),
1232 m_bIsPDF_UA( false ),
1233 m_bIsPDF_A3( false ),
1234 m_rOuterFace( i_rOuterFace )
1253 osl::File::RC aError =
m_aFile.open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create);
1254 if (aError != osl::File::E_None)
1256 if (aError == osl::File::E_EXIST)
1258 aError =
m_aFile.open(osl_File_OpenFlag_Write);
1259 if (aError == osl::File::E_None)
1263 if (aError != osl::File::E_None)
1272 m_aCipher = rtl_cipher_createARCFOUR( rtl_Cipher_ModeStream );
1289 OSL_ENSURE(
false,
"encryption data failed sanity check, encryption disabled" );
1310 aBuffer.append(
"\n%\303\244\303\274\303\266\303\237\n" );
1376 std::vector< sal_uInt8 > aId;
1387 TimeValue aTVal, aGMT;
1389 osl_getSystemTime(&aGMT);
1390 osl_getLocalTimeFromSystemTime(&aGMT, &aTVal);
1391 osl_getDateTimeFromTimeValue(&aTVal, &aDT);
1393 sal_Int32 nDelta = aTVal.Seconds-aGMT.Seconds;
1395 appendPdfTimeDate(aRet, aDT.Year, aDT.Month, aDT.Day, aDT.Hours, aDT.Minutes, aDT.Seconds, nDelta);
1398 return aRet.makeStringAndClear();
1403 const OString& i_rCString1,
1404 OString& o_rCString2
1407 o_rIdentifier.clear();
1410 OString aInfoValuesOut;
1411 OStringBuffer aID( 1024 );
1412 if( !i_rDocInfo.
Title.isEmpty() )
1414 if( !i_rDocInfo.
Author.isEmpty() )
1416 if( !i_rDocInfo.
Subject.isEmpty() )
1418 if( !i_rDocInfo.
Keywords.isEmpty() )
1420 if( !i_rDocInfo.
Creator.isEmpty() )
1422 if( !i_rDocInfo.
Producer.isEmpty() )
1425 TimeValue aTVal, aGMT;
1427 osl_getSystemTime( &aGMT );
1428 osl_getLocalTimeFromSystemTime( &aGMT, &aTVal );
1429 osl_getDateTimeFromTimeValue( &aTVal, &aDT );
1430 OStringBuffer aCreationMetaDateString(64);
1438 aCreationMetaDateString.append(
1439 OStringChar(
static_cast<char>(
'0' + ((aDT.Year/1000)%10)) )
1440 + OStringChar(
static_cast<char>(
'0' + ((aDT.Year/100)%10)) )
1441 + OStringChar(
static_cast<char>(
'0' + ((aDT.Year/10)%10)) )
1442 + OStringChar(
static_cast<char>(
'0' + ((aDT.Year)%10)) )
1444 + OStringChar(
static_cast<char>(
'0' + ((aDT.Month/10)%10)) )
1445 + OStringChar(
static_cast<char>(
'0' + ((aDT.Month)%10)) )
1447 + OStringChar(
static_cast<char>(
'0' + ((aDT.Day/10)%10)) )
1448 + OStringChar(
static_cast<char>(
'0' + ((aDT.Day)%10)) )
1450 + OStringChar(
static_cast<char>(
'0' + ((aDT.Hours/10)%10)) )
1451 + OStringChar(
static_cast<char>(
'0' + ((aDT.Hours)%10)) )
1453 + OStringChar(
static_cast<char>(
'0' + ((aDT.Minutes/10)%10)) )
1454 + OStringChar(
static_cast<char>(
'0' + ((aDT.Minutes)%10)) )
1456 + OStringChar(
static_cast<char>(
'0' + ((aDT.Seconds/10)%10)) )
1457 + OStringChar(
static_cast<char>(
'0' + ((aDT.Seconds)%10)) ));
1459 sal_uInt32 nDelta = 0;
1460 if( aGMT.Seconds > aTVal.Seconds )
1462 nDelta = aGMT.Seconds-aTVal.Seconds;
1463 aCreationMetaDateString.append(
"-" );
1465 else if( aGMT.Seconds < aTVal.Seconds )
1467 nDelta = aTVal.Seconds-aGMT.Seconds;
1468 aCreationMetaDateString.append(
"+" );
1472 aCreationMetaDateString.append(
"Z" );
1477 aCreationMetaDateString.append(
1478 OStringChar(
static_cast<char>(
'0' + ((nDelta/36000)%10)) )
1479 + OStringChar(
static_cast<char>(
'0' + ((nDelta/3600)%10)) )
1481 + OStringChar(
static_cast<char>(
'0' + ((nDelta/600)%6)) )
1482 + OStringChar(
static_cast<char>(
'0' + ((nDelta/60)%10)) ));
1484 aID.append( i_rCString1.getStr(), i_rCString1.getLength() );
1486 aInfoValuesOut = aID.makeStringAndClear();
1487 o_rCString2 = aCreationMetaDateString.makeStringAndClear();
1490 aDigest.
update(
reinterpret_cast<unsigned char const*
>(&aGMT),
sizeof(aGMT));
1491 aDigest.
update(
reinterpret_cast<unsigned char const*
>(aInfoValuesOut.getStr()), aInfoValuesOut.getLength());
1493 o_rIdentifier = aDigest.
finalize();
1503 rOutBuffer.append(
"<" );
1507 sal_Int32 nLen = rInString.getLength();
1511 sal_Int32 nChars = 2 + (nLen * 2);
1516 for(
int i = 0;
i < nLen;
i++ )
1519 *pCopy++ =
static_cast<sal_uInt8>( aUnChar >> 8 );
1520 *pCopy++ =
static_cast<sal_uInt8>( aUnChar & 255 );
1525 for(
int i = 0;
i < nChars;
i++)
1530 rOutBuffer.append(
">" );
1535 rOutBuffer.append(
"(" );
1536 sal_Int32 nChars = rInString.size();
1544 appendLiteralString(
reinterpret_cast<char*
>(
m_vEncryptionBuffer.data()), nChars, rOutBuffer );
1547 appendLiteralString( rInString.data(), nChars , rOutBuffer );
1548 rOutBuffer.append(
")" );
1554 sal_Int32 nLen = aBufferString.getLength();
1555 OStringBuffer
aBuf( nLen );
1556 const char* pT = aBufferString.getStr();
1558 for( sal_Int32
i = 0;
i < nLen;
i++, pT++ )
1560 if( (*pT & 0x80) == 0 )
1565 appendHex( *pT,
aBuf );
1569 aBufferString =
aBuf.makeStringAndClear();
1577 OString aLine = OString::Concat(
"% ") + pComment +
"\n";
1585 sal_uInt64 nEndPos = pStream->
TellEnd();
1587 ZCodec aCodec( 0x4000, 0x4000 );
1592 nEndPos = aStream.
Tell();
1607 m_pCodec = std::make_unique<ZCodec>( 0x4000, 0x4000 );
1638 pBuffer, sal::static_int_cast<std::size_t>(nBytes));
1642 sal_uInt64 nWritten;
1657 pBuffer,
static_cast<sal_Size
>(nBytes),
1662 m_DocDigest.
update(
static_cast<unsigned char const*
>(pWriteBuffer),
static_cast<sal_uInt32
>(nBytes));
1664 if (
m_aFile.write(pWriteBuffer, nBytes, nWritten) != osl::File::E_None)
1667 if( nWritten != nBytes )
1674 return nWritten == nBytes;
1681 m_aPages.emplace_back(
this, nPageWidth, nPageHeight, eOrientation );
1683 sal_Int32 nUserUnit =
m_aPages.back().m_nUserUnit;
1694 OStringBuffer
aBuf( 16 );
1696 aBuf.append(
" w\n" );
1711 OSL_FAIL(
"redirection across pages !!!" );
1734 if( ! bitmap.m_aBitmap.IsEmpty() )
1742 if( jpeg.m_pStream )
1745 jpeg.m_pStream.reset();
1751 if( item.m_pContentStream )
1754 item.m_pContentStream.reset();
1771 sal_uInt64 nOffset = ~0
U;
1772 osl::File::RC aError =
m_aFile.getPos(nOffset);
1773 SAL_WARN_IF( aError != osl::File::E_None,
"vcl.pdfwriter",
"could not register object" );
1774 if (aError != osl::File::E_None)
1780 return aError == osl::File::E_None;
1783#define CHECK_RETURN( x ) if( !(x) ) return 0
1784#define CHECK_RETURN2( x ) if( !(x) ) return
1790 OStringBuffer aLine( 1024 );
1792 aLine.append( OString::number(nObject)
1796 for( sal_Int32
n = 0;
n < nTreeItems;
n++ )
1798 aLine.append( OString::number(
n) +
" "
1802 aLine.append(
"]>>\nendobj\n\n" );
1812 return "id" + OString::number(nObjectId);
1823 std::map<OString, sal_Int32> ids;
1829 appendObjectID(nObject, buf);
1830 buf.append(
"<</Names [\n");
1831 for (
auto const& it : ids)
1835 appendObjectReference(it.second, buf);
1838 buf.append(
"] >>\nendobj\n\n");
1848 static constexpr auto aAttributeStrings = frozen::make_map<PDFWriter::StructAttribute, const char*>({
1874 auto it = aAttributeStrings.find( eAttr );
1876 if( it == aAttributeStrings.end() )
1877 SAL_INFO(
"vcl.pdfwriter",
"invalid PDFWriter::StructAttribute " << eAttr);
1879 return it != aAttributeStrings.end() ? it->second :
"";
1884 static constexpr auto aValueStrings = frozen::make_map<PDFWriter::StructAttributeValue, const char*>({
1927 auto it = aValueStrings.find( eVal );
1929 if( it == aValueStrings.end() )
1930 SAL_INFO(
"vcl.pdfwriter",
"invalid PDFWriter::StructAttributeValue " << eVal);
1932 return it != aValueStrings.end() ? it->second :
"";
1937 o_rLine.append(
"/" );
1942 o_rLine.append(
"/" );
1948 o_rLine.append(
" " );
1950 appendFixedInt( i_rVal.
nValue, o_rLine );
1952 o_rLine.append( i_rVal.
nValue );
1954 o_rLine.append(
"\n" );
1961 OString
const aStructParentEntry(OString::number(i_rEle.
m_nObject) +
" 0 R");
1964 sal_Int32
const nAnnotObj(rAnnot.m_nObject);
1970 OString::number( nRefObject ) +
1972 "<</Type/OBJR/Obj " +
1973 OString::number(nAnnotObj) +
1979 i_rEle.
m_aKids.emplace_back( nRefObject );
1985 OStringBuffer aLayout(256), aList(64), aTable(64);
1986 OStringBuffer aPrintField;
2003 sal_Int32 nLink =
attribute.second.nValue;
2004 std::map< sal_Int32, sal_Int32 >::const_iterator link_it =
2007 nLink = link_it->second;
2014 OSL_FAIL(
"unresolved link id for Link structure" );
2015 SAL_INFO(
"vcl.pdfwriter",
"unresolved link id " << nLink <<
" for Link structure");
2018 OString aLine =
"unresolved link id " +
2019 OString::number( nLink ) +
2020 " for Link structure";
2030 aLayout.append(
"/BBox[" );
2032 aLayout.append(
" " );
2033 appendFixedInt( i_rEle.
m_aBBox.
Top(), aLayout );
2034 aLayout.append(
" " );
2036 aLayout.append(
" " );
2038 aLayout.append(
"]\n" );
2041 std::vector< sal_Int32 > aAttribObjects;
2042 auto const WriteAttrs = [&](
char const*
const pName, OStringBuffer & rBuf)
2047 OStringBuffer aObj( 64 );
2048 aObj.append( aAttribObjects.back() );
2049 aObj.append(
" 0 obj\n"
2053 rBuf.append(
">>\nendobj\n\n");
2058 if( !aLayout.isEmpty() )
2060 WriteAttrs(
"/Layout", aLayout);
2062 if( !aList.isEmpty() )
2064 WriteAttrs(
"/List", aList);
2066 if (!aPrintField.isEmpty())
2068 WriteAttrs(
"/PrintField", aPrintField);
2070 if( !aTable.isEmpty() )
2072 WriteAttrs(
"/Table", aTable);
2075 OStringBuffer aRet( 64 );
2076 if( aAttribObjects.size() > 1 )
2077 aRet.append(
" [" );
2078 for (
auto const& attrib : aAttribObjects)
2080 aRet.append(
" " + OString::number(attrib) +
" 0 R" );
2082 if( aAttribObjects.size() > 1 )
2083 aRet.append(
" ]" );
2084 return aRet.makeStringAndClear();
2108 OSL_FAIL(
"PDFWriterImpl::emitStructure: invalid child structure element" );
2109 SAL_INFO(
"vcl.pdfwriter",
"PDFWriterImpl::emitStructure: invalid child structure element with id " << child);
2115 OSL_FAIL(
"PDFWriterImpl::emitStructure: invalid child structure id" );
2116 SAL_INFO(
"vcl.pdfwriter",
"PDFWriterImpl::emitStructure: invalid child structure id " << child);
2120 OStringBuffer aLine( 512 );
2125 sal_Int32 nParentTree = -1;
2126 sal_Int32 nIDTree = -1;
2131 aLine.append(
"/StructTreeRoot\n"
2133 + OString::number(nParentTree)
2137 aLine.append(
"/RoleMap<<" );
2140 aLine.append(
"/" + role.first +
"/" + role.second +
"\n" );
2142 aLine.append(
">>\n" );
2147 aLine.append(
"/IDTree ");
2148 appendObjectReference(nIDTree, aLine);
2154 aLine.append(
"/StructElem\n"
2162 aLine.append(
"\n/ID ");
2175 aLine.append(
"/ActualText" );
2177 aLine.append(
"\n" );
2181 aLine.append(
"/Alt" );
2183 aLine.append(
"\n" );
2189 if( !aAttribs.isEmpty() )
2191 aLine.append(
"/A" + aAttribs +
"\n" );
2194 if( !rEle.
m_aLocale.Language.isEmpty() )
2203 OUString aLanguage, aScript, aCountry;
2205 if (!aLanguage.isEmpty())
2207 OUStringBuffer aLocBuf( 16 );
2208 aLocBuf.append( aLanguage );
2209 if( !aCountry.isEmpty() )
2211 aLocBuf.append(
"-" + aCountry );
2213 aLine.append(
"/Lang" );
2215 aLine.append(
"\n" );
2240 aLine.append(
"/K[" );
2241 for (
auto const& kid : rEle.
m_aKids)
2243 if( kid.nMCID == -1 )
2246 OString::number(kid.nObject)
2248 aLine.append( ( (
i & 15) == 15 ) ?
"\n" :
" " );
2254 aLine.append( OString::number(kid.nMCID) +
" " );
2260 + OString::number(kid.nObject)
2262 + OString::number(kid.nMCID)
2268 aLine.append(
"]\n" );
2270 aLine.append(
">>\nendobj\n\n" );
2292 OStringBuffer aTilingObj( 1024 );
2296 SAL_WARN_IF( !tiling.m_pTilingStream,
"vcl.pdfwriter",
"tiling without stream" );
2297 if( ! tiling.m_pTilingStream )
2300 aTilingObj.setLength( 0 );
2307 sal_Int32 nX =
static_cast<sal_Int32
>(tiling.m_aRectangle.Left());
2308 sal_Int32 nY =
static_cast<sal_Int32
>(tiling.m_aRectangle.Top());
2309 sal_Int32 nW =
static_cast<sal_Int32
>(tiling.m_aRectangle.GetWidth());
2310 sal_Int32 nH =
static_cast<sal_Int32
>(tiling.m_aRectangle.GetHeight());
2311 if( tiling.m_aCellSize.Width() == 0 )
2312 tiling.m_aCellSize.setWidth( nW );
2313 if( tiling.m_aCellSize.Height() == 0 )
2314 tiling.m_aCellSize.setHeight( nH );
2317 sal_uInt64
const nTilingStreamSize = tiling.m_pTilingStream->TellEnd();
2322 OString::number(tiling.m_nObject)
2324 "<</Type/Pattern/PatternType 1\n"
2328 appendFixedInt( nX, aTilingObj );
2329 aTilingObj.append(
' ' );
2330 appendFixedInt( nY, aTilingObj );
2331 aTilingObj.append(
' ' );
2332 appendFixedInt( nX+nW, aTilingObj );
2333 aTilingObj.append(
' ' );
2334 appendFixedInt( nY+nH, aTilingObj );
2335 aTilingObj.append(
"]\n"
2337 appendFixedInt( tiling.m_aCellSize.Width(), aTilingObj );
2338 aTilingObj.append(
"\n"
2340 appendFixedInt( tiling.m_aCellSize.Height(), aTilingObj );
2341 aTilingObj.append(
"\n" );
2342 if( tiling.m_aTransform.matrix[0] != 1.0 ||
2343 tiling.m_aTransform.matrix[1] != 0.0 ||
2344 tiling.m_aTransform.matrix[3] != 0.0 ||
2345 tiling.m_aTransform.matrix[4] != 1.0 ||
2346 tiling.m_aTransform.matrix[2] != 0.0 ||
2347 tiling.m_aTransform.matrix[5] != 0.0 )
2349 aTilingObj.append(
"/Matrix [" );
2351 appendDouble( tiling.m_aTransform.matrix[0], aTilingObj );
2352 aTilingObj.append(
' ' );
2353 appendDouble( tiling.m_aTransform.matrix[1], aTilingObj );
2354 aTilingObj.append(
' ' );
2355 appendDouble( tiling.m_aTransform.matrix[3], aTilingObj );
2356 aTilingObj.append(
' ' );
2357 appendDouble( tiling.m_aTransform.matrix[4], aTilingObj );
2358 aTilingObj.append(
' ' );
2359 appendDouble( tiling.m_aTransform.matrix[2], aTilingObj );
2360 aTilingObj.append(
' ' );
2361 appendDouble( tiling.m_aTransform.matrix[5], aTilingObj );
2362 aTilingObj.append(
"]\n" );
2364 aTilingObj.append(
"/Resources" );
2367 aTilingObj.append(
"/Filter/FlateDecode" );
2368 aTilingObj.append(
"/Length "
2369 + OString::number(
static_cast<sal_Int32
>(nTilingStreamSize))
2374 bool written =
writeBufferBytes( tiling.m_pTilingStream->GetData(), nTilingStreamSize );
2375 tiling.m_pTilingStream.reset();
2379 aTilingObj.setLength( 0 );
2380 aTilingObj.append(
"\nendstream\nendobj\n\n" );
2392 OStringBuffer aLine( 1024 );
2394 if( nFontObject <= 0 )
2398 OString::number(nFontObject)
2400 "<</Type/Font/Subtype/Type1/BaseFont/" );
2401 appendName( rBuildinFont.
m_pPSName, aLine );
2402 aLine.append(
"\n" );
2403 if( rBuildinFont.
m_eCharSet == RTL_TEXTENCODING_MS_1252 )
2404 aLine.append(
"/Encoding/WinAnsiEncoding\n" );
2405 aLine.append(
">>\nendobj\n\n" );
2413int XUnits(
int nUPEM,
int n) {
return (n * 1000) / nUPEM; }
2418 std::map< sal_Int32, sal_Int32 > aRet;
2431 sal_Int32 pWidths[256] = { 0 };
2434 for(
sal_Ucs c = 32; c < 256; c++ )
2443 std::vector<sal_uInt8>
aBuffer;
2448 if( nFontDescriptor )
2454 OStringBuffer aLine( 1024 );
2456 OString::number(nObject)
2458 "<</Type/Font/Subtype/TrueType"
2461 aLine.append(
"\n" );
2463 aLine.append(
"/Encoding/WinAnsiEncoding\n" );
2464 aLine.append(
"/FirstChar 32 /LastChar 255\n"
2466 for(
int i = 32;
i < 256;
i++ )
2468 aLine.append( pWidths[
i] );
2469 aLine.append( ((
i&15) == 15) ?
"\n" :
" " );
2473 + OString::number( nFontDescriptor )
2487uint32_t fillSubsetArrays(
const FontEmit& rSubset,
sal_GlyphId* pGlyphIds, sal_Int32* pWidths,
2488 sal_uInt8* pEncoding, sal_Int32* pEncToUnicodeIndex,
2489 sal_Int32* pCodeUnitsPerGlyph, std::vector<sal_Ucs>& rCodeUnits,
2490 sal_Int32& nToUnicodeStream)
2492 rCodeUnits.reserve(256);
2497 uint32_t nGlyphs = 1;
2500 sal_uInt8 nEnc = item.second.getGlyphId();
2502 SAL_WARN_IF(pGlyphIds[nEnc] != 0 || pEncoding[nEnc] != 0,
"vcl.pdfwriter",
2506 pGlyphIds[nEnc] = item.first;
2507 pEncoding[nEnc] = nEnc;
2508 pEncToUnicodeIndex[nEnc] =
static_cast<sal_Int32
>(rCodeUnits.size());
2509 pCodeUnitsPerGlyph[nEnc] = item.second.countCodes();
2510 pWidths[nEnc] = item.second.getGlyphWidth();
2511 for (sal_Int32 n = 0;
n < pCodeUnitsPerGlyph[nEnc];
n++)
2512 rCodeUnits.push_back(item.second.getCode(n));
2513 if (item.second.getCode(0))
2514 nToUnicodeStream = 1;
2518 OSL_FAIL(
"too many glyphs for subset");
2527 std::map<sal_Int32, sal_Int32>& rFontIDToObject)
2537 std::vector<sal_uInt8>
aBuffer;
2543 sal_Int32 pWidths[256];
2545 sal_Int32 pEncToUnicodeIndex[256] = {};
2546 sal_Int32 pCodeUnitsPerGlyph[256] = {};
2547 std::vector<sal_Ucs> aCodeUnits;
2548 sal_Int32 nToUnicodeStream = 0;
2551 auto nGlyphs = fillSubsetArrays(rSubset, pGlyphIds, pWidths, pEncoding, pEncToUnicodeIndex,
2552 pCodeUnitsPerGlyph, aCodeUnits, nToUnicodeStream);
2555 sal_Int32 nFontDescriptor = 0;
2559 if (nToUnicodeStream)
2561 pEncToUnicodeIndex, nGlyphs);
2568 OStringBuffer aLine(1024);
2570 OString::number(nFontObject)
2572 "<</Type/Font/Subtype/Type3/Name/");
2573 appendName(aSubsetInfo.
m_aPSName, aLine);
2590 + OString::number(nScale)
2592 + OString::number(nScale)
2595 sal_Int32 pGlyphStreams[256] = {};
2596 aLine.append(
"/CharProcs<<\n");
2597 for (
auto i = 1u;
i < nGlyphs;
i++)
2603 + OString::number(nStream)
2605 pGlyphStreams[
i] = nStream;
2609 "/Encoding<</Type/Encoding/Differences[1");
2610 for (
auto i = 1u;
i < nGlyphs;
i++)
2611 aLine.append(
" /" + pFace->
GetGlyphName(pGlyphIds[
i],
true));
2612 aLine.append(
"]>>\n"
2616 + OString::number(nGlyphs)
2620 for (
auto i = 0
u;
i < nGlyphs;
i++)
2622 aLine.append(OString::number(pWidths[
i]) +
" ");
2624 aLine.append(
"]\n");
2628 aLine.append(
"/FontDescriptor " + OString::number(nFontDescriptor) +
" 0 R\n");
2632 aLine.append(
"/Resources " + OString::number(nResources) +
" 0 R\n");
2634 if (nToUnicodeStream)
2636 aLine.append(
"/ToUnicode " + OString::number(nToUnicodeStream) +
" 0 R\n");
2645 std::set<sal_Int32> aUsedFonts;
2646 std::list<BitmapEmit> aUsedBitmaps;
2647 std::map<sal_uInt8, sal_Int32> aUsedAlpha;
2649 std::list<StreamRedirect> aOutputStreams;
2652 double fScaleX =
GetDPIX() / 72.;
2653 double fScaleY =
GetDPIY() / 72.;
2655 for (
auto i = 1u;
i < nGlyphs;
i++)
2657 auto nStream = pGlyphStreams[
i];
2660 OStringBuffer aContents(1024);
2661 aContents.append(OString::number(pWidths[
i]) +
" 0 d0\n");
2663 const auto& rGlyph = rSubset.
m_aMapping.find(pGlyphIds[
i])->second;
2664 const auto& rLayers = rGlyph.getColorLayers();
2665 for (
const auto& rLayer : rLayers)
2667 aUsedFonts.insert(rLayer.m_nFontID);
2669 aContents.append(
"q ");
2671 if (rLayer.m_nColorIndex != 0xFFFF)
2673 auto& rPalette = rColorPalettes[0];
2674 auto aColor(rPalette[rLayer.m_nColorIndex]);
2676 aContents.append(
" ");
2677 if (aColor.GetAlpha() != 0xFF
2680 auto nAlpha = aColor.GetAlpha();
2681 OStringBuffer
aName(16);
2683 appendHex(nAlpha,
aName);
2685 aContents.append(
"/" +
aName +
" gs ");
2687 if (aUsedAlpha.find(nAlpha) == aUsedAlpha.end())
2690 aUsedAlpha[nAlpha] = nObject;
2692 nObject, aResourceDict, aOutputStreams);
2698 "/F" + OString::number(rLayer.m_nFontID) +
" "
2699 + OString::number(pFace->
UnitsPerEm()) +
" Tf "
2701 appendHex(rLayer.m_nSubsetGlyphID, aContents);
2709 const auto& rBitmapData = rGlyph.getColorBitmap(aRect);
2710 if (!rBitmapData.empty())
2712 SvMemoryStream aStream(
const_cast<uint8_t*
>(rBitmapData.data()), rBitmapData.size(),
2716 aUsedBitmaps, aResourceDict, aOutputStreams);
2718 auto nObject = aBitmapEmit.m_aReferenceXObject.getObject();
2721 + OString::number(aRect.
GetWidth())
2725 + OString::number(aRect.
getX())
2727 + OString::number(aRect.
getY())
2730 + OString::number(nObject)
2734 const auto& rOutline = rGlyph.getOutline();
2735 if (rOutline.count())
2737 aContents.append(
"q ");
2738 appendDouble(fScaleX, aContents);
2739 aContents.append(
" 0 0 ");
2740 appendDouble(fScaleY, aContents);
2741 aContents.append(
" 0 ");
2742 appendDouble(
m_aPages.back().getHeight() * -fScaleY, aContents, 3);
2743 aContents.append(
" cm\n");
2744 m_aPages.back().appendPolyPolygon(rOutline, aContents);
2745 aContents.append(
"f\n"
2750 aLine.append(OString::number(nStream)
2751 +
" 0 obj\n<</Length "
2752 + OString::number(aContents.getLength())
2759 aLine.append(
"endstream\nendobj\n\n");
2765 sal_Int32 nFontDict = 0;
2766 if (!aUsedFonts.empty())
2770 aLine.append(OString::number(nFontDict) +
" 0 obj\n<<");
2771 for (
auto nFontID : aUsedFonts)
2774 + OString::number(nFontID)
2776 + OString::number(rFontIDToObject[nFontID])
2779 aLine.append(
">>\nendobj\n\n");
2787 if (!aUsedAlpha.empty())
2789 for (
const auto & [ nAlpha, nObject ] : aUsedAlpha)
2792 aLine.append(OString::number(nObject) +
" 0 obj\n<<");
2795 aLine.append(
"/CA 1.0/ca 1.0");
2800 aLine.append(
"/CA ");
2801 appendDouble(nAlpha / 255., aLine);
2802 aLine.append(
"/ca ");
2803 appendDouble(nAlpha / 255., aLine);
2805 aLine.append(
">>\nendobj\n\n");
2814 for (
auto& aBitmap : aUsedBitmaps)
2819 aLine.append(OString::number(nResources) +
" 0 obj\n");
2820 aResourceDict.
append(aLine, nFontDict);
2821 aLine.append(
"endobj\n\n");
2827 rFontIDToObject[rSubset.
m_nFontID] = nFontObject;
2837 if( !pFontBytes || (nByteLen < 0) )
2839 const unsigned char* pPtr = pFontBytes;
2840 const unsigned char* pEnd = pFontBytes + nByteLen;
2842 for(
int & rSegmentLength : rSegmentLengths) {
2844 if( pPtr+6 >= pEnd )
2846 if( (pPtr[0] != 0x80) || (pPtr[1] >= 0x03) )
2848 const int nLen = (pPtr[5]<<24) + (pPtr[4]<<16) + (pPtr[3]<<8) + pPtr[2];
2851 rSegmentLength = nLen;
2856 if( pPtr+2 >= pEnd )
2858 if( (pPtr[0] != 0x80) || (pPtr[1] != 0x03) )
2864static void appendSubsetName(
int nSubsetID, std::u16string_view rPSName, OStringBuffer& rBuffer )
2868 for(
int i = 0;
i < 6;
i++ )
2870 int nOffset = nSubsetID % 26;
2872 rBuffer.append(
static_cast<char>(
'A'+nOffset) );
2874 rBuffer.append(
'+' );
2876 appendName( rPSName, rBuffer );
2880 const std::vector<sal_Ucs>& rCodeUnits,
2881 const sal_Int32* pCodeUnitsPerGlyph,
2882 const sal_Int32* pEncToUnicodeIndex,
2886 for (
auto n = 0
u;
n < nGlyphs; ++
n)
2887 if (pCodeUnitsPerGlyph[
n] && rCodeUnits[pEncToUnicodeIndex[
n]])
2896 OStringBuffer aContents( 1024 );
2898 "/CIDInit/ProcSet findresource begin\n"
2901 "/CIDSystemInfo<<\n"
2902 "/Registry (Adobe)\n"
2906 "/CMapName/Adobe-Identity-UCS def\n"
2908 "1 begincodespacerange\n"
2910 "endcodespacerange\n"
2913 for (
auto n = 0
u;
n < nGlyphs; ++
n)
2915 if (pCodeUnitsPerGlyph[
n] && rCodeUnits[pEncToUnicodeIndex[
n]])
2917 if( (
nCount % 100) == 0 )
2920 aContents.append(
"endbfchar\n" );
2921 aContents.append( OString::number(
static_cast<sal_Int32
>(std::min(nMapped-
nCount, 100)) )
2922 +
" beginbfchar\n" );
2924 aContents.append(
'<' );
2925 appendHex(
static_cast<sal_Int8>(pEncoding[
n]), aContents );
2926 aContents.append(
"> <" );
2928 sal_Int32
nIndex = pEncToUnicodeIndex[
n];
2929 for( sal_Int32 j = 0; j < pCodeUnitsPerGlyph[
n]; j++ )
2931 appendHex(
static_cast<sal_Int8>(rCodeUnits[
nIndex + j] / 256), aContents );
2932 appendHex(
static_cast<sal_Int8>(rCodeUnits[
nIndex + j] & 255), aContents );
2934 aContents.append(
">\n" );
2938 aContents.append(
"endbfchar\n"
2940 "CMapName currentdict /CMap defineresource pop\n"
2946 ZCodec aCodec( 0x4000, 0x4000 );
2948 aCodec.
Write( aStream,
reinterpret_cast<const sal_uInt8*
>(aContents.getStr()), aContents.getLength() );
2954 emitComment(
"PDFWriterImpl::createToUnicodeCMap" );
2956 OStringBuffer aLine( 40 );
2958 aLine.append( OString::number(nStream ) +
" 0 obj\n<</Length " );
2962 nLen =
static_cast<sal_Int32
>(aStream.
Tell());
2964 aLine.append( OString::number(nLen) +
"/Filter/FlateDecode" );
2967 aLine.append( aContents.getLength() );
2968 aLine.append(
">>\nstream\n" );
2980 aLine.setLength( 0 );
2981 aLine.append(
"\nendstream\n"
2989 OStringBuffer aLine( 1024 );
2993 sal_Int32 nFontFlags = (1<<2);
2995 nFontFlags |= (1 << 6);
2999 nFontFlags |= (1 << 3);
3001 nFontFlags |= (1 << 1);
3005 aLine.setLength( 0 );
3007 OString::number(nFontDescriptor)
3009 "<</Type/FontDescriptor/FontName/" );
3013 + OString::number( nFontFlags )
3019 + OString::number(
static_cast<sal_Int32
>(rInfo.
m_aFontBBox.
Top()) )
3024 +
"]/ItalicAngle " );
3026 aLine.append(
"-30" );
3028 aLine.append(
"0" );
3031 + OString::number(
static_cast<sal_Int32
>(rInfo.
m_nAscent) )
3034 + OString::number(
static_cast<sal_Int32
>(-rInfo.
m_nDescent) )
3037 + OString::number(
static_cast<sal_Int32
>(rInfo.
m_nCapHeight) )
3044 aLine.append(
"/FontFile" );
3048 aLine.append(
'2' );
3055 OSL_FAIL(
"unknown fonttype in PDF font descriptor" );
3058 aLine.append(
" " + OString::number(nFontStream) +
" 0 R\n" );
3060 aLine.append(
">>\n"
3064 return nFontDescriptor;
3072 rDict.append(
' ' );
3073 rDict.append( item.second );
3074 rDict.append(
" 0 R" );
3080 OStringBuffer aLine( 1024 );
3082 std::map< sal_Int32, sal_Int32 > aFontIDToObject;
3086 for (
auto & s_subset :subset.second.m_aSubsets)
3089 sal_Int32 pWidths[ 256 ];
3091 sal_Int32 pEncToUnicodeIndex[ 256 ] = {};
3092 sal_Int32 pCodeUnitsPerGlyph[ 256 ] = {};
3093 std::vector<sal_Ucs> aCodeUnits;
3094 sal_Int32 nToUnicodeStream = 0;
3097 auto nGlyphs = fillSubsetArrays(s_subset, pGlyphIds, pWidths, pEncoding, pEncToUnicodeIndex,
3098 pCodeUnitsPerGlyph, aCodeUnits, nToUnicodeStream);
3100 std::vector<sal_uInt8>
aBuffer;
3102 const auto* pFace = subset.first;
3103 if (pFace->CreateFontSubset(
aBuffer, pGlyphIds, pEncoding, nGlyphs, aSubsetInfo))
3113 aLine.setLength( 0 );
3114 aLine.append( OString::number(nFontStream)
3117 + OString::number( nStreamLengthObject ) );
3119 aLine.append(
" 0 R"
3120 "/Filter/FlateDecode"
3123 aLine.append(
" 0 R"
3126 sal_uInt64 nStartPos = 0;
3129 aLine.append( OString::number(
static_cast<sal_Int32
>(
aBuffer.size()))
3133 if ( osl::File::E_None !=
m_aFile.getPos(nStartPos) )
return false;
3144 OSL_FAIL(
"PDFWriterImpl does not support CFF-font subsets yet!" );
3153 aLine.append( OString::number(
static_cast<sal_Int32
>(aSegmentLengths[0]) )
3155 + OString::number(
static_cast<sal_Int32
>(aSegmentLengths[1]) )
3157 + OString::number(
static_cast<sal_Int32
>(aSegmentLengths[2]) )
3161 if ( osl::File::E_None !=
m_aFile.getPos(nStartPos) )
return false;
3168 if ( !
writeBufferBytes( &
aBuffer[18] + aSegmentLengths[0] + aSegmentLengths[1], aSegmentLengths[2] ) )
return false;
3172 SAL_INFO(
"vcl.pdfwriter",
"PDF: CreateFontSubset result in not yet supported format=" <<
static_cast<int>(aSubsetInfo.
m_nFontType));
3173 aLine.append(
"0 >>\nstream\n" );
3179 sal_uInt64 nEndPos = 0;
3180 if ( osl::File::E_None !=
m_aFile.getPos(nEndPos) )
return false;
3182 aLine.setLength( 0 );
3183 aLine.append(
"\nendstream\nendobj\n\n" );
3187 if ( !
updateObject( nStreamLengthObject ) )
return false;
3188 aLine.setLength( 0 );
3189 aLine.append( OString::number(nStreamLengthObject)
3191 + OString::number(
static_cast<sal_Int64
>(nEndPos-nStartPos) )
3196 sal_Int32 nFontDescriptor =
emitFontDescriptor( subset.first, aSubsetInfo, s_subset.m_nFontID, nFontStream );
3198 if( nToUnicodeStream )
3199 nToUnicodeStream =
createToUnicodeCMap( pEncoding, aCodeUnits, pCodeUnitsPerGlyph, pEncToUnicodeIndex, nGlyphs );
3203 aLine.setLength( 0 );
3204 aLine.append( OString::number(nFontObject) +
" 0 obj\n" );
3206 "<</Type/Font/Subtype/Type1/BaseFont/" :
3207 "<</Type/Font/Subtype/TrueType/BaseFont/" );
3212 + OString::number(
static_cast<sal_Int32
>(nGlyphs-1) )
3215 for (
auto i = 0
u;
i < nGlyphs;
i++)
3217 aLine.append( pWidths[
i ] );
3218 aLine.append( ((
i & 15) == 15) ?
"\n" :
" " );
3222 + OString::number( nFontDescriptor )
3224 if( nToUnicodeStream )
3226 aLine.append(
"/ToUnicode "
3227 + OString::number( nToUnicodeStream )
3230 aLine.append(
">>\n"
3234 aFontIDToObject[ s_subset.m_nFontID ] = nFontObject;
3238 OStringBuffer aErrorComment( 256 );
3239 aErrorComment.append(
"CreateFontSubset failed for font \""
3243 aErrorComment.append(
" italic" );
3245 aErrorComment.append(
" oblique" );
3246 aErrorComment.append(
" weight=" + OString::number( sal_Int32(pFace->GetWeight()) ) );
3255 std::map< sal_Int32, sal_Int32 > aObjects =
emitSystemFont( systemFont.first, systemFont.second );
3256 for (
auto const& item : aObjects)
3258 if ( !item.second )
return false;
3259 aFontIDToObject[ item.first ] = item.second;
3270 OStringBuffer aFontDict( 1024 );
3275 for (
auto const& itemMap : aFontIDToObject)
3277 aFontDict.append(
"/F"
3278 + OString::number( itemMap.first )
3280 + OString::number( itemMap.second )
3282 if( ((++ni) & 7) == 0 )
3283 aFontDict.append(
'\n' );
3293 aFontDict.append(
"\n>>\nendobj\n\n" );
3313 OStringBuffer aLine( 512 );
3316 aLine.setLength( 0 );
3317 aLine.append( OString::number(nResourceDict)
3320 aLine.append(
"endobj\n\n" );
3322 return nResourceDict;
3326 sal_Int32 nItemLevel,
3327 sal_Int32 nCurrentItemId )
3344 for( sal_Int32
i = 0;
i < nChildren;
i++ )
3346 rCounts[nCurrentItemId] =
nCount;
3357 rCounts[ nCurrentItemId ] = -sal_Int32(rItem.
m_aChildren.size());
3358 for( sal_Int32
i = 0;
i < nChildren;
i++ )
3375 for(
i = 0;
i < nItems; ++
i )
3379 for(
i = 0;
i < nItems; ++
i )
3386 for(
int n = 0;
n < nChildren; ++
n )
3399 std::vector< sal_Int32 > aCounts( nItems );
3403 for(
i = 0;
i < nItems; ++
i )
3406 OStringBuffer aLine( 1024 );
3409 aLine.append( OString::number(rItem.
m_nObject)
3413 if(
i > 0 || aCounts[0] > 0 )
3415 aLine.append(
"/Count " + OString::number( aCounts[
i] ) );
3420 aLine.append(
"/First "
3429 aLine.append(
"/Title" );
3431 aLine.append(
"\n" );
3435 aLine.append(
"/Dest" );
3438 aLine.append(
"/Parent "
3443 aLine.append(
"/Prev "
3449 aLine.append(
"/Next "
3454 aLine.append(
">>\nendobj\n\n" );
3462#define CHECK_RETURN( x ) if( !x ) return false
3468 SAL_INFO(
"vcl.pdfwriter",
"ERROR: invalid dest " <<
static_cast<int>(nDestID) <<
" requested");
3475 rBuffer.append(
'[' );
3477 rBuffer.append(
" 0 R" );
3483 rBuffer.append(
"/XYZ " );
3485 rBuffer.append(
' ' );
3487 rBuffer.append(
" 0" );
3490 rBuffer.append(
"/FitR " );
3492 rBuffer.append(
' ' );
3493 appendFixedInt( rDest.
m_aRect.
Top(), rBuffer );
3494 rBuffer.append(
' ' );
3496 rBuffer.append(
' ' );
3500 rBuffer.append(
']' );
3509 rAttachedFile.maFilename = rFileName;
3510 rAttachedFile.maMimeType = rMimeType;
3511 rAttachedFile.maDescription = rDescription;
3512 rAttachedFile.mnEmbeddedFileObjectId = nObjectID;
3520 rEmbedded.m_nObject = aObjectID;
3521 rEmbedded.m_aSubType = rMimeType;
3522 rEmbedded.m_pStream = std::move(rStream);
3538 for (
int i = 0;
i < nAnnots;
i++)
3542 OStringBuffer aLine;
3543 bool bEmbed =
false;
3555 aLine.append(
" 0 obj\n");
3556 aLine.append(
"<< /Type /EmbeddedFile /Length ");
3557 aLine.append(
static_cast<sal_Int64
>(aMemoryStream.
GetSize()));
3558 aLine.append(
" >>\nstream\n");
3564 aLine.append(
"\nendstream\nendobj\n\n");
3573 aLine.append(OString::number(rScreen.
m_nObject)
3576 "/Subtype/Screen/Rect[");
3579 appendFixedInt(rScreen.
m_aRect.
Top(), aLine);
3587 aLine.append(
"/A<</Type/Action /S/Rendition /AN "
3592 aLine.append(
"/R<</Type/Rendition /S/MR ");
3595 aLine.append(
"/C<</Type/MediaClip /S/MCD ");
3598 aLine.append(
"\n/D << /Type /Filespec /F (<embedded file>) ");
3601 aLine.append(
"/UF (<embedded file>) ");
3603 aLine.append(
"/EF << /F ");
3605 aLine.append(
" 0 R >>");
3610 aLine.append(
"\n/D << /Type /Filespec /FS /URL /F ");
3614 aLine.append(
"/UF ");
3621 aLine.append(
"/Desc ");
3624 aLine.append(
" >>\n");
3626 aLine.append(
"/P <</TF (TEMPACCESS)>>");
3628 aLine.append(
"/CT ");
3632 aLine.append(
" /Alt [ () ");
3638 aLine.append(
"/P<</BE<</C true >>>>"
3642 aLine.append(
"/OP 0 >>");
3646 aLine.append(
"\n/StructParent "
3654 +
" 0 R\n>>\nendobj\n\n");
3663 MARK(
"PDFWriterImpl::emitLinkAnnotations");
3665 for(
int i = 0;
i < nAnnots;
i++ )
3671 OStringBuffer aLine( 1024 );
3673 aLine.append(
" 0 obj\n" );
3676 aLine.append(
"<</Type/Annot" );
3678 aLine.append(
"/F 4" );
3679 aLine.append(
"/Subtype/Link/Border[0 0 0]/Rect[" );
3682 aLine.append(
' ' );
3683 appendFixedInt( rLink.
m_aRect.
Top(), aLine );
3684 aLine.append(
' ' );
3686 aLine.append(
' ' );
3688 aLine.append(
"]" );
3690 aLine.append(
"/Contents");
3694 aLine.append(
"/Dest" );
3725 bool bSetGoToRMode =
false;
3726 bool bTargetHasPDFExtension =
false;
3728 bool bIsUNCPath =
false;
3729 bool bUnparsedURI =
false;
3734 if( eTargetProtocol == INetProtocol::NotValid )
3736 if( url.getLength() > 4 && url.startsWith(
"\\\\\\\\"))
3746 u"http://ahost.ax"),
3754 bUnparsedURI = eTargetProtocol == INetProtocol::NotValid;
3758 OUString aFileExtension =
aTargetURL.GetFileExtension();
3766 if( !aFileExtension.isEmpty() )
3770 bool bChangeFileExtensionToPDF =
false;
3772 if( aFileExtension.equalsIgnoreAsciiCase(
"odm" ) )
3773 bChangeFileExtensionToPDF =
true;
3774 if( aFileExtension.equalsIgnoreAsciiCase(
"odt" ) )
3775 bChangeFileExtensionToPDF =
true;
3776 else if( aFileExtension.equalsIgnoreAsciiCase(
"odp" ) )
3777 bChangeFileExtensionToPDF =
true;
3778 else if( aFileExtension.equalsIgnoreAsciiCase(
"odg" ) )
3779 bChangeFileExtensionToPDF =
true;
3780 else if( aFileExtension.equalsIgnoreAsciiCase(
"ods" ) )
3781 bChangeFileExtensionToPDF =
true;
3782 if( bChangeFileExtensionToPDF )
3786 bTargetHasPDFExtension =
aTargetURL.GetFileExtension().equalsIgnoreAsciiCase(
"pdf" );
3788 bSetGoToRMode =
true;
3793 aLine.append(
"/A<</Type/Action/S");
3796 aLine.append(
"/Launch/Win<</F" );
3799 aLine.append(
">>" );
3803 bool bSetRelative =
false;
3804 bool bFileSpec =
false;
3806 if(
m_aContext.
RelFsys && eBaseProtocol == eTargetProtocol && eTargetProtocol == INetProtocol::File )
3807 bSetRelative =
true;
3810 if( !bSetGoToRMode )
3817 aLine.append(
"/URI/URI" );
3827 if( (!aFragment.isEmpty() && !bTargetHasPDFExtension) ||
3828 eTargetProtocol != INetProtocol::File )
3830 aLine.append(
"/URI/URI" );
3834 aLine.append(
"/Launch/F" );
3846 aLine.append(
"/GoToR");
3851 aURLNoMark, rLink.
m_nObject, aLine, osl_getThreadTextEncoding() );
3852 if( !aFragment.isEmpty() )
3854 aLine.append(
"/D/");
3855 appendDestinationName( aFragment , aLine );
3863 bTargetHasPDFExtension && !aFragment.isEmpty() )
3865 OStringBuffer aLineLoc( 1024 );
3866 appendDestinationName( aFragment , aLineLoc );
3868 aTargetURL.SetMark( OStringToOUString(aLineLoc, RTL_TEXTENCODING_ASCII_US) );
3870 OUString
aURL = bUnparsedURI ? url :
3877 aURL , rLink.
m_nObject, aLine, osl_getThreadTextEncoding() );
3880 aLine.append(
">>\n" );
3884 aLine.append(
"/StructParent " );
3887 aLine.append(
">>\nendobj\n\n" );
3897void appendAnnotationRect(
tools::Rectangle const & rRectangle, OStringBuffer & aLine)
3899 aLine.append(
"/Rect[");
3900 appendFixedInt(rRectangle.
Left(), aLine);
3902 appendFixedInt(rRectangle.
Top(), aLine);
3904 appendFixedInt(rRectangle.
Right(), aLine);
3906 appendFixedInt(rRectangle.
Bottom(), aLine);
3916 aLine.append(
"<</Type /Annot /Subtype ");
3920 aLine.append(rPolygon.isClosed() ?
"/Polygon " :
"/Polyline ");
3921 aLine.append(
"/Vertices [");
3922 for (sal_uInt32
i = 0;
i < rPolygon.count(); ++
i)
3928 aLine, nLog10Divisor);
3932 aLine.append(
"/C [");
3935 if (rPolygon.isClosed())
3937 aLine.append(
"/IC [");
3944 aLine.append(
"/Ink /InkList [");
3948 for (sal_uInt32
i = 0;
i < rPolygon.count(); ++
i)
3955 aLine, nLog10Divisor);
3959 aLine.append(
"/C [");
3966 aLine.append(
"/FreeText ");
3968 aLine.append(
"/Text ");
3970 aLine.append(
"/BS<</W 0>>");
3975 aLine.append(
"/F 4 ");
3977 appendAnnotationRect(rNote.
m_aRect, aLine);
3979 aLine.append(
"/Popup ");
3984 aLine.append(
"/M (");
3985 appendPdfTimeDate(aLine, rDateTime.Year, rDateTime.Month, rDateTime.Day, rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, 0);
3989 aLine.append(
"/Contents ");
3996 aLine.append(
"/T ");
4000 aLine.append(
">>\n");
4001 aLine.append(
"endobj\n\n");
4006 appendObjectID(rPopUp.
m_nObject, aLine);
4007 aLine.append(
"<</Type /Annot /Subtype /Popup ");
4008 aLine.append(
"/Parent ");
4010 aLine.append(
">>\n");
4011 aLine.append(
"endobj\n\n");
4018 for(
int i = 0;
i < nAnnots;
i++ )
4027 OStringBuffer aLine(1024);
4040 OStringBuffer aLine(1024);
4053 bool bAdjustSize =
false;
4055 Font aFont( rControlFont );
4058 aFont = rAppSetFont;
4085 sal_Int32 nBest = 4;
4094 aFontName = aFontName.toAsciiLowerCase();
4096 if( aFontName.indexOf(
"times" ) != -1 )
4098 else if( aFontName.indexOf(
"courier" ) != -1 )
4100 else if( aFontName.indexOf(
"dingbats" ) != -1 )
4102 else if( aFontName.indexOf(
"symbol" ) != -1 )
4149 OStringBuffer aDA( 256 );
4157 aDA.append(
" Tf" );
4176 rButton.
m_aMKDict =
"/BC [] /BG [] /CA";
4190 sal_Int32 nDelta =
GetDPIX() / 500;
4243 OStringBuffer aDA( 32 );
4248 OStringBuffer aDR( 32 );
4249 aDR.append(
"/Font " );
4251 aDR.append(
" 0 R" );
4252 rEdit.
m_aDRDict = aDR.makeStringAndClear();
4255 aDA.append(
" Tf" );
4301 OStringBuffer aDA( 256 );
4306 aDA.append( nBest );
4308 OStringBuffer aDR( 32 );
4309 aDR.append(
"/Font " );
4311 aDR.append(
" 0 R" );
4312 rBox.
m_aDRDict = aDR.makeStringAndClear();
4315 aDA.append(
" Tf" );
4338 sal_Int32 nDelta = aFontSize.
Height()/10;
4364 OStringBuffer aLW( 32 );
4367 aLW.append(
" w " );
4376 OStringBuffer aDA( 256 );
4390 const auto nGlyphWidth = pFontInstance->
GetGlyphWidth(nGlyphId,
false,
false);
4393 sal_Int32 nMappedFontObject;
4394 registerGlyph(nGlyphId, pFace, pFontInstance, { cMark }, nGlyphWidth, nMappedGlyph, nMappedFontObject);
4399 aDA.append( nMappedFontObject );
4400 aDA.append(
" 0 Tf" );
4402 OStringBuffer aDR( 32 );
4403 aDR.append(
"/Font " );
4405 aDR.append(
" 0 R" );
4406 rBox.
m_aDRDict = aDR.makeStringAndClear();
4413 sal_Int32 nCharXOffset = 1000 - 787;
4415 nCharXOffset /= 2000;
4416 sal_Int32 nCharYOffset = 1000 - (820-143);
4418 nCharYOffset /= 2000;
4423 aDA.append(
"/Tx BMC\nq BT\n" );
4427 aDA.append( nMappedFontObject );
4430 aDA.append(
" Tf\n" );
4434 aDA.append(
" Td <" );
4435 appendHex( nMappedGlyph, aDA );
4436 aDA.append(
"> Tj\nET\nQ\nEMC\n" );
4468 sal_Int32 nDelta = aFontSize.
Height()/10;
4494 OStringBuffer aLW( 32 );
4497 aLW.append(
" w " );
4518 OStringBuffer aDA( 256 );
4519 aDA.append(
"/Tx BMC\nq BT\n" );
4523 aDA.append(
" 0 0 Td\nET\nQ\n" );
4548 OString aStandardAppearance;
4560 rAnnotDict.append(
"/AP<<\n" );
4563 rAnnotDict.append(
"/" );
4564 rAnnotDict.append( dict_item.first );
4565 bool bUseSubDict = (dict_item.second.size() > 1);
4579 rAnnotDict.append( bUseSubDict ?
"<<" :
" " );
4581 for (
auto const& stream_item : dict_item.second)
4584 dict_item.second[ stream_item.first ] =
nullptr;
4588 sal_Int64 nStreamLen = pAppearanceStream->
TellEnd();
4596 OStringBuffer aLine;
4597 aLine.append( nObject );
4599 aLine.append(
" 0 obj\n"
4604 aLine.append(
" " );
4609 aLine.append(
" 0 R\n"
4611 aLine.append( nStreamLen );
4612 aLine.append(
"\n" );
4614 aLine.append(
"/Filter/FlateDecode\n" );
4615 aLine.append(
">>\nstream\n" );
4624 rAnnotDict.append(
" /" );
4625 rAnnotDict.append( stream_item.first );
4626 rAnnotDict.append(
" " );
4628 rAnnotDict.append( nObject );
4629 rAnnotDict.append(
" 0 R" );
4631 delete pAppearanceStream;
4634 rAnnotDict.append( bUseSubDict ?
">>\n" :
"\n" );
4636 rAnnotDict.append(
">>\n" );
4637 if( !aStandardAppearance.isEmpty() )
4639 rAnnotDict.append(
"/AS /" );
4640 rAnnotDict.append( aStandardAppearance );
4641 rAnnotDict.append(
"\n" );
4653 for(
int a = 0;
a < nAnnots;
a++ )
4664 auto stream_it = app_it->second.find(
"Yes" );
4665 if( stream_it != app_it->second.end() )
4668 app_it->second.erase( stream_it );
4671 (app_it->second)[
aBuf.makeStringAndClear() ] = pStream;
4674 SAL_INFO(
"vcl.pdfwriter",
"error: CheckBox without \"Yes\" stream" );
4683 auto stream_it = app_it->second.find(
"Off" );
4684 if( stream_it != app_it->second.end() )
4687 app_it->second.erase( stream_it );
4690 (app_it->second)[
aBuf.makeStringAndClear() ] = pStream;
4693 SAL_INFO(
"vcl.pdfwriter",
"error: CheckBox without \"Off\" stream" );
4698 OStringBuffer aLine( 1024 );
4699 OStringBuffer aValue( 256 );
4701 aLine.append(
" 0 obj\n"
4710 aLine.append(
"/Type/Annot/Subtype/Widget/F " );
4714 aLine.append(
"132\n" );
4719 aLine.append(
"4\n" );
4725 aLine.append(
"/StructParent ");
4730 aLine.append(
"/Rect[" );
4731 appendFixedInt( rWidget.
m_aRect.
Left()-iRectMargin, aLine );
4732 aLine.append(
' ' );
4733 appendFixedInt( rWidget.
m_aRect.
Top()+iRectMargin, aLine );
4734 aLine.append(
' ' );
4735 appendFixedInt( rWidget.
m_aRect.
Right()+iRectMargin, aLine );
4736 aLine.append(
' ' );
4737 appendFixedInt( rWidget.
m_aRect.
Bottom()-iRectMargin, aLine );
4738 aLine.append(
"]\n" );
4740 aLine.append(
"/FT/" );
4752 aValue.append(
"/" );
4755 aValue.append(
"Off" );
4757 appendName( rWidget.
m_aValue, aValue );
4761 aLine.append(
"Btn" );
4766 aValue.append(
"[" );
4774 aValue.append(
"]" );
4784 aLine.append(
"Ch" );
4788 aLine.append(
"Ch" );
4791 aLine.append(
"Tx" );
4795 aLine.append(
"Sig" );
4801 aLine.append(
"\n" );
4802 aLine.append(
"/P " );
4804 aLine.append(
" 0 R\n" );
4808 aLine.append(
"/Parent " );
4810 aLine.append(
" 0 R\n" );
4812 if( !rWidget.
m_aKids.empty() )
4814 aLine.append(
"/Kids[" );
4815 for(
size_t i = 0;
i < rWidget.
m_aKids.size();
i++ )
4817 aLine.append( rWidget.
m_aKids[
i] );
4818 aLine.append(
" 0 R" );
4819 aLine.append( ( (
i&15) == 15 ) ?
"\n" :
" " );
4821 aLine.append(
"]\n" );
4823 if( !rWidget.
m_aName.isEmpty() )
4825 aLine.append(
"/T" );
4827 aLine.append(
"\n" );
4833 aLine.append(
"/TU" );
4835 aLine.append(
"\n" );
4840 aLine.append(
"/Ff " );
4842 aLine.append(
"\n" );
4844 if( !aValue.isEmpty() )
4846 OString aVal = aValue.makeStringAndClear();
4847 aLine.append(
"/V " );
4848 aLine.append( aVal );
4851 aLine.append( aVal );
4852 aLine.append(
"\n" );
4857 aLine.append(
"/Opt[\n" );
4862 aLine.append(
"\n" );
4867 aLine.append(
"]\n" );
4870 aLine.append(
"/TI " );
4871 aLine.append( nTI );
4872 aLine.append(
"\n" );
4875 aLine.append(
"/I [" );
4876 aLine.append( nTI );
4877 aLine.append(
"]\n" );
4885 aLine.append(
"/MaxLen " );
4887 aLine.append(
"\n" );
4898 aHexText =
"\\\\u" + OString::number(cChar, 16);
4901 aLine.append(
"/AA<<\n");
4902 aLine.append(
"/F<</JS(AFNumber_Format\\(");
4904 aLine.append(
", 0, 0, 0, \"");
4905 aLine.append( aHexText );
4906 aLine.append(
"\",");
4908 aLine.append(
"\\);)");
4909 aLine.append(
"/S/JavaScript>>\n");
4910 aLine.append(
"/K<</JS(AFNumber_Keystroke\\(");
4912 aLine.append(
", 0, 0, 0, \"");
4913 aLine.append( aHexText );
4914 aLine.append(
"\",");
4916 aLine.append(
"\\);)");
4917 aLine.append(
"/S/JavaScript>>\n");
4918 aLine.append(
">>\n");
4922 aLine.append(
"/AA<<\n");
4923 aLine.append(
"/F<</JS(AFTime_FormatEx\\(\"");
4925 aLine.append(
"\"\\);)");
4926 aLine.append(
"/S/JavaScript>>\n");
4927 aLine.append(
"/K<</JS(AFTime_KeystrokeEx\\(\"");
4929 aLine.append(
"\"\\);)");
4930 aLine.append(
"/S/JavaScript>>\n");
4931 aLine.append(
">>\n");
4935 aLine.append(
"/AA<<\n");
4936 aLine.append(
"/F<</JS(AFDate_FormatEx\\(\"");
4938 aLine.append(
"\"\\);)");
4939 aLine.append(
"/S/JavaScript>>\n");
4940 aLine.append(
"/K<</JS(AFDate_KeystrokeEx\\(\"");
4942 aLine.append(
"\"\\);)");
4943 aLine.append(
"/S/JavaScript>>\n");
4944 aLine.append(
">>\n");
4951 OStringBuffer aDest;
4954 aLine.append(
"/AA<</D<</Type/Action/S/GoTo/D " );
4955 aLine.append( aDest );
4956 aLine.append(
">>>>\n" );
4963 aLine.append(
"/AA<</D<</Type/Action/S/ResetForm>>>>\n" );
4969 aLine.append(
"/AA<</D<</Type/Action/S/SubmitForm/F" );
4971 aLine.append(
"/Flags " );
4973 sal_Int32 nFlags = 0;
4991 aLine.append( nFlags );
4992 aLine.append(
">>>>\n" );
4997 aLine.append(
"/AA<</D<</Type/Action/S/URI/URI(" );
4999 aLine.append(
")>>>>\n" );
5009 aLine.append(
"/DR<<" );
5011 aLine.append(
">>\n" );
5015 aLine.append(
"/DR<</Font<<" );
5017 aLine.append(
">>>>\n" );
5019 aLine.append(
"/DA" );
5021 aLine.append(
"\n" );
5023 aLine.append(
"/Q 1\n" );
5025 aLine.append(
"/Q 2\n" );
5032 aLine.append(
"/MK<<" );
5036 aLine.append(
">>\n" );
5041 aLine.append(
">>\n"
5062class PDFStreamIf :
public cppu::WeakImplHelper< css::io::XOutputStream >
5069 virtual void SAL_CALL
writeBytes(
const css::uno::Sequence< sal_Int8 >& aData )
override
5073 sal_Int32 nBytes =
aData.getLength();
5077 virtual void SAL_CALL
flush()
override {}
5094 OStringBuffer aLine;
5095 aLine.append(rEmbeddedFile.m_nObject);
5096 aLine.append(
" 0 obj\n");
5097 aLine.append(
"<< /Type /EmbeddedFile");
5098 if (!rEmbeddedFile.m_aSubType.isEmpty())
5100 aLine.append(
"/Subtype /");
5101 appendName(rEmbeddedFile.m_aSubType, aLine);
5103 aLine.append(
" /Length ");
5104 appendObjectReference(nSizeObject, aLine);
5105 aLine.append(
" /Params ");
5106 appendObjectReference(nParamsObject, aLine);
5107 aLine.append(
">>\nstream\n");
5114 if (!rEmbeddedFile.m_aDataContainer.isEmpty())
5116 nSize = rEmbeddedFile.m_aDataContainer.getSize();
5119 else if (rEmbeddedFile.m_pStream)
5123 rEmbeddedFile.m_pStream->write(
xStream);
5124 rEmbeddedFile.m_pStream.reset();
5128 aLine.append(
"\nendstream\nendobj\n\n");
5134 aLine.append(nSizeObject);
5135 aLine.append(
" 0 obj\n");
5136 aLine.append(nSize);
5137 aLine.append(
"\nendobj\n\n");
5144 aLine.append(nParamsObject);
5145 aLine.append(
" 0 obj\n");
5147 aLine.append(
"/Size ");
5148 aLine.append(nSize);
5150 aLine.append(
"\nendobj\n\n");
5158#define CHECK_RETURN( x ) if( !x ) return false
5173 if( ! page.emit( nTreeNode ) )
5186 sal_Int32 nStructureDict = 0;
5201 OStringBuffer aLine( 2048 );
5202 aLine.append( nTreeNode );
5203 aLine.append(
" 0 obj\n" );
5204 aLine.append(
"<</Type/Pages\n" );
5205 aLine.append(
"/Resources " );
5207 aLine.append(
" 0 R\n" );
5209 double nMediaBoxWidth = 0;
5210 double nMediaBoxHeight = 0;
5211 sal_Int32 nUserUnit = 1;
5221 if( page.m_nPageWidth > nMediaBoxWidth )
5223 nMediaBoxWidth = page.m_nPageWidth;
5224 nUserUnit = page.m_nUserUnit;
5226 if( page.m_nPageHeight > nMediaBoxHeight )
5228 nMediaBoxHeight = page.m_nPageHeight;
5229 nUserUnit = page.m_nUserUnit;
5233 aLine.append(
"/MediaBox[ 0 0 " );
5234 aLine.append(nMediaBoxWidth / nUserUnit);
5235 aLine.append(
' ' );
5236 aLine.append(nMediaBoxHeight / nUserUnit);
5237 aLine.append(
" ]\n");
5240 aLine.append(
"/UserUnit ");
5241 aLine.append(nUserUnit);
5244 aLine.append(
"/Kids[ ");
5248 aLine.append( page.m_nPageObject );
5249 aLine.append(
" 0 R" );
5250 aLine.append( ( (
i&15) == 15 ) ?
"\n" :
" " );
5255 aLine.append(
static_cast<sal_Int32
>(
m_aPages.size()) );
5256 aLine.append(
">>\n"
5269 aLine.setLength( 0 );
5271 appendObjectID(rAttachedFile.mnObjectId, aLine);
5272 aLine.append(
"<</Type /Filespec");
5273 aLine.append(
"/F<");
5278 aLine.append(
"/UF<");
5282 if (!rAttachedFile.maDescription.isEmpty())
5284 aLine.append(
"/Desc <");
5288 aLine.append(
"/EF <</F ");
5289 appendObjectReference(rAttachedFile.mnEmbeddedFileObjectId, aLine);
5291 aLine.append(
">>\nendobj\n\n");
5299 aLine.setLength( 0 );
5301 aLine.append(
" 0 obj\n"
5302 "<</Type/Catalog/Pages " );
5303 aLine.append( nTreeNode );
5304 aLine.append(
" 0 R\n" );
5307 if( nNamedDestinationsDictionary )
5309 aLine.append(
"/Dests ");
5310 aLine.append( nNamedDestinationsDictionary );
5311 aLine.append(
" 0 R\n" );
5316 aLine.append(
"/Names ");
5317 aLine.append(
"<</EmbeddedFiles <</Names [");
5324 appendObjectReference(rAttachedFile.mnObjectId, aLine);
5326 aLine.append(
"]>>>>");
5327 aLine.append(
"\n" );
5335 aLine.append(
"/PageLayout/SinglePage\n" );
5338 aLine.append(
"/PageLayout/OneColumn\n" );
5342 aLine.append(
"/PageLayout/TwoColumnRight\n" );
5349 aLine.append(
"/PageMode/UseNone\n" );
5352 aLine.append(
"/PageMode/UseOutlines\n" );
5355 aLine.append(
"/PageMode/UseThumbs\n" );
5359 aLine.append(
"/PageMode/FullScreen\n" );
5361 OStringBuffer aInitPageRef;
5365 aInitPageRef.append(
" 0 R" );
5368 aInitPageRef.append(
"0" );
5374 if( aInitPageRef.getLength() > 1 )
5376 aLine.append(
"/OpenAction[" );
5377 aLine.append( aInitPageRef );
5378 aLine.append(
" /XYZ null null 0]\n" );
5382 aLine.append(
"/OpenAction[" );
5383 aLine.append( aInitPageRef );
5384 aLine.append(
" /Fit]\n" );
5387 aLine.append(
"/OpenAction[" );
5388 aLine.append( aInitPageRef );
5389 aLine.append(
" /FitH " );
5391 aLine.append(
"]\n" );
5394 aLine.append(
"/OpenAction[" );
5395 aLine.append( aInitPageRef );
5396 aLine.append(
" /FitBH " );
5398 aLine.append(
"]\n" );
5401 aLine.append(
"/OpenAction[" );
5402 aLine.append( aInitPageRef );
5403 aLine.append(
" /XYZ null null " );
5407 aLine.append(
"0" );
5408 aLine.append(
"]\n" );
5420 aLine.append(
"/ViewerPreferences<<" );
5422 aLine.append(
"/HideToolbar true\n" );
5424 aLine.append(
"/HideMenubar true\n" );
5426 aLine.append(
"/HideWindowUI true\n" );
5428 aLine.append(
"/FitWindow true\n" );
5430 aLine.append(
"/CenterWindow true\n" );
5432 aLine.append(
"/DisplayDocTitle true\n" );
5434 aLine.append(
"/Direction/R2L\n" );
5440 aLine.append(
"/NonFullScreenPageMode/UseNone\n" );
5443 aLine.append(
"/NonFullScreenPageMode/UseOutlines\n" );
5446 aLine.append(
"/NonFullScreenPageMode/UseThumbs\n" );
5449 aLine.append(
">>\n" );
5454 aLine.append(
"/Outlines " );
5455 aLine.append( nOutlineDict );
5456 aLine.append(
" 0 R\n" );
5458 if( nStructureDict )
5460 aLine.append(
"/StructTreeRoot " );
5461 aLine.append( nStructureDict );
5462 aLine.append(
" 0 R\n" );
5468 OUString aLanguage, aScript, aCountry;
5470 if (!aLanguage.isEmpty())
5472 OUStringBuffer aLocBuf( 16 );
5473 aLocBuf.append( aLanguage );
5474 if( !aCountry.isEmpty() )
5476 aLocBuf.append(
'-' );
5477 aLocBuf.append( aCountry );
5479 aLine.append(
"/Lang" );
5481 aLine.append(
"\n" );
5486 aLine.append(
"/MarkInfo<</Marked true>>\n" );
5490 aLine.append(
"/AcroForm<</Fields[\n" );
5493 for(
int j = 0; j < nWidgets; j++ )
5499 aLine.append( (nOut++ % 5)==4 ?
" 0 R\n" :
" 0 R " );
5502 aLine.append(
"\n]" );
5506 aLine.append(
"/SigFlags 3");
5509 aLine.append(
"/DR " );
5511 aLine.append(
" 0 R" );
5518 aLine.append(
">>\n" );
5520 aLine.append(
"/NeedAppearances true>>\n" );
5524 if( nOutputIntentObject )
5526 aLine.append(
"/OutputIntents[");
5527 aLine.append( nOutputIntentObject );
5528 aLine.append(
" 0 R]" );
5531 if( nMetadataObject )
5533 aLine.append(
"/Metadata ");
5534 aLine.append( nMetadataObject );
5535 aLine.append(
" 0 R" );
5538 aLine.append(
">>\n"
5550 OStringBuffer aLine( 0x5000 );
5552 aLine.append(
" 0 obj\n" );
5553 aLine.append(
"<</Contents <" );
5555 sal_uInt64 nOffset = ~0
U;
5561 OStringBuffer aContentFiller( MAX_SIGNATURE_CONTENT_LENGTH );
5563 aLine.append( aContentFiller );
5564 aLine.append(
">\n/Type/Sig/SubFilter/adbe.pkcs7.detached");
5568 aLine.append(
"/Name" );
5572 aLine.append(
" /M ");
5575 aLine.append(
" /ByteRange [ 0 ");
5577 aLine.append(
" " );
5579 aLine.append(
" " );
5586 OStringBuffer aByteRangeFiller( 100 );
5588 aLine.append( aByteRangeFiller );
5589 aLine.append(
" /Filter/Adobe.PPKMS");
5594 aLine.append(
"/Reason");
5600 aLine.append(
"/Location");
5606 aLine.append(
"/ContactInfo");
5610 aLine.append(
" >>\nendobj\n\n" );
5621 sal_uInt64 nOffset = ~0
U;
5627 sal_uInt64 nWritten = 0;
5629 OString aByteRangeNo = OString::number( nLastByteRangeNo ) +
" ]";
5631 if (
m_aFile.write(aByteRangeNo.getStr(), aByteRangeNo.getLength(), nWritten) != osl::File::E_None)
5643 sal_uInt64 bytesRead1;
5649 SAL_WARN(
"vcl.pdfwriter",
"First buffer read failed");
5653 std::unique_ptr<char[]> buffer2(
new char[nLastByteRangeNo + 1]);
5654 sal_uInt64 bytesRead2;
5657 osl::File::E_None !=
m_aFile.read(buffer2.get(), nLastByteRangeNo, bytesRead2) ||
5658 bytesRead2 !=
static_cast<sal_uInt64
>(nLastByteRangeNo))
5660 SAL_WARN(
"vcl.pdfwriter",
"Second buffer read failed");
5664 OStringBuffer aCMSHexBuffer;
5666 aSigning.AddDataRange(buffer1.get(), bytesRead1);
5667 aSigning.AddDataRange(buffer2.get(), bytesRead2);
5670 if (!aSigning.Sign(aCMSHexBuffer))
5672 SAL_WARN(
"vcl.pdfwriter",
"PDFWriter::Sign() failed");
5676 assert(aCMSHexBuffer.getLength() <= MAX_SIGNATURE_CONTENT_LENGTH);
5681 m_aFile.write(aCMSHexBuffer.getStr(), aCMSHexBuffer.getLength(), nWritten);
5683 return osl::File::E_None ==
m_aFile.setPos(osl_Pos_Absolut, nOffset);
5694 OStringBuffer aLine( 1024 );
5695 aLine.append( nObject );
5696 aLine.append(
" 0 obj\n"
5700 aLine.append(
"/Title" );
5702 aLine.append(
"\n" );
5706 aLine.append(
"/Author" );
5708 aLine.append(
"\n" );
5712 aLine.append(
"/Subject" );
5714 aLine.append(
"\n" );
5718 aLine.append(
"/Keywords" );
5720 aLine.append(
"\n" );
5724 aLine.append(
"/Creator" );
5726 aLine.append(
"\n" );
5730 aLine.append(
"/Producer" );
5732 aLine.append(
"\n" );
5735 aLine.append(
"/CreationDate" );
5737 aLine.append(
">>\nendobj\n\n" );
5760 OStringBuffer aLine( 1024 );
5761 aLine.append( nObject );
5762 aLine.append(
" 0 obj\n"
5766 for( nDestID = 0; nDestID <
nCount; nDestID++ )
5780 aLine.append(
'/' );
5781 appendDestinationName(
aName, aLine );
5782 aLine.append(
'[' );
5785 aLine.append(
" 0 R" );
5791 aLine.append(
"/XYZ " );
5793 aLine.append(
' ' );
5795 aLine.append(
" 0" );
5798 aLine.append(
"/FitR " );
5800 aLine.append(
' ' );
5801 appendFixedInt( rDest.
m_aRect.
Top(), aLine );
5802 aLine.append(
' ' );
5804 aLine.append(
' ' );
5808 aLine.append(
"]\n" );
5812 aLine.append(
">>\nendobj\n\n" );
5830 OStringBuffer aLine( 1024 );
5834 aLine.append( nICCObject );
5836 aLine.append(
" 0 obj\n<</N 3/Length " );
5837 aLine.append( nStreamLengthObject );
5838 aLine.append(
" 0 R" );
5840 aLine.append(
"/Filter/FlateDecode" );
5841 aLine.append(
">>\nstream\n" );
5845 sal_uInt64 nBeginStreamPos = 0;
5846 if (osl::File::E_None !=
m_aFile.getPos(nBeginStreamPos))
5850 cmsHPROFILE hProfile = cmsCreate_sRGBProfile();
5852 cmsSetProfileVersion(hProfile, 2.1);
5853 cmsUInt32Number nBytesNeeded = 0;
5854 cmsSaveProfileToMem(hProfile,
nullptr, &nBytesNeeded);
5857 std::vector<unsigned char>
aBuffer(nBytesNeeded);
5858 cmsSaveProfileToMem(hProfile,
aBuffer.data(), &nBytesNeeded);
5859 cmsCloseProfile(hProfile);
5864 sal_uInt64 nEndStreamPos = 0;
5865 if (
m_aFile.getPos(nEndStreamPos) != osl::File::E_None)
5872 aLine.setLength( 0 );
5876 aLine.setLength( 0 );
5877 aLine.append( nStreamLengthObject );
5878 aLine.append(
" 0 obj\n" );
5879 aLine.append(
static_cast<sal_Int64
>(nEndStreamPos-nBeginStreamPos) );
5880 aLine.append(
"\nendobj\n\n" );
5882 aLine.setLength( 0 );
5887 aLine.append( nOIObject );
5888 aLine.append(
" 0 obj\n"
5889 "<</Type/OutputIntent/S/GTS_PDFA1/OutputConditionIdentifier");
5892 aLine.append(
"/DestOutputProfile ");
5893 aLine.append( nICCObject );
5894 aLine.append(
" 0 R>>\nendobj\n\n" );
5902 if (!aValue.empty())
5939 OStringBuffer aMetadataObj( 1024 );
5941 aMetadataObj.append( nObject );
5942 aMetadataObj.append(
" 0 obj\n" );
5944 aMetadataObj.append(
"<</Type/Metadata/Subtype/XML/Length " );
5946 aMetadataObj.append( sal_Int32(aMetadata.
getSize()) );
5947 aMetadataObj.append(
">>\nstream\n" );
5968 sal_Int32 nSecObject = 0;
5979 OStringBuffer aLineS( 1024 );
5980 aLineS.append( nSecObject );
5981 aLineS.append(
" 0 obj\n"
5982 "<</Filter/Standard/V " );
5984 aLineS.append(
"2/Length 128/R 3" );
5987 aLineS.append(
"/O(" );
5989 aLineS.append(
")/U(" );
5991 aLineS.append(
")/P " );
5993 aLineS.append(
">>\nendobj\n\n" );
6002 sal_uInt64 nXRefOffset = 0;
6007 OStringBuffer aLine;
6008 aLine.append(
"0 " );
6009 aLine.append(
static_cast<sal_Int32
>(nObjects+1) );
6010 aLine.append(
"\n" );
6011 aLine.append(
"0000000000 65535 f \n" );
6014 for( sal_Int32
i = 0;
i < nObjects;
i++ )
6016 aLine.setLength( 0 );
6017 OString aOffset = OString::number(
m_aObjects[
i] );
6018 for( sal_Int32 j = 0; j < (10-aOffset.getLength()); j++ )
6019 aLine.append(
'0' );
6020 aLine.append( aOffset );
6021 aLine.append(
" 00000 n \n" );
6022 SAL_WARN_IF( aLine.getLength() != 20,
"vcl.pdfwriter",
"invalid xref entry" );
6027 OStringBuffer aDocChecksum( 2*RTL_DIGEST_LENGTH_MD5+1 );
6030 appendHex(
i, aDocChecksum );
6033 aLine.setLength( 0 );
6034 aLine.append(
"trailer\n"
6036 aLine.append(
static_cast<sal_Int32
>(nObjects+1) );
6037 aLine.append(
"/Root " );
6039 aLine.append(
" 0 R\n" );
6042 aLine.append(
"/Encrypt ");
6043 aLine.append( nSecObject );
6044 aLine.append(
" 0 R\n" );
6046 if( nDocInfoObject )
6048 aLine.append(
"/Info " );
6049 aLine.append( nDocInfoObject );
6050 aLine.append(
" 0 R\n" );
6054 aLine.append(
"/ID [ <" );
6057 appendHex(
sal_Int8(item), aLine );
6063 appendHex(
sal_Int8(item), aLine );
6065 aLine.append(
"> ]\n" );
6067 if( !aDocChecksum.isEmpty() )
6069 aLine.append(
"/DocChecksum /" );
6070 aLine.append( aDocChecksum );
6071 aLine.append(
"\n" );
6076 aLine.append(
"/AdditionalStreams [" );
6079 aLine.append(
"/" );
6080 appendName(rAttachedFile.maMimeType, aLine);
6082 appendObjectReference(rAttachedFile.mnEmbeddedFileObjectId, aLine);
6085 aLine.append(
"]\n" );
6088 aLine.append(
">>\n"
6090 aLine.append(
static_cast<sal_Int64
>(nXRefOffset) );
6098struct AnnotationSortEntry
6100 sal_Int32 nTabOrder;
6102 sal_Int32 nWidgetIndex;
6104 AnnotationSortEntry( sal_Int32 nTab, sal_Int32 nObj, sal_Int32 nI ) :
6111struct AnnotSortContainer
6114 std::vector< AnnotationSortEntry > aSortedAnnots;
6117struct AnnotSorterLess
6119 std::vector<PDFWidget>& m_rWidgets;
6121 explicit AnnotSorterLess( std::vector<PDFWidget>& rWidgets ) : m_rWidgets( rWidgets ) {}
6123 bool operator()(
const AnnotationSortEntry& rLeft,
const AnnotationSortEntry& rRight )
6125 if( rLeft.nTabOrder < rRight.nTabOrder )
6127 if( rRight.nTabOrder < rLeft.nTabOrder )
6129 if( rLeft.nWidgetIndex < 0 && rRight.nWidgetIndex < 0 )
6131 if( rRight.nWidgetIndex < 0 )
6133 if( rLeft.nWidgetIndex < 0 )
6136 if( m_rWidgets[ rLeft.nWidgetIndex ].m_aRect.Top() >
6137 m_rWidgets[ rRight.nWidgetIndex ].m_aRect.Top() )
6139 if( m_rWidgets[ rRight.nWidgetIndex ].m_aRect.Top() >
6140 m_rWidgets[ rLeft.nWidgetIndex ].m_aRect.Top() )
6142 if( m_rWidgets[ rLeft.nWidgetIndex ].m_aRect.Left() <
6143 m_rWidgets[ rRight.nWidgetIndex ].m_aRect.Left() )
6155 std::unordered_map< sal_Int32, AnnotSortContainer > sorted;
6157 for(
int nW = 0; nW < nWidgets; nW++ )
6162 AnnotSortContainer& rCont = sorted[ rWidget.
m_nPage ];
6164 if( rCont.aSortedAnnots.empty() )
6165 rCont.aSortedAnnots.reserve(
m_aPages[ rWidget.
m_nPage ].m_aAnnotations.size() );
6170 rCont.aObjects.insert( rWidget.
m_nObject );
6175 for (
auto & item : sorted)
6180 for(
unsigned int nA = 0; nA < nAnnots; nA++ )
6181 if( item.second.aObjects.find( rPage.
m_aAnnotations[nA] ) == item.second.aObjects.end())
6182 item.second.aSortedAnnots.emplace_back( 10000, rPage.
m_aAnnotations[nA], -1 );
6185 std::stable_sort( item.second.aSortedAnnots.begin(), item.second.aSortedAnnots.end(), aLess );
6187 if( item.second.aSortedAnnots.size() == nAnnots)
6189 for(
unsigned int nA = 0; nA < nAnnots; nA++ )
6190 rPage.
m_aAnnotations[nA] = item.second.aSortedAnnots[nA].nObject;
6194 SAL_WARN(
"vcl.pdfwriter",
"wrong number of sorted annotations" );
6195 SAL_INFO(
"vcl.pdfwriter",
"PDFWriterImpl::sortWidgets(): wrong number of sorted assertions "
6196 "on page nr " << item.first <<
", " <<
6197 static_cast<tools::Long>(item.second.aSortedAnnots.size()) <<
" sorted and " <<
6198 static_cast<tools::Long>(nAnnots) <<
" unsorted");
6218 aSignature.
Name =
"Signature1";
6266 sal_Int32 nFontID = 0;
6269 nFontID = it->second.m_nNormalFontID;
6284 const std::vector<sal_Ucs>& rCodeUnits,
6285 sal_Int32 nGlyphWidth,
6287 sal_Int32& nMappedFontObject)
6291 auto it = rSubset.
m_aMapping.find( nFontGlyphId );
6294 nMappedFontObject = it->second.m_nFontID;
6295 nMappedGlyph = it->second.m_nSubsetGlyphID;
6301 || (rSubset.
m_aSubsets.back().m_aMapping.size() > 254) )
6307 nMappedFontObject = rSubset.
m_aSubsets.back().m_nFontID;
6309 sal_uInt8 nNewId = sal::static_int_cast<sal_uInt8>(rSubset.
m_aSubsets.back().m_aMapping.size()+1);
6310 nMappedGlyph = nNewId;
6316 for (
const auto nCode : rCodeUnits)
6321 rNewGlyph.
m_nFontID = nMappedFontObject;
6329 const std::vector<sal_Ucs>& rCodeUnits, sal_Int32 nGlyphWidth,
6330 sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject)
6346 if (!aLayers.empty() || !aBitmap.empty() || bVariations)
6349 auto it = rSubset.
m_aMapping.find(nFontGlyphId);
6352 nMappedFontObject = it->second.m_nFontID;
6353 nMappedGlyph = it->second.m_nSubsetGlyphID;
6358 if (rSubset.m_aSubsets.empty()
6359 || (rSubset.m_aSubsets.back().
m_aMapping.size() > 254))
6361 rSubset.m_aSubsets.emplace_back(
m_nNextFID++);
6365 nMappedFontObject = rSubset.m_aSubsets.back().
m_nFontID;
6367 sal_uInt8 nNewId = sal::static_int_cast<sal_uInt8>(
6368 rSubset.m_aSubsets.back().
m_aMapping.size() + 1);
6369 nMappedGlyph = nNewId;
6372 auto& rNewGlyphEmit = rSubset.m_aSubsets.back().
m_aMapping[nFontGlyphId];
6373 rNewGlyphEmit.setGlyphId(nNewId);
6374 rNewGlyphEmit.setGlyphWidth(nGlyphWidth);
6375 for (
const auto nCode : rCodeUnits)
6376 rNewGlyphEmit.addCode(nCode);
6379 if (!aLayers.empty())
6381 for (
const auto& aLayer : aLayers)
6384 sal_Int32 nLayerFontID;
6386 nLayerGlyph, nLayerFontID);
6388 rNewGlyphEmit.addColorLayer(
6389 { nLayerFontID, nLayerGlyph, aLayer.nColorIndex });
6392 else if (!aBitmap.empty())
6393 rNewGlyphEmit.setColorBitmap(aBitmap, aRect);
6394 else if (bVariations)
6399 rNewGlyph.
m_nFontID = nMappedFontObject;
6491 const std::vector<PDFGlyph>& rGlyphs,
6492 OStringBuffer& rLine,
6493 const Point& rAlignOffset,
6497 sal_Int32 nFontHeight)
6499 double nXOffset = 0;
6501 aCurPos += rAlignOffset;
6502 for(
size_t i = 0;
i < rGlyphs.size();
i++ )
6505 double fDeltaAngle = 0.0;
6506 double fYScale = 1.0;
6507 double fTempXScale = fXScale;
6511 if (rGlyphs[
i].m_pFont->NeedsArtificialItalic())
6514 double fSkewB = fSkew;
6515 double fSkewA = 0.0;
6518 if (rGlyphs[
i].m_pGlyph->IsVertical())
6520 fDeltaAngle = M_PI/2.0;
6527 if(
i < rGlyphs.size()-1 )
6530 double nOffsetX = rGlyphs[
i+1].m_aPos.getX() - rGlyphs[
i].m_aPos.getX();
6531 double nOffsetY = rGlyphs[
i+1].m_aPos.getY() - rGlyphs[
i].m_aPos.getY();
6532 nXOffset += std::hypot(nOffsetX, nOffsetY);
6534 if (!rGlyphs[
i].m_pGlyph->glyphId())
6537 aDeltaPos = rRotScale.
transform( aDeltaPos );
6540 if( fSkewB != 0.0 || fSkewA != 0.0 )
6541 aMat.
skew( fSkewA, fSkewB );
6542 aMat.
scale( fTempXScale, fYScale );
6543 aMat.
rotate( fAngle+fDeltaAngle );
6544 aMat.
translate( aCurPos.
X()+aDeltaPos.
X(), aCurPos.
Y()+aDeltaPos.
Y() );
6545 m_aPages.back().appendMatrix3(aMat, rLine);
6546 rLine.append(
" Tm" );
6547 if(
i == 0 || rGlyphs[
i-1].m_nMappedFontId != rGlyphs[
i].m_nMappedFontId )
6549 rLine.append(
" /F" );
6550 rLine.append( rGlyphs[
i].m_nMappedFontId );
6551 rLine.append(
' ' );
6552 m_aPages.back().appendMappedLength( nFontHeight, rLine );
6553 rLine.append(
" Tf" );
6555 rLine.append(
"<" );
6556 appendHex( rGlyphs[
i].m_nMappedGlyphId, rLine );
6557 rLine.append(
">Tj\n" );
6562 const std::vector<PDFGlyph>& rGlyphs,
6563 OStringBuffer& rLine,
6564 const Point& rAlignOffset,
6568 sal_Int32 nFontHeight,
6569 sal_Int32 nPixelFontHeight)
6576 std::vector< sal_uInt32 > aRunEnds;
6577 aRunEnds.reserve( rGlyphs.size() );
6578 for(
size_t i = 1;
i < rGlyphs.size();
i++ )
6580 if( rGlyphs[
i].m_nMappedFontId != rGlyphs[
i-1].m_nMappedFontId ||
6581 rGlyphs[
i].m_pFont != rGlyphs[
i-1].m_pFont ||
6582 rGlyphs[
i].m_aPos.getY() != rGlyphs[
i-1].m_aPos.getY() )
6584 aRunEnds.push_back(
i);
6588 aRunEnds.push_back( rGlyphs.size() );
6591 sal_uInt32 nBeginRun = 0;
6592 for(
size_t nRun = 0; nRun < aRunEnds.size(); nRun++ )
6596 aCurPos += rAlignOffset;
6600 if (rGlyphs[nBeginRun].m_pFont->NeedsArtificialItalic())
6608 if( bFirst && nRun == 0 && fAngle == 0.0 && fXScale == 1.0 && fSkew == 0.0 )
6610 m_aPages.back().appendPoint( aCurPos, rLine );
6611 rLine.append(
" Td " );
6616 aMat.
skew( 0.0, fSkew );
6617 aMat.
scale( fXScale, 1.0 );
6620 m_aPages.back().appendMatrix3(aMat, rLine);
6621 rLine.append(
" Tm\n" );
6624 rLine.append(
"/F" );
6625 rLine.append( rGlyphs[nBeginRun].m_nMappedFontId );
6626 rLine.append(
' ' );
6627 m_aPages.back().appendMappedLength( nFontHeight, rLine );
6628 rLine.append(
" Tf" );
6631 OStringBuffer aKernedLine( 256 ), aUnkernedLine( 256 );
6632 aKernedLine.append(
"[<" );
6633 aUnkernedLine.append(
'<' );
6634 appendHex( rGlyphs[nBeginRun].m_nMappedGlyphId, aKernedLine );
6635 appendHex( rGlyphs[nBeginRun].m_nMappedGlyphId, aUnkernedLine );
6638 bool bNeedKern =
false;
6639 for( sal_uInt32
nPos = nBeginRun+1;
nPos < aRunEnds[nRun];
nPos++ )
6641 appendHex( rGlyphs[
nPos].m_nMappedGlyphId, aUnkernedLine );
6645 double fAdvance = aThisPos.
getX() - aPrevPos.
getX();
6646 fAdvance *= 1000.0 / nPixelFontHeight;
6647 const double fAdjustment = rGlyphs[
nPos-1].m_nNativeWidth - fAdvance + 0.5;
6649 fAdjustment < SAL_MIN_INT32 || fAdjustment >
SAL_MAX_INT32,
"vcl.pdfwriter",
6650 "adjustment " << fAdjustment <<
" outside 32-bit int");
6651 const sal_Int32 nAdjustment =
static_cast<sal_Int32
>(
6653 if( nAdjustment != 0 )
6657 aKernedLine.append(
">" );
6658 aKernedLine.append( nAdjustment );
6659 aKernedLine.append(
"<" );
6661 appendHex( rGlyphs[
nPos].m_nMappedGlyphId, aKernedLine );
6663 aKernedLine.append(
">]TJ\n" );
6664 aUnkernedLine.append(
">Tj\n" );
6665 rLine.append( bNeedKern ? aKernedLine : aUnkernedLine );
6668 nBeginRun = aRunEnds[nRun];
6683 OStringBuffer aLine( 512 );
6685 const int nMaxGlyphs = 256;
6687 std::vector<sal_Ucs> aCodeUnits;
6690 double fXScale = 1.0;
6718 while( nAngle < 0_deg10 )
6719 nAngle += 3600_deg10;
6720 nAngle = nAngle % 3600_deg10;
6724 aRotScale.
scale( fXScale, 1.0 );
6726 aRotScale.
rotate( -fAngle );
6729 bool bABold =
false;
6754 aLine.append(
"q " );
6757 aLine.append(
"\n" );
6762 aLine.append(
"q " );
6765 aLine.append(
"\n" );
6769 aLine.append(
"BT\n" );
6774 aLine.append(
"2 Tr " );
6780 aLine.append(
"0.25 w \n" );
6785 m_aPages.back().appendMappedLength( fW, aLine );
6786 aLine.append (
" w\n" );
6795 std::vector< PDFGlyph > aGlyphs;
6796 aGlyphs.reserve( nMaxGlyphs );
6825 aCodeUnits.push_back(rText[pGlyph->
charPos() +
n]);
6827 bool bUseActualText =
false;
6831 bUseActualText =
true;
6833 const auto nGlyphId = pGlyph->
glyphId();
6837 if (!aCodeUnits.empty() && !bUseActualText)
6841 const auto& it = rSubset.
m_aMapping.find(nGlyphId);
6842 if (it != rSubset.
m_aMapping.cend() && it->second.codes() != aCodeUnits)
6844 bUseActualText =
true;
6853 sal_Int32 nMappedFontObject;
6854 registerGlyph(nGlyphId, pFace, pGlyphFont, aCodeUnits, nGlyphWidth, nMappedGlyph, nMappedFontObject);
6860 aGlyphs.emplace_back(aPos,
6863 XUnits(pFace->UnitsPerEm(), nGlyphWidth),
6910 if( aAlignOffset.
X() || aAlignOffset.
Y() )
6911 aAlignOffset = aRotScale.
transform( aAlignOffset );
6916 if( ! aGlyphs.empty() )
6920 while (nStart < aGlyphs.size())
6922 while (nEnd < aGlyphs.size() && aGlyphs[nEnd].m_nCharPos == aGlyphs[nStart].m_nCharPos)
6925 std::vector<PDFGlyph> aRun(aGlyphs.begin() + nStart, aGlyphs.begin() + nEnd);
6927 int nCharPos, nCharCount;
6928 if (!aRun.front().m_pGlyph->IsRTLGlyph())
6930 nCharPos = aRun.front().m_nCharPos;
6931 nCharCount = aRun.front().m_pGlyph->charCount();
6935 nCharPos = aRun.back().m_nCharPos;
6936 nCharCount = aRun.back().m_pGlyph->charCount();
6939 if (nCharPos >= 0 && nCharCount)
6941 aLine.append(
"/Span<</ActualText<FEFF");
6942 for (
int i = 0;
i < nCharCount;
i++)
6945 appendHex(
static_cast<sal_Int8>(aChar >> 8), aLine);
6946 appendHex(
static_cast<sal_Int8>(aChar & 255), aLine);
6948 aLine.append(
">>>\nBDC\n" );
6952 drawVerticalGlyphs(aRun, aLine, aAlignOffset, aRotScale, fAngle, fXScale, nFontHeight);
6954 drawHorizontalGlyphs(aRun, aLine, aAlignOffset, nStart == 0, fAngle, fXScale, nFontHeight, nPixelFontHeight);
6956 if (nCharPos >= 0 && nCharCount)
6957 aLine.append(
"EMC\n" );
6964 aLine.append(
"ET\n" );
6966 aLine.append(
"Q\n" );
6997 else if( nWidth > 0 )
7001 eStrikeout, eUnderline, eOverline, bUnderlineAbove );
7010 eStrikeout, eUnderline, eOverline, bUnderlineAbove );
7019 eStrikeout, eUnderline, eOverline, bUnderlineAbove );
7029 aLine.setLength( 0 );
7030 aLine.append(
"q\n" );
7035 if ( nEmphMark & FontEmphasisMark::PosBelow )
7055 Point aOffsetVert(0,0);
7057 if ( nEmphMark & FontEmphasisMark::PosBelow )
7060 aOffsetVert = aOffset;
7072 aOffset +=
Point( nEmphWidth2, nEmphHeight2 );
7100 aAdjOffset = aRotScale.
transform( aAdjOffset );
7105 aMarkDevPos += aAdjOffset;
7125 if ( rPolyPoly.
Count() )
7130 aPoly.
Move( nX, nY );
7136 aPolyPoly.
Move( nX, nY );
7166 GetLayoutGlyphs(
this, rText,
nIndex, nLen );
7167 std::unique_ptr<SalLayout> pLayout =
ImplLayout( rText,
nIndex, nLen, rPos,
7177 MARK(
"drawText with array" );
7184 GetLayoutGlyphs(
this, rText,
nIndex, nLen );
7185 std::unique_ptr<SalLayout> pLayout =
ImplLayout( rText,
nIndex, nLen, rPos, 0, pDXArray, pKashidaArray,
7195 MARK(
"drawStretchText" );
7202 GetLayoutGlyphs(
this, rText,
nIndex, nLen, nWidth );
7203 std::unique_ptr<SalLayout> pLayout =
ImplLayout( rText,
nIndex, nLen, rPos, nWidth,
7216 if ( nWidth <= 0 || nHeight <= 0 )
7219 MARK(
"drawText with rectangle" );
7224 OStringBuffer aLine;
7225 aLine.append(
"q " );
7226 m_aPages.back().appendRect( rRect, aLine );
7227 aLine.append(
" W* n\n" );
7235 sal_Int32 nMnemonicPos = -1;
7237 OUString
aStr = rOrigStr;
7246 sal_Int32 nFormatLines;
7253 sal_Int32 nLines = nHeight/nTextHeight;
7254 nFormatLines = aMultiLineInfo.
Count();
7257 if ( nFormatLines > nLines )
7262 nFormatLines = nLines-1;
7267 aLastLine = aLastLine.replace(
'\n',
' ');
7276 aPos.
AdjustY(nHeight-(nFormatLines*nTextHeight) );
7278 aPos.
AdjustY((nHeight-(nFormatLines*nTextHeight))/2 );
7281 for (
i = 0;
i < nFormatLines;
i++ )
7289 sal_Int32 nLineLen = rLineInfo.
GetLen();
7298 if (!aLastLine.isEmpty())
7299 drawText( aPos, aLastLine, 0, aLastLine.getLength() );
7307 if ( nTextWidth > nWidth )
7320 aPos.
AdjustX(nWidth-nTextWidth );
7322 aPos.
AdjustX((nWidth-nTextWidth)/2 );
7325 aPos.
AdjustY(nHeight-nTextHeight );
7327 aPos.
AdjustY((nHeight-nTextHeight)/2 );
7336 aLine.setLength( 0 );
7337 aLine.append(
"Q\n" );
7350 OStringBuffer aLine;
7351 m_aPages.back().appendPoint( rStart, aLine );
7352 aLine.append(
" m " );
7353 m_aPages.back().appendPoint( rStop, aLine );
7354 aLine.append(
" l S\n" );
7361 MARK(
"drawLine with LineInfo" );
7373 OStringBuffer aLine;
7375 aLine.append(
"q " );
7376 if(
m_aPages.back().appendLineInfo( rInfo, aLine ) )
7378 m_aPages.back().appendPoint( rStart, aLine );
7379 aLine.append(
" m " );
7380 m_aPages.back().appendPoint( rStop, aLine );
7381 aLine.append(
" l S Q\n" );
7389 Point aPolyPoints[2] = { rStart, rStop };
7395#define HCONV( x ) ImplDevicePixelToLogicHeight( x )
7405 aLine.append(
"\n" );
7409 if ( !pFontInstance->
mxFontMetric->GetAboveWavelineUnderlineSize() )
7411 nLineHeight =
HCONV( pFontInstance->
mxFontMetric->GetAboveWavelineUnderlineSize() );
7412 nLinePos =
HCONV( pFontInstance->
mxFontMetric->GetAboveWavelineUnderlineOffset() );
7416 if ( !pFontInstance->
mxFontMetric->GetWavelineUnderlineSize() )
7432 aLine.append(
" w " );
7438 if ( nLineHeight < 2 )
7440 if ( nOrgLineHeight > 1 )
7445 tools::Long nLineDY = nOrgLineHeight-(nLineHeight*2);
7454 m_aPages.back().appendWaveLine( nWidth, -nLinePos, 2*nLineHeight, aLine );
7457 m_aPages.back().appendWaveLine( nWidth, -nLinePos, 2*nLineHeight, aLine );
7463 m_aPages.back().appendWaveLine( nWidth, -nLinePos, nLineHeight, aLine );
7478 switch ( eTextLine )
7488 if ( !pFontInstance->
mxFontMetric->GetAboveUnderlineSize() )
7490 nLineHeight = pFontInstance->
mxFontMetric->GetAboveUnderlineSize();
7491 nLinePos = pFontInstance->
mxFontMetric->GetAboveUnderlineOffset();
7495 if ( !pFontInstance->
mxFontMetric->GetUnderlineSize() )
7497 nLineHeight = pFontInstance->
mxFontMetric->GetUnderlineSize();
7498 nLinePos = pFontInstance->
mxFontMetric->GetUnderlineOffset();
7509 if ( !pFontInstance->
mxFontMetric->GetAboveBoldUnderlineSize() )
7511 nLineHeight = pFontInstance->
mxFontMetric->GetAboveBoldUnderlineSize();
7512 nLinePos = pFontInstance->
mxFontMetric->GetAboveBoldUnderlineOffset();
7516 if ( !pFontInstance->
mxFontMetric->GetBoldUnderlineSize() )
7518 nLineHeight = pFontInstance->
mxFontMetric->GetBoldUnderlineSize();
7519 nLinePos = pFontInstance->
mxFontMetric->GetBoldUnderlineOffset();
7525 if ( !pFontInstance->
mxFontMetric->GetAboveDoubleUnderlineSize() )
7527 nLineHeight = pFontInstance->
mxFontMetric->GetAboveDoubleUnderlineSize();
7528 nLinePos = pFontInstance->
mxFontMetric->GetAboveDoubleUnderlineOffset1();
7529 nLinePos2 = pFontInstance->
mxFontMetric->GetAboveDoubleUnderlineOffset2();
7533 if ( !pFontInstance->
mxFontMetric->GetDoubleUnderlineSize() )
7535 nLineHeight = pFontInstance->
mxFontMetric->GetDoubleUnderlineSize();
7536 nLinePos = pFontInstance->
mxFontMetric->GetDoubleUnderlineOffset1();
7537 nLinePos2 = pFontInstance->
mxFontMetric->GetDoubleUnderlineOffset2();
7551 auto nOffset = nLineHeight / 2;
7557 nOffset = nLineHeight;
7560 nLineHeight =
HCONV(nLineHeight);
7561 nLinePos =
HCONV(nLinePos + nOffset);
7562 nLinePos2 =
HCONV(nLinePos2 + nOffset);
7568 aLine.append(
" " );
7570 aLine.append(
"\n" );
7571 aLine.append(
"0.25 w \n" );
7574 aLine.append(
"0 " );
7575 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos), aLine );
7576 aLine.append(
" " );
7577 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nWidth), aLine,
false );
7578 aLine.append(
' ' );
7579 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine );
7580 aLine.append(
" re h B\n" );
7585 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine );
7586 aLine.append(
" w " );
7588 aLine.append(
"\n" );
7590 switch ( eTextLine )
7594 aLine.append(
"[ " );
7595 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine,
false );
7596 aLine.append(
" ] 0 d\n" );
7603 sal_Int32 nDashLength = 4*nLineHeight;
7604 sal_Int32 nVoidLength = 2*nLineHeight;
7606 nDashLength = 8*nLineHeight;
7608 aLine.append(
"[ " );
7609 m_aPages.back().appendMappedLength( nDashLength, aLine,
false );
7610 aLine.append(
' ' );
7611 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7612 aLine.append(
" ] 0 d\n" );
7618 sal_Int32 nDashLength = 4*nLineHeight;
7619 sal_Int32 nVoidLength = 2*nLineHeight;
7620 aLine.append(
"[ " );
7621 m_aPages.back().appendMappedLength( nDashLength, aLine,
false );
7622 aLine.append(
' ' );
7623 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7624 aLine.append(
' ' );
7625 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine,
false );
7626 aLine.append(
' ' );
7627 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7628 aLine.append(
" ] 0 d\n" );
7634 sal_Int32 nDashLength = 4*nLineHeight;
7635 sal_Int32 nVoidLength = 2*nLineHeight;
7636 aLine.append(
"[ " );
7637 m_aPages.back().appendMappedLength( nDashLength, aLine,
false );
7638 aLine.append(
' ' );
7639 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7640 aLine.append(
' ' );
7641 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine,
false );
7642 aLine.append(
' ' );
7643 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7644 aLine.append(
' ' );
7645 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine,
false );
7646 aLine.append(
' ' );
7647 m_aPages.back().appendMappedLength( nVoidLength, aLine,
false );
7648 aLine.append(
" ] 0 d\n" );
7655 aLine.append(
"0 " );
7656 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos), aLine );
7657 aLine.append(
" m " );
7658 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nWidth), aLine,
false );
7659 aLine.append(
' ' );
7660 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos), aLine );
7661 aLine.append(
" l S\n" );
7664 aLine.append(
"0 " );
7665 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos2-nLineHeight), aLine );
7666 aLine.append(
" m " );
7667 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nWidth), aLine,
false );
7668 aLine.append(
' ' );
7669 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos2-nLineHeight), aLine );
7670 aLine.append(
" l S\n" );
7686 switch ( eStrikeout )
7689 if ( !pFontInstance->
mxFontMetric->GetStrikeoutSize() )
7691 nLineHeight = pFontInstance->
mxFontMetric->GetStrikeoutSize();
7692 nLinePos = pFontInstance->
mxFontMetric->GetStrikeoutOffset();
7695 if ( !pFontInstance->
mxFontMetric->GetBoldStrikeoutSize() )
7697 nLineHeight = pFontInstance->
mxFontMetric->GetBoldStrikeoutSize();
7698 nLinePos = pFontInstance->
mxFontMetric->GetBoldStrikeoutOffset();
7701 if ( !pFontInstance->
mxFontMetric->GetDoubleStrikeoutSize() )
7703 nLineHeight = pFontInstance->
mxFontMetric->GetDoubleStrikeoutSize();
7704 nLinePos = pFontInstance->
mxFontMetric->GetDoubleStrikeoutOffset1();
7705 nLinePos2 = pFontInstance->
mxFontMetric->GetDoubleStrikeoutOffset2();
7718 nLinePos =
HCONV(nLinePos + nLineHeight / 2);
7719 nLinePos2 =
HCONV(nLinePos2 + nLineHeight / 2);
7720 nLineHeight =
HCONV(nLineHeight);
7722 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nLineHeight), aLine );
7723 aLine.append(
" w " );
7725 aLine.append(
"\n" );
7727 aLine.append(
"0 " );
7728 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos), aLine );
7729 aLine.append(
" m " );
7730 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nWidth), aLine );
7731 aLine.append(
' ' );
7732 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos), aLine );
7733 aLine.append(
" l S\n" );
7737 aLine.append(
"0 " );
7738 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos2-nLineHeight), aLine );
7739 aLine.append(
" m " );
7740 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(nWidth), aLine );
7741 aLine.append(
' ' );
7742 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(-nLinePos2-nLineHeight), aLine );
7743 aLine.append(
" l S\n" );
7753 OUString aStrikeoutChar = eStrikeout ==
STRIKEOUT_SLASH ? OUString(
"/" ) : OUString(
"X" );
7754 OUString aStrikeout = aStrikeoutChar;
7756 aStrikeout += aStrikeout;
7760 aStrikeout = aStrikeout.copy(1);
7761 aStrikeout += aStrikeoutChar;
7792 drawText( rPos, aStrikeout, 0, aStrikeout.getLength(),
false );
7814 MARK(
"drawTextLine" );
7822 bool bStrikeoutDone =
false;
7823 bool bUnderlineDone =
false;
7824 bool bOverlineDone =
false;
7829 bStrikeoutDone =
true;
7839 OStringBuffer aLine( 512 );
7841 aLine.append(
"q " );
7848 m_aPages.back().appendMatrix3(aMat, aLine);
7849 aLine.append(
" cm\n" );
7852 aUnderlineColor = aStrikeoutColor;
7855 aOverlineColor = aStrikeoutColor;
7862 drawWaveTextLine( aLine, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove );
7863 bUnderlineDone =
true;
7872 bOverlineDone =
true;
7875 if ( !bUnderlineDone )
7880 if ( !bOverlineDone )
7885 if ( !bStrikeoutDone )
7890 aLine.append(
"Q\n" );
7896 MARK(
"drawPolygon" );
7904 int nPoints = rPoly.
GetSize();
7905 OStringBuffer aLine( 20 * nPoints );
7906 m_aPages.back().appendPolygon( rPoly, aLine );
7909 aLine.append(
"B*\n" );
7911 aLine.append(
"S\n" );
7913 aLine.append(
"f*\n" );
7920 MARK(
"drawPolyPolygon" );
7928 int nPolygons = rPolyPoly.
Count();
7930 OStringBuffer aLine( 40 * nPolygons );
7931 m_aPages.back().appendPolyPolygon( rPolyPoly, aLine );
7934 aLine.append(
"B*\n" );
7936 aLine.append(
"S\n" );
7938 aLine.append(
"f*\n" );
7945 SAL_WARN_IF( nTransparentPercent > 100,
"vcl.pdfwriter",
"invalid alpha value" );
7946 nTransparentPercent = nTransparentPercent % 100;
7948 MARK(
"drawTransparent" );
7977 OStringBuffer aContent( 256 );
7978 m_aPages.back().appendPolyPolygon( rPolyPoly, aContent );
7981 aContent.append(
" B*\n" );
7983 aContent.append(
" S\n" );
7985 aContent.append(
" f*\n" );
7987 aContent.getStr(), aContent.getLength() );
7989 OStringBuffer aObjName( 16 );
7990 aObjName.append(
"Tr" );
7992 OString aTrName( aObjName.makeStringAndClear() );
7993 aObjName.append(
"EGS" );
7995 OString aExtName( aObjName.makeStringAndClear() );
8017 case ResourceKind::XObject:
8019 if (!rOutputStreams.empty())
8020 rOutputStreams.front().m_aResourceDict.m_aXObjects[rResource] = nObject;
8022 case ResourceKind::ExtGState:
8024 if (!rOutputStreams.empty())
8025 rOutputStreams.front().m_aResourceDict.m_aExtGStates[rResource] = nObject;
8027 case ResourceKind::Shading:
8029 if (!rOutputStreams.empty())
8030 rOutputStreams.front().m_aResourceDict.m_aShadings[rResource] = nObject;
8034 if (!rOutputStreams.empty())
8035 rOutputStreams.front().m_aResourceDict.m_aPatterns[rResource] = nObject;
8110 SAL_WARN_IF( nTransparentPercent > 100,
"vcl.pdfwriter",
"invalid alpha value" );
8111 nTransparentPercent = nTransparentPercent % 100;
8127 OStringBuffer aObjName( 16 );
8128 aObjName.append(
"Tr" );
8130 OString aTrName( aObjName.makeStringAndClear() );
8131 aObjName.append(
"EGS" );
8133 OString aExtName( aObjName.makeStringAndClear() );
8151 MARK(
"drawRectangle" );
8159 OStringBuffer aLine( 40 );
8160 m_aPages.back().appendRect( rRect, aLine );
8164 aLine.append(
" B*\n" );
8166 aLine.append(
" S\n" );
8168 aLine.append(
" f*\n" );
8175 MARK(
"drawRectangle with rounded edges" );
8177 if( !nHorzRound && !nVertRound )
8186 if( nHorzRound >
static_cast<sal_uInt32
>(rRect.
GetWidth())/2 )
8188 if( nVertRound >
static_cast<sal_uInt32
>(rRect.
GetHeight())/2 )
8192 const double kappa = 0.5522847498;
8193 const sal_uInt32 kx =
static_cast<sal_uInt32
>((kappa*
static_cast<double>(nHorzRound))+0.5);
8194 const sal_uInt32 ky =
static_cast<sal_uInt32
>((kappa*
static_cast<double>(nVertRound))+0.5);
8196 aPoints[1] =
Point( rRect.
Left() + nHorzRound, rRect.
Top() );
8197 aPoints[0] =
Point( aPoints[1].
X() - kx, aPoints[1].
Y() );
8198 aPoints[2] =
Point( rRect.
Right()+1 - nHorzRound, aPoints[1].
Y() );
8199 aPoints[3] =
Point( aPoints[2].
X()+kx, aPoints[2].
Y() );
8201 aPoints[5] =
Point( rRect.
Right()+1, rRect.
Top()+nVertRound );
8202 aPoints[4] =
Point( aPoints[5].
X(), aPoints[5].
Y()-ky );
8203 aPoints[6] =
Point( aPoints[5].
X(), rRect.
Bottom()+1 - nVertRound );
8204 aPoints[7] =
Point( aPoints[6].
X(), aPoints[6].
Y()+ky );
8207 aPoints[8] =
Point( aPoints[9].
X()+kx, aPoints[9].
Y() );
8208 aPoints[10] =
Point( rRect.
Left() + nHorzRound, aPoints[9].
Y() );
8209 aPoints[11] =
Point( aPoints[10].
X()-kx, aPoints[10].
Y() );
8212 aPoints[12] =
Point( aPoints[13].
X(), aPoints[13].
Y()+ky );
8213 aPoints[14] =
Point( rRect.
Left(), rRect.
Top()+nVertRound );
8214 aPoints[15] =
Point( aPoints[14].
X(), aPoints[14].
Y()-ky );
8216 OStringBuffer aLine( 80 );
8217 m_aPages.back().appendPoint( aPoints[1], aLine );
8218 aLine.append(
" m " );
8219 m_aPages.back().appendPoint( aPoints[2], aLine );
8220 aLine.append(
" l " );
8221 m_aPages.back().appendPoint( aPoints[3], aLine );
8222 aLine.append(
' ' );
8223 m_aPages.back().appendPoint( aPoints[4], aLine );
8224 aLine.append(
' ' );
8225 m_aPages.back().appendPoint( aPoints[5], aLine );
8226 aLine.append(
" c\n" );
8227 m_aPages.back().appendPoint( aPoints[6], aLine );
8228 aLine.append(
" l " );
8229 m_aPages.back().appendPoint( aPoints[7], aLine );
8230 aLine.append(
' ' );
8231 m_aPages.back().appendPoint( aPoints[8], aLine );
8232 aLine.append(
' ' );
8233 m_aPages.back().appendPoint( aPoints[9], aLine );
8234 aLine.append(
" c\n" );
8235 m_aPages.back().appendPoint( aPoints[10], aLine );
8236 aLine.append(
" l " );
8237 m_aPages.back().appendPoint( aPoints[11], aLine );
8238 aLine.append(
' ' );
8239 m_aPages.back().appendPoint( aPoints[12], aLine );
8240 aLine.append(
' ' );
8241 m_aPages.back().appendPoint( aPoints[13], aLine );
8242 aLine.append(
" c\n" );
8243 m_aPages.back().appendPoint( aPoints[14], aLine );
8244 aLine.append(
" l " );
8245 m_aPages.back().appendPoint( aPoints[15], aLine );
8246 aLine.append(
' ' );
8247 m_aPages.back().appendPoint( aPoints[0], aLine );
8248 aLine.append(
' ' );
8249 m_aPages.back().appendPoint( aPoints[1], aLine );
8250 aLine.append(
" c " );
8254 aLine.append(
"b*\n" );
8256 aLine.append(
"s\n" );
8258 aLine.append(
"f*\n" );
8265 MARK(
"drawEllipse" );
8274 const double kappa = 0.5522847498;
8275 const sal_uInt32 kx =
static_cast<sal_uInt32
>((kappa*
static_cast<double>(rRect.
GetWidth())/2.0)+0.5);
8276 const sal_uInt32 ky =
static_cast<sal_uInt32
>((kappa*
static_cast<double>(rRect.
GetHeight())/2.0)+0.5);
8279 aPoints[0] =
Point( aPoints[1].
X() - kx, aPoints[1].
Y() );
8280 aPoints[2] =
Point( aPoints[1].
X() + kx, aPoints[1].
Y() );
8283 aPoints[3] =
Point( aPoints[4].
X(), aPoints[4].
Y() - ky );
8284 aPoints[5] =
Point( aPoints[4].
X(), aPoints[4].
Y() + ky );
8287 aPoints[6] =
Point( aPoints[7].
X() + kx, aPoints[7].
Y() );
8288 aPoints[8] =
Point( aPoints[7].
X() - kx, aPoints[7].
Y() );
8291 aPoints[9] =
Point( aPoints[10].
X(), aPoints[10].
Y() + ky );
8292 aPoints[11] =
Point( aPoints[10].
X(), aPoints[10].
Y() - ky );
8294 OStringBuffer aLine( 80 );
8295 m_aPages.back().appendPoint( aPoints[1], aLine );
8296 aLine.append(
" m " );
8297 m_aPages.back().appendPoint( aPoints[2], aLine );
8298 aLine.append(
' ' );
8299 m_aPages.back().appendPoint( aPoints[3], aLine );
8300 aLine.append(
' ' );
8301 m_aPages.back().appendPoint( aPoints[4], aLine );
8302 aLine.append(
" c\n" );
8303 m_aPages.back().appendPoint( aPoints[5], aLine );
8304 aLine.append(
' ' );
8305 m_aPages.back().appendPoint( aPoints[6], aLine );
8306 aLine.append(
' ' );
8307 m_aPages.back().appendPoint( aPoints[7], aLine );
8308 aLine.append(
" c\n" );
8309 m_aPages.back().appendPoint( aPoints[8], aLine );
8310 aLine.append(
' ' );
8311 m_aPages.back().appendPoint( aPoints[9], aLine );
8312 aLine.append(
' ' );
8313 m_aPages.back().appendPoint( aPoints[10], aLine );
8314 aLine.append(
" c\n" );
8315 m_aPages.back().appendPoint( aPoints[11], aLine );
8316 aLine.append(
' ' );
8317 m_aPages.back().appendPoint( aPoints[0], aLine );
8318 aLine.append(
' ' );
8319 m_aPages.back().appendPoint( aPoints[1], aLine );
8320 aLine.append(
" c " );
8324 aLine.append(
"b*\n" );
8326 aLine.append(
"s\n" );
8328 aLine.append(
"f*\n" );
8337 Point aPoint = rPoint - aOrigin;
8339 double fX =
static_cast<double>(aPoint.
X());
8340 double fY =
static_cast<double>(-aPoint.
Y());
8346 fY = fY*(
static_cast<double>(rRect.
GetWidth())/
static_cast<double>(rRect.
GetHeight()));
8348 fX = fX*(
static_cast<double>(rRect.
GetHeight())/
static_cast<double>(rRect.
GetWidth()));
8349 return atan2( fY, fX );
8363 const double fStartAngle =
calcAngle( rRect, rStart );
8364 double fStopAngle =
calcAngle( rRect, rStop );
8365 while( fStopAngle < fStartAngle )
8366 fStopAngle += 2.0*M_PI;
8367 const int nFragments =
static_cast<int>((fStopAngle-fStartAngle)/(M_PI/2.0))+1;
8368 const double fFragmentDelta = (fStopAngle-fStartAngle)/
static_cast<double>(nFragments);
8369 const double kappa = fabs( 4.0 * (1.0-cos(fFragmentDelta/2.0))/sin(fFragmentDelta/2.0) / 3.0);
8370 const double halfWidth =
static_cast<double>(rRect.
GetWidth())/2.0;
8371 const double halfHeight =
static_cast<double>(rRect.
GetHeight())/2.0;
8376 OStringBuffer aLine( 30*nFragments );
8377 Point aPoint(
static_cast<int>(halfWidth * cos(fStartAngle) ),
8378 -
static_cast<int>(halfHeight * sin(fStartAngle) ) );
8380 m_aPages.back().appendPoint( aPoint, aLine );
8381 aLine.append(
" m " );
8384 for(
int i = 0;
i < nFragments;
i++ )
8386 const double fStartFragment = fStartAngle +
static_cast<double>(
i)*fFragmentDelta;
8387 const double fStopFragment = fStartFragment + fFragmentDelta;
8388 aPoint =
Point(
static_cast<int>(halfWidth * (cos(fStartFragment) - kappa*sin(fStartFragment) ) ),
8389 -
static_cast<int>(halfHeight * (sin(fStartFragment) + kappa*cos(fStartFragment) ) ) );
8391 m_aPages.back().appendPoint( aPoint, aLine );
8392 aLine.append(
' ' );
8394 aPoint =
Point(
static_cast<int>(halfWidth * (cos(fStopFragment) + kappa*sin(fStopFragment) ) ),
8395 -
static_cast<int>(halfHeight * (sin(fStopFragment) - kappa*cos(fStopFragment) ) ) );
8397 m_aPages.back().appendPoint( aPoint, aLine );
8398 aLine.append(
' ' );
8400 aPoint =
Point(
static_cast<int>(halfWidth * cos(fStopFragment) ),
8401 -
static_cast<int>(halfHeight * sin(fStopFragment) ) );
8403 m_aPages.back().appendPoint( aPoint, aLine );
8404 aLine.append(
" c\n" );
8407 if( bWithChord || bWithPie )
8411 m_aPages.back().appendPoint( aCenter, aLine );
8412 aLine.append(
" l " );
8414 aLine.append(
"h " );
8416 if( ! bWithChord && ! bWithPie )
8417 aLine.append(
"S\n" );
8420 aLine.append(
"B*\n" );
8422 aLine.append(
"S\n" );
8424 aLine.append(
"f*\n" );
8431 MARK(
"drawPolyLine" );
8433 sal_uInt16 nPoints = rPoly.
GetSize();
8442 OStringBuffer aLine( 20 * nPoints );
8443 m_aPages.back().appendPolygon( rPoly, aLine, rPoly[0] == rPoly[nPoints-1] );
8444 aLine.append(
"S\n" );
8451 MARK(
"drawPolyLine with LineInfo" );
8458 OStringBuffer aLine;
8459 aLine.append(
"q " );
8460 if(
m_aPages.back().appendLineInfo( rInfo, aLine ) )
8485 switch(rIn.GetLineJoin())
8507 switch(rIn.GetLineCap())
8514 case css::drawing::LineCap_ROUND:
8519 case css::drawing::LineCap_SQUARE:
8529 MARK(
"drawPolyLine with ExtLineInfo" );
8542 OStringBuffer aLine;
8543 aLine.append(
"q " );
8545 aLine.append(
" w" );
8565 aLine.append(
" 0 j " );
8566 appendDouble( fLimit, aLine );
8567 aLine.append(
" M" );
8575 aLine.append(
" [ " );
8578 m_aPages.back().appendMappedLength( dash, aLine );
8579 aLine.append(
' ' );
8581 aLine.append(
"] 0 d" );
8583 aLine.append(
"\n" );
8599 const sal_uInt32 nPolygonCount(aPolyPoly.
count());
8601 for( sal_uInt32 nPoly = 0; nPoly < nPolygonCount; nPoly++ )
8603 aLine.append( (nPoly != 0 && (nPoly & 7) == 0) ?
"\n" :
" " );
8605 const sal_uInt32 nPointCount(aPoly.
count());
8609 const sal_uInt32 nEdgeCount(aPoly.
isClosed() ? nPointCount : nPointCount - 1);
8612 for(sal_uInt32
a(0);
a < nEdgeCount;
a++)
8615 aLine.append(
" " );
8616 const sal_uInt32 nNextIndex((
a + 1) % nPointCount);
8622 aLine.append(
" m " );
8626 aLine.append(
" l" );
8633 aLine.append(
" S " );
8657 MARK(
"drawPixel" );
8671 OStringBuffer aLine( 20 );
8672 m_aPages.back().appendPoint( rPoint, aLine );
8673 aLine.append(
' ' );
8674 appendDouble( 1.0/
double(
GetDPIX()), aLine );
8675 aLine.append(
' ' );
8676 appendDouble( 1.0/
double(
GetDPIY()), aLine );
8677 aLine.append(
" re f\n" );
8692 emitComment(
"PDFWriterImpl::writeTransparentObject" );
8694 OStringBuffer aLine( 512 );
8697 aLine.append(
" 0 obj\n"
8702 aLine.append(
' ' );
8704 aLine.append(
' ' );
8706 aLine.append(
' ' );
8708 aLine.append(
" ]\n" );
8712 aLine.append(
"/Resources " );
8714 aLine.append(
" 0 R\n" );
8716 aLine.append(
"/Group<</S/Transparency/CS/DeviceRGB/K true>>\n" );
8719 aLine.append(
"/Length " );
8720 aLine.append(
static_cast<sal_Int32
>(nSize) );
8721 aLine.append(
"\n" );
8723 aLine.append(
"/Filter/FlateDecode\n" );
8724 aLine.append(
">>\n"
8730 aLine.setLength( 0 );
8737 aLine.setLength( 0 );
8739 aLine.append(
" 0 obj\n"
8744 aLine.append(
"/CA 1.0/ca 1.0" );
8749 aLine.append(
"/CA " );
8750 appendDouble( rObject.
m_fAlpha, aLine );
8753 appendDouble( rObject.
m_fAlpha, aLine );
8755 aLine.append(
"\n" );
8757 aLine.append(
">>\n"
8775 aDev->SetOutputSizePixel( rObject.
m_aSize );
8776 aDev->SetMapMode(
MapMode( MapUnit::MapPixel ) );
8778 aDev->SetDrawMode( aDev->GetDrawMode() |
8791 emitComment(
"PDFWriterImpl::writeGradientFunction" );
8793 OStringBuffer aLine( 120 );
8794 aLine.append( nFunctionObject );
8795 aLine.append(
" 0 obj\n"
8796 "<</FunctionType 0\n");
8799 case css::awt::GradientStyle_LINEAR:
8800 case css::awt::GradientStyle_AXIAL:
8801 aLine.append(
"/Domain[ 0 1]\n");
8804 aLine.append(
"/Domain[ 0 1 0 1]\n");
8806 aLine.append(
"/Size[ " );
8809 case css::awt::GradientStyle_LINEAR:
8812 case css::awt::GradientStyle_AXIAL:
8816 aLine.append(
static_cast<sal_Int32
>(aSize.
Width()) );
8817 aLine.append(
' ' );
8818 aLine.append(
static_cast<sal_Int32
>(aSize.
Height()) );
8820 aLine.append(
" ]\n"
8821 "/BitsPerSample 8\n"
8822 "/Range[ 0 1 0 1 0 1 ]\n"
8825 aLine.append( nStreamLengthObject );
8827 aLine.append(
" 0 R\n"
8828 "/Filter/FlateDecode"
8832 aLine.append(
" 0 R\n"
8837 sal_uInt64 nStartStreamPos = 0;
8845 case css::awt::GradientStyle_AXIAL:
8851 case css::awt::GradientStyle_LINEAR:
8865 for(
int y = aSize.
Height()-1;
y >= 0;
y-- )
8870 aCol[0] = aColor.
GetRed();
8880 sal_uInt64 nEndStreamPos = 0;
8883 aLine.setLength( 0 );
8884 aLine.append(
"\nendstream\nendobj\n\n" );
8889 aLine.setLength( 0 );
8890 aLine.append( nStreamLengthObject );
8891 aLine.append(
" 0 obj\n" );
8892 aLine.append(
static_cast<sal_Int64
>(nEndStreamPos-nStartStreamPos) );
8893 aLine.append(
"\nendobj\n\n" );
8897 aLine.setLength( 0 );
8899 aLine.append(
" 0 obj\n");
8902 case css::awt::GradientStyle_LINEAR:
8903 case css::awt::GradientStyle_AXIAL:
8904 aLine.append(
"<</ShadingType 2\n");
8907 aLine.append(
"<</ShadingType 1\n");
8909 aLine.append(
"/ColorSpace/DeviceRGB\n"
8910 "/AntiAlias true\n");
8940 case css::awt::GradientStyle_LINEAR:
8941 case css::awt::GradientStyle_AXIAL:
8943 aLine.append(
"/Domain[ 0 1 ]\n"
8948 aPoly.
Rotate( aCenter, 3600_deg10 - nAngle );
8950 aLine.append(
static_cast<sal_Int32
>(aPoly[0].
X()) );
8951 aLine.append(
" " );
8952 aLine.append(
static_cast<sal_Int32
>(aPoly[0].
Y()) );
8953 aLine.append(
" " );
8954 aLine.append(
static_cast<sal_Int32
>(aPoly[1].
X()));
8956 aLine.append(
static_cast<sal_Int32
>(aPoly[1].
Y()));
8957 aLine.append(
" ]\n");
8958 aLine.append(
"/Extend [true true]\n");
8962 aLine.append(
"/Domain[ 0 1 0 1 ]\n"
8964 aLine.append(
static_cast<sal_Int32
>(aSize.
Width()) );
8965 aLine.append(
" 0 0 " );
8966 aLine.append(
static_cast<sal_Int32
>(aSize.
Height()) );
8967 aLine.append(
" 0 0 ]\n");
8969 aLine.append(
"/Function " );
8970 aLine.append( nFunctionObject );
8971 aLine.append(
" 0 R\n"
8991 sal_Int32 nMaskObject = 0;
9010 OStringBuffer aLine(200);
9012 aLine.append(
" 0 obj\n"
9013 "<</Type/XObject/Subtype/Image/Width " );
9015 aLine.append(
" /Height " );
9017 aLine.append(
" /BitsPerComponent 8 " );
9019 aLine.append(
"/ColorSpace/DeviceRGB" );
9021 aLine.append(
"/ColorSpace/DeviceGray" );
9022 aLine.append(
"/Filter/DCTDecode/Length " );
9026 aLine.append(
" /SMask ");
9027 aLine.append( nMaskObject );
9028 aLine.append(
" 0 R " );
9030 aLine.append(
">>\nstream\n" );
9037 aLine.setLength( 0 );
9061 sal_Int32 nOldDPIX =
GetDPIX();
9062 sal_Int32 nOldDPIY =
GetDPIY();
9068 double fScaleX = 1.0 / aSize.
Width();
9069 double fScaleY = 1.0 / aSize.
Height();
9071 sal_Int32 nWrappedFormObject = 0;
9083 SAL_WARN(
"vcl.pdfwriter",
"PDFWriterImpl::writeReferenceXObject: failed to parse the document");
9087 std::vector<filter::PDFObjectElement*> aPages = pPDFDocument->GetPages();
9090 SAL_WARN(
"vcl.pdfwriter",
"PDFWriterImpl::writeReferenceXObject: no pages");
9099 SAL_WARN(
"vcl.pdfwriter",
"PDFWriterImpl::writeReferenceXObject: no page");
9103 double aOrigin[2] = { 0.0, 0.0 };
9106 const auto& rElements = pArray->GetElements();
9107 if (rElements.size() >= 4)
9110 for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx)
9113 aOrigin[nIdx] = pNumElement->GetValue();
9118 std::vector<filter::PDFObjectElement*> aContentStreams;
9120 aContentStreams.push_back(pContentStream);
9123 for (
const auto pElement : pArray->GetElements())
9133 aContentStreams.push_back(
pObject);
9137 if (aContentStreams.empty())
9139 SAL_WARN(
"vcl.pdfwriter",
"PDFWriterImpl::writeReferenceXObject: no content stream");
9144 std::vector<filter::PDFObjectElement*> aAnnots;
9147 for (
const auto pElement : pArray->GetElements())
9162 if (!pType || pType->GetValue() !=
"Annot")
9168 if (!pSubtype || pSubtype->GetValue() !=
"Link")
9177 if (!aAnnots.empty())
9181 std::map<sal_Int32, sal_Int32>
aMap;
9182 for (
const auto& pAnnot : aAnnots)
9186 m_aPages.back().m_aAnnotations.push_back(nNewId);
9194 OStringBuffer aLine;
9195 aLine.append(nWrappedFormObject);
9196 aLine.append(
" 0 obj\n");
9197 aLine.append(
"<< /Type /XObject");
9198 aLine.append(
" /Subtype /Form");
9207 sal_Int32 nRotAngle =
static_cast<sal_Int32
>(pRotate->GetValue()) % 360;
9209 sal_Int32 nAngle = -1 * nRotAngle;
9221 aMat.
translate(0.5 * nWidth, 0.5 * nHeight);
9223 aLine.append(
" /Matrix [ ");
9224 aLine.append(aMat.
a());
9226 aLine.append(aMat.
b());
9228 aLine.append(aMat.
c());
9230 aLine.append(aMat.
d());
9232 aLine.append(aMat.
e());
9234 aLine.append(aMat.
f());
9235 aLine.append(
" ] ");
9239 auto & rResources = rExternalPDFStream.getCopiedResources();
9242 aLine.append(
" /BBox [ ");
9243 aLine.append(aOrigin[0]);
9245 aLine.append(aOrigin[1]);
9247 aLine.append(aBBox.
getWidth() + aOrigin[0]);
9249 aLine.append(aBBox.
getHeight() + aOrigin[1]);
9253 aLine.append(
" /Filter/FlateDecode");
9254 aLine.append(
" /Length ");
9257 bool bCompressed =
false;
9261 aLine.append(
">>\nstream\n");
9264 emitComment(
"PDFWriterImpl::writeReferenceXObject, WrappedFormObject");
9274 aLine.append(
static_cast<const char*
>(aStream.
GetData()), aStream.
GetSize());
9280 aLine.append(
"\nendstream\nendobj\n\n");
9285 OStringBuffer aLine;
9288 emitComment(
"PDFWriterImpl::writeReferenceXObject, FormObject");
9295 aLine.append(
" 0 obj\n");
9296 aLine.append(
"<< /Type /XObject");
9297 aLine.append(
" /Subtype /Form");
9298 aLine.append(
" /Resources << /XObject<<");
9301 aLine.append(
" /Im");
9302 aLine.append(nObject);
9304 aLine.append(nObject);
9305 aLine.append(
" 0 R");
9307 aLine.append(
">> >>");
9308 aLine.append(
" /Matrix [ ");
9309 appendDouble(fScaleX, aLine);
9310 aLine.append(
" 0 0 ");
9311 appendDouble(fScaleY, aLine);
9312 aLine.append(
" 0 0 ]");
9313 aLine.append(
" /BBox [ 0 0 ");
9314 aLine.append(aSize.
Width());
9316 aLine.append(aSize.
Height());
9317 aLine.append(
" ]\n");
9322 aLine.append(
"/Ref<< /F << /Type /Filespec /F (<embedded file>) ");
9325 aLine.append(
"/UF (<embedded file>) ");
9327 aLine.append(
"/EF << /F ");
9329 aLine.append(
" 0 R >> >> /Page 0 >>\n");
9332 aLine.append(
"/Length ");
9334 OStringBuffer aStream;
9335 aStream.append(
"q ");
9340 aStream.append(aSize.
Width());
9341 aStream.append(
" 0 0 ");
9342 aStream.append(aSize.
Height());
9343 aStream.append(
" 0 0 cm\n");
9344 aStream.append(
"/Im");
9346 aStream.append(
" Do\n");
9351 aStream.append(
" 1 w\n");
9355 aStream.append(
"1 1 1 rg\n");
9356 aStream.append(
"0 0 ");
9357 aStream.append(aSize.
Width());
9358 aStream.append(
" ");
9359 aStream.append(aSize.
Height());
9360 aStream.append(
" re\n");
9361 aStream.append(
"f*\n");
9364 aStream.append(
"0 0 0 rg\n");
9367 aStream.append(
"/Im");
9368 aStream.append(nWrappedFormObject);
9369 aStream.append(
" Do\n");
9371 aStream.append(
"Q");
9372 aLine.append(aStream.getLength());
9374 aLine.append(
">>\nstream\n");
9380 aLine.append(aStream.getStr());
9386 aLine.append(
"\nendstream\nendobj\n\n");
9401 bool bWriteMask =
false;
9433 bool bTrueColor =
true;
9434 sal_Int32 nBitsPerComponent = 0;
9436 switch (ePixelFormat)
9445 nBitsPerComponent = 8;
9452 sal_Int32 nMaskObject = 0;
9456 emitComment(
"PDFWriterImpl::writeBitmapObject" );
9458 OStringBuffer aLine(1024);
9460 aLine.append(
" 0 obj\n"
9461 "<</Type/XObject/Subtype/Image/Width " );
9463 aLine.append(
"/Height " );
9465 aLine.append(
"/BitsPerComponent " );
9466 aLine.append( nBitsPerComponent );
9467 aLine.append(
"/Length " );
9468 aLine.append( nStreamLengthObject );
9469 aLine.append(
" 0 R\n" );
9472 if( nBitsPerComponent != 1 )
9474 aLine.append(
"/Filter/FlateDecode" );
9478 aLine.append(
"/Filter/CCITTFaxDecode/DecodeParms<</K -1/BlackIs1 true/Columns " );
9480 aLine.append(
">>\n" );
9485 aLine.append(
"/ColorSpace" );
9487 aLine.append(
"/DeviceRGB\n" );
9490 aLine.append(
"/DeviceGray\n" );
9495 assert( nBlackIndex == 0 || nBlackIndex == 1);
9501 if( nBlackIndex == 1 )
9502 aLine.append(
"/Decode[1 0]\n" );
9507 aLine.append(
"/Decode[" );
9512 aLine.append( pAccess->
GetPalette()[0].GetRed() / 255.0 );
9513 aLine.append(
" " );
9514 aLine.append( pAccess->
GetPalette()[1].GetRed() / 255.0 );
9515 aLine.append(
"]\n" );
9521 aLine.append(
"[ /Indexed/DeviceRGB " );
9523 aLine.append(
"\n<" );
9554 appendHex( rColor.
GetRed(), aLine );
9555 appendHex( rColor.
GetGreen(), aLine );
9556 appendHex( rColor.
GetBlue(), aLine );
9559 aLine.append(
">\n]\n" );
9564 aLine.append(
"/ColorSpace/DeviceGray\n"
9565 "/Decode [ 1 0 ]\n" );
9574 aLine.append(
"/SMask " );
9576 aLine.append(
"/Mask " );
9577 aLine.append( nMaskObject );
9578 aLine.append(
" 0 R\n" );
9584 aLine.append(
">>\n"
9587 sal_uInt64 nStartPos = 0;
9601 const int nScanLineBytes = ((pAccess->
GetBitCount() * pAccess->
Width()) + 7U) / 8U;
9610 const int nScanLineBytes = pAccess->
Width()*3;
9611 std::unique_ptr<sal_uInt8[]> xCol(
new sal_uInt8[nScanLineBytes]);
9617 xCol[3*
x+0] = aColor.
GetRed();
9628 sal_uInt64 nEndPos = 0;
9630 aLine.setLength( 0 );
9631 aLine.append(
"\nendstream\nendobj\n\n" );
9634 aLine.setLength( 0 );
9635 aLine.append( nStreamLengthObject );
9636 aLine.append(
" 0 obj\n" );
9637 aLine.append(
static_cast<sal_Int64
>(nEndPos-nStartPos) );
9638 aLine.append(
"\nendobj\n\n" );
9684 MARK(
"drawJPGBitmap" );
9686 OStringBuffer aLine( 80 );
9692 if( ! (rSizePixel.
Width() && rSizePixel.
Height()) )
9705 BitmapEx aBmpEx( aBmp, rAlphaMask );
9714 pStream->WriteStream( rDCTData );
9719 aID.
m_nSize = pStream->Tell();
9725 std::vector< JPGEmit >::const_iterator it = std::find_if(
m_aJPGs.begin(),
m_aJPGs.end(),
9726 [&](
const JPGEmit& arg) { return aID == arg.m_aID; });
9743 aLine.append(
"q " );
9744 sal_Int32 nCheckWidth = 0;
9745 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rTargetArea.
GetWidth()), aLine,
false, &nCheckWidth );
9746 aLine.append(
" 0 0 " );
9747 sal_Int32 nCheckHeight = 0;
9748 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rTargetArea.
GetHeight()), aLine,
true, &nCheckHeight );
9749 aLine.append(
' ' );
9751 aLine.append(
" cm\n/Im" );
9752 sal_Int32 nObject = it->m_aReferenceXObject.getObject();
9753 aLine.append(nObject);
9754 aLine.append(
" Do Q\n" );
9755 if( nCheckWidth == 0 || nCheckHeight == 0 )
9758 aLine.setLength( 0 );
9759 aLine.append(
"\n%jpeg image /Im" );
9760 aLine.append( it->m_nObject );
9761 aLine.append(
" scaled to zero size, omitted\n" );
9765 OString aObjName =
"Im" + OString::number(nObject);
9766 pushResource( ResourceKind::XObject, aObjName, nObject );
9772 OStringBuffer aLine( 80 );
9775 aLine.append(
"q " );
9779 aLine.append(
' ' );
9781 sal_Int32 nCheckWidth = 0;
9782 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rDestSize.
Width()), aLine,
false, &nCheckWidth );
9783 aLine.append(
" 0 0 " );
9784 sal_Int32 nCheckHeight = 0;
9785 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rDestSize.
Height()), aLine,
true, &nCheckHeight );
9786 aLine.append(
' ' );
9788 aLine.append(
" cm\n/Im" );
9790 aLine.append(nObject);
9791 aLine.append(
" Do Q\n" );
9792 if( nCheckWidth == 0 || nCheckHeight == 0 )
9795 aLine.setLength( 0 );
9796 aLine.append(
"\n%bitmap image /Im" );
9798 aLine.append(
" scaled to zero size, omitted\n" );
9816 std::list<BitmapEmit>::const_iterator it = std::find_if(rBitmaps.begin(), rBitmaps.end(),
9817 [&](
const BitmapEmit& arg) { return aID == arg.m_aID; });
9818 if (it == rBitmaps.end())
9821 rBitmaps.front().m_aID = aID;
9822 rBitmaps.front().m_aBitmap = aBitmap;
9825 createEmbeddedFile(rGraphic, rBitmaps.front().m_aReferenceXObject, rBitmaps.front().m_nObject);
9826 it = rBitmaps.begin();
9829 sal_Int32 nObject = it->m_aReferenceXObject.getObject();
9830 OString aObjName =
"Im" + OString::number(nObject);
9831 pushResource(ResourceKind::XObject, aObjName, nObject, rResourceDict, rOutputStreams);
9843 MARK(
"drawBitmap (Bitmap)" );
9855 MARK(
"drawBitmap (BitmapEx)" );
9877 [&](
const GradientEmit& arg) { return ((rGradient == arg.m_aGradient) && (aPtSize == arg.m_aSize) ); });
9888 OStringBuffer aObjName( 16 );
9889 aObjName.append(
'P' );
9890 aObjName.append( it->m_nObject );
9891 pushResource( ResourceKind::Shading, aObjName.makeStringAndClear(), it->m_nObject );
9893 return it->m_nObject;
9898 MARK(
"drawGradient (Rectangle)" );
9903 aTranslate +=
Point( 0, 1 );
9907 OStringBuffer aLine( 80 );
9908 aLine.append(
"q 1 0 0 1 " );
9909 m_aPages.back().appendPoint( aTranslate, aLine );
9910 aLine.append(
" cm " );
9913 aLine.append(
"q " );
9914 aLine.append(
"0 0 " );
9915 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rRect.
GetWidth()), aLine,
false );
9916 aLine.append(
' ' );
9917 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rRect.
GetHeight()), aLine );
9918 aLine.append(
" re W n\n" );
9920 aLine.append(
"/P" );
9921 aLine.append( nGradient );
9922 aLine.append(
" sh " );
9925 aLine.append(
"Q 0 0 " );
9926 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rRect.
GetWidth()), aLine,
false );
9927 aLine.append(
' ' );
9928 m_aPages.back().appendMappedLength(
static_cast<sal_Int32
>(rRect.
GetHeight()), aLine );
9929 aLine.append(
" re S " );
9931 aLine.append(
"Q\n" );
9937 MARK(
"drawHatch" );
9941 if( rPolyPoly.
Count() )
9945 aPolyPoly.
Optimize( PolyOptimizeFlags::NO_SAME );
9955 MARK(
"drawWallpaper" );
9957 bool bDrawColor =
false;
9958 bool bDrawGradient =
false;
9959 bool bDrawBitmap =
false;
9984 bDrawGradient =
true;
10030 m_aPages.back().convertRect( aConvertRect );
10032 OString aImageName =
"Im" + OString::number( rEmit.
m_nObject );
10035 OStringBuffer aTilingStream( 32 );
10036 appendFixedInt( aConvertRect.
GetWidth(), aTilingStream );
10037 aTilingStream.append(
" 0 0 " );
10038 appendFixedInt( aConvertRect.
GetHeight(), aTilingStream );
10039 aTilingStream.append(
" 0 0 cm\n/" );
10040 aTilingStream.append( aImageName );
10041 aTilingStream.append(
" Do\n" );
10047 m_aTilings.back().m_pTilingStream->WriteBytes(
10048 aTilingStream.getStr(), aTilingStream.getLength() );
10052 m_aTilings.back().m_aTransform.matrix[2] = double(aConvertRect.
Left() % aConvertRect.
GetWidth()) / fDivisor;
10053 m_aTilings.back().m_aTransform.matrix[5] = double(aConvertRect.
Top() % aConvertRect.
GetHeight()) / fDivisor;
10058 OStringBuffer aObjName( 16 );
10059 aObjName.append(
'P' );
10060 aObjName.append(
m_aTilings.back().m_nObject );
10061 OString aPatternName( aObjName.makeStringAndClear() );
10065 OStringBuffer aLine( 100 );
10066 aLine.append(
"q /Pattern cs /" );
10067 aLine.append( aPatternName );
10068 aLine.append(
" scn " );
10069 m_aPages.back().appendRect( rRect, aLine );
10070 aLine.append(
" f Q\n" );
10078 bDrawBitmap =
true;
10084 bDrawGradient =
true;
10090 bDrawGradient =
true;
10094 if( bDrawGradient )
10112 OStringBuffer aLine( 20 );
10113 aLine.append(
"q " );
10114 m_aPages.back().appendRect( rRect, aLine );
10115 aLine.append(
" W n\n" );
10124 OStringBuffer aLine( 256 );
10128 if( rNewState.
m_nUpdateFlags & GraphicsStateUpdateFlags::ClipRegion )
10137 aLine.append(
"Q " );
10150 aLine.append(
"q ");
10160 aLine.append(
"0 0 m h " );
10162 aLine.append(
"W* n\n" );
10189 if( rNewState.
m_nUpdateFlags & GraphicsStateUpdateFlags::DigitLanguage )
10202 aLine.append(
"\n" );
10213 aLine.append(
"\n" );
10217 if( rNewState.
m_nUpdateFlags & GraphicsStateUpdateFlags::TransparentPercent )
10228 if ((
mode != Mode::NOWRITE) && !aLine.isEmpty())
10315 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
10337 aB2DPointA *= aConvertA;
10338 aB2DPointB *= aConvertA;
10339 aB2DPointA -= aB2DPointB;
10344 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
10362 m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion;
10386 auto & rNoteEntry =
m_aNotes.back();
10388 rNoteEntry.m_aPopUpAnnotation.m_nObject =
createObject();
10389 rNoteEntry.m_aPopUpAnnotation.m_nParentObject = rNoteEntry.m_nObject;
10390 rNoteEntry.m_aContents = rNote;
10391 rNoteEntry.m_aRect = rRect;
10392 rNoteEntry.m_nPage = nPageNr;
10394 m_aPages[nPageNr].convertRect(rNoteEntry.m_aRect);
10397 m_aPages[nPageNr].m_aAnnotations.push_back(rNoteEntry.m_nObject);
10398 m_aPages[nPageNr].m_aAnnotations.push_back(rNoteEntry.m_aPopUpAnnotation.m_nObject);
10413 m_aLinks.back().m_nPage = nPageNr;
10419 m_aPages[ nPageNr ].m_aAnnotations.push_back(
m_aLinks.back().m_nObject );
10434 m_aScreens.emplace_back(rAltText, rMimeType);
10479 m_aDests.back().m_nPage = nPageNr;
10501 m_aLinks[ nLinkId ].m_nDest = nDestId;
10516 m_xTrans = util::URLTransformer::create(xContext);
10520 aURL.Complete = rURL;
10540 m_aScreens[nScreenId].m_aTempFileURL = rURL;
10573 m_aOutline[ nNewParent ].m_aChildren.push_back( nItem );
10595 static constexpr auto aTagStrings = frozen::make_map<PDFWriter::StructElement, const char*>({
10642 auto it = aTagStrings.find(
eType );
10644 return it != aTagStrings.end() ? it->second :
"Div";
10652 if (aAlias != aTag)
10669 OStringBuffer aLine( 128 );
10671 aLine.append(
"/" );
10676 aLine.append(
"<</MCID " );
10677 aLine.append( nMCID );
10678 aLine.append(
">>BDC\n" );
10682 SAL_INFO(
"vcl.pdfwriter",
"beginning marked content id " << nMCID <<
" on page object "
10699 OString aLine =
"/Artifact ";
10738 bool bEmit =
false;
10788 const std::vector< sal_Int32 >& rRootChildren =
m_aStructure[0].m_aChildren;
10789 auto it = std::find_if(rRootChildren.begin(), rRootChildren.end(),
10790 [&](sal_Int32 nElement) {
10791 return m_aStructure[nElement].m_oType
10792 && *m_aStructure[nElement].m_oType == PDFWriter::Document; });
10793 if( it != rRootChildren.end() )
10796 SAL_WARN(
"vcl.pdfwriter",
"Structure element inserted to StructTreeRoot that is not a document" );
10799 OSL_FAIL(
"document structure in disorder !" );
10803 OSL_FAIL(
"PDF document structure MUST be contained in a Document element" );
10822 OStringBuffer aNameBuf( rAlias.size() );
10823 appendName( rAlias, aNameBuf );
10824 OString aAliasName( aNameBuf.makeStringAndClear() );
10850 assert(
id != -1 &&
"cid#1538888 doesn't consider above m_aContext.Tagged");
10861 OStringBuffer aLine(
"beginStructureElement " );
10863 aLine.append(
": " );
10866 :
"<placeholder>" );
10869 aLine.append(
" aliased as \"" );
10871 aLine.append(
'\"' );
10898 OStringBuffer aLine;
10901 aLine.append(
"endStructureElement " );
10903 aLine.append(
": " );
10906 :
"<placeholder>" );
10909 aLine.append(
" aliased as \"" );
10911 aLine.append(
'\"' );
10930void removePlaceholderSEImpl(std::vector<PDFStructureElement> & rStructure,
10931 std::vector<sal_Int32>::iterator & rParentIt)
10934 removePlaceholderSE(rStructure, rEle);
10943 rParentIt = rParent.m_aChildren.erase(rParentIt);
10944 std::vector<sal_Int32> children;
10945 for (
auto const child : rEle.m_aChildren)
10951 rParentIt = rParent.m_aChildren.insert(rParentIt, children.begin(), children.end())
10961void removePlaceholderSE(std::vector<PDFStructureElement> & rStructure, PDFStructureElement& rEle)
10963 for (
auto it = rEle.m_aChildren.begin(); it != rEle.m_aChildren.end(); )
10965 removePlaceholderSEImpl(rStructure, it);
10999 OSL_FAIL(
"PDFWriterImpl::addInternalStructureContainer: invalid child structure element" );
11000 SAL_INFO(
"vcl.pdfwriter",
"PDFWriterImpl::addInternalStructureContainer: invalid child structure element with id " << child );
11006 OSL_FAIL(
"PDFWriterImpl::emitStructure: invalid child structure id" );
11007 SAL_INFO(
"vcl.pdfwriter",
"PDFWriterImpl::addInternalStructureContainer: invalid child structure id " << child );
11021 std::list< PDFStructureElementKid > aNewKids;
11022 std::vector< sal_Int32 > aNewChildren;
11025 OString aAliasName(
"Div");
11042 aNewKids.emplace_back( rEleNew.
m_nObject );
11043 aNewChildren.push_back( nNewId );
11045 std::vector< sal_Int32 >::iterator aChildEndIt( rEle.
m_aChildren.begin() );
11046 std::list< PDFStructureElementKid >::iterator aKidEndIt( rEle.
m_aKids.begin() );
11066 rEle.
m_aKids.insert( rEle.
m_aKids.begin(), aNewKids.begin(), aNewKids.end() );
11072 bool bSuccess =
false;
11083 OStringBuffer aLine(
"setCurrentStructureElement " );
11085 aLine.append(
": " );
11088 :
"<placeholder>" );
11091 aLine.append(
" aliased as \"" );
11093 aLine.append(
'\"' );
11096 aLine.append(
" (inside NonStruct)" );
11111 bool bInsert =
false;
11352 bool bInsert =
false;
11470 "rejecting setStructureAttributeNumerical( " <<
getAttributeTag( eAttr )
11471 <<
", " <<
static_cast<int>(
nValue)
11539 m_aPages[ nPageNr ].m_nTransTime = nMilliSec;
11549 std::unordered_map< OUString, sal_Int32 > aOnValues;
11550 bool bIsUnique =
true;
11551 for (
auto const& nKidIndex : rGroupWidget.
m_aKidsIndex)
11553 const OUString& rVal =
m_aWidgets[nKidIndex].m_aOnValue;
11554 SAL_INFO(
"vcl.pdfwriter",
"OnValue: " << rVal);
11555 if( aOnValues.find( rVal ) == aOnValues.end() )
11557 aOnValues[ rVal ] = 1;
11567 SAL_INFO(
"vcl.pdfwriter",
"enforcing unique OnValues" );
11570 for (
auto const& nKidIndex : rGroupWidget.
m_aKidsIndex)
11573 rKid.
m_aOnValue = OUString::number( nKid+1 );
11580 for (
auto const& nKidIndex : rGroupWidget.
m_aKidsIndex)
11588 auto stream_it = app_it->second.find(
"Yes" );
11589 if( stream_it != app_it->second.end() )
11592 app_it->second.erase( stream_it );
11595 (app_it->second)[
aBuf.makeStringAndClear() ] = pStream;
11598 SAL_INFO(
"vcl.pdfwriter",
"error: RadioButton without \"Yes\" stream" );
11607 auto stream_it = app_it->second.find(
"Off" );
11608 if( stream_it != app_it->second.end() )
11611 app_it->second.erase( stream_it );
11614 (app_it->second)[
aBuf.makeStringAndClear() ] = pStream;
11617 SAL_INFO(
"vcl.pdfwriter",
"error: RadioButton without \"Off\" stream" );
11632 sal_Int32 nRadioGroupWidget = -1;
11652 nRadioGroupWidget = it->second;
11654 return nRadioGroupWidget;
11665 bool sigHidden(
true);
11674 sal_Int32 nRadioGroupWidget = -1;
11706 rNewWidget.
m_nFlags |= 0x00010000;
11707 if( !rBtn.
URL.isEmpty() )
11748 m_aPages[ nPageNr ].convertRect( aRect );
11759 = rBox.
Checked ? std::u16string_view(
u"Yes") : std::u16string_view(
u"Off" );
11775 rNewWidget.
m_nFlags |= 0x00020000;
11777 rNewWidget.
m_nFlags |= 0x00200000;
11789 rNewWidget.
m_nFlags |= 0x00060000;
11817 rNewWidget.
m_nFlags |= 0x00001000;
11821 rNewWidget.
m_nFlags |= 0x00002000;
11823 rNewWidget.
m_nFlags |= 0x00100000;
11835#if HAVE_FEATURE_NSS
constexpr float ARTIFICIAL_ITALIC_SKEW
constexpr auto convertMm100ToPoint(N n)
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
Bitmap const & GetBitmap() const
Base class used mainly for the LibreOffice Desktop class.
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
const AlphaMask & GetAlphaMask() const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Bitmap GetBitmap(Color aTransparentReplaceColor) const
const MapMode & GetPrefMapMode() const
const Size & GetPrefSize() const
const Size & GetSizePixel() const
tools::Long Height() const
tools::Long Width() const
const BitmapPalette & GetPalette() const
sal_uInt16 GetBestPaletteIndex(const BitmapColor &rBitmapColor) const
ScanlineFormat GetScanlineFormat() const
sal_uInt16 GetPaletteEntryCount() const
sal_uInt16 GetBitCount() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
Scanline GetScanline(tools::Long nY) const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
BitmapChecksum GetChecksum() const
Size GetSizePixel() const
bool HasGreyPaletteAny() const
vcl::PixelFormat getPixelFormat() const
sal_uInt8 GetLuminance() const
sal_uInt8 GetBlue() const
bool IsTransparent() const
sal_uInt8 GetGreen() const
bool IsMicrosoftSymbolEncoded() const
FontFamily GetFamilyType() const
FontItalic GetItalic() const
const OUString & GetFamilyName() const
FontPitch GetPitch() const
tools::Long GetLineHeight() const
tools::Long GetDescent() const
tools::Long GetAscent() const
tools::Rectangle m_aFontBBox
FontType m_nFontType
font-type of subset result
int m_nAscent
all metrics in PS font units
bool GetGlyphBoundRect(const LogicalFontInstance *, tools::Rectangle &) const
sal_GlyphId glyphId() const
bool IsClusterStart() const
Degree10 GetAngle() const
sal_uInt16 GetBorder() const
const Color & GetEndColor() const
const Color & GetStartColor() const
css::awt::GradientStyle GetStyle() const
void GetBoundRect(const tools::Rectangle &rRect, tools::Rectangle &rBoundRect, Point &rCenter) const
static ErrCode Import(SvStream &rIStm, Graphic &rGraphic, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
const Color & GetColor() const
OUString GetMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static OUString GetRelURL(std::u16string_view rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
INetProtocol GetProtocol() const
bool SetMark(std::u16string_view rTheFragment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const ImplTextLineInfo & GetLine(sal_Int32 nLine) const
sal_Int32 GetIndex() const
tools::Long GetWidth() const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
void getIsoLanguageScriptCountry(OUString &rLanguage, OUString &rScript, OUString &rCountry) const
basegfx::B2DPolyPolygon GetGlyphOutlineUntransformed(sal_GlyphId) const
const vcl::font::PhysicalFontFace * GetFontFace() const
double GetGlyphWidth(sal_GlyphId, bool=false, bool=true) const
FontMetricDataRef mxFontMetric
const vcl::font::FontSelectPattern & GetFontSelectPattern() const
sal_GlyphId GetGlyphIndex(uint32_t, uint32_t=0) const
void SetOrigin(const Point &rOrigin)
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Point & GetOrigin() const
const Fraction & GetScaleY() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
LogicalFontInstance const * GetFontInstance() const
basegfx::B2DHomMatrix GetViewTransformation() const
SAL_DLLPRIVATE tools::Long ImplDevicePixelToLogicHeight(tools::Long nHeight) const
Convert device pixels to a height in logical units.
void SetFont(const vcl::Font &rNewFont)
std::shared_ptr< ImplFontCache > mxFontCache
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
virtual bool ImplNewFont() const
basegfx::B2DHomMatrix GetInverseViewTransformation() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
std::shared_ptr< vcl::font::PhysicalFontCollection > mxFontCollection
void DrawHatch(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
OUString GetEllipsisString(const OUString &rStr, tools::Long nMaxWidth, DrawTextFlags nStyle=DrawTextFlags::EndEllipsis) const
SAL_DLLPRIVATE Point SubPixelToLogic(const basegfx::B2DPoint &rDevicePt) const
SAL_DLLPRIVATE tools::Long GetEmphasisDescent() const
SAL_DLLPRIVATE void SetDPIY(sal_Int32 nDPIY)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
void SetDigitLanguage(LanguageType)
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
SAL_DLLPRIVATE tools::Long ImplDevicePixelToLogicWidth(tools::Long nWidth) const
Convert device pixels to a width in logical units.
FontMetric GetFontMetric() const
SAL_DLLPRIVATE void ImplInitTextLineSize()
static SAL_DLLPRIVATE tools::Long ImplGetTextLines(const tools::Rectangle &rRect, tools::Long nTextHeight, ImplMultiTextLineInfo &rLineInfo, tools::Long nWidth, const OUString &rStr, DrawTextFlags nStyle, const vcl::ITextLayout &_rLayout)
const MapMode & GetMapMode() const
SAL_DLLPRIVATE void ImplInitAboveTextLineSize()
SAL_DLLPRIVATE tools::Long GetEmphasisAscent() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
std::unique_ptr< SalLayout > ImplLayout(const OUString &, sal_Int32 nIndex, sal_Int32 nLen, const Point &rLogicPos=Point(0, 0), tools::Long nLogicWidth=0, KernArraySpan aKernArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, SalLayoutFlags flags=SalLayoutFlags::NONE, vcl::text::TextLayoutCache const *=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
SAL_DLLPRIVATE void SetDPIX(sal_Int32 nDPIX)
SAL_DLLPRIVATE void ImplUpdateFontData()
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
static SalLayoutGlyphsCache * self()
virtual double GetTextWidth() const
basegfx::B2DPoint GetDrawPosition(const basegfx::B2DPoint &rRelative=basegfx::B2DPoint(0, 0)) const
basegfx::B2DPoint & DrawBase()
virtual bool GetNextGlyph(const GlyphItem **pGlyph, basegfx::B2DPoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const =0
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetDarkShadowColor() const
const Color & GetFieldTextColor() const
const Color & GetShadowColor() const
const Color & GetFieldColor() const
const Color & GetRadioCheckTextColor() const
const vcl::Font & GetRadioCheckFont() const
const vcl::Font & GetFieldFont() const
const Color & GetCheckedColor() const
const vcl::Font & GetPushButtonFont() const
const Color & GetLightBorderColor() const
const Color & GetLightColor() const
const Color & GetDialogColor() const
const Color & GetButtonTextColor() const
virtual sal_uInt64 TellEnd() override
std::size_t WriteBytes(const void *pData, std::size_t nSize)
bool SetStreamSize(sal_uInt64 nSize)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteStream(SvStream &rStream)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true, bool bAlphaMaskTransparent=false)
void SetReferenceDevice(RefDevMode)
virtual void dispose() override
const BitmapEx & GetBitmap() const
const Color & GetColor() const
WallpaperStyle GetStyle() const
Gradient GetGradient() const
const tools::Rectangle & GetRect() const
tools::Long EndCompression()
void BeginCompression(int nCompressLevel=ZCODEC_DEFAULT_COMPRESSION, bool gzLib=false)
void Write(SvStream &rOStm, const sal_uInt8 *pData, sal_uInt32 nSize)
void rotate(double fRadiant)
void translate(double fX, double fY)
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
void transform(const basegfx::B2DHomMatrix &rMatrix)
bool isPrevControlPointUsed(sal_uInt32 nIndex) const
bool isNextControlPointUsed(sal_uInt32 nIndex) const
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const
B2DRange const & getB2DRange() const
basegfx::B2DPoint getNextControlPoint(sal_uInt32 nIndex) const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
std::vector< unsigned char > finalize()
void update(const unsigned char *pInput, size_t length)
is an implementation of the ITextLayout interface which simply delegates its calls to the respective ...
ExternalPDFStream & get(sal_uInt32 nIndex)
sal_Int32 store(BinaryDataContainer const &rDataContainer)
tools::Long GetFontHeight() const
void SetFontSize(const Size &)
FontFamily GetFamilyType()
void SetOutline(bool bOutline)
void SetAverageFontWidth(tools::Long nWidth)
void SetColor(const Color &)
FontStrikeout GetStrikeout() const
FontLineStyle GetOverline() const
FontRelief GetRelief() const
FontEmphasisMark GetEmphasisMark() const
void SetItalic(FontItalic)
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
TextAlign GetAlignment() const
const Size & GetFontSize() const
bool IsUnderlineAbove() const
const Color & GetColor() const
void SetFamilyName(const OUString &rFamilyName)
FontLineStyle GetUnderline() const
void SetShadow(bool bShadow)
void SetRelief(FontRelief)
bool IsWordLineMode() const
Degree10 GetOrientation() const
FontEmphasisMark GetEmphasisMarkStyle() const
const Color & GetFillColor() const
tools::Long GetAverageFontWidth() const
bool writeBuffer(std::string_view aBuffer)
Copies objects from one PDF file into another one.
static sal_Int32 copyPageStreams(std::vector< filter::PDFObjectElement * > &rContentStreams, SvMemoryStream &rStream, bool &rCompressed)
Copies page one or more page streams from rContentStreams into rStream.
void copyPageResources(filter::PDFObjectElement *pPage, OStringBuffer &rLine)
Copies resources of pPage into rLine.
sal_Int32 copyExternalResource(SvMemoryStream &rDocBuffer, filter::PDFObjectElement &rObject, std::map< sal_Int32, sal_Int32 > &rCopiedResources)
Copies a single resource from an external document, returns the new object ID in our document.
PDFStreamIf(PDFWriterImpl *pWriter)
virtual void SAL_CALL flush() override
virtual void SAL_CALL closeOutput() override
virtual void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
VclPtr< PDFWriterImpl > m_pWriter
static void computeDocumentIdentifier(std::vector< sal_uInt8 > &o_rIdentifier, const vcl::PDFWriter::PDFDocInfo &i_rDocInfo, const OString &i_rCString1, OString &o_rCString2)
std::list< GradientEmit > m_aGradients
sal_Int64 m_nSignatureContentOffset
sal_Int32 emitResources()
void drawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWall)
void setTextAlign(TextAlign eAlign)
std::map< sal_Int32, sal_Int32 > m_aLinkPropertyMap
bool emitScreenAnnotations()
void moveClipRegion(sal_Int32 nX, sal_Int32 nY)
sal_Int64 m_nSignatureLastByteRangeNoOffset
bool updateObject(sal_Int32 n) override
See vcl::PDFObjectContainer::updateObject().
void beginStructureElement(sal_Int32 id)
void drawEllipse(const tools::Rectangle &rRect)
void addInternalStructureContainer(PDFStructureElement &rEle)
void enableStringEncryption(sal_Int32 nObject)
void setFont(const Font &rFont)
sal_Int32 findRadioGroupWidget(const PDFWriter::RadioButtonWidget &rRadio)
void setAlternateText(const OUString &rText)
sal_Int32 emitBuildinFont(const pdf::BuildinFontFace *, sal_Int32 nObject)
~PDFWriterImpl() override
sal_Int32 emitStructParentTree(sal_Int32 nTreeObject)
sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace *, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream)
void beginStructureElementMCSeq()
static void convertLineInfoToExtLineInfo(const LineInfo &rIn, PDFWriter::ExtLineInfo &rOut)
std::set< PDFWriter::ErrorCode > m_aErrors
sal_Int32 addEmbeddedFile(BinaryDataContainer const &rDataContainer)
void createNote(const tools::Rectangle &rRect, const PDFNote &rNote, sal_Int32 nPageNr)
std::map< const vcl::font::PhysicalFontFace *, FontSubset > m_aSubsets
void setActualText(const OUString &rText)
std::map< const vcl::font::PhysicalFontFace *, EmbedFont > m_aSystemFonts
static void emitPopupAnnotationLine(OStringBuffer &aLine, PDFPopupAnnotation const &rPopUp)
void drawPolyLine(const tools::Polygon &rPoly)
sal_Int32 m_nRC4KeyLength
std::list< GraphicsState > m_aGraphicsStack
GraphicsState m_aCurrentPDFState
std::map< const vcl::font::PhysicalFontFace *, FontSubset > m_aType3Fonts
std::unordered_map< OString, OString > m_aRoleMap
void createWidgetFieldName(sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget &i_rInWidget)
sal_Int32 createControl(const PDFWriter::AnyWidget &rControl, sal_Int32 nPageNr=-1)
void writeTransparentObject(TransparencyEmit &rObject)
sal_Int32 m_nCurrentStructElement
void drawVerticalGlyphs(const std::vector< PDFGlyph > &rGlyphs, OStringBuffer &rLine, const Point &rAlignOffset, const Matrix3 &rRotScale, double fAngle, double fXScale, sal_Int32 nFontHeight)
const char * getStructureTag(PDFWriter::StructElement)
void drawPolyPolygon(const tools::PolyPolygon &rPolyPoly)
void endStructureElementMCSeq(EndMode=EndMode::Default)
void addRoleMap(OString aAlias, PDFWriter::StructElement eType)
sal_Int32 m_nCatalogObject
OString emitStructureAttributes(PDFStructureElement &rEle)
std::unordered_set< sal_Int32 > m_StructElemObjsWithID
std::vector< PDFLink > m_aLinks
std::vector< PDFEmbeddedFile > m_aEmbeddedFiles
Contains embedded files.
static sal_Int32 computeAccessPermissions(const vcl::PDFWriter::PDFEncryptionProperties &i_rProperties, sal_Int32 &o_rKeyLength, sal_Int32 &o_rRC4KeyLength)
sal_Int32 createLink(const tools::Rectangle &rRect, sal_Int32 nPageNr, OUString const &rAltText)
void appendLiteralStringEncrypt(std::u16string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer &rOutBuffer, rtl_TextEncoding nEnc=RTL_TEXTENCODING_ASCII_US)
std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets
void initStructureElement(sal_Int32 id, PDFWriter::StructElement eType, std::u16string_view rAlias)
sal_Int32 ensureStructureElement()
std::list< StreamRedirect > m_aOutputStreams
void drawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
void drawTextLine(const Point &rPos, tools::Long nWidth, FontStrikeout eStrikeout, FontLineStyle eUnderline, FontLineStyle eOverline, bool bUnderlineAbove)
OString m_aCreationMetaDateString
void newPage(double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation)
bool emitNoteAnnotations()
void drawStraightTextLine(OStringBuffer &aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove)
void setOutlineItemDest(sal_Int32 nItem, sal_Int32 nDestID)
bool writeGradientFunction(GradientEmit const &rObject)
void drawText(const Point &rPos, const OUString &rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines=true)
std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace *, EmbedFont const &)
void createDefaultRadioButtonAppearance(PDFWidget &, const PDFWriter::RadioButtonWidget &rWidget)
void drawStretchText(const Point &rPos, sal_Int32 nWidth, const OUString &rText, sal_Int32 nIndex, sal_Int32 nLen)
void writeG4Stream(BitmapReadAccess const *i_pBitmap)
bool emitLinkAnnotations()
PDFWriter::PDFWriterContext m_aContext
void createDefaultPushButtonAppearance(PDFWidget &, const PDFWriter::PushButtonWidget &rWidget)
void drawStrikeoutLine(OStringBuffer &aLine, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor)
void drawHorizontalGlyphs(const std::vector< PDFGlyph > &rGlyphs, OStringBuffer &rLine, const Point &rAlignOffset, bool bFirst, double fAngle, double fXScale, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight)
void setOutlineItemText(sal_Int32 nItem, std::u16string_view rText)
std::list< BitmapEmit > m_aBitmaps
PDFWriterImpl(const PDFWriter::PDFWriterContext &rContext, const css::uno::Reference< css::beans::XMaterialHolder > &, PDFWriter &)
std::vector< PDFNamedDest > m_aNamedDests
bool checkEmitStructure()
checks whether a non struct element lies in the ancestor hierarchy of the current structure element
void setMapMode(const MapMode &rMapMode)
sal_Int32 emitDocumentMetadata()
void setOutlineItemParent(sal_Int32 nItem, sal_Int32 nNewParent)
void checkAndEnableStreamEncryption(sal_Int32 nObject) override
bool emitEmbeddedFiles()
Writes embedded files.
sal_Int32 updateOutlineItemCount(std::vector< sal_Int32 > &rCounts, sal_Int32 nItemLevel, sal_Int32 nCurrentItemId)
void setLinkURL(sal_Int32 nLinkId, const OUString &rURL)
void endTransparencyGroup(const tools::Rectangle &rBoundingBox, sal_uInt32 nTransparentPercent)
std::unique_ptr< SvMemoryStream > m_pMemStream
void disableStreamEncryption() override
::comphelper::Hash m_DocDigest
void setScreenStream(sal_Int32 nScreenId, const OUString &rURL)
void drawArc(const tools::Rectangle &rRect, const Point &rStart, const Point &rStop, bool bWithPie, bool bWidthChord)
void drawStrikeoutChar(const Point &rPos, tools::Long nWidth, FontStrikeout eStrikeout)
std::vector< PDFPage > m_aPages
void appendBuildinFontsToDict(OStringBuffer &rDict) const
std::vector< sal_uInt8 > m_vEncryptionBuffer
void createDefaultEditAppearance(PDFWidget &, const PDFWriter::EditWidget &rWidget)
StyleSettings m_aWidgetStyleSettings
bool m_bEncryptThisStream
const MapMode & getMapMode()
sal_Int32 getFontDictObject()
void writeReferenceXObject(const ReferenceXObjectEmit &rEmit)
Writes the form XObject proxy for the image.
void setStructureBoundingBox(const tools::Rectangle &rRect)
void createDefaultListBoxAppearance(PDFWidget &, const PDFWriter::ListBoxWidget &rWidget)
std::unordered_map< OString, sal_Int32 > m_aFieldNameMap
std::vector< TransparencyEmit > m_aTransparentObjects
bool emitWidgetAnnotations()
void drawEmphasisMark(tools::Long nX, tools::Long nY, const tools::PolyPolygon &rPolyPoly, bool bPolyLine, const tools::Rectangle &rRect1, const tools::Rectangle &rRect2)
void createEmbeddedFile(const Graphic &rGraphic, ReferenceXObjectEmit &rEmit, sal_Int32 nBitmapObject)
Stores the original PDF data from rGraphic as an embedded file.
static const sal_uInt32 ncMaxPDFArraySize
bool writeBufferBytes(const void *pBuffer, sal_uInt64 nBytes) override
See vcl::PDFObjectContainer::writeBuffer().
sal_Int32 createScreen(const tools::Rectangle &rRect, sal_Int32 nPageNr, OUString const &rAltText, OUString const &rMimeType)
bool setStructureAttribute(enum PDFWriter::StructAttribute eAttr, enum PDFWriter::StructAttributeValue eVal)
std::vector< OString > m_aStructParentTree
void drawRelief(SalLayout &rLayout, const OUString &rText, bool bTextLines)
const BitmapEmit & createBitmapEmit(const BitmapEx &rBitmapEx, const Graphic &rGraphic, std::list< BitmapEmit > &rBitmaps, ResourceDict &rResourceDict, std::list< StreamRedirect > &rOutputStreams)
std::vector< PDFDocumentAttachedFile > m_aDocumentAttachedFiles
void appendStrokingColor(const Color &rColor, OStringBuffer &rBuffer)
void setLinkPropertyId(sal_Int32 nLinkId, sal_Int32 nPropertyId)
void beginTransparencyGroup()
static const char * getAttributeTag(PDFWriter::StructAttribute eAtr)
sal_Int32 getBestBuildinFont(const Font &rFont)
void drawJPGBitmap(SvStream &rDCTData, bool bIsTrueColor, const Size &rSizePixel, const tools::Rectangle &rTargetArea, const AlphaMask &rAlphaMask, const Graphic &rGraphic)
void setStructureAnnotIds(::std::vector< sal_Int32 > const &rAnnotIds)
void endStructureElement()
sal_Int32 createNamedDest(const OUString &sDestName, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
void drawHatch(const tools::PolyPolygon &rPolyPoly, const Hatch &rHatch)
void drawTransparent(const tools::PolyPolygon &rPolyPoly, sal_uInt32 nTransparentPercent)
std::stack< sal_Int32 > m_StructElementStack
sal_Int32 emitStructure(PDFStructureElement &rEle)
void push(PushFlags nFlags)
void setScreenURL(sal_Int32 nScreenId, const OUString &rURL)
std::vector< sal_uInt64 > m_aObjects
void AppendAnnotKid(PDFStructureElement &i_rEle, T &rAnnot)
Font drawFieldBorder(PDFWidget &, const PDFWriter::AnyWidget &, const StyleSettings &)
std::vector< TilingEmit > m_aTilings
std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap
bool ImplNewFont() const override
sal_Int32 m_nAccessPermissions
void beginRedirect(SvStream *pStream, const tools::Rectangle &)
sal_Int32 emitOutputIntent()
sal_Int32 createGradient(const Gradient &rGradient, const Size &rSize)
sal_Int32 createObject() override
See vcl::PDFObjectContainer::createObject().
bool setCurrentStructureElement(sal_Int32 nElement)
void appendNonStrokingColor(const Color &rColor, OStringBuffer &rBuffer)
void createDefaultCheckBoxAppearance(PDFWidget &, const PDFWriter::CheckBoxWidget &rWidget)
void drawLine(const Point &rStart, const Point &rStop)
std::vector< PDFDest > m_aDests
void setFillColor(const Color &rColor)
void drawTextArray(const Point &rPos, const OUString &rText, KernArraySpan pDXArray, o3tl::span< const sal_Bool > pKashidaArray, sal_Int32 nIndex, sal_Int32 nLen)
void drawRectangle(const tools::Rectangle &rRect)
void drawLayout(SalLayout &rLayout, const OUString &rText, bool bTextLines)
sal_Int32 emitStructIDTree(sal_Int32 nTreeObject)
void setTextColor(const Color &rColor)
std::vector< PDFStructureElement > m_aStructure
void appendUnicodeTextStringEncrypt(const OUString &rInString, const sal_Int32 nInObjectNumber, OStringBuffer &rOutBuffer)
void ensureUniqueRadioOnValues()
std::vector< JPGEmit > m_aJPGs
sal_Int32 m_nSignatureObject
bool setStructureAttributeNumerical(enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue)
void drawBitmap(const Point &rDestPt, const Size &rDestSize, const BitmapEmit &rBitmap, const Color &rFillColor)
sal_Int32 getSystemFont(const Font &i_rFont)
void addDocumentAttachedFile(OUString const &rFileName, OUString const &rMimeType, OUString const &rDescription, std::unique_ptr< PDFOutputStream > rStream)
std::vector< PDFScreen > m_aScreens
Contains all screen annotations.
static const char * getAttributeValueTag(PDFWriter::StructAttributeValue eVal)
void drawShadow(SalLayout &rLayout, const OUString &rText, bool bTextLines)
void writeJPG(const JPGEmit &rEmit)
bool prepareEncryption(const css::uno::Reference< css::beans::XMaterialHolder > &)
bool appendDest(sal_Int32 nDestID, OStringBuffer &rBuffer)
std::vector< PDFNoteEntry > m_aNotes
void setPageTransition(PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr)
void MARK(const char *pString)
void emitComment(const char *pComment)
sal_Int32 createToUnicodeCMap(sal_uInt8 const *pEncoding, const std::vector< sal_Ucs > &CodeUnits, const sal_Int32 *pCodeUnitsPerGlyph, const sal_Int32 *pEncToUnicodeIndex, uint32_t nGlyphs)
ExternalPDFStreams m_aExternalPDFStreams
sal_Int32 registerDestReference(sal_Int32 nDestId, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
sal_Int32 createOutlineItem(sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID)
void emitTextAnnotationLine(OStringBuffer &aLine, PDFNoteEntry const &rNote)
sal_Int32 getResourceDictObj()
ResourceDict m_aGlobalResourceDict
sal_Int32 createDest(const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType)
bool emitAppearances(PDFWidget &rWidget, OStringBuffer &rAnnotDict)
void intersectClipRegion(const tools::Rectangle &rRect)
OString m_aCreationDateString
void setLineColor(const Color &rColor)
void setLinkDest(sal_Int32 nLinkId, sal_Int32 nDestId)
static void pushResource(ResourceKind eKind, const OString &rResource, sal_Int32 nObject, ResourceDict &rResourceDict, std::list< StreamRedirect > &rOutputStreams)
void updateGraphicsState(Mode mode=Mode::DEFAULT)
css::uno::Reference< css::util::XURLTransformer > m_xTrans
void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace *, const LogicalFontInstance *pFont, const std::vector< sal_Ucs > &, sal_Int32, sal_uInt8 &, sal_Int32 &)
void drawWaveTextLine(OStringBuffer &aLine, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove)
std::vector< PDFWidget > m_aWidgets
static bool compressStream(SvMemoryStream *)
sal_uInt64 getCurrentFilePosition()
void setClipRegion(const basegfx::B2DPolyPolygon &rRegion)
sal_Int32 emitNamedDestinations()
bool writeBitmapObject(const BitmapEmit &rObject, bool bMask=false)
static const sal_uInt8 s_nPadString[ENCRYPTED_PWD_SIZE]
bool emitType3Font(const vcl::font::PhysicalFontFace *, const FontSubset &, std::map< sal_Int32, sal_Int32 > &)
::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation
contains destinations accessible via a public Id, instead of being linked to by an ordinary link
Font replaceFont(const Font &rControlFont, const Font &rAppSetFont)
void drawPolygon(const tools::Polygon &rPoly)
std::vector< PDFOutlineEntry > m_aOutline
std::unique_ptr< ZCodec > m_pCodec
void registerSimpleGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace *, const std::vector< sal_Ucs > &, sal_Int32, sal_uInt8 &, sal_Int32 &)
void drawPixel(const Point &rPt, const Color &rColor)
static void AppendUnicodeTextString(const OUString &rString, OStringBuffer &rBuffer)
Write rString as a PDF hex string into rBuffer.
static OString GetDateTime()
Get current date/time in PDF D:YYYYMMDDHHMMSS form.
@ Warning_Transparency_Omitted_PDFA
@ Warning_Transparency_Omitted_PDF13
@ Warning_FormAction_Omitted_PDFA
bool read(BitmapEx &rBitmap)
SvMemoryStream & GetEditBuffer()
Access to the input document, even after the input stream is gone.
Name object: a key string.
Numbering object: an integer or a real.
Indirect object: something with a unique ID.
PDFElement * Lookup(const OString &rDictionaryKey)
PDFObjectElement * LookupObject(const OString &rDictionaryKey)
PDFDocument & GetDocument()
Reference object: something with a unique ID.
tools::Long GetYOffset() const
tools::Rectangle GetRect1() const
tools::PolyPolygon GetShape() const
tools::Rectangle GetRect2() const
tools::Long GetWidth() const
bool IsShapePolyLine() const
abstract base class for physical font faces
RawFontData GetGlyphColorBitmap(sal_GlyphId, tools::Rectangle &) const
bool CreateFontSubset(std::vector< sal_uInt8 > &, const sal_GlyphId *, const sal_uInt8 *, const int, FontSubsetInfo &) const
std::vector< ColorLayer > GetGlyphColorLayers(sal_GlyphId) const
virtual const std::vector< hb_variation_t > & GetVariations(const LogicalFontInstance &) const
const std::vector< ColorPalette > & GetColorPalettes() const
uint32_t UnitsPerEm() const
RawFontData GetRawFontData(uint32_t) const
OString GetGlyphName(sal_GlyphId, bool=false) const
const BuildinFont & GetBuildinFont() const
static const BuildinFont & Get(int nId)
void addCode(sal_Ucs i_cCode)
void setGlyphWidth(sal_Int32 nWidth)
void setGlyphId(sal_uInt8 i_nId)
void translate(double tx, double ty)
Point transform(const Point &rPoint) const
void rotate(double angle)
double get(size_t i) const
void scale(double sx, double sy)
void skew(double alpha, double beta)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define MAX_SIGNATURE_CONTENT_LENGTH
Reference< XComponentContext > m_aContext
EmbeddedObjectRef * pObject
std::deque< AttacherIndex_Impl > aIndex
@ TYPE1_PFB
PSType1 Postscript Font Binary.
@ CFF_FONT
CFF-container with PSType2 glyphs.
@ TYPE1_PFA
PSType1 Postscript Font Ascii.
@ SFNT_TTF
SFNT container with TrueType glyphs.
tools::Long FRound(double fVal)
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
SVL_DLLPUBLIC OUString resolveIdnaHost(OUString const &url)
B2DPolyPolygon prepareForPolygonOperation(const B2DPolygon &rCandidate)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
B2DPolyPolygon solvePolygonOperationAnd(const B2DPolyPolygon &rCandidateA, const B2DPolyPolygon &rCandidateB)
B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon &rCandidate, double fAngleBound)
bool isRectangle(const B2DPolygon &rPoly)
constexpr double deg2rad(double v)
OUString encodeForXml(std::u16string_view rStr)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
Reference< XComponentContext > getProcessComponentContext()
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr T & temporary(T &&x)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
OUString WhitespaceToSpace(std::u16string_view rLine, bool bProtect)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
double getDefaultPdfResolutionDpi()
Get the default PDF rendering resolution in DPI.
double pointToPixel(const double fPoint, const double fResolutionDPI)
Convert to inch, then assume 96 DPI.
constexpr sal_Int32 g_nInheritedPageWidth
constexpr sal_Int32 g_nInheritedPageHeight
static void appendStructureAttributeLine(PDFWriter::StructAttribute i_eAttr, const PDFStructureAttribute &i_rVal, OStringBuffer &o_rLine, bool i_bIsFixedInt)
static void lcl_assignMeta(std::u16string_view aValue, OString &aMeta)
static int XUnits(int unitsPerEm, int n)
static void appendSubsetName(int nSubsetID, std::u16string_view rPSName, OStringBuffer &rBuffer)
static OString GenerateID(sal_Int32 const nObjectId)
static bool getPfbSegmentLengths(const unsigned char *pFontBytes, int nByteLen, ThreeInts &rSegmentLengths)
static const Color & replaceColor(const Color &rCol1, const Color &rCol2)
static double calcAngle(const tools::Rectangle &rRect, const Point &rPoint)
constexpr sal_uInt16 pixelFormatBitCount(PixelFormat ePixelFormat)
HashMap_OWString_Interface aMap
static bool g_bDebugDisableCompression
constexpr sal_Int32 MAXIMUM_RC4_KEY_LENGTH
constexpr sal_Int32 ENCRYPTED_PWD_SIZE
#define STREAM_SEEK_TO_END
#define STREAM_SEEK_TO_BEGIN
std::shared_ptr< vcl::font::PhysicalFontCollection > mxScreenFontList
std::shared_ptr< ImplFontCache > mxScreenFontCache
std::shared_ptr< filter::PDFDocument > & getPDFDocument()
std::vector< basegfx::B2DPolygon > maPolygons
css::util::DateTime maModificationDate
std::vector< double > m_aDashArray
std::vector< sal_uInt8 > UValue
std::vector< sal_uInt8 > DocumentIdentifier
std::vector< sal_uInt8 > EncryptionKey
std::vector< sal_uInt8 > OValue
PDFWriter::PDFLinkDefaultAction DefaultLinkAction
bool AllowDuplicateFieldNames
PDFWriter::ExportDataFormat SubmitFormat
css::uno::Reference< css::security::XCertificate > SignCertificate
bool ConvertOOoTargetToPDFTarget
sal_Int32 OpenBookmarkLevels
bool DisplayPDFDocumentTitle
bool UseReferenceXObject
Use reference XObject markup for PDF images.
PDFWriter::PDFViewerPageMode PDFDocumentMode
PDFWriter::PDFViewerAction PDFDocumentAction
bool HideViewerWindowControls
PDFWriter::PDFEncryptionProperties Encryption
bool OpenInFullScreenMode
PDFWriter::PDFDocInfo DocumentInfo
bool UniversalAccessibilityCompliance
PDFWriter::ColorMode ColorMode
css::lang::Locale DocumentLocale
ReferenceXObjectEmit m_aReferenceXObject
BitmapChecksum m_nChecksum
BitmapChecksum m_nMaskChecksum
rtl_TextEncoding const m_eCharSet
OString getNameObject() const
sal_Int32 m_nNormalFontID
LogicalFontInstance * m_pFontInstance
std::map< sal_GlyphId, GlyphEmit > m_aMapping
std::vector< FontEmit > m_aSubsets
std::map< sal_GlyphId, Glyph > m_aMapping
sal_uInt8 m_nSubsetGlyphID
vcl::text::ComplexTextLayoutFlags m_nLayoutMode
basegfx::B2DPolyPolygon m_aClipRegion
GraphicsStateUpdateFlags m_nUpdateFlags
LanguageType m_aDigitLanguage
std::unique_ptr< SvMemoryStream > m_pStream
ReferenceXObjectEmit m_aReferenceXObject
PDFWriter::DestAreaType m_eType
sal_Int32 m_nStructParent
PDFWriter::DestAreaType m_eType
PDFPopupAnnotation m_aPopUpAnnotation
sal_Int32 m_nParentObject
std::vector< sal_Int32 > m_aChildren
PDFPage(PDFWriterImpl *pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation)
void appendWaveLine(sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer &rBuffer) const
sal_uInt64 m_nBeginStreamPos
void appendPoint(const Point &rPoint, OStringBuffer &rBuffer) const
void appendPixelPoint(const basegfx::B2DPoint &rPoint, OStringBuffer &rBuffer) const
void convertRect(tools::Rectangle &rRect) const
VclPtr< PDFWriterImpl > m_pWriter
void appendMatrix3(Matrix3 const &rMatrix, OStringBuffer &rBuffer)
std::vector< sal_Int32 > m_aAnnotations
void appendRect(const tools::Rectangle &rRect, OStringBuffer &rBuffer) const
sal_Int32 m_nUserUnit
A positive number that gives the size of default user space units, in multiples of points.
bool appendLineInfo(const LineInfo &rInfo, OStringBuffer &rBuffer) const
std::vector< sal_Int32 > m_aMCIDParents
void appendMappedLength(sal_Int32 nLength, OStringBuffer &rBuffer, bool bVertical=true, sal_Int32 *pOutLength=nullptr) const
sal_Int32 m_nStreamLengthObject
bool emit(sal_Int32 nParentPage)
void appendPolygon(const tools::Polygon &rPoly, OStringBuffer &rBuffer, bool bClose=true) const
PDFWriter::Orientation m_eOrientation
std::vector< sal_Int32 > m_aStreamObjects
void appendPolyPolygon(const tools::PolyPolygon &rPolyPoly, OStringBuffer &rBuffer) const
PDFWriter::PageTransition m_eTransition
OUString m_aTempFileURL
Embedded video.
sal_Int32 m_nTempFileObject
ID of the EmbeddedFile object.
OUString m_aURL
Linked video.
sal_Int32 m_nStructParent
OUString m_AltText
alternative text description
PDFWriter::StructAttributeValue eValue
css::lang::Locale m_aLocale
::std::vector< sal_Int32 > m_AnnotIds
sal_Int32 m_nParentElement
std::map< PDFWriter::StructAttribute, PDFStructureAttribute > m_aAttributes
std::vector< sal_Int32 > m_aChildren
std::list< PDFStructureElementKid > m_aKids
::std::optional< PDFWriter::StructElement > m_oType
sal_Int32 m_nFirstPageObject
Contains information to emit a reference XObject.
sal_Int32 m_nExternalPDFPageIndex
sal_Int32 m_nEmbeddedObject
ID of the vector/embedded object, if m_nFormObject is used.
sal_Int32 m_nFormObject
ID of the Form XObject, if any.
sal_Int32 getObject() const
Returns the ID one should use when referring to this bitmap.
sal_Int32 m_nBitmapObject
ID of the bitmap object, if m_nFormObject is used.
bool hasExternalPDFData() const
sal_Int32 m_nExternalPDFDataIndex
PDF data from the graphic object, if not writing a reference XObject.
Size m_aPixelSize
Size of the bitmap replacement, in pixels.
std::map< OString, sal_Int32 > m_aPatterns
std::map< OString, sal_Int32 > m_aExtGStates
void append(OStringBuffer &rBuffer, sal_Int32 nFontDictObject)
std::map< OString, sal_Int32 > m_aShadings
std::map< OString, sal_Int32 > m_aXObjects
std::unique_ptr< SvMemoryStream > m_pContentStream
tools::Rectangle m_aBoundRect
sal_Int32 m_nExtGStateObject
ImplSVData * ImplGetSVData()
OUString removeMnemonicFromString(OUString const &rStr)
std::unique_ptr< char[]> aBuffer