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 <sal/config.h>
27 #include <tools/fract.hxx>
28 #include <vcl/virdev.hxx>
29 #include <vcl/graph.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/xdash.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
35 #include <vcl/filter/PDFiumLibrary.hxx>
37 // Forward Declarations
44 class SvdProgressInfo
;
46 // Helper Class to import PDF
47 class ImpSdrPdfImport final
49 std::vector
<rtl::Reference
<SdrObject
>> maTmpList
;
50 ScopedVclPtr
<VirtualDevice
> mpVD
;
51 tools::Rectangle maScaleRect
;
52 size_t mnMapScalingOfs
; // from here on, not edited with MapScaling
53 std::unique_ptr
<SfxItemSet
> mpLineAttr
;
54 std::unique_ptr
<SfxItemSet
> mpFillAttr
;
55 std::unique_ptr
<SfxItemSet
> mpTextAttr
;
59 sal_Int32 mnLineWidth
;
60 static constexpr css::drawing::LineCap gaLineCap
= css::drawing::LineCap_BUTT
;
73 // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
74 bool mbLastObjWasPolyWithoutLine
;
79 basegfx::B2DPolyPolygon maClip
;
81 std::unique_ptr
<vcl::pdf::PDFiumDocument
> mpPdfDocument
;
83 double mdPageHeightPts
;
84 /// The current transformation matrix, typically used with Form objects.
85 basegfx::B2DHomMatrix maCurrentMatrix
;
87 /// Correct the vertical coordinate to start at the top.
88 /// PDF coordinate system has origin at the bottom right.
89 double correctVertOrigin(double offsetPts
) const { return mdPageHeightPts
- offsetPts
; }
90 /// Convert PDF points to logic (twips).
91 tools::Rectangle
PointsToLogic(double left
, double right
, double top
, double bottom
) const;
92 Point
PointsToLogic(double x
, double y
) const;
94 std::shared_ptr
<vcl::pdf::PDFium
> mpPDFium
;
96 // check for clip and evtl. fill maClip
100 void ImportPdfObject(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
101 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
102 int nPageObjectIndex
);
103 void ImportForm(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
104 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
105 int nPageObjectIndex
);
106 void ImportImage(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
107 int nPageObjectIndex
);
108 void ImportPath(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
109 int nPageObjectIndex
);
110 void ImportText(std::unique_ptr
<vcl::pdf::PDFiumPageObject
> const& pPageObject
,
111 std::unique_ptr
<vcl::pdf::PDFiumTextPage
> const& pTextPage
,
112 int nPageObjectIndex
);
113 void InsertTextObject(const Point
& rPos
, const Size
& rSize
, const OUString
& rStr
);
115 void SetupPageScale(const double dPageWidth
, const double dPageHeight
);
116 void SetAttributes(SdrObject
* pObj
, bool bForceTextAttr
= false);
117 void InsertObj(SdrObject
* pObj
, bool bScale
= true);
120 // #i73407# reformulation to use new B2DPolygon classes
121 bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon
& rPolyPolygon
);
123 void DoObjects(SvdProgressInfo
* pProgrInfo
, sal_uInt32
* pActionsToReport
, int nPageIndex
);
125 // Copy assignment is forbidden and not implemented.
126 ImpSdrPdfImport(const ImpSdrPdfImport
&) = delete;
127 ImpSdrPdfImport
& operator=(const ImpSdrPdfImport
&) = delete;
130 ImpSdrPdfImport(SdrModel
& rModel
, SdrLayerID nLay
, const tools::Rectangle
& rRect
,
131 Graphic
const& rGraphic
);
135 int GetPageCount() const { return mnPageCount
; }
136 size_t DoImport(SdrObjList
& rDestList
, size_t nInsPos
, int nPageNumber
,
137 SvdProgressInfo
* pProgrInfo
= nullptr);
140 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */