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 Frame_Info( const SwFrame& rFrame ) : mrFrame( rFrame ) {};
107};
108
110{
114
115 Por_Info(const SwLinePortion& rPor, const SwTextPainter& rTextPainer, bool const isNumberingLabel)
116 : mrPor(rPor), mrTextPainter(rTextPainer), m_isNumberingLabel(isNumberingLabel) {};
117};
118
120{
121 bool operator()( tools::Long nVal1, tools::Long nVal2 ) const
122 {
123 return nVal1 + ( MINLAY - 1 ) < nVal2;
124 }
125};
126
127// Analyses a given frame during painting and generates the appropriate
128// structure elements.
130{
131 private:
132
133 // This will be incremented for each BeginTag() call.
134 // It denotes the number of tags to close during EndStructureElements();
136
137 // If an already existing tag is reopened for follows of flow frames,
138 // this value stores the tag id which has to be restored.
140
142
146
147 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& rTagName );
148 void EndTag();
149
151
152 // These functions are called by the c'tor, d'tor
157
158 bool CheckReopenTag();
159 void CheckRestoreTag() const;
160
161 public:
162
163 // pFrameInfo != 0 => BeginBlockStructureElement
164 // pPorInfo != 0 => BeginInlineStructureElement
165 // pFrameInfo, pPorInfo = 0 => BeginNonStructureElement
166 SwTaggedPDFHelper( const Num_Info* pNumInfo, const Frame_Info* pFrameInfo, const Por_Info* pPorInfo,
167 OutputDevice const & rOut );
169
170 static bool IsExportTaggedPDF( const OutputDevice& rOut );
171};
172
173/*
174 * Analyses the document structure and export Notes, Hyperlinks, References,
175 * and Outline. Link ids created during pdf export are stored in
176 * aReferenceIdMap and aHyperlinkIdMap, in order to use them during
177 * tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
178 * before painting. Unfortunately links from the EditEngine into the
179 * Writer document require to be exported after they have been painted.
180 * Therefore SwEnhancedPDFExportHelper also has to be used after the
181 * painting process, the parameter bEditEngineOnly indicated that only
182 * the bookmarks from the EditEngine have to be processed.
183 */
184typedef std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry;
185typedef std::pair< SwRect, sal_Int32 > IdMapEntry;
186typedef std::vector< IdMapEntry > LinkIdMap;
187typedef std::map< const SwTable*, TableColumnsMapEntry > TableColumnsMap;
188typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListIdMap;
189typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListBodyIdMap;
190typedef std::map< const void*, sal_Int32 > FrameTagIdMap;
191
193{
194 private:
195
198
199 std::unique_ptr<StringRangeEnumerator> mpRangeEnum;
207 std::vector< sal_Int32 > maPageNumberMap;
208
211
213
219
221
222 void EnhancedPDFExport();
223
226
227 sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
228 std::vector< sal_Int32 > CalcOutputPageNums( const SwRect& rRect ) const;
229
230 void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
231 const SwTextNode& rTNd, const SwRect& rLinkRect,
232 sal_Int32 nDestId, const OUString& rURL,
233 bool bIntern, OUString const& rContent) const;
234
235 public:
236
238 OutputDevice& rOut,
239 const OUString& rPageRange,
240 bool bSkipEmptyPages,
241 bool bEditEngineOnly,
242 const SwPrintData& rPrintData );
243
245
247 static LinkIdMap& GetLinkIdMap() { return s_aLinkIdMap; }
251
253
254 //scale and position rRectangle if we're scaling due to notes in margins.
256 const tools::Rectangle& rRectangle) const;
257};
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry
std::map< const SwNumberTreeNode *, sal_Int32 > NumListIdMap
std::map< const SwNumberTreeNode *, sal_Int32 > NumListBodyIdMap
std::vector< IdMapEntry > LinkIdMap
std::map< const void *, sal_Int32 > FrameTagIdMap
std::map< const SwTable *, TableColumnsMapEntry > TableColumnsMap
std::pair< SwRect, sal_Int32 > IdMapEntry
static TableColumnsMap & GetTableColumnsMap()
static NumListBodyIdMap & GetNumListBodyIdMap()
sal_Int32 CalcOutputPageNum(const SwRect &rRect) const
static FrameTagIdMap & GetFrameTagIdMap()
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:59
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
const SwFrame & mrFrame
Frame_Info(const SwFrame &rFrame)
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