diff options
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 25 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.hxx | 2 | ||||
-rw-r--r-- | filter/source/pdf/pdffilter.cxx | 36 | ||||
-rw-r--r-- | include/sfx2/sfxsids.hrc | 4 | ||||
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 14 | ||||
-rw-r--r-- | sd/uiconfig/sdraw/toolbar/redactionbar.xml | 2 | ||||
-rw-r--r-- | sfx2/sdi/sfx.sdi | 3 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 12 |
9 files changed, 95 insertions, 4 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 31adb9788e1d..9013c63e2973 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -114,6 +114,8 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc, mnProgressValue ( 0 ), mbRemoveTransparencies ( false ), + mbIsRedactMode ( false ), + mbHideViewerToolbar ( false ), mbHideViewerMenubar ( false ), mbHideViewerWindowControls ( false ), @@ -225,7 +227,27 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, if( aMtf.GetActionSize() && ( !mbSkipEmptyPages || aPageSize.Width || aPageSize.Height ) ) + { + // We convert the whole metafile into a bitmap to get rid of the + // text covered by redaction shapes + if (mbIsRedactMode) + { + try + { + Graphic aGraph(aMtf); + BitmapEx bmp = aGraph.GetBitmapEx(); + Graphic bgraph(bmp); + aMtf = bgraph.GetGDIMetaFile(); + } + catch(const Exception& e) + { + SAL_WARN("filter.pdf", "Something went wrong while converting metafile to bitmap. Exception: " + << e.Message); + } + } + bRet = ImplExportPage(rPDFWriter, rPDFExtOutDevData, aMtf) || bRet; + } pOut->Pop(); @@ -555,6 +577,9 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData[ nData ].Value >>= mbExportPlaceholders; else if ( rFilterData[ nData ].Name == "UseReferenceXObject" ) rFilterData[ nData ].Value >>= mbUseReferenceXObject; + // Redaction & bitmap related stuff + else if ( rFilterData[ nData ].Name == "IsRedactMode" ) + rFilterData[ nData ].Value >>= mbIsRedactMode; } aContext.URL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri); diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx index 9d302900cdee..da7ca044ea60 100644 --- a/filter/source/pdf/pdfexport.hxx +++ b/filter/source/pdf/pdfexport.hxx @@ -65,6 +65,8 @@ private: sal_Int32 mnProgressValue; bool mbRemoveTransparencies; + bool mbIsRedactMode; + OUString msWatermark; OUString msTiledWatermark; diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index 2a32408bb0c3..71b874dbb4e6 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -44,11 +44,12 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) Sequence< PropertyValue > aFilterData; sal_Int32 nLength = rDescriptor.getLength(); const PropertyValue* pValue = rDescriptor.getConstArray(); + bool bIsRedactMode = false; bool bRet = false; Reference< task::XStatusIndicator > xStatusIndicator; Reference< task::XInteractionHandler > xIH; - for ( sal_Int32 i = 0 ; ( i < nLength ) && !xOStm.is(); ++i) + for (sal_Int32 i = 0 ; ( i < nLength ) && !xOStm.is(); ++i) { if ( pValue[ i ].Name == "OutputStream" ) pValue[ i ].Value >>= xOStm; @@ -60,6 +61,12 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) pValue[i].Value >>= xIH; } + for (sal_Int32 i = 0 ; i < nLength; ++i) + { + if ( pValue[i].Name == "IsRedactMode") + pValue[i].Value >>= bIsRedactMode; + } + /* we don't get FilterData if we are exporting directly to pdf, but we have to use the last user settings (especially for the CompressMode) */ if ( !aFilterData.getLength() ) @@ -104,9 +111,36 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) aCfgItem.ReadBool( "ExportBookmarks", true ); aCfgItem.ReadBool( "ExportHiddenSlides", false ); aCfgItem.ReadInt32( "OpenBookmarkLevels", -1 ); + + aCfgItem.ReadBool( "IsRedactMode", false); + aFilterData = aCfgItem.GetFilterData(); } + + if (bIsRedactMode) + { + bool bFound = false; + + for (int i = 0; i < aFilterData.getLength(); ++i) + { + if (aFilterData[i].Name == "IsRedactMode") + { + aFilterData[i].Value <<= bIsRedactMode; + bFound = true; + break; + } + } + + if (!bFound) + { + sal_Int32 nNewSize = aFilterData.getLength() + 1; + aFilterData.realloc( nNewSize ); + aFilterData[nNewSize - 1].Name = "IsRedactMode"; + aFilterData[nNewSize - 1].Value <<= bIsRedactMode; + } + } + if( mxSrcDoc.is() && xOStm.is() ) { PDFExport aExport( mxSrcDoc, xStatusIndicator, xIH, mxContext ); diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 4dc9db677a8b..68e2055db36c 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -246,7 +246,9 @@ #define SID_TOOLBAR_MODE (SID_SFX_START + 1728) #define SID_NO_FILE_SYNC (SID_SFX_START + 1729) -// SID_SFX_free_START (SID_SFX_START + 1731) +#define SID_IS_REDACT_MODE (SID_SFX_START + 1731) + +// SID_SFX_free_START (SID_SFX_START + 1732) // SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 45ed074966df..7f92b83df9e9 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -4908,6 +4908,20 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:ExportDirectToPDF?IsRedactMode:bool=true" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Sanitized PDF</value> + </prop> + <prop oor:name="ContextLabel" oor:type="xs:string"> + <value xml:lang="en-US">Export Directly to PDF as Bitmap</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Export Directly to PDF as Bitmap</value> + </prop> + <prop oor:name="Properties" oor:type="xs:int"> + <value>1</value> + </prop> + </node> <node oor:name=".uno:ExportToEPUB" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">EPUB</value> diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml index 1a5b45b31634..a0fb06709377 100644 --- a/sd/uiconfig/sdraw/toolbar/redactionbar.xml +++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml @@ -21,5 +21,5 @@ <toolbar:toolbaritem xlink:href=".uno:Rect?FillTransparence:short=50&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true"/> <toolbar:toolbaritem xlink:href=".uno:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true"/> <toolbar:toolbarseparator/> - <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/> + <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF?IsRedactMode:bool=true"/> </toolbar:toolbar> diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 240cb0be10f0..47586b60e464 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4727,7 +4727,8 @@ SfxVoidItem ExportToPDF SID_EXPORTDOCASPDF ] SfxVoidItem ExportDirectToPDF SID_DIRECTEXPORTDOCASPDF -(SfxStringItem URL SID_FILE_NAME, SfxStringItem FilterName SID_FILTER_NAME) +(SfxStringItem URL SID_FILE_NAME, SfxStringItem FilterName SID_FILTER_NAME, + SfxBoolItem IsRedactMode SID_IS_REDACT_MODE) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index bed21cc2b91b..16dc5ed207c6 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -106,6 +106,7 @@ SfxFormalArgument const aFormalArgs[] = { { reinterpret_cast<SfxType*>(&aSfxInt16Item_Impl), "Version", SID_VERSION }, { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM }, { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoFileSync", SID_NO_FILE_SYNC }, + { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "IsRedactMode", SID_IS_REDACT_MODE }, }; static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 79b85e480508..c776ff944957 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2380,6 +2380,7 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) bool bHasStream = false; bool bHasBaseURL = false; bool bHasFilterName = false; + bool bIsRedactMode = false; sal_Int32 i; sal_Int32 nEnd = aOldArgs.getLength(); @@ -2398,6 +2399,10 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) bHasFilterName = true; } + // FIXME: Handle this inside TransformItems() + if (pItems->GetItemState(SID_IS_REDACT_MODE) == SfxItemState::SET) + bIsRedactMode = true; + if ( !bHasOutputStream ) { aArgs.realloc ( ++nEnd ); @@ -2427,6 +2432,13 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) aArgs[nEnd-1].Value <<= aFilterName; } + if (bIsRedactMode) + { + aArgs.realloc( ++nEnd ); + aArgs[nEnd-1].Name = "IsRedactMode"; + aArgs[nEnd-1].Value <<= bIsRedactMode; + } + return xFilter->filter( aArgs ); }catch(const uno::Exception&) {} |