summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/source/text/sbasic/shared/03/sf_document.xhp')
-rw-r--r--helpcontent2/source/text/sbasic/shared/03/sf_document.xhp729
1 files changed, 729 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp b/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp
new file mode 100644
index 000000000..f0c0ee7c5
--- /dev/null
+++ b/helpcontent2/source/text/sbasic/shared/03/sf_document.xhp
@@ -0,0 +1,729 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+
+<meta>
+ <topic id="SF_Document" indexer="include" status="PUBLISH">
+ <title id="tit" xml-lang="en-US">SFDocuments.Document service</title>
+ <filename>/text/sbasic/shared/03/sf_document.xhp</filename>
+ </topic>
+</meta>
+
+<body>
+<section id="SFDocuments-sf_document">
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id261582733781987">
+ <bookmark_value>Document service</bookmark_value>
+ </bookmark>
+</section>
+
+<section id="abstract">
+ <h1 id="hd_id731582733781114" xml-lang="en-US"><variable id="DocumentService"><link href="text/sbasic/shared/03/sf_document.xhp" name="Exception service"><literal>SFDocuments</literal>.<literal>Document</literal> service</link></variable></h1>
+ <paragraph role="paragraph" id="par_id381589189355849" xml-lang="en-US">The <literal>SFDocuments</literal> library provides methods and properties to facilitate the management and manipulation of %PRODUCTNAME documents.</paragraph>
+ <paragraph role="paragraph" id="par_id591589189364267" xml-lang="en-US">Methods that are applicable for all types of documents (Text Documents, Sheets, Presentations, etc) are provided by the <literal>SFDocuments.Document</literal> service. Some examples are:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id891589189452545" role="listitem" xml-lang="en-US">Opening, closing and saving documents</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id811589189463041" role="listitem" xml-lang="en-US">Accessing standard or custom properties of documents</paragraph>
+ </listitem>
+ </list>
+</section>
+
+ <warning id="par_id301611085807704">The properties, methods or arguments marked with <emph>(*)</emph> are <emph>NOT applicable to Base documents</emph>.</warning>
+ <paragraph role="paragraph" id="par_id241589189701274" xml-lang="en-US">Methods and properties that are specific to certain %PRODUCTNAME components are stored in separate services, such as <literal>SFDocuments.SF_Calc</literal> and <literal>SFDocuments.SF_Base</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id641611090052376">Although the Basic language does not offer inheritance between object classes, the latter services may be considered as subclasses of the <literal>SFDocuments.Document</literal> service. Such subclasses can invoke the properties and methods described below.</paragraph>
+
+ <h2 id="hd_id581582885621841" xml-lang="en-US">Service invocation</h2>
+ <paragraph role="paragraph" id="par_id141609955500101">Before using the <literal>Document</literal> service the <literal>ScriptForge</literal> library needs to be loaded or imported:</paragraph>
+ <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#importLibs"/>
+
+ <paragraph role="paragraph" id="par_id581611090387382">Below are three variants of how the <literal>Document</literal> service can be invoked.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <paragraph role="paragraph" id="par_id181622816732197">Using the <literal>getDocument</literal> method from the <literal>ScriptForge</literal>.<literal>UI</literal> service:</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id371582885621964">Dim ui As Object, oDoc As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id201582885621287">Set ui = CreateScriptService("UI")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id561589191748697">Set oDoc = ui.GetDocument("Untitled 1")</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id181622818236233">Alternatively you can use the methods <literal>CreateDocument</literal> and <literal>OpenDocument</literal> from the <literal>UI</literal> service.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id511589191758563">Set oDocA = ui.CreateDocument("Calc")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id331589191766531">Set oDocB = ui.OpenDocument("C:\Documents\MyFile.odt")</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id691622816765571">Directly if the document is already open.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id371589191782045">Dim oDoc As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id711589191788959">Set oDoc = CreateScriptService("SFDocuments.Document", "Untitled 1") 'Default = ActiveWindow</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id821622816825012">From a macro triggered by a document event.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id61598109336361">Sub RunEvent(ByRef poEvent As Object)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id31598109342395"> Dim oDoc As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id481598109349427"> Set oDoc = CreateScriptService("SFDocuments.DocumentEvent", poEvent)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id401622818141194"> ' (...)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id991622818141557">End Sub</paragraph>
+ </bascode>
+ <note id="par_id831622816562430">The <literal>Document</literal> service is closely related to the <literal>UI</literal> and <literal>FileSystem</literal> services.</note>
+ <paragraph role="paragraph" id="par_id891582733781994" xml-lang="en-US">Except when the document was closed by program with the CloseDocument method (it is then superfluous), it is recommended to free resources after use:</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id61582733781413">Set oDoc = oDoc.Dispose()</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id261622818031652">from scriptforge import CreateScriptService</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id291622818032129">ui = CreateScriptService("UI")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id781622818032358">doc = ui.GetDocument("Untitled 1")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id741622818032551"># (...)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221622818032804">doc.Dispose()</paragraph>
+ </pycode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id421622818033432">docA = ui.CreateDocument("Calc")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id451622818787113">docB = ui.OpenDocument("C:\Documents\MyFile.odt")</paragraph>
+ </pycode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id931622818866918">doc = CreateScriptService("SFDocuments.Document", "Untitled 1")</paragraph>
+ </pycode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id551622819064247">def RunEvent(event)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id311622819064554"> doc = CreateScriptService("SFDocuments.DocumentEvent", Event)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221622819064967"> # (...)</paragraph>
+ </pycode>
+ <tip id="par_id71611090922315">The use of the prefix "<literal>SFDocuments.</literal>" while calling the service is optional.</tip>
+
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id81611339709014">
+ <bookmark_value>API;Duration</bookmark_value>
+ <bookmark_value>API;XComponent</bookmark_value>
+ <bookmark_value>API;ODatabaseDocument</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id351582885195476" xml-lang="en-US">Properties</h2>
+ <table id="tab_id971582885195582">
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id41582885195836" role="tablehead" xml-lang="en-US">Name</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id31582885195372" role="tablehead" xml-lang="en-US">Readonly</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id31582885195238" role="tablehead" xml-lang="en-US">Type</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id931582885195131" role="tablehead" xml-lang="en-US" >Description</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id7715828856553" role="tablecontent" xml-lang="en-US" localize="false">CustomProperties (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id861582885655779" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id271582885655525" role="tablecontent" xml-lang="en-US" localize="false">Dictionary service</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id581582885655885" role="tablecontent" xml-lang="en-US" >Returns a <literal>ScriptForge.Dictionary</literal> object instance. After update, can be passed again to the property for updating the document.<br />Individual items of the dictionary may be either strings, numbers, (Basic) dates or <link href="https://api.libreoffice.org/docs/idl/ref/structcom_1_1sun_1_1star_1_1util_1_1Duration.html" name="Duration API"><literal>com.sun.star.util.Duration</literal></link> items.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id841582886030384" role="tablecontent" xml-lang="en-US" localize="false">Description (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id441582886030118" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id131582886030297" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id471582886030489" role="tablecontent" xml-lang="en-US" >Gives access to the Description property of the document (also known as "Comments")</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id231582886791351" role="tablecontent" xml-lang="en-US" localize="false">DocumentProperties (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id971582886791838" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id271582886791111" role="tablecontent" xml-lang="en-US" localize="false">Dictionary service</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id16158288679167" role="tablecontent" xml-lang="en-US" >Returns a <literal>ScriptForge.Dictionary</literal> object containing all the entries. Document statistics are included. Note that they are specific to the type of document. As an example, a Calc document includes a "CellCount" entry. Other documents do not.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id881589194571813" role="tablecontent" xml-lang="en-US" localize="false">DocumentType</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id201589194571955" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id951589194571781" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id941589194571801" role="tablecontent" xml-lang="en-US" >String value with the document type ("Base", "Calc", "Writer", etc)</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id881589194572136" role="tablecontent" xml-lang="en-US" localize="false">ExportFilters</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id201589194571699" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id951589194571391" role="tablecontent" xml-lang="en-US" localize="false">String array</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id941589194571327" role="tablecontent" xml-lang="en-US">Returns a list with the export filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id881589194573253" role="tablecontent" xml-lang="en-US" localize="false">ImportFilters</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id201589194571067" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id951589194571292" role="tablecontent" xml-lang="en-US" localize="false">String array</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id941589194571922" role="tablecontent" xml-lang="en-US">Returns a list with the import filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id241589194633142" role="tablecontent" xml-lang="en-US" localize="false">IsBase<br />IsCalc<br />IsDraw<br />IsImpress<br />IsMath<br />IsWriter</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id761589194633950" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id741589194633956" role="tablecontent" xml-lang="en-US" localize="false">Boolean</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id611589194633853" role="tablecontent" xml-lang="en-US" >Exactly one of these properties is <literal>True</literal> for a given document.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id311589194910727" role="tablecontent" xml-lang="en-US" localize="false">Keywords (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id231589194910179" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id421589194910942" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id311589194910190" role="tablecontent" xml-lang="en-US">Gives access to the Keywords property of the document. Represented as a comma-separated list of keywords</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id911589638614922" role="tablecontent" xml-lang="en-US" localize="false">Readonly (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id921589638614972" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id501589638614132" role="tablecontent" xml-lang="en-US" localize="false">Boolean</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id801589638614518" role="tablecontent" xml-lang="en-US"><literal>True</literal> if the document is actually in read-only mode</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id921589195028191" role="tablecontent" xml-lang="en-US" localize="false">Subject (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id201589195028733" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id551589195028724" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id371589195028843" role="tablecontent" xml-lang="en-US">Gives access to the Subject property of the document.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id521589195028736" role="tablecontent" xml-lang="en-US" localize="false">Title (*)</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id451589195028910" role="tablecontent" xml-lang="en-US">No</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id31589195028773" role="tablecontent" xml-lang="en-US" localize="false">String</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id771589195028748" role="tablecontent" xml-lang="en-US">Gives access to the Title property of the document.</paragraph>
+ </tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id97158288519551" role="tablecontent" xml-lang="en-US" localize="false">XComponent</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id221582885195686" role="tablecontent" xml-lang="en-US">Yes</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id371582885195525" role="tablecontent" xml-lang="en-US">UNO Object</paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id881582885195976" role="tablecontent" xml-lang="en-US" >The UNO object <link href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XComponent.html" name="XComponent API"><literal>com.sun.star.lang.XComponent</literal></link> or <link href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sdb_1_1OfficeDatabaseDocument.html" name="ODatabaseDocument API"><literal>com.sun.star.comp.dba.ODatabaseDocument</literal></link> representing the document</paragraph>
+ </tablecell>
+ </tablerow>
+</table>
+
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <paragraph role="paragraph" id="par_id861611146581334">The example below prints all the properties of a document. Note that the <literal>oDoc</literal> object returned by the <literal>UI.OpenDocument</literal> method is a <literal>SFDocuments.Document</literal> object.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id391611146834072">Dim ui as Variant : Set ui = CreateScriptService("UI")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id471611146957794">Dim oDoc as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id311611146962193">Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods")</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id711611146962784">Dim propDict as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id391611146963409">Set propDict = oDoc.DocumentProperties</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id621611146963920">Dim keys as Variant : propKeys = propDict.Keys</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id21611146964465">Dim k as String, strProp as String</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id681611146965001">For Each k In propKeys</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id191611146965538"> strProp = strProp &amp; k &amp; ": " &amp; propDict.Item(k) &amp; CHR$(10)</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id741611146966256">Next k</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id911611146967874">MsgBox strProp</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id681611147290092">oDoc.CloseDocument()</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <paragraph role="paragraph" id="par_id571622826920742">To access document properties in a Python script the user needs to directly access them using their names, as shown below:</paragraph>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id391622827274657">doc = ui.GetDocument(r"C:\Documents\MyFile.ods")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id261622827328471">msg = doc.Title + '\n' + doc.Description + '\n' + doc.Keywords</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id41622827328938">bas = CreateScriptService("Basic")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id71622827329510">bas.MsgBox(msg)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id71622827327225">doc.CloseDocument()</paragraph>
+ </pycode>
+
+ <table id="tab_id901611086279902">
+ <tablerow>
+ <tablecell colspan="3"><paragraph id="par_id651606319520519" role="tablehead">List of Methods in the Document Service</paragraph></tablecell>
+ </tablerow>
+ <tablerow>
+ <tablecell>
+ <paragraph id="par_id761611086279902" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_document.xhp#Activate" name="Activate method">Activate</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#CloseDocument" name="CloseDocument method">CloseDocument</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#CreateMenu" name="CreateMenu method">CreateMenu</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#ExportAsPDF" name="ExportAsPDF method">ExportAsPDF</link><br/>
+ </paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id141611086279902" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_document.xhp#PrintOut" name="PrintOut method">PrintOut</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#RemoveMenu" name="RemoveMenu method">RemoveMenu</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#RunCommand" name="RunCommand method">RunCommand</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#Save" name="Save method">Save</link><br/>
+ </paragraph>
+ </tablecell>
+ <tablecell>
+ <paragraph id="par_id761611086279903" role="tablecontent" localize="false">
+ <link href="text/sbasic/shared/03/sf_document.xhp#SaveAs" name="SaveAs method">SaveAs</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#SaveCopyAs" name="SaveCopyAs method">SaveCopyAs</link><br/>
+ <link href="text/sbasic/shared/03/sf_document.xhp#SetPrinter" name="SetPrinter method">SetPrinter</link><br/><br/>
+ </paragraph>
+ </tablecell>
+ </tablerow>
+ </table>
+
+<section id="Activate">
+ <comment> Activate -------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id92158919969883">
+ <bookmark_value>Document service;Activate</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id201589199698251" localize="false">Activate</h2>
+ <paragraph role="paragraph" id="par_id93158919969864">Returns <literal>True</literal> if the document could be activated. Otherwise, there is no change in the actual user interface. It is equivalent to the <literal>Activate</literal> method of the <literal>UI</literal> service.</paragraph>
+ <paragraph role="paragraph" id="par_id421611148353046">This method is useful when one needs to give focus for a document that is minimized or hidden.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id181622827609276">
+ <input>svc.Activate(): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <paragraph role="paragraph" id="par_id601611148017930">The example below considers that the file "My_File.ods" is already open but not active.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id41158919969836">Dim oDoc As Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id881611147617212">Set oDoc = CreateScriptService("Document", "MyFile.ods")</paragraph>
+ <paragraph role="bascode" localize="false" id="pyc_id571611147618913">oDoc.Activate()</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id411622827715523">doc = CreateScriptService("Document", "MyFile.ods")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id171622827715836">doc.Activate()</paragraph>
+ </pycode>
+ <tip id="par_id601611148080503">Keep in mind that you can invoke the <literal>Document</literal> service by passing to <literal>CreateScriptService</literal> either "Document" or "SFDocuments.Document"</tip>
+</section>
+
+<section id="CloseDocument">
+ <comment> CloseDocument ---------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721589200121249">
+ <bookmark_value>Document service;CloseDocument</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id261589200121415" localize="false">CloseDocument</h2>
+ <paragraph role="paragraph" id="par_id651589200121138">Closes the document. If the document is already closed, regardless of how the document was closed, this method has no effect and returns <literal>False</literal>.</paragraph>
+ <paragraph role="paragraph" id="par_id341611149562894">The method will also return <literal>False</literal> if the user declines to close it.</paragraph>
+ <paragraph role="paragraph" id="par_id981611149616934">Returns <literal>True</literal> if the document was successfully closed.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001622887222169">
+ <input>svc.CloseDocument(saveask: bool = True): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id361589200121646"><emph>saveask</emph> : If <literal>True</literal> (default), the user is invited to confirm if the changes should be written on disk. This argument is ignored if the document was not modified.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id891580290121516">If oDoc.CloseDocument(True) Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id51589200506125"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id751622827903730">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731622827946898">if doc.CloseDocument(True):</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221622827947414"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="CreateMenu">
+ <comment> CreateMenu --------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721589200120958">
+ <bookmark_value>Document service;CreateMenu</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id261589200121339" localize="false">CreateMenu</h2>
+ <paragraph role="paragraph" id="par_id651589200121080">Creates a new menu entry in the menubar of a given document window.</paragraph>
+ <paragraph role="paragraph" id="par_id981611149616155">This method returns an instance of the <link href="text/sbasic/shared/03/sf_menu.xhp" name="Menu_link1"><input>SFWidgets.Menu</input></link> service.</paragraph>
+ <note id="par_id721643121487974">The menu created is only available during the current %PRODUCTNAME session and is not saved neither in the document nor in the global application settings. Hence closing the document window will make the menu disappear. It will only reappear when the macro that creates the menu is executed again.</note>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001622887222964">
+ <input>svc.CreateMenu(menuheader: str, [before: any], submenuchar: str = "&gt;"): svc</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id361589200120316"><emph>menuheader</emph>: The toplevel name of the new menu.</paragraph>
+ <paragraph role="paragraph" id="par_id361589200129686"><emph>before</emph>: The name (as a string) or position (as an integer starting at 1) of an existing menu before which the new menu will be placed. If no value is defined for this argument, the menu will be created at the last position in the menubar.</paragraph>
+ <paragraph role="paragraph" id="par_id361589200122507"><emph>submenuchar</emph>: The delimiter used to create menu trees when calling methods as <literal>AddItem</literal> from the <literal>Menu</literal> service. The default value is "&gt;".</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id891580290121500">Dim oDoc as Object, oMenu as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id515892005061251">Set oDoc = CreateScriptService("Document")</paragraph>
+ <paragraph role="bascode" id="bas_id751622827903865">Set oMenu = oDoc.CreateMenu("My Menu")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id621643120224240">With oMenu</paragraph>
+ <paragraph role="bascode" id="bas_id391643120224507"> ' Add items to the menu</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id411643120224708"> .AddItem("Item A")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id411643120224719"> .AddItem("Item B")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id461643120224936"> ' ...</paragraph>
+ <paragraph role="bascode" id="bas_id100164312025160"> ' After creating the menu, the service instance can be disposed of</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id401643120225361"> .Dispose()</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id701643120225536">End With</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731622827946021">doc = CreateScriptService("Document")</paragraph>
+ <paragraph role="pycode" id="pyc_id221622827943208">menu = doc.CreateMenu("My Menu")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id381643120494454">menu.AddItem("Item A")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id381643120494463">menu.AddItem("Item B")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id361643120494723"># ...</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id151643120494942">menu.Dispose()</paragraph>
+ </pycode>
+ <section id="menu_tip">
+ <tip id="par_id271643139068194">Refer to the <link href="text/sbasic/shared/03/sf_menu.xhp" name="Menu_link2"><input>SFWidgets.Menu</input></link> help page to learn more about how to create/remove menus in %PRODUCTNAME document windows.</tip>
+ </section>
+</section>
+
+<section id="ExportAsPDF">
+ <comment> ExportAsPDF -------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721985200121025">
+ <bookmark_value>Document service;ExportAsPDF</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id261589202100695" localize="false">ExportAsPDF</h2>
+ <paragraph role="paragraph" id="par_id156589200123048">Exports the document directly as a PDF file to the specified location. Returns <literal>True</literal> if the PDF file was successfully created.</paragraph>
+ <paragraph role="paragraph" id="par_id811638276067119">The export options can be set either manually using the <menuitem>File - Export As - Export as PDF</menuitem> dialog or by calling the methods <literal>GetPDFExportOptions</literal> and <literal>SetPDFExportOptions</literal> from the <link href="text/sbasic/shared/03/sf_session.xhp" name="SFSession">Session</link> service.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001622827826679">
+ <input>svc.ExportAsPDF(filename: str, overwrite: bool = False, opt pages: str, opt password: str, opt watermark: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id211635436910641"><emph>filename</emph>: The full path and file name of the PDF to be created. It must follow the <literal>SF_FileSystem.FileNaming</literal> notation.</paragraph>
+ <paragraph role="paragraph" id="par_id141635436912005"><emph>overwrite</emph>: Specifies if the destination file can be overwritten (Default = <literal>False</literal>). An error will occur if <literal>overwrite</literal> is set to <literal>False</literal> and the destination file already exists.</paragraph>
+ <paragraph role="paragraph" id="par_id141635436913587"><emph>pages</emph><emph></emph>: String specifying which pages will be exported. This argument uses the same notation as in the dialog <menuitem>File - Export As - Export as PDF</menuitem>.</paragraph>
+ <paragraph role="paragraph" id="par_id141635436919655"><emph>password</emph><emph></emph>: Specifies a password to open the PDF file.</paragraph>
+ <paragraph role="paragraph" id="par_id141635436913365"><emph>watermark</emph>: Text to be used as watermark in the PDF file, which will be drawn in every page of the resulting PDF.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <paragraph role="paragraph" id="par_id301638234284727">The following example exports the current document as a PDF file, defines a password and overwrites the destination file if it already exists.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id891589200127786">oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf", Password := "1234", Overwrite := True)</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id311638276257020">The code snippet below gets the current PDF export options and uses them to create the PDF file.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id791638277305385">Dim exportSettings as Object, oSession as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id51638277174044">oSession = CreateScriptService("Session")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id291638277174233">exportSettings = oSession.GetPDFExportOptions()</paragraph>
+ <paragraph role="bascode" id="bas_id851638277174798">' Sets to True the option to export comments as PDF notes</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id71638277174405">exportSettings.ReplaceItem("ExportNotes", True)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id611638277174622">oSession.SetPDFExportOptions(exportSettings)</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id461638277174958">oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf")</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731622728946003">doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf", password = "1234", overwrite = True)</paragraph>
+ </pycode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id481638277330132">session = CreateScriptService("Session")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id881638277330334">exportSettings = oSession.GetPDFExportOptions()</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id121638277330485">exportSettings.ReplaceItem("ExportNotes", True)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id401638277330637">session.SetPDFExportOptions(exportSettings)</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id591638277330780">doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf")</paragraph>
+ </pycode>
+</section>
+
+<section id="PrintOut">
+ <comment> PrintOut ---------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721985200121249">
+ <bookmark_value>Document service;PrintOut</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id261589202101415" localize="false">PrintOut</h2>
+ <paragraph role="paragraph" id="par_id156589200121138">This method sends the contents of the document to the default printer or to the printer defined by the <literal>SetPrinter</literal> method.</paragraph>
+ <paragraph role="paragraph" id="par_id981611169416934">Returns <literal>True</literal> if the document was successfully printed.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001622827822169">
+ <input>svc.PrintOut(pages: str = "", copies: num = 1): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id211635436910093"><emph>pages</emph>: The pages to print as a string, like in the user interface. Example: &quot;1-4;10;15-18&quot;. Default is all pages.</paragraph>
+ <paragraph role="paragraph" id="par_id141635436912146"><emph>copies</emph>: The number of copies. Default is 1.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id891589200121516">If oDoc.PrintOut("1-4;10;15-18", Copies := 2) Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id515892500606125"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id751682227903730">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731622728946898">if doc.PrintOut(copies=3, pages='45-88'):</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id221628227947414"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="RemoveMenu">
+ <comment> RemoveMenu --------------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id721589200129148">
+ <bookmark_value>Document service;RemoveMenu</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id261589200121147" localize="false">RemoveMenu</h2>
+ <paragraph role="paragraph" id="par_id651589200165470">Removes a toplevel menu from the menubar of a given document window.</paragraph>
+ <paragraph role="paragraph" id="par_id981611149610695">Returns <literal>True</literal> if the specified menu could be removed. If the specified menu does not exist, the method returns <literal>False</literal>.</paragraph>
+ <note id="par_id571643121106014">This method can be used to remove any menu entry from the document window, including default menus. However, none of these changes in the menubar are saved to the document or to the application settings. To restore the menubar to the default settings, simply close and reopen the document window.</note>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id1001622887065864">
+ <input>svc.RemoveMenu(menuheader: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id361589200121156"><emph>menuheader</emph>: The toplevel name of the menu to be removed.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id891580290121522">Dim oDoc as Object</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id515892005060659">Set oDoc = CreateScriptService("Document")</paragraph>
+ <paragraph role="bascode" id="bas_id391643120223147">oDoc.RemoveMenu("My Menu")</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id731622827946155">doc = CreateScriptService("Document")</paragraph>
+ <paragraph role="pycode" id="pyc_id221622827946338">doc.RemoveMenu("My Menu")</paragraph>
+ </pycode>
+ <embed href="text/sbasic/shared/03/sf_document.xhp#menu_tip"/>
+</section>
+
+<section id="RunCommand">
+ <comment> RunCommand --------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id601589202413561">
+ <bookmark_value>Document service;RunCommand</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id611589202413141" localize="false">RunCommand</h2>
+ <paragraph role="paragraph" id="par_id991589202413257">Runs a UNO command on the document window associated with the service instance. A few typical commands are: Save, SaveAs, ExportToPDF, Undo, Copy, Paste, etc.</paragraph>
+ <paragraph role="paragraph" id="par_id261589202778896" xml-lang="en-US">The document itself does not need to be active to be able to run commands.</paragraph>
+ <paragraph role="paragraph" id="par_id921611152932311">Commands can be run with or without arguments. Arguments are not validated before running the command. If the command or its arguments are invalid, then nothing will happen.</paragraph>
+ <tip id="par_id31644182402479">For a complete list of UNO commands that can be run in %PRODUCTNAME, refer to the Wiki page <link href="https://wiki.documentfoundation.org/Development/DispatchCommands" name="Commands_Wiki">Development/DispatchCommands</link>.</tip>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id521622828226683">
+ <input>svc.RunCommand(command: str, [args: any])</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id401589202413575"><emph>command</emph>: Case-sensitive string containing the UNO command name. The inclusion of the prefix ".uno:" in the command is optional. The command itself is not checked for correctness. If nothing happens after the command call, then the command is probably wrong.</paragraph>
+ <paragraph role="paragraph" id="par_id521644182774710"><emph>args</emph>: For each argument to be passed to the command, specify a pair containing the argument name and value.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <paragraph role="paragraph" id="par_id721611153068137">The following example runs the <literal>SelectData</literal> command in a Calc file named "MyFile.ods", which will result in the selection of the data area based on the currently selected cell. Note that this command does not require any arguments.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id401611153339973">Set oDoc = CreateScriptService("Document", "MyFile.ods")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id121589202413630">oDoc.RunCommand("SelectData")</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id371644184276886">Below is an example that runs the UNO command <literal>ReplaceAll</literal> and passes values for its arguments <literal>SearchString</literal> and <literal>ReplaceString</literal>. Running this command will replace all occurrence of the string "abc" by "ABC" in the current sheet.</paragraph>
+ <bascode>
+ <paragraph role="bascode" id="bas_id631644184414955">' Arguments passed to the command:</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id621644184336024">' SearchString = "abc"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id516441843364240">' ReplaceString = "ABC"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id391644184337449">oDoc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC")</paragraph>
+ </bascode>
+ <paragraph role="paragraph" id="par_id41644184549167">Note that calling the command <literal>ReplaceAll</literal> without arguments will open the <menuitem>Find and Replace</menuitem> dialog.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id821622828361025">doc = CreateScriptService("Document", "MyFile.ods")</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id211622828361293">doc.RunCommand("SelectData")</paragraph>
+ </pycode>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id661644184648102">doc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC")</paragraph>
+ </pycode>
+ <paragraph role="paragraph" id="par_id811644243228448">In Python it is also possible to call <literal>RunCommand</literal> using keyword arguments:</paragraph>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id301644243318500">doc.RunCommand(".uno:ReplaceAll", SearchString = "abc", ReplaceString = "ABC")</paragraph>
+ </pycode>
+ <tip id="par_id191611153511038">Each %PRODUCTNAME component has its own set of commands available. One easy way to learn commands is going to <emph>Tools - Customize - Keyboard</emph>. When you position your mouse over a function in the <emph>Function</emph> list, a tooltip will appear with the corresponding UNO command.</tip>
+</section>
+
+<section id="Save">
+ <comment> Save ------------------------------------------------------------------------ </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id691589202925124">
+ <bookmark_value>Document service;Save</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id3615892029256" localize="false">Save</h2>
+ <paragraph role="paragraph" id="par_id81589202925519">Stores the document to the file location from which it was loaded. The method is ignored if the document was not modified.</paragraph>
+ <paragraph role="paragraph" id="par_id731611153918907">Returns <literal>False</literal> if the document could not be saved. An error is raised if the file is open as read-only, or if it is a new file that has not been saved yet.</paragraph>
+ <paragraph role="paragraph" id="par_id211589203690937" xml-lang="en-US">The document itself does not need to be active to run this method.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id711622828457342">
+ <input>svc.Save(): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id31589202925376">If Not oDoc.Save() Then</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id821589203188905"> ' ...</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id811622828432150">End If</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id981622828541243">if not doc.Save():</paragraph>
+ <paragraph role="pycode" localize="false" id="pyc_id781622828542374"> # ...</paragraph>
+ </pycode>
+</section>
+
+<section id="SaveAs">
+ <comment> SaveAs --------------------------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id141589203370367">
+ <bookmark_value>Document service;SaveAs</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id161589203370594" localize="false">SaveAs</h2>
+ <paragraph role="paragraph" id="par_id121589203370778">Stores the document to the given file location. The new location becomes the new file name on which simple Save method calls will be applied.</paragraph>
+ <paragraph role="paragraph" id="par_id31611154475602">Returns <literal>False</literal> if the document could not be saved. An error is raised when overwriting the destination is rejected or when the destination has its read-only attribute set.</paragraph>
+ <paragraph role="paragraph" id="par_id391589203370902" xml-lang="en-US">The document itself does not need to be active to run this method.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id561622828596238">
+ <input>svc.SaveAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id331589203370950"><emph>filename</emph>: A string containing the file name to be used. It must follow the <literal>SF_FileSystem.FileNaming</literal> notation.</paragraph>
+ <paragraph role="paragraph" id="par_id631589204010142" xml-lang="en-US"><emph>overwrite</emph>: If <literal>True</literal>, the destination file may be overwritten (default = <literal>False</literal>).</paragraph>
+ <paragraph role="paragraph" id="par_id811589204084107" xml-lang="en-US"><emph>password</emph> (*): A non-space string to protect the document.</paragraph>
+ <paragraph role="paragraph" id="par_id451589204163772" xml-lang="en-US"><emph>filtername</emph> (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist.</paragraph>
+ <paragraph role="paragraph" id="par_id981589204207800" xml-lang="en-US"><emph>filteroptions</emph> (*): An optional string of options associated with the filter.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id81589203370943">oDoc.SaveAs("C:\Documents\NewCopy.odt", overwrite := True)</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id801622828865363">doc.SaveAs(r"C:\Documents\NewCopy.odt", overwrite = True)</paragraph>
+ </pycode>
+</section>
+
+<section id="SaveCopyAs">
+ <comment> SaveCopyAs ------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id71158920514765">
+ <bookmark_value>Document service;SaveCopyAs</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id811589205147824" localize="false">SaveCopyAs</h2>
+ <paragraph role="paragraph" id="par_id911589205147502">Stores a copy of or export the document to the given file location. The actual location is unchanged.</paragraph>
+ <paragraph role="paragraph" id="par_id381611154800685">Returns <literal>False</literal> if the document could not be saved. An error is raised when overwriting the destination is rejected or when the destination has its read-only attribute set.</paragraph>
+ <paragraph role="paragraph" id="par_id11589205147643" xml-lang="en-US">The document itself does not need to be active to run this method.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id561622828596855">
+ <input>svc.SaveCopyAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph role="paragraph" id="par_id301589205147697"><emph>filename</emph>: A string containing the file name to be used. It must follow the <literal>SF_FileSystem.FileNaming</literal> notation.</paragraph>
+ <paragraph role="paragraph" id="par_id851589205147348" xml-lang="en-US"><emph>overwrite</emph>: If <literal>True</literal>, the destination file may be overwritten (default = <literal>False</literal>).</paragraph>
+ <paragraph role="paragraph" id="par_id821589205147330" xml-lang="en-US"><emph>password</emph> (*): A non-space string to protect the document.</paragraph>
+ <paragraph role="paragraph" id="par_id67158920514729" xml-lang="en-US"><emph>filtername</emph> (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist.</paragraph>
+ <paragraph role="paragraph" id="par_id881589205147911" xml-lang="en-US"><emph>filteroptions</emph> (*): An optional string of options associated with the filter.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id431589205147164">oDoc.SaveCopyAs("C:\Documents\Copy2.odt", Overwrite := True)</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id941622829095519">doc.SaveCopyAs(r"C:\Documents\Copy2.odt", overwrite = True)</paragraph>
+ </pycode>
+</section>
+
+<section id="SetPrinter">
+ <comment> SetPrinter ------------------------------------------------------------------- </comment>
+ <bookmark xml-lang="en-US" localize="false" branch="index" id="bm_id71158921504765">
+ <bookmark_value>Document service;SetPrinter</bookmark_value>
+ </bookmark>
+ <h2 id="hd_id811589502147824" localize="false">SetPrinter</h2>
+ <paragraph role="paragraph" id="par_id911298505147502">Defines the printer options for the document.</paragraph>
+ <paragraph role="paragraph" id="par_id381651114800685">Returns <literal>True</literal> when successful.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="paragraph" localize="false" id="par_id261652828596855">
+ <input>svc.SetPrinter(opt printer: str, opt orientation: str, paperformat: str): bool</input>
+ </paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <section id="setPrinterArgs">
+ <paragraph role="paragraph" id="par_id301589205741697"><emph>printer</emph>: The name of the printer queue where to print to. When absent, the default printer is set.</paragraph>
+ <paragraph role="paragraph" id="par_id851985205147348"><emph>orientation</emph>: Either <literal>PORTRAIT</literal> or <literal>LANDSCAPE</literal>. When absent, left unchanged with respect to the printer settings.</paragraph>
+ <paragraph role="paragraph" id="par_id821985205147330"><emph>paperformat</emph>: Specifies the paper format as a string value that can be either <literal>A3</literal>, <literal>A4</literal>, <literal>A5</literal>, <literal>LETTER</literal>, <literal>LEGAL</literal> or <literal>TABLOID</literal>. Left unchanged when absent.</paragraph>
+ </section>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Basic"/>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="bas_id431589204157164">oDoc.SetPrinter(Orientation := "PORTRAIT")</paragraph>
+ </bascode>
+ <embed href="text/sbasic/shared/00000003.xhp#In_Python"/>
+ <pycode>
+ <paragraph role="pycode" localize="false" id="pyc_id941628229095519">doc.SetPrinter(paperformat='TABLOID')</paragraph>
+ </pycode>
+</section>
+
+ <embed href="text/sbasic/shared/03/lib_ScriptForge.xhp#SF_InternalUse"/>
+ <section id="relatedtopics">
+ <embed href="text/sbasic/shared/03/sf_dictionary.xhp#SFDictionary"/>
+ <embed href="text/sbasic/shared/03/sf_ui.xhp#UIService"/>
+ <embed href="text/sbasic/shared/03/sf_menu.xhp#MenuService"/>
+ </section>
+</body>
+</helpdocument>