update dev300-m58
[ooovba.git] / sw / inc / EnhancedPDFExportHelper.hxx
blobdc5335f589788b0bc5dac37be42d6f681d11026b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EnhancedPDFExportHelper.hxx,v $
10 * $Revision: 1.10.174.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _ENHANCEDPDFEXPORTHELPER_HXX
32 #define _ENHANCEDPDFEXPORTHELPER_HXX
34 #include <vcl/pdfextoutdevdata.hxx>
35 #include <i18npool/lang.h>
36 #include <swrect.hxx>
37 #include <swtypes.hxx>
39 #include <map>
40 #include <vector>
41 #include <set>
43 namespace vcl
45 class PDFExtOutDevData;
47 class OutputDevice;
48 class SwFrm;
49 class SwLinePortion;
50 class SwTxtPainter;
51 class SwEditShell;
52 namespace rtl
54 class OUString;
56 class MultiSelection;
57 class SwTxtNode;
58 class SwNumRule;
59 class SwTable;
60 class SwNumberTreeNode;
61 class String;
62 class SvxLanguageItem;
66 * Mapping of OOo elements to tagged pdf elements:
68 * OOo element tagged pdf element
69 * ----------- ------------------
71 * Grouping elements:
73 * SwRootFrm Document
74 * Part
75 * Art
76 * SwSection Sect
77 * SwFtnContFrm and SwFlyFrm Div
78 * SwFmt "Quotations" BlockQuote
79 * SwFmt "Caption" Caption
80 * SwSection (TOC) TOC
81 * SwTxtNode in TOC TOCI
82 * SwSection (Index) Index
84 * Block-Level Structure Elements:
86 * SwTxtNode P
87 * SwFmt "Heading" H
88 * SwTxtNode with Outline H1 - H6
89 * SwTxtNode with NumRule L, LI, LBody
90 * SwTable Table
91 * SwRowFrm TR
92 * SwCellFrm in Headline row or
93 * SwFtm "Table Heading" TH
94 * SwCellFrm TD
96 * Inline-Level Structure Elements:
98 * SwTxtPortion Span
99 * SwFmt "Quotation" Quote
100 * SwFtnFrm Note
101 * Form
102 * Reference
103 * SwFldPortion (AuthorityField) BibEntry
104 * SwFmt "Source Text" Code
105 * SwFtnPortion, SwFldPortion (RefField) Link
107 * Illustration elements:
109 * SwFlyFrm with SwNoTxtFrm Figure
110 * SwFlyFrm with Math OLE Object Formula
114 struct Num_Info
116 const SwFrm& mrFrm;
117 Num_Info( const SwFrm& rFrm ) : mrFrm( rFrm ) {};
120 struct Frm_Info
122 const SwFrm& mrFrm;
123 Frm_Info( const SwFrm& rFrm ) : mrFrm( rFrm ) {};
126 struct Por_Info
128 const SwLinePortion& mrPor;
129 const SwTxtPainter& mrTxtPainter;
130 Por_Info( const SwLinePortion& rPor, const SwTxtPainter& rTxtPainer )
131 : mrPor( rPor ), mrTxtPainter( rTxtPainer ) {};
134 struct lt_TableColumn
136 bool operator()( long nVal1, long nVal2 ) const
138 return nVal1 + ( MINLAY - 1 ) < nVal2;
142 /*************************************************************************
143 * class SwTaggedPDFHelper
144 * Analyses a given frame during painting and generates the appropriate
145 * structure elements.
146 *************************************************************************/
148 class SwTaggedPDFHelper
150 private:
152 // This will be incremented for each BeginTag() call.
153 // It denotes the number of tags to close during EndStructureElements();
154 BYTE nEndStructureElement;
156 // If an already existing tag is reopened for follows of flow frames,
157 // this value stores the tag id which has to be restored.
158 sal_Int32 nRestoreCurrentTag;
160 vcl::PDFExtOutDevData* mpPDFExtOutDevData;
162 const Num_Info* mpNumInfo;
163 const Frm_Info* mpFrmInfo;
164 const Por_Info* mpPorInfo;
166 void BeginTag( vcl::PDFWriter::StructElement aTagRole, const String& rTagName );
167 void EndTag();
169 void SetAttributes( vcl::PDFWriter::StructElement eType );
171 // These functions are called by the c'tor, d'tor
172 void BeginNumberedListStructureElements();
173 void BeginBlockStructureElements();
174 void BeginInlineStructureElements();
175 void EndStructureElements();
177 bool CheckReopenTag();
178 bool CheckRestoreTag() const;
180 public:
182 // pFrmInfo != 0 => BeginBlockStructureElement
183 // pPorInfo != 0 => BeginInlineStructureElement
184 // pFrmInfo, pPorInfo = 0 => BeginNonStructureElement
185 SwTaggedPDFHelper( const Num_Info* pNumInfo, const Frm_Info* pFrmInfo, const Por_Info* pPorInfo,
186 OutputDevice& rOut );
187 ~SwTaggedPDFHelper();
189 static bool IsExportTaggedPDF( const OutputDevice& rOut );
192 /*************************************************************************
193 * class SwEnhancedPDFExportHelper
194 * Analyses the document structure and export Notes, Hyperlinks, References,
195 * and Outline. Link ids created during pdf export are stored in
196 * aReferenceIdMap and aHyperlinkIdMap, in order to use them during
197 * tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
198 * before painting. Unfortunately links from the EditEngine into the
199 * Writer document require to be exported after they have been painted.
200 * Therefore SwEnhancedPDFExportHelper also has to be used after the
201 * painting process, the parameter bEditEngineOnly indicated that only
202 * the bookmarks from the EditEngine have to be processed.
203 *************************************************************************/
205 typedef std::set< long, lt_TableColumn > TableColumnsMapEntry;
206 typedef std::pair< SwRect, sal_Int32 > IdMapEntry;
207 typedef std::vector< IdMapEntry > LinkIdMap;
208 typedef std::map< const SwTable*, TableColumnsMapEntry > TableColumnsMap;
209 typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListIdMap;
210 typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListBodyIdMap;
211 typedef std::map< const void*, sal_Int32 > FrmTagIdMap;
213 class SwEnhancedPDFExportHelper
215 private:
217 SwEditShell& mrSh;
218 OutputDevice& mrOut;
220 MultiSelection* pPageRange;
222 bool mbSkipEmptyPages;
223 bool mbEditEngineOnly;
225 static TableColumnsMap aTableColumnsMap;
226 static LinkIdMap aLinkIdMap;
227 static NumListIdMap aNumListIdMap;
228 static NumListBodyIdMap aNumListBodyIdMap;
229 static FrmTagIdMap aFrmTagIdMap;
231 static LanguageType eLanguageDefault;
233 void EnhancedPDFExport();
234 sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
236 void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
237 const SwTxtNode& rTNd, const SwRect& rLinkRect,
238 sal_Int32 nDestId, const String& rURL, bool bIntern ) const;
240 public:
242 SwEnhancedPDFExportHelper( SwEditShell& rSh,
243 OutputDevice& rOut,
244 const rtl::OUString& rPageRange,
245 bool bSkipEmptyPages,
246 bool bEditEngineOnly );
248 ~SwEnhancedPDFExportHelper();
250 static TableColumnsMap& GetTableColumnsMap() {return aTableColumnsMap; }
251 static LinkIdMap& GetLinkIdMap() { return aLinkIdMap; }
252 static NumListIdMap& GetNumListIdMap() {return aNumListIdMap; }
253 static NumListBodyIdMap& GetNumListBodyIdMap() {return aNumListBodyIdMap; }
254 static FrmTagIdMap& GetFrmTagIdMap() { return aFrmTagIdMap; }
256 static LanguageType GetDefaultLanguage() {return eLanguageDefault; }
259 #endif