1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _ENHANCEDPDFEXPORTHELPER_HXX
21 #define _ENHANCEDPDFEXPORTHELPER_HXX
23 #include <vcl/pdfextoutdevdata.hxx>
24 #include <i18nlangtag/lang.h>
26 #include <swtypes.hxx>
34 class PDFExtOutDevData
;
41 class StringRangeEnumerator
;
45 class SwNumberTreeNode
;
47 class SvxLanguageItem
;
51 * Mapping of OOo elements to tagged pdf elements:
53 * OOo element tagged pdf element
54 * ----------- ------------------
62 * SwFtnContFrm and SwFlyFrm Div
63 * SwFmt "Quotations" BlockQuote
64 * SwFmt "Caption" Caption
66 * SwTxtNode in TOC TOCI
67 * SwSection (Index) Index
69 * Block-Level Structure Elements:
73 * SwTxtNode with Outline H1 - H6
74 * SwTxtNode with NumRule L, LI, LBody
77 * SwCellFrm in Headline row or
78 * SwFtm "Table Heading" TH
81 * Inline-Level Structure Elements:
84 * SwFmt "Quotation" Quote
88 * SwFldPortion (AuthorityField) BibEntry
89 * SwFmt "Source Text" Code
90 * SwFtnPortion, SwFldPortion (RefField) Link
92 * Illustration elements:
94 * SwFlyFrm with SwNoTxtFrm Figure
95 * SwFlyFrm with Math OLE Object Formula
102 Num_Info( const SwFrm
& rFrm
) : mrFrm( rFrm
) {};
108 Frm_Info( const SwFrm
& rFrm
) : mrFrm( rFrm
) {};
113 const SwLinePortion
& mrPor
;
114 const SwTxtPainter
& mrTxtPainter
;
115 Por_Info( const SwLinePortion
& rPor
, const SwTxtPainter
& rTxtPainer
)
116 : mrPor( rPor
), mrTxtPainter( rTxtPainer
) {};
119 struct lt_TableColumn
121 bool operator()( long nVal1
, long nVal2
) const
123 return nVal1
+ ( MINLAY
- 1 ) < nVal2
;
127 /*************************************************************************
128 * class SwTaggedPDFHelper
129 * Analyses a given frame during painting and generates the appropriate
130 * structure elements.
131 *************************************************************************/
133 class SwTaggedPDFHelper
137 // This will be incremented for each BeginTag() call.
138 // It denotes the number of tags to close during EndStructureElements();
139 sal_uInt8 nEndStructureElement
;
141 // If an already existing tag is reopened for follows of flow frames,
142 // this value stores the tag id which has to be restored.
143 sal_Int32 nRestoreCurrentTag
;
145 vcl::PDFExtOutDevData
* mpPDFExtOutDevData
;
147 const Num_Info
* mpNumInfo
;
148 const Frm_Info
* mpFrmInfo
;
149 const Por_Info
* mpPorInfo
;
151 void BeginTag( vcl::PDFWriter::StructElement aTagRole
, const String
& rTagName
);
154 void SetAttributes( vcl::PDFWriter::StructElement eType
);
156 // These functions are called by the c'tor, d'tor
157 void BeginNumberedListStructureElements();
158 void BeginBlockStructureElements();
159 void BeginInlineStructureElements();
160 void EndStructureElements();
162 bool CheckReopenTag();
163 bool CheckRestoreTag() const;
167 // pFrmInfo != 0 => BeginBlockStructureElement
168 // pPorInfo != 0 => BeginInlineStructureElement
169 // pFrmInfo, pPorInfo = 0 => BeginNonStructureElement
170 SwTaggedPDFHelper( const Num_Info
* pNumInfo
, const Frm_Info
* pFrmInfo
, const Por_Info
* pPorInfo
,
171 OutputDevice
& rOut
);
172 ~SwTaggedPDFHelper();
174 static bool IsExportTaggedPDF( const OutputDevice
& rOut
);
177 /*************************************************************************
178 * class SwEnhancedPDFExportHelper
179 * Analyses the document structure and export Notes, Hyperlinks, References,
180 * and Outline. Link ids created during pdf export are stored in
181 * aReferenceIdMap and aHyperlinkIdMap, in order to use them during
182 * tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
183 * before painting. Unfortunately links from the EditEngine into the
184 * Writer document require to be exported after they have been painted.
185 * Therefore SwEnhancedPDFExportHelper also has to be used after the
186 * painting process, the parameter bEditEngineOnly indicated that only
187 * the bookmarks from the EditEngine have to be processed.
188 *************************************************************************/
190 typedef std::set
< long, lt_TableColumn
> TableColumnsMapEntry
;
191 typedef std::pair
< SwRect
, sal_Int32
> IdMapEntry
;
192 typedef std::vector
< IdMapEntry
> LinkIdMap
;
193 typedef std::map
< const SwTable
*, TableColumnsMapEntry
> TableColumnsMap
;
194 typedef std::map
< const SwNumberTreeNode
*, sal_Int32
> NumListIdMap
;
195 typedef std::map
< const SwNumberTreeNode
*, sal_Int32
> NumListBodyIdMap
;
196 typedef std::map
< const void*, sal_Int32
> FrmTagIdMap
;
198 class SwEnhancedPDFExportHelper
205 StringRangeEnumerator
* mpRangeEnum
;
206 /** The problem is that numbers in StringRangeEnumerator aren't accordant
207 * to real page numbers if mbSkipEmptyPages is true, because in this case
208 * empty pages are excluded from a page range and numbers in
209 * StringRangeEnumerator are shifted.
211 * maPageNumberMap[real_page_number] is either a corresponding page number
212 * in a page range without empty pages, or -1 if this page is empty. */
213 std::vector
< sal_Int32
> maPageNumberMap
;
215 bool mbSkipEmptyPages
;
216 bool mbEditEngineOnly
;
218 static TableColumnsMap aTableColumnsMap
;
219 static LinkIdMap aLinkIdMap
;
220 static NumListIdMap aNumListIdMap
;
221 static NumListBodyIdMap aNumListBodyIdMap
;
222 static FrmTagIdMap aFrmTagIdMap
;
224 static LanguageType eLanguageDefault
;
226 void EnhancedPDFExport();
227 sal_Int32
CalcOutputPageNum( const SwRect
& rRect
) const;
228 std::vector
< sal_Int32
> CalcOutputPageNums( const SwRect
& rRect
) const;
230 void MakeHeaderFooterLinks( vcl::PDFExtOutDevData
& rPDFExtOutDevData
,
231 const SwTxtNode
& rTNd
, const SwRect
& rLinkRect
,
232 sal_Int32 nDestId
, const String
& rURL
, bool bIntern
) const;
236 SwEnhancedPDFExportHelper( SwEditShell
& rSh
,
238 const OUString
& rPageRange
,
239 bool bSkipEmptyPages
,
240 bool bEditEngineOnly
);
242 ~SwEnhancedPDFExportHelper();
244 static TableColumnsMap
& GetTableColumnsMap() {return aTableColumnsMap
; }
245 static LinkIdMap
& GetLinkIdMap() { return aLinkIdMap
; }
246 static NumListIdMap
& GetNumListIdMap() {return aNumListIdMap
; }
247 static NumListBodyIdMap
& GetNumListBodyIdMap() {return aNumListBodyIdMap
; }
248 static FrmTagIdMap
& GetFrmTagIdMap() { return aFrmTagIdMap
; }
250 static LanguageType
GetDefaultLanguage() {return eLanguageDefault
; }
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */