LCOV - code coverage report
Current view: top level - include/vcl - pdfextoutdevdata.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 17 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_VCL_PDFEXTOUTDEVDATA_HXX
      21             : #define INCLUDED_VCL_PDFEXTOUTDEVDATA_HXX
      22             : 
      23             : #include <vcl/dllapi.h>
      24             : 
      25             : #include <vcl/pdfwriter.hxx>
      26             : #include <vcl/extoutdevdata.hxx>
      27             : #include <vcl/gdimtf.hxx>
      28             : #include <vcl/mapmod.hxx>
      29             : #include <tools/rtti.hxx>
      30             : #include <vector>
      31             : #include <deque>
      32             : 
      33             : class Graphic;
      34             : 
      35             : namespace vcl { class PDFWriter; }
      36             : 
      37             : namespace vcl
      38             : {
      39             : 
      40             : /*
      41             :     A PDFExtOutDevBookmarkEntry is being created by the EditEngine if
      42             :     a bookmark URL has been parsed. The Application is requested to take
      43             :     care of each bookmark entry by emptying out the bookmark vector.
      44             : */
      45           0 : struct PDFExtOutDevBookmarkEntry
      46             : {
      47             :     /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link.
      48             :     */
      49             :     sal_Int32       nLinkId;
      50             : 
      51             :     /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination.
      52             :     */
      53             :     sal_Int32       nDestId;
      54             : 
      55             :     /** link target name, respectively destination name
      56             :     */
      57             :     OUString   aBookmark;
      58             : 
      59           0 :     PDFExtOutDevBookmarkEntry()
      60             :         :nLinkId( -1 )
      61             :         ,nDestId( -1 )
      62           0 :         ,aBookmark()
      63             :     {
      64           0 :     }
      65             : };
      66             : 
      67             : /*
      68             :  Class that is being set at the OutputDevice allowing the
      69             :  application to send enhanced PDF commands like CreateLink
      70             : */
      71             : struct PageSyncData;
      72             : struct GlobalSyncData;
      73             : class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData
      74             : {
      75             : 
      76             :     const OutputDevice& mrOutDev;
      77             : 
      78             :     bool                        mbTaggedPDF;
      79             :     bool                        mbExportNotes;
      80             :     bool                        mbExportNotesPages;
      81             :     bool                        mbTransitionEffects;
      82             :     bool                        mbUseLosslessCompression;
      83             :     bool                        mbReduceImageResolution;
      84             :     bool                        mbExportFormFields;
      85             :     bool                        mbExportBookmarks;
      86             :     bool                        mbExportHiddenSlides;
      87             :     bool                        mbExportNDests; //i56629
      88             :     sal_Int32                       mnFormsFormat;
      89             :     sal_Int32                       mnPage;
      90             :     com::sun::star::lang::Locale    maDocLocale;
      91             : 
      92             :     PageSyncData*               mpPageSyncData;
      93             :     GlobalSyncData*             mpGlobalSyncData;
      94             : 
      95             :     std::vector< PDFExtOutDevBookmarkEntry > maBookmarks;
      96             : 
      97             : public :
      98             : 
      99             :     TYPEINFO_OVERRIDE();
     100             :     PDFExtOutDevData( const OutputDevice& rOutDev );
     101             :     virtual ~PDFExtOutDevData();
     102             : 
     103             :     bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction );
     104             :     void ResetSyncData();
     105             : 
     106             :     void PlayGlobalActions( PDFWriter& rWriter );
     107             : 
     108             : 
     109             : 
     110           0 :     bool    GetIsExportNotes() const { return mbExportNotes;}
     111             :     void        SetIsExportNotes( const bool bExportNotes );
     112             : 
     113           0 :     bool    GetIsExportNotesPages() const { return mbExportNotesPages;}
     114             :     void        SetIsExportNotesPages( const bool bExportNotesPages );
     115             : 
     116           0 :     bool    GetIsExportTaggedPDF() const { return mbTaggedPDF;}
     117             :     void        SetIsExportTaggedPDF( const bool bTaggedPDF );
     118             : 
     119           0 :     bool    GetIsExportTransitionEffects() const { return mbTransitionEffects;}
     120             :     void        SetIsExportTransitionEffects( const bool bTransitionalEffects );
     121             : 
     122           0 :     bool    GetIsExportFormFields() const { return mbExportFormFields;}
     123             :     void        SetIsExportFormFields( const bool bExportFormFields );
     124             : 
     125             :     void        SetFormsFormat( const sal_Int32 nFormsFormat );
     126             : 
     127           0 :     bool    GetIsExportBookmarks() const { return mbExportBookmarks;}
     128             :     void        SetIsExportBookmarks( const bool bExportBookmarks );
     129             : 
     130           0 :     bool    GetIsExportHiddenSlides() const { return mbExportHiddenSlides;}
     131             :     void        SetIsExportHiddenSlides( const bool bExportHiddenSlides );
     132             : 
     133           0 :     bool    GetIsExportNamedDestinations() const { return mbExportNDests;} //i56629
     134             :     void        SetIsExportNamedDestinations( const bool bExportNDests ); //i56629
     135             : 
     136             :     // PageNumber, Compression is being set by the PDFExport
     137           0 :     sal_Int32   GetCurrentPageNumber() const { return mnPage;}
     138             :     void        SetCurrentPageNumber( const sal_Int32 nPage );
     139             : 
     140           0 :     bool    GetIsLosslessCompression() const { return mbUseLosslessCompression;}
     141             :     void        SetIsLosslessCompression( const bool bLosslessCompression );
     142             : 
     143           0 :     bool    GetIsReduceImageResolution() const { return mbReduceImageResolution;}
     144             :     void        SetIsReduceImageResolution( const bool bReduceImageResolution );
     145             : 
     146           0 :     const com::sun::star::lang::Locale& GetDocumentLocale() const { return maDocLocale;}
     147             :     void        SetDocumentLocale( const com::sun::star::lang::Locale& rLoc );
     148             : 
     149           0 :     std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks() { return maBookmarks;}
     150             : 
     151             :     /** Start a new group of render output
     152             : 
     153             :         Use this method to group render output.
     154             :      */
     155             :     void        BeginGroup();
     156             : 
     157             :     /** End render output
     158             : 
     159             :         This method ends grouped render output, that can be
     160             :         represented by a GfxLink. This is typically used for
     161             :         external graphic files, such as JPEGs, EPS files etc.
     162             :         The BeginGroup/EndGroup calls must exactly enclose the
     163             :         relevant OutputDevice calls issued to render the
     164             :         graphic the normal way.
     165             : 
     166             :         @param rGraphic
     167             :         The link to the original graphic
     168             : 
     169             :         @param nTransparency
     170             :         Eight bit transparency value, with 0 denoting full opacity,
     171             :         and 255 full transparency.
     172             : 
     173             :         @param rOutputRect
     174             :         The output rectangle of the graphic.
     175             : 
     176             :         @param rVisibleOutputRect
     177             :         The visible part of the output. This might be less than
     178             :         rOutputRect, e.g. for cropped graphics.
     179             :      */
     180             :     void        EndGroup( const Graphic&    rGraphic,
     181             :                           sal_uInt8             nTransparency,
     182             :                           const Rectangle&  rOutputRect,
     183             :                           const Rectangle&  rVisibleOutputRect );
     184             : //--->i56629
     185             :     /** Create a new named destination to be used in a link to this document from another PDF document
     186             :  (see PDF spec 1.4, 8.2.1)
     187             : 
     188             :     @param sDestName
     189             :     the name this destination will be addressed with from others PDF document
     190             : 
     191             :     @param rRect
     192             :     target rectangle on page to be displayed if dest is jumped to
     193             : 
     194             :     @param nPageNr
     195             :     number of page the dest is on (as returned by NewPage)
     196             :     or -1 in which case the current page is used
     197             : 
     198             :     @param eType
     199             :     what dest type to use
     200             : 
     201             :     @returns
     202             :     the destination id (to be used in SetLinkDest) or
     203             :     -1 if page id does not exist
     204             :     */
     205             :     sal_Int32 CreateNamedDest( const OUString& sDestName,  const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
     206             : 
     207             :     /** registers a destination for which a destinatin ID needs to be known immediately, instead of later on setting it via
     208             :         SetLinkDest.
     209             : 
     210             :         This is used in contexts where a destination is referenced by means other than a link.
     211             : 
     212             :         Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about
     213             :         the destination.
     214             : 
     215             :         @return
     216             :             the unique Id of the destination
     217             :     */
     218             :     sal_Int32   RegisterDest();
     219             : 
     220             :     /** provides detailed information about a destination range which previously has been registered using RegisterDest.
     221             :     */
     222             :     void        DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
     223             : 
     224             : //<---i56629
     225             : 
     226             :     /** Create a new destination to be used in a link
     227             : 
     228             :     @param rRect
     229             :     target rectangle on page to be displayed if dest is jumped to
     230             : 
     231             :     @param nPageNr
     232             :     number of page the dest is on (as returned by NewPage)
     233             :     or -1 in which case the current page is used
     234             : 
     235             :     @param eType
     236             :     what dest type to use
     237             : 
     238             :     @returns
     239             :     the destination id (to be used in SetLinkDest) or
     240             :     -1 if page id does not exist
     241             :     */
     242             :     sal_Int32 CreateDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
     243             :     /** Create a new link on a page
     244             : 
     245             :     @param rRect
     246             :     active rectangle of the link (that is the area that has to be
     247             :     hit to activate the link)
     248             : 
     249             :     @param nPageNr
     250             :     number of page the link is on (as returned by NewPage)
     251             :     or -1 in which case the current page is used
     252             : 
     253             :     @returns
     254             :     the link id (to be used in SetLinkDest, SetLinkURL) or
     255             :     -1 if page id does not exist
     256             :     */
     257             :     sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 );
     258             :     /** Set the destination for a link
     259             :         <p>will change a URL type link to a dest link if necessary</p>
     260             : 
     261             :         @param nLinkId
     262             :         the link to be changed
     263             : 
     264             :         @param nDestId
     265             :         the dest the link shall point to
     266             :         @returns
     267             :         0 for success
     268             :         -1 in case the link id does not exist
     269             :         -2 in case the dest id does not exist
     270             :     */
     271             :     sal_Int32 SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
     272             :     /** Set the URL for a link
     273             :         <p>will change a dest type link to an URL type link if necessary</p>
     274             :         @param nLinkId
     275             :         the link to be changed
     276             : 
     277             :         @param rURL
     278             :         the URL the link shall point to.
     279             :         there will be no error checking or any kind of
     280             :         conversion done to this parameter execept this:
     281             :         it will be output as 7bit Ascii. The URL
     282             :         will appear literally in the PDF file produced
     283             : 
     284             :         @returns
     285             :         0 for success
     286             :         -1 in case the link id does not exist
     287             :     */
     288             :     sal_Int32 SetLinkURL( sal_Int32 nLinkId, const OUString& rURL );
     289             :     /** Create a new outline item
     290             : 
     291             :         @param nParent
     292             :         declares the parent of the new item in the outline hierarchy.
     293             :         An invalid value will result in a new toplevel item.
     294             : 
     295             :         @param rText
     296             :         sets the title text of the item
     297             : 
     298             :         @param nDestID
     299             :         declares which Dest (created with CreateDest) the outline item
     300             :         will point to
     301             : 
     302             :         @returns
     303             :         the outline item id of the new item
     304             :     */
     305             :     sal_Int32 CreateOutlineItem( sal_Int32 nParent = 0, const OUString& rText = OUString(), sal_Int32 nDestID = -1 );
     306             : 
     307             :     /** Create a new note on a page
     308             : 
     309             :     @param rRect
     310             :     active rectangle of the note (that is the area that has to be
     311             :     hit to popup the annotation)
     312             : 
     313             :     @param rNote
     314             :     specifies the contents of the note
     315             : 
     316             :     @param nPageNr
     317             :     number of page the note is on (as returned by NewPage)
     318             :     or -1 in which case the current page is used
     319             :     */
     320             :     void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
     321             : 
     322             :     /** begin a new logical structure element
     323             : 
     324             :     BeginStructureElement/EndStructureElement calls build the logical structure
     325             :     of the PDF - the basis for tagged PDF. Structural elements are implemented
     326             :     using marked content tags. Each structural element can contain sub elements
     327             :     (e.g. a section can contain a heading and a paragraph). The structure hierarchy
     328             :     is build automatically from the Begin/EndStructureElement calls.
     329             : 
     330             :     A structural element need not be contained on one page; e.g. paragraphs often
     331             :     run from one page to the next. In this case the corresponding EndStructureElement
     332             :     must be called while drawing the next page.
     333             : 
     334             :     BeginStructureElement and EndStructureElement must be called only after
     335             :     PDFWriter::NewPage has been called and before
     336             :     PDFWriter::Emit gets called. The current page
     337             :     number is an implicit context parameter for Begin/EndStructureElement.
     338             : 
     339             :     For pagination artifacts that are not part of the logical structure
     340             :     of the document (like header, footer or page number) the special
     341             :     StructElement NonStructElement exists. To place content
     342             :     outside of the struture tree simply call
     343             :     BeginStructureElement( NonStructElement ) then draw your
     344             :     content and then call EndStructureElement(). Any children
     345             :     of a NonStructElement will not be part of the structure as well.
     346             : 
     347             :     @param eType
     348             :     denotes what kind of element to begin (e.g. a heading or paragraph)
     349             : 
     350             :     @param rAlias
     351             :     the specified alias will be used as structure tag. Also an entry in the PDF's
     352             :     role map will be created mapping alias to regular structure type.
     353             : 
     354             :     @returns
     355             :     the id of the newly created structural element
     356             :      */
     357             :      sal_Int32 BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias = OUString() );
     358             :     /** end a logical structure element
     359             : 
     360             :     @see BeginStructureElement
     361             :      */
     362             :     void EndStructureElement();
     363             :     /** set the current structure element
     364             : 
     365             :     <p>
     366             :     For different purposes it may be useful to paint a structure element's
     367             :     content discontinously. In that case an already existing structure element
     368             :     can be appended to by using SetCurrentStructureElement. The
     369             :     refenrenced structure element becomes the current structure element with
     370             :     all consequences: all following structure elements are appended as children
     371             :     of the current element.
     372             :     </p>
     373             : 
     374             :     @param nElement
     375             :     the id of the new current structure element
     376             : 
     377             :     @returns
     378             :     True if the current structure element could be set successfully
     379             :     False if the current structure element could not be changed
     380             :     (e.g. if the passed element id is invalid)
     381             :      */
     382             :     bool SetCurrentStructureElement( sal_Int32 nElement );
     383             :     /** get the current structure element id
     384             : 
     385             :     @returns
     386             :     the id of the current structure element
     387             :     */
     388             :     sal_Int32 GetCurrentStructureElement();
     389             : 
     390             :     /** set a structure attribute on the current structural element
     391             : 
     392             :     SetStructureAttribute sets an attribute of the current structural element to a
     393             :     new value. A consistency check is performed before actually setting the value;
     394             :     if the check fails, the function returns False and the attribute remains
     395             :     unchanged.
     396             : 
     397             :     @param eAttr
     398             :     denotes what attribute to change
     399             : 
     400             :     @param eVal
     401             :     the value to set the attribute to
     402             : 
     403             :     @returns
     404             :     True if the value was valid and the change has been performed,
     405             :     False if the attribute or value was invalid; attribute remains unchanged
     406             :      */
     407             :     bool SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal );
     408             :     /** set a structure attribute on the current structural element
     409             : 
     410             :     SetStructureAttributeNumerical sets an attribute of the current structural element
     411             :     to a new numerical value. A consistency check is performed before actually setting
     412             :     the value; if the check fails, the function returns False and the attribute
     413             :     remains unchanged.
     414             : 
     415             :     @param eAttr
     416             :     denotes what attribute to change
     417             : 
     418             :     @param nValue
     419             :     the value to set the attribute to
     420             : 
     421             :     @returns
     422             :     True if the value was valid and the change has been performed,
     423             :     False if the attribute or value was invalid; attribute remains unchanged
     424             :      */
     425             :     bool SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
     426             :     /** set the bounding box of a structural element
     427             : 
     428             :     SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
     429             :     attribute can only be applied to Table, Figure,
     430             :     Form and Formula elements, a call of this function
     431             :     for other element types will be ignored and the BBox attribute not be set.
     432             : 
     433             :     @param rRect
     434             :     the new bounding box for the structural element
     435             :      */
     436             :     void SetStructureBoundingBox( const Rectangle& rRect );
     437             : 
     438             :     /** set the ActualText attribute of a structural element
     439             : 
     440             :     ActualText contains the Unicode text without layout artifacts that is shown by
     441             :     a structural element. For example if a line is ended prematurely with a break in
     442             :     a word and continued on the next line (e.g. "happen-<newline>stance") the
     443             :     corresponding ActualText would contain the unbroken line (e.g. "happenstance").
     444             : 
     445             :     @param rText
     446             :     contains the complete logical text the structural element displays.
     447             :      */
     448             :     void SetActualText( const OUString& rText );
     449             : 
     450             :     /** set the Alt attribute of a strutural element
     451             : 
     452             :     Alt is s replacement text describing the contents of a structural element. This
     453             :     is mainly used by accessibility applications; e.g. a screen reader would read
     454             :     the Alt replacement text for an image to a visually impaired user.
     455             : 
     456             :     @param rText
     457             :     contains the replacement text for the structural element
     458             :     */
     459             :     void SetAlternateText( const OUString& rText );
     460             : 
     461             :     /** Sets the transitional effect to be applied when the current page gets shown.
     462             : 
     463             :     @param eType
     464             :     the kind of effect to be used; use Regular to disable transitional effects
     465             :     for this page
     466             : 
     467             :     @param nMilliSec
     468             :     the duration of the transitional effect in milliseconds;
     469             :     set 0 to disable transitional effects
     470             : 
     471             :     @param nPageNr
     472             :     the page number to apply the effect to; -1 denotes the current page
     473             :     */
     474             :     void SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 );
     475             : 
     476             :     /** create a new form control
     477             : 
     478             :     This function creates a new form control in the PDF and sets its various
     479             :     properties. Do not pass an actual AnyWidget as rControlType
     480             :     will be cast to the type described by the type member.
     481             : 
     482             :     @param rControlType
     483             :     a descendant of AnyWidget determing the control's properties
     484             : 
     485             :     @param nPageNr
     486             :     the page number to apply the effect to; -1 denotes the current page
     487             :      */
     488             :     void    CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 nPageNr = -1 );
     489             : };
     490             : 
     491             : }
     492             : 
     493             : #endif
     494             : 
     495             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11