LibreOffice Module sw (master) 1
EnhancedPDFExportHelper.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#pragma once
21
22#include <i18nlangtag/lang.h>
23#include <vcl/pdfwriter.hxx>
24#include "swrect.hxx"
25#include "swtypes.hxx"
26
27#include <map>
28#include <memory>
29#include <vector>
30#include <set>
31
32namespace vcl
33{
34 class PDFExtOutDevData;
35}
36class OutputDevice;
37class SwFrame;
38class SwLinePortion;
39class SwPageFrame;
40class SwPrintData;
41class SwTextPainter;
42class SwEditShell;
44class SwTextNode;
45class SwTable;
47
48/*
49 * Mapping of OOo elements to tagged pdf elements:
50 *
51 * OOo element tagged pdf element
52 * ----------- ------------------
53 *
54 * Grouping elements:
55 *
56 * SwRootFrame Document
57 * Part
58 * Art
59 * SwSection Sect
60 * SwFootnoteContFrame and SwFlyFrame Div
61 * SwFormat "Quotations" BlockQuote
62 * SwFormat "Caption" Caption
63 * SwSection (TOC) TOC
64 * SwTextNode in TOC TOCI
65 * SwSection (Index) Index
66 *
67 * Block-Level Structure Elements:
68 *
69 * SwTextNode P
70 * SwFormat "Heading" H
71 * SwTextNode with Outline H1 - H6
72 * SwTextNode with NumRule L, LI, LBody
73 * SwTable Table
74 * SwRowFrame TR
75 * SwCellFrame in Headline row or
76 * SwFtm "Table Heading" TH
77 * SwCellFrame TD
78 *
79 * Inline-Level Structure Elements:
80 *
81 * SwTextPortion Span
82 * SwFormat "Quotation" Quote
83 * SwFootnoteFrame Note
84 * Form
85 * Reference
86 * SwFieldPortion (AuthorityField) BibEntry
87 * SwFormat "Source Text" Code
88 * SwFootnotePortion, SwFieldPortion (RefField) Link
89 *
90 * Illustration elements:
91 *
92 * SwFlyFrame with SwNoTextFrame Figure
93 * SwFlyFrame with Math OLE Object Formula
94 *
95 */
96
98{
100 Num_Info( const SwFrame& rFrame ) : mrFrame( rFrame ) {};
101};
102
104{
106 bool const m_isLink;
107
108 Frame_Info(const SwFrame& rFrame, bool const isLink)
109 : mrFrame(rFrame), m_isLink(isLink) {}
110};
111
113{
117
118 Por_Info(const SwLinePortion& rPor, const SwTextPainter& rTextPainer, bool const isNumberingLabel)
119 : mrPor(rPor), mrTextPainter(rTextPainer), m_isNumberingLabel(isNumberingLabel) {};
120};
121
123{
124 bool operator()( tools::Long nVal1, tools::Long nVal2 ) const
125 {
126 return nVal1 + ( MINLAY - 1 ) < nVal2;
127 }
128};
129
130// Analyses a given frame during painting and generates the appropriate
131// structure elements.
133{
134 private:
135
136 // This will be incremented for each BeginTag() call.
137 // It denotes the number of tags to close during EndStructureElements();
139
140 // If an already existing tag is reopened for follows of flow frames,
141 // this value stores the tag id which has to be restored.
143
145
149
150 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& rTagName );
151 void EndTag();
152
154
155 // These functions are called by the c'tor, d'tor
160
161 bool CheckReopenTag();
162 void CheckRestoreTag() const;
163
164 public:
165
166 // pFrameInfo != 0 => BeginBlockStructureElement
167 // pPorInfo != 0 => BeginInlineStructureElement
168 // pFrameInfo, pPorInfo = 0 => BeginNonStructureElement
169 SwTaggedPDFHelper( const Num_Info* pNumInfo, const Frame_Info* pFrameInfo, const Por_Info* pPorInfo,
170 OutputDevice const & rOut );
172
173 static bool IsExportTaggedPDF( const OutputDevice& rOut );
174};
175
176/*
177 * Analyses the document structure and export Notes, Hyperlinks, References,
178 * and Outline. Link ids created during pdf export are stored in
179 * aReferenceIdMap and aHyperlinkIdMap, in order to use them during
180 * tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
181 * before painting. Unfortunately links from the EditEngine into the
182 * Writer document require to be exported after they have been painted.
183 * Therefore SwEnhancedPDFExportHelper also has to be used after the
184 * painting process, the parameter bEditEngineOnly indicated that only
185 * the bookmarks from the EditEngine have to be processed.
186 */
187typedef std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry;
188typedef std::pair< SwRect, sal_Int32 > IdMapEntry;
189typedef std::vector< IdMapEntry > LinkIdMap;
190typedef std::map< const SwTable*, TableColumnsMapEntry > TableColumnsMap;
191typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListIdMap;
192typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListBodyIdMap;
193typedef std::set<const void*> FrameTagSet;
194
196{
197 private:
198
201
202 std::unique_ptr<StringRangeEnumerator> mpRangeEnum;
210 std::vector< sal_Int32 > maPageNumberMap;
211
214
216
222
224
225 void EnhancedPDFExport();
226
229
230 sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
231 std::vector< sal_Int32 > CalcOutputPageNums( const SwRect& rRect ) const;
232
233 void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
234 const SwTextNode& rTNd, const SwRect& rLinkRect,
235 sal_Int32 nDestId, const OUString& rURL,
236 bool bIntern, OUString const& rContent) const;
237
238 public:
239
241 OutputDevice& rOut,
242 const OUString& rPageRange,
243 bool bSkipEmptyPages,
244 bool bEditEngineOnly,
245 const SwPrintData& rPrintData );
246
248
250 static LinkIdMap& GetLinkIdMap() { return s_aLinkIdMap; }
254
256
257 //scale and position rRectangle if we're scaling due to notes in margins.
259 const tools::Rectangle& rRectangle) const;
260};
261
262/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry
std::set< const void * > FrameTagSet
std::map< const SwNumberTreeNode *, sal_Int32 > NumListIdMap
std::map< const SwNumberTreeNode *, sal_Int32 > NumListBodyIdMap
std::vector< IdMapEntry > LinkIdMap
std::map< const SwTable *, TableColumnsMapEntry > TableColumnsMap
std::pair< SwRect, sal_Int32 > IdMapEntry
static FrameTagSet & GetFrameTagSet()
static TableColumnsMap & GetTableColumnsMap()
static NumListBodyIdMap & GetNumListBodyIdMap()
sal_Int32 CalcOutputPageNum(const SwRect &rRect) const
SwEnhancedPDFExportHelper(SwEditShell &rSh, OutputDevice &rOut, const OUString &rPageRange, bool bSkipEmptyPages, bool bEditEngineOnly, const SwPrintData &rPrintData)
static TableColumnsMap s_aTableColumnsMap
static LanguageType GetDefaultLanguage()
static NumListBodyIdMap s_aNumListBodyIdMap
static NumListIdMap & GetNumListIdMap()
std::vector< sal_Int32 > CalcOutputPageNums(const SwRect &rRect) const
void ExportAuthorityEntryLinks()
Exports bibliography entry links.
std::vector< sal_Int32 > maPageNumberMap
The problem is that numbers in StringRangeEnumerator aren't accordant to real page numbers if mbSkipE...
tools::Rectangle SwRectToPDFRect(const SwPageFrame *pCurrPage, const tools::Rectangle &rRectangle) const
void MakeHeaderFooterLinks(vcl::PDFExtOutDevData &rPDFExtOutDevData, const SwTextNode &rTNd, const SwRect &rLinkRect, sal_Int32 nDestId, const OUString &rURL, bool bIntern, OUString const &rContent) const
std::unique_ptr< StringRangeEnumerator > mpRangeEnum
Base class of the Writer layout elements.
Definition: frame.hxx:315
Base class for anything that can be part of a line in the Writer layout.
Definition: porlin.hxx:52
A tree of numbered nodes.
A page of the document layout.
Definition: pagefrm.hxx:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
const Frame_Info * mpFrameInfo
void SetAttributes(vcl::PDFWriter::StructElement eType)
static bool IsExportTaggedPDF(const OutputDevice &rOut)
SwTaggedPDFHelper(const Num_Info *pNumInfo, const Frame_Info *pFrameInfo, const Por_Info *pPorInfo, OutputDevice const &rOut)
vcl::PDFExtOutDevData * mpPDFExtOutDevData
void BeginTag(vcl::PDFWriter::StructElement aTagRole, const OUString &rTagName)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
long Long
Frame_Info(const SwFrame &rFrame, bool const isLink)
const SwFrame & mrFrame
Num_Info(const SwFrame &rFrame)
const SwFrame & mrFrame
const SwLinePortion & mrPor
const SwTextPainter & mrTextPainter
Por_Info(const SwLinePortion &rPor, const SwTextPainter &rTextPainer, bool const isNumberingLabel)
bool const m_isNumberingLabel
bool operator()(tools::Long nVal1, tools::Long nVal2) const
#define MINLAY
Definition: swtypes.hxx:62
unsigned char sal_uInt8