diff options
-rw-r--r-- | toolkit/inc/toolkit/helper/formpdfexport.hxx | 14 | ||||
-rw-r--r-- | toolkit/source/helper/formpdfexport.cxx | 58 | ||||
-rw-r--r-- | vcl/inc/vcl/pdfextoutdevdata.hxx | 34 | ||||
-rw-r--r-- | vcl/inc/vcl/pdfwriter.hxx | 23 | ||||
-rw-r--r-- | vcl/source/gdi/pdfextoutdevdata.cxx | 53 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 4 |
8 files changed, 151 insertions, 46 deletions
diff --git a/toolkit/inc/toolkit/helper/formpdfexport.hxx b/toolkit/inc/toolkit/helper/formpdfexport.hxx index 502f25520145..cafcb5d00d38 100644 --- a/toolkit/inc/toolkit/helper/formpdfexport.hxx +++ b/toolkit/inc/toolkit/helper/formpdfexport.hxx @@ -28,22 +28,21 @@ #ifndef _TOOLKIT_HELPER_FORM_FORMPDFEXPORT_HXX #define _TOOLKIT_HELPER_FORM_FORMPDFEXPORT_HXX -#ifndef TOOLKIT_DLLAPI_H #include <toolkit/dllapi.h> -#endif /** === begin UNO includes === **/ -#ifndef _COM_SUN_STAR_AWT_XCONTROL_HPP_ #include <com/sun/star/awt/XControl.hpp> -#endif /** === end UNO includes === **/ -#ifndef _VCL_PDFWRITER_HXX #include <vcl/pdfwriter.hxx> -#endif #include <memory> +namespace vcl +{ + class PDFExtOutDevData; +} + //........................................................................ namespace toolkitform { @@ -53,7 +52,8 @@ namespace toolkitform */ void TOOLKIT_DLLPUBLIC describePDFControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl, - ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget >& _rpDescriptor + ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget >& _rpDescriptor, + ::vcl::PDFExtOutDevData& i_pdfExportData ) SAL_THROW(()); //........................................................................ diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index bff2d6008d10..1bde6f66a3c0 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -28,58 +28,27 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#ifndef _TOOLKIT_HELPER_FORM_FORMPDFEXPORT_HXX #include <toolkit/helper/formpdfexport.hxx> -#endif /** === begin UNO includes === **/ -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ #include <com/sun/star/container/XIndexAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ #include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ #include <com/sun/star/form/XForm.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ #include <com/sun/star/form/FormComponentType.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ #include <com/sun/star/awt/TextAlign.hpp> -#endif -#ifndef _COM_SUN_STAR_STYLE_VERTICALALIGNMENT_HPP_ #include <com/sun/star/style/VerticalAlignment.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMBUTTONTYPE_HPP_ #include <com/sun/star/form/FormButtonType.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_SUBMITMETHOD_HPP_ #include <com/sun/star/form/FormSubmitMethod.hpp> -#endif /** === end UNO includes === **/ -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/helper/vclunohelper.hxx> -#endif -#ifndef _VCL_PDFEXTOUTDEVDATA_HXX +#include <tools/diagnose_ex.h> #include <vcl/pdfextoutdevdata.hxx> -#endif -#ifndef _SV_OUTDEV_HXX #include <vcl/outdev.hxx> -#endif #include <functional> #include <algorithm> @@ -315,7 +284,8 @@ namespace toolkitform //-------------------------------------------------------------------- /** creates a PDF compatible control descriptor for the given control */ - void TOOLKIT_DLLPUBLIC describePDFControl( const Reference< XControl >& _rxControl, ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget >& _rpDescriptor ) SAL_THROW(()) + void TOOLKIT_DLLPUBLIC describePDFControl( const Reference< XControl >& _rxControl, + ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget >& _rpDescriptor, ::vcl::PDFExtOutDevData& i_pdfExportData ) SAL_THROW(()) { _rpDescriptor.reset( NULL ); OSL_ENSURE( _rxControl.is(), "describePDFControl: invalid (NULL) control!" ); @@ -529,7 +499,25 @@ namespace toolkitform } else if ( eButtonType == FormButtonType_URL ) { - OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_TARGET_URL ) >>= pButtonWidget->URL); + ::rtl::OUString sURL; + OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_TARGET_URL ) >>= sURL ); + const bool bDocumentLocalTarget = ( sURL.getLength() > 0 ) && ( sURL.getStr()[0] == '#' ); + if ( bDocumentLocalTarget ) + { + const ::rtl::OUString sDestinationName( sURL.copy(1) ); + // Register the destination for for future handling ... + pButtonWidget->Dest = i_pdfExportData.RegisterDest(); + + // and put it into the bookmarks, to ensure the future handling really happens + ::std::vector< ::vcl::PDFExtOutDevBookmarkEntry >& rBookmarks( i_pdfExportData.GetBookmarks() ); + ::vcl::PDFExtOutDevBookmarkEntry aBookmark; + aBookmark.nDestId = pButtonWidget->Dest; + aBookmark.aBookmark = sURL; + rBookmarks.push_back( aBookmark ); + } + else + pButtonWidget->URL = sURL; + pButtonWidget->Submit = false; } @@ -630,7 +618,7 @@ namespace toolkitform } catch( const Exception& ) { - OSL_ENSURE( sal_False, "describePDFControl: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } diff --git a/vcl/inc/vcl/pdfextoutdevdata.hxx b/vcl/inc/vcl/pdfextoutdevdata.hxx index 5dda4b0f79fa..1aa9ebcc745e 100644 --- a/vcl/inc/vcl/pdfextoutdevdata.hxx +++ b/vcl/inc/vcl/pdfextoutdevdata.hxx @@ -52,8 +52,24 @@ namespace vcl */ struct PDFExtOutDevBookmarkEntry { + /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link. + */ sal_Int32 nLinkId; + + /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination. + */ + sal_Int32 nDestId; + + /** link target name, respectively destination name + */ rtl::OUString aBookmark; + + PDFExtOutDevBookmarkEntry() + :nLinkId( -1 ) + ,nDestId( -1 ) + ,aBookmark() + { + } }; /* @@ -195,6 +211,24 @@ public : -1 if page id does not exist */ sal_Int32 CreateNamedDest( const String& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); + + /** registers a destination for which a destinatin ID needs to be known immediately, instead of later on setting it via + SetLinkDest. + + This is used in contexts where a destination is referenced by means other than a link. + + Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about + the destination. + + @return + the unique Id of the destination + */ + sal_Int32 RegisterDest(); + + /** provides detailed information about a destination range which previously has been registered using RegisterDest. + */ + void DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); + //<---i56629 /** Create a new destination to be used in a link diff --git a/vcl/inc/vcl/pdfwriter.hxx b/vcl/inc/vcl/pdfwriter.hxx index 27dbbfc80c72..af10cef382bc 100644 --- a/vcl/inc/vcl/pdfwriter.hxx +++ b/vcl/inc/vcl/pdfwriter.hxx @@ -923,6 +923,29 @@ The following structure describes the permissions used in PDF security -1 if page id does not exist */ sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 ); + + /** creates a destination which is not intended to be referred to by a link, but by a public destination Id. + + Form widgets, for instance, might refer to a destination, without ever actually creating a source link to + point to this destination. In such cases, a public destination Id will be assigned to the form widget, + and later on, the concrete destination data for this public Id will be registered using RegisterDestReference. + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the internal destination Id. + */ + sal_Int32 RegisterDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, DestAreaType eType = XYZ ); + + /** Set the destination for a link <p>will change a URL type link to a dest link if necessary</p> diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 046bc4a8951d..815a3b62c027 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -31,22 +31,25 @@ #include "vcl/graph.hxx" #include "vcl/outdev.hxx" #include "vcl/gfxlink.hxx" +#include "vcl/dllapi.h" #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolygontools.hxx" #include <boost/shared_ptr.hpp> #include <set> +#include <map> namespace vcl { -struct PDFExtOutDevDataSync +struct SAL_DLLPRIVATE PDFExtOutDevDataSync { enum Action{ CreateNamedDest, CreateDest, CreateLink, SetLinkDest, SetLinkURL, + RegisterDest, CreateOutlineItem, SetOutlineItemParent, SetOutlineItemText, @@ -73,7 +76,15 @@ struct PDFExtOutDevDataSync Action eAct; }; -struct GlobalSyncData +struct SAL_DLLPRIVATE PDFLinkDestination +{ + Rectangle mRect; + MapMode mMapMode; + sal_Int32 mPageNr; + PDFWriter::DestAreaType mAreaType; +}; + +struct SAL_DLLPRIVATE GlobalSyncData { std::deque< PDFExtOutDevDataSync::Action > mActions; std::deque< MapMode > mParaMapModes; @@ -84,6 +95,7 @@ struct GlobalSyncData std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes; std::deque< PDFNote > mParaPDFNotes; std::deque< PDFWriter::PageTransition > mParaPageTransitions; + ::std::map< sal_Int32, PDFLinkDestination > mFutureDestinations; sal_Int32 GetMappedId(); sal_Int32 GetMappedStructId( sal_Int32 ); @@ -145,7 +157,7 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter ) { switch( *aIter ) { - case PDFExtOutDevDataSync::CreateNamedDest : //i56629 + case PDFExtOutDevDataSync::CreateNamedDest : //i56629 { rWriter.Push( PUSH_MAPMODE ); rWriter.SetMapMode( mParaMapModes.front() ); @@ -197,6 +209,21 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter ) mParaOUStrings.pop_front(); } break; + case PDFExtOutDevDataSync::RegisterDest : + { + const sal_Int32 nDestId = mParaInts.front(); + mParaInts.pop_front(); + OSL_ENSURE( mFutureDestinations.find( nDestId ) != mFutureDestinations.end(), + "GlobalSyncData::PlayGlobalActions: DescribeRegisteredRequest has not been called for that destination!" ); + + PDFLinkDestination& rDest = mFutureDestinations[ nDestId ]; + + rWriter.Push( PUSH_MAPMODE ); + rWriter.SetMapMode( rDest.mMapMode ); + mParaIds.push_back( rWriter.RegisterDestReference( nDestId, rDest.mRect, rDest.mPageNr, rDest.mAreaType ) ); + rWriter.Pop(); + } + break; case PDFExtOutDevDataSync::CreateOutlineItem : { sal_Int32 nParent = GetMappedId(); @@ -459,6 +486,7 @@ sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIM case PDFExtOutDevDataSync::CreateLink: case PDFExtOutDevDataSync::SetLinkDest: case PDFExtOutDevDataSync::SetLinkURL: + case PDFExtOutDevDataSync::RegisterDest: case PDFExtOutDevDataSync::CreateOutlineItem: case PDFExtOutDevDataSync::SetOutlineItemParent: case PDFExtOutDevDataSync::SetOutlineItemText: @@ -617,9 +645,28 @@ sal_Int32 PDFExtOutDevData::CreateNamedDest(const String& sDestName, const Rect mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() ); mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr ); mpGlobalSyncData->mParaDestAreaTypes.push_back( eType ); + return mpGlobalSyncData->mCurId++; } //<---i56629 +sal_Int32 PDFExtOutDevData::RegisterDest() +{ + const sal_Int32 nLinkDestID = mpGlobalSyncData->mCurId++; + mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::RegisterDest ); + mpGlobalSyncData->mParaInts.push_back( nLinkDestID ); + + return nLinkDestID; +} +void PDFExtOutDevData::DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) +{ + OSL_PRECOND( nDestId != -1, "PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" ); + PDFLinkDestination aLinkDestination; + aLinkDestination.mRect = rRect; + aLinkDestination.mMapMode = mrOutDev.GetMapMode(); + aLinkDestination.mPageNr = nPageNr == -1 ? mnPage : nPageNr; + aLinkDestination.mAreaType = eType; + mpGlobalSyncData->mFutureDestinations[ nDestId ] = aLinkDestination; +} sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) { mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest ); diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 969bc51b3cac..2b7d66e9837c 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -430,6 +430,10 @@ sal_Int32 PDFWriter::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr ) { return ((PDFWriterImpl*)pImplementation)->createLink( rRect, nPageNr ); } +sal_Int32 PDFWriter::RegisterDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ) +{ + return ((PDFWriterImpl*)pImplementation)->registerDestReference( nDestId, rRect, nPageNr, eType ); +} //--->i56629 sal_Int32 PDFWriter::CreateNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) { diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 5d75c829da8a..add3aebb270d 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5569,7 +5569,7 @@ bool PDFWriterImpl::emitWidgetAnnotations() if(!m_bIsPDF_A1) { OStringBuffer aDest; - if( rWidget.m_nDest != -1 && appendDest( rWidget.m_nDest, aDest ) ) + if( rWidget.m_nDest != -1 && appendDest( m_aDestinationIdTranslation[ rWidget.m_nDest ], aDest ) ) { aLine.append( "/AA<</D<</Type/Action/S/GoTo/D " ); aLine.append( aDest.makeStringAndClear() ); @@ -10747,6 +10747,11 @@ sal_Int32 PDFWriterImpl::createDest( const Rectangle& rRect, sal_Int32 nPageNr, return nRet; } +sal_Int32 PDFWriterImpl::registerDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) +{ + return m_aDestinationIdTranslation[ nDestId ] = createDest( rRect, nPageNr, eType ); +} + sal_Int32 PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) { if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 9457aea5f0c2..d21fca75be4f 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -612,6 +612,9 @@ private: dest id is always the dest's position in this vector */ std::vector<PDFDest> m_aDests; + /** contains destinations accessible via a public Id, instead of being linked to by an ordinary link + */ + ::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation; /* contains all links ever set during PDF creation, link id is always the link's position in this vector */ @@ -1326,6 +1329,7 @@ public: // links sal_Int32 createLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 ); sal_Int32 createDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); + sal_Int32 registerDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); sal_Int32 setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); sal_Int32 setLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL ); void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId ); |