как распознать опцию макроса

Автор ASSEI, 6 марта 2017, 22:27

0 Пользователи и 1 гость просматривают эту тему.

ASSEI

sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///C:/Users/Владелец/Desktop/документ.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(2).Name = "FilterData"
args1(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ReduceImageResolution",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ViewPDFAfterExport",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportBookmarks",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportPlaceholders",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportFormFields",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("PDFViewSelection",1,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Watermark",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("PreparedPasswords",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("PreparedPermissionPassword",0,Array(),com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("Selection",1,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignatureLocation",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignatureReason",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignatureContactInfo",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignaturePassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignatureCertificate",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE),_
Array("SignatureTSA",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE))
dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())
end sub
это код который мной записан хотелось бы его модифицировать.

mikekaganski

REM  *****  BASIC  *****
REM Сохранить указанный файл с заданным именем aURL$ и набором параметров oExpFilterOptions
Sub DoExportToPDF(oDoc, aURL$)
Dim oExpOptions
oExpOptions = Array(MkPropVal( "FilterName", "calc_pdf_Export" ),_
MkPropVal( "FilterData",  CheckPDFFilterProperties(oDoc.CurrentSelection.Spreadsheet)))
oDoc.storeToURL( aURL, oExpOptions )
End Sub

REM Набор параметров для экспорта в PDF
REM Подробное описание - http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
Function CheckPDFFilterProperties(selection)
CheckPDFFilterProperties = Array(_
MkPropVal( "UseLosslessCompression", False ),_
MkPropVal( "Quality", 90 ),_
MkPropVal( "ReduceImageResolution", True ),_
MkPropVal( "MaxImageResolution", 150 ),_
MkPropVal( "UseTaggedPDF", False ),_
MkPropVal( "ExportNotes", False ),_
MkPropVal( "ExportBookmarks", False ),_
MkPropVal( "OpenBookmarkLevels", 1 ),_
MkPropVal( "UseTransitionEffects", True ),_
MkPropVal( "IsSkipEmptyPages", True ),_
MkPropVal( "IsAddStream", False ),_
MkPropVal( "EmbedStandardFonts", False ),_
MkPropVal( "FormsType", 0 ),_
MkPropVal( "ExportFormFields", False ),_
MkPropVal( "AllowDuplicateFieldNames", False ),_
MkPropVal( "HideViewerToolbar", True ),_
MkPropVal( "HideViewerMenubar", False ),_
MkPropVal( "HideViewerWindowControls", False ),_
MkPropVal( "ResizeWindowToInitialPage", False ),_
MkPropVal( "CenterWindow", False ),_
MkPropVal( "OpenInFullScreenMode", False ),_
MkPropVal( "DisplayPDFDocumentTitle", True ),_
MkPropVal( "InitialView", 1 ),_
MkPropVal( "Magnification", 3 ),_
MkPropVal( "Zoom", 100 ),_
MkPropVal( "PageLayout", 2 ),_
MkPropVal( "FirstPageOnLeft", True ),_
MkPropVal( "InitialPage", 1 ),_
MkPropVal( "Printing", 2 ),_
MkPropVal( "Changes", 4 ),_
MkPropVal( "EnableCopyingOfContent", True ),_
MkPropVal( "EnableTextAccessForAccessibilityTools", True ),_
MkPropVal( "ExportLinksRelativeFsys", False ),_
MkPropVal( "PDFViewSelection", 0 ),_
MkPropVal( "ConvertOOoTargetToPDFTarget", True ),_
MkPropVal( "ExportBookmarksToPDFDestination", False ),_
MkPropVal( "_OkButtonString",  ),_
MkPropVal( "EncryptFile", False ),_
MkPropVal( "PreparedPasswords",  ),_
MkPropVal( "RestrictPermissions", False ),_
MkPropVal( "Selection", selection ),_
)
End Function

REM Создать пару имя-значения для установки свойств
Function MkPropVal( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then oPropertyValue.Name = cName
If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue
MkPropVal() = oPropertyValue
End Function

Sub Main
    DoExportToPDF ThisComponent, "file:///D:/документ.pdf"
End Sub
С уважением,
Михаил Каганский

ASSEI