Files
libreoffice/sw/inc/EnhancedPDFExportHelper.hxx

254 lines
8.6 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_INC_ENHANCEDPDFEXPORTHELPER_HXX
#define INCLUDED_SW_INC_ENHANCEDPDFEXPORTHELPER_HXX
#include <vcl/pdfextoutdevdata.hxx>
#include <i18nlangtag/lang.h>
#include <swrect.hxx>
#include <swtypes.hxx>
#include <map>
#include <vector>
#include <set>
2008-10-10 13:02:43 +00:00
namespace vcl
{
class PDFExtOutDevData;
}
class OutputDevice;
class SwFrm;
class SwLinePortion;
class SwTxtPainter;
class SwEditShell;
class StringRangeEnumerator;
class SwTxtNode;
class SwNumRule;
class SwTable;
class SwNumberTreeNode;
class SvxLanguageItem;
/*
* Mapping of OOo elements to tagged pdf elements:
*
* OOo element tagged pdf element
* ----------- ------------------
*
* Grouping elements:
*
* SwRootFrm Document
* Part
* Art
* SwSection Sect
* SwFtnContFrm and SwFlyFrm Div
* SwFmt "Quotations" BlockQuote
* SwFmt "Caption" Caption
* SwSection (TOC) TOC
* SwTxtNode in TOC TOCI
* SwSection (Index) Index
*
* Block-Level Structure Elements:
*
* SwTxtNode P
* SwFmt "Heading" H
* SwTxtNode with Outline H1 - H6
* SwTxtNode with NumRule L, LI, LBody
* SwTable Table
* SwRowFrm TR
* SwCellFrm in Headline row or
* SwFtm "Table Heading" TH
* SwCellFrm TD
*
* Inline-Level Structure Elements:
*
* SwTxtPortion Span
* SwFmt "Quotation" Quote
* SwFtnFrm Note
* Form
* Reference
* SwFldPortion (AuthorityField) BibEntry
* SwFmt "Source Text" Code
* SwFtnPortion, SwFldPortion (RefField) Link
*
* Illustration elements:
*
* SwFlyFrm with SwNoTxtFrm Figure
* SwFlyFrm with Math OLE Object Formula
*
*/
struct Num_Info
{
const SwFrm& mrFrm;
Num_Info( const SwFrm& rFrm ) : mrFrm( rFrm ) {};
};
struct Frm_Info
{
const SwFrm& mrFrm;
Frm_Info( const SwFrm& rFrm ) : mrFrm( rFrm ) {};
};
struct Por_Info
{
const SwLinePortion& mrPor;
const SwTxtPainter& mrTxtPainter;
Por_Info( const SwLinePortion& rPor, const SwTxtPainter& rTxtPainer )
: mrPor( rPor ), mrTxtPainter( rTxtPainer ) {};
};
struct lt_TableColumn
{
bool operator()( long nVal1, long nVal2 ) const
{
return nVal1 + ( MINLAY - 1 ) < nVal2;
}
};
/*************************************************************************
* class SwTaggedPDFHelper
* Analyses a given frame during painting and generates the appropriate
* structure elements.
*************************************************************************/
class SwTaggedPDFHelper
{
private:
// This will be incremented for each BeginTag() call.
// It denotes the number of tags to close during EndStructureElements();
sal_uInt8 nEndStructureElement;
// If an already existing tag is reopened for follows of flow frames,
// this value stores the tag id which has to be restored.
sal_Int32 nRestoreCurrentTag;
vcl::PDFExtOutDevData* mpPDFExtOutDevData;
const Num_Info* mpNumInfo;
const Frm_Info* mpFrmInfo;
const Por_Info* mpPorInfo;
void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& rTagName );
void EndTag();
void SetAttributes( vcl::PDFWriter::StructElement eType );
// These functions are called by the c'tor, d'tor
void BeginNumberedListStructureElements();
void BeginBlockStructureElements();
void BeginInlineStructureElements();
void EndStructureElements();
bool CheckReopenTag();
bool CheckRestoreTag() const;
public:
// pFrmInfo != 0 => BeginBlockStructureElement
// pPorInfo != 0 => BeginInlineStructureElement
// pFrmInfo, pPorInfo = 0 => BeginNonStructureElement
SwTaggedPDFHelper( const Num_Info* pNumInfo, const Frm_Info* pFrmInfo, const Por_Info* pPorInfo,
OutputDevice& rOut );
~SwTaggedPDFHelper();
static bool IsExportTaggedPDF( const OutputDevice& rOut );
};
/*************************************************************************
* class SwEnhancedPDFExportHelper
* Analyses the document structure and export Notes, Hyperlinks, References,
* and Outline. Link ids created during pdf export are stored in
* aReferenceIdMap and aHyperlinkIdMap, in order to use them during
* tagged pdf output. Therefore the SwEnhancedPDFExportHelper is used
* before painting. Unfortunately links from the EditEngine into the
* Writer document require to be exported after they have been painted.
* Therefore SwEnhancedPDFExportHelper also has to be used after the
* painting process, the parameter bEditEngineOnly indicated that only
* the bookmarks from the EditEngine have to be processed.
*************************************************************************/
typedef std::set< long, lt_TableColumn > TableColumnsMapEntry;
typedef std::pair< SwRect, sal_Int32 > IdMapEntry;
typedef std::vector< IdMapEntry > LinkIdMap;
typedef std::map< const SwTable*, TableColumnsMapEntry > TableColumnsMap;
typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListIdMap;
typedef std::map< const SwNumberTreeNode*, sal_Int32 > NumListBodyIdMap;
typedef std::map< const void*, sal_Int32 > FrmTagIdMap;
class SwEnhancedPDFExportHelper
{
private:
SwEditShell& mrSh;
OutputDevice& mrOut;
StringRangeEnumerator* mpRangeEnum;
/** The problem is that numbers in StringRangeEnumerator aren't accordant
* to real page numbers if mbSkipEmptyPages is true, because in this case
* empty pages are excluded from a page range and numbers in
* StringRangeEnumerator are shifted.
*
* maPageNumberMap[real_page_number] is either a corresponding page number
* in a page range without empty pages, or -1 if this page is empty. */
std::vector< sal_Int32 > maPageNumberMap;
bool mbSkipEmptyPages;
bool mbEditEngineOnly;
static TableColumnsMap aTableColumnsMap;
static LinkIdMap aLinkIdMap;
static NumListIdMap aNumListIdMap;
static NumListBodyIdMap aNumListBodyIdMap;
static FrmTagIdMap aFrmTagIdMap;
static LanguageType eLanguageDefault;
void EnhancedPDFExport();
sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
std::vector< sal_Int32 > CalcOutputPageNums( const SwRect& rRect ) const;
void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
const SwTxtNode& rTNd, const SwRect& rLinkRect,
sal_Int32 nDestId, const OUString& rURL, bool bIntern ) const;
public:
SwEnhancedPDFExportHelper( SwEditShell& rSh,
OutputDevice& rOut,
const OUString& rPageRange,
bool bSkipEmptyPages,
bool bEditEngineOnly );
~SwEnhancedPDFExportHelper();
static TableColumnsMap& GetTableColumnsMap() {return aTableColumnsMap; }
static LinkIdMap& GetLinkIdMap() { return aLinkIdMap; }
static NumListIdMap& GetNumListIdMap() {return aNumListIdMap; }
static NumListBodyIdMap& GetNumListBodyIdMap() {return aNumListBodyIdMap; }
static FrmTagIdMap& GetFrmTagIdMap() { return aFrmTagIdMap; }
2008-10-10 13:02:43 +00:00
static LanguageType GetDefaultLanguage() {return eLanguageDefault; }
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */