1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
21 #define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
23 #include <config_features.h>
25 #if HAVE_FEATURE_PDFIUM
26 #include <sal/config.h>
27 #include <svx/svxdllapi.h>
31 #include <tools/contnr.hxx>
32 #include <tools/fract.hxx>
33 #include <vcl/metaact.hxx>
34 #include <vcl/virdev.hxx>
35 #include <vcl/graph.hxx>
36 #include <svx/svdobj.hxx>
37 #include <svx/xdash.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
40 #include <basegfx/matrix/b2dhommatrix.hxx>
42 // Prevent workdir/UnpackedTarball/pdfium/public/fpdfview.h from including windows.h in a way that
43 // it will define e.g. Yield as a macro:
48 #include <vcl/filter/PDFiumLibrary.hxx>
50 // Forward Declarations
57 class SvdProgressInfo
;
59 // Helper Class to import PDF
60 class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
62 Graphic
const& mrGraphic
;
63 std::vector
<SdrObject
*> maTmpList
;
64 ScopedVclPtr
<VirtualDevice
> mpVD
;
65 tools::Rectangle
const maScaleRect
;
66 size_t mnMapScalingOfs
; // from here on, not edited with MapScaling
67 std::unique_ptr
<SfxItemSet
> mpLineAttr
;
68 std::unique_ptr
<SfxItemSet
> mpFillAttr
;
69 std::unique_ptr
<SfxItemSet
> mpTextAttr
;
71 SdrLayerID
const mnLayer
;
73 sal_Int32 mnLineWidth
;
74 static constexpr css::drawing::LineCap gaLineCap
= css::drawing::LineCap_BUTT
;
87 // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
88 bool mbLastObjWasPolyWithoutLine
;
93 basegfx::B2DPolyPolygon maClip
;
95 std::unique_ptr
<vcl::pdf::PDFiumDocument
> mpPdfDocument
;
97 double mdPageWidthPts
;
98 double mdPageHeightPts
;
99 /// The current transformation matrix, typically used with Form objects.
100 basegfx::B2DHomMatrix maCurrentMatrix
;
102 /// Correct the vertical coordinate to start at the top.
103 /// PDF coordinate system has origin at the bottom right.
104 double correctVertOrigin(double offsetPts
) const { return mdPageHeightPts
- offsetPts
; }
105 /// Convert PDF points to logic (twips).
106 tools::Rectangle
PointsToLogic(double left
, double right
, double top
, double bottom
) const;
107 Point
PointsToLogic(double x
, double y
) const;
109 std::shared_ptr
<vcl::pdf::PDFium
> mpPDFium
;
111 // check for clip and evtl. fill maClip
115 void ImportPdfObject(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
116 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
117 int nPageObjectIndex
);
118 void ImportForm(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
119 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
120 int nPageObjectIndex
);
121 void ImportImage(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
122 int nPageObjectIndex
);
123 void ImportPath(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
124 int nPageObjectIndex
);
125 void ImportText(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
126 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
127 int nPageObjectIndex
);
128 void InsertTextObject(const Point
& rPos
, const Size
& rSize
, const OUString
& rStr
);
130 void SetupPageScale(const double dPageWidth
, const double dPageHeight
);
131 void SetAttributes(SdrObject
* pObj
, bool bForceTextAttr
= false);
132 void InsertObj(SdrObject
* pObj
, bool bScale
= true);
135 // #i73407# reformulation to use new B2DPolygon classes
136 bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon
& rPolyPolygon
);
138 void DoObjects(SvdProgressInfo
* pProgrInfo
, sal_uInt32
* pActionsToReport
, int nPageIndex
);
140 // Copy assignment is forbidden and not implemented.
141 ImpSdrPdfImport(const ImpSdrPdfImport
&) = delete;
142 ImpSdrPdfImport
& operator=(const ImpSdrPdfImport
&) = delete;
145 ImpSdrPdfImport(SdrModel
& rModel
, SdrLayerID nLay
, const tools::Rectangle
& rRect
,
146 Graphic
const& rGraphic
);
150 int GetPageCount() const { return mnPageCount
; }
151 size_t DoImport(SdrObjList
& rDestList
, size_t nInsPos
, int nPageNumber
,
152 SvdProgressInfo
* pProgrInfo
= nullptr);
155 #endif // HAVE_FEATURE_PDFIUM
157 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDFMTF_HXX
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */