31#include <osl/diagnose.h>
41struct PDFExtOutDevDataSync
43 enum Action{ CreateNamedDest,
56 EnsureStructureElement,
58 BeginStructureElement,
60 SetCurrentStructureElement,
61 SetStructureAttribute,
62 SetStructureAttributeNumerical,
63 SetStructureBoundingBox,
76struct PDFLinkDestination
88 std::deque< PDFExtOutDevDataSync::Action >
mActions;
135 SAL_WARN_IF( nLinkId < 0,
"vcl",
"unmapped id in GlobalSyncData" );
147 case PDFExtOutDevDataSync::CreateNamedDest :
160 case PDFExtOutDevDataSync::CreateDest :
172 case PDFExtOutDevDataSync::CreateLink :
186 case PDFExtOutDevDataSync::CreateScreen:
203 case PDFExtOutDevDataSync::SetLinkDest :
210 case PDFExtOutDevDataSync::SetLinkURL :
217 case PDFExtOutDevDataSync::SetScreenURL:
224 case PDFExtOutDevDataSync::SetScreenStream:
231 case PDFExtOutDevDataSync::RegisterDest :
233 const sal_Int32 nDestId =
mParaInts.front();
236 "GlobalSyncData::PlayGlobalActions: DescribeRegisteredRequest has not been called for that destination!" );
246 case PDFExtOutDevDataSync::CreateOutlineItem :
254 case PDFExtOutDevDataSync::CreateNote :
265 case PDFExtOutDevDataSync::SetPageTransition :
273 case PDFExtOutDevDataSync::EnsureStructureElement:
274 case PDFExtOutDevDataSync::InitStructureElement:
275 case PDFExtOutDevDataSync::BeginStructureElement:
276 case PDFExtOutDevDataSync::EndStructureElement:
277 case PDFExtOutDevDataSync::SetCurrentStructureElement:
278 case PDFExtOutDevDataSync::SetStructureAttribute:
279 case PDFExtOutDevDataSync::SetStructureAttributeNumerical:
280 case PDFExtOutDevDataSync::SetStructureBoundingBox:
281 case PDFExtOutDevDataSync::SetStructureAnnotIds:
282 case PDFExtOutDevDataSync::SetActualText:
283 case PDFExtOutDevDataSync::SetAlternateText:
284 case PDFExtOutDevDataSync::CreateControl:
285 case PDFExtOutDevDataSync::BeginGroup:
286 case PDFExtOutDevDataSync::EndGroupGfxLink:
303 std::deque< std::shared_ptr< PDFWriter::AnyWidget > >
321 SAL_WARN_IF( !pMtf,
"vcl",
"PageSyncData::PushAction -> no ConnectMetaFile !!!" );
323 PDFExtOutDevDataSync aSync;
328 aSync.nIdx = 0x7fffffff;
337 PDFExtOutDevDataSync aDataSync =
mActions.front();
339 switch( aDataSync.eAct )
341 case PDFExtOutDevDataSync::EnsureStructureElement:
347 assert(
id == -1 ||
id ==
mParaInts.front());
351 case PDFExtOutDevDataSync::InitStructureElement:
359 case PDFExtOutDevDataSync::BeginStructureElement :
365 case PDFExtOutDevDataSync::EndStructureElement :
370 case PDFExtOutDevDataSync::SetCurrentStructureElement:
376 case PDFExtOutDevDataSync::SetStructureAttribute :
383 case PDFExtOutDevDataSync::SetStructureAttributeNumerical :
390 case PDFExtOutDevDataSync::SetStructureBoundingBox :
396 case PDFExtOutDevDataSync::SetStructureAnnotIds:
398 ::std::vector<sal_Int32> annotIds;
401 for (
auto i = 0;
i <
size; ++
i)
409 case PDFExtOutDevDataSync::SetActualText :
415 case PDFExtOutDevDataSync::SetAlternateText :
421 case PDFExtOutDevDataSync::CreateControl:
423 std::shared_ptr< PDFWriter::AnyWidget > pControl(
mControls.front() );
424 SAL_WARN_IF( !pControl,
"vcl",
"PageSyncData::PlaySyncPageAct: invalid widget!" );
437 case PDFExtOutDevDataSync::BeginGroup :
443 [](
const PDFExtOutDevDataSync& rAction) { return rAction.eAct == PDFExtOutDevDataSync::EndGroupGfxLink; });
444 if ( isStartingGfxLink )
465 case PDFExtOutDevDataSync::EndGroupGfxLink :
471 sal_Int32 nTransparency =
mParaInts.front();
480 bool bClippingNeeded = ( aOutputRect != aVisibleOutputRect ) && !aVisibleOutputRect.
IsEmpty();
485 if ( bClippingNeeded )
497 aAlphaMask.
Erase(nTransparency);
503 if(
pData && nBytes )
512 if (rCurGDIMtfAction > 0)
527 if ( bClippingNeeded )
535 case PDFExtOutDevDataSync::CreateNamedDest:
536 case PDFExtOutDevDataSync::CreateDest:
537 case PDFExtOutDevDataSync::CreateLink:
538 case PDFExtOutDevDataSync::CreateScreen:
539 case PDFExtOutDevDataSync::SetLinkDest:
540 case PDFExtOutDevDataSync::SetLinkURL:
541 case PDFExtOutDevDataSync::SetScreenURL:
542 case PDFExtOutDevDataSync::SetScreenStream:
543 case PDFExtOutDevDataSync::RegisterDest:
544 case PDFExtOutDevDataSync::CreateOutlineItem:
545 case PDFExtOutDevDataSync::CreateNote:
546 case PDFExtOutDevDataSync::SetPageTransition:
559 mrOutDev ( rOutDev ),
560 mbTaggedPDF ( false ),
561 mbExportNotes ( true ),
562 mbExportNotesInMargin ( false ),
563 mbExportNotesPages ( false ),
564 mbTransitionEffects ( true ),
565 mbUseLosslessCompression( true ),
566 mbReduceImageResolution ( false ),
567 mbExportFormFields ( false ),
568 mbExportBookmarks ( false ),
569 mbExportHiddenSlides ( false ),
570 mbSinglePageSheets ( false ),
571 mbExportNDests ( false ),
573 mnCompressionQuality ( 90 ),
656 return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, rMtf, *
this );
669 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNamedDest );
689 OSL_PRECOND( nDestId != -1,
"PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" );
690 PDFLinkDestination aLinkDestination;
691 aLinkDestination.mRect = rRect;
693 aLinkDestination.mPageNr = nPageNr == -1 ?
mnPage : nPageNr;
694 aLinkDestination.mAreaType =
eType;
717 OUString
const& rAltText, OUString
const& rMimeType,
718 sal_Int32 nPageNr,
SdrObject const*
const pObj)
763 mpGlobalSyncData->mActions.push_back(PDFExtOutDevDataSync::SetScreenStream);
774 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateOutlineItem );
790 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
856 bool bSuccess =
false;
892 for (sal_Int32
const id : rAnnotIds)
913 std::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.
Clone() );
945 if (rOutputRect != rVisibleOutputRect)
960 StreamMode::READ | StreamMode::WRITE);
969 if ( aSize.
Width() < 32 &&
977 sal_Int32 nCurrentRatio = (100 * aSize.
Width() * aSize.
Height() * 4) /
980 static const struct {
984 { 100, 400 }, { 95, 700 }, { 90, 1000 }, { 85, 1200 },
985 { 80, 1500 }, { 75, 1700 }
987 sal_Int32 nTargetRatio = 10000;
988 bool bIsTargetRatioReached =
false;
989 for (
auto & rRatio : aRatios)
993 bIsTargetRatioReached =
true;
996 nTargetRatio = rRatio.mnRatio;
999 return ((nCurrentRatio > nTargetRatio) && bIsTargetRatioReached);
void Erase(sal_uInt8 cTransparency)
vcl::PixelFormat getPixelFormat() const
const sal_uInt8 * GetData() const
sal_uInt32 GetDataSize() const
GfxLinkType GetType() const
sal_uInt8 GetNumberOfImageComponents() const
bool Detect(bool bExtendedInfo=false)
starts the detection
GfxLink GetGfxLink() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
GDIMetaFile * GetConnectMetaFile() const
const MapMode & GetMapMode() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
bool SetCurrentStructureElement(sal_Int32 nElement)
set the current structure element
void SetStructureBoundingBox(const tools::Rectangle &rRect)
set the bounding box of a structural element
void SetIsExportNamedDestinations(const bool bExportNDests)
void CreateNote(const tools::Rectangle &rRect, const PDFNote &rNote, sal_Int32 nPageNr=-1)
Create a new note on a page.
std::unique_ptr< GlobalSyncData > mpGlobalSyncData
sal_Int32 mnCompressionQuality
bool GetIsLosslessCompression() const
std::unique_ptr< PageSyncData > mpPageSyncData
sal_Int32 CreateScreen(const tools::Rectangle &rRect, OUString const &rAltText, OUString const &rMimeType, sal_Int32 nPageNr, SdrObject const *pObj)
Create a Screen annotation.
sal_Int32 EnsureStructureElement(void const *key)
sal_Int32 CreateDest(const tools::Rectangle &rRect, sal_Int32 nPageNr=-1, PDFWriter::DestAreaType eType=PDFWriter::DestAreaType::XYZ)
Create a new destination to be used in a link.
void SetStructureAnnotIds(::std::vector< sal_Int32 > const &rAnnotIds)
set the annotations that should be referenced as children of the current structural element.
void BeginStructureElement(sal_Int32 id)
void SetDocumentLocale(const css::lang::Locale &rLoc)
void SetStructureAttributeNumerical(PDFWriter::StructAttribute eAttr, sal_Int32 nValue)
set a structure attribute on the current structural element
void SetScreenStream(sal_Int32 nScreenId, const OUString &rURL)
Set URL for an embedded Screen annotation.
void SetAlternateText(const OUString &rText)
set the Alt attribute of a strutural element
void SetIsExportNotes(const bool bExportNotes)
sal_Int32 GetCurrentStructureElement() const
get the current structure element id
sal_Int32 RegisterDest()
registers a destination for which a destination ID needs to be known immediately, instead of later on...
PDFExtOutDevData(const OutputDevice &rOutDev)
void SetIsExportTaggedPDF(const bool bTaggedPDF)
void SetStructureAttribute(PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal)
set a structure attribute on the current structural element
bool PlaySyncPageAct(PDFWriter &rWriter, sal_uInt32 &rCurGDIMtfAction, const GDIMetaFile &rMtf)
bool mbExportNotesInMargin
bool GetIsReduceImageResolution() const
void SetPageTransition(PDFWriter::PageTransition eType, sal_uInt32 nMilliSec)
Sets the transitional effect to be applied when the current page gets shown.
css::lang::Locale maDocLocale
void SetIsExportNotesPages(const bool bExportNotesPages)
const Graphic & GetCurrentGraphic() const
void SetActualText(const OUString &rText)
set the ActualText attribute of a structural element
void PlayGlobalActions(PDFWriter &rWriter)
void BeginGroup()
Start a new group of render output.
void SetScreenURL(sal_Int32 nScreenId, const OUString &rURL)
Set URL for a linked Screen annotation.
void SetIsLosslessCompression(const bool bLosslessCompression)
void SetIsReduceImageResolution(const bool bReduceImageResolution)
void SetCurrentPageNumber(const sal_Int32 nPage)
void EndGroup(const Graphic &rGraphic, sal_uInt8 nTransparency, const tools::Rectangle &rOutputRect, const tools::Rectangle &rVisibleOutputRect)
End render output.
void DescribeRegisteredDest(sal_Int32 nDestId, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType=PDFWriter::DestAreaType::XYZ)
provides detailed information about a destination range which previously has been registered using Re...
void SetLinkURL(sal_Int32 nLinkId, const OUString &rURL)
Set the URL for a link.
void CreateControl(const PDFWriter::AnyWidget &rControlType)
create a new form control
sal_Int32 WrapBeginStructureElement(PDFWriter::StructElement eType, const OUString &rAlias=OUString())
begin a new logical structure element
sal_Int32 CreateOutlineItem(sal_Int32 nParent, const OUString &rText, sal_Int32 nDestID)
Create a new outline item.
::std::vector< sal_Int32 > const & GetScreenAnnotIds(SdrObject const *pObj) const
Get back the annotations created for one SdrObject.
void SetIsExportBookmarks(const bool bExportBookmarks)
bool mbExportHiddenSlides
::std::map< SdrObject const *, ::std::vector< sal_Int32 > > m_ScreenAnnotations
std::vector< OUString > maChapterNames
void SetIsExportHiddenSlides(const bool bExportHiddenSlides)
void SetIsSinglePageSheets(const bool bSinglePageSheets)
void SetIsExportTransitionEffects(const bool bTransitionalEffects)
void SetIsExportFormFields(const bool bExportFormFields)
sal_Int32 CreateNamedDest(const OUString &sDestName, const tools::Rectangle &rRect, sal_Int32 nPageNr=-1)
Create a new named destination to be used in a link to this document from another PDF document (see P...
bool mbUseLosslessCompression
sal_Int32 CreateLink(const tools::Rectangle &rRect, OUString const &rAltText, sal_Int32 nPageNr=-1)
Create a new link on a page.
bool mbReduceImageResolution
void EndStructureElement()
end a logical structure element
bool HasAdequateCompression(const Graphic &rGraphic, const tools::Rectangle &rOutputRect, const tools::Rectangle &rVisibleOutputRect) const
Detect if stream is compressed enough to avoid de-compress / scale & re-compress.
virtual ~PDFExtOutDevData() override
void SetCompressionQuality(const sal_Int32 nQuality)
const OutputDevice & mrOutDev
void InitStructureElement(sal_Int32 id, PDFWriter::StructElement eType, const OUString &rAlias)
void SetIsExportNotesInMargin(const bool bExportNotesInMargin)
void SetLinkDest(sal_Int32 nLinkId, sal_Int32 nDestId)
Set the destination for a link.
void CreateNote(const tools::Rectangle &rRect, const PDFNote &rNote, sal_Int32 nPageNr)
Create a new note on a page.
void SetLinkDest(sal_Int32 nLinkId, sal_Int32 nDestId)
Set the destination for a link will change a URL type link to a dest link if necessary.
void SetScreenURL(sal_Int32 nScreenId, const OUString &rURL)
Sets the URL of a linked screen annotation.
void SetActualText(const OUString &rText)
set the ActualText attribute of a structural element
void SetLinkURL(sal_Int32 nLinkId, const OUString &rURL)
Set the URL for a link will change a dest type link to a URL type link if necessary.
void InitStructureElement(sal_Int32 id, PDFWriter::StructElement eType, std::u16string_view rAlias)
sal_Int32 CreateNamedDest(const OUString &sDestName, const tools::Rectangle &rRect, sal_Int32 nPageNr, DestAreaType eType)
Create a new named destination to be used in a link from another PDF document.
void Push(PushFlags nFlags=PushFlags::ALL)
sal_Int32 CreateScreen(const tools::Rectangle &rRect, sal_Int32 nPageNr, OUString const &rAltText, OUString const &rMimeType)
Creates a screen annotation.
sal_Int32 CreateControl(const AnyWidget &rControlType)
create a new form control
void SetCurrentStructureElement(sal_Int32 nElement)
set the current structure element
sal_Int32 RegisterDestReference(sal_Int32 nDestId, const tools::Rectangle &rRect, sal_Int32 nPageNr, DestAreaType eType)
creates a destination which is not intended to be referred to by a link, but by a public destination ...
void DrawJPGBitmap(SvStream &rJPGData, bool bIsTrueColor, const Size &rSrcSizePixel, const tools::Rectangle &rTargetArea, const AlphaMask &rAlphaMask, const Graphic &rGraphic)
Insert a JPG encoded image (optionally with mask)
void SetMapMode(const MapMode &rNewMapMode)
void SetAlternateText(const OUString &rText)
set the Alt attribute of a strutural element
void SetStructureBoundingBox(const tools::Rectangle &rRect)
set the bounding box of a structural element
void SetStructureAnnotIds(::std::vector< sal_Int32 > const &rAnnotIds)
set the annotations that should be referenced as children of the current structural element.
void SetStructureAttributeNumerical(enum StructAttribute eAttr, sal_Int32 nValue)
set a structure attribute on the current structural element
void SetPageTransition(PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr)
Sets the transitional effect to be applied when the current page gets shown.
void BeginStructureElement(sal_Int32 id)
begin a new logical structure element
sal_Int32 CreateDest(const tools::Rectangle &rRect, sal_Int32 nPageNr, DestAreaType eType)
Create a new destination to be used in a link.
void SetLinkPropertyID(sal_Int32 nLinkId, sal_Int32 nPropertyID)
Resolve link in logical structure.
sal_Int32 CreateLink(const tools::Rectangle &rRect, sal_Int32 nPageNr, OUString const &rAltText)
Create a new link on a page.
void EndStructureElement()
end the current logical structure element
void SetStructureAttribute(enum StructAttribute eAttr, enum StructAttributeValue eVal)
set a structure attribute on the current structural element
sal_Int32 CreateOutlineItem(sal_Int32 nParent, std::u16string_view rText, sal_Int32 nDestID)
Create a new outline item.
void SetScreenStream(sal_Int32 nScreenId, const OUString &rURL)
Sets the URL of an embedded screen annotation.
sal_Int32 EnsureStructureElement()
GfxLinkType
GfxLink graphic types that are supported by GfxLink.
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::deque< sal_Int32 > mParaInts
std::deque< PDFWriter::PageTransition > mParaPageTransitions
std::deque< MapMode > mParaMapModes
std::vector< sal_Int32 > mParaIds
std::deque< PDFExtOutDevDataSync::Action > mActions
std::deque< sal_uInt32 > mParauInts
std::deque< PDFNote > mParaPDFNotes
sal_Int32 mCurrentStructElement
std::map< void const *, sal_Int32 > mSEMap
std::deque< OUString > mParaOUStrings
void PlayGlobalActions(PDFWriter &rWriter)
std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes
std::vector< sal_Int32 > mStructParents
std::deque< tools::Rectangle > mParaRects
sal_Int32 mCurId
the way this appears to work: (only) everything that increments mCurId at recording time must put an ...
::std::map< sal_Int32, PDFLinkDestination > mFutureDestinations
std::deque< PDFWriter::StructAttributeValue > mParaStructAttributeValues
std::deque< PDFWriter::StructAttribute > mParaStructAttributes
std::deque< tools::Rectangle > mParaRects
bool mbGroupIgnoreGDIMtfActions
GlobalSyncData * mpGlobalData
PageSyncData(GlobalSyncData *pGlobal)
std::deque< PDFExtOutDevDataSync > mActions
std::deque< OUString > mParaOUStrings
std::deque< sal_Int32 > mParaInts
std::deque< Graphic > mGraphics
std::deque< std::shared_ptr< PDFWriter::AnyWidget > > mControls
void PushAction(const OutputDevice &rOutDev, const PDFExtOutDevDataSync::Action eAct)
std::deque< PDFWriter::StructElement > mParaStructElements
bool PlaySyncPageAct(PDFWriter &rWriter, sal_uInt32 &rCurGDIMtfAction, const GDIMetaFile &rMtf, const PDFExtOutDevData &rOutDevData)