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 <sal/config.h>
24 
25 #include <memory>
26 
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>
32 
34 
36 
37 // Forward Declarations
38 
39 class SfxItemSet;
40 class SdrObjList;
41 class SdrModel;
42 class SdrPage;
43 class SdrObject;
44 class SvdProgressInfo;
45 
46 // Helper Class to import PDF
47 class ImpSdrPdfImport final
48 {
49  std::vector<SdrObject*> maTmpList;
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;
62 
63  bool mbMov;
64  bool mbSize;
66  double mfScaleX;
67  double mfScaleY;
70 
71  bool mbFntDirty;
72 
73  // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
75  bool mbNoLine;
76  bool mbNoFill;
77 
78  // clipregion
80 
81  std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
86 
89  double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; }
91  tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const;
92  Point PointsToLogic(double x, double y) const;
93 
94  std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
95 
96  // check for clip and evtl. fill maClip
97  void checkClip();
98  bool isClip() const;
99 
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);
114 
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);
118  void MapScaling();
119 
120  // #i73407# reformulation to use new B2DPolygon classes
121  bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
122 
123  void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
124 
125  // Copy assignment is forbidden and not implemented.
126  ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
127  ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete;
128 
129 public:
130  ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
131  Graphic const& rGraphic);
132 
134 
135  int GetPageCount() const { return mnPageCount; }
136  size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber,
137  SvdProgressInfo* pProgrInfo = nullptr);
138 };
139 
140 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
141 
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Color maOldLineColor
Definition: svdpdf.hxx:58
void InsertTextObject(const Point &rPos, const Size &rSize, const OUString &rStr)
Definition: svdpdf.cxx:785
basegfx::B2DPolyPolygon maClip
Definition: svdpdf.hxx:79
size_t DoImport(SdrObjList &rDestList, size_t nInsPos, int nPageNumber, SvdProgressInfo *pProgrInfo=nullptr)
Definition: svdpdf.cxx:221
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon &rPolyPolygon)
Definition: svdpdf.cxx:613
bool mbLastObjWasPolyWithoutLine
Definition: svdpdf.hxx:74
XDash maDash
Definition: svdpdf.hxx:61
void MapScaling()
Definition: svdpdf.cxx:843
ImpSdrPdfImport(const ImpSdrPdfImport &)=delete
void ImportImage(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, int nPageObjectIndex)
Definition: svdpdf.cxx:863
void SetAttributes(SdrObject *pObj, bool bForceTextAttr=false)
Definition: svdpdf.cxx:281
double mdPageHeightPts
Definition: svdpdf.hxx:83
Fraction maScaleX
Definition: svdpdf.hxx:68
SdrLayerID mnLayer
Definition: svdpdf.hxx:57
size_t mnMapScalingOfs
Definition: svdpdf.hxx:52
double mfScaleY
Definition: svdpdf.hxx:67
Definition: xdash.hxx:31
std::unique_ptr< vcl::pdf::PDFiumDocument > mpPdfDocument
Definition: svdpdf.hxx:81
void SetupPageScale(const double dPageWidth, const double dPageHeight)
Definition: svdpdf.cxx:177
void ImportText(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
Definition: svdpdf.cxx:710
Fraction maScaleY
Definition: svdpdf.hxx:69
void ImportPath(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, int nPageObjectIndex)
Definition: svdpdf.cxx:923
void ImportPdfObject(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
Definition: svdpdf.cxx:657
void ImportForm(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
Definition: svdpdf.cxx:689
std::unique_ptr< SfxItemSet > mpLineAttr
Definition: svdpdf.hxx:53
bool mbFntDirty
Definition: svdpdf.hxx:71
void checkClip()
Definition: svdpdf.cxx:640
void InsertObj(SdrObject *pObj, bool bScale=true)
Definition: svdpdf.cxx:404
Helper class for the communication between the dialog In order to break open Metafiles (sd/source/ui/...
Definition: svdetc.hxx:112
Abstract DrawObject.
Definition: svdobj.hxx:259
std::unique_ptr< SfxItemSet > mpTextAttr
Definition: svdpdf.hxx:55
static constexpr css::drawing::LineCap gaLineCap
Definition: svdpdf.hxx:60
std::unique_ptr< SfxItemSet > mpFillAttr
Definition: svdpdf.hxx:54
double mfScaleX
Definition: svdpdf.hxx:66
std::vector< SdrObject * > maTmpList
Definition: svdpdf.hxx:49
std::shared_ptr< vcl::pdf::PDFium > mpPDFium
Definition: svdpdf.hxx:94
ImpSdrPdfImport & operator=(const ImpSdrPdfImport &)=delete
double correctVertOrigin(double offsetPts) const
Correct the vertical coordinate to start at the top.
Definition: svdpdf.hxx:89
tools::Rectangle maScaleRect
Definition: svdpdf.hxx:51
void DoObjects(SvdProgressInfo *pProgrInfo, sal_uInt32 *pActionsToReport, int nPageIndex)
Definition: svdpdf.cxx:132
tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const
Convert PDF points to logic (twips).
Definition: svdpdf.cxx:1044
int GetPageCount() const
Definition: svdpdf.hxx:135
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
bool isClip() const
Definition: svdpdf.cxx:656
basegfx::B2DHomMatrix maCurrentMatrix
The current transformation matrix, typically used with Form objects.
Definition: svdpdf.hxx:85
ScopedVclPtr< VirtualDevice > mpVD
Definition: svdpdf.hxx:50
sal_Int32 mnLineWidth
Definition: svdpdf.hxx:59
SdrModel * mpModel
Definition: svdpdf.hxx:56