32#include <com/sun/star/io/XOutputStream.hpp>
37#include <boost/property_tree/json_parser/error.hpp>
54 Reference< XOutputStream > xOStm;
55 Sequence< PropertyValue > aFilterData;
56 OUString aFilterOptions;
57 sal_Int32
nLength = rDescriptor.getLength();
58 const PropertyValue* pValue = rDescriptor.getConstArray();
59 bool bIsRedactMode =
false;
61 Reference< task::XStatusIndicator > xStatusIndicator;
62 Reference< task::XInteractionHandler > xIH;
66 if ( pValue[
i ].
Name ==
"OutputStream" )
67 pValue[
i ].Value >>= xOStm;
68 else if ( pValue[
i ].
Name ==
"FilterData" )
69 pValue[
i ].Value >>= aFilterData;
70 else if ( pValue[
i ].
Name ==
"FilterOptions" )
71 pValue[
i ].Value >>= aFilterOptions;
72 else if ( pValue[
i ].
Name ==
"StatusIndicator" )
73 pValue[
i ].Value >>= xStatusIndicator;
74 else if ( pValue[
i].
Name ==
"InteractionHandler" )
75 pValue[
i].Value >>= xIH;
80 if ( pValue[
i].
Name ==
"IsRedactMode")
81 pValue[
i].Value >>= bIsRedactMode;
84 if (!aFilterData.hasElements() && aFilterOptions.startsWith(
"{"))
89 std::vector<PropertyValue>
aData
93 catch (
const boost::property_tree::json_parser::json_parser_error& e)
96 SAL_WARN(
"filter.pdf",
"error parsing FilterOptions: " << e.message());
102 if ( !aFilterData.hasElements() )
105 aCfgItem.
ReadBool(
"UseLosslessCompression",
false );
107 aCfgItem.
ReadBool(
"ReduceImageResolution",
false );
108 aCfgItem.
ReadInt32(
"MaxImageResolution", 300 );
109 aCfgItem.
ReadBool(
"UseTaggedPDF",
false );
110 aCfgItem.
ReadInt32(
"SelectPdfVersion", 0 );
111 aCfgItem.
ReadBool(
"PDFUACompliance",
false);
112 aCfgItem.
ReadBool(
"ExportNotes",
false );
113 aCfgItem.
ReadBool(
"ExportNotesInMargin",
false );
114 aCfgItem.
ReadBool(
"ExportPlaceholders",
false );
115 aCfgItem.
ReadBool(
"ExportNotesPages",
false );
116 aCfgItem.
ReadBool(
"ExportOnlyNotesPages",
false );
117 aCfgItem.
ReadBool(
"UseTransitionEffects",
true );
118 aCfgItem.
ReadBool(
"IsSkipEmptyPages",
false );
119 aCfgItem.
ReadBool(
"ExportFormFields",
true );
121 aCfgItem.
ReadBool(
"HideViewerToolbar",
false );
122 aCfgItem.
ReadBool(
"HideViewerMenubar",
false );
123 aCfgItem.
ReadBool(
"HideViewerWindowControls",
false );
124 aCfgItem.
ReadBool(
"ResizeWindowToInitialPage",
false );
125 aCfgItem.
ReadBool(
"CenterWindow",
false );
126 aCfgItem.
ReadBool(
"OpenInFullScreenMode",
false );
127 aCfgItem.
ReadBool(
"DisplayPDFDocumentTitle",
true );
129 aCfgItem.
ReadInt32(
"Magnification", 0 );
132 aCfgItem.
ReadBool(
"FirstPageOnLeft",
false );
134 aCfgItem.
ReadBool(
"IsAddStream",
false );
141 aCfgItem.
ReadBool(
"ExportLinksRelativeFsys",
false );
142 aCfgItem.
ReadInt32(
"PDFViewSelection", 0 );
143 aCfgItem.
ReadBool(
"ConvertOOoTargetToPDFTarget",
false );
144 aCfgItem.
ReadBool(
"ExportBookmarksToPDFDestination",
false );
146 aCfgItem.
ReadBool(
"ExportBookmarks",
true );
147 aCfgItem.
ReadBool(
"ExportHiddenSlides",
false );
148 aCfgItem.
ReadBool(
"SinglePageSheets",
false );
149 aCfgItem.
ReadInt32(
"OpenBookmarkLevels", -1 );
151 aCfgItem.
ReadBool(
"IsRedactMode",
false);
161 for (PropertyValue& rProp : asNonConstRange(aFilterData))
163 if (rProp.Name ==
"IsRedactMode")
165 rProp.Value <<= bIsRedactMode;
173 sal_Int32 nNewSize = aFilterData.getLength() + 1;
174 aFilterData.realloc( nNewSize );
175 auto pFilterData = aFilterData.getArray();
176 pFilterData[nNewSize - 1].Name =
"IsRedactMode";
177 pFilterData[nNewSize - 1].Value <<= bIsRedactMode;
187 bRet = aExport.
Export( aTempFile.
GetURL(), aFilterData );
197 aOStm.WriteStream( *pIStm );
198 bRet = ( aOStm.Tell() && ( aOStm.GetError() ==
ERRCODE_NONE ) );
208class FocusWindowWaitCursor
215 FocusWindowWaitCursor() :
220 m_pFocusWindow->AddEventListener(
LINK(
this, FocusWindowWaitCursor, DestroyedLink ) );
221 m_pFocusWindow->EnterWait();
225 ~FocusWindowWaitCursor()
229 m_pFocusWindow->LeaveWait();
230 m_pFocusWindow->RemoveEventListener(
LINK(
this, FocusWindowWaitCursor, DestroyedLink ) );
241 if( rEvent.GetId() == VclEventId::ObjectDying )
242 m_pFocusWindow =
nullptr;
248 FocusWindowWaitCursor aCur;
278 return "com.sun.star.comp.PDF.PDFFilter";
290 return {
"com.sun.star.document.PDFFilter" };
294extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
296 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
298 return cppu::acquire(
new PDFFilter(context));
bool ReadBool(const OUString &rKey, bool bDefault)
sal_Int32 ReadInt32(const OUString &rKey, sal_Int32 nDefault)
const css::uno::Sequence< css::beans::PropertyValue > & GetFilterData() const
bool Export(const OUString &rFile, const css::uno::Sequence< css::beans::PropertyValue > &rFilterData)
virtual ~PDFFilter() override
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override
bool implExport(const Sequence< PropertyValue > &rDescriptor)
virtual void SAL_CALL initialize(const Sequence< Any > &aArguments) override
Reference< XComponent > mxSrcDoc
virtual void SAL_CALL setSourceDocument(const Reference< XComponent > &xDoc) override
virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue > &rDescriptor) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL cancel() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
PDFFilter(const Reference< XComponentContext > &rxContext)
Reference< XComponentContext > mxContext
void SetCacheGlyphsWhenDoingFallbackFonts(bool bOK)
static SalLayoutGlyphsCache * self()
void EnableKillingFile(bool bEnable=true)
OUString const & GetURL() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral aData
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::vector< css::beans::PropertyValue > JsonToPropertyValues(const OString &rJson)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * filter_PDFFilter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
IMPL_LINK(FocusWindowWaitCursor, DestroyedLink, VclWindowEvent &, rEvent, void)