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#ifndef INCLUDED_SW_INC_ENHANCEDPDFEXPORTHELPER_HXX
21#define INCLUDED_SW_INC_ENHANCEDPDFEXPORTHELPER_HXX
22
23#include <i18nlangtag/lang.h>
24#include <vcl/pdfwriter.hxx>
25#include "swrect.hxx"
26#include "swtypes.hxx"
27
28#include <map>
29#include <memory>
30#include <vector>
31#include <set>
32
33namespace vcl
34{
35 class PDFExtOutDevData;
36}
37class OutputDevice;
38class SwFrame;
39class SwLinePortion;
40class SwPageFrame;
41class SwPrintData;
42class SwTextPainter;
43class SwEditShell;
45class SwTextNode;
46class SwTable;
48
49/*
50 * Mapping of OOo elements to tagged pdf elements:
51 *
52 * OOo element tagged pdf element
53 * ----------- ------------------
54 *
55 * Grouping elements:
56 *
57 * SwRootFrame Document
58 * Part
59 * Art
60 * SwSection Sect
61 * SwFootnoteContFrame and SwFlyFrame Div
62 * SwFormat "Quotations" BlockQuote
63 * SwFormat "Caption" Caption
64 * SwSection (TOC) TOC
65 * SwTextNode in TOC TOCI
66 * SwSection (Index) Index
67 *
68 * Block-Level Structure Elements:
69 *
70 * SwTextNode P
71 * SwFormat "Heading" H
72 * SwTextNode with Outline H1 - H6
73 * SwTextNode with NumRule L, LI, LBody
74 * SwTable Table
75 * SwRowFrame TR
76 * SwCellFrame in Headline row or
77 * SwFtm "Table Heading" TH
78 * SwCellFrame TD
79 *
80 * Inline-Level Structure Elements:
81 *
82 * SwTextPortion Span
83 * SwFormat "Quotation" Quote
84 * SwFootnoteFrame Note
85 * Form
86 * Reference
87 * SwFieldPortion (AuthorityField) BibEntry
88 * SwFormat "Source Text" Code
89 * SwFootnotePortion, SwFieldPortion (RefField) Link
90 *
91 * Illustration elements:
92 *
93 * SwFlyFrame with SwNoTextFrame Figure
94 * SwFlyFrame with Math OLE Object Formula
95 *
96 */
97
99{
101 Num_Info( const SwFrame& rFrame ) : mrFrame( rFrame ) {};
102};
103
105{
107 Frame_Info( const SwFrame& rFrame ) : mrFrame( rFrame ) {};
108};
109
111{
114 Por_Info( const SwLinePortion& rPor, const SwTextPainter& rTextPainer )
115 : mrPor( rPor ), mrTextPainter( rTextPainer ) {};
116};
117
119{
120 bool operator()( tools::Long nVal1, tools::Long nVal2 ) const
121 {
122 return nVal1 + ( MINLAY - 1 ) < nVal2;
123 }
124};
125
126// Analyses a given frame during painting and generates the appropriate
127// structure elements.
129{
130 private:
131
132 // This will be incremented for each BeginTag() call.
133 // It denotes the number of tags to close during EndStructureElements();
135
136 // If an already existing tag is reopened for follows of flow frames,
137 // this value stores the tag id which has to be restored.
139
141
145
146 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& rTagName );
147 void EndTag();
148
150
151 // These functions are called by the c'tor, d'tor
156
157 bool CheckReopenTag();
158 void CheckRestoreTag() const;
159
160 public:
161
162 // pFrameInfo != 0 => BeginBlockStructureElement
163 // pPorInfo != 0 => BeginInlineStructureElement
164 // pFrameInfo, pPorInfo = 0 => BeginNonStructureElement
165 SwTaggedPDFHelper( const Num_Info* pNumInfo, const Frame_Info* pFrameInfo, const Por_Info* pPorInfo,
166 OutputDevice const & rOut );
168
169 static bool IsExportTaggedPDF( const OutputDevice& rOut );
170};
171
172/*
173 * Analyses the document structure and export Notes, Hyperlinks, References,
174 * and Outline. Link ids created during pdf export are stored in
175 * aReferenceIdMap and aHyperlinkIdMap, in order to use them during
176 * tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
177 * before painting. Unfortunately links from the EditEngine into the
178 * Writer document require to be exported after they have been painted.
179 * Therefore SwEnhancedPDFExportHelper also has to be used after the
180 * painting process, the parameter bEditEngineOnly indicated that only
181 * the bookmarks from the EditEngine have to be processed.
182 */
183typedef std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry;
184typedef std::pair< SwRect, sal_Int32 > IdMapEntry;
185typedef std::vector< IdMapEntry > LinkIdMap;
186typedef std::map< const SwTable*, TableColumnsMapEntry > TableColumnsMap;
187typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListIdMap;
188typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListBodyIdMap;
189typedef std::map< const void*, sal_Int32 > FrameTagIdMap;
190
192{
193 private:
194
197
198 std::unique_ptr<StringRangeEnumerator> mpRangeEnum;
206 std::vector< sal_Int32 > maPageNumberMap;
207
210
212
218
220
221 void EnhancedPDFExport();
222
225
226 sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
227 std::vector< sal_Int32 > CalcOutputPageNums( const SwRect& rRect ) const;
228
229 void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
230 const SwTextNode& rTNd, const SwRect& rLinkRect,
231 sal_Int32 nDestId, const OUString& rURL, bool bIntern ) const;
232
233 public:
234
236 OutputDevice& rOut,
237 const OUString& rPageRange,
238 bool bSkipEmptyPages,
239 bool bEditEngineOnly,
240 const SwPrintData& rPrintData );
241
243
245 static LinkIdMap& GetLinkIdMap() { return s_aLinkIdMap; }
249
251
252 //scale and position rRectangle if we're scaling due to notes in margins.
254 const tools::Rectangle& rRectangle) const;
255};
256
257#endif
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.
void MakeHeaderFooterLinks(vcl::PDFExtOutDevData &rPDFExtOutDevData, const SwTextNode &rTNd, const SwRect &rLinkRect, sal_Int32 nDestId, const OUString &rURL, bool bIntern) const
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
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:58
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:86
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 operator()(tools::Long nVal1, tools::Long nVal2) const
#define MINLAY
Definition: swtypes.hxx:62
unsigned char sal_uInt8