LibreOffice Module svx (master)  1
svdpdf.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
21 #define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
22 
23 #include <config_features.h>
24 
25 #if HAVE_FEATURE_PDFIUM
26 #include <sal/config.h>
27 #include <svx/svxdllapi.h>
28 
29 #include <memory>
30 
31 #include <tools/fract.hxx>
32 #include <vcl/virdev.hxx>
33 #include <vcl/graph.hxx>
34 #include <svx/svdobj.hxx>
35 #include <svx/xdash.hxx>
36 
38 
39 // Prevent workdir/UnpackedTarball/pdfium/public/fpdfview.h from including windows.h in a way that
40 // it will define e.g. Yield as a macro:
41 #include <prewin.h>
42 #include <postwin.h>
43 #include <fpdfview.h>
44 
46 
47 // Forward Declarations
48 
49 class SfxItemSet;
50 class SdrObjList;
51 class SdrModel;
52 class SdrPage;
53 class SdrObject;
54 class SvdProgressInfo;
55 
56 // Helper Class to import PDF
57 class ImpSdrPdfImport final
58 {
59  std::vector<SdrObject*> maTmpList;
61  tools::Rectangle maScaleRect;
62  size_t mnMapScalingOfs; // from here on, not edited with MapScaling
63  std::unique_ptr<SfxItemSet> mpLineAttr;
64  std::unique_ptr<SfxItemSet> mpFillAttr;
65  std::unique_ptr<SfxItemSet> mpTextAttr;
66  SdrModel* mpModel;
68  Color maOldLineColor;
69  sal_Int32 mnLineWidth;
70  static constexpr css::drawing::LineCap gaLineCap = css::drawing::LineCap_BUTT;
71  XDash maDash;
72 
73  bool mbMov;
74  bool mbSize;
75  Point maOfs;
76  double mfScaleX;
77  double mfScaleY;
78  Fraction maScaleX;
79  Fraction maScaleY;
80 
81  bool mbFntDirty;
82 
83  // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
84  bool mbLastObjWasPolyWithoutLine;
85  bool mbNoLine;
86  bool mbNoFill;
87 
88  // clipregion
90 
91  std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
92  int mnPageCount;
93  double mdPageHeightPts;
95  basegfx::B2DHomMatrix maCurrentMatrix;
96 
99  double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; }
101  tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const;
102  Point PointsToLogic(double x, double y) const;
103 
104  std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
105 
106  // check for clip and evtl. fill maClip
107  void checkClip();
108  bool isClip() const;
109 
110  void ImportPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
111  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
112  int nPageObjectIndex);
113  void ImportForm(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
114  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
115  int nPageObjectIndex);
116  void ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
117  int nPageObjectIndex);
118  void ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
119  int nPageObjectIndex);
120  void ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
121  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
122  int nPageObjectIndex);
123  void InsertTextObject(const Point& rPos, const Size& rSize, const OUString& rStr);
124 
125  void SetupPageScale(const double dPageWidth, const double dPageHeight);
126  void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
127  void InsertObj(SdrObject* pObj, bool bScale = true);
128  void MapScaling();
129 
130  // #i73407# reformulation to use new B2DPolygon classes
131  bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
132 
133  void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
134 
135  // Copy assignment is forbidden and not implemented.
136  ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
137  ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete;
138 
139 public:
140  ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
141  Graphic const& rGraphic);
142 
143  ~ImpSdrPdfImport();
144 
145  int GetPageCount() const { return mnPageCount; }
146  size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber,
147  SvdProgressInfo* pProgrInfo = nullptr);
148 };
149 
150 #endif // HAVE_FEATURE_PDFIUM
151 
152 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDFMTF_HXX
153 
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: xdash.hxx:31
basegfx::B2DPolyPolygon maClip
Helper class for the communication between the dialog In order to break open Metafiles (sd/source/ui/...
Definition: svdetc.hxx:111
Abstract DrawObject.
Definition: svdobj.hxx:312
const int mnLayer
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365