From 974c21ad33bfa1d93d5ae795556d35ca7eb36e68 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:52:12 +0200 Subject: Adding debian version 1:7.0.4-4+deb11u8. Signed-off-by: Daniel Baumann --- ...22-26305-compare-authors-using-Thumbprint.patch | 63 + ...2-26307-make-hash-encoding-match-decoding.patch | 183 + ...306-add-Initialization-Vectors-to-passwor.patch | 583 + ...30-6-7-add-infobar-to-prompt-to-refresh-t.patch | 117 + debian/patches/CVE-2023-2255.diff | 943 + debian/patches/ZDI-CAN-17859.diff | 290 + debian/patches/add-access2base-doc.diff | 25337 +++++++++++++++++++ debian/patches/apparmor-allow-java.security.diff | 14 + debian/patches/apparmor-cleanups.diff | 105 + debian/patches/apparmor-complain.diff | 26 + debian/patches/apparmor-mesa.diff | 10 + debian/patches/apparmor-opencl.diff | 20 + debian/patches/apparmor-updates.diff | 13 + debian/patches/appstream-ignore-startcenter.diff | 10 + debian/patches/avoid-empty-java.class.path.diff | 90 + .../b0404f80577de9ff69e58390c6f6ef949fdb0139.patch | 63 + debian/patches/bash-completion-DRAWDOCS-pdf.diff | 26 + debian/patches/bigendian.diff | 352 + debian/patches/build-against-shared-lpsolve.diff | 27 + debian/patches/cppunit-optional.diff | 185 + debian/patches/debian-debug.diff | 47 + .../debian-hardened-buildflags-CPPFLAGS.diff | 37 + ...d-buildflags-no-LO-fstack-protector-strong.diff | 32 + debian/patches/debian-opt.diff | 26 + .../default-to-CertificateValidity::INVALID.diff | 52 + debian/patches/disable-flaky-tests.diff | 141 + ...able-java-in-odk-build-examples-on-zero-vm.diff | 58 + .../disable-shortcuts_tab_navigation-uitest.diff | 49 + debian/patches/disable-unused-test-programs.diff | 70 + debian/patches/disableClassPathURLCheck.diff | 10 + debian/patches/do-not-hide-test-output.diff | 99 + debian/patches/dont-touch-urd.diff | 80 + debian/patches/escape-url-passed-to-gstreamer.diff | 49 + debian/patches/fix-bluez-external.diff | 23 + .../fix-e_book_client_connect_direct_sync-sig.diff | 26 + debian/patches/fix-flaky-bridgetest.diff | 46 + debian/patches/fix-internal-hsqldb-build.diff | 45 + debian/patches/fix-lo-xlate-lang-nb.diff | 13 + debian/patches/fix-system-lpsolve-build.diff | 31 + debian/patches/fix-uicheck-tests-on-i386.patch | 34 + .../floating-frame-targets-unneeded-protocols.diff | 83 + debian/patches/help-msg-add-package-info.diff | 13 + debian/patches/hide-math-desktop-file.patch | 15 + debian/patches/hppa-is-32bit.diff | 13 + debian/patches/hrk-euro-default.diff | 42 + debian/patches/hrk-euro.diff | 156 + ...-LO-special-purpose-hyperlinks-per-default.diff | 237 + debian/patches/improve-macro-checks.diff | 145 + debian/patches/install-fixes.diff | 166 + debian/patches/javadoc-optional.diff | 153 + debian/patches/jdbc-driver-classpaths.diff | 35 + debian/patches/jurt-soffice-location.diff | 20 + debian/patches/liborcus-0.16.diff | 1255 + debian/patches/make-package-modules-not-suck.diff | 200 + debian/patches/mediwiki-oor-replace.diff | 51 + debian/patches/mention-java-common-package.diff | 35 + debian/patches/no-check-if-root.diff | 26 + debian/patches/no-opencl-per-default.diff | 26 + debian/patches/no-openssl.diff | 357 + debian/patches/no-packagekit-per-default.diff | 21 + debian/patches/pdfium-m68k.diff | 20 + debian/patches/reportdesign-mention-package.diff | 13 + .../reuse-AllowedLinkProtocolFromDocument-1.diff | 261 + .../reuse-AllowedLinkProtocolFromDocument-2.diff | 82 + debian/patches/sc-opengl-optional.diff | 26 + debian/patches/sc-stack-parameter-count.diff | 221 + debian/patches/search-usr-share-for-images.diff | 137 + debian/patches/sensible-lomua.diff | 50 + debian/patches/series | 78 + debian/patches/split-evoab.diff | 61 + .../system-officeotron-and-odfvalidator.diff | 16 + debian/patches/unowinreg-static-libgcc.diff | 13 + .../use-mariadb-java-instead-of-mysql-java.diff | 59 + .../warn-about-exotic-protocols-as-well.diff | 79 + .../work-around-expired-certificiate-in-test.diff | 24 + ...cParser-confused-about-multiple-timestamps.diff | 393 + ...re-elements-in-ds:Object-that-arent-signed.diff | 740 + ...ove-handling-of-multiple-X509Data-elements.diff | 1597 ++ ...security-replace-XSecParser-implementation.diff | 2170 ++ 79 files changed, 38514 insertions(+) create mode 100644 debian/patches/0001-CVE-2022-26305-compare-authors-using-Thumbprint.patch create mode 100644 debian/patches/0002-CVE-2022-26307-make-hash-encoding-match-decoding.patch create mode 100644 debian/patches/0003-CVE-2022-26306-add-Initialization-Vectors-to-passwor.patch create mode 100644 debian/patches/0004-CVE-2022-2630-6-7-add-infobar-to-prompt-to-refresh-t.patch create mode 100644 debian/patches/CVE-2023-2255.diff create mode 100644 debian/patches/ZDI-CAN-17859.diff create mode 100644 debian/patches/add-access2base-doc.diff create mode 100644 debian/patches/apparmor-allow-java.security.diff create mode 100644 debian/patches/apparmor-cleanups.diff create mode 100644 debian/patches/apparmor-complain.diff create mode 100644 debian/patches/apparmor-mesa.diff create mode 100644 debian/patches/apparmor-opencl.diff create mode 100644 debian/patches/apparmor-updates.diff create mode 100644 debian/patches/appstream-ignore-startcenter.diff create mode 100644 debian/patches/avoid-empty-java.class.path.diff create mode 100644 debian/patches/b0404f80577de9ff69e58390c6f6ef949fdb0139.patch create mode 100644 debian/patches/bash-completion-DRAWDOCS-pdf.diff create mode 100644 debian/patches/bigendian.diff create mode 100644 debian/patches/build-against-shared-lpsolve.diff create mode 100644 debian/patches/cppunit-optional.diff create mode 100644 debian/patches/debian-debug.diff create mode 100644 debian/patches/debian-hardened-buildflags-CPPFLAGS.diff create mode 100644 debian/patches/debian-hardened-buildflags-no-LO-fstack-protector-strong.diff create mode 100644 debian/patches/debian-opt.diff create mode 100644 debian/patches/default-to-CertificateValidity::INVALID.diff create mode 100644 debian/patches/disable-flaky-tests.diff create mode 100644 debian/patches/disable-java-in-odk-build-examples-on-zero-vm.diff create mode 100644 debian/patches/disable-shortcuts_tab_navigation-uitest.diff create mode 100644 debian/patches/disable-unused-test-programs.diff create mode 100644 debian/patches/disableClassPathURLCheck.diff create mode 100644 debian/patches/do-not-hide-test-output.diff create mode 100644 debian/patches/dont-touch-urd.diff create mode 100644 debian/patches/escape-url-passed-to-gstreamer.diff create mode 100644 debian/patches/fix-bluez-external.diff create mode 100644 debian/patches/fix-e_book_client_connect_direct_sync-sig.diff create mode 100644 debian/patches/fix-flaky-bridgetest.diff create mode 100644 debian/patches/fix-internal-hsqldb-build.diff create mode 100644 debian/patches/fix-lo-xlate-lang-nb.diff create mode 100644 debian/patches/fix-system-lpsolve-build.diff create mode 100644 debian/patches/fix-uicheck-tests-on-i386.patch create mode 100644 debian/patches/floating-frame-targets-unneeded-protocols.diff create mode 100644 debian/patches/help-msg-add-package-info.diff create mode 100644 debian/patches/hide-math-desktop-file.patch create mode 100644 debian/patches/hppa-is-32bit.diff create mode 100644 debian/patches/hrk-euro-default.diff create mode 100644 debian/patches/hrk-euro.diff create mode 100644 debian/patches/ignore-LO-special-purpose-hyperlinks-per-default.diff create mode 100644 debian/patches/improve-macro-checks.diff create mode 100644 debian/patches/install-fixes.diff create mode 100644 debian/patches/javadoc-optional.diff create mode 100644 debian/patches/jdbc-driver-classpaths.diff create mode 100644 debian/patches/jurt-soffice-location.diff create mode 100644 debian/patches/liborcus-0.16.diff create mode 100644 debian/patches/make-package-modules-not-suck.diff create mode 100644 debian/patches/mediwiki-oor-replace.diff create mode 100644 debian/patches/mention-java-common-package.diff create mode 100644 debian/patches/no-check-if-root.diff create mode 100644 debian/patches/no-opencl-per-default.diff create mode 100644 debian/patches/no-openssl.diff create mode 100644 debian/patches/no-packagekit-per-default.diff create mode 100644 debian/patches/pdfium-m68k.diff create mode 100644 debian/patches/reportdesign-mention-package.diff create mode 100644 debian/patches/reuse-AllowedLinkProtocolFromDocument-1.diff create mode 100644 debian/patches/reuse-AllowedLinkProtocolFromDocument-2.diff create mode 100644 debian/patches/sc-opengl-optional.diff create mode 100644 debian/patches/sc-stack-parameter-count.diff create mode 100644 debian/patches/search-usr-share-for-images.diff create mode 100644 debian/patches/sensible-lomua.diff create mode 100644 debian/patches/series create mode 100644 debian/patches/split-evoab.diff create mode 100644 debian/patches/system-officeotron-and-odfvalidator.diff create mode 100644 debian/patches/unowinreg-static-libgcc.diff create mode 100644 debian/patches/use-mariadb-java-instead-of-mysql-java.diff create mode 100644 debian/patches/warn-about-exotic-protocols-as-well.diff create mode 100644 debian/patches/work-around-expired-certificiate-in-test.diff create mode 100644 debian/patches/xmlsecurity-XSecParser-confused-about-multiple-timestamps.diff create mode 100644 debian/patches/xmlsecurity-ignore-elements-in-ds:Object-that-arent-signed.diff create mode 100644 debian/patches/xmlsecurity-improve-handling-of-multiple-X509Data-elements.diff create mode 100644 debian/patches/xmlsecurity-replace-XSecParser-implementation.diff (limited to 'debian/patches') diff --git a/debian/patches/0001-CVE-2022-26305-compare-authors-using-Thumbprint.patch b/debian/patches/0001-CVE-2022-26305-compare-authors-using-Thumbprint.patch new file mode 100644 index 000000000..e02b110f8 --- /dev/null +++ b/debian/patches/0001-CVE-2022-26305-compare-authors-using-Thumbprint.patch @@ -0,0 +1,63 @@ +From 77f30ada1156ca1e1357776fea8e9dc113f6898d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 3 Mar 2022 14:22:37 +0000 +Subject: [PATCH 1/4] CVE-2022-26305 compare authors using Thumbprint + +Change-Id: I338f58eb07cbf0a3d13a7dafdaddac09252a8546 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130929 +Tested-by: Jenkins +Reviewed-by: Miklos Vajna +(cherry picked from commit 65442205b5b274ad309308162f150f8d41648f72) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130866 +Reviewed-by: Michael Stahl +(cherry picked from commit a7aaa78acea4c1d51283c2fce54ff9f5339026f8) +--- + .../component/documentdigitalsignatures.cxx | 23 +++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx +index b9066ea92cac..5a21c8421bec 100644 +--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx ++++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx +@@ -19,9 +19,10 @@ + + #include + +-#include ++#include + #include + #include ++#include + #include + #include + #include +@@ -666,9 +667,23 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted( + Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors(); + + return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(), +- [&xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { +- return xmlsecurity::EqualDistinguishedNames(rAuthor[0], xAuthor->getIssuerName()) +- && ( rAuthor[1] == sSerialNum ); ++ [this, &xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { ++ if (!xmlsecurity::EqualDistinguishedNames(rAuthor[0], xAuthor->getIssuerName())) ++ return false; ++ if (rAuthor[1] != sSerialNum) ++ return false; ++ ++ DocumentSignatureManager aSignatureManager(mxCtx, {}); ++ if (!aSignatureManager.init()) ++ return false; ++ uno::Reference xCert = aSignatureManager.getSecurityEnvironment()->createCertificateFromAscii(rAuthor[2]); ++ ++ auto pAuthor = dynamic_cast(xAuthor.get()); ++ auto pCert = dynamic_cast(xCert.get()); ++ if (pAuthor && pCert) ++ return pCert->getSHA256Thumbprint() == pAuthor->getSHA256Thumbprint(); ++ ++ return xCert->getSHA1Thumbprint() == xAuthor->getSHA1Thumbprint(); + }); + } + +-- +2.37.1 + diff --git a/debian/patches/0002-CVE-2022-26307-make-hash-encoding-match-decoding.patch b/debian/patches/0002-CVE-2022-26307-make-hash-encoding-match-decoding.patch new file mode 100644 index 000000000..d56b5ea04 --- /dev/null +++ b/debian/patches/0002-CVE-2022-26307-make-hash-encoding-match-decoding.patch @@ -0,0 +1,183 @@ +From 780c42cdd8006dc60e281be2fe6566f101e909bc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Mon, 21 Mar 2022 20:58:34 +0000 +Subject: [PATCH 2/4] CVE-2022-26307 make hash encoding match decoding + +Seeing as old versions of the hash may be in the users config, add a +StorageVersion field to the office config Passwords section which +defaults to 0 to indicate the old hash is in use. + +Try the old varient when StorageVersion is 0. When a new encoded master +password it set write StorageVersion of 1 to indicate a new hash is in +use and use the new style when StorageVersion is 1. + +Change-Id: I3174c37a5891bfc849984e0ec5c2c392b9c6e7b1 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132080 +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +(cherry picked from commit e890f54dbac57f3ab5acf4fbd31222095d3e8ab6) +--- + .../schema/org/openoffice/Office/Common.xcs | 6 +++ + .../passwordcontainer/passwordcontainer.cxx | 45 +++++++++++++++++-- + .../passwordcontainer/passwordcontainer.hxx | 6 +++ + uui/source/iahndl-authentication.cxx | 5 ++- + 4 files changed, 57 insertions(+), 5 deletions(-) + +diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +index 9097c23c3c6a..922efc33cca7 100644 +--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs ++++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +@@ -942,6 +942,12 @@ + + false + ++ ++ ++ Specifies what version of encoding scheme the password container uses. ++ ++ 0 ++ + + + Specifies if there is a valid master password. +diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx +index 51fb129cddb1..b674844f91d3 100644 +--- a/svl/source/passwordcontainer/passwordcontainer.cxx ++++ b/svl/source/passwordcontainer/passwordcontainer.cxx +@@ -17,7 +17,6 @@ + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +- + #include "passwordcontainer.hxx" + + #include +@@ -259,6 +258,23 @@ bool StorageItem::useStorage() + return aResult; + } + ++sal_Int32 StorageItem::getStorageVersion() ++{ ++ Sequence aNodeNames { "StorageVersion" }; ++ ++ Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aNodeNames ); ++ ++ if( aPropertyValues.getLength() != aNodeNames.getLength() ) ++ { ++ OSL_FAIL( "Problems during reading" ); ++ return 0; ++ } ++ ++ sal_Int32 nResult = 0; ++ aPropertyValues[0] >>= nResult; ++ ++ return nResult; ++} + + bool StorageItem::getEncodedMP( OUString& aResult ) + { +@@ -291,15 +307,17 @@ bool StorageItem::getEncodedMP( OUString& aResult ) + + void StorageItem::setEncodedMP( const OUString& aEncoded, bool bAcceptEmpty ) + { +- Sequence< OUString > sendNames(2); +- Sequence< uno::Any > sendVals(2); ++ Sequence< OUString > sendNames(3); ++ Sequence< uno::Any > sendVals(3); + + sendNames[0] = "HasMaster"; + sendNames[1] = "Master"; ++ sendNames[2] = "StorageVersion"; + + bool bHasMaster = ( !aEncoded.isEmpty() || bAcceptEmpty ); + sendVals[0] <<= bHasMaster; + sendVals[1] <<= aEncoded; ++ sendVals[2] <<= nCurrentStorageVersion; + + ConfigItem::SetModified(); + ConfigItem::PutProperties( sendNames, sendVals ); +@@ -800,6 +818,18 @@ OUString PasswordContainer::RequestPasswordFromUser( PasswordRequestMode aRMode, + return aResult; + } + ++// Mangle the key to match an old bug ++static OUString ReencodeAsOldHash(const OUString& rPass) ++{ ++ OUStringBuffer aBuffer; ++ for (int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ++ind) ++ { ++ unsigned char i = static_cast(rPass.copy(ind * 2, 2).toUInt32(16)); ++ aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4))); ++ aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15))); ++ } ++ return aBuffer.makeStringAndClear(); ++} + + OUString const & PasswordContainer::GetMasterPassword( const Reference< XInteractionHandler >& aHandler ) + { +@@ -838,6 +868,9 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac + } + else + { ++ if (m_pStorageFile->getStorageVersion() == 0) ++ aPass = ReencodeAsOldHash(aPass); ++ + std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass, aRMode ) ); + if( aRM.empty() || aPass != aRM[0] ) + { +@@ -1042,6 +1075,12 @@ sal_Bool SAL_CALL PasswordContainer::authorizateWithMasterPassword( const uno::R + + do { + aPass = RequestPasswordFromUser( aRMode, xTmpHandler ); ++ ++ if (!aPass.isEmpty() && m_pStorageFile->getStorageVersion() == 0) ++ { ++ aPass = ReencodeAsOldHash(aPass); ++ } ++ + bResult = ( !aPass.isEmpty() && aPass == m_aMasterPasswd ); + aRMode = PasswordRequestMode_PASSWORD_REENTER; // further questions with error notification + } while( !bResult && !aPass.isEmpty() ); +diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx +index 46ffec888602..bf43b5903602 100644 +--- a/svl/source/passwordcontainer/passwordcontainer.hxx ++++ b/svl/source/passwordcontainer/passwordcontainer.hxx +@@ -168,6 +168,10 @@ public: + typedef ::std::pair< const OUString, ::std::vector< NamePassRecord > > PairUrlRecord; + typedef ::std::map< OUString, ::std::vector< NamePassRecord > > PassMap; + ++// org.openoffice.Office.Common/Passwords/StorageVersion bump if details of ++// how password details are saved changes. Enables migration from previous ++// schemes. ++constexpr sal_Int32 nCurrentStorageVersion = 1; + + class PasswordContainer; + +@@ -195,6 +195,8 @@ + void remove( const OUString& url, const OUString& rec ); + void clear(); + ++ sal_Int32 getStorageVersion(); ++ + bool getEncodedMP( OUString& aResult ); + void setEncodedMP( const OUString& aResult, bool bAcceptEnmpty = false ); + void setUseStorage( bool bUse ); +diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx +index ad975d3f9ae7..951f0b8a1c6b 100644 +--- a/uui/source/iahndl-authentication.cxx ++++ b/uui/source/iahndl-authentication.cxx +@@ -436,8 +436,9 @@ executeMasterPasswordDialog( + OUStringBuffer aBuffer; + for (sal_uInt8 i : aKey) + { +- aBuffer.append(static_cast< sal_Unicode >('a' + (i >> 4))); +- aBuffer.append(static_cast< sal_Unicode >('a' + (i & 15))); ++ // match PasswordContainer::DecodePasswords aMasterPasswd.copy(index * 2, 2).toUInt32(16)); ++ aBuffer.append(OUString::number(i >> 4, 16)); ++ aBuffer.append(OUString::number(i & 15, 16)); + } + rInfo.SetPassword(aBuffer.makeStringAndClear()); + } +-- +2.37.1 + diff --git a/debian/patches/0003-CVE-2022-26306-add-Initialization-Vectors-to-passwor.patch b/debian/patches/0003-CVE-2022-26306-add-Initialization-Vectors-to-passwor.patch new file mode 100644 index 000000000..b65b3530c --- /dev/null +++ b/debian/patches/0003-CVE-2022-26306-add-Initialization-Vectors-to-passwor.patch @@ -0,0 +1,583 @@ +From e809625c2ca9f0c026aab9b5c2d13ced628c13e9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Tue, 22 Mar 2022 17:22:22 +0000 +Subject: [PATCH 3/4] CVE-2022-26306 add Initialization Vectors to password + storage + +old ones default to the current all zero case and continue to work +as before + +Change-Id: I6fe3b02fafcce1b5e7133e77e76a5118177d77af +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131974 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 192fa1e3bfc6269f2ebb91716471485a56074aea) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132306 +Reviewed-by: Thorsten Behrens +(cherry picked from commit ab77587ec300f5c30084471000663c46ddf25dad) +--- + .../schema/org/openoffice/Office/Common.xcs | 10 ++ + .../passwordcontainer/passwordcontainer.cxx | 127 ++++++++++++------ + .../passwordcontainer/passwordcontainer.hxx | 63 +++++++-- + 3 files changed, 151 insertions(+), 49 deletions(-) + +diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +index 922efc33cca7..8d87d00d5369 100644 +--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs ++++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +@@ -27,6 +27,11 @@ + + Contains a container for passwords. + ++ ++ ++ Contains an initialization vector for the password encryption. ++ ++ + + + Contains a password encoded with the master password. +@@ -954,6 +959,11 @@ + + false + ++ ++ ++ Contains an initialization vector for the master password encryption. ++ ++ + + + Contains the master password encrypted by itself. +diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx +index b674844f91d3..ef79470a2cb6 100644 +--- a/svl/source/passwordcontainer/passwordcontainer.cxx ++++ b/svl/source/passwordcontainer/passwordcontainer.cxx +@@ -181,15 +181,18 @@ PassMap StorageItem::getInfo() + + Sequence< OUString > aNodeNames = ConfigItem::GetNodeNames( "Store" ); + sal_Int32 aNodeCount = aNodeNames.getLength(); +- Sequence< OUString > aPropNames( aNodeCount ); ++ Sequence< OUString > aPropNames( aNodeCount * 2); + + std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.begin(), + [](const OUString& rName) -> OUString { + return "Store/Passwordstorage['" + rName + "']/Password"; }); ++ std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.getArray() + aNodeCount, ++ [](const OUString& rName) -> OUString { ++ return "Store/Passwordstorage['" + rName + "']/InitializationVector"; }); + + Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aPropNames ); + +- if( aPropertyValues.getLength() != aNodeCount ) ++ if( aPropertyValues.getLength() != aNodeCount * 2) + { + OSL_FAIL( "Problems during reading" ); + return aResult; +@@ -205,14 +208,16 @@ PassMap StorageItem::getInfo() + OUString aName = aUrlUsr[1]; + + OUString aEPasswd; ++ OUString aIV; + aPropertyValues[aNodeInd] >>= aEPasswd; ++ aPropertyValues[aNodeInd + aNodeCount] >>= aIV; + + PassMap::iterator aIter = aResult.find( aUrl ); + if( aIter != aResult.end() ) +- aIter->second.emplace_back( aName, aEPasswd ); ++ aIter->second.emplace_back( aName, aEPasswd, aIV ); + else + { +- NamePassRecord aNewRecord( aName, aEPasswd ); ++ NamePassRecord aNewRecord( aName, aEPasswd, aIV ); + std::vector< NamePassRecord > listToAdd( 1, aNewRecord ); + + aResult.insert( PairUrlRecord( aUrl, listToAdd ) ); +@@ -276,17 +281,19 @@ sal_Int32 StorageItem::getStorageVersion() + return nResult; + } + +-bool StorageItem::getEncodedMP( OUString& aResult ) ++bool StorageItem::getEncodedMP( OUString& aResult, OUString& aResultIV ) + { + if( hasEncoded ) + { + aResult = mEncoded; ++ aResultIV = mEncodedIV; + return true; + } + +- Sequence< OUString > aNodeNames( 2 ); ++ Sequence< OUString > aNodeNames( 3 ); + aNodeNames[0] = "HasMaster"; + aNodeNames[1] = "Master"; ++ aNodeNames[2] = "MasterInitializationVector"; + + Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aNodeNames ); + +@@ -298,32 +305,37 @@ bool StorageItem::getEncodedMP( OUString& aResult ) + + aPropertyValues[0] >>= hasEncoded; + aPropertyValues[1] >>= mEncoded; ++ aPropertyValues[2] >>= mEncodedIV; + + aResult = mEncoded; ++ aResultIV = mEncodedIV; + + return hasEncoded; + } + + +-void StorageItem::setEncodedMP( const OUString& aEncoded, bool bAcceptEmpty ) ++void StorageItem::setEncodedMP( const OUString& aEncoded, const OUString& aEncodedIV, bool bAcceptEmpty ) + { +- Sequence< OUString > sendNames(3); +- Sequence< uno::Any > sendVals(3); ++ Sequence< OUString > sendNames(4); ++ Sequence< uno::Any > sendVals(4); + + sendNames[0] = "HasMaster"; + sendNames[1] = "Master"; +- sendNames[2] = "StorageVersion"; ++ sendNames[2] = "MasterInitializationVector"; ++ sendNames[3] = "StorageVersion"; + + bool bHasMaster = ( !aEncoded.isEmpty() || bAcceptEmpty ); + sendVals[0] <<= bHasMaster; + sendVals[1] <<= aEncoded; +- sendVals[2] <<= nCurrentStorageVersion; ++ sendVals[2] <<= aEncodedIV; ++ sendVals[3] <<= nCurrentStorageVersion; + + ConfigItem::SetModified(); + ConfigItem::PutProperties( sendNames, sendVals ); + + hasEncoded = bHasMaster; + mEncoded = aEncoded; ++ mEncodedIV = aEncodedIV; + } + + +@@ -359,11 +371,13 @@ void StorageItem::update( const OUString& aURL, const NamePassRecord& aRecord ) + forIndex.push_back( aURL ); + forIndex.push_back( aRecord.GetUserName() ); + +- Sequence< beans::PropertyValue > sendSeq(1); ++ Sequence< beans::PropertyValue > sendSeq(2); + +- sendSeq[0].Name = "Store/Passwordstorage['" + createIndex( forIndex ) + "']/Password"; ++ sendSeq[0].Name = "Store/Passwordstorage['" + createIndex( forIndex ) + "']/InitializationVector"; ++ sendSeq[0].Value <<= aRecord.GetPersistentIV(); + +- sendSeq[0].Value <<= aRecord.GetPersPasswords(); ++ sendSeq[1].Name = "Store/Passwordstorage['" + createIndex( forIndex ) + "']/Password"; ++ sendSeq[1].Value <<= aRecord.GetPersPasswords(); + + ConfigItem::SetModified(); + ConfigItem::SetSetProperties( "Store", sendSeq ); +@@ -424,7 +438,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& ) + } + } + +-std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode ) ++std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode ) + { + if( !aMasterPasswd.isEmpty() ) + { +@@ -439,9 +453,16 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin + for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) + code[ ind ] = static_cast(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16)); + ++ unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0}; ++ if (!aIV.isEmpty()) ++ { ++ for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) ++ iv[ ind ] = static_cast(aIV.copy( ind*2, 2 ).toUInt32(16)); ++ } ++ + rtlCipherError result = rtl_cipher_init ( + aDecoder, rtl_Cipher_DirectionDecode, +- code, RTL_DIGEST_LENGTH_MD5, nullptr, 0 ); ++ code, RTL_DIGEST_LENGTH_MD5, iv, RTL_DIGEST_LENGTH_MD5 ); + + if( result == rtl_Cipher_E_None ) + { +@@ -474,7 +495,7 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin + "Can't decode!", css::uno::Reference(), mode); + } + +-OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPasswd ) ++OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPasswd) + { + if( !aMasterPasswd.isEmpty() ) + { +@@ -491,9 +512,16 @@ OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines + for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) + code[ ind ] = static_cast(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16)); + ++ unsigned char iv[RTL_DIGEST_LENGTH_MD5] = {0}; ++ if (!aIV.isEmpty()) ++ { ++ for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ ) ++ iv[ ind ] = static_cast(aIV.copy( ind*2, 2 ).toUInt32(16)); ++ } ++ + rtlCipherError result = rtl_cipher_init ( + aEncoder, rtl_Cipher_DirectionEncode, +- code, RTL_DIGEST_LENGTH_MD5, nullptr, 0 ); ++ code, RTL_DIGEST_LENGTH_MD5, iv, RTL_DIGEST_LENGTH_MD5 ); + + if( result == rtl_Cipher_E_None ) + { +@@ -561,7 +589,7 @@ void PasswordContainer::UpdateVector( const OUString& aURL, std::vector< NamePas + + if( aRecord.HasPasswords( PERSISTENT_RECORD ) ) + { +- aNPIter.SetPersPasswords( aRecord.GetPersPasswords() ); ++ aNPIter.SetPersPasswords( aRecord.GetPersPasswords(), aRecord.GetPersistentIV() ); + + if( writeFile ) + { +@@ -594,7 +622,8 @@ UserRecord PasswordContainer::CopyToUserRecord( const NamePassRecord& aRecord, b + { + try + { +- ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ); ++ ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), aRecord.GetPersistentIV(), ++ GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ); + aPasswords.insert( aPasswords.end(), aDecodedPasswords.begin(), aDecodedPasswords.end() ); + } + catch( NoMasterException& ) +@@ -639,6 +668,19 @@ void SAL_CALL PasswordContainer::addPersistent( const OUString& Url, const OUStr + PrivateAdd( Url, UserName, Passwords, PERSISTENT_RECORD, aHandler ); + } + ++OUString PasswordContainer::createIV() ++{ ++ rtlRandomPool randomPool = mRandomPool.get(); ++ unsigned char iv[RTL_DIGEST_LENGTH_MD5]; ++ rtl_random_getBytes(randomPool, iv, RTL_DIGEST_LENGTH_MD5); ++ OUStringBuffer aBuffer; ++ for (sal_uInt8 i : iv) ++ { ++ aBuffer.append(OUString::number(i >> 4, 16)); ++ aBuffer.append(OUString::number(i & 15, 16)); ++ } ++ return aBuffer.makeStringAndClear(); ++} + + void PasswordContainer::PrivateAdd( const OUString& Url, const OUString& UserName, const Sequence< OUString >& Passwords, char Mode, const Reference< XInteractionHandler >& aHandler ) + { +@@ -646,7 +688,11 @@ void PasswordContainer::PrivateAdd( const OUString& Url, const OUString& UserNam + ::std::vector< OUString > aStorePass = comphelper::sequenceToContainer< std::vector >( Passwords ); + + if( Mode == PERSISTENT_RECORD ) +- aRecord.SetPersPasswords( EncodePasswords( aStorePass, GetMasterPassword( aHandler ) ) ); ++ { ++ OUString sIV = createIV(); ++ OUString sEncodedPasswords = EncodePasswords( aStorePass, sIV, GetMasterPassword( aHandler ) ); ++ aRecord.SetPersPasswords( sEncodedPasswords, sIV ); ++ } + else if( Mode == MEMORY_RECORD ) + aRecord.SetMemPasswords( aStorePass ); + else +@@ -839,10 +885,10 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac + + if( m_aMasterPasswd.isEmpty() && aHandler.is() ) + { +- OUString aEncodedMP; ++ OUString aEncodedMP, aEncodedMPIV; + bool bDefaultPassword = false; + +- if( !m_pStorageFile->getEncodedMP( aEncodedMP ) ) ++ if( !m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) + aRMode = PasswordRequestMode_PASSWORD_CREATE; + else if ( aEncodedMP.isEmpty() ) + { +@@ -864,14 +910,15 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac + m_aMasterPasswd = aPass; + std::vector< OUString > aMaster( 1, m_aMasterPasswd ); + +- m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, m_aMasterPasswd ) ); ++ OUString sIV = createIV(); ++ m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, sIV, m_aMasterPasswd ), sIV ); + } + else + { + if (m_pStorageFile->getStorageVersion() == 0) + aPass = ReencodeAsOldHash(aPass); + +- std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass, aRMode ) ); ++ std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aEncodedMPIV, aPass, aRMode ) ); + if( aRM.empty() || aPass != aRM[0] ) + { + bAskAgain = true; +@@ -1028,7 +1075,8 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere + { + sal_Int32 oldLen = aUsers.getLength(); + aUsers.realloc( oldLen + 1 ); +- aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) ); ++ aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), aNP.GetPersistentIV(), ++ GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) ); + } + + if( aUsers.hasElements() ) +@@ -1045,12 +1093,12 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere + sal_Bool SAL_CALL PasswordContainer::authorizateWithMasterPassword( const uno::Reference< task::XInteractionHandler >& xHandler ) + { + bool bResult = false; +- OUString aEncodedMP; ++ OUString aEncodedMP, aEncodedMPIV; + uno::Reference< task::XInteractionHandler > xTmpHandler = xHandler; + ::osl::MutexGuard aGuard( mMutex ); + + // the method should fail if there is no master password +- if( m_pStorageFile && m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) ) ++ if( m_pStorageFile && m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) + { + if ( aEncodedMP.isEmpty() ) + { +@@ -1118,8 +1166,8 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference< + + bool bCanChangePassword = true; + // if there is already a stored master password it should be entered by the user before the change happen +- OUString aEncodedMP; +- if( !m_aMasterPasswd.isEmpty() || m_pStorageFile->getEncodedMP( aEncodedMP ) ) ++ OUString aEncodedMP, aEncodedMPIV; ++ if( !m_aMasterPasswd.isEmpty() || m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ) + bCanChangePassword = authorizateWithMasterPassword( xTmpHandler ); + + if ( bCanChangePassword ) +@@ -1138,7 +1186,8 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference< + // store the new master password + m_aMasterPasswd = aPass; + std::vector< OUString > aMaster( 1, m_aMasterPasswd ); +- m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, m_aMasterPasswd ) ); ++ OUString aIV = createIV(); ++ m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, aIV, m_aMasterPasswd ), aIV ); + + // store all the entries with the new password + for ( const auto& rURL : aPersistent ) +@@ -1163,7 +1212,7 @@ void SAL_CALL PasswordContainer::removeMasterPassword() + if ( m_pStorageFile ) + { + m_aMasterPasswd.clear(); +- m_pStorageFile->setEncodedMP( OUString() ); // let the master password be removed from configuration ++ m_pStorageFile->setEncodedMP( OUString(), OUString() ); // let the master password be removed from configuration + } + } + +@@ -1174,8 +1223,8 @@ sal_Bool SAL_CALL PasswordContainer::hasMasterPassword( ) + if ( !m_pStorageFile ) + throw uno::RuntimeException(); + +- OUString aEncodedMP; +- return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) ); ++ OUString aEncodedMP, aEncodedMPIV; ++ return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) ); + } + + sal_Bool SAL_CALL PasswordContainer::allowPersistentStoring( sal_Bool bAllow ) +@@ -1222,8 +1271,8 @@ sal_Bool SAL_CALL PasswordContainer::useDefaultMasterPassword( const uno::Refere + + bool bCanChangePassword = true; + // if there is already a stored nondefault master password it should be entered by the user before the change happen +- OUString aEncodedMP; +- if( m_pStorageFile->getEncodedMP( aEncodedMP ) && !aEncodedMP.isEmpty() ) ++ OUString aEncodedMP, aEncodedMPIV; ++ if( m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) && !aEncodedMP.isEmpty() ) + bCanChangePassword = authorizateWithMasterPassword( xTmpHandler ); + + if ( bCanChangePassword ) +@@ -1240,7 +1289,7 @@ sal_Bool SAL_CALL PasswordContainer::useDefaultMasterPassword( const uno::Refere + + // store the empty string to flag the default master password + m_aMasterPasswd = aPass; +- m_pStorageFile->setEncodedMP( OUString(), true ); ++ m_pStorageFile->setEncodedMP( OUString(), OUString(), true ); + + // store all the entries with the new password + for ( const auto& rURL : aPersistent ) +@@ -1264,8 +1313,8 @@ sal_Bool SAL_CALL PasswordContainer::isDefaultMasterPasswordUsed() + if ( !m_pStorageFile ) + throw uno::RuntimeException(); + +- OUString aEncodedMP; +- return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP ) && aEncodedMP.isEmpty() ); ++ OUString aEncodedMP, aEncodedMPIV; ++ return ( m_pStorageFile->useStorage() && m_pStorageFile->getEncodedMP( aEncodedMP, aEncodedMPIV ) && aEncodedMP.isEmpty() ); + } + + +diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx +index bf43b5903602..0454437b9dc2 100644 +--- a/svl/source/passwordcontainer/passwordcontainer.hxx ++++ b/svl/source/passwordcontainer/passwordcontainer.hxx +@@ -34,6 +34,7 @@ + #include + #include + ++#include + #include + #include + +@@ -52,11 +53,12 @@ class NamePassRecord + ::std::vector< OUString > m_aMemPass; + + // persistent passwords are encrypted in one string +- bool m_bHasPersPass; ++ bool m_bHasPersPass; + OUString m_aPersPass; ++ OUString m_aPersistentIV; + + void InitArrays( bool bHasMemoryList, const ::std::vector< OUString >& aMemoryList, +- bool bHasPersistentList, const OUString& aPersistentList ) ++ bool bHasPersistentList, const OUString& aPersistentList, const OUString& aPersistentIV ) + { + m_bHasMemPass = bHasMemoryList; + if ( bHasMemoryList ) +@@ -64,7 +66,10 @@ class NamePassRecord + + m_bHasPersPass = bHasPersistentList; + if ( bHasPersistentList ) ++ { + m_aPersPass = aPersistentList; ++ m_aPersistentIV = aPersistentIV; ++ } + } + + public: +@@ -76,11 +81,12 @@ public: + { + } + +- NamePassRecord( const OUString& aName, const OUString& aPersistentList ) ++ NamePassRecord( const OUString& aName, const OUString& aPersistentList, const OUString& aPersistentIV ) + : m_aName( aName ) + , m_bHasMemPass( false ) + , m_bHasPersPass( true ) + , m_aPersPass( aPersistentList ) ++ , m_aPersistentIV( aPersistentIV ) + { + } + +@@ -89,7 +95,8 @@ public: + , m_bHasMemPass( false ) + , m_bHasPersPass( false ) + { +- InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass ); ++ InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, ++ aRecord.m_bHasPersPass, aRecord.m_aPersPass, aRecord.m_aPersistentIV ); + } + + NamePassRecord& operator=( const NamePassRecord& aRecord ) +@@ -100,7 +107,9 @@ public: + + m_aMemPass.clear(); + m_aPersPass.clear(); +- InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass ); ++ m_aPersistentIV.clear(); ++ InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, ++ aRecord.m_bHasPersPass, aRecord.m_aPersPass, aRecord.m_aPersistentIV ); + } + return *this; + } +@@ -136,15 +145,24 @@ public: + return OUString(); + } + ++ OUString GetPersistentIV() const ++ { ++ if ( m_bHasPersPass ) ++ return m_aPersistentIV; ++ ++ return OUString(); ++ } ++ + void SetMemPasswords( const ::std::vector< OUString >& aMemList ) + { + m_aMemPass = aMemList; + m_bHasMemPass = true; + } + +- void SetPersPasswords( const OUString& aPersList ) ++ void SetPersPasswords( const OUString& aPersList, const OUString& aPersIV ) + { + m_aPersPass = aPersList; ++ m_aPersistentIV = aPersIV; + m_bHasPersPass = true; + } + +@@ -159,6 +177,7 @@ public: + { + m_bHasPersPass = false; + m_aPersPass.clear(); ++ m_aPersistentIV.clear(); + } + } + +@@ -182,6 +201,7 @@ private: + PasswordContainer* mainCont; + bool hasEncoded; + OUString mEncoded; ++ OUString mEncodedIV; + + virtual void ImplCommit() override; + +@@ -201,8 +201,8 @@ + + sal_Int32 getStorageVersion(); + +- bool getEncodedMP( OUString& aResult ); +- void setEncodedMP( const OUString& aResult, bool bAcceptEnmpty = false ); ++ bool getEncodedMP( OUString& aResult, OUString& aResultIV ); ++ void setEncodedMP( const OUString& aResult, const OUString& aResultIV, bool bAcceptEmpty = false ); + void setUseStorage( bool bUse ); + bool useStorage(); + +@@ -224,6 +244,29 @@ private: + css::uno::Reference< css::lang::XComponent > mComponent; + SysCredentialsConfig mUrlContainer; + ++ class RandomPool ++ { ++ private: ++ rtlRandomPool m_aRandomPool; ++ public: ++ RandomPool() : m_aRandomPool(rtl_random_createPool()) ++ { ++ } ++ rtlRandomPool get() ++ { ++ return m_aRandomPool; ++ } ++ ~RandomPool() ++ { ++ // Clean up random pool memory ++ rtl_random_destroyPool(m_aRandomPool); ++ } ++ }; ++ ++ RandomPool mRandomPool; ++ ++ OUString createIV(); ++ + /// @throws css::uno::RuntimeException + css::uno::Sequence< css::task::UserRecord > CopyToUserRecordSequence( + const ::std::vector< NamePassRecord >& original, +@@ -274,10 +317,10 @@ css::task::UrlRecord find( + const css::uno::Reference< css::task::XInteractionHandler >& Handler ); + + /// @throws css::uno::RuntimeException +- static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword, css::task::PasswordRequestMode mode ); ++ static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aIV, const OUString& aMasterPassword, css::task::PasswordRequestMode mode ); + + /// @throws css::uno::RuntimeException +- static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPassword ); ++ static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aIV, const OUString& aMasterPassword ); + + public: + PasswordContainer( const css::uno::Reference< css::lang::XMultiServiceFactory >& ); +-- +2.37.1 + diff --git a/debian/patches/0004-CVE-2022-2630-6-7-add-infobar-to-prompt-to-refresh-t.patch b/debian/patches/0004-CVE-2022-2630-6-7-add-infobar-to-prompt-to-refresh-t.patch new file mode 100644 index 000000000..fd02eb7bb --- /dev/null +++ b/debian/patches/0004-CVE-2022-2630-6-7-add-infobar-to-prompt-to-refresh-t.patch @@ -0,0 +1,117 @@ +From 4cfd591942e4cfd3efc416bfac8e46e3580d37ba Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Wed, 23 Mar 2022 13:03:30 +0000 +Subject: add infobar to prompt to refresh to replace old format + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131976 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit bbd196ff82bda9f66b4ba32a412f10cefe6da60e) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132307 +Reviewed-by: Sophie Gautier +Reviewed-by: Christian Lohmaier +(cherry picked from commit c5d01b11db3c83cb4a89d3b388d78e20dd3990b5) + +Change-Id: Id99cbf2b50a4ebf289dae6fc67e22e20afcda35b +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133906 +Tested-by: Michael Stahl +Reviewed-by: Michael Stahl +--- + include/sfx2/strings.hrc | 2 ++ + include/sfx2/viewfrm.hxx | 1 + + sfx2/source/view/viewfrm.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 43 insertions(+) + +diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc +index 1f21f0a0f186..1db36e733c0c 100644 +--- a/include/sfx2/strings.hrc ++++ b/include/sfx2/strings.hrc +@@ -297,6 +297,8 @@ + #define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.") + #define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.") + #define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures") ++#define STR_REFRESH_MASTER_PASSWORD NC_("STR_REFRESH_MASTER_PASSWORD", "The master password is stored in an outdated format, you should refresh it") ++#define STR_REFRESH_PASSWORD NC_("STR_REFRESH_PASSWORD", "Refresh Password") + + #define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane") + #define STR_SFX_DOCK NC_("STR_SFX_DOCK", "Dock") +diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx +index fe336ba5f091..cc6a7dae7047 100644 +--- a/include/sfx2/viewfrm.hxx ++++ b/include/sfx2/viewfrm.hxx +@@ -61,6 +61,7 @@ protected: + DECL_LINK(WhatsNewHandler, Button*, void); + DECL_LINK(SwitchReadOnlyHandler, Button*, void); + DECL_LINK(SignDocumentHandler, Button*, void); ++ DECL_DLLPRIVATE_LINK(RefreshMasterPasswordHdl, Button*, void); + SAL_DLLPRIVATE void KillDispatcher_Impl(); + + virtual ~SfxViewFrame() override; +diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx +index 5a64599e5894..86e7d51bbfea 100644 +--- a/sfx2/source/view/viewfrm.cxx ++++ b/sfx2/source/view/viewfrm.cxx +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1390,6 +1391,24 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) + batch->commit(); + } + ++ if (officecfg::Office::Common::Passwords::HasMaster::get() && ++ officecfg::Office::Common::Passwords::StorageVersion::get() == 0) ++ { ++ // master password stored in deprecated format ++ VclPtr pOldMasterPasswordInfoBar = ++ AppendInfoBar("oldmasterpassword", "", ++ SfxResId(STR_REFRESH_MASTER_PASSWORD), InfobarType::DANGER, false); ++ if (pOldMasterPasswordInfoBar) ++ { ++ VclPtrInstance const xBtn(&GetWindow()); ++ xBtn->SetText(SfxResId(STR_REFRESH_PASSWORD)); ++ xBtn->SetSizePixel(xBtn->GetOptimalSize()); ++ xBtn->SetClickHdl(LINK(this, ++ SfxViewFrame, RefreshMasterPasswordHdl)); ++ pOldMasterPasswordInfoBar->addButton(xBtn); ++ } ++ } ++ + // read-only infobar if necessary + const SfxViewShell *pVSh; + const SfxShell *pFSh; +@@ -1565,6 +1584,27 @@ IMPL_LINK_NOARG(SfxViewFrame, SignDocumentHandler, Button*, void) + GetDispatcher()->Execute(SID_SIGNATURE); + } + ++IMPL_LINK_NOARG(SfxViewFrame, RefreshMasterPasswordHdl, Button*, void) ++{ ++ bool bChanged = false; ++ try ++ { ++ Reference< task::XPasswordContainer2 > xMasterPasswd( ++ task::PasswordContainer::create(comphelper::getProcessComponentContext())); ++ ++ css::uno::Reference xFrame = GetFrame().GetFrameInterface(); ++ css::uno::Reference xContainerWindow = xFrame->getContainerWindow(); ++ ++ uno::Reference xTmpHandler(task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), ++ xContainerWindow)); ++ bChanged = xMasterPasswd->changeMasterPassword(xTmpHandler); ++ } ++ catch (const Exception&) ++ {} ++ if (bChanged) ++ RemoveInfoBar(u"oldmasterpassword"); ++} ++ + void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) + { + m_pImpl->bResizeInToOut = true; +-- +cgit v1.2.1 + diff --git a/debian/patches/CVE-2023-2255.diff b/debian/patches/CVE-2023-2255.diff new file mode 100644 index 000000000..4edfe0cdb --- /dev/null +++ b/debian/patches/CVE-2023-2255.diff @@ -0,0 +1,943 @@ +From 683e4de0de8dde7c5570c67cbd2bae17b6d7f0e0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Tue, 11 Apr 2023 10:13:37 +0100 +Subject: set Referer on loading IFrames + +so tools, options, security, options, +"block any links from document not..." +applies to their contents. + +Change-Id: I04839aea6b07a4a76ac147a85045939ccd9c3c79 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150225 +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +--- + sfx2/source/doc/iframe.cxx | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +From 49a554471cddc3e52ae381f864e689fe4a8c6131 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 13 Apr 2023 11:31:17 +0100 +Subject: put floating frames under managed links control +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +like we do for sections and ole objects that link to their content + +individual commits in trunk are: + +extract a OCommonEmbeddedObject::SetInplaceActiveState for reuse + +no behaviour change intended + +Change-Id: Ia1d12aa5c9afdc1347f6d4364bc6a0b7f41ee168 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150341 +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit 183e34a3f8c429c0698951e24c17844e416a3825) + +use parent window as dialog parent + +it makes no odds, but is more convenient for upcoming modification + +Change-Id: Ibc5333b137d2da089b3b701ff615c6ddf43063d0 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150342 +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit f93edf343658abd489bde3639d2ffaefd50c0f99) + +adjust IFrameObject so it could reuse mxFrame for a reload of content + +Change-Id: I7eec3132a23faafd9a2878215a0a117a67bc9bf2 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150343 +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit 3a727d26fd9eb6fa140bc3f5cadf3db079d42206) + +query getUserAllowsLinkUpdate for the case of content in a floating frame + +similarly to how it works for the more common "normal" embedded objects + +Change-Id: I83e38dfa2f84907c2de9680e91f779d34864a9ad +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149971 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 52aa46468531918eabfa2031dedf50377ae72cf7) + +add a route to get writer Floating Frame links under 'manage links' + +Change-Id: If90ff71d6a96342574799312f764badaf97980eb +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150349 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 8b8a2844addbd262befb1a2d193dfb590dfa20be) + +allow SvxOle2Shape::resetModifiedState to survive having no SdrObject + +Change-Id: Iea059262c124e3f44249e49b4189732310d28156 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150538 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 02379929bd0e1d1676635f0ca1920422702ebb7c) + +create the FloatingFrameShape in a separate step to inserting it + +this is derived from the path taken by the AddShape(const OUString&) +function for this case. No change in behavior is intended. + +Change-Id: Id09ae0c65a55a37743ad7c184070fb8dd97d8a7f +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150526 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit bafec47847a0b9697b3bbe9358e53f8118af3024) + +add a route to get calc Floating Frame links under 'manage links' + +much harder than writer because the organization and ordering +of properties and object activation etc is different. + +This ended up ugly, but functions. + +We set FrameURL before AddShape, we have to do it again later because it +gets cleared when the SdrOle2Obj is attached to the XShape. But we want +FrameURL to exist when AddShape triggers SetPersistName which itself +triggers SdrOle2Obj::CheckFileLink_Impl and at that point we want to +know what URL will end up being used. So bodge this by setting FrameURL +to the temp pre-SdrOle2Obj attached properties and we can smuggle it +eventually into SdrOle2Obj::SetPersistName at the right point after +PersistName is set but before SdrOle2Obj::CheckFileLink_Impl is called +in order to inform the link manager that this is an IFrame that links to +a URL + +Change-Id: I67fc199fef9e67fa12ca7873f0fe12137aa16d8f +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150539 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 07179a5a5bd00f34acfa8a3f260dd834ae003c63) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150753 +Reviewed-by: Michael Stahl +--- + embeddedobj/source/commonembedding/embedobj.cxx | 60 ++++++------ + .../source/commonembedding/specialobject.cxx | 9 ++ + embeddedobj/source/inc/commonembobj.hxx | 3 + + embeddedobj/source/inc/specialobject.hxx | 6 ++ + include/svx/svdoole2.hxx | 17 +++- + include/svx/unoshape.hxx | 2 + + sc/source/ui/docshell/documentlinkmgr.cxx | 9 +- + sfx2/source/doc/iframe.cxx | 55 +++++++---- + svx/source/svdraw/svdoole2.cxx | 104 +++++++++++++++++---- + svx/source/unodraw/shapeimpl.hxx | 5 + + svx/source/unodraw/unoshap4.cxx | 23 ++++- + sw/inc/ndole.hxx | 4 +- + sw/source/core/ole/ndole.cxx | 89 ++++++++++++++++-- + xmloff/source/draw/ximpshap.cxx | 29 +++++- + xmloff/source/draw/ximpshap.hxx | 2 + + 15 files changed, 331 insertions(+), 86 deletions(-) + +From 26a8966b07f6335450ddbf4b0f5d5206db43bcbf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 20 Apr 2023 20:58:21 +0100 +Subject: assume IFrame script/macro support isn't needed + +seems undocumented at least + +Change-Id: I316e4f4f25ddb7cf6b7bac4d856a721b987207a3 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151019 +Tested-by: Jenkins +Reviewed-by: Xisco Fauli +--- + sfx2/source/doc/iframe.cxx | 15 ++++----------- + sfx2/source/inc/eventsupplier.hxx | 1 + + 2 files changed, 5 insertions(+), 11 deletions(-) + +diff -urN libreoffice-7-0-4.old/embeddedobj/source/commonembedding/embedobj.cxx libreoffice-7-0-4/embeddedobj/source/commonembedding/embedobj.cxx +--- libreoffice-7-0-4.old/embeddedobj/source/commonembedding/embedobj.cxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/embeddedobj/source/commonembedding/embedobj.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -155,6 +155,37 @@ + rGuard.reset(); + } + ++void OCommonEmbeddedObject::SetInplaceActiveState() ++{ ++ if ( !m_xClientSite.is() ) ++ throw embed::WrongStateException( "client site not set, yet", *this ); ++ ++ uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); ++ if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() ) ++ throw embed::WrongStateException(); //TODO: can't activate inplace ++ xInplaceClient->activatingInplace(); ++ ++ uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW ); ++ ++ m_xClientWindow = xClientWindowSupplier->getWindow(); ++ m_aOwnRectangle = xInplaceClient->getPlacement(); ++ m_aClipRectangle = xInplaceClient->getClipRectangle(); ++ awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle ); ++ ++ // create own window based on the client window ++ // place and resize the window according to the rectangles ++ uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW ); ++ ++ // dispatch provider may not be provided ++ uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); ++ bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP ); ++ m_nObjectState = embed::EmbedStates::INPLACE_ACTIVE; ++ if ( !bOk ) ++ { ++ SwitchStateTo_Impl( embed::EmbedStates::RUNNING ); ++ throw embed::WrongStateException(); //TODO: can't activate inplace ++ } ++} + + void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState ) + { +@@ -228,34 +259,7 @@ + { + if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE ) + { +- if ( !m_xClientSite.is() ) +- throw embed::WrongStateException( "client site not set, yet", *this ); +- +- uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); +- if ( !xInplaceClient.is() || !xInplaceClient->canInplaceActivate() ) +- throw embed::WrongStateException(); //TODO: can't activate inplace +- xInplaceClient->activatingInplace(); +- +- uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY_THROW ); +- +- m_xClientWindow = xClientWindowSupplier->getWindow(); +- m_aOwnRectangle = xInplaceClient->getPlacement(); +- m_aClipRectangle = xInplaceClient->getClipRectangle(); +- awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle ); +- +- // create own window based on the client window +- // place and resize the window according to the rectangles +- uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY_THROW ); +- +- // dispatch provider may not be provided +- uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider(); +- bool bOk = m_xDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP ); +- m_nObjectState = nNextState; +- if ( !bOk ) +- { +- SwitchStateTo_Impl( embed::EmbedStates::RUNNING ); +- throw embed::WrongStateException(); //TODO: can't activate inplace +- } ++ SetInplaceActiveState(); + } + else if ( nNextState == embed::EmbedStates::ACTIVE ) + { +diff -urN libreoffice-7-0-4.old/embeddedobj/source/commonembedding/specialobject.cxx libreoffice-7-0-4/embeddedobj/source/commonembedding/specialobject.cxx +--- libreoffice-7-0-4.old/embeddedobj/source/commonembedding/specialobject.cxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/embeddedobj/source/commonembedding/specialobject.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -47,6 +47,7 @@ + uno::Any aReturn = ::cppu::queryInterface( rType, + static_cast< embed::XEmbeddedObject* >( this ), + static_cast< embed::XInplaceObject* >( this ), ++ static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ), + static_cast< embed::XVisualObject* >( this ), + static_cast< embed::XClassifiedObject* >( this ), + static_cast< embed::XComponentSupplier* >( this ), +@@ -160,4 +161,12 @@ + OCommonEmbeddedObject::doVerb( nVerbID ); + } + ++void SAL_CALL OSpecialEmbeddedObject::reload( ++ const uno::Sequence< beans::PropertyValue >&, ++ const uno::Sequence< beans::PropertyValue >&) ++{ ++ // Allow IFrames to reload their content ++ SetInplaceActiveState(); ++} ++ + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff -urN libreoffice-7-0-4.old/embeddedobj/source/inc/commonembobj.hxx libreoffice-7-0-4/embeddedobj/source/inc/commonembobj.hxx +--- libreoffice-7-0-4.old/embeddedobj/source/inc/commonembobj.hxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/embeddedobj/source/inc/commonembobj.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -227,6 +227,9 @@ + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ); + ++protected: ++ void SetInplaceActiveState(); ++ + public: + OCommonEmbeddedObject( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, +diff -urN libreoffice-7-0-4.old/embeddedobj/source/inc/specialobject.hxx libreoffice-7-0-4/embeddedobj/source/inc/specialobject.hxx +--- libreoffice-7-0-4.old/embeddedobj/source/inc/specialobject.hxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/embeddedobj/source/inc/specialobject.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -48,6 +48,12 @@ + virtual void SAL_CALL changeState( sal_Int32 nNewState ) override; + + virtual void SAL_CALL doVerb( sal_Int32 nVerbID ) override; ++ ++// XCommonEmbedPersist ++ ++ virtual void SAL_CALL reload( ++ const css::uno::Sequence< css::beans::PropertyValue >& lArguments, ++ const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; + }; + + #endif +diff -urN libreoffice-7-0-4.old/include/svx/svdoole2.hxx libreoffice-7-0-4/include/svx/svdoole2.hxx +--- libreoffice-7-0-4.old/include/svx/svdoole2.hxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/include/svx/svdoole2.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -42,6 +42,7 @@ + namespace svt { class EmbeddedObjectRef; } + + class SdrOle2ObjImpl; ++class SvxOle2Shape; + + class SVXCORE_DLLPUBLIC SdrOle2Obj : public SdrRectObj + { +@@ -49,7 +50,7 @@ + std::unique_ptr mpImpl; + + private: +- SVX_DLLPRIVATE void Connect_Impl(); ++ SVX_DLLPRIVATE void Connect_Impl(SvxOle2Shape* pCreator = nullptr); + SVX_DLLPRIVATE void Disconnect_Impl(); + SVX_DLLPRIVATE void AddListeners_Impl(); + SVX_DLLPRIVATE void RemoveListeners_Impl(); +@@ -105,7 +106,7 @@ + // OLE object has got a separate PersistName member now; + // !!! use ::SetPersistName( ... ) only, if you know what you do !!! + const OUString& GetPersistName() const; +- void SetPersistName( const OUString& rPersistName ); ++ void SetPersistName( const OUString& rPersistName, SvxOle2Shape* pCreator = nullptr ); + + // One can add an application name to a SdrOle2Obj, which can be queried for + // later on (SD needs this for presentation objects). +@@ -153,7 +154,7 @@ + sal_Int64 nAspect ); + static bool Unload( const css::uno::Reference< css::embed::XEmbeddedObject >& xObj, sal_Int64 nAspect ); + bool Unload(); +- void Connect(); ++ void Connect(SvxOle2Shape* pCreator = nullptr); + void Disconnect(); + void ObjectLoaded(); + +@@ -200,6 +201,16 @@ + void Connect() { GetRealObject(); } + }; + ++class SVXCORE_DLLPUBLIC SdrIFrameLink final : public sfx2::SvBaseLink ++{ ++ SdrOle2Obj* m_pObject; ++ ++public: ++ explicit SdrIFrameLink(SdrOle2Obj* pObject); ++ virtual ::sfx2::SvBaseLink::UpdateResult DataChanged( ++ const OUString& rMimeType, const css::uno::Any & rValue ) override; ++}; ++ + #endif // INCLUDED_SVX_SVDOOLE2_HXX + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff -urN libreoffice-7-0-4.old/include/svx/unoshape.hxx libreoffice-7-0-4/include/svx/unoshape.hxx +--- libreoffice-7-0-4.old/include/svx/unoshape.hxx 2023-05-24 17:17:08.688721561 +0200 ++++ libreoffice-7-0-4/include/svx/unoshape.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -607,6 +607,8 @@ + bool createObject( const SvGlobalName &aClassName ); + + void createLink( const OUString& aLinkURL ); ++ ++ virtual OUString GetAndClearInitialFrameURL(); + }; + + +diff -urN libreoffice-7-0-4.old/sc/source/ui/docshell/documentlinkmgr.cxx libreoffice-7-0-4/sc/source/ui/docshell/documentlinkmgr.cxx +--- libreoffice-7-0-4.old/sc/source/ui/docshell/documentlinkmgr.cxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/sc/source/ui/docshell/documentlinkmgr.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -142,7 +142,7 @@ + sfx2::SvBaseLink* pBase = rLink.get(); + if (bDde && dynamic_cast(pBase)) + return true; +- if (bOle && dynamic_cast(pBase)) ++ if (bOle && (dynamic_cast(pBase) || dynamic_cast(pBase))) + return true; + if (bWebService && dynamic_cast(pBase)) + return true; +@@ -173,6 +173,13 @@ + continue; + } + ++ SdrIFrameLink* pIFrameLink = dynamic_cast(pBase); ++ if (pIFrameLink) ++ { ++ pIFrameLink->Update(); ++ continue; ++ } ++ + ScWebServiceLink* pWebserviceLink = dynamic_cast(pBase); + if (pWebserviceLink) + { +diff -urN libreoffice-7-0-4.old/sfx2/source/doc/iframe.cxx libreoffice-7-0-4/sfx2/source/doc/iframe.cxx +--- libreoffice-7-0-4.old/sfx2/source/doc/iframe.cxx 2023-05-24 17:17:38.000000000 +0200 ++++ libreoffice-7-0-4/sfx2/source/doc/iframe.cxx 2023-05-24 17:26:40.329719103 +0200 +@@ -33,10 +33,12 @@ + #include + #include + ++#include + #include + #include + #include + #include ++#include + #include + #include + #include +@@ -164,41 +166,57 @@ + uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); + xTrans->parseStrict( aTargetURL ); + +- if (INetURLObject(aTargetURL.Complete).GetProtocol() == INetProtocol::Macro) ++ INetURLObject aURLObject(aTargetURL.Complete); ++ if (aURLObject.GetProtocol() == INetProtocol::Macro || aURLObject.isSchemeEqualTo(u"vnd.sun.star.script")) ++ return false; ++ ++ uno::Reference xParentFrame = xFrame->getCreator(); ++ SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); ++ ++ bool bUpdateAllowed(true); ++ if (pDoc) ++ { ++ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pDoc->getEmbeddedObjectContainer(); ++ bUpdateAllowed = rEmbeddedObjectContainer.getUserAllowsLinkUpdate(); ++ } ++ if (!bUpdateAllowed) ++ return false; ++ ++ OUString sReferer; ++ if (pDoc && pDoc->HasName()) ++ sReferer = pDoc->GetMedium()->GetName(); ++ ++ uno::Reference xParentWindow(xFrame->getContainerWindow()); ++ ++ if (!mxFrame.is()) + { +- uno::Reference xParentFrame = xFrame->getCreator(); +- SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); +- if (pDoc && !pDoc->AdjustMacroMode()) +- return false; ++ VclPtr pParent = VCLUnoHelper::GetWindow(xParentWindow); ++ VclPtr pWin = VclPtr::Create( pParent, maFrmDescr.IsFrameBorderOn() ); ++ pWin->SetSizePixel( pParent->GetOutputSizePixel() ); ++ pWin->SetBackground(); ++ pWin->Show(); ++ ++ uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); ++ xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); ++ ++ // we must destroy the IFrame before the parent is destroyed ++ xWindow->addEventListener( this ); ++ ++ mxFrame = frame::Frame::create( mxContext ); ++ uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); ++ mxFrame->initialize( xWin ); ++ mxFrame->setName( maFrmDescr.GetName() ); ++ ++ uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); ++ if ( xFramesSupplier.is() ) ++ mxFrame->setCreator( xFramesSupplier ); + } + +- DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); +- VclPtr pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); +- VclPtr pWin = VclPtr::Create( pParent, maFrmDescr.IsFrameBorderOn() ); +- pWin->SetSizePixel( pParent->GetOutputSizePixel() ); +- pWin->SetBackground(); +- pWin->Show(); +- +- uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); +- xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); +- +- // we must destroy the IFrame before the parent is destroyed +- xWindow->addEventListener( this ); +- +- mxFrame = frame::Frame::create( mxContext ); +- uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); +- mxFrame->initialize( xWin ); +- mxFrame->setName( maFrmDescr.GetName() ); +- +- uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); +- if ( xFramesSupplier.is() ) +- mxFrame->setCreator( xFramesSupplier ); +- +- uno::Sequence < beans::PropertyValue > aProps(2); +- aProps[0].Name = "PluginMode"; +- aProps[0].Value <<= sal_Int16(2); +- aProps[1].Name = "ReadOnly"; +- aProps[1].Value <<= true; ++ uno::Sequence < beans::PropertyValue > aProps{ ++ comphelper::makePropertyValue("PluginMode", sal_Int16(2)), ++ comphelper::makePropertyValue("ReadOnly", true), ++ comphelper::makePropertyValue("Referer", sReferer) ++ }; + uno::Reference < frame::XDispatch > xDisp = mxFrame->queryDispatch( aTargetURL, "_self", 0 ); + if ( xDisp.is() ) + xDisp->dispatch( aTargetURL, aProps ); +diff -urN libreoffice-7-0-4.old/svx/source/svdraw/svdoole2.cxx libreoffice-7-0-4/svx/source/svdraw/svdoole2.cxx +--- libreoffice-7-0-4.old/svx/source/svdraw/svdoole2.cxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/svx/source/svdraw/svdoole2.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -67,6 +67,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -591,6 +592,35 @@ + SvBaseLink::Closed(); + } + ++SdrIFrameLink::SdrIFrameLink(SdrOle2Obj* pObject) ++ : ::sfx2::SvBaseLink(::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB) ++ , m_pObject(pObject) ++{ ++ SetSynchron( false ); ++} ++ ++::sfx2::SvBaseLink::UpdateResult SdrIFrameLink::DataChanged( ++ const OUString&, const uno::Any& ) ++{ ++ uno::Reference xObject = m_pObject->GetObjRef(); ++ uno::Reference xPersObj(xObject, uno::UNO_QUERY); ++ if (xPersObj.is()) ++ { ++ // let the IFrameObject reload the link ++ try ++ { ++ xPersObj->reload(uno::Sequence(), uno::Sequence()); ++ } ++ catch (const uno::Exception&) ++ { ++ } ++ ++ m_pObject->SetChanged(); ++ } ++ ++ return SUCCESS; ++} ++ + class SdrOle2ObjImpl + { + public: +@@ -608,7 +638,7 @@ + bool mbLoadingOLEObjectFailed:1; // New local var to avoid repeated loading if load of OLE2 fails + bool mbConnected:1; + +- SdrEmbedObjectLink* mpObjectLink; ++ sfx2::SvBaseLink* mpObjectLink; + OUString maLinkURL; + + rtl::Reference mxModifyListener; +@@ -808,7 +838,7 @@ + return !mpImpl->mxObjRef.is(); + } + +-void SdrOle2Obj::Connect() ++void SdrOle2Obj::Connect(SvxOle2Shape* pCreator) + { + if( IsEmptyPresObj() ) + return; +@@ -821,7 +851,7 @@ + return; + } + +- Connect_Impl(); ++ Connect_Impl(pCreator); + AddListeners_Impl(); + } + +@@ -920,24 +950,51 @@ + { + try + { +- uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY ); ++ uno::Reference xObject = mpImpl->mxObjRef.GetObject(); ++ if (!xObject) ++ return; ++ ++ bool bIFrame = false; ++ ++ OUString aLinkURL; ++ uno::Reference xLinkSupport(xObject, uno::UNO_QUERY); ++ if (xLinkSupport) ++ { ++ if (xLinkSupport->isLink()) ++ aLinkURL = xLinkSupport->getLinkURL(); ++ } ++ else ++ { ++ // get IFrame (Floating Frames) listed and updatable from the ++ // manage links dialog ++ SvGlobalName aClassId(xObject->getClassID()); ++ if (aClassId == SvGlobalName(SO3_IFRAME_CLASSID)) ++ { ++ uno::Reference xSet(xObject->getComponent(), uno::UNO_QUERY); ++ if (xSet.is()) ++ xSet->getPropertyValue("FrameURL") >>= aLinkURL; ++ bIFrame = true; ++ } ++ } + +- if ( xLinkSupport.is() && xLinkSupport->isLink() ) ++ if (!aLinkURL.isEmpty()) // this is a file link so the model link manager should handle it + { +- OUString aLinkURL = xLinkSupport->getLinkURL(); ++ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager()); + +- if ( !aLinkURL.isEmpty() ) ++ if ( pLinkManager ) + { +- // this is a file link so the model link manager should handle it +- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager()); +- +- if ( pLinkManager ) ++ SdrEmbedObjectLink* pEmbedObjectLink = nullptr; ++ if (!bIFrame) + { +- mpImpl->mpObjectLink = new SdrEmbedObjectLink( this ); +- mpImpl->maLinkURL = aLinkURL; +- pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); +- mpImpl->mpObjectLink->Connect(); ++ pEmbedObjectLink = new SdrEmbedObjectLink(this); ++ mpImpl->mpObjectLink = pEmbedObjectLink; + } ++ else ++ mpImpl->mpObjectLink = new SdrIFrameLink(this); ++ mpImpl->maLinkURL = aLinkURL; ++ pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); ++ if (pEmbedObjectLink) ++ pEmbedObjectLink->Connect(); + } + } + } +@@ -948,7 +1005,7 @@ + } + } + +-void SdrOle2Obj::Connect_Impl() ++void SdrOle2Obj::Connect_Impl(SvxOle2Shape* pCreator) + { + if(!mpImpl->aPersistName.isEmpty() ) + { +@@ -988,6 +1045,17 @@ + } + } + ++ if (pCreator) ++ { ++ OUString sFrameURL(pCreator->GetAndClearInitialFrameURL()); ++ if (!sFrameURL.isEmpty() && svt::EmbeddedObjectRef::TryRunningState(mpImpl->mxObjRef.GetObject())) ++ { ++ uno::Reference xSet(mpImpl->mxObjRef->getComponent(), uno::UNO_QUERY); ++ if (xSet.is()) ++ xSet->setPropertyValue("FrameURL", uno::Any(sFrameURL)); ++ } ++ } ++ + if ( mpImpl->mxObjRef.is() ) + { + if ( !mpImpl->mxLightClient.is() ) +@@ -1301,14 +1369,14 @@ + return createSdrGrafObjReplacement(false); + } + +-void SdrOle2Obj::SetPersistName( const OUString& rPersistName ) ++void SdrOle2Obj::SetPersistName( const OUString& rPersistName, SvxOle2Shape* pCreator ) + { + DBG_ASSERT( mpImpl->aPersistName.isEmpty(), "Persist name changed!"); + + mpImpl->aPersistName = rPersistName; + mpImpl->mbLoadingOLEObjectFailed = false; + +- Connect(); ++ Connect(pCreator); + SetChanged(); + } + +diff -urN libreoffice-7-0-4.old/svx/source/unodraw/shapeimpl.hxx libreoffice-7-0-4/svx/source/unodraw/shapeimpl.hxx +--- libreoffice-7-0-4.old/svx/source/unodraw/shapeimpl.hxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/svx/source/unodraw/shapeimpl.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -64,8 +64,11 @@ + + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override; + }; ++ + class SvxFrameShape : public SvxOle2Shape + { ++private: ++ OUString m_sInitialFrameURL; + protected: + // override these for special property handling in subcasses. Return true if property is handled + virtual bool setPropertyValueImpl( const OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const css::uno::Any& rValue ) override; +@@ -82,6 +85,8 @@ + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override; + + virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override; ++ ++ virtual OUString GetAndClearInitialFrameURL() override; + }; + + +diff -urN libreoffice-7-0-4.old/svx/source/unodraw/unoshap4.cxx libreoffice-7-0-4/svx/source/unodraw/unoshap4.cxx +--- libreoffice-7-0-4.old/svx/source/unodraw/unoshap4.cxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/svx/source/unodraw/unoshap4.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -174,7 +174,7 @@ + #else + pOle = static_cast(GetSdrObject()); + #endif +- pOle->SetPersistName( aPersistName ); ++ pOle->SetPersistName( aPersistName, this ); + return true; + } + break; +@@ -495,10 +495,11 @@ + + void SvxOle2Shape::resetModifiedState() + { +- ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist(); ++ SdrObject* pObject = GetSdrObject(); ++ ::comphelper::IEmbeddedHelper* pPersist = pObject ? pObject->getSdrModelFromSdrObject().GetPersist() : nullptr; + if( pPersist && !pPersist->isEnableSetModified() ) + { +- SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() ); ++ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >(pObject); + if( pOle && !pOle->IsEmpty() ) + { + uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY ); +@@ -548,6 +549,11 @@ + return aClassName; + } + ++OUString SvxOle2Shape::GetAndClearInitialFrameURL() ++{ ++ return OUString(); ++} ++ + SvxAppletShape::SvxAppletShape(SdrObject* pObject) + : SvxOle2Shape( pObject, getSvxMapProvider().GetMap(SVXMAP_APPLET), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET, SdrObject::GetGlobalDrawObjectItemPool()) ) + { +@@ -701,8 +707,19 @@ + { + } + ++OUString SvxFrameShape::GetAndClearInitialFrameURL() ++{ ++ OUString sRet(m_sInitialFrameURL); ++ m_sInitialFrameURL.clear(); ++ return sRet; ++} ++ + void SvxFrameShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) + { ++ uno::Reference xSet(static_cast(this), uno::UNO_QUERY); ++ if (xSet) ++ xSet->getPropertyValue("FrameURL") >>= m_sInitialFrameURL; ++ + SvxShape::Create( pNewObj, pNewPage ); + const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); + createObject(aIFrameClassId); +diff -urN libreoffice-7-0-4.old/sw/inc/ndole.hxx libreoffice-7-0-4/sw/inc/ndole.hxx +--- libreoffice-7-0-4.old/sw/inc/ndole.hxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/sw/inc/ndole.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -28,7 +28,7 @@ + class SwDoc; + class SwOLENode; + class SwOLEListener_Impl; +-class SwEmbedObjectLink; ++namespace sfx2 { class SvBaseLink; } + class DeflateData; + + class SW_DLLPUBLIC SwOLEObj +@@ -90,7 +90,7 @@ + bool mbOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify + (e.g. copied). Is not persistent. */ + +- SwEmbedObjectLink* mpObjectLink; ++ sfx2::SvBaseLink* mpObjectLink; + OUString maLinkURL; + + SwOLENode( const SwNodeIndex &rWhere, +diff -urN libreoffice-7-0-4.old/sw/source/core/ole/ndole.cxx libreoffice-7-0-4/sw/source/core/ole/ndole.cxx +--- libreoffice-7-0-4.old/sw/source/core/ole/ndole.cxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/sw/source/core/ole/ndole.cxx 2023-05-24 17:24:13.613547961 +0200 +@@ -146,6 +146,8 @@ + // TODO/LATER: actually SwEmbedObjectLink should be used here, but because different objects are used to control + // embedded object different link objects with the same functionality had to be implemented + ++namespace { ++ + class SwEmbedObjectLink : public sfx2::SvBaseLink + { + SwOLENode* pOleNode; +@@ -208,6 +210,44 @@ + SvBaseLink::Closed(); + } + ++class SwIFrameLink : public sfx2::SvBaseLink ++{ ++ SwOLENode* m_pOleNode; ++ ++public: ++ explicit SwIFrameLink(SwOLENode* pNode) ++ : ::sfx2::SvBaseLink(::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB) ++ , m_pOleNode(pNode) ++ { ++ SetSynchron( false ); ++ } ++ ++ ::sfx2::SvBaseLink::UpdateResult DataChanged( ++ const OUString&, const uno::Any& ) ++ { ++ uno::Reference xObject = m_pOleNode->GetOLEObj().GetOleRef(); ++ uno::Reference xPersObj(xObject, uno::UNO_QUERY); ++ if (xPersObj.is()) ++ { ++ // let the IFrameObject reload the link ++ try ++ { ++ xPersObj->reload(uno::Sequence(), uno::Sequence()); ++ } ++ catch (const uno::Exception&) ++ { ++ } ++ ++ m_pOleNode->SetChanged(); ++ } ++ ++ return SUCCESS; ++ } ++ ++}; ++ ++} ++ + SwOLENode::SwOLENode( const SwNodeIndex &rWhere, + const svt::EmbeddedObjectRef& xObj, + SwGrfFormatColl *pGrfColl, +@@ -605,18 +645,49 @@ + { + try + { +- uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW ); +- if ( xLinkSupport->isLink() ) ++ uno::Reference xObject = maOLEObj.m_xOLERef.GetObject(); ++ if (!xObject) ++ return; ++ ++ bool bIFrame = false; ++ ++ OUString aLinkURL; ++ uno::Reference xLinkSupport(xObject, uno::UNO_QUERY); ++ if (xLinkSupport) ++ { ++ if (xLinkSupport->isLink()) ++ aLinkURL = xLinkSupport->getLinkURL(); ++ } ++ else ++ { ++ // get IFrame (Floating Frames) listed and updatable from the ++ // manage links dialog ++ SvGlobalName aClassId(xObject->getClassID()); ++ if (aClassId == SvGlobalName(SO3_IFRAME_CLASSID)) ++ { ++ uno::Reference xSet(xObject->getComponent(), uno::UNO_QUERY); ++ if (xSet.is()) ++ xSet->getPropertyValue("FrameURL") >>= aLinkURL; ++ bIFrame = true; ++ } ++ } ++ ++ if (!aLinkURL.isEmpty()) // this is a file link so the model link manager should handle it + { +- const OUString aLinkURL = xLinkSupport->getLinkURL(); +- if ( !aLinkURL.isEmpty() ) ++ SwEmbedObjectLink* pEmbedObjectLink = nullptr; ++ if (!bIFrame) ++ { ++ pEmbedObjectLink = new SwEmbedObjectLink(this); ++ mpObjectLink = pEmbedObjectLink; ++ } ++ else + { +- // this is a file link so the model link manager should handle it +- mpObjectLink = new SwEmbedObjectLink( this ); +- maLinkURL = aLinkURL; +- GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); +- mpObjectLink->Connect(); ++ mpObjectLink = new SwIFrameLink(this); + } ++ maLinkURL = aLinkURL; ++ GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); ++ if (pEmbedObjectLink) ++ pEmbedObjectLink->Connect(); + } + } + catch( uno::Exception& ) +diff -urN libreoffice-7-0-4.old/xmloff/source/draw/ximpshap.cxx libreoffice-7-0-4/xmloff/source/draw/ximpshap.cxx +--- libreoffice-7-0-4.old/xmloff/source/draw/ximpshap.cxx 2023-05-24 17:17:38.000000000 +0200 ++++ libreoffice-7-0-4/xmloff/source/draw/ximpshap.cxx 2023-05-24 17:26:15.413109472 +0200 +@@ -3245,9 +3245,35 @@ + { + } + ++uno::Reference SdXMLFloatingFrameShapeContext::CreateFloatingFrameShape() const ++{ ++ uno::Reference xServiceFact(GetImport().GetModel(), uno::UNO_QUERY); ++ if (!xServiceFact.is()) ++ return nullptr; ++ uno::Reference xShape( ++ xServiceFact->createInstance("com.sun.star.drawing.FrameShape"), uno::UNO_QUERY); ++ return xShape; ++} ++ + void SdXMLFloatingFrameShapeContext::StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& ) + { +- AddShape("com.sun.star.drawing.FrameShape"); ++ uno::Reference xShape(SdXMLFloatingFrameShapeContext::CreateFloatingFrameShape()); ++ ++ uno::Reference< beans::XPropertySet > xProps(xShape, uno::UNO_QUERY); ++ // set FrameURL before AddShape, we have to do it again later because it ++ // gets cleared when the SdrOle2Obj is attached to the XShape. But we want ++ // FrameURL to exist when AddShape triggers SetPersistName which itself ++ // triggers SdrOle2Obj::CheckFileLink_Impl and at that point we want to ++ // know what URL will end up being used. So bodge this by setting FrameURL ++ // to the temp pre-SdrOle2Obj attached properties and we can smuggle it ++ // eventually into SdrOle2Obj::SetPersistName at the right point after ++ // PersistName is set but before SdrOle2Obj::CheckFileLink_Impl is called ++ // in order to inform the link manager that this is an IFrame that links to ++ // a URL ++ if (xProps && !maHref.isEmpty()) ++ xProps->setPropertyValue("FrameURL", Any(maHref)); ++ ++ AddShape(xShape); + + if( mxShape.is() ) + { +@@ -3256,7 +3282,6 @@ + // set pos, size, shear and rotate + SetTransformation(); + +- uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if( xProps.is() ) + { + if( !maFrameName.isEmpty() ) +diff -urN libreoffice-7-0-4.old/xmloff/source/draw/ximpshap.hxx libreoffice-7-0-4/xmloff/source/draw/ximpshap.hxx +--- libreoffice-7-0-4.old/xmloff/source/draw/ximpshap.hxx 2023-05-24 17:17:08.692721562 +0200 ++++ libreoffice-7-0-4/xmloff/source/draw/ximpshap.hxx 2023-05-24 17:24:13.613547961 +0200 +@@ -513,6 +513,8 @@ + OUString maFrameName; + OUString maHref; + ++ css::uno::Reference CreateFloatingFrameShape() const; ++ + public: + + SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, diff --git a/debian/patches/ZDI-CAN-17859.diff b/debian/patches/ZDI-CAN-17859.diff new file mode 100644 index 000000000..9b668c4b3 --- /dev/null +++ b/debian/patches/ZDI-CAN-17859.diff @@ -0,0 +1,290 @@ +From e36986a3a7f448722961bde79691fb2f225c48ea Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Tue, 30 Aug 2022 14:04:52 +0200 +Subject: These commands are always URLs already + +Conflicts: + wizards/source/scriptforge/SF_Session.xba + +Change-Id: I5083765c879689d7f933bbe00ad70bb68e635a21 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139042 +Tested-by: Jean-Pierre Ledure +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +--- + wizards/source/access2base/DoCmd.xba | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba +index 27b0d74be34f..26755a8d901d 100644 +--- a/wizards/source/access2base/DoCmd.xba ++++ b/wizards/source/access2base/DoCmd.xba +@@ -2655,7 +2655,7 @@ Private Sub _ShellExecute(sCommand As String) + + Dim oShell As Object + Set oShell = createUnoService("com.sun.star.system.SystemShellExecute") +- oShell.execute(sCommand, "" , com.sun.star.system.SystemShellExecuteFlags.DEFAULTS) ++ oShell.execute(sCommand, "" , com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY) + + End Sub ' _ShellExecute V0.8.5 + +-- +cgit v1.2.1 + +From 7c299586526c29875d2d1438c95580c18835c99b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Tue, 30 Aug 2022 17:01:08 +0100 +Subject: check IFrame "FrameURL" target + +similiar to + +commit b3edf85e0fe6ca03dc26e1bf531be82193bc9627 +Date: Wed Aug 7 17:37:11 2019 +0100 + + warn on load when a document binds an event to a macro + +Conflicts: + sfx2/source/doc/iframe.cxx + sw/source/filter/html/htmlplug.cxx + sw/source/filter/xml/xmltexti.cxx + +Change-Id: Iea888b1c083d2dc69ec322309ac9ae8c5e5eb315 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139059 +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +--- + sfx2/source/appl/macroloader.cxx | 9 +++++++-- + sfx2/source/doc/iframe.cxx | 20 +++++++++++++++----- + sfx2/source/inc/macroloader.hxx | 2 ++ + sw/source/filter/html/htmlplug.cxx | 7 ++++++- + sw/source/filter/xml/xmltexti.cxx | 9 +++++++-- + 5 files changed, 37 insertions(+), 10 deletions(-) + +diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx +index 98e036e0a7ea..b50d1e63c789 100644 +--- a/sfx2/source/appl/macroloader.cxx ++++ b/sfx2/source/appl/macroloader.cxx +@@ -68,10 +68,10 @@ css::uno::Sequence SAL_CALL SfxMacroLoader::getSupportedServiceNames() + return { "com.sun.star.frame.ProtocolHandler" }; + } + +-SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() ++SfxObjectShell* SfxMacroLoader::GetObjectShell(const Reference & xFrame) + { + SfxObjectShell* pDocShell = nullptr; +- Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); ++ + if ( xFrame.is() ) + { + SfxFrame* pFrame=nullptr; +@@ -96,6 +96,11 @@ SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() + return pDocShell; + } + ++SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() ++{ ++ Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); ++ return SfxMacroLoader::GetObjectShell(xFrame); ++} + + uno::Reference SAL_CALL SfxMacroLoader::queryDispatch( + const util::URL& aURL , +diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx +index 8b1271545dfb..aea851894286 100644 +--- a/sfx2/source/doc/iframe.cxx ++++ b/sfx2/source/doc/iframe.cxx +@@ -38,10 +38,12 @@ + #include + #include + #include ++#include + #include + #include + #include + #include ++#include + + using namespace ::com::sun::star; + +@@ -159,6 +161,19 @@ sal_Bool SAL_CALL IFrameObject::load( + { + if ( SvtMiscOptions().IsPluginsEnabled() ) + { ++ util::URL aTargetURL; ++ aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); ++ uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); ++ xTrans->parseStrict( aTargetURL ); ++ ++ if (INetURLObject(aTargetURL.Complete).GetProtocol() == INetProtocol::Macro) ++ { ++ uno::Reference xParentFrame = xFrame->getCreator(); ++ SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); ++ if (pDoc && !pDoc->AdjustMacroMode()) ++ return false; ++ } ++ + DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); + VclPtr pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + VclPtr pWin = VclPtr::Create( pParent, maFrmDescr.IsFrameBorderOn() ); +@@ -181,11 +196,6 @@ sal_Bool SAL_CALL IFrameObject::load( + if ( xFramesSupplier.is() ) + mxFrame->setCreator( xFramesSupplier ); + +- util::URL aTargetURL; +- aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); +- uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); +- xTrans->parseStrict( aTargetURL ); +- + uno::Sequence < beans::PropertyValue > aProps(2); + aProps[0].Name = "PluginMode"; + aProps[0].Value <<= sal_Int16(2); +diff --git a/sfx2/source/inc/macroloader.hxx b/sfx2/source/inc/macroloader.hxx +index 9e1dfba18ed0..b3e7a5ec1abc 100644 +--- a/sfx2/source/inc/macroloader.hxx ++++ b/sfx2/source/inc/macroloader.hxx +@@ -82,6 +82,8 @@ public: + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; + + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; ++ ++ static SfxObjectShell* GetObjectShell(const css::uno::Reference& xFrame); + }; + + #endif +diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx +index a0da671de733..eb707040adb2 100644 +--- a/sw/source/filter/html/htmlplug.cxx ++++ b/sw/source/filter/html/htmlplug.cxx +@@ -1087,7 +1087,12 @@ void SwHTMLParser::InsertFloatingFrame() + bool bHasBorder = aFrameDesc.HasFrameBorder(); + Size aMargin = aFrameDesc.GetMargin(); + +- xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) ); ++ OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); ++ ++ if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) ++ NotifyMacroEventRead(); ++ ++ xSet->setPropertyValue("FrameURL", uno::makeAny( sHRef ) ); + xSet->setPropertyValue("FrameName", uno::makeAny( aName ) ); + + if ( eScroll == ScrollingMode::Auto ) +diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx +index 788bec5c2d47..169cbdc1534d 100644 +--- a/sw/source/filter/xml/xmltexti.cxx ++++ b/sw/source/filter/xml/xmltexti.cxx +@@ -853,9 +853,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { ++ OUString sHRef = URIHelper::SmartRel2Abs( ++ INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ); ++ ++ if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) ++ GetXMLImport().NotifyMacroEventRead(); ++ + xSet->setPropertyValue("FrameURL", +- makeAny( URIHelper::SmartRel2Abs( +- INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) ) ); ++ makeAny( sHRef ) ); + + xSet->setPropertyValue("FrameName", + makeAny( rName ) ); +-- +cgit v1.2.1 + +From 2f7e7dbebb28123b1e608c30af6cc335e7b5ed2f Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Thu, 1 Sep 2022 17:33:51 +0200 +Subject: Filter out unwanted command URIs + +Conflicts: + desktop/source/app/cmdlineargs.cxx + +Change-Id: I0b7e5329af8cc053d14d5c60ec14fe7f364ef993 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139225 +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +--- + desktop/source/app/cmdlineargs.cxx | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx +index 381147cd534e..f004f4b179dd 100644 +--- a/desktop/source/app/cmdlineargs.cxx ++++ b/desktop/source/app/cmdlineargs.cxx +@@ -28,6 +28,7 @@ + #include "cmdlineargs.hxx" + #include + #include ++#include + #include + #include + #include +@@ -169,7 +170,14 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& arg, CommandLineEvent cur + } + if (nURIlen < 0) + nURIlen = rest2.getLength(); +- arg = rest2.copy(0, nURIlen); ++ auto const uri = rest2.copy(0, nURIlen); ++ if (INetURLObject(uri).GetProtocol() == INetProtocol::Macro) { ++ // Let the "Open" machinery process the full command URI (leading to failure, by intention, ++ // as the "Open" machinery does not know about those command URI schemes): ++ curEvt = CommandLineEvent::Open; ++ } else { ++ arg = uri; ++ } + return curEvt; + } + +-- +cgit v1.2.1 + +From 46216a79f440dc972724bb243396b295267530ce Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Tue, 6 Sep 2022 11:38:55 +0100 +Subject: check impress/calc IFrame "FrameURL" target +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +similar to + +commit c7450d0b9d02c64ae3da467d329040787039767e +Date: Tue Aug 30 17:01:08 2022 +0100 + + check IFrame "FrameURL" target + +Change-Id: Ibf28c29acb4476830431d02772f3ecd4b23a6a27 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139480 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +--- + xmloff/source/draw/ximpshap.cxx | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx +index af0bfc1a7ef0..94ac8532b6c9 100644 +--- a/xmloff/source/draw/ximpshap.cxx ++++ b/xmloff/source/draw/ximpshap.cxx +@@ -90,6 +90,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -3265,6 +3265,9 @@ void SdXMLFloatingFrameShapeContext::StartElement( const css::uno::Reference< cs + + if( !maHref.isEmpty() ) + { ++ if (INetURLObject(maHref).GetProtocol() == INetProtocol::Macro) ++ GetImport().NotifyMacroEventRead(); ++ + xProps->setPropertyValue("FrameURL", Any(maHref) ); + } + } +-- +cgit v1.2.1 + diff --git a/debian/patches/add-access2base-doc.diff b/debian/patches/add-access2base-doc.diff new file mode 100644 index 000000000..4ad717862 --- /dev/null +++ b/debian/patches/add-access2base-doc.diff @@ -0,0 +1,25337 @@ +--- /dev/null 2019-06-18 20:58:03.983176917 +0000 ++++ a/wizards/source/access2base/access2base.html 2019-11-17 10:18:33.356387757 +0000 +@@ -0,0 +1,25334 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Access2Base - It's about converting PEOPLE, not data ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++
++
++
++
++
++
++
++
++
++
++
Background: #fff
++Foreground: #000
++PrimaryPale: #8cf
++PrimaryLight: #18f
++PrimaryMid: #04b
++PrimaryDark: #014
++SecondaryPale: #ffc
++SecondaryLight: #fe8
++SecondaryMid: #db4
++SecondaryDark: #841
++TertiaryPale: #eee
++TertiaryLight: #ccc
++TertiaryMid: #999
++TertiaryDark: #666
++Error: #f88
++
++
++
++
<!--{{{-->
++<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
++<div class='title' macro='view title'></div>
++<div class='editor' macro='edit title'></div>
++<div macro='annotations'></div>
++<div class='editor' macro='edit text'></div>
++<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser excludeLists'></span></div>
++<!--}}}-->
++
++
++
++
To get started with this blank [[TiddlyWiki]], you'll need to modify the following tiddlers:
++* [[SiteTitle]] & [[SiteSubtitle]]: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
++* [[MainMenu]]: The menu (usually on the left)
++* [[DefaultTiddlers]]: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
++You'll also need to enter your username for signing your edits: <<option txtUserName>>
++
++
++
++
<<importTiddlers>>
++
++
++
++
<!--{{{-->
++<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
++<!--}}}-->
++
++
++
++
These [[InterfaceOptions]] for customising [[TiddlyWiki]] are saved in your browser
++
++Your username for signing your edits. Write it as a [[WikiWord]] (eg [[JoeBloggs]])
++
++<<option txtUserName>>
++<<option chkSaveBackups>> [[SaveBackups]]
++<<option chkAutoSave>> [[AutoSave]]
++<<option chkRegExpSearch>> [[RegExpSearch]]
++<<option chkCaseSensitiveSearch>> [[CaseSensitiveSearch]]
++<<option chkAnimate>> [[EnableAnimations]]
++
++----
++Also see [[AdvancedOptions]]
++
++
++
++
<!--{{{-->
++<div class='header' role='banner' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
++<div class='headerShadow'>
++<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
++<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
++</div>
++<div class='headerForeground'>
++<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
++<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
++</div>
++</div>
++<div id='mainMenu' role='navigation' refresh='content' tiddler='MainMenu'></div>
++<div id='sidebar'>
++<div id='sidebarOptions' role='navigation' refresh='content' tiddler='SideBarOptions'></div>
++<div id='sidebarTabs' role='complementary' refresh='content' force='true' tiddler='SideBarTabs'></div>
++</div>
++<div id='displayArea' role='main'>
++<div id='messageArea'></div>
++<div id='tiddlerDisplay'></div>
++</div>
++<!--}}}-->
++
++
++
++
/*{{{*/
++body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
++
++a {color:[[ColorPalette::PrimaryMid]];}
++a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
++a img {border:0;}
++
++h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
++h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
++h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
++
++.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
++.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
++.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
++
++.header {background:[[ColorPalette::PrimaryMid]];}
++.headerShadow {color:[[ColorPalette::Foreground]];}
++.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
++.headerForeground {color:[[ColorPalette::Background]];}
++.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
++
++.tabSelected {color:[[ColorPalette::PrimaryDark]];
++	background:[[ColorPalette::TertiaryPale]];
++	border-left:1px solid [[ColorPalette::TertiaryLight]];
++	border-top:1px solid [[ColorPalette::TertiaryLight]];
++	border-right:1px solid [[ColorPalette::TertiaryLight]];
++}
++.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
++.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
++.tabContents .button {border:0;}
++
++#sidebar {}
++#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
++#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
++#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
++#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
++#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
++
++.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
++.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
++.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
++.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
++	border:1px solid [[ColorPalette::PrimaryMid]];}
++.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
++.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
++.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
++.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
++	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
++.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
++.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
++	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
++
++.wizard .notChanged {background:transparent;}
++.wizard .changedLocally {background:#80ff80;}
++.wizard .changedServer {background:#8080ff;}
++.wizard .changedBoth {background:#ff8080;}
++.wizard .notFound {background:#ffff80;}
++.wizard .putToServer {background:#ff80ff;}
++.wizard .gotFromServer {background:#80ffff;}
++
++#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
++#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
++
++.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
++
++.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
++.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
++.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
++.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
++.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
++.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
++.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
++.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
++
++.tiddler .defaultCommand {font-weight:bold;}
++
++.shadow .title {color:[[ColorPalette::TertiaryDark]];}
++
++.title {color:[[ColorPalette::SecondaryDark]];}
++.subtitle {color:[[ColorPalette::TertiaryDark]];}
++
++.toolbar {color:[[ColorPalette::PrimaryMid]];}
++.toolbar a {color:[[ColorPalette::TertiaryLight]];}
++.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
++.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
++
++.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
++.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
++.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
++.tagging .button, .tagged .button {border:none;}
++
++.footer {color:[[ColorPalette::TertiaryLight]];}
++.selected .footer {color:[[ColorPalette::TertiaryMid]];}
++
++.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
++.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
++.lowlight {background:[[ColorPalette::TertiaryLight]];}
++
++.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
++
++.imageLink, #displayArea .imageLink {background:transparent;}
++
++.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
++
++.viewer .listTitle {list-style-type:none; margin-left:-2em;}
++.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
++.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
++
++.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
++.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
++.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
++
++.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
++.viewer code {color:[[ColorPalette::SecondaryDark]];}
++.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
++
++.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
++
++.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
++.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
++.editorFooter {color:[[ColorPalette::TertiaryMid]];}
++.readOnly {background:[[ColorPalette::TertiaryPale]];}
++
++#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
++#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
++#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
++#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
++#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
++#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
++#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
++.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
++.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
++#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:alpha(opacity=60);}
++/*}}}*/
++
++
++
++
/*{{{*/
++* html .tiddler {height:1%;}
++
++body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
++
++h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
++h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
++h4,h5,h6 {margin-top:1em;}
++h1 {font-size:1.35em;}
++h2 {font-size:1.25em;}
++h3 {font-size:1.1em;}
++h4 {font-size:1em;}
++h5 {font-size:.9em;}
++
++hr {height:1px;}
++
++a {text-decoration:none;}
++
++dt {font-weight:bold;}
++
++ol {list-style-type:decimal;}
++ol ol {list-style-type:lower-alpha;}
++ol ol ol {list-style-type:lower-roman;}
++ol ol ol ol {list-style-type:decimal;}
++ol ol ol ol ol {list-style-type:lower-alpha;}
++ol ol ol ol ol ol {list-style-type:lower-roman;}
++ol ol ol ol ol ol ol {list-style-type:decimal;}
++
++.txtOptionInput {width:11em;}
++
++#contentWrapper .chkOptionInput {border:0;}
++
++.externalLink {text-decoration:underline;}
++
++.indent {margin-left:3em;}
++.outdent {margin-left:3em; text-indent:-3em;}
++code.escaped {white-space:nowrap;}
++
++.tiddlyLinkExisting {font-weight:bold;}
++.tiddlyLinkNonExisting {font-style:italic;}
++
++/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
++a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
++
++#mainMenu .tiddlyLinkExisting,
++	#mainMenu .tiddlyLinkNonExisting,
++	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
++#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
++
++.header {position:relative;}
++.header a:hover {background:transparent;}
++.headerShadow {position:relative; padding:4.5em 0 1em 1em; left:-1px; top:-1px;}
++.headerForeground {position:absolute; padding:4.5em 0 1em 1em; left:0; top:0;}
++
++.siteTitle {font-size:3em;}
++.siteSubtitle {font-size:1.2em;}
++
++#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}
++
++#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
++#sidebarOptions {padding-top:0.3em;}
++#sidebarOptions a {margin:0 0.2em; padding:0.2em 0.3em; display:block;}
++#sidebarOptions input {margin:0.4em 0.5em;}
++#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
++#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
++#sidebarOptions .sliderPanel input {margin:0 0 0.3em 0;}
++#sidebarTabs .tabContents {width:15em; overflow:hidden;}
++
++.wizard {padding:0.1em 1em 0 2em;}
++.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
++.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
++.wizardStep {padding:1em 1em 1em 1em;}
++.wizard .button {margin:0.5em 0 0; font-size:1.2em;}
++.wizardFooter {padding:0.8em 0.4em 0.8em 0;}
++.wizardFooter .status {padding:0 0.4em; margin-left:1em;}
++.wizard .button {padding:0.1em 0.2em;}
++
++#messageArea {position:fixed; top:2em; right:0; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
++.messageToolbar {display:block; text-align:right; padding:0.2em;}
++#messageArea a {text-decoration:underline;}
++
++.tiddlerPopupButton {padding:0.2em;}
++.popupTiddler {position: absolute; z-index:300; padding:1em; margin:0;}
++
++.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
++.popup .popupMessage {padding:0.4em;}
++.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0;}
++.popup li.disabled {padding:0.4em;}
++.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
++.listBreak {font-size:1px; line-height:1px;}
++.listBreak div {margin:2px 0;}
++
++.tabset {padding:1em 0 0 0.5em;}
++.tab {margin:0 0 0 0.25em; padding:2px;}
++.tabContents {padding:0.5em;}
++.tabContents ul, .tabContents ol {margin:0; padding:0;}
++.txtMainTab .tabContents li {list-style:none;}
++.tabContents li.listLink { margin-left:.75em;}
++
++#contentWrapper {display:block;}
++#splashScreen {display:none;}
++
++#displayArea {margin:1em 17em 0 14em;}
++
++.toolbar {text-align:right; font-size:.9em;}
++
++.tiddler {padding:1em 1em 0;}
++
++.missing .viewer,.missing .title {font-style:italic;}
++
++.title {font-size:1.6em; font-weight:bold;}
++
++.missing .subtitle {display:none;}
++.subtitle {font-size:1.1em;}
++
++.tiddler .button {padding:0.2em 0.4em;}
++
++.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
++.isTag .tagging {display:block;}
++.tagged {margin:0.5em; float:right;}
++.tagging, .tagged {font-size:0.9em; padding:0.25em;}
++.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
++.tagClear {clear:both;}
++
++.footer {font-size:.9em;}
++.footer li {display:inline;}
++
++.annotation {padding:0.5em; margin:0.5em;}
++
++* html .viewer pre {width:99%; padding:0 0 1em 0;}
++.viewer {line-height:1.4em; padding-top:0.5em;}
++.viewer .button {margin:0 0.25em; padding:0 0.25em;}
++.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
++.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
++
++.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
++.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
++table.listView {font-size:0.85em; margin:0.8em 1.0em;}
++table.listView th, table.listView td, table.listView tr {padding:0 3px 0 3px;}
++
++.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
++.viewer code {font-size:1.2em; line-height:1.4em;}
++
++.editor {font-size:1.1em;}
++.editor input, .editor textarea {display:block; width:100%; font:inherit;}
++.editorFooter {padding:0.25em 0; font-size:.9em;}
++.editorFooter .button {padding-top:0; padding-bottom:0;}
++
++.fieldsetFix {border:0; padding:0; margin:1px 0px;}
++
++.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
++.zoomer div {padding:1em;}
++
++* html #backstage {width:99%;}
++* html #backstageArea {width:99%;}
++#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em;}
++#backstageToolbar {position:relative;}
++#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em;}
++#backstageButton {display:none; position:absolute; z-index:175; top:0; right:0;}
++#backstageButton a {padding:0.1em 0.4em; margin:0.1em;}
++#backstage {position:relative; width:100%; z-index:50;}
++#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin-left:3em; padding:1em;}
++.backstagePanelFooter {padding-top:0.2em; float:right;}
++.backstagePanelFooter a {padding:0.2em 0.4em;}
++#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
++
++.whenBackstage {display:none;}
++.backstageVisible .whenBackstage {display:block;}
++/*}}}*/
++
++
++
++
/***
++StyleSheet for use when a translation requires any css style changes.
++This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
++***/
++/*{{{*/
++body {font-size:0.8em;}
++#sidebarOptions {font-size:1.05em;}
++#sidebarOptions a {font-style:normal;}
++#sidebarOptions .sliderPanel {font-size:0.95em;}
++.subtitle {font-size:0.8em;}
++.viewer table.listView {font-size:0.95em;}
++/*}}}*/
++
++
++
++
/*{{{*/
++@media print {
++#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none !important;}
++#displayArea {margin: 1em 1em 0em;}
++noscript {display:none;} /* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
++}
++/*}}}*/
++
++
++
++
<!--{{{-->
++<div class='toolbar' role='navigation' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
++<div class='title' macro='view title'></div>
++<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
++<div class='tagging' macro='tagging'></div>
++<div class='tagged' macro='tags'></div>
++<div class='viewer' macro='view text wikified'></div>
++<div class='tagClear'></div>
++<!--}}}-->
++
++
++ ++
++ ++
++
++
The //~AbsolutePosition// property sets or returns the relative record number of a [[Recordset object's|Recordset]] current record.
++!!!Applies to ...
++| !Object |!Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.AbsolutePosition}}}
++//recordset//{{{.AbsolutePosition}}} = //value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++*You can use the //~AbsolutePosition// property to position the current record pointer to a specific record based on its ordinal position in a //Recordset// object. You can also determine the current record number by checking the //~AbsolutePosition// property setting.
++*The //~AbsolutePosition// property value is 1-based (that is, a setting of 1 refers to the first record in the //Recordset// object), you cannot set it to a value greater than or equal to the number of populated records; doing so causes an error. You can determine the number of populated records in the //Recordset// object by checking the [[RecordCount]] property setting. The maximum allowable setting for the //~AbsolutePosition// property is the value of the //~RecordCount// property.<br />Note that in //~MSAccess// the //~AbsolutePosition// property is zero-based (a setting of 0 refers to the 1st record of the //Recordset//).
++*If there is no current record, as when there are no records in the //Recordset// object, //~AbsolutePosition// returns –1. If the current record is deleted, the //~AbsolutePosition// property value isn't defined, and an error occurs if it's referenced.
++*You shouldn't use this property as a surrogate record number. //Bookmarks// are still the recommended way of retaining and returning to a given position and are the only way to position the current record across a //Recordset// object. In particular, the position of a record changes when one or more records preceding it are deleted. There is also no assurance that a record will have the same absolute position if the //Recordset// object is re-created again because the order of individual records within a //Recordset// object isn't guaranteed unless it's created with an SQL statement by using an ORDER BY clause.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Recordset delivered no data. Action on current record rejected |
++|Recordset has been closed. Recordset action rejected |
++|Current record out of range |
++!!!See also
++[[Bookmarkable]]
++[[GoToRecord]]
++[[Move|Move (recordset)]]
++[[MoveFirst|Move (recordset)]]
++[[MoveLast|Move (recordset)]]
++[[MoveNext|Move (recordset)]]
++[[MovePrevious|Move (recordset)]]
++[[RecordCount]]
++[[Recordset]]
++!!!Example
++<<tiddler "AbsolutePosition example">>
++
++
++
Know the number of records by moving to the last record of the recordset
++//{{{
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().OpenRecordset("SELECT * FROM [Products]")
++	oRecordset.MoveLast()
++	Print "Number of records = " & oRecordset.AbsolutePosition
++	oRecordset.mClose()
++//}}}
++See also [[Design a generic DMedian function|DMedian function]]
++
++
++
<<tiddler "Home">>
++
++
++
~LibreOffice/~OpenOffice Base with ~Access2Base
++//{{{
++REM Open a form ...
++          OpenForm("myForm")
++REM Move a form to new left-top coordinates ...
++          Dim ofForm As Object		' In VBA =>		Dim ofForm As Form
++          Set ofForm = Forms("myForm")
++          ofForm.Move(100, 200)
++REM Get the value of a control ...
++          Dim ocControl As Object
++          ocControl = ofForm.Controls("myControl")
++          MsgBox ocControl.Value
++REM Hide a control ...
++          ocControl.Visible = False
++REM ... or alternatively ...
++          setValue("Forms!myForm!myControl.Visible", False)	'    Shortcut notation
++			' In VBA => 	Forms!myForm!myControl.Visible = False
++
++//}}}
++
++
++
++

++
++
++
*Adds a [[table|TableDef]] object to the [[TableDefs]] collection. The //Add// method finalizes the creation of a new table initiated with the [[CreateTableDef]] method.
++*Adds a new [[tempvar object|TempVar]] to the [[TempVars collection|TempVars]] and initializes its value.
++!!!Applies to ...
++| !Object | !Description |
++|[[TableDefs]] |The set of tables of the database. |
++|[[TempVars]] |The collection of temporary variables. |
++!!!Syntax
++//database.~TableDefs()//{{{.Add(}}}//table//{{{)}}}
++//[application.]~TempVars()//{{{.Add(}}}//name, value//{{{)}}}
++| !Argument | !Type |!Returned value |
++|table | [[TableDef]] object |True if success.|
++|name | string |~|
++|value | variant |~|
++!!!Remarks when applied to ~TableDefs
++*The name "Add" has been preferred to "Append" (like in //~MSAccess// because the latter is a reserved word in ~OpenOffice (not in ~LibreOffice).
++When applied to ~TableDef objects:
++*If the //Add// method is not invoked after a prior invocation of the [[CreateTableDef]] method, or if not at least one field has been defined with the [[CreateField]] method, an error message will be raised.
++*The database document is automatically saved after the table creation.
++!!!Error Messages
++|Method 'Collection.Add' not applicable in this context |
++|Table '...' could not be created |
++!!!See also
++[[CreateTableDef]]
++[[CreateField]]
++[[TableDef]]
++[[TableDefs]]
++[[TempVar]]
++[[TempVars]]
++!!!Example
++<<tiddler "CreateTableDef example">>
++<<tiddler "Tempvar example">>
++
++
++
(Q) Can I add a "All" option in a combo box on top of the list ?
++
++(R) Use either a special SELECT statement or, alternatively, the [[RowSource]] property to adjust the list.
++
++Assuming next table:
++<<tiddler "CustomersTable">>
++we want to make a combo box listing all //~CompanyName//s.
++!!!(1) Solution with a UNION SELECT statement:
++Define your combo box with the //List content// defined like
++//{{{
++		SELECT "CompanyName" FROM "Customers" UNION SELECT '(All)' as "Bogus" From "Customers" ORDER BY "CompanyName"
++//}}}
++Depending on the database (RDBMS) used above SQL will probably require that the //Type of list contents// entry contains {{{Sql [Native]}}}
++!!!(2) Solution with a bit code
++This solution requires that the list of proposed values remains unchanged as long as the form remains open.
++Additionally it is valid ONLY for LISTBOXES.
++The listbox is defined, exactly as above. Store in the //List content// entry a more usual SQL statement:
++//{{{
++		SELECT DISTINCT "CompanyName" FROM "Customers"
++//}}}
++Note that the code below is also usable if the //~ListBox// is based on a list of values i.o. data in a database table.
++The code, triggered from the form's //When loading// event, will concatenate "(All)" with all values contained in the list.
++//{{{
++Sub AddAllToList(poEvent As Object)
++
++Dim oEvent As Object, ofForm As Object, ocList As Object
++Dim i As Integer, sSource As String
++	Set oEvent = Events(poEvent)
++	Set ofForm = oEvent.Source
++	Set ocList = ofForm.Controls("listBox-All")
++	With ocList
++		Select Case .RowSourceType
++			Case com.sun.star.form.ListSourceType.VALUELIST
++				.RowSource = "(All);" & .RowSource
++			Case Else	'	Table, Query, SQL, SqlPassThrough
++				sSource = "(All)"
++				For i = 0 To .ListCount - 1
++					sSource = sSource & ";" & .Itemdata(i)
++				Next i
++				.RowSourceType = com.sun.star.form.ListSourceType.VALUELIST
++				.RowSource = sSource
++		End Select
++	End With
++	
++End Sub
++//}}}
++!!!See also
++[[ComboBox]]
++[[ListBox]]
++[[RowSource]]
++[[RowSourceType]]
++!!!Refer to ...
++| !Solution | !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++| (1) ||~Products_ListBoxFilter ||~CustomersAll-SQL |||
++| (2) |~ListBox|~|When loading |~ListBox-All |~|~|
++
++
++
The //~AddItem// method adds a new item to the list of values displayed by the specified list box control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a Dialog |!Description |
++|[[Control]] | [[ListBox]] | [[ListBox]] | [[ListBox]] |A listbox on an open form, a dialog or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.AddItem(}}}//value// [, //index//]{{{)}}}
++| !Argument | !Type | !Description |
++| value | String |The display text for the new item. |
++| index | Integer<br />Long |The position of the item in the list.<br />If this argument is omitted, the item is added to the end of the list. |
++!!!Remarks
++*The [[RowSourceType]] property (invalid in dialogs) must contain the value {{{com.sun.star.form.ListSourceType.VALUELIST}}}. 
++*Combo boxes do not support this value for that property. That's why //~AddItem// is applicable only on listboxes.
++*List item numbers start from zero. If the value of the {{{index}}} argument doesn't correspond to an existing item number or to the last item number + 1, an error occurs.
++*//~AddItem// returns True if success, False otherwise.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Method not applicable in this context |
++!!!See also
++[[ListBox]]
++[[RemoveItem]]
++[[RowSource]]
++[[RowSourceType]]
++!!!Example
++<<tiddler "Addremoveitem example">>
++
++
++
Creates a new record for an updatable [[Recordset object|Recordset]]. The //~AddNew// method must be finalized with the [[Update]] method.
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.AddNew()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++*Use the //~AddNew// method to create and add a new record. This method sets the fields to [[default values|DefaultValue]], and if no default values are specified in the table definition, it sets the fields to Null.
++*After you modify the new record, use the [[Update]] method to save the changes and add the record to the //Recordset//. No changes occur in the database until you use the //Update// method.
++**''Caution'' If you issue an //~AddNew// and then perform any operation that moves to another record, but without using //Update//, your changes are lost without warning.
++*The record that was current before you used //~AddNew// remains current.
++!!!Error Messages
++|Recordset or field is not updatable |
++!!!See also
++[[CancelUpdate]]
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[DefaultValue]]
++[[Edit]]
++[[Update]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "AddNew example">>
++
++
++
Add a new record to a table
++//{{{
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Expenses")
++	With oRecordset	
++		.AddNew				'	Fields initialised with the default value
++		.Fields("AMOUNT").Value = 1234
++		.Fields("DATE EXPENSE").Value = Now()
++		.Fields("CATEGORY").Value = "Food"
++		.Fields("DESCRIPTION").Value = "Lunch"
++		.Fields("VAT CODE").Value = 3
++		.Update
++		.mClose
++	End With
++//}}}
++
++
++
(Q) How to add a record to a recordset
++
++(R) To add a record to a [[Recordset object|Recordset]]:
++*Use the [[AddNew]] method to create a record you can edit.
++*Assign values to each of the record's fields.
++*Use the [[Update]] method to save the new record.
++The following code example adds a record to a Recordset associated with a table called Shippers.
++<<tiddler "ShippersTable">>
++//{{{
++Dim odbNorthwind As Object
++Dim orsShippers As Object
++
++	Set odbNorthwind = Application.CurrentDb
++	Set orsShippers = odbNorthwind.OpenRecordset("Shippers")
++
++	With orsShippers
++		.AddNew
++		.Fields("CompanyName").Value = "Global Open Source Service"
++		'
++		' Set remaining fields.
++		'
++		.Update
++		.mClose()
++	End With
++//}}}
++When you use the //~AddNew// method, //~Access2Base// prepares a new, blank record, initializes its fields to their default value and makes it the current record. When you use the //Update// method to save the new record, the record that was current before you used the //~AddNew// method becomes the current record again.
++
++If you use the //~AddNew// method to add a record, and then move to another record or close the //Recordset// without first using the //Update// method, your changes are lost without warning. For example, omitting the ''Update'' method from the preceding example results in no changes being made to the Shippers table.
++!!!See also
++[[OpenRecordset]]
++[[Value (field)]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~AddRecordToShippers ||
++
++
++
Display in an empty ListBox all dates between today and today + 9 days
++//{{{
++Dim ocList As Object, i As Integer, sDate As String
++	Set ocList = getObject("Forms!myForm!myListBoxDate")
++	sDate = Date
++	For i = 0 To 9
++		ocList.AddItem(sDate)
++		sDate = DateAdd("d", 1, sDate)
++	Next i
++//}}}
++
++Remove from the added dates all the non-working days (it is assumed that, for any reason, this could not have been done while loading the dates in the box ...)
++//{{{
++Dim ocList As Object, i As Integer, sDates() As String, dDate As Date
++	Set ocList = getObject("Forms!myForm!myListBoxDate")
++	sDates() = ocList.ItemData
++	For i = 0 To UBound(sDates)
++		dDate = DateValue(sDates(i))
++		If DatePart("w", dDate, 2) > 5 Then ocList.RemoveItem(sDates(i))		'	Remove saturdays and sundays
++	Next i
++//}}}
++
++
++
The //~AllDialogs// collection describes instances of all [[dialogs|Dialog]] present in the currently loaded dialog libraries.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]AllDialogs()}}}
++{{{[Application.]AllDialogs(index)}}}
++{{{[Application.]AllDialogs(dialogname)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[Dialog]] object corresponding to the index-th item in the ~AllDialogs() collection. The 1st dialog is ~AllDialogs(0), the 2nd is ~AllDialogs(1) and so on ... The last one is ~AllDialogs.Count - 1.|
++| dialogname | string |A [[Dialog]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*//~Access2Base// will scan first the dialogs present in the current Base document (".odb" file) or current non-Base document containing one or more [[standalone forms|Standalone Forms]] (".odt", ".ods", ... file) and continue the search thru all currently loaded libraries. __The //~Access2Base// library itself however will be skipped__.
++*The //dialogname// argument is not case sensitive.
++*Homonyms within the scanned libraries should be avoided. Only their non case-sensitive name can differentiate them.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection ~AllDialogs() |
++|Dialog '...' not found in the currently loaded libraries |
++!!!See also ...
++[[Collection]]
++[[EndExecute]]
++[[Execute|Execute (dialog)]]
++[[Start]]
++[[Terminate]]
++!!!Examples
++<<tiddler "Dialog example">>
++
++
++
++
The //~AllForms// collection describes instances of all __forms__ present in the current Base document (".odb" file) or in the current non-Base document (".odt", ".ods", ... file) containing one or more [[standalone forms|Standalone Forms]].
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]AllForms()}}} or {{{AllForms()}}}
++{{{[Application.]AllForms(index)}}}
++{{{[Application.]AllForms(formname)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[Form]] object corresponding to the index-th item in the {{{AllForms()}}} collection. The 1st form is {{{AllForms(0)}}}, the 2nd is {{{AllForms(1)}}} and so on ... The last one has as index {{{AllForms.Count - 1}}}.|
++| formname | string |A [[Form]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*~Access2Base supports hierarchical form names exactly like Base does it. The //formname// argument must contain the full pathname of the designated form.
++*The //formname// argument is not case sensitive.
++*When invoked from a [[standalone form|Standalone Forms]], the {{{formname}}} argument must be the own name of the form, __which is often "~MainForm"__. If only one form is present in the file (very often the case), use simply {{{AllForms(0)}}} to get a form object matching that single occurrence.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection ~AllForms() |
++|Form "..." not found |
++!!!See also ...
++[[Forms]]
++!!!Examples
++<<tiddler "AllForms examples">>
++
++
++
++
To display the name of all forms (uses the [[Name]] property):
++//{{{
++Dim i As Integer, oCollection As Object
++	Set oCollection = AllForms
++	For i = 0 To oCollection.Count - 1	'AllForms without argument returns a Collection object
++		Print AllForms(i).Name,	'AllForms(...) with an argument returns a Form object
++	Next i
++	Print
++//}}}
++Can shorter ... :
++//{{{
++Dim i As Integer
++	For i = 0 To AllForms.Count - 1		'AllForms without argument returns a Collection object
++		Print AllForms(i).Name,		'AllForms(...) with an argument returns a Form object
++	Next i
++	Print
++//}}}
++To know the exact name of a form:
++//{{{
++Dim ofForm As Object
++	Set ofForm = AllForms("MYFORM")	'Exact name = myForm :o)
++	MsgBox ofForm.Name
++//}}}
++
++
++
The //~AllModules// collection describes instances of all [[modules|Module]] present in the currently loaded Basic libraries.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]AllModules()}}}
++{{{[Application.]AllModules(index)}}}
++{{{[Application.]AllModules(modulename)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[Module]] object corresponding to the index-th item in the ~AllModules() collection. The 1st module is ~AlModules(0), the 2nd is ~AllModules(1) and so on ... The last one is ~AllModules.Count - 1.|
++| modulename | string |A [[Module]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*//~Access2Base// will scan first the modules present in the current Base document (".odb" file) or current non-Base document containing one or more [[standalone forms|Standalone Forms]] (".odt", ".ods", ... file) and continue the search thru all currently loaded libraries. __The //~Access2Base// library itself however will be skipped__.
++*The //modulename// argument is not case sensitive.
++!!!How to name modules ?
++To manage potential homonyms among libraries, the ''name'' of a module consists in 3 components:
++//{{{
++	[[SCOPE.][LIBRARY.]MODULE
++//}}}
++, the first two being optional.
++*The //SCOPE// is either
++**''{{{GLOBAL}}}'' grouping both the ''~LibreOffice/~OpenOffice Macros and Dialogs'' and the ''My Macros and Dialogs'' catalogs of libraries.
++**''{{{DOCUMENT}}}'' grouping the libraries stored in the current document. __This is the default__.
++*The //LIBRARY// component is the name of the library. __The default is "''Standard''"__.
++As such,
++//{{{
++	AllModules("DOCUMENT.STANDARD.myModule")
++//}}}
++is equivalent to:
++//{{{
++	AllModules("myModule")
++//}}}
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection ~AllModules() |
++|Module '...' not found in the currently loaded libraries |
++!!!See also ...
++[[Collection]]
++[[Module]]
++!!!Examples
++<<tiddler "Module example">>
++
++
++
++
Make a form read-only
++//{{{
++Dim ofForm As Object
++	Set ofForm = AllForms("myForm")
++	With ofForm
++		.AllowEdits = False
++		.AllowDeletions = False
++		.AllowAdditions = False
++	End With
++//}}}
++
++
++
The //~AllowAdditions// property specifies whether a user can add a record when using a form or a subform.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.AllowAdditions}}}
++//form//{{{.AllowAdditions}}} = //value//
++//subform//{{{.AllowAdditions}}}
++//form//{{{.AllowAdditions}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~AllowAdditions' |
++!!!See also
++[[AllowDeletions]]
++[[AllowEdits]]
++!!!Example
++<<tiddler "Allow example">>
++
++
++
The //~AllowDeletions// property specifies whether a user can delete a record when using a form or a subform.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.AllowDeletions}}}
++//form//{{{.AllowDeletions}}} = //value//
++//subform//{{{.AllowDeletions}}}
++//subform//{{{.AllowDeletions}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~AllowDeletions' |
++!!!See also
++[[AllowAdditions]]
++[[AllowEdits]]
++!!!Example
++<<tiddler "Allow example">>
++
++
++
The //~AllowEdits// property specifies whether a user can edit saved records when using a form or a subform.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.AllowEdits}}}
++//form//{{{.AllowEdits}}} = //value//
++//subform//{{{.AllowEdits}}}
++//form//{{{.AllowEdits}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~AllowEdits' |
++!!!See also
++[[AllowAdditions]]
++[[AllowDeletions]]
++!!!Example
++<<tiddler "Allow example">>
++
++
++
The //~AppendChunk// method appends data to a binary [[Field]] belonging to the [[Fields]] collection of a [[Recordset]].
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.~DataType.BINARY<br />com.sun.star.sdbc.~DataType.VARBINARY<br />com.sun.star.sdbc.~DataType.LONGVARBINARY |
++!!!Syntax
++//field//{{{.AppendChunk(}}}//value//{{{)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++|value | Variant |An array of integers, probably built with the [[GetChunk]] method.  |
++!!!Remarks
++*Use the //~AppendChunk// and //~GetChunk// methods to access subsets of data in (Long) Binary fields. 
++*If memory space is limited or the amount of bytes to be stored cannot be reasonably processed with the [[Value|Value (field)]] property, you may need to work with chunks of a field instead of the entire field. 
++*The initial AppendChunk operation (after an [[Edit]] or [[AddNew]] call) will simply place the data in the field, overwriting any existing data. Subsequent //~AppendChunk// calls within the same Edit or ~AddNew session will then add to the existing data. 
++*//~AppendChunk// will be rejected if either the [[AddNew]] or the [[Edit]] method has not been applied on the concerned [[Recordset]] first. The modifications will be applied when the [[Update]] Method is applied on the same //recordset// object. If the //Update// method is never applied, or if the [[CancelUpdate]] method is invoked instead, the database will not be impacted.
++!!!Error messages
++|Method '~AppendChunk' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Edit]]
++[[GetChunk]]
++[[Update]]
++[[WriteAllBytes]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "Chunk example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Application// class is the root class from which the initial [[collections|Collection]] are derived.
++The //Application// class must not be instantiated. The only preset instance MUST be called {{{Application}}}. In fact it is implemented simply as a Basic module. 
++As an example, next statements are equivalent :
++//{{{
++	Set ofForm = Forms("anyform")
++//}}}
++and
++//{{{
++	Set ofForm = Application.Forms("anyform")
++//}}}
++However, __the second one is recommended__ to avoid risks of naming collisions between concurrent Basic libraries.
++!!Functions returning objects
++| !Function | !Description |
++|[[AllDialogs]] |Collection of dialogs, active or not. |
++|[[AllForms]] |Collection of forms, open or not. |
++|[[AllModules]] |All Basic scripts available in the currently loaded Basic libraries. |
++|[[CommandBars]] |Collection of tool-, menu- and statusbars associated with the current window. |
++|[[CurrentDb]] |Returns the current [[database|Database]] object, i.e. the only database from a Base (".odb" document, or the database linked with the first [[standalone form|Standalone Forms]] contained in a non-Base (Writer, Calc, ...) document. |
++|[[Events]] |Returns the currently running [[event|Event]] as an object. |
++|[[Forms]] |Collection of open forms. |
++|[[OpenDatabase]] |Returns a [[database|Database]] object giving access to the data stored in that database. |
++|[[TempVars]] |Collection of temporary variables available thru the whole ~LibreOffice/~OpenOffice session. |
++!!Properties
++| !Property | !Type | !Description |
++|[[CurrentUser]] | String |The logon name of the current user. |
++|[[DAvg]]<br />[[DCount]]<br />[[DLookup]]<br />[[DMin, DMax]]<br />[[DStDev, DStDevP]]<br />[[DSum]]<br />[[DVar, DVarP]] | Any |The database functions. |
++|[[HtmlEncode]] | String |Returns an Html encoded string. |
++|[[ProductCode]] | String |Returns "~Access2Base x.y.z" where x.y.z equals the version number of the library. |
++|[[Version]] | String |Returns "~LibreOffice x.y.z" or "~OpenOffice x.y.z" where x.y.z is the version number. |
++!!Methods
++|[[OpenConnection]] |To be run to connect the application to the database. |
++|[[CloseConnection]] |To be run to disconnect the application from the database. |
++
++
++
!!!Applies to ...
++| !Object | !Description |
++|[[Application]] |Root class. When present, its name must be "{{{Application}}}" but the object name is optional. |
++
++
++
!!!Applies to ...
++| !Object | !Description |
++|[[DoCmd]] |Root class. When present, its name must be "{{{DoCmd}}}" but the object name is optional. |
++
++
++
{{firstletter{
++ @@color:#930;U@@
++ }}}se the //~ApplyFilter// action to apply a filter, a query, or an SQL WHERE clause to a table, form, subform or query to restrict the records in the table or query, or the records from the underlying table or query of the form/subform.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]ApplyFilter(}}}//{{{[filter], [SQLwhere], [controlname]}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{filter}}} | Yes | String |The //Filter// and //~SQLWhere// arguments have identical meanings.<br />They both contain a SQL ''Where'' clause without the word //Where//.<br />If both arguments are present, __the second argument__ only is applied to the data. |
++|{{{SQLwhere}}} |~|~|~|
++|{{{controlname}}} |~|~|The name of a subform of the active form. |
++!!!Remarks
++*The //~ApplyFilter// action must not be called from a [[standalone form|Standalone Forms]].
++*The //~ApplyFilter// action is applied on the current window. To make a window current, use the [[SelectObject]] action. If the current window is neither a form, a table datasheet or a query datasheet, the //~ApplyFilter// action return {{{False}}} and ignores the request.
++*The //~ApplyFilter// action, when applied to a table or a query datasheet, __does NOT work in //~OpenOffice//__ (//~LibreOffice// OK).
++*To apply a filter on a table or a query with //~ApplyFilter//, the table or the query must be open. Eventually use therefore the [[OpenTable]] or [[OpenQuery]] actions.
++*If //controlname// is present, the active window is expected to be a form.  Otherwise //~ApplyFilter// refurns {{{False}}} and the request is ignored. The //controlname// is NOT case-sensitive. If //controlname// does not exist in the active form or is not the name of one of its [[subforms|SubForm]] then the action generates a run-time error.
++*When a filter is applied with //~ApplyFilter// the first record (if it exists ...) becomes the current record.
++*Once applied, the filter is preserved for subsequent table or query openings during the same //~LibreOffice/~OpenOffice// session. It will become persistent when the database file ("*.odb") is saved.
++*In the filter argument, record and field names may be surrounded by square brackets. They will be replaced with the correct character surrounding such names in SQL statements targeted to be run on the concerned RDBMS (Relational Database Management System).
++*Giving the null-length string ("") as filter argument resets any pre-existing filter.
++!!!Error messages
++|Argument nr.X [Value = '...'] is invalid|
++|Control '...' not found in parent (form, grid or dialog) '...' |
++|Subform '...' not found in parent form '...' |
++!!!See also
++[[Filter]]
++[[FilterOn]]
++[[GoToRecord]]
++[[SelectObject]]
++[[SetFocus]]
++[[SetOrderBy]]
++!!!Example
++<<tiddler "ApplyFilter example">>
++
++
++
Set and apply a filter on the data displayed by a query
++//{{{
++Dim sApplyFilter As String
++Const cstQueryName = "myQuery"
++	OpenQuery(cstQueryName)
++	sApplyFilter = "[USUAL NAME] LIKE 'W%'"
++	SelectObject(acQuery, cstQueryName)
++	DoCmd.ApplyFilter(sApplyFilter)
++//}}}
++
++
++
(Q) How can I control when a record is saved in a form ?
++
++(R) Use the form's //Before record change// event to run code each time Base tries to save a record. This way, if the user doesn't want to save a record, you can issue an Undo command instead of saving the record.
++
++For strange reasons the //Before record change// form event is fired twice by //AAO/~LibO// while in most cases one occurrence would be sufficient. That's where the //Recommendation// property becomes useful. 
++Read [[Roberto Benitez's Forms and Dialogs document|http://www.baseprogramming.com/FormsAndDialogs.pdf]] about this strange behaviour (p. 20+).
++
++!!!Solution
++Next code will make it. The event fires here a //Function// which will return {{{True}}} only if the modification is confirmed by the user. Otherwise the //Undo// command is run automatically. Other requests for changes (INSERT or DELETE actions) will be accepted blindly.
++//{{{
++Function AskBeforeSave(poEvent As Object) As Boolean
++
++Dim sMsg As String, oEvent As Object
++
++REM MsgBox constants
++Const vbYesNo = 4 			'	Yes and No buttons 
++Const vbQuestion = 32 			'	Warning query 
++Const vbYes = 6 			'	Yes button pressed 
++
++	AskBeforeSave = True
++	Set oEvent = Events(poEvent)
++	If oEvent.Recommendation = "IGNORE" Then Exit Function
++	If oEvent.RowChangeAction <> com.sun.star.sdb.RowChangeAction.UPDATE Then Exit Function	'	INSERT / DELETE ignored
++	sMsg = "Data has changed." & Chr(13) & "Do you wish to save the changes?" _
++			& Chr(13) & "Click Yes to save or No to discard changes."
++	If MsgBox(sMsg, vbQuestion + vbYesNo, "Save record ?") <> vbYes Then
++		RunCommand("RecUndo")		'	Cancel editing done
++		AskBeforeSave = False
++	End If
++	
++End Function
++//}}}
++!!!See also
++[[Event]]
++[[Events Handler]]
++[[RunCommand]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~NewRec |~Customers_NewRec |Before record action ||||
++
++
++
text/plain
++.txt .text .js .vbs .asp .cgi .pl
++----
++text/html
++.htm .html .hta .htx .mht
++----
++text/comma-separated-values
++.csv
++----
++text/javascript
++.js
++----
++text/css
++.css
++----
++text/xml
++.xml .xsl .xslt
++----
++image/gif
++.gif
++----
++image/jpeg
++.jpg .jpe .jpeg
++----
++image/png
++.png
++----
++image/bmp
++.bmp
++----
++image/tiff
++.tif .tiff
++----
++audio/basic
++.au .snd
++----
++audio/wav
++.wav
++----
++audio/x-pn-realaudio
++.ra .rm .ram
++----
++audio/x-midi
++.mid .midi
++----
++audio/mp3
++.mp3
++----
++audio/m3u
++.m3u
++----
++video/x-ms-asf
++.asf
++----
++video/avi
++.avi
++----
++video/mpeg
++.mpg .mpeg
++----
++video/quicktime
++.qt .mov .qtvr
++----
++application/pdf
++.pdf
++----
++application/rtf
++.rtf
++----
++application/postscript
++.ai .eps .ps
++----
++application/wordperfect
++.wpd
++----
++application/mswrite
++.wri
++----
++application/msexcel
++.xls .xls3 .xls4 .xls5 .xlw
++----
++application/msword
++.doc
++----
++application/mspowerpoint
++.ppt .pps
++----
++application/x-director
++.swa
++----
++application/x-shockwave-flash
++.swf
++----
++application/x-zip-compressed
++.zip
++----
++application/x-gzip
++.gz
++----
++application/x-rar-compressed
++.rar
++----
++application/octet-stream
++.com .exe .dll .ocx
++----
++application/java-archive
++.jar
++
++
++
/***
++|Name|AttachFilePlugin|
++|Source|http://www.TiddlyTools.com/#AttachFilePlugin|
++|Documentation|http://www.TiddlyTools.com/#AttachFilePluginInfo|
++|Version|4.0.1|
++|Author|Eric Shulman|
++|License|http://www.TiddlyTools.com/#LegalStatements|
++|~CoreVersion|2.1|
++|Type|plugin|
++|Requires|AttachFilePluginFormatters, AttachFileMIMETypes|
++|Description|Store binary files as base64-encoded tiddlers with fallback links for separate local and/or remote file storage|
++Store or link binary files (such as jpg, gif, pdf or even mp3) within your TiddlyWiki document and then use them as images or links from within your tiddler content.
++> Important note: As of version 3.6.0, in order to //render// images and other binary attachments created with this plugin, you must also install [[AttachFilePluginFormatters]], which extends the behavior of the TiddlyWiki core formatters for embedded images ({{{[img[tooltip|image]]}}}), linked embedded images ({{{[img[tooltip|image][link]]}}}), and external/"pretty" links ({{{[[label|link]]}}}), so that these formatter will process references to attachment tiddlers as if a normal file reference had been provided. |
++!!!!!Documentation
++>see [[AttachFilePluginInfo]]
++!!!!!Inline interface (live)
++>see [[AttachFile]] (shadow tiddler)
++><<tiddler AttachFile>>
++!!!!!Revisions
++<<<
++2011.02.14 4.0.1 fix OSX error: use picker.file.path
++2009.06.04 4.0.0 changed attachment storage format to use //sections// instead of embedded substring markers.
++|please see [[AttachFilePluginInfo]] for additional revision details|
++2005.07.20 1.0.0 Initial Release
++<<<
++!!!!!Code
++***/
++// // version
++//{{{
++version.extensions.AttachFilePlugin= {major: 4, minor: 0, revision: 1, date: new Date(2011,2,14)};
++
++// shadow tiddler
++config.shadowTiddlers.AttachFile="<<attach inline>>";
++
++// add 'attach' backstage task (insert before built-in 'importTask')
++if (config.tasks) { // for TW2.2b or above
++	config.tasks.attachTask = {
++		text: "attach",
++		tooltip: "Attach a binary file as a tiddler",
++		content: "<<attach inline>>"
++	}
++	config.backstageTasks.splice(config.backstageTasks.indexOf("importTask"),0,"attachTask");
++}
++
++config.macros.attach = {
++// // lingo
++//{{{
++	label: "attach file",
++	tooltip: "Attach a file to this document",
++	linkTooltip: "Attachment: ",
++
++	typeList: "AttachFileMIMETypes",
++
++	titlePrompt: " enter tiddler title...",
++	MIMEPrompt: "<option value=''>select MIME type...</option><option value='editlist'>[edit list...]</option>",
++	localPrompt: " enter local path/filename...",
++	URLPrompt: " enter remote URL...",
++
++	tiddlerErr: "Please enter a tiddler title",
++	sourceErr: "Please enter a source path/filename",
++	storageErr: "Please select a storage method: embedded, local or remote",
++	MIMEErr: "Unrecognized file format.  Please select a MIME type",
++	localErr: "Please enter a local path/filename",
++	URLErr: "Please enter a remote URL",
++	fileErr: "Invalid path/file or file not found",
++
++	tiddlerFormat: '!usage\n{{{%0}}}\n%0\n!notes\n%1\n!type\n%2\n!file\n%3\n!url\n%4\n!data\n%5\n',
++
++//}}}
++// // macro definition
++//{{{
++	handler:
++	function(place,macroName,params) {
++		if (params && !params[0])
++			{ createTiddlyButton(place,this.label,this.tooltip,this.toggleAttachPanel); return; }
++		var id=params.shift();
++		this.createAttachPanel(place,id+"_attachPanel",params);
++		document.getElementById(id+"_attachPanel").style.position="static";
++		document.getElementById(id+"_attachPanel").style.display="block";
++	},
++//}}}
++//{{{
++	createAttachPanel:
++	function(place,panel_id,params) {
++		if (!panel_id || !panel_id.length) var panel_id="_attachPanel";
++		// remove existing panel (if any)
++		var panel=document.getElementById(panel_id); if (panel) panel.parentNode.removeChild(panel);
++		// set styles for this panel
++		setStylesheet(this.css,"attachPanel");
++		// create new panel
++		var title=""; if (params && params[0]) title=params.shift();
++		var types=this.MIMEPrompt+this.formatListOptions(store.getTiddlerText(this.typeList)); // get MIME types
++		panel=createTiddlyElement(place,"span",panel_id,"attachPanel",null);
++		var html=this.html.replace(/%id%/g,panel_id);
++		html=html.replace(/%title%/g,title);
++		html=html.replace(/%disabled%/g,title.length?"disabled":"");
++		html=html.replace(/%IEdisabled%/g,config.browser.isIE?"disabled":"");
++		html=html.replace(/%types%/g,types);
++		panel.innerHTML=html;
++		if (config.browser.isGecko) { // FF3 FIXUP
++			document.getElementById("attachSource").style.display="none";
++			document.getElementById("attachFixPanel").style.display="block";
++		}
++		return panel;
++	},
++//}}}
++//{{{
++	toggleAttachPanel:
++	function (e) {
++		if (!e) var e = window.event;
++		var parent=resolveTarget(e).parentNode;
++		var panel = document.getElementById("_attachPanel");
++		if (panel==undefined || panel.parentNode!=parent)
++			panel=config.macros.attach.createAttachPanel(parent,"_attachPanel");
++		var isOpen = panel.style.display=="block";
++		if(config.options.chkAnimate)
++			anim.startAnimating(new Slider(panel,!isOpen,e.shiftKey || e.altKey,"none"));
++		else
++			panel.style.display = isOpen ? "none" : "block" ;
++		e.cancelBubble = true;
++		if (e.stopPropagation) e.stopPropagation();
++		return(false);
++	},
++//}}}
++//{{{
++	formatListOptions:
++	function(text) {
++		if (!text || !text.trim().length) return "";
++		// get MIME list content from text
++		var parts=text.split("\n----\n");
++		var out="";
++		for (var p=0; p<parts.length; p++) {
++			var lines=parts[p].split("\n");
++			var label=lines.shift(); // 1st line=display text
++			var value=lines.shift(); // 2nd line=item value
++			out +='<option value="%1">%0</option>'.format([label,value]);
++		}
++		return out;
++	},
++//}}}
++// // interface definition
++//{{{
++	css:
++	".attachPanel { display: none; position:absolute; z-index:10; width:35em; right:105%; top:0em;\
++		background-color: #eee; color:#000; font-size: 8pt; line-height:110%;\
++		border:1px solid black; border-bottom-width: 3px; border-right-width: 3px;\
++		padding: 0.5em; margin:0em; -moz-border-radius:1em;-webkit-border-radius:1em; text-align:left }\
++	.attachPanel form { display:inline;border:0;padding:0;margin:0; }\
++	.attachPanel select { width:99%;margin:0px;font-size:8pt;line-height:110%;}\
++	.attachPanel input  { width:98%;padding:0px;margin:0px;font-size:8pt;line-height:110%}\
++	.attachPanel textarea { width:98%;margin:0px;height:2em;font-size:8pt;line-height:110%}\
++	.attachPanel table { width:100%;border:0;margin:0;padding:0;color:inherit; }\
++	.attachPanel tbody, .attachPanel tr, .attachPanel td { border:0;margin:0;padding:0;color:#000; }\
++	.attachPanel .box { border:1px solid black; padding:.3em; margin:.3em 0px; background:#f8f8f8; \
++		-moz-border-radius:5px;-webkit-border-radius:5px; }\
++	.attachPanel .chk { width:auto;border:0; }\
++	.attachPanel .btn { width:auto; }\
++	.attachPanel .btn2 { width:49%; }\
++	",
++//}}}
++//{{{
++	html:
++	'<form>\
++		attach from source file\
++		<input type="file" id="attachSource" name="source" size="56"\
++			onChange="config.macros.attach.onChangeSource(this)">\
++		<div id="attachFixPanel" style="display:none"><!-- FF3 FIXUP -->\
++			<input type="text" id="attachFixSource" style="width:90%"\
++				title="Enter a path/file to attach"\
++				onChange="config.macros.attach.onChangeSource(this);">\
++			<input type="button" style="width:7%" value="..."\
++				title="Enter a path/file to attach"\
++				onClick="config.macros.attach.askForFilename(document.getElementById(\'attachFixSource\'));">\
++		</div><!--end FF3 FIXUP-->\
++		<div class="box">\
++		<table style="border:0"><tr style="border:0"><td style="border:0;text-align:right;width:1%;white-space:nowrap">\
++			embed data <input type=checkbox class=chk name="useData" %IEdisabled% \
++				onclick="if (!this.form.MIMEType.value.length)\
++					this.form.MIMEType.selectedIndex=this.checked?1:0; ">&nbsp;\
++		</td><td style="border:0">\
++			<select size=1 name="MIMEType" \
++				onchange="this.title=this.value; if (this.value==\'editlist\')\
++					{ this.selectedIndex=this.form.useData.checked?1:0; story.displayTiddler(null,config.macros.attach.typeList,2); return; }">\
++				<option value=""></option>\
++				%types%\
++			</select>\
++		</td></tr><tr style="border:0"><td style="border:0;text-align:right;width:1%;white-space:nowrap">\
++			local link <input type=checkbox class=chk name="useLocal"\
++				onclick="this.form.local.value=this.form.local.defaultValue=this.checked?config.macros.attach.localPrompt:\'\';">&nbsp;\
++		</td><td style="border:0">\
++			<input type=text name="local" size=15 autocomplete=off value=""\
++				onchange="this.form.useLocal.checked=this.value.length" \
++				onkeyup="this.form.useLocal.checked=this.value.length" \
++				onfocus="if (!this.value.length) this.value=config.macros.attach.localPrompt; this.select()">\
++		</td></tr><tr style="border:0"><td style="border:0;text-align:right;width:1%;white-space:nowrap">\
++			remote link <input type=checkbox class=chk name="useURL"\
++				onclick="this.form.URL.value=this.form.URL.defaultValue=this.checked?config.macros.attach.URLPrompt:\'\';\">&nbsp;\
++		</td><td style="border:0">\
++			<input type=text name="URL" size=15 autocomplete=off value=""\
++				onfocus="if (!this.value.length) this.value=config.macros.attach.URLPrompt; this.select()"\
++				onchange="this.form.useURL.checked=this.value.length;"\
++				onkeyup="this.form.useURL.checked=this.value.length;">\
++		</td></tr></table>\
++		</div>\
++		<table style="border:0"><tr style="border:0"><td style="border:0;text-align:right;vertical-align:top;width:1%;white-space:nowrap">\
++			notes&nbsp;\
++		</td><td style="border:0" colspan=2>\
++			<textarea name="notes" style="width:98%;height:3.5em;margin-bottom:2px"></textarea>\
++		</td><tr style="border:0"><td style="border:0;text-align:right;width:1%;white-space:nowrap">\
++			attach as&nbsp;\
++		</td><td style="border:0" colspan=2>\
++			<input type=text name="tiddlertitle" size=15 autocomplete=off value="%title%"\
++				onkeyup="if (!this.value.length) { this.value=config.macros.attach.titlePrompt; this.select(); }"\
++				onfocus="if (!this.value.length) this.value=config.macros.attach.titlePrompt; this.select()" %disabled%>\
++		</td></tr></tr><tr style="border:0"><td style="border:0;text-align:right;width:1%;white-space:nowrap">\
++			add tags&nbsp;\
++		</td><td style="border:0">\
++			<input type=text name="tags" size=15 autocomplete=off value="" onfocus="this.select()">\
++		</td><td style="width:40%;text-align:right;border:0">\
++			<input type=button class=btn2 value="attach"\
++				onclick="config.macros.attach.onClickAttach(this)"><!--\
++			--><input type=button class=btn2 value="close"\
++				onclick="var panel=document.getElementById(\'%id%\'); if (panel) panel.parentNode.removeChild(panel);">\
++		</td></tr></table>\
++	</form>',
++//}}}
++// // control processing
++//{{{
++	onChangeSource:
++	function(here) {
++		var form=here.form;
++		var list=form.MIMEType;
++		var theFilename  = here.value;
++		var theExtension = theFilename.substr(theFilename.lastIndexOf('.')).toLowerCase();
++		// if theFilename is in current document folder, remove path prefix and use relative reference
++		var h=document.location.href; folder=getLocalPath(decodeURIComponent(h.substr(0,h.lastIndexOf("/")+1)));
++		if (theFilename.substr(0,folder.length)==folder) theFilename='./'+theFilename.substr(folder.length);
++		else theFilename='file:///'+theFilename; // otherwise, use absolute reference
++		theFilename=theFilename.replace(/\\/g,"/"); // fixup: change \ to /
++		form.useLocal.checked = true;
++		form.local.value = theFilename;
++		form.useData.checked = !form.useData.disabled;
++		list.selectedIndex=1;
++		for (var i=0; i<list.options.length; i++) // find matching MIME type
++			if (list.options[i].value.indexOf(theExtension)!=-1) { list.selectedIndex = i; break; }
++		if (!form.tiddlertitle.disabled)
++			form.tiddlertitle.value=theFilename.substr(theFilename.lastIndexOf('/')+1); // get tiddlername from filename
++	},
++//}}}
++//{{{
++	onClickAttach:
++	function (here) {
++		clearMessage();
++		// get input values
++		var form=here.form;
++		var src=form.source; if (config.browser.isGecko) src=document.getElementById("attachFixSource");
++		src=src.value!=src.defaultValue?src.value:"";
++		var when=(new Date()).formatString(config.macros.timeline.dateFormat);
++		var title=form.tiddlertitle.value;
++		var local = form.local.value!=form.local.defaultValue?form.local.value:"";
++		var url = form.URL.value!=form.URL.defaultValue?form.URL.value:"";
++		var notes = form.notes.value;
++		var tags = "attachment excludeMissing "+form.tags.value;
++		var useData=form.useData.checked;
++		var useLocal=form.useLocal.checked;
++		var useURL=form.useURL.checked;
++		var mimetype = form.MIMEType.value.length?form.MIMEType.options[form.MIMEType.selectedIndex].text:"";
++		// validate checkboxes and get filename
++		if (useData) {
++			if (src.length) { if (!theLocation) var theLocation=src; }
++			else { alert(this.sourceErr); src.focus(); return false; }
++		}
++		if (useLocal) {
++			if (local.length) { if (!theLocation) var theLocation = local; }
++			else { alert(this.localErr); form.local.focus(); return false; }
++		}
++		if (useURL) {
++			if (url.length) { if (!theLocation) var theLocation = url; }
++			else { alert(this.URLErr); form.URL.focus(); return false; }
++		}
++		if (!(useData||useLocal||useURL))
++			{ form.useData.focus(); alert(this.storageErr); return false; }
++		if (!theLocation)
++			{ src.focus(); alert(this.sourceErr); return false; }
++		if (!title || !title.trim().length || title==this.titlePrompt)
++			{ form.tiddlertitle.focus(); alert(this.tiddlerErr); return false; }
++		// if not already selected, determine MIME type based on filename extension (if any)
++		if (useData && !mimetype.length && theLocation.lastIndexOf('.')!=-1) {
++			var theExt = theLocation.substr(theLocation.lastIndexOf('.')).toLowerCase();
++			var theList=form.MIMEType;
++			for (var i=0; i<theList.options.length; i++)
++				if (theList.options[i].value.indexOf(theExt)!=-1)
++					{ var mimetype=theList.options[i].text; theList.selectedIndex=i; break; }
++		}
++		// attach the file
++		return this.createAttachmentTiddler(src, when, notes, tags, title,
++			useData, useLocal, useURL, local, url, mimetype);
++	},
++	getMIMEType:
++	function(src,def) {
++		var ext = src.substr(src.lastIndexOf('.')).toLowerCase();
++		var list=store.getTiddlerText(this.typeList);
++		if (!list || !list.trim().length) return def;
++		// get MIME list content from tiddler
++		var parts=list.split("\n----\n");
++		for (var p=0; p<parts.length; p++) {
++			var lines=parts[p].split("\n");
++			var mime=lines.shift(); // 1st line=MIME type
++			var match=lines.shift(); // 2nd line=matching extensions
++			if (match.indexOf(ext)!=-1) return mime;
++		}
++		return def;
++	},
++	createAttachmentTiddler:
++	function (src, when, notes, tags, title, useData, useLocal, useURL, local, url, mimetype, noshow) {
++		if (useData) { // encode the data
++			if (!mimetype.length) {
++				alert(this.MIMEErr);
++				form.MIMEType.selectedIndex=1; form.MIMEType.focus();
++				return false;
++			}
++			var d = this.readFile(src); if (!d) { return false; }
++			displayMessage('encoding '+src);
++			var encoded = this.encodeBase64(d);
++			displayMessage('file size='+d.length+' bytes, encoded size='+encoded.length+' bytes');
++		}
++		var usage=(mimetype.substr(0,5)=="image"?'[img[%0]]':'[[%0|%0]]').format([title]);
++		var theText=this.tiddlerFormat.format([
++			usage, notes.length?notes:'//none//', mimetype,
++			useLocal?local.replace(/\\/g,'/'):'', useURL?url:'',
++			useData?('data:'+mimetype+';base64,'+encoded):'' ]);
++		store.saveTiddler(title,title,theText,config.options.txtUserName,new Date(),tags);
++		var panel=document.getElementById("attachPanel"); if (panel) panel.style.display="none";
++		if (!noshow) { story.displayTiddler(null,title); story.refreshTiddler(title,null,true); }
++		displayMessage('attached "'+title+'"');
++		return true;
++	},
++//}}}
++// // base64 conversion
++//{{{
++	encodeBase64:
++	function (d) {
++		if (!d) return null;
++		// encode as base64
++		var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
++		var out="";
++		var chr1,chr2,chr3="";
++		var enc1,enc2,enc3,enc4="";
++		for (var count=0,i=0; i<d.length; ) {
++			chr1=d.charCodeAt(i++);
++			chr2=d.charCodeAt(i++);
++			chr3=d.charCodeAt(i++);
++			enc1=chr1 >> 2;
++			enc2=((chr1 & 3) << 4) | (chr2 >> 4);
++			enc3=((chr2 & 15) << 2) | (chr3 >> 6);
++			enc4=chr3 & 63;
++			if (isNaN(chr2)) enc3=enc4=64;
++			else if (isNaN(chr3)) enc4=64;
++			out+=keyStr.charAt(enc1)+keyStr.charAt(enc2)+keyStr.charAt(enc3)+keyStr.charAt(enc4);
++			chr1=chr2=chr3=enc1=enc2=enc3=enc4="";
++		}
++		return out;
++	},
++	decodeBase64: function(input) {
++		var out="";
++		var chr1,chr2,chr3;
++		var enc1,enc2,enc3,enc4;
++		var i = 0;
++		// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
++		input=input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
++		do {
++			enc1=keyStr.indexOf(input.charAt(i++));
++			enc2=keyStr.indexOf(input.charAt(i++));
++			enc3=keyStr.indexOf(input.charAt(i++));
++			enc4=keyStr.indexOf(input.charAt(i++));
++			chr1=(enc1 << 2) | (enc2 >> 4);
++			chr2=((enc2 & 15) << 4) | (enc3 >> 2);
++			chr3=((enc3 & 3) << 6) | enc4;
++			out=out+String.fromCharCode(chr1);
++			if (enc3!=64) out=out+String.fromCharCode(chr2);
++			if (enc4!=64) out=out+String.fromCharCode(chr3);
++		} while (i<input.length);
++		return out;
++	},
++//}}}
++// // I/O functions
++//{{{
++	readFile: // read local BINARY file data
++	function(filePath) {
++		if(!window.Components) { return null; }
++		try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
++		catch(e) { alert("access denied: "+filePath); return null; }
++		var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
++		try { file.initWithPath(filePath); } catch(e) { alert("cannot read file - invalid path: "+filePath); return null; }
++		if (!file.exists()) { alert("cannot read file - not found: "+filePath); return null; }
++		var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
++		inputStream.init(file, 0x01, 00004, null);
++		var bInputStream = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(Components.interfaces.nsIBinaryInputStream);
++		bInputStream.setInputStream(inputStream);
++		return(bInputStream.readBytes(inputStream.available()));
++	},
++//}}}
++//{{{
++	writeFile:
++	function(filepath,data) {
++		// TBD: decode base64 and write BINARY data to specified local path/filename
++		return(false);
++	},
++//}}}
++//{{{
++	askForFilename: // for FF3 fixup
++	function(target) {
++		var msg=config.messages.selectFile;
++		if (target && target.title) msg=target.title; // use target field tooltip (if any) as dialog prompt text
++		// get local path for current document
++		var path=getLocalPath(document.location.href);
++		var p=path.lastIndexOf("/"); if (p==-1) p=path.lastIndexOf("\\"); // Unix or Windows
++		if (p!=-1) path=path.substr(0,p+1); // remove filename, leave trailing slash
++		var file=""
++		var result=window.mozAskForFilename(msg,path,file,true); // FF3 FIXUP ONLY
++		if (target && result.length) // set target field and trigger handling
++			{ target.value=result; target.onchange(); }
++		return result; 
++	}
++};
++//}}}
++//{{{
++if (window.mozAskForFilename===undefined) { // also defined by CoreTweaks (for ticket #604)
++	window.mozAskForFilename=function(msg,path,file,mustExist) {
++		if(!window.Components) return false;
++		try {
++			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
++			var nsIFilePicker = window.Components.interfaces.nsIFilePicker;
++			var picker = Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
++			picker.init(window, msg, mustExist?nsIFilePicker.modeOpen:nsIFilePicker.modeSave);
++			var thispath = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
++			thispath.initWithPath(path);
++			picker.displayDirectory=thispath;
++			picker.defaultExtension='';
++			picker.defaultString=file;
++			picker.appendFilters(nsIFilePicker.filterAll|nsIFilePicker.filterText|nsIFilePicker.filterHTML);
++			if (picker.show()!=nsIFilePicker.returnCancel)
++				var result=picker.file.path;
++		}
++		catch(ex) { displayMessage(ex.toString()); }
++		return result;
++	}
++}
++//}}}
++
++
++
/***
++|Name|AttachFilePluginFormatters|
++|Source|http://www.TiddlyTools.com/#AttachFilePluginFormatters|
++|Version|4.0.1|
++|Author|Eric Shulman|
++|License|http://www.TiddlyTools.com/#LegalStatements|
++|~CoreVersion|2.1.3|
++|Type|plugin|
++|Description|run-time library for displaying attachment tiddlers|
++Runtime processing for //rendering// attachment tiddlers created by [[AttachFilePlugin]].   Attachment tiddlers are tagged with<<tag attachment>>and contain binary file content (e.g., jpg, gif, pdf, mp3, etc.) that has been stored directly as base64 text-encoded data or can be loaded from external files stored on a local filesystem or remote web server.  Note: after creating new attachment tiddlers, you can remove [[AttachFilePlugin]], as long as you retain //this// tiddler (so that images can be rendered later on).
++!!!!!Formatters
++<<<
++This plugin extends the behavior of the following TiddlyWiki core "wikify()" formatters:
++* embedded images: {{{[img[tooltip|image]]}}}
++* linked embedded images: {{{[img[tooltip|image][link]]}}}
++* external/"pretty" links: {{{[[label|link]]}}}
++''Please refer to AttachFilePlugin (source: http://www.TiddlyTools.com/#AttachFilePlugin) for additional information.''
++<<<
++!!!!!Revisions
++<<<
++2009.10.10 [4.0.1] in fileExists(), check for IE to avoid hanging Chrome during startup
++2009.06.04 [4.0.0] changed attachment storage format to use //sections// instead of embedded substring markers.
++2008.01.08 [*.*.*] plugin size reduction: documentation moved to ...Info
++2007.12.04 [*.*.*] update for TW2.3.0: replaced deprecated core functions, regexps, and macros
++2007.10.29 [3.7.0] more code reduction: removed upload handling from AttachFilePlugin (saves ~7K!)
++2007.10.28 [3.6.0] removed duplicate formatter code from AttachFilePlugin (saves ~10K!) and updated documentation accordingly.  This plugin ([[AttachFilePluginFormatters]]) is now //''required''// in order to display attached images/binary files within tiddler content.
++2006.05.20 [3.4.0] through 2007.03.01 [3.5.3] sync with AttachFilePlugin
++2006.05.13 [3.2.0] created from AttachFilePlugin v3.2.0
++<<<
++!!!!!Code
++***/
++// // version
++//{{{
++version.extensions.AttachFilePluginFormatters= {major: 4, minor: 0, revision: 1, date: new Date(2009,10,10)};
++//}}}
++
++//{{{
++if (config.macros.attach==undefined) config.macros.attach= { };
++//}}}
++//{{{
++if (config.macros.attach.isAttachment==undefined) config.macros.attach.isAttachment=function (title) {
++	var tiddler = store.getTiddler(title);
++	if (tiddler==undefined || tiddler.tags==undefined) return false;
++	return (tiddler.tags.indexOf("attachment")!=-1);
++}
++//}}}
++
++//{{{
++// test for local file existence - returns true/false without visible error display
++if (config.macros.attach.fileExists==undefined) config.macros.attach.fileExists=function(f) {
++	if(window.Components) { // MOZ
++		try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
++		catch(e) { return false; } // security access denied
++		var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
++		try { file.initWithPath(f); }
++		catch(e) { return false; } // invalid directory
++		return file.exists();
++	}
++	else if (config.browser.isIE) { // IE
++		var fso = new ActiveXObject("Scripting.FileSystemObject");
++		return fso.FileExists(f);
++	}
++	else return true; // other browsers: assume file exists
++}
++//}}}
++
++//{{{
++if (config.macros.attach.getAttachment==undefined) config.macros.attach.getAttachment=function(title) {
++
++	// extract embedded data, local and remote links (if any)
++	var text=store.getTiddlerText(title,'');
++	var embedded=store.getTiddlerText(title+'##data','').trim();
++	var locallink=store.getTiddlerText(title+'##file','').trim();
++	var remotelink=store.getTiddlerText(title+'##url','').trim();
++
++	// backward-compatibility for older attachments (pre 4.0.0)
++	var startmarker="---BEGIN_DATA---\n";
++	var endmarker="\n---END_DATA---";
++	var pos=0; var endpos=0;
++	if ((pos=text.indexOf(startmarker))!=-1 && (endpos=text.indexOf(endmarker))!=-1)
++		embedded="data:"+(text.substring(pos+startmarker.length,endpos)).replace(/\n/g,'');
++	if ((pos=text.indexOf("/%LOCAL_LINK%/"))!=-1)
++		locallink=text.substring(text.indexOf("|",pos)+1,text.indexOf("]]",pos));
++	if ((pos=text.indexOf("/%REMOTE_LINK%/"))!=-1)
++		remotelink=text.substring(text.indexOf("|",pos)+1,text.indexOf("]]",pos));
++
++	// if there is a data: URI defined (not supported by IE)
++	if (embedded.length && !config.browser.isIE) return embedded;
++
++	// document is being served remotely... use remote URL (if any)  (avoids security alert)
++	if (remotelink.length && document.location.protocol!="file:")
++		return remotelink;  
++
++	// local link only... return link without checking file existence (avoids security alert)
++	if (locallink.length && !remotelink.length) 
++		return locallink; 
++
++	// local link, check for file exist... use local link if found
++	if (locallink.length) { 
++		locallink=locallink.replace(/^\.[\/\\]/,''); // strip leading './' or '.\' (if any)
++		if (this.fileExists(getLocalPath(locallink))) return locallink;
++		// maybe local link is relative... add path from current document and try again
++		var pathPrefix=document.location.href;  // get current document path and trim off filename
++		var slashpos=pathPrefix.lastIndexOf("/"); if (slashpos==-1) slashpos=pathPrefix.lastIndexOf("\\"); 
++		if (slashpos!=-1 && slashpos!=pathPrefix.length-1) pathPrefix=pathPrefix.substr(0,slashpos+1);
++		if (this.fileExists(getLocalPath(pathPrefix+locallink))) return locallink;
++	}
++
++	// no embedded data, no local (or not found), fallback to remote URL (if any)
++	if (remotelink.length) return remotelink;
++
++	// attachment URL doesn't resolve, just return input as is
++	return title;
++}
++//}}}
++//{{{
++if (config.macros.attach.init_formatters==undefined) config.macros.attach.init_formatters=function() {
++	if (this.initialized) return;
++
++	// find the formatter for "image" and replace the handler
++	for (var i=0; i<config.formatters.length && config.formatters[i].name!="image"; i++);
++	if (i<config.formatters.length)	config.formatters[i].handler=function(w) {
++		this.lookaheadRegExp.lastIndex = w.matchStart;
++		var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
++		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) // Simple bracketted link
++			{
++			var e = w.output;
++			if(lookaheadMatch[5])
++				{
++				var link = lookaheadMatch[5];
++				// ELS -------------
++				var external=config.formatterHelpers.isExternalLink(link);
++				if (external)
++					{
++					if (config.macros.attach.isAttachment(link))
++						{
++						e = createExternalLink(w.output,link);
++						e.href=config.macros.attach.getAttachment(link);
++						e.title = config.macros.attach.linkTooltip + link;
++						}
++					else
++						e = createExternalLink(w.output,link);
++					}
++				else 
++					e = createTiddlyLink(w.output,link,false,null,w.isStatic);
++				// ELS -------------
++				addClass(e,"imageLink");
++				}
++			var img = createTiddlyElement(e,"img");
++			if(lookaheadMatch[1])
++				img.align = "left";
++			else if(lookaheadMatch[2])
++				img.align = "right";
++			if(lookaheadMatch[3])
++				img.title = lookaheadMatch[3];
++			img.src = lookaheadMatch[4];
++			// ELS -------------
++			if (config.macros.attach.isAttachment(lookaheadMatch[4]))
++				img.src=config.macros.attach.getAttachment(lookaheadMatch[4]);
++			// ELS -------------
++			w.nextMatch = this.lookaheadRegExp.lastIndex;
++		}
++	}
++//}}}
++//{{{
++	// find the formatter for "prettyLink" and replace the handler
++	for (var i=0; i<config.formatters.length && config.formatters[i].name!="prettyLink"; i++);
++	if (i<config.formatters.length)	{
++		config.formatters[i].handler=function(w) {
++			this.lookaheadRegExp.lastIndex = w.matchStart;
++			var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
++			if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
++				var e;
++				var text = lookaheadMatch[1];
++				if(lookaheadMatch[3]) {
++					// Pretty bracketted link
++					var link = lookaheadMatch[3];
++					if (config.macros.attach.isAttachment(link)) {
++						e = createExternalLink(w.output,link);
++						e.href=config.macros.attach.getAttachment(link);
++						e.title=config.macros.attach.linkTooltip+link;
++					}
++					else e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link))
++						? createExternalLink(w.output,link)
++						: createTiddlyLink(w.output,link,false,null,w.isStatic);
++				} else {
++					e = createTiddlyLink(w.output,text,false,null,w.isStatic);
++				}
++				createTiddlyText(e,text);
++				w.nextMatch = this.lookaheadRegExp.lastIndex;
++			}
++		}
++	} // if "prettyLink" formatter found
++	this.initialized=true;
++}
++//}}}
++//{{{
++config.macros.attach.init_formatters(); // load time init
++//}}}
++//{{{
++if (TiddlyWiki.prototype.coreGetRecursiveTiddlerText==undefined) {
++	TiddlyWiki.prototype.coreGetRecursiveTiddlerText = TiddlyWiki.prototype.getRecursiveTiddlerText;
++	TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth) {
++		return config.macros.attach.isAttachment(title)?
++			config.macros.attach.getAttachment(title):this.coreGetRecursiveTiddlerText.apply(this,arguments);
++	}
++}
++//}}}
++
++
++
/***
++|Name|AttachFilePluginInfo|
++|Source|http://www.TiddlyTools.com/#AttachFilePlugin|
++|Documentation|http://www.TiddlyTools.com/#AttachFilePluginInfo|
++|Version|4.0.0|
++|Author|Eric Shulman|
++|License|http://www.TiddlyTools.com/#LegalStatements|
++|~CoreVersion|2.1|
++|Type|plugin|
++|Description|Documentation for AttachFilePlugin|
++Store or link binary files (such as jpg, gif, pdf or even mp3) within your ~TiddlyWiki document and then use them as images or links from within your tiddler content.
++!!!!!Inline interface (live)
++>see [[AttachFile]] (shadow tiddler)
++><<tiddler AttachFile>>
++!!!!!Syntax
++<<<
++''To display the attach file control panel, simply view the [[AttachFile]] shadow tiddler that is automatically created by the plugin, and contains an instance of the inline control panel.''.  Or, you can write:
++{{{
++<<attach inline>>
++}}}
++in any tiddler to display the control panel embedded within that tiddler.  Note: you can actually use any unique identifier in place of the "inline" keyword.  Each unique id creates a separate instance of the controls.  If the same ID is used in more than one tiddler, then the control panel is automatically moved to the most recently rendered location.  Or, you can write:
++{{{
++<<attach>>
++}}}
++(with no ID parameter) in ~SidebarOptions.  This adds a command link that opens the controls as a floating panel, positioned directly to the left of the sidebar.
++<<<
++!!!!!Usage
++<<<
++Binary file content can be stored in three different locations:
++#embedded in the attachment tiddler (encoded as base64)
++#on your filesystem (a 'local link' path/filename)
++#on a web server (a 'remote link' URL)
++The plugin creates an "attachment tiddler" for each file you attach.  Regardless of where you store the binary content, your document can refer to the attachment tiddler rather than using a direct file or URL reference in your embedded image or external links, so that changing document locations will not require updating numerous tiddlers or copying files from one system to another.
++> Important note: As of version 3.6.0, in order to //render// images and other binary attachments created with this plugin, you must also install [[AttachFilePluginFormatters]], which extends the behavior of the ~TiddlyWiki core formatters for embedded images ({{{[img[tooltip|image]]}}}), linked embedded images ({{{[img[tooltip|image][link]]}}}), and external/"pretty" links ({{{[[label|link]]}}}), so that these formatter will process references to attachment tiddlers as if a normal file reference had been provided. |
++When you attach a file, a tiddler (tagged with<<tag attachment>>) is generated (using the source filename as the tiddler's title).  The tiddler contains //''base64 text-encoded binary data''//, surrounded by {{{/%...%/}}} comment markers (so they are not visible when viewing the tiddler).  The tiddler also includes summary details about the file: when it was attached, by whom, etc. and, if the attachment is an image file (jpg, gif, or png), the image is automatically displayed below the summary information.
++>Note: although you can edit an attachment tiddler, ''don't change any of the encoded content below the attachment header'', as it has been prepared for use in the rest of your document, and even changing a single character can make the attachment unusable.  //If needed, you ''can'' edit the header information or even the MIME type declaration in the attachment data, but be very careful not to change any of the base64-encoded binary data.//
++Unfortunately, embedding just a few moderately-sized binary files using base64 text-encoding can dramatically increase the size of your document.   To avoid this problem, you can create attachment tiddlers that define external local filesystem (file://) and/or remote web server (http://) 'reference' links, without embedding the binary data directly in the tiddler (i.e., uncheck "embed data" in the 'control panel').
++
++These links provide an alternative source for the binary data: if embedded data is not found (or you are running on Internet Explorer, which does not currently support using embedded data), then the plugin tries the local filesystem reference.  If a local file is not found, then the remote reference (if any) is used.  This "fallback" approach also lets you 'virtualize' the external links in your document, so that you can access very large binary content such as ~PDFs, ~MP3's, and even *video* files, by using just a 'remote reference link' without embedding any data or downloading huge files to your hard disk.
++
++Of course, when you //do// download an attached file, the local copy will be used instead of accessing a remote server each time, thereby saving bandwidth and allowing you to 'go mobile' without having to edit any tiddlers to alter the link locations...
++<<<
++!!!!!Syntax / Examples
++<<<
++To embed attached files as images or link to them from other tiddlers, use the standard ~TiddlyWiki image syntax ({{{[img[tooltip|filename]]}}}), linked image syntax ({{{[img[tooltip|filename][tiddlername]]}}}) , or "external link" syntax ({{{[[text|URL]]}}}), replacing the filename or URL that is normally entered with the title of an attachment tiddler.
++
++embedded image data:
++>{{{[img[Meow|tracelog dialog.png]]}}}
++>[img[Meow|tracelog dialog.png]]
++embedded image data with link to larger remote image:
++>{{{[img[click for larger view|tracelog dialog.png][tracelog dialog.png]]}}}
++>[img[click for larger view|tracelog dialog.png][tracelog dialog.png]]
++'external' link to embedded image data:
++>{{{[[click to view attachment|tracelog dialog.png]]}}}
++>[[click to view attachment|tracelog dialog.png]]
++'external' link to remote image:
++>{{{[[click to view attachment|tracelog dialog.png]]}}}
++>[[click to view attachment|tracelog dialog.png]]
++regular ~TiddlyWiki links to attachment tiddlers:
++>{{{[[tracelog dialog.png]]}}} [[tracelog dialog.png]]
++>{{{[[tracelog dialog.png]]}}} [[tracelog dialog.png]]
++<<<
++!!!!!Defining MIME types
++<<<
++When you select a source file, a ''[[MIME|http://en.wikipedia.org/wiki/MIME]]'' file type is automatically suggested, based on filename extension.  The AttachFileMIMETypes tiddler defines the list of MIME types that will be recognized by the plugin.  Each MIME type definition consists of exactly two lines of text: the official MIME type designator (e.g., "text/plain", "image/gif", etc.), and a space-separated list of file extensions associated with that type.  List entries are separated by "----" (horizontal rules).
++<<<
++!!!!!Known Limitations
++<<<
++Internet Explorer does not support the data: URI scheme, and cannot use the //embedded// data to render images or links.  However, you can still use the local/remote link definitions to create file attachments that are stored externally.  In addition, while it is relatively easy to read local //text// files, reading binary files is not directly supported by IE's ~FileSystemObject (FSO) methods, and other file I/O techniques are subject to security barriers or require additional MS proprietary technologies (like ASP or VB) that make implementation more difficult.  As a result, you cannot //create// new attachment tiddlers using IE.
++<<<
++!!!!!Installation
++<<<
++Import (or copy/paste) the following tiddlers into your document:
++* [[AttachFilePlugin]] (tagged with <<tag systemConfig>>)
++* [[AttachFilePluginFormatters]] ("runtime distribution library") (tagged with <<tag systemConfig>>)
++* ~TraceLog Dialog.png and ~TraceLog Dialog.png //(tagged with <<tag attachment>>)//
++* [[AttachFileMIMETypes]] //(defines binary file types)//
++> Important note: As of version 3.6.0, in order to //render// images and other binary attachments created with this plugin, you must also install [[AttachFilePluginFormatters]], which extends the behavior of the ~TiddlyWiki core formatters for embedded images ({{{[img[tooltip|image]]}}}), linked embedded images ({{{[img[tooltip|image][link]]}}}), and external/"pretty" links ({{{[[label|link]]}}}), so that these formatter will process references to attachment tiddlers as if a normal file reference had been provided. |
++<<<
++!!!!!Revisions
++<<<
++2009.06.04 4.0.0 changed attachment storage format to use //sections// instead of embedded substring markers.
++2008.07.21 3.9.0 Fixup for ~FireFox 3: use HTML with separate text+button control instead of type='file' control
++2008.05.12 3.8.1 automatically add 'attach' task to backstage (moved from ~BackstageTweaks)
++2008.04.09 3.8.0 in onChangeSource(), if source matches current document folder, use relative reference for local link.  Also, disable 'embed' when using IE (which //still// doesn't support data: URI)
++2008.04.07 3.7.3 fixed typo in HTML for 'local file link' so that clicking in input field doesn't erase current path/file (if any)
++2008.04.07 3.7.2 auto-create AttachFile shadow tiddler for inline interface
++2008.01.08 [*.*.*] plugin size reduction: documentation moved to ...Info
++2007.12.04 [*.*.*] update for ~TW2.3.0: replaced deprecated core functions, regexps, and macros
++2007.12.03 3.7.1 in createAttachmentTiddler(), added optional "noshow" flag to suppress display of newly created tiddlers.
++2007.10.29 3.7.0 code reduction: removed support for built-in upload to server... on-line hosting of binary attachments is left to the document author, who can upload/host files using 3rd-party web-based services (e.g. www.flickr.com, ) or stand-alone applications (e.g., FTP).
++2007.10.28 3.6.0 code reduction: removed duplicate definition of image and prettyLink formatters.  Rendering of attachment tiddlers now //requires// installation of AttachFilePluginFormatters
++2007.03.01 3.5.3 use apply() to invoke hijacked function
++2007.02.25 3.5.2 in hijack of "prettyLink", fix version check for ~TW2.2 compatibility (prevent incorrect use of fallback handler)
++2007.01.09 3.5.1 onClickAttach() refactored to create separate createAttachmentTiddler() API for use with ~FileDropPluginHandlers
++2006.11.30 3.5.0 in getAttachment(), for local references, add check for file existence and fallback to remote URL if local file not found.  Added fileExists() to encapsulate FF vs. IE local file test function (IE FSO object code is TBD).
++2006.11.29 3.4.8 in hijack for ~PrettyLink, 'simple bracketed link' opens tiddler instead of external link to attachment
++2006.11.29 3.4.7 in readFile(), added try..catch around initWithPath() to handle invalid/non-existent paths better.
++2006.11.09 3.4.6 REAL FIX for ~TWv2.1.3: incorporate new ~TW2.1.3 core "prettyLink" formatter regexp handling logic and check for version < 2.1.3 with fallback to old plugin code.  Also, cleanup table layout in HTML (added "border:0" directly to table elements to override stylesheet)
++2006.11.08 3.4.5 TEMPORARY FIX for ~TWv2.1.3: disable hijack of wikiLink formatter due to changes in core wikiLink regexp definition.  //Links to attachments are broken, but you can still use {{{[img[TiddlerName]]}}} to render attachments as images, as well as {{{background:url('[[TiddlerName]]')}}} in CSS declarations for background images.//
++2006.09.10 3.4.4 update formatters for 2.1 compatibility (use this.lookaheadRegExp instead of temp variable)
++2006.07.24 3.4.3 in prettyLink formatter, added check for isShadowTiddler() to fix problem where shadow links became external links.
++2006.07.13 3.4.2 in getAttachment(), fixed stripping of newlines so data: used in CSS will work
++2006.05.21 3.4.1 in getAttachment(), fixed substring() to extract data: URI (was losing last character, which broken rendering of SOME images)
++2006.05.20 3.4.0 hijack core getRecursiveTiddlerText() to support rendering attachments in stylesheets (e.g. {{{url([[TraceLog Dialog.png]])}}})
++2006.05.20 3.3.6 add "description" feature to easily include notes in attachment tiddler (you can always edit to add them later... but...)
++2006.05.19 3.3.5 add "attach as" feature to change default name for attachment tiddlers.  Also, new optional param to specify tiddler name (disables editing)
++2006.05.16 3.3.0 completed ~XMLHttpRequest handling for GET or POST to configurable server scripts
++2006.05.13 3.2.0 added interface for upload feature.  Major rewrite of code for clean object definitions.  Major improvements in UI interaction and validation.
++2006.05.09 3.1.1 add wikifer support for using attachments in links from "linked image" syntax: {{{[img[tip|attachment1][attachment2]]}}}
++2006.05.09 3.1.0 lots of code changes: new options for attachments that use embedded data and/or links to external files (local or remote)
++2006.05.03 3.0.2 added {{{/%...%/}}} comments around attachment data to hide it when viewing attachment tiddler.
++2006.02.05 3.0.1 wrapped wikifier hijacks in initAttachmentFormatters() function to eliminate globals and avoid ~FireFox 1.5.0.1 crash bug when referencing globals
++2005.12.27 3.0.0 Update for ~TW2.0.  Automatically add 'excludeMissing' tag to attachments
++2005.12.16 2.2.0 Dynamically create/remove attachPanel as needed to ensure only one instance of interface elements exists, even if there are multiple instances of macro embedding.
++2005.11.20 2.1.0 added wikifier handler extensions for "image" and "prettyLink" to render tiddler attachments
++2005.11.09 2.0.0 begin port from old ELS Design adaptation based on ~TW1.2.33
++2005.07.20 1.0.0 Initial release (as adaptation)
++<<<
++
++
++
The //BOF// property returns a value that indicates whether the current record position is before the first record in a [[Recordset]] object.
++The //EOF// property returns a value that indicates whether the current record position is after the last record in a [[Recordset]] object.
++!!!Applies to ...
++| !Object |!Description |
++|[[Recordset]] |The representation of a set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.BOF}}}
++//recordset//{{{.EOF}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++*You can use the //BOF// and //EOF// properties to determine whether a //Recordset// object contains records or whether you've gone beyond the limits of a //Recordset// object when you move from record to record.
++*If either the //BOF// or //EOF// property is {{{True}}}, there is no current record.
++*If you open a //Recordset// object containing no records, the //BOF// and //EOF// properties are set to {{{True}}}, and the //Recordset// object's [[RecordCount]] property setting is 0. When you open a //Recordset// object that contains at least one record, the first record is the current record and the //BOF// and //EOF// properties are {{{False}}}; they remain {{{False}}} until you move beyond the beginning or end of the //Recordset// object by using the [[MovePrevious|Move (recordset)]] or [[MoveNext|Move (recordset)]] method, respectively. When you move beyond the beginning or end of the //Recordset//, there is no current record or no record exists.
++*If you delete the last remaining record in the //Recordset// object, the //BOF// and //EOF// properties may remain {{{False}}} until you attempt to reposition the current record.
++*Typically, when you work with all the records in a //Recordset// object, your code will loop through the records by using the //~MoveNext// method until the //EOF// property is set to {{{True}}}.
++*If you use the //~MoveNext// method while the //EOF// property is set to {{{True}}} or the //~MovePrevious// method while the //BOF// property is set to {{{True}}}, an error occurs.
++!!!Error messages
++!!!See also
++[[Move|Move (recordset)]]
++[[MoveFirst|Move (recordset)]]
++[[MoveLast|Move (recordset)]]
++[[MoveNext|Move (recordset)]]
++[[MovePrevious|Move (recordset)]]
++[[Recordset]]
++!!!Example
++<<tiddler "OpenRecordset example">>
++
++
++
The //~BackColor// property specifies or determines the color (RGB) of the Control's background.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a Dialog |!Description |
++|[[Control]] |All except<br />--~GroupBox<br />~HiddenControl<br />[[SubForm]]-- | None | All |A control on an open form |
++!!!Syntax
++//control//{{{.BackColor}}}
++//control//{{{.BackColor}}} = //value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++The //~BackColor// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~BackColor' not applicable in this context |
++|Value '...' is invalid for property '~BackColor' |
++!!!See also
++[[BorderColor]]
++[[BorderStyle]]
++[[ForeColor]]
++!!!Example
++<<tiddler "Color example">>
++
++
++
The //~BeginGroup// property returns {{{True}}} if the specified [[command bar control|CommandBarControl]] appears at the beginning of a group of controls on the command bar. The property is read-only.
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBarControl]] |A control belonging to a [[CommandBar]]. |
++!!!Syntax
++//commandbarcontrol//{{{.BeginGroup}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++
++
++
++
<script>
++if (!window.story) window.story=window;
++var url="http://www.access2base.com/access2base.html";	//store.getTiddlerText("SiteUrl");
++if (!url) url=document.location.href;
++var title=story.findContainingTiddler(place).id.substr(7).replace('_',' ')	//var title=story.findContainingTiddler(place).id.substr(7)
++var permalink=encodeURIComponent(String.encodeTiddlyLink(title));
++return "\n"+"|Bookmark this page » » [["+title+"|"+url+"#"+permalink+"]]|";
++</script>
++
++
++
++
*sitemap.xml
++<script>
++var out=""
++var tids=store.getTiddlers("title","excludeLists");
++var d=""
++for (var t=0; t<tids.length; t++) {
++	var url="http://www.access2base.com/access2base.html";	//store.getTiddlerText("SiteUrl");
++	if (!url) url=document.location.href;
++	var permalink=encodeURIComponent(String.encodeTiddlyLink(tids[t].title));
++	d = tids[t].modified.getFullYear() + '-';
++	if (tids[t].modified.getMonth() + 1 < 10) d = d + '0';
++	d = d + (tids[t].modified.getMonth() + 1) + '-';
++	if (tids[t].modified.getDate() < 10) d = d + '0';
++	d = d +tids[t].modified.getDate();
++	out+="<url><loc>"+url+"#"+permalink+"</loc><lastmod>"+d+"</lastmod></url>"+"\n";
++}
++return "{{{\n"+out+"\n}}}\n"; 
++</script>
++*urllist.txt
++<script>
++var out=""
++var tids=store.getTiddlers("title","excludeLists");
++for (var t=0; t<tids.length; t++) {
++	var url="http://www.access2base.com/access2base.html";	//store.getTiddlerText("SiteUrl");
++	if (!url) url=document.location.href;
++	var permalink=encodeURIComponent(String.encodeTiddlyLink(tids[t].title));
++	out+=url+"#"+permalink+"\n";
++}
++return "{{{\n"+out+"\n}}}\n"; 
++</script>
++
++
++
The //Bookmark// property specifies uniquely the current record of
++*a form's underlying table, query or SQL statement;
++*a //Recordset// object.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form. |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//form//{{{.Bookmark}}}
++//form//{{{.Bookmark}}} = //value//
++//recordset//{{{.Bookmark}}}
++//recordset//{{{.Bookmark}}} = //value//
++!!!Returned values / Arguments
++{{{Variant}}}
++!!!Remarks
++*There is no rule about the bookmark value returned by the API. That's why the argument must be of type {{{Variant}}}.
++*The {{{value}}} argument refers to the record where to move to.
++*There is no limit to the number of bookmarks you can establish. To create a bookmark for a record other than the current record, move to the desired record and assign the value of the //Bookmark// property to a {{{Variant}}} variable that identifies the record.
++*The //Bookmark// property setting moves the cursor to the row identified by a valid bookmark. If the bookmark could not be located, the result set will be positioned after the last record. If the bookmark is invalid, or not generated by the current result set, then the behaviour is not defined, __even an abnormal termination is possible__.
++*To make sure the //Recordset// object supports bookmarks, check the value of its [[Bookmarkable]] property before you use the //Bookmark// property. If the //Bookmarkable// property is {{{False}}}, the //Recordset// object doesn't support bookmarks, and using the //Bookmark// property results in an error.
++!!!Error messages
++|Form '...' is currently not open |
++|Action rejected in a forward-only or not bookmarkable recordset |
++|Value '...' is invalid for property 'Bookmark' |
++!!!See also
++[[Bookmarkable]]
++[[GoToRecord]]
++[[Move|Move (recordset)]]
++[[MoveFirst|Move (recordset)]]
++[[MoveLast|Move (recordset)]]
++[[MoveNext|Move (recordset)]]
++[[MovePrevious|Move (recordset)]]
++[[Recordset]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Bookmark example">>
++<<tiddler "Bookmark2 example">>
++
++
++
Register the actual record of a form
++//{{{
++Global gvBookmark As Variant
++//}}}
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	gvBookmark = ofForm.Bookmark
++//}}}
++Later on, for any reason, go back to same record
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	ofForm.Bookmark = gvBookmark
++//}}}
++
++
++
Walk through a recordset with bookmarks
++//{{{
++Dim oRecordset As Object, vBookmark As Variant
++	Set oRecordset = Application.CurrentDb().OpenRecordset("SELECT * FROM [ARTICLE]")
++	With oRecordset
++		.Move(1000)
++		If .Bookmarkable Then
++			vBookmark = .Bookmark
++			.MoveLast
++			MsgBox "Last record = # " & .RecordCount
++			.Bookmark = vBookmark		'	Back to bookmarked record
++		End If
++		.mClose()				'	Never forget !!
++	End With
++
++//}}}
++
++
++
The //Bookmarkable// property returns a value that indicates whether a [[Recordset]] object supports bookmarks, which you can set by using the [[Bookmark]] property.
++!!!Applies to ...
++| !Object |!Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.Bookmarkable}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++Check the Bookmarkable property setting of a //Recordset// object before you attempt to set or check the Bookmark property.
++!!!Error messages
++!!!See also
++[[Bookmark]]
++[[GoToRecord]]
++[[Move|Move (recordset)]]
++[[MoveFirst|Move (recordset)]]
++[[MoveLast|Move (recordset)]]
++[[MoveNext|Move (recordset)]]
++[[MovePrevious|Move (recordset)]]
++[[Recordset]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Bookmark2 example">>
++
++
++
The //~BorderColor// property specifies or determines the color (RGB) of a Control's border.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a Dialog |!Description |
++|[[Control]] |All except<br />--~CheckBox<br />~CommandButton<br />~GroupBox<br />~HiddenControl<br />~NavigationBar<br />[[RadioButton]]<br />[[SubForm]]-- | None |All except<br />--~CheckBox<br />~CommandButton<br />~FixedLine<br />[[RadioButton]]-- |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.BorderColor}}}
++//control//{{{.BorderColor}}} = //value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++*The //~BorderColor// property is not compatible with all values of the [[BorderStyle]] property.
++*The //~BorderColor// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~BorderColor' not applicable in this context |
++|Value '...' is invalid for property '~BorderColor' |
++!!!See also
++[[BackColor]]
++[[BorderStyle]]
++[[ForeColor]]
++!!!Example
++<<tiddler "Color example">>
++
++
++
The //~BorderStyle// property specifies or determines the style (normal, 3D) of a Control's border.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a Dialog |!Description |
++|[[Control]] |All except<br />--~CheckBox<br />~CommandButton<br />~GroupBox<br />~HiddenControl<br />[[RadioButton]]<br />[[SubForm]]-- | None |All except<br />--~CheckBox<br />~CommandButton<br />~FixedLine<br />[[RadioButton]]-- |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.BorderStyle}}}
++//control//{{{.BorderStyle}}} = //value//
++!!!Returned values / Arguments
++{{{Integer}}}
++!!!Remarks
++*The allowed values for ~BorderStyle are:
++>0: No border
++>1: 3D border
++>2: simple border
++*The //~BorderStyle// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~BorderStyle' not applicable in this context |
++|Value '...' is invalid for property '~BorderStyle' |
++!!!See also
++[[BorderColor]]
++!!!Example
++<<tiddler "Color example">>
++
++
++
(Q) Can I list the value of all controls on a form for debugging purposes ?
++
++(R) Use the [[Controls]] collection on objects and nested objects recursively as shown.
++
++Consider next tables:
++<<tiddler "OrdersTable">>
++<<tiddler "OrderDetailsTable">>
++Define a main/sub form based on those tables (wizard is perfect for making the form ...: choose a normal format for the mainform and the grid format for the subform).
++
++Run next code:
++//{{{
++Sub StartBrowseThruControls(ByVal psFormName As String)
++
++Dim oMainForm As Object
++	Set oMainForm = Forms(psFormName)
++	BrowseThruControls(oMainForm)
++
++End Sub
++
++Sub BrowseThruControls(poObject As Object, ByVal Optional piLevel As Integer)
++
++Dim i As Integer, ocControl As Object
++	If IsMissing(piLevel) Then piLevel = 1
++	For i = 0 To poObject.Controls.Count - 1
++		Set ocControl = poObject.Controls(i)
++		Select Case ocControl.SubType
++			Case "SUBFORMCONTROL"
++				DebugPrint piLevel, ocControl.SubType, ocControl.Name
++				BrowseThruControls(ocControl.Form, piLevel + 1)
++			Case "GRIDCONTROL"
++				DebugPrint piLevel, ocControl.SubType, ocControl.Name
++				BrowseThruControls(ocControl, piLevel + 1)
++			Case Else
++				If ocControl.hasProperty("Value") Then DebugPrint piLevel, ocControl.SubType, ocControl.Name, ocControl.Value
++		End Select
++	Next i
++
++End Sub
++//}}}
++This will produce next result in the //~Access2Base// console:
++//{{{
++13:23:38 ===>    1    TEXTFIELD txtShipPostalCode   51100
++13:23:38 ===>    1    FORMATTEDFIELD fmtShipVia     3
++13:23:38 ===>    1    DATEFIELD datRequiredDate     01/08/1996
++13:23:38 ===>    1    SUBFORMCONTROL SubForm
++13:23:38 ===>    2    GRIDCONTROL    SubForm_Grid
++13:23:38 ===>    3    FORMATTEDFIELD OrderID   10248
++13:23:38 ===>    3    FORMATTEDFIELD Discount  0
++13:23:38 ===>    3    FORMATTEDFIELD ProductID 11
++13:23:38 ===>    3    FORMATTEDFIELD UnitPrice 14
++13:23:38 ===>    3    FORMATTEDFIELD Quantity  12
++13:23:38 ===>    1    DATEFIELD datShippedDate 16/07/1996
++13:23:38 ===>    1    TIMEFIELD timShippedDate 0
++13:23:38 ===>    1    FORMATTEDFIELD fmtEmployeeID  5
++13:23:38 ===>    1    TEXTFIELD txtShipName    Vins et alcools Chevalier
++13:23:38 ===>    1    TIMEFIELD timRequiredDate     0
++13:23:39 ===>    1    TEXTFIELD txtShipAddress 59 rue de l'Abbaye
++13:23:39 ===>    1    FORMATTEDFIELD fmtOrderID     10248
++13:23:39 ===>    1    FORMATTEDFIELD fmtFreight     32,38
++13:23:39 ===>    1    DATEFIELD datOrderDate   04/07/1996
++13:23:39 ===>    1    TEXTFIELD txtShipCountry France
++13:23:39 ===>    1    TEXTFIELD txtShipCity    Reims
++13:23:39 ===>    1    TEXTFIELD txtShipRegion  
++13:23:39 ===>    1    TIMEFIELD timOrderDate   0
++13:23:39 ===>    1    TEXTFIELD txtCustomerID  WILMK
++//}}}
++It makes clear:
++*that a subform is a control like any control
++*that the gridcontrol is simply embedded in the subform also like any other control
++!!!See also
++[[DebugPrint]]
++[[Form (subform)]]
++[[hasProperty]]
++[[SubType]]
++[[TraceConsole]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Browse |~Orders_Browse ||||Open the form manually and run the //Main// Sub from the Basic IDE. |
++
++
++
The //~BuiltIn// property returns {{{True}}} if the specified [[command bar|CommandBar]]  or [[command bar control|CommandBarControl]] is a built-in command bar or command bar control of the container window. It returns {{{False}}} if it is a custom command bar or command bar control. The property is read-only.
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBar]] |The representation of a tool-, menu- or statusbar. |
++|[[CommandBarControl]] |A control belonging to a ~CommandBar. |
++!!!Syntax
++//commandbar//{{{.BuiltIn}}}
++//commandbarcontrol//{{{.BuiltIn}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++!!!Example
++<<tiddler "CommandBar example">>
++
++
++
(Q) How do I simulate a calculated field on a form ? //AOO/~LibO// does not support such fields in forms while //~MSAccess// does.
++
++(R)
++*Make the calculated field {{{Enabled = False}}} in the Control properties sheet.
++*Compute its content in the "After record Change" event.
++
++Let's consider next tables:
++<<tiddler OrdersTable>>
++<<tiddler OrderDetailsTable>>
++The goal is to have a form linked to the {{{Orders}}} table in which a //~SumOfDetails// calculated field contains the sum of the orders as found in the {{{Order Details}}} child records, computed as:
++//{{{
++[Order Details].[UnitPrice] * [Order Details].[Quantity] * (1 - [Order Details].[Discount])
++//}}}
++!!!(1) Solution by computing the field in Basic
++Store next code in the "After record Change" event of the form :
++//{{{
++Sub ComputeOrderTotal(poEvent As Object)
++Dim oeEvent As Object, ofForm As Object, ocSum As Object, vOrderId As Variant
++	Set oeEvent = Events(poEvent)
++	If Not IsNull(oeEvent) Then
++		Set ofForm =oeEvent.Source
++		vOrderId = ofForm.Controls("OrderID").Value
++		If Not IsEmpty(vOrderId) Then
++			Set ocSum = ofForm.Controls("SumOfDetails")
++			ocSum.Value = DSum("[Order Details].[UnitPrice] * [Order Details].[Quantity] * (1 - [Order Details].[Discount])" _
++				, "[Order Details]", "[Order Details].[OrderID]=" & vOrderId)
++		End If
++	End If
++End Sub
++//}}}
++!!!(2) Solution with SQL only
++This solution is preferable whenever possible.
++To have an idea of the functions built in HSQLDB, look at [[HSLQB Built-in functions|http://wiki.openoffice.org/wiki/Built-in_functions_and_Stored_Procedures]].
++Associate the form with next SQL command and the Calculated field with the //~TotalOrder// database field :
++//{{{
++SELECT "Orders"."OrderID", "Orders"."OrderDate", "Orders"."ShipAddress", "Orders"."ShipCity",
++	SUM( "Order Details"."UnitPrice" * "Order Details"."Quantity" * ( 1 - "Order Details"."Discount" ) ) AS "TotalOrder"
++	FROM "Order Details", "Orders" WHERE "Order Details"."OrderID" = "Orders"."OrderID"
++	GROUP BY "Orders"."OrderID", "Orders"."OrderDate", "Orders"."ShipAddress", "Orders"."ShipCity"
++//}}}
++!!!See also
++[[Events Handler]]
++[[getObject]]
++[[DSum]]
++[[Forms]]
++[[Controls]]
++!!!Refer to ...
++| !Solution | !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++| (1) |~CalculatedField |~Orders_CalculatedField |After Record change |||
++| (2) |~|~Orders_CalculatedFieldGrid ||~|~|
++
++
++
(Q) Can a numeric field be edited thru a Calculator widget like Base forms propose a Calendar widget for date fields ?
++
++(R) A calculator can be implemented as a [[Dialog]]. When the dialog is closed the computed result is copied into the concerned form field.
++
++The solution must implement a //as easy as possible// programming AND user interface from the initial form event activating the calculator up to the final copy of the result into the numeric form field.
++See the suggested implementation in the //Calculator// form of the provided examples database: a button with a nice calculator icon opens the dialog.
++
++Steps:
++!!!!Make a form containing the targeted  numeric fields and one button by such field.
++Link the //Execute action// event of each button with a macro similar to next one. One macro by each field/button pair.
++//{{{
++Sub StartCalculator(poEvent As Object)
++'	StartCalculator should be adapted to user's need:
++'	- it is assumed to be activated from an appropriate button
++'	- the field to compute is assumed in the same form or subform as the button
++'	- the field to compute must be of type NUMERICFIELD or CURRENCYFIELD
++'	- the name of the field to compute should be set in next line
++'	- The 3rd argument is optional. True = initialize calculator with field current value
++
++	Call StartCalcDialog(poEvent, "TargetCalcField", True)
++	
++End Sub
++//}}}
++Of course adapt the code to your needs !
++!!!!--Design a calculator such as-- ... Export and re-import next calculator dialog ...
++[img[calculator.png]]
++!!!!The code behind the //~StartCalcDialog// Sub
++The code is stored in the //Calculator// module of the provided example file. It is inspired by an old [[sample code from Microsoft|http://groups.engin.umd.umich.edu/CIS/course.des/cis400/vbasic/calcode.txt]].
++It is generic enough to adapt the display of the decimal point to the locale settings.
++
++1. The current status of the Calculator is constantly maintained in next variables
++//{{{
++Type CalcBuffer
++	DisplayField		As Object		'	Display window on calculator dialog
++	Operand1		As Double		'	1st Operand
++	Operand2		As Double		'	2nd Operand
++	DisplayText		As String		'	To display in dialog
++	NumberOfOperands	As Integer		'	1 or 2
++	DecimalPoint		As Boolean		'	Decimal point present yet ?
++	LastInput		As String		'	Indicate type of last keypress event (NONE, CE, NUMS, NEG, OPS)
++	PendingOperation	As String		'	Indicate pending operation (+, -, *, /)
++	LocalePoint		As String		'	Local decimal point
++End Type
++
++Public gCalc As CalcBuffer
++Const cstStdFormat = "General Number"		'	Format of display in calculator
++//}}}
++2. Next Sub (the core Sub) checks the arguments, manages the display of the dialog window, and copies the result in the original numeric field if the OK button is pressed:
++//{{{
++Sub StartCalcDialog(poEvent, ByVal psFieldName As String, Optional ByVal pbCopy As Boolean)
++
++Dim ocFieldToCompute As Object, ocButton As Object, ofForm As Object, oDialog As Object
++Dim i As Integer, bFound As Boolean, iDialog As Integer
++	Set ocButton = Application.Events(poEvent).Source
++	If ocButton.ObjectType <> "CONTROL" Then Exit Sub
++	
++	If IsMissing(pbCopy) Then pbCopy = True
++	
++	'Check field name exists
++	Set ofForm = ocButton.Parent	'	ofForm could be a form or a subform !
++	bFound = False
++	For i = 0 To ofForm.Controls().Count - 1
++		Set ocFieldToCompute = ofForm.Controls(i)
++		If UCase(ocFieldToCompute.Name) = UCase(psFieldName) Then
++			bFound = True
++			Exit For
++		End If
++	Next i
++	If Not bFound Then
++		TraceLog("ERROR", "Field name " & psFieldName & " not found in form or subform " & ofForm.Name)
++		Exit Sub
++	End If
++	
++	'Check field is of admitted types
++	If ocFieldToCompute.SubType <> "NUMERICFIELD" And ocFieldToCompute.SubType <> "CURRENCYFIELD" Then
++			TraceLog("ERROR", "Field " & psFieldName & " is not numeric")
++			Exit Sub
++	End If
++	
++Const dlgOK = 1				'	OK button pressed
++Const dlgCancel = 0			'	Cancel button pressed
++	Set oDialog = Application.AllDialogs("dlgCalc")
++	oDialog.Start
++
++	'	Initialize gCalc
++	gCalc.DisplayField = oDialog.Controls("CalcDisplay")
++	gCalc.LocalePoint = Right(Format(0,"General Number"),1)
++	If pbCopy Then
++		gCalc.Operand1 = ocFieldToCompute.Value
++		gCalc.Operand2 = gCalc.Operand1
++		gCalc.DisplayText = Join(Split(Format(gCalc.Operand1, cstStdFormat), ","), ".")
++		gCalc.DecimalPoint = ( Abs(gCalc.Operand1 - Fix(gCalc.Operand1)) > 0 )
++		gCalc.NumberOfOperands = 1
++		gCalc.LastInput = "OPS"
++		gCalc.PendingOperation = "="
++	Else
++		gCalc.LastInput = "NONE"
++		gCalc.NumberOfOperands = 0
++		gCalc.PendingOperation = " "
++		gCalc.DecimalPoint = False
++		gCalc.Operand1 = 0
++		gCalc.Operand2 = 0
++	End If
++	
++	'Load dialog
++	gCalc.DisplayField.Value = Format(gCalc.Operand1, cstStdFormat)
++	oDialog.Controls("BtnPoint").Caption = gCalc.LocalePoint		'	Set decimal point button to locale setting
++	iDialog = oDialog.Execute
++	Select Case iDialog
++		Case dlgOK
++			ocFieldToCompute.Value = gCalc.Operand1
++		Case dlgCancel
++	End Select
++	
++	oDialog.Terminate
++	Exit Sub
++End Sub
++//}}}
++3. The calculator should react to each activation of any button in the dialog box. Link all buttons - except //OK// and //Cancel// - //Execute action// event to next Sub:
++//{{{
++Sub CalcButtonPressed(poEvent As Object)
++
++Dim oEvent As Object, sName As String, oButton As Object, oDisplay As Object, sChar As String
++	Set oEvent = Application.Events(poEvent)
++	If oEvent.EventType <> "ACTIONEVENT" Then Exit Sub
++	
++	Set oButton = oEvent.Source
++	sName = UCase(oButton.Name)
++	Select Case sName
++		Case "BTNADD"			:	sChar = "+"
++		Case "BTNSUB"			:	sChar = "-"
++		Case "BTNMULT"			:	sChar = "*"
++		Case "BTNDIV"			:	sChar = "/"
++		Case "BTNENTER"			:	sChar = "="
++		Case "BTNCLEAR"			:	sChar = "C"
++		Case "BTNCE"			:	sChar = "CE"
++		Case "BTNINVERT"		:	sChar = "1/x"
++		Case "BTNPOINT"			:	sChar = "."
++		Case Else			:	sChar = Right(sName, 1)		'	DIGIT !!
++	End Select
++	Call ProcessKey(sChar)
++	Exit Sub
++	
++End Sub
++//}}}
++4. In addition, the caculator should react in the same way when the equivalent key is pressed. Link the //Key pressed// event of the //~CalcDisplay// field (i.e. the display of the calculator) to next Sub:
++//{{{
++Sub CalcKeyPressed(poEvent As Object)
++
++Dim oEvent As Object, oDisplay As Object, sChar As String
++	Set oEvent = Application.Events(poEvent)
++	If oEvent.EventType <> "KEYEVENT" Then Exit Sub
++
++'Accepted keys: 0-9, BACKSPACE, C, ESCAPE, dot, comma, +, -, *, /, %, =, ENTER.
++'All other keys ignored
++	With oEvent
++		Select Case True	'	Both KeyCode and KeyChar used to be generic across all keyboards and OS's
++			Case .KeyAlt, .KeyCtrl	:	Beep	:	Exit Sub	'	Ignore if associated with Alt or Ctrl
++			Case .KeyCode = com.sun.star.awt.Key.ESCAPE Or UCase(.KeyChar) = "C"	:	sChar = "C"
++			Case .KeyCode = com.sun.star.awt.Key.BACKSPACE				:	sChar = "CE"
++			Case .KeyCode = com.sun.star.awt.Key.RETURN Or .KeyCode = com.sun.star.awt.Key.EQUAL Or .KeyChar = "="
++				sChar = "="
++			Case .KeyCode = com.sun.star.awt.Key.ADD Or .KeyChar = "+"		:	sChar = "+"
++			Case .KeyCode = com.sun.star.awt.Key.SUBTRACT Or .KeyChar = "-"		:	sChar = "-"
++			Case .KeyCode = com.sun.star.awt.Key.MULTIPLY Or .KeyChar = "*"		:	sChar = "*"
++			Case .KeyCode = com.sun.star.awt.Key.DIVIDE Or .KeyChar = "/" Or .KeyChar = ":"
++				sChar = "/"
++			Case .KeyChar = "_"							:	sChar = "1/x"
++			Case .KeyCode = com.sun.star.awt.Key.DECIMAL Or .KeyCode = com.sun.star.awt.Key.POINT _
++				Or .KeyCode = com.sun.star.awt.Key.COMMA Or .KeyChar = "." Or .KeyChar = ","
++				sChar = "."
++			Case .KeyChar >= "0" And .KeyChar <= "9"				:	sChar = .KeyChar
++			Case .KeyCode >= com.sun.star.awt.Key.NUM0 And .KeyCode <= com.sun.star.awt.Key.NUM9
++				sChar = Trim(Str(.KeyCode - com.sun.star.awt.Key.NUM0))
++			Case Else		:	Beep	:	Exit Sub
++		End Select
++	End With
++	
++	Call ProcessKey(sChar)
++	Exit Sub
++
++End Sub
++//}}}
++5. Now the real processing of the entered key or the clicked button:
++//{{{
++Sub ProcessKey(ByVal psChar As String)
++'	Process gCalc structure based on argument
++
++Dim sDisplayText As String
++Const cstMax = 999999999999
++
++	Select Case psChar
++		Case "C"		'	Cancel
++			gCalc.DisplayText = Format(0, "0.")
++			gCalc.Operand1 = 0
++			gCalc.Operand2 = 0
++			gCalc.NumberOfOperands = 0
++			gCalc.PendingOperation = " "
++			gCalc.LastInput = "NONE"
++		Case "CE"		'	Cancel entry
++			gCalc.DisplayText = Format(0, "0.")
++			gCalc.DecimalPoint = False
++			gCalc.LastInput = "CE"
++		Case "."		'	Decimal point
++		' If last keypress was an operator, initialize DisplayText to "0."
++		' Otherwise, append a decimal point to the display.
++			If gCalc.DecimalPoint Then
++				Beep
++			Else
++				If gCalc.LastInput = "NEG" Then
++					gCalc.DisplayText = Format(0, "-0.")
++				ElseIf gCalc.LastInput <> "NUMS" Then
++					gCalc.DisplayText = Format(0, "0.")
++				End If
++				gCalc.DecimalPoint = True
++				gCalc.LastInput = "NUMS"
++			End If
++		Case "+", "-", "*", "/", "="	'	Arithmetic operators
++		' If the immediately preceeding keypress was part of a number, increment DecimalPoint. If one operand is present,
++		' set Operand1. If two are present, set Operand1 equal to the result of the operation on Operand1 and the current
++		' input string, and display the result.
++			sDisplayText = gCalc.DisplayText
++			If gCalc.LastInput = "NUMS" Then
++				gCalc.NumberOfOperands = gCalc.NumberOfOperands + 1
++			End If
++			Select Case gCalc.NumberOfOperands
++				Case 0
++					If psChar = "-" And gCalc.LastInput <> "NEG" Then
++						gCalc.DisplayText = "-" & gCalc.DisplayText
++						gCalc.LastInput = "NEG"
++					End If
++				Case 1
++					gCalc.Operand1 = Val(gCalc.DisplayText)
++					If psChar = "-" And gCalc.LastInput <> "NUMS" And gCalc.PendingOperation <> "=" Then
++						gCalc.DisplayText = "-"
++						gCalc.LastInput = "NEG"
++					End If
++				Case 2
++					gCalc.Operand2 = Val(sDisplayText)
++					Select Case gCalc.PendingOperation
++						Case "+"
++							gCalc.Operand1 = gCalc.Operand1 + gCalc.Operand2
++						Case "-"
++							gCalc.Operand1 = gCalc.Operand1 - gCalc.Operand2
++						Case "*"
++							gCalc.Operand1 = gCalc.Operand1 * gCalc.Operand2
++						Case "/"
++							If Sgn(gCalc.Operand2) = 0 Then
++								gCalc.Operand1 = cstMax * Sgn(gCalc.Operand1)
++							Else
++								gCalc.Operand1 = gCalc.Operand1 / gCalc.Operand2
++							End If
++						Case "="
++							gCalc.Operand1 = gCalc.Operand2
++					End Select
++					gCalc.DisplayText = Join(Split(Format(gCalc.Operand1, cstStdFormat), ","), ".")
++					gCalc.NumberOfOperands = 1
++			End Select
++			If gCalc.LastInput <> "NEG" Then
++				gCalc.LastInput = "OPS"
++				gCalc.PendingOperation = psChar
++			End If
++		Case "1/x"	'	Invert result
++			If gCalc.LastInput = "NUMS" Then gCalc.Operand1 = Val(gCalc.DisplayText)
++			If Sgn(gCalc.Operand1) = 0 Then
++				gCalc.Operand1 = cstMax
++			Else
++				gCalc.Operand1 = 1 / gCalc.Operand1
++			End If
++			gCalc.LastInput = "OPS"
++			gCalc.DisplayText = Join(Split(Format(gCalc.Operand1, cstStdFormat), ","), ".")
++		Case Else		'	DIGIT
++		' Append new number to the number in the display.
++			If gCalc.LastInput <> "NUMS" Then
++				gCalc.DisplayText = Format(0, ".")
++				gCalc.DecimalPoint = False
++			End If
++			If gCalc.DecimalPoint Then
++				gCalc.DisplayText = gCalc.DisplayText & psChar
++			Else
++				gCalc.DisplayText = Left(gCalc.DisplayText, InStr(gCalc.DisplayText, ".") - 1) & psChar & "."
++			End If
++			If gCalc.LastInput = "NEG" Then gCalc.DisplayText = "-" & gCalc.DisplayText
++			gCalc.LastInput = "NUMS"
++	End Select
++	
++	'DebugPrint psChar, gCalc.Operand1, gCalc.Operand2, gCalc.PendingOperation, gCalc.NumberOfOperands, gCalc.LastInput, gCalc.DisplayText
++	gCalc.DisplayField.Value = Join(Split(gCalc.DisplayText, "."), gcalc.LocalePoint)
++	Exit Sub
++
++End Sub
++//}}}
++!!!See also
++[[Dialog]]
++[[Control]]
++[[Events Handler]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Calculator |Calculator ||Calculator |Execute action |Enter an optional initial value and click on the icon. |
++|~|dlgCalc<br />(dialog) |~|cmd0...9<br />btnClear<br />btnCE<br />btnAdd<br />btnSub<br />btnMult<br />btnDiv<br />btnEnter<br />btnInvert |Execute action ||
++|~|~|~|~CalcDisplay |Key pressed |~|
++
++
++
The //Cancel// property specifies if a command button has or not the behaviour of a Cancel button.
++!!!Applies to ...
++| !Oobject | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |~CommandButton | None |~CommandButton |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.Cancel}}}
++//control//{{{.Cancel}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Property 'Cancel' not applicable in this context |
++|Value '...' is invalid for property 'Cancel' |
++!!!See also
++[[Default]]
++!!!Example
++<<tiddler "Cancel & Default example">>
++
++
++
Display the status of a command button
++//{{{
++Dim ocControl As Object
++	Set ocControl = getObject("Forms!myForm!cmdButton")
++	MsgBox "Cancel=" & ocControl.Cancel & " - Default=" & ocControl.Default
++//}}}
++
++
++
Cancels any pending updates for a [[Recordset object|Recordset]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.CancelUpdate()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++*You can use the //~CancelUpdate// method to cancel any pending updates resulting from an [[Edit]] or [[AddNew]] operation. For example, if a user invokes the //Edit// or //~AddNew// method and hasn't yet invoked the [[Update]] method, //~CancelUpdate// cancels any changes made after //Edit// or //~AddNew// was invoked.
++*Check the [[EditMode property|EditMode]] of the //Recordset// to determine if there is a pending operation that can be canceled.
++*Using the //~CancelUpdate// method has the same effect as moving to another record without using the //Update// method, except that the current record doesn't change, and various properties, such as [[BOF|BOF, EOF]] and [[EOF|BOF, EOF]], aren't updated.
++!!!Error Messages
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[DefaultValue]]
++[[Edit]]
++[[Update]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "CancelUpdate example">>
++
++
++
Modify the last record in a table fter user confirmation
++//{{{
++Dim oRecordset As Object
++Const cstYesNo = 4
++Const cstYes = 6
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Expenses")	'	"Expenses" = a table
++	With oRecordset
++		.MoveLast
++		.Edit
++		.Fields("AMOUNT").Value = 9876
++		If MsgBox("Do you confirm ?", cstYesNo, "Update record") = cstYes Then .Update Else .CancelUpdate
++		.mClose
++	End With
++//}}}
++
++
++
The //Caption// property specifies the text string appearing in the title bar of a [[form|Form]] or a [[dialog|Dialog]].
++When related to a [[Control]] the //Caption// property refers to the text associated with the control.
++When the control belongs to a [[GridControl]] the //Caption// property specifies the column header.
++When related to a [[CommandBarControl]] the //Caption// property refers to the text displayed in the button.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when in a Dialog |!Description |
++|[[Form]] ||||An open form. |
++|[[Dialog]] |~|~|~|An active dialog. |
++|[[Control]] | ~CheckBox<br />~CommandButton<br />~FixedText<br />~GroupBox<br />[[RadioButton]] | All | ~CheckBox<br />~CommandButton<br />~FixedLine<br />~FixedText<br />~GroupBox<br />[[RadioButton]] |A control on an open form, dialog or within a [[GridControl]] of one of the listed types. |
++|[[CommandBarControl]] ||||An element within a [[CommandBar]]. |
++!!!Syntax
++//form//{{{.Caption}}}
++//form//{{{.Caption}}} = //value//
++//dialog//{{{.Caption}}}
++//dialog//{{{.Caption}}} = //value//
++//control//{{{.Caption}}}
++//control//{{{.Caption}}} = //value//
++//commandbarcontrol//{{{.Caption}}}
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++When applied to a ~CommandBarControl, the //Caption// property is read-only.
++!!!Error messages
++|Form '...' is currently not open |
++|Dialog '...' not active |
++|Value '...' is invalid for property 'Caption' |
++!!!Examples
++<<tiddler "Caption examples">>
++
++
++
Display and change form title bar
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	MsgBox ofForm.Caption
++	ofForm.Caption = "New title"
++//}}}
++Change a checkbox label
++//{{{
++Dim ocCheckBox As Object
++	ocCheckBox = getObject("Forms!myForm!myChkBox")
++	If ocCheckBox.Value Then
++		ocCheckBox.Caption = "Checked"
++	Else
++		ocCheckBox.Caption = "Unchecked"
++	End If
++//}}}
++
++
++
(Q) How do I carry forward the current value of a control so that it's automatically entered for all new records?
++
++(R) To use the current control value for new records, you need to assign it to the defaultvalue of the control.
++
++Consider next table:
++<<tiddler "CustomersTable">>
++Then if a form is built on above table, link next code to the "After record change" event of the form:
++//{{{
++Sub SetDefaultNewRec(poEvent As Object)
++
++Dim ofForm As Object, ocControl As Object
++	Set ofForm = Events(poEvent).Source	'	Get the current form
++	Set ocControl = ofForm.Controls("txtCountry")
++	ocControl.DefaultValue = ocControl.Value
++	
++End Sub
++//}}}
++The //country// field will appear initialized with its value in the current record if the user enters a new record.
++!!!See also
++[[Events Handler]]
++[[DefaultValue]]
++[[Value]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~NewRec |~Customers_NewRec |After record change |||Go to whichever record, then click on the //new record// button. |
++
++
++
*Categories table
++| !Fields | !Field Type | !Primary |
++|~CategoryName | Text ||
++|Description | Text ||
++|Picture | Binary ||
++|~CategoryID | ~BigInt | Y |
++
++
++
Copy a binary field to another, whatever its size
++//{{{
++Dim oTable As Object, oBinField1 As Object, oBinField2 As Object
++Dim lFieldSize As Long, vBinary As Variant
++
++	Set oTable = Application.CurrentDb().OpenRecordset("myTable")
++	With oTable
++		.MoveFirst
++		Set oBinField1 = .Fields("myFld1")
++		Set oBinField2 = .Fields("myFld2")
++		lFieldSize = 0
++		.Edit
++		Do While lFieldSize < oBinField1.FieldSize
++			vBinary = oBinField1.GetChunk(lFieldSize, 100000)
++			lFieldSize = lFieldSize + UBound(vBinary) + 1
++			oBinField2.AppendChunk(vBinary)
++		Loop
++		.Update
++		.mClose	
++	End With
++//}}}
++
++
++
Creates a duplicate [[Recordset object|Recordset]] that refers to the original //Recordset// object..
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.Clone()}}}
++!!!Returned value
++A {{{recordset}}} object.
++!!!Remarks
++*Use the //Clone// method to create multiple, duplicate //Recordset// objects. Each //Recordset// can have its own current record. Using //Clone// by itself doesn't change the data in the objects or in their underlying structures. When you use the //Clone// method, you can share bookmarks between two or more //Recordset// objects because their bookmarks are interchangeable.
++*You can use the //Clone// method when you want to perform an operation on a //Recordset// that requires multiple current records. When created the current record of the clone is the first record if it exists.
++*A cloned //Recordset// is always read-only.
++*It is forbidden to use the //Clone// method on a cloned //Recordset//.
++*The cloned //Recordset(s)// must be closed __before__ the original //Recordset//.
++!!!Error Messages
++|Cloning a cloned Recordset is forbidden |
++!!!See also
++[[Close|Close (method)]]
++[[OpenRecordset]]
++!!!Example
++<<tiddler "Clone example">>
++
++
++
Use a cloned recordset to move to a bookmark without changing the current record
++//{{{
++Dim oRecordset1 As Object, oRecordset2 As Object, vBookmark As Variant
++	Set oRecordset1 = Application.CurrentDb().OpenRecordset("SELECT * FROM [PRODUCTS]")
++	oRecordset1.Move(300)
++	DebugPrint oRecordset1.Fields("DENOMINATION").Value
++	vBookmark = oRecordset1.Bookmark
++	Set oRecordset2 = oRecordset1.Clone()			'	Bookmarks become interchangeable
++	oRecordset1.MoveLast					'	Continue navigation
++	oRecordset2.Bookmark = vBookmark
++	DebugPrint orecordset2.Fields("DENOMINATION").Value
++	oRecordset2.mClose()					'	First close clone
++	oRecordset1.mClose()
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Close// action closes an object (table, query, form or report).
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]mClose(}}}//{{{ObjectType, ObjectName, Save}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{ObjectType}}} | No | acTable<br />acQuery<br />acForm<br />acReport |The type of object to close. |
++|{{{ObjectName}}} | No | String |The name of the object to close. This argument is NOT case-sensitive. |
++|{{{Save}}} | Yes | acSavePrompt |Indicates if a prompt to the user will prevent from closing without saving. acSavePrompt is the only supported value. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++
++Const acSavePrompt = 0
++//}}}
++!!!Remarks
++*The {{{ObjectName}}} object must exist in the database document (".odb" file). However if it is not open, the command has no effect.
++*If the object is a table or a query, and the object is not open, running the //Close// action will open the Table or Query and close it immediately.
++*The //Close// action is not allowed from a non-Base document containing [[standalone forms|Standalone Forms]].
++!!!Error messages
++|Table (or form or query or report) '...' could not be closed |
++|Table (or form or query or report) '...' not found |
++!!!See also
++[[OpenForm]]
++[[OpenQuery]]
++[[OpenReport]]
++[[OpenTable]]
++!!!Example
++//{{{
++	DoCmd.mClose(acTable, "myTable")
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Close// method closes the targeted object.
++!!!Applies to ...
++| !Object | !Description |
++|[[Database]] |The representation of a database opened with the [[OpenDatabase]] method. |
++|[[Form]] |The representation of an open form. |
++|[[Recordset]] |The representation of a set of records. |
++!!!Syntax
++//database//{{{.mClose()}}}
++//form//{{{.mClose()}}}
++//recordset//{{{.mClose()}}}
++!!!Remarks
++When applied to a __database object__:
++*A database object opened with //~OpenDatabase// should not remain open longer than strictly needed.
++*Recordsets derived from the database object should be closed __before__ the database object.
++When applied to a __form object__:
++*The //Close// method is equivalent to the [[Close]] action when applied to the same form.
++*The //Close// method is not allowed from a [[standalone form|Standalone Forms]] contained in a non-Base (Calc, Writer, ...) document.
++When applied to a __recordset object__:
++*After processing a recordset should be closed as soon as possible.
++*To close all open recordsets at once, use the [[CloseAllRecordsets]] method.
++*Once a //recordset// has been closed, all [[Field objects|Field]] objects derived from its [[Fields collection|Fields]] must not be used anymore.
++!!!Error messages
++Processing is never interrupted when the //Close// method is invoked.
++!!!See also
++[[OpenDatabase]]
++[[OpenForm]]
++[[OpenRecordset]]
++[[CloseAllRecordsets]]
++!!!Example
++//{{{
++Dim ofForm As Object
++	ofForm = Forms("myForm")
++	ofForm.mClose()
++//}}}
++<<tiddler "OpenRecordset example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~CloseAllrecordsets// method closes all the currently open [[recordsets|Recordset]] in the current database.
++After processing a recordset should be closed as soon as possible. To close all open recordsets at once, use the //~CloseAllRecordsets// method.
++!!!Applies to ...
++| !Object | !Description |
++|[[Database]] |The representation of a connected database. |
++!!!Syntax
++//database//{{{.CloseAllrecordsets()}}}
++!!!Remarks
++The current database can be retrieved by using the [[CurrentDb]] method applied either to the [[Application]] object, or to a [[form|Form]] object
++!!!Error messages
++Processing is never interrupted when the //~CloseAllrecordsets// method is invoked.
++!!!See also
++[[OpenRecordset]]
++[[Close (method)]]
++!!!Example
++//{{{
++	Application.CurrentDb().CloseAllrecordsets()
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he invocation of the //~CloseConnection// as a Sub is ''recommended'' but not mandatory before closing a document invoking the //~Access2Base// API.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{Call [Application.]CloseConnection ()}}}
++!!!Remarks
++*The invocation of //~CloseConnection// has next effects:
++**All the [[recordsets|Recordset]] related to a database linked to the current document are closed.
++**The [[database object(s)|Database]] is(are) released.
++*It is recommended to have all open embedded forms closed before calling //~CloseConnection//.
++*Calling //~CloseConnection// is best done from a //"View is going to be closed"// document event.
++*After //~CloseConnection// the [[CurrentDb]] function returns {{{Nothing-}}} (to be tested with the {{{IsNull()}}} Basic function).
++*If needed, __for database documents only__ ("*.odb" files) the connection can be re-established with the [[OpenConnection]] method. For [[Standalone Forms]] an //~OpenConnection// request invoked after a //~CloseConnection// invocation will be ignored.
++<<tiddler "RunWithoutConnection">>
++!!!See also
++[[Database]]
++[[CurrentDb]]
++[[Install]]
++{{OpenConnection]]
++[[OpenDatabase]]
++[[Standalone Forms]]
++
++
++
++
This page details the conventions used in the coding of the //~Access2Base// API.
++!!Library and Modules
++*The acConstants module lists constants that are used in the API. They are defined as //Global//. Their name is identical as in ~MSAccess. Their value is in most cases identical to that of ~MSAccess, however not always. The scope of global constants is limited to one single library. As a consequence their definition may freely be copied and pasted to make them available in user libraries.
++*The reserved words are //~Proper-Cased// showing the same appearance as in the IDE of ~MSAccess.
++!!Functions and Subroutines
++*~OpenOffice/~LibreOffice ignores the Private/Public attribute in Functions or Subs declarations. Nevertheless the attribute must be present. Rules for use are:
++| !Attribute | !Sub/Function Naming | !When |
++|Public |Starts with a letter |The Sub/Function belongs to the ~Access2Base API. As such it may be called from any other library developed by the user. |
++|Public |Starts with an underscore "_" |The Sub/Function must be called only from within the ~Access2Base library. As such it MUST NOT be called from another library as there is no guarantee about the arguments, the logic or even the existence of that piece of code in a later release. |
++|Private |The Sub/Function must start with an underscore "_" |The Sub/Function must be called only from the module in which it is located |
++*Functions and Subroutines belonging to the API (= "standard" functions/Subs) are defined in their module in alphabetical order.
++*Functions and Subroutines not belonging to the API are defined in their module in alphabetical order below the standard ones.
++*The return value of a function is always declared explicitly.
++*The parameters are always declared explicitly even if they're variants.
++*The Function and Sub declarations start at the 1^^st^^ column of the line.
++*The End Function/Sub statement is followed by a comment reminding the name of the function or sub.
++!!Variable declarations
++*The //Option Explicit// statement is mandatory in every module.
++*The Global, Dim and Const statements always start in the first column of the line.
++*The type (Dim ... As ..., Function ... As ...) is always declared explicitly, even if the type is Variant.
++*Variables are //~Proper-Cased//. They are always preceded by a lower-case letter indicating their type. With next exception: variables i, j, k, l, m and n must be declared as integers.
++| !First letter | !Type |
++| b |Boolean |
++| d |Date |
++| v |Variant |
++| o |Object |
++| i |Integer |
++| l |Long|
++| s |String |
++{{indent{Example:{{{          Dim sValue As String}}}
++*Parameters are preceded by the letter //p// which itself precedes the single typing letter. Like in:<br />{{{Public Function MyFunction(psValue As String) As Variant}}}
++*Object variables are preceded by the letter o followed by their type:
++| !First letter | !Type |
++| db |Database |
++| f |Form or Subform |
++| c |Control |
++| e |Event |
++| p |Property |
++{{indent{like in:{{{          Dim ocControl As Object}}}
++*Global variables in the ~Access2Base library are ALL preceded by an underscore "_" as NONE of them should be invoked from outside the library.
++*Constant values with a local scope are //~Proper-Cased// and preceded by the letters //cst//.
++*Constants with a global scope are //~UPPER-CASED//
++Example
++//{{{
++Global Const ACONSTANT = "This is a global constant"
++Function MyFunction(pocControl As Object, piValue) As Variant
++Dim iValue As Integer
++Const cstMyConstant = 3
++//}}}
++!Goto
++The //Goto// statement is forbidden.
++It is however highly recommended for __error__ and __exception__ handling.
++
++
++
++
A //Collection// contains a list of other objects.
++The individual members of the collection are accessible either via their index or via their name. The name is NOT case-sensitive.
++!!!Collections
++A //Collection// object is returned by next functions
++| !Function |!Description |
++|[[AllDialogs]] |{{{AllDialogs()}}} without argument returns the //Collection// of all [[dialogs|Dialog]] present in any of the accessible dialog libraries |
++|[[AllForms]] |{{{AllForms()}}} without argument returns the //Collection// of all [[forms|Form]] defined in the current Base or non-Base document |
++|[[AllModules]] |{{{AllModules()}}} without argument returns the //Collection// of all [[ùodules|Module]] present in any of the accessible Basic libraries |
++|[[CommandBars]] |{{{CommandBars()}}} without argument returns the //Collection// of all toolbars associated with the current ~LibO/AOO window. |
++|[[CommandBarControls]] |{{{myCommandBar.CommandBarControls()}}} returns the //Collection// of all the controls of the //commandbar// designated by //~myCommandBar// |
++|[[Controls]] |{{{myObject.Controls()}}} returns the //Collection// of all the controls of a //form//, a //dialog//, a [[subform|SubForm]] or a [[gridcontrol|GridControl]] designated by the object //myObject// |
++|[[Events]] |{{{Events(event)}}} returns the current [[event|Event]] object |
++|[[Fields]] |{{{myObject.Fields()}}} returns the //Collection// of all the [[fields|Field]] of a //table//, a //query// or a //recordset// designated by the object //myObject// |
++|[[Forms]] |{{{Forms()}}} without argument returns the //Collection// of all open //forms// |
++|[[Properties|Properties (collection)]] |{{{myObject.Properties()}}} returns the //Collection// of all [[properties|Property]] of the object //myObject// |
++|[[QueryDefs]] |{{{CurrentDb().QueryDefs()}}} without argument returns the //Collection// of all [[queries|QueryDef]] in the database |
++|[[Recordsets]] |{{{CurrentDb().Recordsets()}}} without argument returns the //Collection// of all currently open [[recordsets|Recordset]] |
++|[[TableDefs]] |{{{CurrentDb().TableDefs()}}} without argument returns the //Collection// of all [[tables|TableDef]] in the database |
++|[[TempVars]] |{{{Application.TempVars()}}} without argument returns the //Collection// of all [[temporary variables|TempVar]] in the current ~LibO/AOO session |
++!!!Properties
++| !Property |!Description |
++|[[Count]] |Number of items in the //Collection//. The first item of the //Collection// has the range //0//; the last one has the range //Count - 1// |
++|[[Item]] |Return the collection member identified by its //index// or its //name// |
++!!!Remarks
++Next pair of expressions are one by one equivalent:
++//{{{
++collection.Item(iIndex)
++collection.Item(sName)
++//}}}
++and
++//{{{
++collection(iIndex)
++collection(sName)
++//}}}
++!!!Methods
++| !Method | !Collection |!Description |
++|[[Add]] |[[TableDefs]]<br />[[TempVars]] |The Add method either<br />- finalizes the creation of a new table initiated with the [[CreateTableDef]] method,<br />- or creates a new //~TempVar// object. |
++|[[Delete|Delete (table-query)]] |[[TableDefs]]<br />[[QueryDefs]] |The Delete method erases a table or a query object from the //~TableDefs// or //~QueryDefs// collections. |
++|[[Remove]] | [[TempVars]] |The Remove method erases a tempvar object from the //~TempVars// collection. |
++|[[RemoveAll]] | [[TempVars]] |The ~RemoveAll method erases all tempvar objects from the //~TempVars// collection. |
++!!!Example
++<<tiddler "Collection example">>
++
++
++
To display the name of all forms
++//{{{
++Dim i As Integer, oCollection As Object
++	Set oCollection = AllForms			'AllForms without argument returns a Collection object
++	For i = 0 To oCollection.Count - 1
++		Print oCollection.Item(i).Name,		'AllForms collects Form objects
++	Next i
++	Print
++//}}}
++
++
++

++
++
++
Modify colors depending on value in field (typically in After Record Change form event)
++//{{{
++Dim ocControl As Object, vValue As Variant
++Dim lBlack As Long, lRed As Long, lYellow As Long, lWhite As Long
++	Set ocControl = getObject("Forms!myForm!myControl")
++	vValue = getValue(ocControl)
++	If Not IsNull(vValue) Then
++		lRed = RGB(255, 0, 0)
++		lBlack = RGB(0, 0, 0)
++		lYellow = RGB(255, 255, 0)
++		lWhite = RGB(255, 255, 255)
++		With ocControl
++			If vValue > 100 Then
++				.BorderColor = lRed
++				.ForeColor = lRed
++				.BackColor = lYellow
++				.BorderStyle = 2
++			Else
++				.BorderColor = lBlack
++				.ForeColor = lBlack
++				.BackColor = lWhite
++				.BorderStyle = 0
++			End If
++		End With
++	End If
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~ComboBox// describes a combo box control. It has specific properties to manage the input list of potential values and to select one of them programmatically.
++A ~ComboBox control is returned by the [[Controls]] collection or by the [[getObject]] shortcut.
++!!!Specific properties for combo box management
++| !Property | !Read only | !Description |
++|[[ItemData]] | Y |Returns the data for the specified row in a ~ComboBox or [[ListBox]]. |
++|[[ListCount]] | Y |Determines the number of rows in a [[ListBox]] or the list box portion of a ~ComboBox. |
++|[[ListIndex]] ||Determines which item is selected in a [[ListBox]] or a ~ComboBox. |
++|[[RowSource]] ||Specifies the source of the data in a [[ListBox]] or a ~ComboBox. |
++|[[RowSourceType]] ||Specifies the source (tablename, queryname or SQL statement) of the data in a [[ListBox]] or a ~ComboBox. |
++|[[Value]] ||Specifies the value currently selected in the ~ComboBox. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~ComboBox has the given property. |
++|[[Requery]] ||~|True if data reloaded in the ~ComboBox |
++|[[SetFocus]] | none |~|Return True if focus set on Control successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++!!!See also
++[[ListBox]]
++!!!Example
++<<tiddler "ComboBox example">>
++
++
++
Display the options of the combo
++//{{{
++Dim i As Integer, ocCombo As Object
++	Set ocCombo = getObject("Forms!myForm!myComboBox")
++	For i = 0 To ocCombo.ListCount - 1
++		Print i & " - " & ocCombo.ItemData(i),
++	Next i
++	Print
++//}}}
++Modify current selection position and find new value
++//{{{
++Dim ocCombo As Object
++	ocCombo.ListIndex = 2
++	Print ocCombo.Value
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~CommandBar// [[object|Object Model]] describes a toolbar, the menubar or the statusbar.
++!!!Functions returning a commandbar object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Application]] |[[CommandBars]] | [[Collection]] | Integer or String |{{{Application.CommandBars("myCommandbar")}}} returns an object corresponding with the {{{myCommandbar}}} custom toolbar. |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[BuiltIn]] || Y |True if the toolbar is a system toolbar. |
++|[[Name]] || Y |Specifies the real name of the toolbar |
++|[[ObjectType]] || Y |Returns "COMMANDBAR" |
++|[[Visible]] |||Shows or hides the coomandbar. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[Reset]] || Boolean |Reset the tool- or menubar to its initial values. Return {{{True}}} if success.. |
++!!!Remarks
++Each //~CommandBar// [[object|Object Model]] has a ~CommandBarControls [[collection|Collection]], that contains all controls on the commandbar. You can refer to a specific control on a commandbar by referring either to the [[Controls]] or the [[CommandBarControls]] collections. 
++!!!Example
++<<tiddler "CommandBar example">>
++
++
++
Reset all built-in toolbars to their initial status
++//{{{
++Dim i As Integer, oCommandBar As Object
++	SelectObject(acForm, "myForm")
++	For i = 0 To Application.CommandBars().Count - 1
++		Set oCommandBar = Application.CommandBars(i)
++		If oCommandBar.BuiltIn Then oCommandBar.Reset
++	Next i
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~CommandBarControl// object is a member of the [[CommandBarControls collection|CommandBarControls]] related to the [[CommandBar]] object.
++!!!Function returning a control object
++| !Parent object | !Function | !Type | !Arguments |!Short example |
++|[[CommandBar]] | [[CommandBarControls]] | [[Collection]] | None<br />Integer, Long |{{{CommandBars("myToolbar").CommandBarControls("myControl")}}}<br />Returns an object of type {{{CommandBarControl}}} referring to the {{{myControl}}} element in the {{{myToolbar}}} toolbar. |
++!!!Properties
++| !Property | !Read only |!Description |
++|[[BeginGroup]] | Y |Gets {{{True}}} if the specified command bar control appears at the beginning of a group of controls on the command bar. |
++|[[BuiltIn]] | Y |Gets {{{True}}} if the specified command bar control is a built-in control of the container [[CommandBar]]. |
++|[[Caption]] | Y |Gets the caption text for a command bar control. |
++|[[Index]] | Y |Gets an {{{Integer}}} representing the index number for a ~CommandBarControl object in the collection. |
++|[[ObjectType]] | Y |Returns "COMMANDBARCONTROL". |
++|[[OnAction]] ||Gets or sets the name of a command or a Basic procedure that will run when the user clicks the ~CommandBarControl. |
++|[[Parent]] | Y |Gets the Parent object for the ~CommandBarControl object. |
++|[[TooltipText]] ||Gets or sets the text displayed in a ~CommandBarControl's ~ScreenTip.|
++|[[Type]] | Y |Returns msoControlButton (=1). |
++|[[Visible]] ||Specifies the visible/hidden status of the ~CommandBarControl. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[Execute|Execute (commandbarcontrol)]] | None | Boolean |Runs the procedure or built-in command assigned to the specified ~CommandBarControl control. |
++|[[hasProperty]] | property |~|Return True if the Control has the given property. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++!!!Example
++<<tiddler "CommandBarControl example">>
++
++
++
List all the actions related to the targeted toolbar
++Force a new //~OnAction// command and its tooltip in the 4th button of the MYFORMTOOLBAR toolbar
++Execute that new action
++//{{{
++Dim i As Integer, j As Integer, oCommandBar As Object, oCommandBarControls As Object, oCommandBarControl As Object
++	DoCmd.SelectObject(acForm, "myForm")
++	For i = 0 To Application.CommandBars().Count - 1
++		Set oCommandBar = Application.CommandBars(i)
++		If oCommandBar.Name = "MYFORMTOOLBAR" And oCommandBar.Visible Then
++			Set oCommandBarControls = oCommandBar.CommandBarControls()
++			For j = 0 To oCommandBarControls.Count - 1
++				Set oCommandBarControl = oCommandBarControls.Item(j)
++				With oCommandBarControl
++					DebugPrint oCommandBar.Name, .Index, .OnAction
++					If .Index = 4 Then
++						.OnAction = "FullScreen"
++						.TooltipText = "Toggle full screen mode"
++						.Execute()
++					End If
++				End With
++			Next j
++		End If
++	Next i
++//}}}
++
++
++
The //~CommandBarControls// collection describes instances of [[CommandBarControl]] objects present in a [[CommandBar]].
++!!!Syntax
++//commandbar//{{{.CommandBarControls()}}}
++//commandbar//{{{.CommandBarControls(}}}//index//{{{)}}}
++//commandbar//{{{.Controls()}}}
++//commandbar//{{{.Controls(}}}//index//{{{)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[CommandBarControl]] object corresponding to the index-th item in the {{{CommandBarControls()}}} collection. The 1st control is {{{CommandBarControls(0)}}}, the 2nd is {{{CommandBarControls(1)}}} and so on ... The last one has as index {{{CommandBarControls.Count - 1}}}.|
++!!!Remarks
++*The //~CommandBarControls// collection can not be browsed by name.
++*An error message will be raised if the //~CommandBar// is the status bar (name = "statusbar") or if the //~CommandBar// is hidden.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size |
++|Action not applicable in this context |
++!!!See also ...
++[[CommandBar]]
++[[CommandBarControl]]
++[[SelectObject]]
++!!!Examples
++
++
++
The //~CommandBars// collection describes instances of all __toolbars__ or menu bars present in the currently selected document, whenever visible or hidden. The document might be any ~LibreOffice/~OpenOffice document, a Base form or report, etc. It is in fact the ~LibO/AOO window that is active at the moment the //~CommandBars()// method is invoked. The concerned commandbars might be system toolbars, the menu bar, the status bar or any user-defined toolbar.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]CommandBars()}}} or {{{CommandBars()}}}
++{{{[Application.]CommandBars(index)}}}
++{{{[Application.]CommandBar(toolbarname)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[CommandBar]] object corresponding to the index-th item in the ~CommandBars() collection. The 1st commandbar is ~CommandBars(0), the 2nd is ~CommandBars(1) and so on ... The last one is ~CommandBars.Count - 1.|
++| toolbarname | string |A [[CommandBar]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*The //toolbarname// argument is not case sensitive.
++*The current list of available toolbars and menu items is highly context-dependent. The context is very often determined by the prior execution of the [[SelectObject]] action on the targeted window or document.
++*The purpose of the //~CommandBars// collection is first of all to allow making individual toolbars visible or hidden programmatically. Its purpose is NOT to modify toolbars or defining new ones. Toolbars are __static by design__. Use the {{{Tools + Customize}}} menu commands to modify them. Additionally, some properties of [[CommandBarControls|CommandBarControl]] are updatable.
++*Most items returned by the //~CommandBars// collection are __toolbars__. Two items however are specific: their names are "menubar" and "statusbar". Their meaning is self-explanatory.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size |
++|~CommandBar "..." not found |
++!!!See also ...
++[[CommandBar]]
++[[CommandBarControl]]
++[[SelectObject]]
++!!!Examples
++<<tiddler "CommandBars example">>
++
++
++
++
List all builtin or custom toolbars, stored in ~LibO/AOO software or in document itself
++//{{{
++Dim i As Integer, oCommandBar As Object
++	SelectObject(acForm, "myForm")
++	For i = 0 To Application.CommandBars().Count - 1
++		Set oCommandBar = Application.CommandBars(i)
++		DebugPrint Right("0" & (i + 1), 2), oCommandBar.Name
++	Next i
++//}}}
++
++
++
The //Version// property the connection string between the //Base document// and the effective database system.
++That string appears in the status bar of the //database window// that appears when the //Base document// gets opened.
++!!!Aplies to ...
++| !Object | !Description |
++|[[Database]] |A database object returned by the [[CurrentDb]] or [[OpenDatabase]] methods. |
++!!!Syntax
++{{{database.Connect}}}
++!!!Returned values
++{{{String}}}
++!!!Remarks
++The //Connect// property is read-only.
++!!!Error messages
++!!!See also
++[[CurrentUser]]
++[[ProductCode]]
++[[Version]]
++!!!Example
++<<tiddler "Connect example">>
++
++
++
//{{{
++	MsgBox Application.CurrentDb.Connect
++//}}}
++
++
++
*To contribute to this piece of software ...
++*To search for help about its use ...
++*For any question you could have ...
++If your request is of public interest, post it on the [[OpenOffice Community forum|http://forum.openoffice.org/en/forum/viewtopic.php?f=47&t=61447]] preferably in the proposed thread, or otherwise in the //Base// or //Macros and API//  rubrics.
++As a third option, send a private message to the user "JPL" on the same forum. Messages in english, french or dutch are welcome.
++
++>Proposals for contributions to translations of ~Access2Base into other languages should be addressed via a private message.<br />(Translating into a new language takes +/- 2 hours ...)
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Control// [[object|Object Model]] describes one of the Controls of an open [[form|Form]], a [[subform|SubForm]], a [[dialog|Dialog]], a [[gridcontrol|GridControl]] or an [[options group|OptionGroup]]. Each control will be retrieved as a member of the [[Controls]] [[collection|Collection]] of its corresponding parent.
++NB: Subforms and gridcontrols are themselves controls and retrieved like other controls as a member of a collection.
++!!!Functions returning a control object
++| !Parent object | !Function | !Type | !Arguments |!Short example |
++|[[Form]]<br />[[SubForm]]<br />[[Control]]<br />[[OptionGroup]]<br />[[Dialog]] |[[Controls]] | [[Collection]] | None<br />Integer, Long<br />String |{{{Forms("myForm").Controls("myControl")}}}<br />Returns an object of type {{{Control}}} referring to the {{{myControl}}} control in the {{{myForm}}} form. {{{myForm}}} must be open. |
++||[[getObject]] || String |{{{getObject("Forms!myForm!myControl")}}} returns an object referring to the {{{myControl}}} control in the {{{myForm}}} form. {{{myForm}}} must be open. |
++!!!Control types
++The distinct control types can be recognized thru the use either of the [[SubType]] (string) or the [[ControlType]] (integer) properties. The ~ControlType property is proposed in //~Access2Base// for compatibility with ~MSAccess.
++See the correspondence table below.
++<<tiddler "ControlTypesList">>
++!!!Properties
++| !Property | !Type | !Read only |!Description or UNO object |
++|[[Name]] || Y |Specifies the exact name of the control |
++|BackColor (*) |||Specifies the color of the interior of a control. |
++|BorderColor (*) |||Specifies the color of a control's border. |
++|BorderStyle (*) |||Specifies how a control's border appears. |
++|[[Cancel]] (*) |||Specifies whether a command button is also the Cancel button on a form. |
++|[[Caption]] |||Specifies the label associated with a control.<br />If the control is located within a ~GridControl, the Caption specifies the column heading. |
++|[[ControlSource]] || Y |Specifies what data appears in a control. |
++|[[ControlTipText]] |||Specifies the text that appears in a ~ScreenTip when you hold the mouse pointer over a control. |
++|[[ControlType]] || Y |Specifies the type of a control. |
++|[[Default]] (*) |||specifies whether a ~CommandButton is the default button on a form. |
++|[[DefaultValue]] |||Specifies a value that is automatically entered in a field when a new record is created. |
++|[[Enabled]] |||Specifies if the cursor can access the control. |
++|[[FontBold]]<br />[[FontItalic]]<br />[[FontName]]<br />[[FontSize]]<br />[[FontUnderline]]<br />[[FontWeight]]<br />[[ForeColor]]<br />(*) |||Specify the font characteristics. |
++|[[Form|Form (subform)]] (*) || Y |Returns the [[SubForm]] object corresponding with the ~SubForm control. |
++|[[Format]] |||Returns the way numbers, dates, times, and text are displayed  |
++|[[ItemData]] || Y |Returns the data for the specified row in a [[ComboBox]] or a [[ListBox]]. |
++|[[ListCount]] || Y |Determines the number of rows in a [[ListBox]] or the list box portion of a [[ComboBox]]. |
++|[[ListIndex]] |||Determines which item is selected in a [[ListBox]] or a [[ComboBox]]. |
++|[[Locked]] |||Specifies whether you can edit data in a control. |
++|[[MultiSelect]] (*) |||Specifies whether a user can make multiple selections in a [[ListBox]] on a form. |
++|[[ObjectType]] || Y |Returns "CONTROL" |
++|[[On ... events|On (control event)]] |||Specifies which function is triggered when a control event occurs. |
++|[[OptionValue]] (*) || Y |Specifies the value that is stored in the database when a [[RadioButton]] is selected and the record saved. |
++|[[Page]] |||Defines the page on which the control is visible. |
++|[[Parent]] || Y |Returns the parent object of the control. |
++|[[Picture]] |||Specifies the image to be displayed in an ~ImageControl or ~ImageButton control. |
++|[[Required]] |||Specifies whether a control must contain a value when the record is edited. |
++|[[RowSource]] |||Specifies the source of the data in a [[ListBox]] or a [[ComboBox]]. |
++|[[RowSourceType]] |||Specifies the source (tablename, queryname or SQL statement) of the data in a [[ListBox]] or a [[ComboBox]]. |
++|[[Selected]] |||Specifies if an item in the data proposed by a [[ListBox]] is currently selected. |
++|[[SubType]] || Y |Specifies the type of a control. |
++|[[TabIndex]] (*) |||Specifies a control's place in the tab order on a form. |
++|[[TabStop]] (*) |||Specifies whether you can use the TAB key to move the focus to a control. |
++|[[Tag]] |||Stores extra information about a control. |
++|[[Text]] || Y |Sets or returns the text contained in a text box (or similar). |
++|[[TextAlign]] |||Specifies the alignment of the text in a control. |
++|[[TripleState]] |||Specifies how a //~CheckBox// wll display Null values. |
++|[[Value]] |||Specifies the value contained in a control. |
++|[[Visible]] (*) |||Specifies if a control is visible or hidden. |
++|~ControlModel | UNO | Y |com.sun.star.comp.forms.~XXXModel |
++|~ControlView | UNO | Y |com.sun.star.comp.forms.~XXXControl |
++|~BoundField | UNO | Y |com.sun.star.sdb.~ODataColumn |
++|~LabelControl | UNO | Y |com.sun.star.form.component.~FixedText<br />com.sun.star.form.component.~GroupBox |
++(*) Not applicable to controls belonging to a [[GridControl]].
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Control has the given property. |
++|[[SetFocus]] | none |~|Return True if focus set on Control successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++!!!Example
++<<tiddler "Control example">>
++
++
++
List all the controls of a form having the Visible property
++//{{{
++Dim ofForm As Object, ocControl As Object, i As Integer, iCount As Integer
++	Set ofForm = Forms("myForm")
++	iCount = ofForm.Controls.Count
++	For i = 0 To iCount - 1
++		Set ocControl = ofForm.Controls(i)
++		If ocControl.hasProperty("Visible") Then Print ocControl.Name & ":" & ocControl.SubType
++	Next i
++	Print
++//}}}
++
++
++
The //~ControlSource// property specifies the database field bound to the [[Control]].
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | ~CheckBox<br />~ComboBox<br />~CurrencyField<br />~DateField<br />~FormattedField<br />~ImageControl<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />[[RadioButton]]<br />~TextField<br />~TimeField | All |A control on an open form or within a [[GridControl]] of one of the allowed types |
++!!!Syntax
++//control//{{{.ControlSource}}}
++!!!Returned value
++{{{String}}}
++!!!Remarks
++The //~ControlSource// property is read-only.
++It returns a zero-length string ({{{""}}}) if the control is not bound to any database field.
++!!!Error messages
++|Property '~ControlSource' not applicable in this context |
++!!!See also
++[[RecordSource]]
++!!!Example
++<<tiddler "ControlSource example">>
++
++
++
Display the bound database field
++//{{{
++Dim ocControl As Object
++	Set ocControl = getObject("Forms!myForm!myGridControl!myTextField")
++	MsgBox ocControl.ControlSource
++//}}}
++
++
++
The //~ControlTipText// property specifies the text that appears in a ~ScreenTip when you hold the mouse pointer over a control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />[[SubForm]]-- | All | All |A control on an open form, a dialog or within a [[GridControl]] of one of the listed types |
++!!!Syntax
++//control//{{{.ControlTipText}}}
++//control//{{{.ControlTipText}}} = //value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++!!!Error messages
++|Property '~ControlTipText' not applicable in this context |
++|Value '...' is invalid for property '~ControlTipText' |
++!!!See also
++!!!Example
++<<tiddler "ControlTipText example">>
++
++
++
Change the tip text of a control
++//{{{
++Dim ocControl As Object
++	Set ocControl = getObject("Forms!myForm!myControl")
++	ocControl.ControlTipText = "This is a new tip !"
++//}}}
++
++
++
The types of control can be recognized thru the use either of the [[SubType]] or the //~ControlType// properties. The ~ControlType property is there for compatibility with ~MSAccess but has the disadvantage to not discriminate control types 100%, e.g. a ~TextField cannot be distinguished from a ~FormattedField control type.
++See the correspondence table below.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | All | All | All |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.ControlType}}}
++!!!Returned values
++{{{Integer}}}
++Table of values:
++<<tiddler "ControlTypesList">>
++Instead of using the numeric values for ~ControlType, one may copy next code and paste it in his/her own code. This allows to use symbolic names, more or less compatible with those existing in ~MSAccess. "More or less" because many control types do not match: e.g. a "spin button" is unknown in ~MSAccess.
++//{{{
++REM Control Types
++REM -----------------------------------------------------------------
++Const acCheckBox = 5
++Const acComboBox = 7
++Const acCommandButton = 2	:	Const acToggleButton = 122
++Const acCurrencyField = 18
++Const acDateField = 15
++Const acFileControl = 12
++Const acFixedLine = 24
++Const acFixedText = 10		:	Const acLabel = 10
++Const acFormattedField = 1
++Const acGridControl = 11
++Const acGroupBox = 8		:	Const acOptionGroup = 8
++Const acHiddenControl = 13
++Const acImageButton = 4
++Const acImageControl = 14	:	Const acImage = 14
++Const acListBox = 6
++Const acNavigationBar = 22
++Const acNumericField = 17
++Const acPatternField = 19
++Const acProgressBar = 23
++Const acRadioButton = 3		:	Const acOptionButton = 3
++Const acScrollBar = 20
++Const acSpinButton = 21
++Const acSubform = 112 
++Const acTextField = 9		:	Const acTextBox = 9
++Const acTimeField = 16
++//}}}
++!!!Remarks
++The ~ControlType property is read-only.
++!!!Error messages
++!!!See also
++[[SubType]]
++!!!Example
++<<tiddler "ControlType example">>
++
++
++
List name, controltype and subtype of all controls on an open form
++//{{{
++Dim ofForm As Object, ocControl As Object, i As Integer, iCount As Integer
++	Set ofForm = Forms("myForm")
++	iCount = ofForm.Controls.Count
++	For i = 0 To iCount - 1
++		Set ocControl = ofForm.Controls(i)
++		Print ocControl.Name & "/" & ocControl.SubType & "/" & ocControl.ControlType
++	Next i
++	Print
++//}}}
++
++
++
|!~SubType | !~ControlType |!Control type available in ... |>|>|>|
++|~|~| [[Forms|Form]] / [[SubForms|SubForm]] | [[GridControls|GridControl]] | [[Dialogs|Dialog]] | [[Option Groups|OptionGroup]] |
++|CHECKBOX | 5 | X | X | X |  |
++|[[COMBOBOX|ComboBox]] | 7 | X | X | X |  |
++|COMMANDBUTTON | 2 | X |  | X |  |
++|CURRENCYFIELD | 18 | X | X | X |  |
++|DATEFIELD | 15 | X | X | X |  |
++|FILECONTROL | 12 | X |  | X |  |
++|FIXEDLINE | 24 |  |  | X |  |
++|FIXEDTEXT | 10 | X |  | X |  |
++|FORMATTEDFIELD | 1 | X | X | X |  |
++|[[GRIDCONTROL|GridControl]] | 11 | X |  |  |  |
++|GROUPBOX | 8 | X |  | X |  |
++|HIDDENCONTROL | 13 | X |  |  |  |
++|IMAGEBUTTON | 4 | X |  |  |  |
++|IMAGECONTROL | 14 | X |  | X |  |
++|[[LISTBOX|ListBox]] | 6 | X | X | X |  |
++|NAVIGATIONBAR | 22 | X |  |  |  |
++|NUMERICFIELD | 17 | X | X | X |  |
++|PATTERNFIELD | 19 | X | X | X |  |
++|PROGRESSBAR | 23 |  |  | X |  |
++|[[RADIOBUTTON|RadioButton]] | 3 | X |  | X | X |
++|SCROLLBAR | 20 | X |  | X |  |
++|SPINBUTTON | 21 | X |  |  |  |
++|[[SUBFORMCONTROL|SubForm]] | 112 | X |  |  |  |
++|TEXTFIELD | 9 | X | X | X |  |
++|TIMEFIELD | 16 | X | X | X |  |
++
++
++
The //Controls// collection describes instances of all __[[controls|Control]]__ present either
++*in an open [[form|Form]]
++*in a [[subform|SubForm]] of an open form of or another subform
++*in a started [[dialog|Dialog]]
++*in a [[GridControl]] part of an open form or one of its subforms
++*or in an [[OptionGroup]] (i.e. a set of [[radio buttons|RadioButton]])
++The //Controls// collection may also refer (as a synonym) to the collection of [[CommandBarControl]] objects of a [[CommandBar]]. To know more about this option, read the page about the [[CommandBarControls]] collection.
++!!!Syntax
++//form//{{{.Controls}}}
++//form//{{{.Controls(}}}//index//{{{)}}}
++//form//{{{.Controls(}}}//controlname//{{{)}}}
++//subform//{{{.Controls}}}
++//subform//{{{.Controls(}}}//index//{{{)}}}
++//subform//{{{.Controls(}}}//controlname//{{{)}}}
++//dialog//{{{.Controls}}}
++//dialog//{{{.Controls(}}}//index//{{{)}}}
++//dialog//{{{.Controls(}}}//controlname//{{{)}}}
++//gridcontrol//{{{.Controls}}}
++//gridcontrol//{{{.Controls(}}}//index//{{{)}}}
++//gridcontrol//{{{.Controls(}}}//controlname//{{{)}}}
++//optiongroup//{{{.Controls}}}
++//optiongroup//{{{.Controls(}}}//index//{{{)}}}
++| !Object | !Type | !Argument | !Type |!Returned value |
++|form | [[Form object|Form]] || absent |A [[Collection]] of the controls of the form |
++|~|~| index | integer<br />long |A [[control object|Control]] |
++|~|~| controlname | string |~|
++|subform | [[Subform object|SubForm]] || absent |A [[Collection]] of the controls of the subform |
++|~|~| index | integer<br />long |A [[control object|Control]] |
++|~|~| controlname | string |~|
++|dialog | [[Dialog object|Dialog]] || absent |A [[Collection]] of the controls of the dialog |
++|~|~| index | integer<br />long |A [[control object|Control]] |
++|~|~| controlname | string |~|
++|gridcontrol | [[Gridcontrol object|GridControl]] || absent |A [[Collection]] of the controls of the gridcontrol |
++|~|~| index | integer<br />long |A [[control object|Control]] |
++|~|~| controlname | string |~|
++|optiongroup | [[Optiongroup object|OptionGroup]] || absent |A [[Collection]] of the controls of the optiongroup |
++|~|~| index | integer<br />long |A [[control object|Control]] of [[SubType]] = [[RadioButton]]. |
++!!!Remarks
++*Control [[collections|Collection]] are numbered from 0 to {{{Controls(...).Count - 1}}}
++*The //controlname// argument is not case sensitive.
++*A form must be opened, either manually by the user or [[programmatically|OpenForm]] to give access to its controls.
++*A dialog must be [[started|Start]] to give access to its controls.
++*The //index// of an [[OptionGroup]] is determined by its position (~X-Y coordinates) on the screen: 1) top to bottom 2) left to right.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection Controls() |
++|Form '...' is currently not open|
++|Dialog '...' not active|
++|Control '...' not found in parent (form, grid or dialog) '...' |
++!!!Examples
++<<tiddler "Controls examples">>
++
++
++
++
To identify the last control of an open form
++//{{{
++Dim ofForm As Object, iCount As Integer
++     Set ofForm = Forms("myForm")
++     iCount = ofForm.Controls.Count
++     MsgBox "The form " & ofForm.Name & " has " & iCount & " controls." _
++          & "The last one is " & ofForm.Controls(iCount - 1).Name
++//}}}
++To know the controls present in a gridcontrol (datagrid)
++//{{{
++Dim ocGrid As Object, i As Integer, iCountGrid As Integer
++     Set ocGrid = Forms("myForm").Controls("myGridControl")
++     iCountGrid = ocGrid.Controls.Count
++     For i = 0 To iCountGrid - 1
++     	Print ocGrid.Controls(i).Name
++     Next i
++     Print
++//}}}
++To know the number of controls in a dialog
++//{{{
++Dim oDialog As Object, iCount As Integer
++	Set oDialog = Dialogs("myDialog")
++	oDialog.Start
++	iCount = oDialog.Controls.Count
++	oDialog.Terminate
++	MsgBox "Number of controls in " & oDialog.Name & " = " & iCount
++//}}}
++
++
++
The //~CopyObject// action copies an existing query or table within the current database or from an external database to the current database.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]CopyObject(}}}//{{{SourceDatabase, NewName, SourceObjectType, SourceObjectName}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description | !Returned Value |
++|{{{SourceDatabase}}} | Yes | String<br />[[Database]] |The null-string "" (default value) designates the current database. | True if sucess |
++|{{{NewName}}} | No | String |The name of the target copy. |~|
++|{{{SourceObjectType}}} | No | acTable<br />acQuery |The type of object to copy. |~|
++|{{{SourceObjectName}}} | No | String |The name of the object to copy. This argument is NOT case-sensitive. |~|
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acQuery = 1
++Const acTable = 0
++//}}}
++!!!Remarks
++*In ~MSAccess the first argument is the //target// database, not the //source// database.<br />The inversion in ~Access2Base is an intentional design choice. Indeed the //~CopyObject// action __imports__ an object in ~Access2Base, while it __exports__ it in ~MSAccess.
++*If an object (table or query) of the same type and with the same name exists already, it is __dropped without warning__.
++*To designate the source database, use either a string containing the full path (URL or ~OS-specific) of the database or a database object returned by the [[OpenDatabase]] method. Use the latter when the external database requires a user/password security check.<br />If a database object is given, the programmer must care for the [[closure of the database|Close (method)]].
++*A new copy of an //acQuery// object contains only its description and its SQL statement.<br />If the databases are not based on the same relational database system, it is very likely that the respective SQL dialects are not compatible. This is not checked by the //~CopyObject// action.
++*A new copy of an //acTable// object contains
++**the table columns with their types
++**the table data
++**the same primary key as the source table. If the source primary key is an //~AutoIncrement// field, the value of the field is copied into an //long// field of the same name without the //~AutoIncrement// behaviour.
++*Other table elements are NOT copied: e.g. indexes. To build them use the [[RunSQL]] action with the appropriate {{{CREATE INDEX ...}}} statement.
++*The copy of the table structure is done
++**When both databases are based on an identical database management system simply by copying field types and precisions.
++**Otherwise by searching among the available datatypes within the target database the datatypes fitting best the input datatypes and precisions. This can lead to
++***either the non-existence of a compatible datatype (error message),
++***or a loss of data when the target field is too short (warning message).
++*The copy of the table data is done
++**When the source database is the current database, via one single  {{{INSERT}}} SQL statement.
++**Otherwise by copying the data row by row and field by field. This is obviously __much slower__ than using an {{{INSERT}}} statement. A progress meter will be displayed when the active window is a form or the Basic IDE.
++*The //~CopyObject// action is forbidden from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Arguments are missing or are not initialized |
++|Argument nr. ... [Value = '...'] is invalid |
++|Object '...' not found |
++|Method '~CopyObject' not applicable in this context |
++|Field '...' could not be converted due to incompatibility of field types between database systems |
++|Field '...' could not be loaded in record #N due to capacity shortage |
++!!!See also
++[[OpenDatabase]]
++[[RunSQL]]
++[[SelectObject]]
++!!!Example
++<<tiddler "CopyObject example">>
++
++
++
Copy a table (design and data)
++//{{{
++	DoCmd.CopyObject(, "COMPANIES_BACKUP", acTable, "COMPANIES")
++//}}}
++
++
++
++
The //Count// property identifies the number of items present in a [[collection|Collection]] or in an [[OptionGroup]] control.
++!!!Applies to ...
++| !Collection |!Description |
++|[[AllDialogs]] |All dialogs present in any of the accessible dialog libraries |
++|[[AllForms]] |All forms, open or closed, in the current database document (".odb" file) |
++|[[Controls]] |All the controls of a //form//, a //dialog//, a //subform// or a //gridcontrol// |
++|[[Fields]] |All the fields of a //table//, a //query// or a //recordset// designated by the object //myObject// |
++|[[Forms]] |All open forms |
++|[[Properties|Properties (collection)]] |All properties of an [[object|Object Model]] |
++|[[QueryDefs]] |All queries in the database |
++|[[Recordsets]] |All recordsets currently open |
++|[[TableDefs]] |All tables in the database |
++| !Control |!Description |
++|[[OptionGroup]] |Groups either<br />- the [[Radio buttons|RadioButton]] with the same name within a (sub)form,<br />- the //Radio buttons// having contiguous ~TabIndexes (= "Order" in the control's property sheet) in a dialog. |
++!!!Syntax
++//collection//{{{.Count}}}
++//optiongroup//{{{.Count}}}
++!!!Returned values
++{{{Integer}}} >= 0
++!!!Remarks
++*The //Count// property is read-only.
++*The items of a [[collection|Collection]] or of an [[OptionGroup]] control are always numbered from 0 to {{{Count - 1}}}
++!!!Error messages
++!!!See also
++[[Item]]
++!!!Example
++<<tiddler "Count example">>
++
++
++
The following example uses the Count property to control a loop that prints information about all open forms and their controls.
++//{{{
++Dim ofForm As Object, i As Integer
++Dim j As Integer
++Dim iControls As Integer, iForms As Integer
++	iForms = Forms.Count        ' Number of open forms.
++	If iForms > 0 Then
++		For i = 0 To iForms - 1
++			Set ofForm = Forms(i)
++			_Print ofForm.Name
++			iControls = ofForm.Controls().Count
++			If iControls > 0 Then
++				For j = 0 To iControls - 1
++					Print ofForm.Controls(j).Name
++				Next j
++			End If
++		Next i
++	End If
++	Print
++//}}}
++
++
++
The //~CountOfDeclarationLines// property indicates the number of lines of code in the Declarations section in a standard or class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.CountOfDeclarationLines}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++Lines in a module are numbered beginning with 1.
++The value of the //~CountOfDeclarationLines// property is equal to the line number of the last line of the Declarations section. You can use this property to determine where the Declarations section ends and the first procedure of the module begins.
++!!!Error messages
++|Property '~CountOfDeclarationLines' not applicable in this context |
++!!!See also
++[[CountOfLines]]
++[[Lines]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
The //~CountOfLines// property indicates the number of lines of code in a class or standard [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.CountOfLines}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++Lines in a module are numbered beginning with 1.
++The line number of the last line in a module is the value of the //~CountOfLines// property.
++!!!Error messages
++|Property '~CountOfLines' not applicable in this context |
++!!!See also
++[[CountOfDeclarationLines]]
++[[Lines]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
(Q) How can I know the number of records in a //Recordset// object ? For example, I may want to create a form that shows how many records are in each of the tables in a database. Or I may want to change the appearance of a form or report based on the number of records it includes.
++
++(R) The [[RecordCount]] property contains the number of records in a [[Recordset]]. A //Recordset object// with no records has a //~RecordCount// property value of 0.
++
++However:
++>The value of the //~RecordCount// property equals the number of records that have actually been accessed. To visit all the records, use the [[MoveLast|Move (recordset)]] method immediately after opening the //Recordset//, then use [[MoveFirst|Move (recordset)]] to return to the first record. This is not done automatically because it may be slow, especially for large result sets.
++
++The following code example creates a //Recordset// object, and then determines the number of records in the //Recordset//.
++//{{{
++Function FindRecordCount(sSQL As String) As Long
++
++Dim odbNorthwind As Object
++Dim orsRecords As Object
++On Local Error GoTo ErrorHandler 
++
++	Set odbNorthwind = Application.CurrentDb
++	Set orsRecords = odbNorthwind.OpenRecordset(sSQL)
++	With orsRecords
++		If .EOF Then
++			FindRecordCount = 0
++		Else
++			.MoveLast
++			FindRecordCount = .RecordCount
++		End If
++		.mClose
++	End With
++
++	Set orsRecords = Nothing
++	Set odbNorthwind = Nothing
++	Exit Function 
++ 
++ErrorHandler:
++	TraceError("ERROR", Err, "FindRecordCount", Erl)
++End Function
++//}}}
++As your application deletes records in a //Recordset//, the value of the //~RecordCount// property decreases. However, in a multiuser environment, records deleted by other users are not reflected in the value of the //~RecordCount// property. Using the //~MoveFirst// method on a //Recordset//, followed by the //~MoveLast// method, resets the //~RecordCount// property to the current total number of records in the //Recordset//.
++!!!See also
++[[BOF, EOF]]
++[[MoveFirst, MoveLast, MoveNext, MovePrevious|Move (recordset)]]
++[[OpenRecordset]]
++[[TraceError]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~FindRecordCount ||
++
++
++
Appends a new [[Field object|Field]] to a [[table|TableDef]].
++This method offers the capacity to create from the Basic code a new table field independently from the underlying RDBMS. Thus without using SQL. However only a limited set of options are available for field descriptions.
++!!!Applies to ...
++| !Object | !Description |
++|[[TableDef]] |The representation of a table in the currently connected database. |
++!!!Syntax
++Set //field// = //tabledef//.{{{CreateField(}}}//name, type, size, attributes//{{{)}}}
++!!!Arguments - Returned value
++| !Argument | !Type | !Optional | !Description | !Returned value |
++|name | String ||The name of the new field | A [[field|Field]] object |
++|type | dbInteger<br />dbLong<br />dbBigInt<br />dbFloat<br />vbSingle<br />dbDouble<br />dbNumeric<br />dbDecimal<br />dbText<br />dbChar<br />dbMemo<br />dbDate<br />dbTime<br />dbTimeStamp<br />dbBinary<br />dbVarBinary<br />dbLongBinary<br />dbBoolean | Y |The [[database type ("DbType")|DataType]] of the new field |~|
++|size | numeric | Y |The length of the field. It is ignored when not relevant.<br />If //size// has a non-integer value, the first decimal digit at the right of the decimal point determines the number of decimal digits. |~|
++|attributes | dbAutoIncrField | Y |Indicates if present that the field is a primary key and is incremented by the RDBMS at each new record insertion. |~|
++!!!List of available field types
++<<tiddler "FieldTypesList">>
++!!!Remarks
++*The //dbAutoIncrField// attribute MUST NOT be set when the //~CreateField// method is applied on an existing table. It is valid only between the [[CreateTableDef]] and [[Add]] methods.
++*When the //dbAutoIncrField// attribute is present (for a new table only ...) the field is created and becomes the primary key of the table. The __auto-increment__ attribute of the newly created primary key will be applied only if the RDBMS and the currently used driver allow it. As an example, for the embedded HSQLDB database, the attribute will be applied, for a [["splitted" HSQLDB database|http://www.oooforum.org/forum/viewtopic.phtml?p=396523#396523]], it might not be applied.
++*When the //dbAutoIncrField// attribute is not present the newly created field is "nullable", i.e. when not initialized it gets the {{{Null}}} value as default.
++*If additional attributes are needed to specify the new field more accurately, use an SQL statement given as argument to the [[RunSQL action|RunSQL]].
++*The //~CreateField// method must not be invoked from a [[standalone form|Standalone Forms]] defined in a non-Base (Writer, Calc, ...) document.
++*Instead of using the numeric values for ~DbType, one may copy next code and paste it in his/her own code. This allows to use symbolic names, close to or identical with the field types existing in ~MSAccess.
++//{{{
++REM Types
++REM -----------------------------------------------------------------
++Const dbBigInt = 16
++Const dbBinary = 9
++Const dbBoolean = 1
++Const dbByte = 2
++Const dbChar = 18
++Const dbCurrency = 5
++Const dbDate = 8
++Const dbDecimal = 20
++Const dbDouble = 7
++Const dbFloat = 21
++Const dbGUID = 15
++Const dbInteger = 3
++Const dbLong = 4
++Const dbLongBinary = 11	'	(OLE Object)
++Const dbMemo= 12
++Const dbNumeric = 19
++Const dbSingle = 6
++Const dbText = 10
++Const dbTime = 22
++Const dbTimeStamp = 23
++Const dbVarBinary = 17
++Const dbUndefined = -1
++REM Attributes
++REM -----------------------------------------------------------------
++Const dbAutoIncrField = 16
++//}}}
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Field '...' could not be created |
++|Method '~TableDef.~CreateField' not applicable in this context |
++!!!See also
++[[Add]]
++[[CreateQueryDef]]
++[[CreateTableDef]]
++[[TableDefs]]
++[[TableDef]]
++[[QueryDefs]]
++[[QueryDef]]
++!!!Example
++<<tiddler "CreateTableDef example">>
++
++
++
Creates a new [[QueryDef object|QueryDef]] in the current [[database|Database]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Database]] |The representation of the currently connected database. |
++!!!Syntax
++Set //querydef// = //database//.{{{CreateQueryDef}}} (//name, sqltext, [option]//)
++!!!Arguments - Returned value
++| !Argument | !Type | !Optional | !Description | !Returned value |
++|name | String | N |The name of the new query | A [[querydef|QueryDef]] object |
++|sqltext | String | N |The SQL statement to be executed when the query if fired. |~|
++|option | Integer<br />Long | Y |If the argument is present its only allowed value = //dbSQLPassThrough//.<br />Forces escape substitution before sending the SQL statement to the database. |~|
++!!!Remarks
++*The //~CreateQueryDef// method must not be applied to a //Database// object created with the [[OpenDatabase]] method.
++*The resulting //~QueryDef// object is automatically appended to the [[QueryDefs collection|QueryDefs]].
++*If the object specified by //name// is already a member of the //~QueryDefs// collection (the comparison is NOT case-sensitive !!), the existing query is erased without warning.
++*The //~CreateQueryDef// method must not be invoked from a [[standalone form|Standalone Forms]] defined in a non-Base (Writer, Calc, ...) document.
++*To include the constant in your own code, copy and paste next line:
++//{{{
++Const dbSQLPassThrough = 64
++//}}}
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Method 'Database.~CreateQueryDef' not applicable in this context |
++!!!See also
++[[CreateTableDef]]
++[[TableDefs]]
++[[TableDef]]
++[[QueryDefs]]
++[[QueryDef]]
++!!!Example
++<<tiddler "CreateQueryDef example">>
++
++
++
Create new Query in the database. If it exists already it will be overwritten.
++//{{{
++Dim oQueryDef As Object
++Const dbSQLPassThrough = 64
++	Set oQueryDef = Application.CurrentDb().CreateQueryDef("NewQuery" _
++			, "SELECT * FROM [Products] ORDER BY [ManufacturingCost] DESC" _
++			, dbSQLPassThrough _
++					)
++//}}}
++
++
++
(Q) Are there different means to access data stored in a database ?
++
++(R) The simplest mean to get data from a database is to create a [[recordset object|Recordset]] from an existing [[table|TableDef]] name, an existing [[query|QueryDef]] name or derived from an existing [[form|Form]].
++Such a resulting recordset object must always be [[closed|Close (method)]] after usage.
++!!!From a table
++Use the [[OpenRecordset]] method with the table name as argument. The name is NOT case-sensitive.
++//{{{
++Sub CreateRecordsetFromTable
++Dim odbNorthwind As Object
++Dim orsShippers As Object		'	Will contain the future Recordset object
++
++	Set odbNorthwind = Application.CurrentDb
++	Set orsShippers = odbNorthwind.OpenRecordset("Shippers")
++
++		'	... do whatever is needed
++	
++	orsShippers.mClose()
++End Sub
++//}}}
++!!!From a query
++Use the [[OpenRecordset]] method with the query name as argument. The name is NOT case-sensitive.
++//{{{
++Sub CreateRecordsetFromQuery
++Dim odbNorthwind As Object
++Dim orsCustomers As Object		'	Will contain the future Recordset object
++
++	Set odbNorthwind = Application.CurrentDb
++	Set orsCustomers = odbNorthwind.OpenRecordset("Customers union All")
++
++		'	... do whatever is needed
++	
++	orsCustomers.mClose()
++End Sub
++//}}}
++!!!From a form
++Use the [[Recordset property|Recordset (property)]] applied to a form object to get its recordset. The same property is applicable, if needed, to a [[subform object|SubForm]].
++//{{{
++Sub CreateRecordsetFromForm
++Dim odbNorthwind As Object
++Dim ofOrders As Object
++Dim orsOrders As Object			'	Will contain the future Recordset object
++
++	Set odbNorthwind = Application.CurrentDb
++	Set ofOrders = Application.OpenForm("Orders_Tabbed")
++	Set orsOrders = ofOrders.Recordset
++
++		'	... do whatever is needed
++	
++	orsOrders.mClose()
++End Sub
++//}}}
++!!!See also
++[[Close|Close (method)]]
++[[OpenRecordset]]
++[[Recordset|Recordset (property)]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~CreateRecordsetFromTable ||
++|~|~CreateRecordsetFromQuery ||
++|~|~CreateRecordsetFromForm ||
++
++
++
Creates a new [[TableDef object|TableDef]] in the current [[database|Database]].
++This method offers the capacity to create from the Basic code a new table independently from the underlying RDBMS. Thus without using SQL. However only a limited set of options are available for field descriptions.
++!!!Applies to ...
++| !Object | !Description |
++|[[Database]] |The representation of the database currently connected to a Base (".odb") document. |
++!!!Syntax
++Set //tabledef// = //database//.{{{CreateTableDef(}}}//name//{{{)}}}
++!!!Arguments - Returned value
++| !Argument | !Type | !Optional | !Description | !Returned value |
++|name | String | N |The name of the new table | A [[tabledef|TableDef]] object |
++!!!Remarks
++*The //~CreateTableDef// method may be applied ONLY from a macro executed from a Base ("*.odb") document, said otherwise, __not from a [[standalone form|Standalone Forms]]__. The //database// object should be returned by the [[Application.CurrentDb|CurrentDb]] method.
++*To become fully viable the new //~TableDef// object has to be [[added|Add]] explicitly to the [[TableDefs collection|TableDefs]].
++*Between the execution of the //~CreateTableDef// and the //Add// methods one or more fields should have been created thru the [[CreateField]] method.
++*If the object specified by //name// is already a member of the //~TableDefs// collection (the comparison is NOT case-sensitive !!), the __existing table is erased without warning__.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Method 'Database.~CreateTableDef' not applicable in this context |
++!!!See also
++[[Add]]
++[[CreateField]]
++[[CreateQueryDef]]
++[[TableDefs]]
++[[TableDef]]
++[[QueryDefs]]
++[[QueryDef]]
++!!!Example
++<<tiddler "CreateTableDef example">>
++
++
++
Build a new table in the database without using SQL
++//{{{
++Dim oDatabase As Object, oTable As Object
++	Set oDatabase = Application.CurrentDb()
++	Set oTable = oDatabase.CreateTableDef("myNewTable")			'	Create "empty" table
++	With oTable
++		.CreateField("myAutoIncrFld", dbLong, , dbAutoIncrField)	'	Create 2 fields
++		.CreateField("myDecimalFld", dbDecimal, 10.4)
++	End With
++	oDatabase.TableDefs().Add(oTable)					'	Finalize table creation
++//}}}
++Add a field to an existing table
++//{{{
++	Set oTable = oDatabase.TableDefs("myExistingTable")
++	oTable.CreateField("myBinaryFld", dbBinary)
++//}}}
++
++
++
(Q) How can I write a query similar to the crosstab queries I find in ~MSAccess (also elsewhere) ? To produce something like:
++| No. Sales per year | 1996 | 1997 | 1998 | Total |
++|Margaret Peacock | 31 | 81 | 44 | 156 |
++|Janet Leverling | 18 | 71 | 38 | 127 |
++|Nancy Davolio | 26 | 55 | 42 | 123 |
++|Laura Callahan | 19 | 54 | 31 | 104 |
++|Andrew Fuller | 16 | 41 | 39 | 96 |
++|etc ... |||||
++
++(R) A crosstab query aggregates data in the form of a matrix. Example: products sales by period. The issue is that the periods to be considered are in the database and can vary over time. Additionally periods can be years, quarters, months, ...
++Doing this is feasible by //generating// with a Basic function the appropriate SQL statement.
++
++The solution presented here will work for the SUM() and COUNT() aggregate functions.
++
++Let's consider next tables:
++<<tiddler "ProductsTable">>
++<<tiddler "CustomersTable">>
++<<tiddler "OrdersTable">>
++<<tiddler "OrderDetailsTable>>
++
++A crosstab query needs at least next inputs:
++*One or more __row headings__: several database fields which will appear in front of each row and on which the aggregation function will be applied => [Rowheadings]] or their aliases
++*One __column heading__: the field varying horizontally (periods, ...) => (~ColHeading] or its alias
++*The (numeric) __value__ which will be aggregated => [Aggregate]
++*The __FROM expression__ listing the concerned tables and the associated WHERE clause => [~FromExpression]
++*and, optionally, one or more sort keys.
++
++The target is to produce an SQL statement which will look like:
++//{{{
++	SELECT 
++		[RowheadingAlias(0)],
++		[RowheadingAlias(1)],
++		...
++		SUM( CASE [ColHeadingAlias] WHEN 'ColValue0' THEN [Data] ELSE 0 END ) As [ColValue0],
++		SUM( CASE [ColHeadingAlias] WHEN 'ColValue1' THEN [Data] ELSE 0 END ) As [ColValue1],
++		SUM( CASE [ColHeadingAlias] WHEN 'ColValue2' THEN [Data] ELSE 0 END ) As [ColValue2],
++		...
++		SUM( [Data] ) As [All]
++	FROM 
++		(SELECT RowHeading(0),
++			RowHeading(1), 
++			...
++			ColHeading,
++			Aggregate As [Data]
++		FROM FromExpression
++		GROUP BY RowHeadingAlias(0),RowHeadingAlias(1), ColHeadingAlias
++		)
++	GROUP BY RowHeadingAlias(0),RowHeadingAlias(1)
++	ORDER BY [All] | OrderBy
++//}}}
++The resulting SQL statement could be afterwards:
++*displayed with the [[OpenSQL]] action
++*browed as a [[Recordset]]
++*stored as a new Query with [[CreateQueryDef]]
++!!!Examples:
++//{{{
++Dim sSql As String
++	sSql = MakeCrossTab( _
++    	"[FirstName] || ' ' || [LastName] As [Name]" _
++		, "YEAR([OrderDate]) || 'Q' || QUARTER([OrderDate]) As [Quarter]" _
++		, "Count(*)" _
++		, "[Employees] INNER JOIN [Orders] ON ([Employees].[EmployeeID]=[Orders].[EmployeeID])" _
++		, "DESC" _
++		)
++	OpenSQL(sSql, dbSQLPassThrough)
++//}}}
++will produce:
++| Name |	 1996Q3 |	 1996Q4 |	 1997Q1 |	 1997Q2 |	 1997Q3 |	 1997Q4 |	 1998Q1 |	 1998Q2 |	 All |
++|Margaret Peacock |	 15 |	 16 |	 18 |	 18 |	 22 |	 23 |	 32 |	 12 |	 156 |
++|Janet Leverling |	 7 |	 11 |	 19 |	 16 |	 10 |	 26 |	 28 |	 10 |	 127 |
++|Nancy Davolio |	 11 |	 15 |	 10 |	 10 |	 18 |	 17 |	 29 |	 13 |	 123 |
++|Laura Callahan |	 11 |	 8 |	 19 |	 9 |	 14 |	 12 |	 19 |	 12 |	 104 |
++|Andrew Fuller |	 8 |	 8 |	 9 |	 10 |	 11 |	 11 |	 19 |	 20 |	 96 |
++|Robert King |	 3 |	 8 |	 6 |	 12 |	 13 |	 5 |	 14 |	 11 |	 72 |
++|Michael Suyama |	 9 |	 6 |	 6 |	 8 |	 5 |	 14 |	 14 |	 5 |	 67 |
++|Anne Dodsworth |	 2 |	 3 |	 2 |	 6 |	 4 |	 7 |	 15 |	 4 |	 43 |
++|Steven Buchanan |	 4 |	 7 |	 3 |	 4 |	 6 |	 5 |	 12 |	 1 |	 42 |
++Similarly:
++//{{{
++Dim sSql As String
++Const dbSQLPassThrough = 64
++	sSql = MakeCrossTab( _
++	   	"[Customers].[CompanyName] As [Customer], [Products].[ProductName] AS [Name]" _
++		, "YEAR([OrderDate]) || 'Q' || QUARTER([OrderDate]) As [Quarter]" _
++		, "SUM([Order Details].[UnitPrice]*[Quantity]*(1-[Discount]))" _
++		, "[Order Details], [Products], [Orders], [Customers] " _
++			& "WHERE [Order Details].[ProductID] = [Products].[ProductID] " _
++			& "AND [Order Details].[OrderID] = [Orders].[OrderID] " _
++			& "AND [Customers].[CustomerID] = [Orders].[CustomerID] " _
++			& "AND YEAR([Orders].[OrderDate]) = 1997" _
++		, "[Customer]" _
++		)
++	OpenSQL(sSql, dbSQLPassThrough)
++//}}}
++will produce next result:
++| Customer |	 Name |	 1997Q1 |	 1997Q2 |	 1997Q3 |	 1997Q4 |	 All |
++|Alfreds Futterkiste |	 Lakkalikööri |	 0 |	 0 |	 0 |	 270 |	 270 |
++|Alfreds Futterkiste |	 Aniseed Syrup |	 0 |	 0 |	 0 |	 60 |	 60 |
++|Alfreds Futterkiste |	 Vegie-spread |	 0 |	 0 |	 0 |	 878 |	 878 |
++|Alfreds Futterkiste |	 Spegesild |	 0 |	 0 |	 18 |	 0 |	 18 |
++|Alfreds Futterkiste |	 Chartreuse verte |	 0 |	 0 |	 283,5 |	 0 |	 283,5 |
++|Alfreds Futterkiste |	 Rössle Sauerkraut |	 0 |	 0 |	 513 |	 0 |	 513 |
++|Ana Trujillo Emparedados y helados |	 Mascarpone Fabioli |	 0 |	 0 |	 0 |	 320 |	 320 |
++|Ana Trujillo Emparedados y helados |	 Camembert Pierrot |	 0 |	 0 |	 340 |	 0 |	 340 |
++|Ana Trujillo Emparedados y helados |	 Singaporean Hokkien Fried Mee |	 0 |	 0 |	 70 |	 0 |	 70 |
++|etc ... |||||||
++Note that in the context of HSQLDB as database management system:
++*the readability of the arguments is strongly improved by using the square brackets [] as delimitors of table- and fieldnames instead of double quotes;
++*either the double quotes or the square brackets are MANDATORY;
++*the table- and fieldnames are case-sensitive.
++!!!Code
++Next function will do the job:
++//{{{
++Public Function MakeCrossTab( _
++		Byval psRowHeading As String _
++		, Byval psColHeading As String _
++		, Byval psAggregate As String _
++		, Byval psFromExpression As String _
++		, Byval psSortBy As String _
++		) As String
++
++Dim sQuery As String, sSubQuery As String, vRowHeading() As Variant, sGroupBy As String, sSortBy As String
++Dim sDataQuery As String, oData As Object, oField As Object, sCase As String, sValue As String
++Dim i As Integer
++	vRowHeading() = Split(psRowHeading, ",")
++	If UBound(vRowHeading) < 0 Then Exit Function
++
++	'	SUBQUERY
++	sSubQuery = "SELECT " & vRowHeading(0)
++	For i = 1 To UBound(vRowHeading)
++		sSubQuery = sSubQuery & "," & vRowheading(i)
++	Next i
++	sSubQuery = sSubQuery & ", " & psColHeading & ", " & psAggregate & " AS [Data] FROM " & psFromExpression & " GROUP BY "
++	sGroupBy = AliasOf(vRowHeading(0))
++	For i = 1 To UBound(vRowHeading)
++		sGroupBy = sGroupBy & ", " & AliasOf(vRowHeading(i))
++	Next i
++	sSubQuery = sSubQuery & sGroupBy & "," & AliasOf(psColHeading)
++
++	'	MAIN QUERY
++	'	Identify all distinct column headings
++	sDataQuery = "SELECT DISTINCT " & psColHeading & " FROM " & psFromExpression & " ORDER BY " & AliasOf(psColHeading)
++	Set oData = CurrentDb().OpenRecordset(sDataQuery,, dbSQLPassThrough, dbReadOnly)
++	Set oField = oData.Fields(0)
++	'	Build CASE sentences
++	sCase = ""
++	For i = 0 To UBound(vRowHeading)
++		scase = sCase & AliasOf(vRowHeading(i)) & ", "
++	Next i
++	With oData	'	Recordset
++		Do While Not .EOF
++			sValue = CStr(oField.Value)		'	Force string
++			sCase = sCase & "SUM( CASE " & AliasOf(psColHeading) & " WHEN '" & sValue & "' THEN [Data] ELSE 0 END ) As [" & sValue & "],"
++			.MoveNext
++		Loop
++		.mClose()
++	End With
++	sCase = sCase & "SUM( [Data] ) As [All]"
++	'	Final query
++	Select Case UCase(psSortBy)
++		Case "", "ASC"		:		sSortBy = "ORDER BY [All] ASC"
++		Case "DESC"		:		sSortBy = "ORDER BY [All] DESC"
++		Case Else		:		sSortBy = "ORDER BY " & psSortBy
++	End Select
++	sQuery = "SELECT " & sCase & " FROM (" & sSubQuery & ") GROUP BY " & sGroupBy & sSortBy
++	
++	'	Store SQL
++	MakeCrossTab = sQuery
++
++End Function
++//}}}
++It calls next small function:
++//{{{
++Function AliasOf(ByVal psString As String) As String
++Dim iPos As Integer
++	iPos = InStr(psString, " AS ")
++	If iPos > 0 Then AliasOf = Right(psString, Len(psString) - iPos - 3) Else AliasOf = psString
++End Function
++//}}}
++!!!See also
++[[CreateQueryDef]]
++[[Execute|Execute (query)]]
++[[OpenSQL]]
++[[Recordset]]
++!!!Refer to ...
++| !Basic module |
++|~CrossTab |
++
++
++
The //~CurrentDb// method returns either
++*the [[database|Database]] object related to a Base (".odb") document,
++*the database object related to a [[standalone form|Standalone Forms]] contained in a non-Base (Writer Calc, ...) document.
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Form]] |The database object related to a standalone form. |
++!!!Syntax
++{{{[Application.]CurrentDb()}}}
++{{{form.CurrentDb()}}}
++!!!Returned values / Arguments
++{{{Database}}} object or {{{Nothing}}}
++!!!Remarks
++*The ~CurrentDb method returns {{{Nothing}}} (to be tested with the {{{IsNull()}}} Basic builtin function) if the database connection is undefined or is currently unavailable. In case of wanted (by using the [[CloseConnection]] method) or unwanted disconnection the [[OpenConnection]] //Sub// may be (re)executed to (re)create a valid connection.
++*When applied to a non-Base document containing at least one //standalone// form, the statements
++//{{{
++Application.CurrentDb()
++//}}}
++and
++//{{{
++Forms(0).CurrentDb()
++//}}}
++are equivalent.
++!!!Error messages
++None
++!!!See also
++[[CloseConnection]]
++[[Database]]
++[[Form]]
++[[OpenConnection]]
++!!!Example
++<<tiddler "CurrentDb example">>
++
++
++
Reconnect database after unwanted disconnection
++//{{{
++	If IsNull(Application.CurrentDb) Then Call Application.OpenConnection(ThisDatabaseDocument)
++//}}}
++
++
++
You can use the //CurrentRecord// property to specify the current record in the recordset being viewed on a form.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.CurrentRecord}}}
++//form//{{{.CurrentRecord = }}}//value//
++//subform//{{{.CurrentRecord}}}
++//subform//{{{.CurrentRecord = }}}//value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++The value specified by this property corresponds to the value shown in the record number box found in the lower-left corner of the form.
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~CurrentRecord' |
++!!!See also
++[[Recordset|Recordset (property)]]
++!!!Example
++<<tiddler "CurrentRecord example">>
++
++
++
Go to the 100th record
++//{{{
++Dim oForm As Object
++	Set oForm = Forms("myForm")
++	oForm.CurrentRecord = 100
++//}}}
++
++
++
The //~CurrentUser// property returns the logon name of the current user.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]CurrentUser}}}
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++!!!Error messages
++!!!See also
++[[ProductCode]]
++[[Version]]
++!!!Example
++<<tiddler "Identification example">>
++
++
++
*Customers table
++| !Fields | !Field Type | !Primary |
++|Address | Text ||
++|City | Text ||
++|~CompanyName | Text ||
++|~ContactName | Text ||
++|Country | Text ||
++|~CustomerID | Text | Y |
++|Fax | Text ||
++|Phone | Text ||
++|~PostalCode | Text ||
++|Region | Text ||
++
++
++
You can use the ~DAvg function to determine the average of a set of values in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DAvg(expression, domain[, criteria])}}}
++{{{database.DAvg(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DAvg function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DCount]]
++[[DLookup]]
++[[DMin, DMax]]
++[[DStDev, DStDevP]]
++[[DSum]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
You can use the ~DCount function to determine the number of records that are in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DCount(expression, domain[, criteria])}}}
++{{{database.DCount(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DCount function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DLookup]]
++[[DMin, DMax]]
++[[DStDev, DStDevP]]
++[[DSum]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
You can use the ~DLookup function to get the value of a particular field from a specified set of records (a domain).
++
++You can use the ~DLookup function to display the value of a field that isn't in the record source for your form. For example, suppose you have a form based on an Order Details table. The form displays the ~OrderID, ~ProductID, ~UnitPrice, Quantity, and Discount fields. However, the ~ProductName field is in another table, the Products table. You could use the ~DLookup function in an event to display the ~ProductName on the same form.
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DLookup(expression, domain[, criteria][, orderclause]))}}}
++{{{database.DLookup(expression, domain[, criteria][, orderclause]))}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++|orderclause | String | Y |A string expression specifying the sequence of the returned records. It is a SQL ORDER BY clause without the words ORDER BY. It can include the ASC or DESC keywords. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*The ~DLookup function returns a single field value based on the information specified in //criteria//. If more than one record meet //domain// and //criteria//, the DLookup function returns a __random__ value in the domain. If a //orderclause// is present the ~DLookup function will return the __first__ value that meets the criteria.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DLookup function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DCount]]
++[[DMin, DMax]]
++[[DStDev, DStDevP]]
++[[DSum]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
Note that the same logic applies to most Domain Aggregate Functions ([[DMin, DMax]] etc.)
++
++!!!Normal usage
++*For numerical values:
++//{{{
++		DLookup("FieldName" , "TableName" , "Criteria=" & num)
++//}}}
++*For strings: (note the single quote before and after the value)
++//{{{
++		DLookup("FieldName" , "TableName" , "Criteria='" & string & "'")
++//}}}
++*For dates: ISO notation => ''~YYYY-MM-DD''
++//{{{
++		DLookup("FieldName" , "TableName" , "Criteria='" & Format(date, "YYYY-MM-DD") & "'")
++//}}}
++!!!Refering to a form control
++*For numerical values
++//{{{
++		DLookup("FieldName", "TableName", "Criteria=" & getValue("Forms!FormName!ControlName")
++//}}}
++*For strings: (note the single quote before and after the value)
++//{{{
++		DLookup("FieldName", "TableName", "Criteria='" & getValue("Forms!FormName!ControlName") & "'")
++//}}}
++*For dates:
++//{{{
++		DLookup("FieldName", "TableName", "Criteria='" & Format(getValue("Forms!FormName!ControlName")) & "'")
++//}}}
++!!!~Mix-n-Match
++//{{{
++		DLookup("FieldName", "TableName", "Criteria1=" & Forms!FormName!Control1  _
++			& " AND Criteria2='" & getValue(Forms!FormName!Control2) & "'" _
++			& " AND Criteria3='" & Format(getValue(Forms!FormName!Control3), "YYYY-MM-DD") & "'")
++//}}}
++
++
++
(Q) How can I write a function that computes the //median// value of a range of data ?
++
++(R) The median is the numerical value separating the higher half of a data sample from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one. If there is an even number of observations, then there is no single middle value; the median is then usually defined to be the mean of the two middle values. (Wikipedia)
++Easily feasible with a [[Recordset]] object.
++
++The function:
++//{{{
++Public Function DMedian( _
++					psField As String _
++					, psTable As String _
++					, Optional psWhere As String _
++					) As Variant
++
++Dim sSql As String, oRecordset As Object, vValue1 As variant, oField As Object
++Const cstQuote = """"
++
++	DMedian = Null
++
++	sSql = "SELECT " _
++			& cstQuote & psField & cstQuote _
++			& " FROM " & cstQuote & psTable & cstQuote _
++			& Iif(IsMissing(psWhere), "", " WHERE " & psWhere) _
++			& " ORDER BY " & cstQuote & psField & cstQuote
++	Set oRecordset = CurrentDb().OpenRecordset(sSql)
++	
++	With oRecordset
++		.MoveLast()			'	Necessary to know the exact number of records
++		If Not .EOF() Then		'	At least 1 record ?
++			Select Case .RecordCount Mod 2
++				Case 0		'	Even
++					.AbsolutePosition = .RecordCount / 2
++					Set oField = .Fields(psField)
++					vValue1 = oField.Value
++					.MoveNext
++					DMedian = (oField.Value + vValue1) / 2
++				Case 1		'	Odd
++					.AbsolutePosition = Int(.RecordCount / 2) + 1		'	Works also if only 1 record
++					DMedian = .Fields(psField).Value
++			End Select
++		End If
++		.mClose()
++	End With
++	
++End Function
++//}}}
++!!!Example
++With next table:
++<<tiddler "ProductsTable">>
++//{{{
++	MsgBox DMedian("UnitPrice", "Products")
++//}}}
++computes the median value of the //~UnitPrice// range of values
++!!!See also
++[[Move (recordset)]]
++[[AbsolutePosition]]
++!!!Refer to ...
++| !Basic module |
++|Records |
++
++
++
You can use the ~DMin and ~DMax functions to determine the minimum and maximum values of a set of values in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DMin(expression, domain[, criteria])}}}
++{{{[Application.]DMax(expression, domain[, criteria])}}}
++{{{database.DMin(expression, domain[, criteria])}}}
++{{{database.DMax(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DMin (~DMax) function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DCount]]
++[[DLookup]]
++[[DStDev, DStDevP]]
++[[DSum]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
(Q) How can I write a function that computes the value corresponding with a given //percentile// of a range of data ?
++
++(R) A percentile is a measure used in statistics indicating the value below which a given percentage of observations in a group of observations fall. For example, the 20th percentile is the value (or score) below which 20 percent of the observations may be found. For example, if a score is in the 86th percentile, it is higher than 86% of the other scores. (Wikipedia)
++Easily feasible with a [[Recordset]] object.
++
++The function:
++//{{{
++Public Function DPercentile( _
++					pdPercentile As Double _
++					, psField As String _
++					, psTable As String _
++					, Optional psWhere As String _
++					) As Variant
++
++Dim sSql As String, oRecordset As Object, vValue1 As variant, oField As Object
++Const cstQuote = """"
++
++	DPercentile = Null
++	If pdPercentile < 0 Or pdPercentile > 1 Then Exit Function
++
++	sSql = "SELECT " _
++			& cstQuote & psField & cstQuote _
++			& " FROM " & cstQuote & psTable & cstQuote _
++			& Iif(IsMissing(psWhere), "", " WHERE " & psWhere) _
++			& " ORDER BY " & cstQuote & psField & cstQuote
++	Set oRecordset = Application.CurrentDb().OpenRecordset(sSql)
++	
++	With oRecordset
++		.MoveLast()			'	Necessary to know the exact number of records
++		If pdPercentile < 1 Then	'	Else take current (highest) value
++			If Not .EOF() Then	'	At least 1 record ?
++				.AbsolutePosition = Int(CDbl(.RecordCount * pdPercentile + 0.5) + 0.5)
++			Else
++				Exit Function
++			End If
++		End If
++		DPercentile = .Fields(psField).Value
++		.mClose()
++	End With
++	
++End Function
++//}}}
++!!!Example
++With next table:
++<<tiddler "ProductsTable">>
++//{{{
++	MsgBox DPercentile(0.25, "UnitPrice", "Products")
++//}}}
++computes the 25th percentile of the //~UnitPrice// range of values
++!!!See also
++[[Move (recordset)]]
++[[AbsolutePosition]]
++!!!Refer to ...
++| !Basic module |
++|Records |
++
++
++
You can use the ~DStDev and ~DStDevP functions to determine the standard deviation of a set of values in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DStDev(expression, domain[, criteria])}}}
++{{{[Application.]DStDevP(expression, domain[, criteria])}}}
++{{{database.DStDev(expression, domain[, criteria])}}}
++{{{database.DStDevP(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DStDev (~DStDevP) function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DCount]]
++[[DLookup]]
++[[DMin, DMax]]
++[[DSum]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
You can use the ~DSum function to determine the sum of a set of numeric values in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DSum(expression, domain[, criteria])}}}
++{{{database.DSum(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DSum function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DCount]]
++[[DLookup]]
++[[DMin, DMax]]
++[[DStDev, DStDevP]]
++[[DVar, DVarP]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
You can use the ~DVar and ~DVarP functions to determine the variance of a set of values in a specified set of records (a domain).
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[Application.]DVar(expression, domain[, criteria])}}}
++{{{[Application.]DVarP(expression, domain[, criteria])}}}
++{{{database.DVar(expression, domain[, criteria])}}}
++{{{database.DVarP(expression, domain[, criteria])}}}
++!!!Arguments
++| !Argument | !Type | !Optional |!Description |
++|database | Object | Y |A database object opened with the //~OpenDatabase// or returned by the //~CurrentDb// methods. |
++|expression | String ||An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be a SQL expression that performs a calculation on data in that field. However the SQL expression must not include any SQL aggregate function. |
++|domain | String ||A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter. |
++|criteria | String | Y |An optional string expression used to restrict the range of data on which the ~DAvg function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the ~DAvg function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain. |
++!!!Returned value
++{{{Variant}}}
++!!!Remarks
++*In all the //expression//, //domain//, //criteria// and //orderclause// arguments, database table- and fieldnames should be surrounded with square brackets []. Additionally, if in the current RDBMS (Relational ~DataBase Management System) table- and fieldnames used in SQL statements are case-sensitive - like in ~MySQL -, the same rule applies when used in database functions.
++*If no record satisfies //criteria// or if //domain// contains no records, the ~DVar (~DVarP) function returns a ''Null''.
++*Construct the //criteria// argument carefully to ensure that it will be evaluated correctly as a valid WHERE clause.
++!!!Error messages
++|~DFunction execution failed SQL='...' |
++!!!See also
++[[DAvg]]
++[[DCount]]
++[[DLookup]]
++[[DMin, DMax]]
++[[DStDev, DStDevP]]
++[[DSum]]
++!!!Example
++<<tiddler "Dfunctions example">>
++
++
++
The type of a field pertaining to a [[table|TableDef]], a [[query|QueryDef]] or a [[recordset|Recordset]] can be recognized thru the use of any of next properties:
++*//~DataType//
++*//~DbType//
++*//~TypeName//
++The ~DbType property is there for compatibility with ~MSAccess.
++See the correspondence table below.
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a table, a query or a recordset. |
++!!!Syntax
++//field//{{{.DataType}}}
++//field//{{{.DbType}}}
++//field//{{{.TypeName}}}
++!!!Returned values
++| !Property | !Returned value |
++|~DataType | Long |
++|~DbType | Integer |
++|~TypeName | String |
++!!!Correspondence table
++<<tiddler "FieldTypesList">>
++Instead of using the numeric values for ~DbType, one may copy next code and paste it in his/her own code. This allows to use symbolic names, close to or identical with the field types existing in ~MSAccess.
++//{{{
++REM Types
++REM -----------------------------------------------------------------
++Const dbBigInt = 16
++Const dbBinary = 9
++Const dbBoolean = 1
++Const dbByte = 2
++Const dbChar = 18
++Const dbCurrency = 5
++Const dbDate = 8
++Const dbDecimal = 20
++Const dbDouble = 7
++Const dbFloat = 21
++Const dbGUID = 15
++Const dbInteger = 3
++Const dbLong = 4
++Const dbLongBinary = 11
++Const dbMemo= 12
++Const dbNumeric = 19
++Const dbSingle = 6
++Const dbText = 10
++Const dbTime = 22
++Const dbTimeStamp = 23
++Const dbVarBinary = 17
++Const dbUndefined = -1
++//}}}
++!!!Remarks
++*The //~DataType//, //~DbType// and //~TypeName// properties are read-only.
++*As you can see there is no bijection between the list of //~DataTypes// and the list of //~TyeNames//. Indeed different Relational Database Systems may return different names for their internal set of database fieldtypes. This can create ambiguity. It is always preferable to use the //~DataType// property wherever possible.
++!!!Error messages
++!!!See also
++!!!Example
++<<tiddler "DataType example">>
++
++
++
List all fields of a table with their types
++//{{{
++Dim i As Integer, oTable As Object, oField As Object
++	Set oTable = Application.CurrentDb().TableDefs("AllTypes")
++	For i = 0 To oTable.Fields().Count - 1
++		Set oField = oTable.Fields(i)
++		DebugPrint oField.Name, oField.DataType, oField.DbType, oField.TypeName
++	Next i
++//}}}
++
++
++
Returns a value that indicates whether the data in the field represented by a [[Field object|Field]] in a [[recordset|Recordset]] is updatable.
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a recordset. |
++!!!Syntax
++//field//{{{.DataUpdatable}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++*An error message is produced when the //~DataUpdatable// property is invoked on a field belonging to the [[Fields collection|Fields]] of a [[TableDef]] or a [[QueryDef]].
++*Use this property to determine whether you can change the [[Value|Value (field)]] property setting of a [[Field object|Field]]. This property is always {{{False}}} on a //auto-increment// field.
++!!!Error messages
++!!!See also
++[[SourceTable]]
++[[Value|Value (field)]]
++!!!Example
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Database// [[object|Object Model]] describes the database the application is currently connected to.
++!!!Functions/Methods returning a database object
++| !Parent object | !Function | !Type |!Description |
++|[[Application]]<br />[[Form]] |[[CurrentDb]] | Method |The //~CurrentDb// method returns either<br />- the database object related to a Base (".odb") document,<br />- or the database object related to a [[standalone form|Standalone Forms]] contained in a non-Base (Writer Calc, ...) document. |
++|[[Application]] |[[OpenDatabase]] | Method |{{{Application.OpenDatabase( ... )}}} returns an object from which SQL statements can be run or recordsets can be browsed. |
++!!!Collections
++| !Collection | !Description |
++|[[QueryDefs]] |The collection of [[QueryDef]] objects. |
++|[[TableDefs]] |The collection of [[TableDef]] objects. |
++|[[Recordsets]] |The collection of __open__ [[Recordset]] objects. |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[Connect]] || Y |The connection string as displayed on the statusbar |
++|[[Name]] || Y |The name of the database |
++|[[ObjectType]] || Y |Returns "DATABASE" |
++|[[Version]] || Y |Something like 'HSQL Database Engine 1.8.0' |
++|Document | UNO | Y |com.sun.star.comp.dba.~ODatabaseDocument |
++|Connection | UNO | Y |com.sun.star.sdbc.drivers.~OConnectionWrapper |
++|~MetaData | UNO | Y |interface ~XDatabaseMetaData |
++!!!Methods
++| !Method | !Description |
++|[[Close|Close (method)]] |Close the database object. |
++|[[CloseAllRecordsets]] |Housekeeping of eventual open recordsets |
++|[[CreateQueryDef]] |Create a new query entry in the database |
++|[[CreateTableDef]] |Create a new table entry in the database |
++|[[DAvg]] |Invoke one of the "database functions" |
++|[[DCount]] |~|
++|[[DLookup]] |~|
++|[[DMin, DMax]] |~|
++|[[DStDev, DStDevP]] |~|
++|[[DSum]] |~|
++|[[DVar, DVarP]] |~|
++|[[getProperty]] |Return the value of the given property. |
++|[[hasProperty]] |Return {{{True}}} if the Database object has the given property. |
++|[[OutputTo]] |Output the content of a table or a query to an HTML page. |
++|[[OpenRecordset]] |Define and open a [[recordset|Recordset]] based on a SQL statement |
++|[[OpenSQL]] |Open a datasheet containing the data described by the provided SELECT SQL statement |
++|[[RunSQL]] |Execute the SQL statement given as argument |
++!!!See also
++[[CurrentDb]]
++
++
++
++

++
++
++
(Q) Can I hide the database window ?
++
++(R) No, the database window cannot be hidden. It can however be minimized.
++
++What is called here the //database window// is the screen welcoming the user when (s)he opens a database front-end file (suffixed with ".odb") where the tables, queries, forms and reports are listed.
++It can be desirable to hide that window and, instead, opening a form for example.
++!!!Minimize the database window
++Very easy code but it's as easy for the user to restore it with a mouse click. Nevertheless ... first select the //database window// then minimize it.
++//{{{
++Const acDatabaseWindow = 102
++	SelectObject(acDatabaseWindow)
++	Minimize()
++//}}}
++A variant:
++//{{{
++Const acDatabaseWindow = 102
++	SelectObject(acDatabaseWindow)
++	MoveSize ,,10,10
++//}}}
++!!!See also
++[[SelectObject]]
++[[Minimize]]
++[[Maximize]]
++[[MoveSize]]
++
++
++
List all tables and all queries
++//{{{
++Dim i As Integer, odbDatabase As Object
++	Set odbDatabase = Application.CurrentDb()
++	With odbDatabase
++		Print "TABLES",
++		For i = 0 To .TableDefs().Count - 1
++			Print .TableDefs(i).Name,
++		Next i
++		Print "QUERIES",
++		For i = 0 To .QueryDefs().Count - 1
++			Print .QueryDefs(i).Name,
++		Next i
++	End With
++//}}}
++
++
++
++
(Q) How could I get data stored in a database from within a Calc cell formula ?
++
++(R) Calc offers as a standard feature to insert data from database tables and queries via a specific browser that is invoked by using the {{{View}}} + {{{Data Sources}}} menu command or the {{{F4}}} function key.
++The Help files describe in detail how to proceed.
++However the question here is, as an example : how is it possible to enter a ''product code'' in a cell and get in another calculated cell its ''description'', knowing that the __correspondence between both fields is somewhere in a database table__ and not in the spreadsheet ?
++
++Obviously, to not simplify the problem, we would appreciate to have things happen automatically, i.e. also when the sheet is configured to have its
++>{{{Tools + Cell Contents}}}
++set to ''{{{AutoCalculate}}}'', and __without useless database accesses__.
++
++In the proposed solution we will go even further. The example shown will illustrate next 4 functionalities:
++*Use database data to populate a dropdown listbox.
++*Derive automatically the //description// from the selected item in the listbox.
++*Prepare a report with the heading derived from the database table field names.
++*Populate an array of data in the sheet extracted from the database and filtered by the choice in the dropdown box..
++[img[Access data dynamically from a Calc spreadsheet|dbaccess_from_calc.png]]
++!!A solution
++Let's consider next tables:
++<<tiddler "CategoriesTable">>
++<<tiddler "ProductsTable">>
++The final purpose of the spreadsheet is to list all products belonging to the category selected by the user.
++!!!Preamble
++The challenge will be to do next things apparently simultaneously without the user becoming aware of the underlying complexity:
++*to load the ~Access2Base macro library, only once
++*to open the database file (".odb") referring to the effective database, also only once
++*to extract the needed data only when relevant and every time it is, i.e. when some input parameter has been modified.
++When Calc recomputes a worksheet, it sequences its computations in function of the respective arguments present in each cell formula.
++For example, if 
++**cell A1 is a number
++**C1 contains the formula {{{"=A1*2"}}}
++**and B1 contains the formula {{{"=C1*C1"}}}
++the worksheet will not be recomputed from left to right, but in the sequence A1, C1, B1. In addition, C1 and B1 will be both recomputed automatically every time A1 receives another value.
++Choosing in this matter either cells or "names" (defined by {{{Insert}}} + {{{Names}}}) does not make any difference. Names will be preferred if they do not need to be visible in the sheet.
++The sequencing of computations done by Calc is the mean we will use to reach our challenge.
++!!!Global
++To access the database we have to make use of a database object. Let's define it as a {{{Global}}} variable.
++Such variables remain in life as long as
++*the AOO/~LibO session is lasting
++*the module where it is declared is not edited.
++Usually I declare {{{Global}}} variable in a separate module as such a module is unlikely to be modified often.
++//{{{
++Global oMyDatabase		As Variant
++//}}}
++!!!Define Name
++Define a {{{Name}}} called {{{IsConnected}}}. Store in it the formula
++//{{{
++=DBCONNECTED()
++//}}}
++DBCONNECTED is a user-defined function and behaves exactly like any builtin Calc function or expression. It has no argument.
++The code of the function is here:
++//{{{
++Sub _Init()
++Dim oLib As Object
++	Set oLib = GlobalScope.BasicLibraries
++	If oLib.hasByName("Access2BaseDev") Then
++		oLib.loadLibrary("Access2BaseDev")
++	ElseIf Not oLib.IsLibraryLoaded("Access2Base") Then
++		oLib.loadLibrary("Access2Base")
++	End If
++	If oLib.hasByName("XrayTool") Then oLib.loadLibrary("XrayTool")
++	Set oMyDatabase = Nothing
++End Sub	
++
++Function DBConnected() As Variant
++Dim sCalc As String, sDatabase As String
++	DBConnected = 0
++	If IsEmpty(oMyDatabase) Or IsNull(oMyDatabase) Then
++		Call _Init()		'	Load Basic libraries
++		With ThisComponent
++			sCalc = Join(Split(.Title, " "), "%20")						'	Replace " " by "%20" in current filename
++			sDatabase = Join(Split(.URL, sCalc), "TT%20NorthWind.odb")	'	Build URL of database located in same directory as current file
++		End With
++		Set oMyDatabase = OpenDatabase(sDatabase)
++	End If
++	DBConnected = 1
++End Function
++//}}}
++The result is that the loading of the library is put on the computation path. There is no reason why Calc would require recomputation several times of {{{IsConnected}}} except while loading the spreadsheet.
++Now we can build other formulas, like:
++//{{{
++=IF(IsConnected;USERDEFINED(...);False)
++//}}}
++being sure that __such formulas will be evaluated by Calc only when the evaluation of {{{IsConnected}}} has been achieved__.
++!!!Setup the dropdown box
++Use the {{{Data}}} + {{{Validity}}} menu commands to define //Criteria// as being a //Cell range//, select the //Show selection list// checkbox and enter as //Source// next formula
++//{{{
++=IF(IsConnected;CATEGORIESLIST();"")
++//}}}
++The CATEGORIESLIST() function:
++//{{{
++Function CategoriesList() As Variant
++'	Return the list of available product categories as an array
++Dim oRs As Object, sCatsRC() As Variant, sCats() As Variant, i As Integer
++	If Not IsNull(oMyDatabase) Then
++		Set oRs = oMyDatabase.OpenRecordset("SELECT [CategoryName] FROM [Categories] ORDER BY [CategoryName]")
++		sCatsRC = oRs.GetRows(1000)		'	matrix (column, row)
++		sCats() = Array()			'	Reduce to column only
++		ReDim sCats(0 To UBound(sCatsRC, 2))
++		For i = 0 To UBound(sCats)
++			sCats(i) = sCatsRC(0, i)
++		Next i
++		CategoriesList = sCats()
++		oRs.mClose()
++	End If
++End Function
++//}}}
++!!!Find description
++The dropdown box is in cell {{{B2}}}. We put in cell {{{D2}}} next formula:
++//{{{
++=IF(IsConnected;CATLOOKUP(B2);"")
++//}}}
++that will be recomputed by Calc each time the cell {{{B2}}} is modified by the user.
++The CATLOOKUP function:
++//{{{
++Function CatLookup(ByVal pvArg As Variant) As Variant
++	If Not IsNull(oMyDatabase) Then CatLookup = oMyDatabase.DLookup("[Description]", "[Categories]", "[CategoryName]='" & pvArg & "'")
++End Function
++//}}}
++!!!Fill the data
++The data matrix will be inserted as an ''array formula'' ({{{Ctrl}}} + {{{Shift}}} + {{{Enter}}}) in cells {{{D6:H35}}}. Look at the AOO/~LibO help to know more about them.
++//{{{
++{=IF(IsConnected,PRODUCTSLOAD($B$2),"")}
++//}}}
++The PRODUCTSLOAD function:
++//{{{
++Function ProductsLoad(ByVal pvCat As Variant) As Variant
++Dim oRS As Object, sSQL As String, vResult() As Variant, vTranspose() As Variant
++Dim i As Integer, j As Integer
++Const cstSize = 30
++	If Not IsNull(oMyDatabase) Then
++		sSQL = "SELECT [ProductName] AS [Product], [QuantityPerUnit] AS [Quantity], [UnitsInStock] AS [Stock], [UnitPrice] AS [Price]" _
++			& ", [CompanyName] AS [Company]" _
++			& " FROM [Products], [Categories], [Suppliers]" _
++			& " WHERE [Products].[CategoryID] = [Categories].[CategoryID]" _
++			& " AND [Suppliers].[SupplierID] = [Products].[SupplierID]" _
++			& " AND [Categories].[CategoryName] = '" & pvCat & "'" _
++			& " ORDER BY [Product] ASC"
++		Set oRS = oMydatabase.Openrecordset(sSQL)
++		'	Enumerate field names
++		vFields() = Array()			'	Mandatory before resizing a variant
++		ReDim vFields(0 To oRS.Fields.Count - 1)
++		For i = 0 To UBound(vFields)
++			vFields(i) = oRS.Fields(i).Name
++		Next i
++		'	fetch recordset data
++		vResult() = oRS.GetRows(cstSize)
++		oRS.mClose()
++		'	Transpose results
++		vTranspose = Array()
++		ReDim vTranspose(0 To cstSize, 0 To UBound(vResult, 1))
++		For i = 0 To cstSize
++			For j = 0 To UBound(vTranspose, 2)
++				'Set Empty to avoid #N/A
++				If i > UBound(vResult, 2) Then vTranspose(i, j) = Empty Else vTranspose(i, j) = vResult(j, i)
++			Next j
++		Next i
++		
++		ProductsLoad = vTranspose()
++	End If
++End Function
++//}}}
++A second {{{Global}}} variable is used here to store the field names in a more generic way:
++//{{{
++Global vFields()		As Variant
++//}}}
++!!!Headings
++The title of the data matrix is again an array formula, put in cells {{{D4:H4}}}.
++The {{{G36>0}}} condition below makes that the heading cells are evaluated after the data cells. Indeed titles are extracted from the database in the same {{{Sub}}} as the data.
++//{{{
++{=IF(AND(IsConnected,G36>0),DBTITLE(),"")}
++//}}}
++associated with next code:
++//{{{
++Function DbTitle() As Variant
++	If Not IsNull(oMyDatabase) Then
++		DbTitle() = vFields()
++	End If
++End Function
++//}}}
++!!!Close the connection
++Finally it is always recommended to clean the connection to the database.
++Associate next code
++//{{{
++Function DbClose()
++	If Not IsNull(oMyDatabase) Then oMyDatabase.mClose()
++	Set oMyDatabase = Nothing		'	Reinitialize oMyDatabase to Null
++End Function
++//}}}
++with the {{{Document closed}}} event ({{{Tools}}} + {{{Customize}}} - {{{Events}}} tab).
++!!See also
++[[Close|Close (method)]]
++[[DLookup]]
++[[GetRows]]
++[[OpenDatabase]]
++[[OpenRecordset]]
++!!!Refer to ...
++| !File | !Basic module |
++|TT ~NorthWind Calc.ods | Connect<br />Globals |
++
++
++
!!!Role
++Registers in the Traces circular buffer a new entry. The arguments will be presented in tabular form.
++!!!Syntax
++{{{DebugPrint([Value1[, Value2[, Value3[ ... ])}}}
++!!!Arguments
++| !Arguments | !Type | !Default | !When ... | !Result string |
++|List of values separated by commas | Any | Empty string ("") | Empty<br />Object<br />Null<br />Variant<br />Array<br />Boolean<br />Numeric<br />Date<br />String<br />Other |{{{--EMPTY--}}}<br />[~Object-Type] ~Object-Name<br />{{{--NULL--}}}<br />{{{--VARIANT--}}}<br />{{{--ARRAY--}}}<br />True or False<br />The numeric value<br />The Date value<br />The string<br />(ERROR) |
++!!!See also
++[[Error Handler]]
++[[TraceConsole]]
++[[TraceError]]
++[[TraceLevel]]
++[[TraceLog]]
++!!!Example
++<<tiddler "DebugPrint example">>
++
++
++
Display debug information.
++
++Next code ...
++//{{{
++Dim oForm As Object, sString As String, dDate As Date
++	Set oForm = Application.AllForms("myForm")
++	sString = "a string"
++	dDate = DateSerial(2014,5,10)
++	DebugPrint dDate, sString, oForm, oForm.Name, oForm.IsLoaded
++//}}}
++... generates next entry in the console:
++//{{{
++15:08:31 ===>    10/05/2014     a string  [FORM] myForm  myForm    False
++//}}}
++
++
++
++
You can use the Default property to specify whether a command button is the default button on a form.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br /> in a dialog |!Description |
++|[[Control]] |~CommandButton | None |~CommandButton |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.Default}}}
++//control//{{{.Default = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Property 'Default' not applicable in this context |
++|Value '...' is invalid for property 'Default' |
++!!!See also
++[[Cancel]]
++!!!Example
++<<tiddler "Cancel & Default example">>
++
++
++
[[Home]]
++
++
++
The //~DefaultValue// property specifies a value that is automatically entered in a field or a control when a new record is created.
++!!!Applies to ...
++| !Object | !Control type when<br />in a (sub)form | !Control type when<br />in a ~GridControl | !Field type |!Description |
++|[[Control]] |~CheckBox<br />[[ComboBox]]<br />~CurrencyField<br />~DateField<br />~FileControl<br />~FormattedField<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />[[RadioButton]]<br />~SpinButton<br />~TextField<br />~TimeField | All | NA |A control on an open form |
++|[[Field]] | NA | NA | Not applicable on<br />~AutoNumber fields<br />Binary and ~LongBinary fields |A field in a [[table|TableDef]], a [[query|QueryDef]] or a [[recordset|Recordset]] |
++!!!Syntax
++//control//{{{.DefaultValue}}}
++//control//{{{.DefaultValue = }}}//value//
++//field//{{{.DefaultValue}}}
++//field//{{{.DefaultValue = }}}//value//
++!!!Returned values / Arguments
++{{{Variant}}} when //~DefaultValue// is a property of a //Control// object
++{{{String}}} when //~DefaultValue// is a property of a //Field// object
++!!!Remarks
++*The //~DefaultValue// property is not applicable to //controls// belonging to a dialog.
++*The //~DefaultValue// property of a //field// returns a null-length string if there is no default value.
++*The //~DefaultValue// property of a //field// is read-only except if the field pertains to a [[table|TableDef]].
++!!!Error messages
++|Property '~DefaultValue' not applicable in this context |
++|Value '...' is invalid for property '~DefaultValue' |
++!!!Example
++<<tiddler "DefaultValue example">>
++
++
++
List the default value of all controls - if relevant - on an open form
++//{{{
++Dim ofForm As Object, ocControl As Object, i As Integer, iCount As Integer
++	Set ofForm = Forms("myForm")
++	iCount = ofForm.Controls.Count
++	For i = 0 To iCount - 1
++		Set ocControl = ofForm.Controls(i)
++		If hasProperty(ocControl, "DefaultValue") Then Print ocControl.Name & "=" & ocControl.DefaultValue
++	Next i
++	Print
++//}}}
++
++
++

++
++
++
Deletes the current record in an updatable [[Recordset object|Recordset]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.Delete()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++*A //Recordset// must contain a current record before you use //Delete//; otherwise, a run-time error occurs.
++*In an updatable //Recordset// object, //Delete// removes the current record and makes it inaccessible. Although you can't edit or use the deleted record, it remains current. Once you move to another record, however, you can't make the deleted record current again. Subsequent references to a deleted record in a //Recordset// are invalid and produce an error.
++!!!Error Messages
++|Recordset or field is not updatable |
++|Current row has been deleted by another process or user |
++|Recordset update sequence error |
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[Edit]]
++[[OpenRecordset]]
++[[Update]]
++!!!Example
++<<tiddler "Delete example">>
++
++
++
Erases a [[table|TableDef]] or a [[query|QueryDef]] object from the [[TableDefs]] or [[QueryDefs]] collections.
++!!!Applies to ...
++| !Object | !Description |
++|[[TableDefs]] |The set of tables of the database. |
++|[[QueryDefs]] |The set of queries of the database document (".odb" file). |
++!!!Syntax
++//database.~TableDefs()//{{{.Delete(}}}//tablename//{{{)}}}
++//database.~QueryDefs()//{{{.Delete(}}}//queryname//{{{)}}}
++| !Collection | !Argument | !Type |!Returned value |
++|~TableDef |tablename | String |True if success.|
++|~QueryDef |queryname |~|~|
++!!!Remarks
++*The //tablename// and //queryname// arguments are NOT case-sensitive.
++*The database document is automatically saved after the table or query deletion.
++!!!Error Messages
++|Table/Query '...' not found |
++|Method 'Collection.Delete' not applicable in this context |
++!!!See also
++[[QueryDefs]]
++[[TableDefs]]
++!!!Example
++<<tiddler "Delete (table-query) example">>
++
++
++
Erase a table from the database and a query from the database document.
++//{{{
++Dim oCollection As Object
++	Set oCollection = Application.CurrentDb().TableDefs()
++	oCollection.Delete("TempTable")
++	Set oCollection = Application.CurrentDb().QueryDefs()
++	oCollection.QueryDefs().Delete("NewQuery")
++//}}}
++
++
++
Delete the last record in a table
++//{{{
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Expenses")
++	With oRecordset
++		.MoveLast
++		.Delete
++		.mClose
++	End With
++//}}}
++
++
++
Returns the description of a field pertaining to a [[table|TableDef]], a [[query|QueryDef]] or a [[recordset|Recordset]]
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a table, a query or a recordset. |
++!!!Syntax
++//field//{{{.Description}}}
++//field//{{{.Description}}} = //Value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++The //Description// property is visible in the //Description// column of the //Table Design// view of Base.
++It is read-only except if the field pertains to a [[table|TableDef]].
++!!!Error messages
++|Value '...' is invalid for property 'Description' |
++!!!See also
++[[Name]]
++[[DataType]]
++!!!Example
++
++
++
Database functions
++//{{{
++Dim sLabel As String, sKey As String, sCategory As String
++Dim dblAverage As Double, iCount As Integer, dblSum As Double
++Dim dblMin As Double, dblMax As Double
++Dim dblStdev As Double, dblStdevP As Double, dblVar As Double, dblVarP As Double
++	sKey = "27165"
++	sLabel = DLookup("[DESCRIPTION]", "[PRODUCTS]", "[PRODUCT CODE]='" & sKey & "'")	'	SQL expects single quotes
++	sCategory = "METALLIC"
++	dblAverage = DAvg("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	iCount = DCount("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblSum = DSum("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	'	dblAverage should be = dblSum/iCount !!!
++	dblMin = DMin("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblMax= DMax("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblStdev = DStdev("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblStdevP = DStdevP("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblVar = DVar("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	dblVarP = DVarP("[SALES PRICE]", "[PRODUCTS]", "[CATEGORY]='" & sCategory & "' AND [SALES PRICE]>0")
++	'	Sqr(dblVar) should be = dblStdev !!!	
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Dialog// [[object|Object Model]] describes a dialog located in one of the accessible Basic libraries.
++If the property [[IsLoaded]] returns //True// then the dialog is active.
++!!!Functions returning a dialog object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Application]] |[[AllDialogs]] | [[Collection]] | Integer or String |{{{Application.AllDialogs("myDialog")}}} returns an object corresponding with the {{{myDialog}}} dialog |
++||[[getObject]] || String |{{{getObject("Dialogs!myDialog")}}} returns an object corresponding with the {{{myDialog}}} dialog. {{{myDialog}}} must be active. |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[Caption]] |||Specifies the text that appears in the title bar. |
++|[[Height]] |||Specifies the height of the dialog. |
++|[[IsLoaded]] || Y |True if dialog is active. |
++|[[Name]] || Y |Specifies the real name of the dialog |
++|[[ObjectType]] || Y |Returns "DIALOG" |
++|[[Visible]] |||Shows or hides the dialog without making it inactive. |
++|[[Width]] |||Specifies the width of the dialog. |
++|~UnoDialog | UNO | Y |com.sun.star.awt.~XControl<br />The output of the //~CreateUnoDialog// Basic function. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[EndExecute]] | returnvalue | Long |Stop the execution of the dialog and return //returnvalue//. |
++|[[Execute|Execute (dialog)]] |||Display the dialog and interact with the user. |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Dialog has the given property. |
++|[[Move]] | coordinates |~|Return True if Dialog has been moved successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++|[[Start]] |||Initialize the dialog. |
++|[[Terminate]] |||Close all processing concerning the actual dialog. |
++!!!Remarks
++Each //Dialog// [[object|Object Model]] has a Controls [[collection|Collection]], that contains all controls on the dialog. You can refer to a specific control on a dialog by referring to the [[Controls]] collection. 
++!!!Examples
++<<tiddler "Dialog example">>
++
++
++
Display a dialog
++//{{{
++Dim oDialog As Object, lExecute As Long
++Const dlgOK = 1
++Const dlgCancel = 0
++	oDialog = Application.AllDialogs("myDialog")
++	oDialog.Start
++	lExecute = oDialog.Execute
++	Select Case lExecute
++		Case dlgCancel			'	Cancel button pressed
++			'	... do probably nothing ...
++		Case dlgOK			'	OK button pressed
++			'	... process the dialog, all controls are still available
++		Case Else			'	Dialog interrupted programmatically
++			'	... process the dialog based on the returned value
++	End Select
++	oDialog.Terminate
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~DoCmd// class is a secondary root class from which actions or commands are initiated..
++The //~DoCmd// class must not be instantiated. The only preset instance MUST be called {{{DoCmd}}}. In fact it is implemented simply as a Basic module. 
++As an example, next statements are equivalent :
++//{{{
++	RunCommand("DBDirectSQL")
++//}}}
++and
++//{{{
++	DoCmd.RunCommand("DBDirectSQL")
++//}}}
++!!Methods
++| !Method | !Description |
++|[[ApplyFilter]] |Apply a filter, a query, or an SQL WHERE clause to a table, form, subform or query. |
++|[[Close]] |Close an object (table, query, form or report). |
++|[[CopyObject]] |Copy an existing query or table. |
++|[[FindNext]] |Find the next instance of data that meets the criteria specified by the arguments of the last invoked //~FindRecord// action. |
++|[[FindRecord]] |Find the first instance of data that meets the criteria specified by the //~FindRecord// arguments. |
++|[[GetHiddenAttribute]] |Know if a named window is currently hidden or visible. |
++|[[GoToControl]] |Move the focus to the named control in the active window. |
++|[[GoToRecord]] |Make the specified record the current record in an open form |
++|[[Maximize]] |Maximize the window containing the //Form// having the focus. |
++|[[Minimize]] |Minimize the window containing the //Form// having the focus. |
++|[[MoveSize]] |Move the active window to the coordinates specified by the argument values. |
++|[[OpenForm]] |Open a form in normal view or in form design view. |
++|[[OpenQuery]] |Open a query in normal view or in query design view. |
++|[[OpenReport]] |Open a report in normal view or in report design view. |
++|[[OpenSQL]] |Open a datasheet containing the data described by the provided SELECT SQL statement. |
++|[[OpenTable]] |Open a table in normal view or in table design view. |
++|[[OutputTo]] |Output the data in the specified object (currently only a form) to several output formats. |
++|[[Quit]] |Quit //~OpenOffice/~LibreOffice Base//. |
++|[[RunApp]] |Run an external application given by its command line. |
++|[[RunCommand]] |Execute the command given as argument. |
++|[[RunSQL]] |Execute the SQL statement given as argument. |
++|[[SelectObject]] |Move the focus to the specified window. |
++|[[SendObject]] |Output the data in the specified object (currently only a form) to several output formats and inserts it into an e-mail. |
++|[[SetHiddenAttribute]] |Specify if a named window must be made hidden or visible. |
++|[[SetOrderBy]] |Apply a sort to a table, form or datasheet. |
++|[[ShowAllRecords]] |Remove any existing filters and sorts that may exist on the current table, query, or form. |
++|[[SysCmd]] |Display a progress meter or specified text in the status bar. |
++
++
++
Copies the current record from an updatable [[Recordset object|Recordset]] to the edit buffer for subsequent editing.
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.Edit()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++*Once you use the //Edit// method, changes made to the current record's fields are copied to the copy buffer. After you make the desired changes to the record, use the [[Update method|Update]] to save your changes.
++*After you modify the new record, use the [[Update]] method to save the changes and add the record to the //Recordset//. No changes occur in the database until you use the //Update// method.
++**''Caution'' If you edit a record and then perform any operation that moves to another record, but without first using //Update//, your changes are lost without warning.
++*The current record remains current after you use //Edit//.
++!!!Error Messages
++|Recordset or field is not updatable |
++|Current row has been deleted |
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[DefaultValue]]
++[[Update]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "Edit example">>
++
++
++
Modify the last record in a table
++//{{{
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Expenses")
++	With oRecordset
++		.MoveLast
++		.Edit
++		.Fields("AMOUNT").Value = 4321
++		.Update
++		.mClose
++	End With
++//}}}
++
++
++
The //~EditMode// property returns a value that indicates the state of editing for the current record.
++!!!Applies to ...
++| !Object |!Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.EditMode}}}
++!!!Returned values
++|dbEditNone | Long |No editing operation is in progress. |
++|dbEditInProgress |~|The [[Edit]] method has been invoked, and the current record is in the edit buffer. |
++|dbEditAdd |~|The [[AddNew]] method has been invoked, and the current record in the edit buffer is a new record that hasn't been saved in the database. |
++!!!Remarks
++*The //~EditMode// property is read-only.
++*The //~EditMode// property is useful when an editing process is interrupted, for example, by an error during validation. You can use the value of the //~EditMode// property to determine whether you should use the [[Update]] or [[CancelUpdate]] method.
++*If useful you can insert next lines in your own code:
++//{{{
++REM Edit mode
++Const dbEditNone = 0
++Const dbEditInProgress = 1
++Const dbEditAdd = 2
++//}}}
++!!!Error messages
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Edit]]
++[[Recordset]]
++[[Update]]
++!!!Example
++
++
++
*Employees table
++| !Fields | !Field Type | !Primary |
++|Address | Text ||
++|~BirthDate | Date/Time ||
++|City | Text ||
++|Country | Text ||
++|Extension | Integer ||
++|~FirstName | Text ||
++|~HireDate | Date/Time ||
++|~HomePhone | Text ||
++|~LastName | Text ||
++|Notes | Text ||
++|Photo | Text ||
++|~PostalCode | Text ||
++|Region | Text ||
++|~ReportsTo | ~BigInt ||
++|Title | Text ||
++|~TitleOfCourtesy | Text ||
++|~EmployeeID | ~BigInt | Y |
++
++
++
The //Enabled// property specifies if the control is accessible with the cursor.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />[[SubForm]]-- | All | All |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.Enabled}}}
++//control//{{{.Enabled = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Property 'Enabled' not applicable in this context |
++|Value '...' is invalid for property 'Enabled' |
++!!!See also
++[[Locked]]
++!!!Example
++<<tiddler "Enabled & Locked example">>
++
++
++
Lock and disable control
++//{{{
++Dim ocControl As Object
++	Set ocControl = Controls("myForm", "myControl")
++	ocControl.Enabled = False
++	ocControl.Locked = True
++//}}}
++
++
++
The //~EndExecute// method interrupts programmatically the display of the specified [[dialog|Dialog]] and transfers a value to be returned by the interrupted [[Execute|Execute (dialog)]] method.
++!!!Applies to ...
++| !Object | !Description |
++|[[Dialog]] |The representation of a Basic dialog |
++!!!Syntax
++//dialog//.{{{EndExecute(}}}//returnvalue//{{{)}}}
++| !Argument | !Type |!Description |
++| returnvalue | //Long// |The value that will return the pending [[Execute|Execute (dialog)]] method applied to the //Dialog// object  |
++!!!Remarks
++*The //~EndExecute// method must be preceeded with the [[Execute|Execute (dialog)]] method applied on the same object.
++*The //~EndExecute// method is usually triggered from a //dialog// or //control// event linked to the concerned dialog box.
++!!!Error messages
++|Dialog unknown |
++|Dialog not yet started |
++!!!See also
++[[AllDialogs]]
++[[Execute|Execute (dialog)]]
++[[Start]]
++[[Terminate]]
++!!!Example
++<<tiddler "Dialog example">>
++
++
++
(Q) How can I cycle through the controls on a form and retrieve their names?
++
++(R) Use the following function as an example. Pass the form's name to it and watch the displayed result.
++
++Note: Make sure you also copy [[bIsLoaded|FindOutFormOpen]] function since fEnumControls uses it internally to make sure that the form to be enumerated is open.
++//{{{
++Sub fEnumControls(ByVal sFrmToEnum As String)
++
++'Display control's Type and Name
++'will NOT enumerate controls within an embedded subform
++
++	'if form is closed, exit function
++Const vbCritical = 16
++	If Not bIsLoaded(sFrmToEnum) Then
++		MsgBox "Form " & sFrmToEnum & " is probably closed!! " & _
++			"Please open it & try again.", vbCritical
++		Exit Sub
++	End If
++
++Dim oForm As Object, oControl As Object, iCount As Integer, i As Integer
++	Set oForm = Forms(sFrmToEnum)
++	'Count the number of controls
++	iCount = oForm.Controls().Count
++
++	For i = 0 To iCount - 1
++		Set oControl = oForm.Controls(i)
++		DebugPrint oControl.SubType & ":", oControl.Name
++	Next i
++	
++End Sub
++//}}}
++!!!See also
++[[Forms]]
++[[Controls]]
++[[Count]]
++[[Name]]
++[[SubType]]
++[[DebugPrint]]
++
++
++
!!!Introduction
++~Access2Base uses internally an error handler that can be optionally used by users in their own code.
++The principles are:
++*An error has an __error-level__. The error-level determines the severity of the error and the behaviour of the program after the error trap: stop or go ahead ?
++*All errors, whatever their level, can be registered on the request of the programmer. The technique used by ~Access2Base is to keep the error //traces// in memory through a //circular buffer//, i.e. a buffer where the oldest entries are replaced by the new ones when the buffer gets full.
++*The error traces (circular buffer) can be viewed for debugging purposes in what is called the ''~Access2Base Console'' dialog box.
++*All the user-defined Subs or Functions follow the same code structure for error handling.
++!!!To view the errors log
++*If //~Access2Base// is included in the software, run next code, either directly in the Basic IDE or via a toolbar button, or ...
++//{{{
++Sub Console()
++	TraceConsole()
++End Sub
++//}}}
++*If //~Access2Base// has been installed as a separate extension, then execute next menu command
++>{{{Tools + Add-Ons + Access2Base Console ...}}}
++in the Basic IDE.
++!!!API
++The routines for error handling are:
++|[[TraceConsole]] |Open the //Console// dialog box for display of all past errors and logs. |
++|[[TraceError]] |Report an error found. |
++|[[TraceLevel]] |Set the minimal level of errors to be reported in the console. |
++|[[TraceLog]] |Log an event in the circular buffer if its level is at least equal to the minimal error level. |
++|DebugPrint |Record as many values as wanted in tabular form in the circular buffer, typically for debugging. |
++!!!Error levels
++| !Level | !Type |!Description |
++|"DEBUG" | String |To report values of variables during the program execution. Such reported errors are NOT user visible. |
++|"INFO" |~|To report any event |
++|"WARNING" |~|To report some abnormal event. |
++|"ERROR" |~|To report an error trapped by a user program. |
++|"FATAL" |~|To report an error caused by a user program but detected by ~Access2Base (f.i. "Form does not exist ..." etc.). |
++|"ABORT" |~|To report an error inside the ~Access2Base API itself. Do not use for programmer or user errors. |
++!!!Recommended program structure for error handling
++The example is given for a //Sub//. It is, mutatis mutandis, equally valid for a //Function//.
++//{{{
++Sub mySub
++	On Local Error Goto Error_Sub
++	...
++Exit_Sub:
++	Exit Sub
++Error_Sub:
++	TraceError("ERROR", Err, "MySub", Erl)
++	Goto Exit_Sub
++End Sub
++//}}}
++In case of error next message will be displayed to the user and simultaneously registered in the trace buffer:
++>Error # //number// (//...description...//) occurred at line //line// in mySub.
++
++
++

++
++
++
The {{{Event}}} [[object|Object Model]] describes an event occurred typically from within a form or a form control, a dialog or a dialog control, or fired from elsewhere.
++!!!Functions returning an //Event// object
++| !Parent object | !Function | !Type | !Arguments |!Description |
++|[[Application]] |[[Events]] | [[Collection]] | the //event// object passed by ~OpenOffice/~LibreOffice<br />as argument of a document, form, subform or control event |{{{Application.Events(oEvent)}}} returns an //Event// object. |
++!!!Properties of an //Event// object
++| !Property | !Type | !Description |
++|~EventType | String |See the [[events handler|Events Handler]]. |
++|~EventName | String |The following //~EventNames// are commonly available:<br />//~OnAlphaCharInput, ~OnClick, ~OnCloseApp, ~OnCopyTo, ~OnCopyToDone, ~OnCreate, ~OnError, ~OnFocus, ~OnInsertDone, ~OnInsertStart, ~OnLoad, ~OnLoadCancel, ~OnLoadDone, ~OnLoadError, ~OnLoadFinished, ~OnMailMerge, ~OnMailMergeFinished, ~OnModifyChanged, ~OnMouseOut, ~OnMouseOver, ~OnMove, ~OnNew, ~OnNewMail, ~OnNonAlphaCharInput, ~OnPageCountChange, ~OnPrepareUnload, ~OnPrepareViewClosing, ~OnPrint, ~OnResize, ~OnSave, ~OnSaveAs, ~OnSaveAsDone, ~OnSaveDone, ~OnSaveFinished, ~OnSelect, ~OnStartApp, ~OnSubComponentClosed, ~OnSubComponentOpened, ~OnTitleChanged, ~OnToggleFullscreen, ~OnUnfocus, ~OnUnload, ~OnViewClosed, ~OnViewCreated.// |
++|~ContextShortcut | String |The [[shortcut notation|ShortCut Notation]] of the object (form, dialog or control) having triggered the event. |
++|~ButtonLeft<br />~ButtonRight<br />~ButtonMiddle | Boolean |Indicates if the mouse button has been pressed .|
++|~XPos<br />~YPos | Null or Long |Coordinates of the mouse cursor. |
++|~ClickCount | Long |Number of mouse clicks. |
++|~KeyCode | Integer |See the constants group {{{com.sun.star.awt.Key}}} |
++|~KeyChar | String |The pressed key. |
++|~KeyFunction | Integer |See the constants group {{{com.sun.star.awt.KeyFunction}}} |
++|~KeyAlt<br />~KeyCtrl<br />~KeyShift | Boolean |Key combined with Alt, Ctrl or Shift keys. |
++|~FocusChangeTemporary | Boolean |False if focus change due to a user action in same window. |
++|[[ObjectType]] | String |Returns "EVENT" |
++|~RowChangeAction | Long |See the constants group {{{com.sun.star.sdb.RowChangeAction}}} |
++|Recommendation | String |"IGNORE" if the event is recommended to be ignored. Valid only for the //Before record action// form event which is, for strange reasons, fired twice. The first time is recommended to be ignored. |
++|Source | Object |Return the [[Database]], [[Form]], [[SubForm]], [[Dialog]] or [[Control]] object having fired the event |
++|~SubComponentName | String |The name of the component being //opened// or //closed// while executing a //Loaded a sub component// or //Closed a sub component// event. Such an event is set thru the {{{Tools + Customize ... + Events}}} menu command. |
++|~SubComponentType | Long |To be associated with the //~SubComponentName// property. Returns one of next constants:<br />//acTable<br />acQuery<br />acForm<br />acReport// |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Event has the given property. |
++!!!Remarks
++*All properties are read-only.
++*Their values are accessible with the usual syntax<br />//oEvent//{{{.property}}}
++*The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++//}}}
++!!!See also
++[[Events Handler]]
++[[Events]]
++!!!Example
++<<tiddler "Event example">>
++
++
++
++
Assign next macro to the //~TextModified// event of a combo box (other controls could require that the //Changed// event should be used for the same purpose).
++When the user changes his/her selection in the combo box the content of the form is requeried and refreshed on the screen.
++//{{{
++Sub SelectChanged(poEvent As Object)
++
++REM Combo value has changed
++REM => requery form
++
++Dim oeEvent As Object, ocCombo As Object, sSQL As String, oForm As Object
++	Set oeEvent = Events(poEvent)
++	Set ocCombo = oeEvent.Source
++	sSQL = "SELECT [PRODUCT CODE],[DENOMINATION],[SUPPLIER ID] FROM PRODUCTS WHERE " _
++				& "[SUPPLIER ID]='" & ocCombo.Value & "'"
++	Set oForm = Forms("myComboForm")
++	oForm.RecordSource = sSQL
++	
++End Sub
++//}}}
++
++
++
The {{{Events}}} collection returns the (unique) instance of the currently executed [[event object|Event]].
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]Events(}}}//event//{{{)}}}
++
++The //event// argument is the variable of {{{Variant/Object}}} type given as argument by ~OpenOffice/~LibreOffice to the macro invoked when the event occurs.
++!!!Returned values
++Either 
++- {{{Nothing}}} (to be tested with the {{{IsNull()}}} Basic builtin function) when the event is not really an event or it was triggered by an unsupported event type - or some other error occurred (the call to {{{Events()}}} never stops the execution of the macro). In particular, when the event has been triggered by a toolbar button;
++or
++- an object of type //Event//.
++!!!See also
++[[Events Handler]]
++[[Event]]
++!!!Example
++<<tiddler "Event example">>
++
++
++
++
{{firstletter{
++ @@color:#930;E@@
++ }}}''vents'' can automatically execute a macro when a specified software event occurs by assigning the desired macro to the event. The macros might be defined at database document, [[form|Form]], [[subform|SubForm]], [[dialog|Dialog]], [[control|Control]], menu item or toolbar button level. The triggered macro has one argument of type //Object//.
++The //Events Handler// of //~Access2Base// provides a mean to standardize the processing of events and to increase the reusability of macros: indeed the same macro could be used for several controls - if meaningful, of course - as there is an easy way to identify the control which triggered the macro.
++
++''Note that the described technique has nothing in common with the events processing in //~MSAccess//.''
++!!!Step by step
++#Assign the event to a macro: see the ~LibreOffice/~OpenOffice Help or documentation.
++#In the code of the macro invoke the [[Events]] collection. Note that the macro may be a {{{Sub}}} or a {{{Function}}} depending on the necessity or not to return the value {{{False}}} to cancel the event.
++#Use the properties of the returned object to process the event. In particular the //Source// property.
++//{{{
++Sub myEventMacro(poEvent As Object)
++Dim oeEvent As Object, myControl As Object
++	Set oeEvent = Events(poEvent)
++	Set myControl = oEvent.Source	'	Return the Control object
++					'	that triggered the event
++	REM ...
++End Sub
++//}}}
++!!!Event types
++The types of events supported by the ~Access2Base API are listed below. See the ~OpenOffice/~LibreOffice documentation for more details.
++The invocation of {{{Events()}}} returns a {{{Null}}} value when other event types occur.
++| !Event type | !Description |
++|DOCUMENTEVENT |At document (database) level. |
++|EVENTOBJECT |Generic for most //form// and //control// events. |
++|ACTIONEVENT |Triggered by a button, ... |
++|FOCUSEVENT |Triggered by a focus change. |
++|INPUTEVENT |Use of special keys. |
++|ITEMEVENT |Action in menu or listbox. |
++|KEYEVENT |Use of normal keys. |
++|MOUSEEVENT |Mouse move or click. |
++|ROWCHANGEEVENT |Insert, update or delete action. |
++|TEXTEVENT |Edition of //control// content. |
++!!!See also
++[[Events]]
++[[Event]]
++[[getObject]]
++!!!Example
++<<tiddler "Event example">>
++
++
++
++
	
++
++
++
The //Execute// method executes the command or script associated with acontrol in a toolbar.
++!!!Applies to ...
++| !Object | !Description |
++|[[CommandBarControl]] |The representation of  control in a [[CommandBar]]. |
++!!!Syntax
++//commandbarcontrol//.{{{Execute}}}
++!!!Returned value
++{{{True}}} if success
++!!!Remarks
++The //Execute// method may be preceded with the [[OnAction]] property of the same object.
++!!!Error messages
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++[[OnAction]]
++[[RunCommand]]
++!!!Example
++<<tiddler "CommandBarControl example">>
++
++
++
The //Execute// method displays the specified [[dialog|Dialog]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Dialog]] |The representation of a Basic dialog |
++!!!Syntax
++//dialog//.{{{Execute}}}
++| !Returned values | !Type |!Description |
++|//dlgOK// ||if OK button pressed |
++|//dlgCancel// |~|if Cancel button pressed or dialog closed with the Window close button |
++|Any | //Long// |The argument of the [[EndExecute]] method having requested the dialog closure |
++!!!Remarks
++*The //Execute// method must be preceeded with the [[Start]] method on the same object.
++*Return values can be incorporated in your code by copying/pasting next lines:
++//{{{
++Const dlgOK = 1				'	OK button pressed
++Const dlgCancel = 0			'	Cancel button pressed
++//}}}
++!!!Error messages
++|Dialog unknown |
++|Dialog not yet started |
++!!!See also
++[[AllDialogs]]
++[[EndExecute]]
++[[Start]]
++[[Terminate]]
++!!!Example
++<<tiddler "Dialog example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Execute// method executes the SQL statement contained in a query. The statement must execute an action. Examples of such statements are: INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX.
++!!!Applies to
++| !Object | !Description |
++|[[QueryDef]] |The representation of a stored query. |
++!!!Syntax
++{{{querydef.Execute(options)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{options}}} | Yes | Integer<br />Long |If the argument is present its only allowed value = dbSQLPassThrough.<br />Forces escape substitution before sending the SQL statement to the database. |
++The method returns False if the execution of the SQL statement failed.
++!!!Remarks
++To include the constant in your own code, copy and paste next line:
++//{{{
++Const dbSQLPassThrough = 64
++//}}}
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|SQL Error, SQL statement = '...' |
++!!!See also
++[[OpenSQL]]
++[[RunSQL]]
++[[OpenQuery]]
++[[SQL]]
++!!!Example
++<<tiddler "Execute query example">>
++
++
++
Delete an existing table and execute a stored query that recreates the table
++//{{{
++Dim oQuery As Object
++	DoCmd.RunSQL("DROP TABLE IF EXISTS [TEST_TABLE]")
++	Set oQuery = Application.CurrentDb().QueryDefs("CreateTestTable")
++	oQuery.Execute
++'Refresh the list of tables in the database window
++Const acDatabaseWindow = 102
++	DoCmd.SelectObject acDatabaseWindow
++	DoCmd.RunCommand "DBRefreshTables"
++//}}}
++The SQL contained in the query is ...
++//{{{
++CREATE TABLE TEST_TABLE
++(COL1 INTEGER NOT NULL,
++COL2 CHAR(25),
++COL3 VARCHAR(25),
++COL4 DECIMAL(10,2) NOT NULL,
++COL5 DATE,
++PRIMARY KEY (COL1))
++//}}}
++
++
++
(Q) How can I list table and field names, and use them in my code ?
++
++(R) We will present 2 techniques. a generic one which uses the ~Access2Base API for exploring //~TableDefs//, and a second, which is specific to HSQLDB, which runs SQL statements on the database schema.
++
++!!!An easy solution is to use the [[TableDefs]] and [[Fields]] collections and their objects.
++Here a simple list of tables with their fields and types:
++//{{{
++Sub ScanTables()
++
++Dim oDatabase As Object, oTable As Object, oField As Object
++Dim i As Integer, j As Integer
++
++	Set oDatabase = Application.CurrentDb()
++	With odatabase
++		For i = 0 To .TableDefs.Count - 1
++			Set oTable = .TableDefs(i)
++			DebugPrint oTable.Name
++
++			For j = 0 To oTable.Fields.Count - 1
++				Set oField = oTable.Fields(j)
++				DebugPrint "", LongStr(oField.Name), LongStr(oField.TypeName), oField.Size
++			Next j
++		Next i
++	End With
++
++End Sub
++
++Function LongStr(psString As String) As String
++Const cstLength = 20
++	LongStr = Left(psString & Space(cstLength), cstLength)
++End Function
++//}}}
++Note that the //~LongStr// function is there only to have the output cleanly aligned in columns.
++The output will be something like:
++//{{{
++    Categories
++         CategoryName             VARCHAR                  50
++         Description              VARCHAR                  2147483647
++         Picture                  BINARY                   2147483647
++         CategoryID               BIGINT                   0
++    Customers
++         Address                  VARCHAR                  50
++         City                     VARCHAR                  50
++         CompanyName              VARCHAR                  50
++         ContactName              VARCHAR                  50
++         ContactTitle             VARCHAR                  50
++         Country                  VARCHAR                  50
++         CustomerID               VARCHAR                  50
++         Fax                      VARCHAR                  50
++         Phone                    VARCHAR                  50
++         PostalCode               VARCHAR                  50
++         Region                   VARCHAR                  50
++    Employees
++         Address                  VARCHAR                  50
++ etc ...
++//}}}
++!!!Solution by exploring the database schema directly (HSQLDB only)
++Not surprisingly __reading the HSQLDB documentation__ will help understand the following examples.
++Running next code
++//{{{
++Sub ScanSchemaSQL()
++Dim sSql As String
++	sSql = "SELECT [TABLE_NAME],[COLUMN_NAME],[SYSTEM_COLUMNS].[TYPE_NAME],[COLUMN_SIZE] " _
++			& "FROM [INFORMATION_SCHEMA].[SYSTEM_TABLES],[INFORMATION_SCHEMA].[SYSTEM_COLUMNS] " _
++			& "WHERE [TABLE_SCHEM]='PUBLIC' AND [SYSTEM_COLUMNS].[TABLE_NAME]=[SYSTEM_TABLES].[TABLE_NAME]"
++	OpenSQL(sSql, dbSQLPassThrough)
++End Sub
++//}}}
++produces the result displayed below:
++//{{{
++TABLE_NAME		COLUMN_NAME		TYPE_NAME	COLUMN_SIZE
++Categories		CategoryName		VARCHAR		50
++Categories		Description		VARCHAR		2147483647
++Categories		Picture			BINARY		2147483647
++Categories		CategoryID		BIGINT	
++Customers		Address			VARCHAR		50
++Customers		City			VARCHAR		50
++Customers		CompanyName		VARCHAR		50
++Customers		ContactName		VARCHAR		50
++Customers		ContactTitle		VARCHAR		50
++Customers		Country			VARCHAR		50
++Customers		CustomerID		VARCHAR		50
++Customers		Fax			VARCHAR		50
++Customers		Phone			VARCHAR		50
++Customers		PostalCode		VARCHAR		50
++Customers		Region			VARCHAR		50
++Employees		Address			VARCHAR		50
++etc ...
++//}}}
++The same results can also be explored programmatically:
++//{{{
++Sub ScanSchema()
++
++Dim oRecordset As Object, sSql As String, iNbFields As integer
++	sSql = "SELECT [TABLE_NAME],[COLUMN_NAME],[SYSTEM_COLUMNS].[TYPE_NAME],[COLUMN_SIZE] " _
++			& "FROM [INFORMATION_SCHEMA].[SYSTEM_TABLES],[INFORMATION_SCHEMA].[SYSTEM_COLUMNS] " _
++			& "WHERE [TABLE_SCHEM]='PUBLIC' AND [SYSTEM_COLUMNS].[TABLE_NAME]=[SYSTEM_TABLES].[TABLE_NAME]"
++	
++	Set oRecordset = Application.CurrentDb().OpenRecordset(sSql, , dbSQLPassThrough, dbReadOnly)
++	With oRecordset
++		iNbFields = .Fields.Count
++		Do While Not .EOF()
++			DebugPrint LongStr(.Fields("TABLE_NAME").Value) _
++						, LongStr(.Fields("COLUMN_NAME").Value) _
++						, LongStr(.Fields("TYPE_NAME").Value) _
++						, .Fields("COLUMN_SIZE").Value
++			.MoveNext()
++		Loop
++	End With
++	
++End Sub
++//}}}
++produces once again the same result as before ...
++//{{{
++Categories               CategoryName             VARCHAR                  50
++Categories               Description              VARCHAR                  2147483647
++Categories               Picture                  BINARY                   2147483647
++Categories               CategoryID               BIGINT                   [NULL]
++Customers                Address                  VARCHAR                  50
++Customers                City                     VARCHAR                  50
++Customers                CompanyName              VARCHAR                  50
++Customers                ContactName              VARCHAR                  50
++Customers                ContactTitle             VARCHAR                  50
++Customers                Country                  VARCHAR                  50
++Customers                CustomerID               VARCHAR                  50
++Customers                Fax                      VARCHAR                  50
++Customers                Phone                    VARCHAR                  50
++Customers                PostalCode               VARCHAR                  50
++Customers                Region                   VARCHAR                  50
++Employees                Address                  VARCHAR                  50
++etc ...
++//}}}
++!!!See also
++[[DebugPrint]]
++[[Fields]]
++[[OpenSQL]]
++[[Recordsets]]
++[[TableDefs]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Dictionary |||||Run one of the proposed Subs. They do not need any form or control event. |
++
++
++
(Q) Can I export the content of database binary fields somewhere to the file system ?
++
++(R) Use the [[WriteAllBytes]] method. It's exactly its purpose !
++
++Let's consider next table:
++<<tiddler "CategoriesTable">>
++Run next Sub. The assumption is that each file in the directory has a name corresponding with the name of the category (after having substituted "/" in category names by a space).
++//{{{
++Sub ExportImages(psPath As String)
++
++Dim oTable As Object, oRecordset As Object, sCatName As String
++	Set oTable = Application.CurrentDb().TableDefs("CATEGORIES")
++	Set oRecordset = oTable.OpenRecordset()
++	
++	With oRecordset
++		Do While Not .EOF()
++			sCatName = Join(Split(.Fields("CATEGORYNAME").Value, "/"), " ")
++			.Fields("Picture").WriteAllBytes(psPath & sCatName & ".png")
++			.MoveNext
++		Loop
++		.mClose()
++	End With
++	
++End Sub
++//}}}
++!!!See also
++[[Fields]]
++[[OpenRecordset]]
++[[Recordset]]
++[[TableDefs]]
++[[ReadAllBytes]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Images |||||Adapt the //path// argument and run the //Main// Sub from the Basic IDE. |
++
++
++
(Q) How do I get data from a database table into my Basic application ?
++
++(R) After you have located a particular record or records, you may want to extract data to use in your application. 2 methods are proposed: a single value or bulk data.
++
++Let's consider next table:
++<<tiddler "OrdersTable">>
++!!!Copying a Single Field
++You can copy a single field of a record to a variable of the appropriate data type. The following example extracts three fields from the first record in a [[Recordset object|Recordset]].
++//{{{
++Dim odbNorthwind As Object
++Dim orsOrders As Object
++Dim dOrderDate As Date
++Dim sShipAddress As String
++Dim sShipCity As String
++
++	Set odbNorthwind = Application.CurrentDb
++	Set orsOrders = odbNorthwind.OpenRecordset("Orders")
++
++	With orsOrders
++		.MoveFirst
++		dOrderDate = .Fields("OrderDate").Value
++		sShipAddress = .Fields("ShipAddress").Value
++		sShipCity = .Fields("ShipCity").Value
++		.mClose()
++	End With
++//}}}
++!!!Copying Entire Records to an Array
++To copy one or more records, you can create a two-dimensional array and copy records one at a time. You increment the first subscript for each record and the second subscript for each field.
++A fast way to do this is to use the [[GetRows method|GetRows]], which returns a two-dimensional array. The first subscript identifies the row and the second identifies the field number, as follows.
++//{{{
++vRecords(iRecord, iField) 
++//}}}
++The following code example uses an SQL statement to retrieve three fields from a table into a //Recordset// object. It then uses the //~GetRows// method to retrieve the first three records of the //Recordset//, and it stores the selected records in a two-dimensional array. It then prints each record, one field at a time, by using the two array indexes to select specific fields and records.
++//{{{
++Sub ExtractDataTableBulk()
++Dim odbNorthwind As Object
++Dim orsOrders As Object
++Dim vRecords As Variant
++Dim iNumRows As Integer
++Dim iNumColumns As Integer
++Dim iRow As Integer
++Dim iColumn As Integer
++Dim sSQL As String 
++ 
++On Local Error GoTo ErrorHandler 
++ 
++	Set odbNorthwind = Application.CurrentDb
++	sSQL = "SELECT [OrderDate],[ShipAddress],[ShipCity] FROM Orders"
++	Set orsOrders = odbNorthwind.OpenRecordset(sSQL)
++
++	vRecords = orsOrders.GetRows(10)
++	iNumRows = UBound(vRecords, 1) + 1
++	iNumColumns = UBound(vRecords, 2) + 1
++
++	For iRow = 0 To inumRows - 1
++		For iColumn = 0 To iNumColumns - 1
++			DebugPrint vRecords(iRow, iColumn)
++		Next iColumn
++	Next iRow
++
++	orsOrders.mClose()
++	Set orsOrders = Nothing
++	Exit Sub
++
++ErrorHandler: 
++	TraceError("ERROR", Err, "ExtractDataTableBulk", Erl)
++End Sub
++//}}}
++You can use subsequent calls to the //~GetRows// method if more records are available. Because the array is filled as soon as you call the GetRows method, you can see why this approach is much faster than copying one field at a time.
++
++Notice also that you do not have to declare the Variant as an array, because this is done automatically when the GetRows method returns records.
++
++If you are trying to retrieve all the rows by using multiple //~GetRows// calls, use the [[EOF|BOF, EOF]] property to be sure that you are at the end of the //Recordset//. The //~GetRows// method may return fewer rows than you request. If you request more than the remaining number of rows in a //Recordset//, the //~GetRows// method returns only the rows that remain. 
++
++Because the //~GetRows// method always returns all the fields in the //Recordset// object, you may want to create a query that returns just the fields that you need. This is especially important for LONGVARBINARY and LONGVARCHAR (Memo) fields.
++!!!See also
++[[DebugPrint]]
++[[OpenRecordset]]
++[[TraceError]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~ExtractDataTable1Field ||
++|~|~ExtractDataTableBulk ||
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //field// [[object|Object Model]] describes one of the fields of a [[table|TableDef]], a [[query|QueryDef]] or a [[recordset|Recordset]]. Each field will be retrieved as a member of the [[Fields]] [[collection|Collection]] of its corresponding parent.
++!!!Functions returning a field object
++| !Parent object | !Function | !Type | !Arguments |!Short example |
++|[[Recordset]]<br />[[QueryDef]]<br />[[TableDef]] |[[Fields]] | [[Collection]] | None<br />Integer, Long<br />String |{{{Application.CurrentDb().TableDefs("myTable").Fields("myField")}}}<br />returns an object of type {{{Field}}} referring to the {{{myField}}} field in the {{{myTable}}} table. |
++!!!Field types
++The distinct field types can be recognized thru the use either of the [[DataType]] (long), the [[DbType|DataType]] (integer) or the [[TypeName|DataType]] (string) properties. The //~DbType// property is proposed in //~Access2Base// for compatibility with ~MSAccess.
++See the correspondence table below.
++<<tiddler "FieldTypesList">>
++!!!Properties
++| !Property | !Type | !Read only |!Description or UNO object |
++|[[DataType]] || Y |Specifies the //AOO/~LibO// type of the data as an integer value |
++|[[DbType|DataType]] || Y |Specifies the //~MsAccess// type of the data as an integer value |
++|[[DefaultValue]] |||Returns the value stored in a new record |
++|[[Description]] |||A summary description of the field |
++|[[FieldSize]] || Y |Returns the number of bytes used in the database of a Memo or Long Binary field |
++|[[Name]] || Y |The exact name of the field |
++|[[ObjectType]] || Y |Always "FIELD" |
++|[[Size]] || Y |The maximum size of the field |
++|[[SourceField]] || Y |Indicates the name of the field that is the original source of the data for the field  |
++|[[SourceTable]] || Y |Indicates the name of the table that is the original source of the data for the field  |
++|[[TypeName|DataType]] || Y |Specifies the //AOO/~LibO// type of the data as a string |
++|[[Value|Value (field)]] |||The value stored or to be stored in the field |
++|Column | UNO | Y |com.sun.star.sdb.~OTableColumnWrapper<br />org.openoffice.comp.dbaccess.~OQueryColumn<br />com.sun.star.sdb.~ODataColumn |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Field has the given property. |
++|[[ReadAllBytes]] | filename |~|Store a binary file in a binary field |
++|[[ReadAllText]] | filename |~|Store a text file in a memo field |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++|[[WriteAllBytes]] | filename |~|Copy a binary field into a file |
++|[[WriteAllText]] | filename |~|Copy a memo field into a file |
++!!!Remarks
++!!!Example
++<<tiddler "DataType example">>
++
++
++
Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary [[Field object|Field]] in the [[Fields collection|Fields]] of a [[Recordset object|Recordset]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a recordset. |
++!!!Syntax
++//field//{{{.FieldSize}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++*The //~FieldSize// property is read-only.
++*Because the size of a Long Binary or Memo field can exceed 64K, you should assign the value returned by //~FieldSize// to a variable large enough to store a {{{Long}}} variable.
++*To determine the size of a [[Field object|Field]] other than Memo and Long Binary types, use the [[Size property|Size]]. The //FieldSize// property returns in this case an {{{EMPTY}}} value.
++!!!Error messages
++|Property '~FieldSize' not applicable in this context |
++!!!See also
++[[DataType]]
++[[Size]]
++!!!Example
++
++
++
| !~DataType | !~DbType | !~TypeName |
++|com.sun.star.sdbc.~DataType.BIT | dbBoolean | BIT<br />BOOL |
++|com.sun.star.sdbc.~DataType.BOOLEAN | dbBoolean | BOOLEAN |
++|com.sun.star.sdbc.~DataType.TINYINT | dbInteger | TINYINT |
++|com.sun.star.sdbc.~DataType.SMALLINT | dbLong | SMALLINT |
++|com.sun.star.sdbc.~DataType.INTEGER | dbLong | INTEGER<br />INT<br />MEDIUMINT |
++|com.sun.star.sdbc.~DataType.BIGINT | dbBigInt | BIGINT |
++|com.sun.star.sdbc.~DataType.FLOAT | dbFloat | FLOAT<br />REAL |
++|com.sun.star.sdbc.~DataType.REAL | dbSingle | REAL |
++|com.sun.star.sdbc.~DataType.DOUBLE | dbDouble | DOUBLE<br />DOUBLE PRECISION<br />REAL |
++|com.sun.star.sdbc.~DataType.NUMERIC | dbNumeric | NUMERIC |
++|com.sun.star.sdbc.~DataType.DECIMAL | dbDecimal | DECIMAL |
++|com.sun.star.sdbc.~DataType.CHAR | dbChar | CHAR<br />CHARACTER |
++|com.sun.star.sdbc.~DataType.VARCHAR | dbText | VARCHAR<br />~VARCHAR_IGNORECASE<br />NVARCHAR<br />ENUM<br />SET |
++|com.sun.star.sdbc.~DataType.LONGVARCHAR | dbMemo | LONGVARCHAR<br />LONG VARCHAR<br />TEXT<br />TINY TEXT<br />MEDIUM TEXT<br />LONG TEXT |
++|com.sun.star.sdbc.~DataType.DATE | dbDate | DATE |
++|com.sun.star.sdbc.~DataType.TIME | dbTime | TIME |
++|com.sun.star.sdbc.~DataType.TIMESTAMP | dbTimeStamp | TIMESTAMP<br />DATETIME |
++|com.sun.star.sdbc.~DataType.BINARY | dbBinary | BINARY |
++|com.sun.star.sdbc.~DataType.VARBINARY | dbVarBinary | VARBINARY |
++|com.sun.star.sdbc.~DataType.LONGVARBINARY | dbLongBinary | LONGVARBINARY<br />LONG VARBINARY<br />BLOB<br />TINY BLOB<br />MEDIUM BLOB<br />LONG BLOB |
++|com.sun.star.sdbc.~DataType.CLOB | dbMemo | CLOB |
++|com.sun.star.sdbc.~DataType.BLOB | dbLongBinary | BLOB |
++
++
++
The //Fields// collection describes instances of all __[[fields|Field]]__ present either
++*in a [[table|TableDef]]
++*in a [[query|QueryDef]]
++*or in a [[recordset|Recordset]]
++!!!Syntax
++//table//{{{.Fields()}}}
++//table//{{{.Fields(}}}//index//{{{)}}}
++//table//{{{.Fields(}}}//fieldname//{{{)}}}
++//query//{{{.Fields()}}}
++//query//{{{.Fields(}}}//index//{{{)}}}
++//query//{{{.Fields(}}}//fieldname//{{{)}}}
++//recordset//{{{.Fields()}}}
++//recordset//{{{.Fields(}}}//index//{{{)}}}
++//recordset//{{{.Fields(}}}//fieldname//{{{)}}}
++| !Object | !Type | !Argument | !Type |!Returned value |
++|table | [[Table object|TableDef]] || absent |A [[Collection]] of the fields of the table |
++|~|~| index | integer<br />long |A [[field object|Field]] |
++|~|~| fieldname | string |~|
++|query | [[Query object|QueryDef]] || absent |A [[Collection]] of the fields of the query |
++|~|~| index | integer<br />long |A [[field object|Field]] |
++|~|~| fieldname | string |~|
++|recordset | [[Recordset object|Recordset]] || absent |A [[Collection]] of the fields of the recordset |
++|~|~| index | integer<br />long |A [[field object|Field]] |
++|~|~| fieldname | string |~|
++!!!Remarks
++*Field [[collections|Collection]] are numbered from 0 to {{{Fields().Count - 1}}}
++*The //fieldname// argument is not case sensitive.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection Fields() |
++|Field '...' not found |
++!!!Examples
++<<tiddler "DataType example">>
++
++
++
++
(Q) Is it possible to have some fields filled in automatically as soon as a certain value has been entered into another field?
++
++(R) A typical example of this is getting state and city name from Zipcodes. If you have a ~Zip-Code table, you'll never have to enter the State/City again.
++
++It is illustrated using next //Employees// table:
++<<tiddler "EmployeesTable">>
++Assume a form with a number of read-only fields corresponding with that table although __the form is not bound to the table__, then trigger next code in the //When losing focus// event of an editable field in which an employee id might be entered:
++//{{{
++Sub EmpFillAuto(poEvent As Object)
++
++Dim oEvent As Object, oEmpID As Object, sCrit As String
++Dim oParentForm As Object, oField As Object, vValue As Variant
++	Set oEvent = Events(poEvent)
++	oEmpID = oEvent.Source
++	sCrit = "[EmployeeID]=" & oEmpID.Value
++	Set oParentForm = oEmpID.Parent
++	With oParentForm
++		Set oField = .Controls("txtTitleOfCourtesy")
++		vValue = DLookup("[TitleOfCourtesy]", "[Employees]", sCrit)
++		If Not IsNull(vValue) Then oField.Value = vValue
++		Set oField = .Controls("txtFirstName")
++		vValue = DLookup("[FirstName]", "[Employees]", sCrit)
++		If Not IsNull(vValue) Then oField.Value = vValue
++		Set oField = .Controls("txtLastName")
++		vValue = DLookup("[LastName]", "[Employees]", sCrit)
++		If Not IsNull(vValue) Then oField.Value = vValue
++		Set oField = .Controls("txtAddress")
++		vValue = DLookup("[Address]", "[Employees]", sCrit)
++		If Not IsNull(vValue) Then oField.Value = vValue
++		Set oField = .Controls("txtCity")
++		vValue = DLookup("[City]", "[Employees]", sCrit)
++		If Not IsNull(vValue) Then oField.Value = vValue
++	End With
++	
++End Sub
++//}}}
++!!!See also
++[[Controls]]
++[[DLookup]]
++[[Events Handler]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~FillAuto |~Employees_FillAuto ||fmtEmployeeID|When losing focus ||
++
++
++
You can use the //Filter// property to
++*specify a subset of records to be displayed when a filter is applied to a [[form|Form]] or a [[subform|SubForm]]
++*set or return a value that determines the records included in a subsequently opened [[Recordset]] object (via [[OpenRecordset]])
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++|[[Recordset]] |The representation of a set of records from a table, a query or a SQL statement |
++!!!Syntax
++//form//{{{.Filter}}}
++//form//{{{.Filter = }}}//value//
++//subform//{{{.Filter}}}
++//subform//{{{.Filter = }}}//value//
++//recordset//{{{.Filter}}}
++//recordset//{{{.Filter = }}}//value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++The //Filter// property is a string expression consisting of a ''WHERE'' clause without the WHERE keyword. Like in //~MsAccess// __table names__, or __field names__ (e.g. when containing a space) may be surrounded by square brackets ([]).
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property 'Filter' |
++!!!See also
++[[FilterOn]]
++!!!Example
++<<tiddler "Filter example">>
++<<tiddler "Filter2 example">>
++
++
++
Set and apply a filter on a form
++//{{{
++Dim ofForm As Object, sFilter As String
++	Set ofForm = Forms("myForm")
++	sFilter = "[VAT CODE]=3 And [PRODUCT CODE]<'28000'"
++	ofForm.Filter = sFilter
++	ofForm.FilterOn = True
++//}}}
++
++
++
Set and apply a filter on a recordset derived from an existing recordset
++Count the records before and after filter application
++//{{{
++Dim oRecordset1 As Object, oRecordset2 As Object, sFilter As String
++	Set oRecordset1 = Application.CurrentDb().OpenRecordset("SELECT * FROM [PRODUCTS]")
++	sFilter = "[VAT CODE]=3 And [PRODUCT CODE]<'28000'"
++	oRecordset1.Filter = sFilter
++	oRecordset1.MoveLast
++	Print oRecordset1.RecordCount,
++	Set oRecordset2 = oRecordset1.OpenRecordset()	'	Filter is applied now
++	oRecordset2.MoveLast
++	Print oRecordset2.RecordCount,
++	Application.CurrentDb().CloseAllRecordsets()	'	Don't forget !!
++//}}}
++
++
++
Use the //~FilterOn// property to specify or determine whether the [[Filter]] property for a form is applied.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.FilterOn}}}
++//form//{{{.FilterOn = }}}//value//
++//subform//{{{.FilterOn}}}
++//subform//{{{.FilterOn = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++When a //Filter// is applied, the form is [[requeried|Requery]].
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~FilterOn' |
++!!!See also
++[[Filter]]
++[[Requery]]
++!!!Example
++<<tiddler "Filter example">>
++
++
++
The //Find// method finds a specified text in a standard or class [[module|Module]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.Find(}}}//target, startline, startcolumn, endline, endcolumn, wholeword, matchcase, patternsearch//{{{)}}}
++| !Argument | !Optional | !Type | !Description | !Returned value |
++|module || [[Module object|Module]] |The Basic script |If the string is found, the //Find// method returns {{{True}}}. |
++|target | N | String |The text that you want to find. |~|
++|startline | N | Long |The line on which to begin searching.<br />If a match is found, the value of the //startline// argument is set to the line on which the beginning character of the matching text is found. |~|
++|startcolumn | N | Long |The column on which to begin searching.<br />If a match is found, the value of the //startcolumn// argument is set to the column on which the beginning character of the matching text is found. |~|
++|endline | N | Long |The line on which to stop searching.<br />If a match is found, the value of the //endline// argument is set to the line on which the ending character of the matching text is found. |~|
++|endcolumn | N | Long |The column on which to stop searching.<br />If a match is found, the value of the //endcolumn// argument is set to the column on which the ending character of the matching text is found. |~|
++|wholeword | Y | Boolean |{{{True}}} results in a search for whole words only.<br />The default is {{{False}}}. |~|
++|matchcase | Y | Boolean |{{{True}}} results in a search for words with case matching the //target// argument.<br />The default is {{{False}}}. |~|
++|patternsearch | Y | Boolean |{{{True}}} results in a search in which the //target// argument may contain wildcard characters such as an asterisk (*) or a question mark (?).<br />The default is {{{False}}}. |~|
++!!!Remarks
++*To determine the position in the module at which the search text was found, pass ''empty variables'' to the //Find// method for the //startline//, //startcolumn//, //endline//, and //endcolumn// arguments.<br />If a match is found, these arguments will contain the line number and column position at which the search text begins (//startline//, //startcolumn//) and ends (//endline//, //endcolumn//).<br />For example, if the search text is found on line 15, begins at column 20, and ends at column 30, the values of these arguments will be:<br />{{{startline = 15, startcolumn = 20, endline = 15, endcolumn = 30}}}.
++*If the input arguments do not allow a fair search (f.i. //endline// < //startline//), then //Find// will return {{{False}}}.
++*To pass an empty value, do not initialize the argument or use the {{{Empty}}} LO/AOO Basic reserved word.
++//{{{
++Dim vStartLine As Variant
++	vStartLine = Empty
++//}}}
++!!!Error messages
++|Argument nr.1 (Value='...') is invalid |
++!!!See also
++[[Module]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~FindNext// action finds the next instance of data that meets the criteria specified by the arguments of the last invoked [[FindRecord]] action.
++If a match has been found, the cursor is set in the matching field. Otherwise it returns to the starting record.
++The starting record is NOT the record where the focus is on but the last record reached by the previous //~FindRecord// action.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]FindNext()}}}
++!!!Remarks
++*A previous //~FindRecord// action is mandatory. Otherwise the invocation of //~FindNext// will generate an error.
++*//~FindNext// returns //True// if a matching occurrence has been found.
++!!!Error messages
++|~FindNext() must be preceded by a successful ~FindRecord(...) call |
++!!!See also
++[[FindRecord]]
++!!!Example
++<<tiddler "FindRecord example">>
++
++
++
(Q) How do I find out from code if a form is open or not?
++
++(R) Pass the form name to the following function.  Function will return True if form is open and False if it's not.
++
++//{{{
++Function bIsLoaded(ByVal sFormName As String) As Boolean
++' sFormName is not case sensitive
++	bIsLoaded = AllForms(sFormName).IsLoaded
++End Function
++//}}}
++!!!See also
++[[AllForms]]
++[[IsLoaded]]
++
++
++
(Q) How do I find out from code if a table exists or not?
++
++(R) Pass the table name to the following function.  Function will return True if table exists or False otherwise.
++
++//{{{
++Function bTableExists(ByVal sTableName As String) As Boolean
++' sTableName is not case sensitive
++
++Dim i As Integer, oDefs As Object
++	bTableExists = False
++	Set oDefs = Application.CurrentDb.TableDefs
++	For i = 0 To oDefs.Count - 1
++		If UCase(oDefs.Item(i).Name) = UCase(sTableName) Then
++			bTableExists = True
++			Exit For
++		End If
++	Next i
++End Function
++//}}}
++!!!See also
++[[TableDefs]]
++[[Item]]
++
++
++
(Q) How do I find the current absolute and relative position in a recordset ?
++
++(R) The [[AbsolutePosition]] property returns the record number of the recordset. Associated with [[RecordCount]] the relative position can be derived.
++
++In some situations, you need to determine how far through a [[Recordset object|Recordset]] you have moved the current record position, and perhaps indicate the current record position to a user. For example, you may want to indicate the current position on a progress bar or similar type of control.
++
++The //~AbsolutePosition// property value is the position of the current record relative to 0. However, do not think of this property as a record number. There is no assurance that a record will have the same absolute position if the Recordset object is recreated because the order of individual records within a Recordset object is not guaranteed unless it is created with an SQL statement that includes an ORDER BY clause.
++
++We can compute the current relative position expressed as a percentage of the total number of records indicated by the //~RecordCount// property. Because the //~RecordCount// property does not reflect the total number of records in the //Recordset// object until the //Recordset// has been fully populated, we will use the [[MoveLast|Move (recordset)]] and [[MoveFirst|Move (recordset)]] methods immediately after opening the Recordset. This fully populates the //Recordset// object. If you have a large result set, using the //~MoveLast// method may take a long time.
++
++The following example opens a //Recordset// object on a table called Employees.
++<<tiddler "EmployeesTable">>
++The procedure then moves through the Employees table and uses the SysCmd method to display a progress bar showing the percentage of the table that has been processed.
++//{{{
++Sub DisplayPosition()
++
++Dim odbNorthwind As Object
++Dim orsEmployees As Object
++Dim sMsg As String
++Dim lCount As Long
++Dim sSQL As String
++Dim dPercent As Double
++ 
++On Local Error GoTo ErrorHandler 
++ 
++	Set odbNorthwind = Application.CurrentDb 
++
++	sSQL = "SELECT * FROM Employees"
++	Set orsEmployees = odbNorthwind.OpenRecordset(sSQL, , , dbReadOnly)
++
++	With orsEmployees
++		If .EOF Then            '	If no records, exit
++			Exit Sub
++		Else
++			sMsg = "Processing Employees table..."
++			DoCmd.SysCmd(acSysCmdInitMeter, sMsg, 100)
++			.MoveLast			'	Determine number of records
++			lCount = .RecordCount
++			.MoveFirst
++		End If
++		Do Until .EOF
++'
++'			Any processing ...
++'
++			Wait 100		'	just to see what happens ...
++			dPercent = .AbsolutePosition / lCount
++			If dPercent <> 0 Then DoCmd.SysCmd(acSysCmdUpdateMeter, sMsg, Int(100*dPercent))
++			.MoveNext
++		Loop
++	End With 
++	MsgBox "Processing ended"
++	DoCmd.SysCmd(acSysCmdRemoveMeter)
++
++	orsEmployees.mClose
++	Set orsEmployees = Nothing
++	Set odbNorthwind = Nothing
++
++Exit Sub
++ 
++ErrorHandler: 
++	TraceError("ERROR", Err, "DisplayPosition", Erl)
++End Sub
++//}}}
++!!!See also
++[[OpenRecordset]]
++[[SysCmd]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~DisplayPosition ||
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~FindRecord// action finds the first instance of data that meets the criteria specified by the //~FindRecord// arguments. This can be in a succeeding or prior record, or in the first record. The search is done in a single column or in all columns of a __form__ (or __subform__)'s [[GridControl]].
++If a match has been found, the cursor is set in the matching field.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]FindRecord(FindWhat,}}}//{{{ Match, MatchCase, Search, SearchAsFormatted, OnlyCurrentField, FindFirst}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{FindWhat}}} | No | String<br />Date<br />Number |Specifies the data you want to find in the record. Enter the text, number, or date you want to find. |
++|{{{Match}}} | Yes | acAnyWhere<br />acEntire<br />acStart |Specifies where the data is located in the field. You can specify a search for data in any part of the field (acAnyWhere), for data that fills the entire field (acEntire), or for data located at the beginning of the field (acStart). Obviously this argument is meaningful only if //~FindWhat// is a string.<br />The default is acEntire. |
++|{{{MatchCase}}} |~| Boolean |Specifies whether the search is case-sensitive (uppercase and lowercase letters must match exactly). The default is False. |
++|{{{Search}}} |~| acDown<br />acSearchAll<br />acUp |Specifies whether the search proceeds from the current record up to the beginning of the records (acUp); down to the end of the records (acDown); or down to the end of the records and then from the beginning of the records to the current record, so all records are searched (acSearchAll). The default is acSearchAll. |
++|{{{SearchAsFormatted}}} |~| Boolean |If present, must be FALSE. True is not supported. |
++|{{{OnlyCurrentField}}} |~| acAll<br />acCurrent |Specifies whether the search is confined to the current field in each record (acCurrent) or includes all fields in each record (acAll). The default is acCurrent. |
++|~|~| String |The argument must contain a [[shortcut|ShortCut Notation]] to a GridControl or to a column of a [[GridControl]]. If the shortcut points to a ~GridControl all the columns are scanned to find a match. |
++|{{{FindFirst}}} |~| Boolean |Specifies whether the search starts at the first or last record (depending on the //Search// argument) or at the current record. The default is True. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acAnywhere = 0
++Const acEntire = 1
++Const acStart = 2
++Const acDown = 1
++Const acSearchAll = 2
++Const acUp = 0
++Const acAll = 0
++Const acCurrent = -1
++//}}}
++!!!Remarks
++*The //~FindRecord// action is most often started from an event. Clicking on a button in a form triggering the event might change the focus from the current field to the button which is not the desired effect. In that case use the [[SetFocus]] method, either on the //form// or on the targeted //control//, before executing the //~FindRecord// statement.
++*The targeted //form// or //subform// MUST contain a //gridcontrol//.
++*The //~FindRecord// action is a function. It returns //True// if a match ha been found, and //False// otherwise.
++*Using a shortcut (i.e. a string ...) as {{{OnlyCurrentField}}} argument is the __only__ way to run a //~FindRecord// action in a //~GridControl// belonging to a //~SubForm//.
++*Using a shortcut (i.e. a string ...) as {{{OnlyCurrentField}}} argument is the __recommended__ way to run a //~FindRecord// action in one of the [[forms|Standalone Forms]] defined in a //non-Base// document.It is the __only__ way if more than 1 form is contained in such a //non-Base// document.
++!!!Error messages
++|No active form or control found |
++|Form '...' has no underlying dataset |
++|Control '...' not found in gridcontrol '...' |
++|No gridcontrol found in form '...' |
++!!!See also
++[[FindNext]]
++[[SetFocus]]
++!!!Example
++<<tiddler "FindRecord example">>
++
++
++
Find the record starting from the top having the value "3" in one of the numeric columns:
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	ofForm.SetFocus()
++	If Not FindRecord(3, , , , , acAll) Then MsgBox "Not Found !"
++//}}}
++Next statement will retrieve the next occurrence:
++//{{{
++	FindNext()	'	Parentheses are optional
++//}}}
++
++
++
Change control aspect
++//{{{
++Dim ofForm As Object, ocControl As Object
++	Set ofForm = Forms("myForm")
++	Set ocControl =ofForm.Controls("myControl")
++	If ofForm.Controls("myChkBox").Value = 1 Then
++		ocControl.FontName = "Verdana"
++		ocControl.FontSize = 18
++		ocControl.FontBold = True
++		ocControl.FontItalic = True
++		ocControl.FontUnderline = True
++		ocControl.ForeColor = RGB(255, 0, 0)
++		ocControl.TextAlign = 2
++	End If
++//}}}
++... or alternatively ...
++//{{{
++Dim ofForm As Object, ocControl As Object
++	Set ofForm = Forms("myForm")
++	Set ocControl =ofForm.Controls("myControl")
++	If ofForm.Controls("myChkBox").Value = 1 Then
++		ocControl.FontName = "Verdana"
++		ocControl.FontSize = 18
++		ocControl.FontWeight = com.sun.star.awt.FontWeight.ULTRABOLD	'	alternative to Bold property
++		ocControl.FontItalic = True
++		ocControl.FontUnderline = True
++		ocControl.ForeColor = RGB(255, 0, 0)
++		ocControl.TextAlign = 2
++	End If
++//}}}
++
++
++
The //~FontBold// property specifies whether a font appears in a bold style in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontBold}}}
++//control//{{{.FontBold = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The //~FontBold// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontBold' not applicable in this context |
++|Value '...' is invalid for property '~FontBold' |
++!!!See also
++[[FontItalic]]
++[[FontName]]
++[[FontSize]]
++[[FontUnderline]]
++[[FontWeight]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~FontItalic// property specifies whether text appears in italic in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontItalic}}}
++//control//{{{.FontItalic = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The //~FontItalic// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontItalic' not applicable in this context |
++|Value '...' is invalid for property '~FontItalic' |
++!!!See also
++[[FontBold]]
++[[FontName]]
++[[FontSize]]
++[[FontUnderline]]
++[[FontWeight]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~FontName// property specifies the name of the font used to display a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontName}}}
++//control//{{{.FontName = }}}//value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++The //~FontName// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontName' not applicable in this context |
++|Value '...' is invalid for property '~FontName' |
++!!!See also
++[[FontBold]]
++[[FontItalic]]
++[[FontSize]]
++[[FontUnderline]]
++[[FontWeight]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~FontSize// property specifies the size of the font used to display a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontSize}}}
++//control//{{{.FontSize = }}}//value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++The //~FontSize// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontSize' not applicable in this context |
++|Value '...' is invalid for property '~FontSize' |
++!!!See also
++[[FontBold]]
++[[FontItalic]]
++[[FontName]]
++[[FontUnderline]]
++[[FontWeight]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~FontUnderline// property specifies whether text is underlined in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontUnderline}}}
++//control//{{{.FontUnderline = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The //~FontUnderline// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontUnderline' not applicable in this context |
++|Value '...' is invalid for property '~FontUnderline' |
++!!!See also
++[[FontBold]]
++[[FontItalic]]
++[[FontName]]
++[[FontSize]]
++[[FontWeight]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~FontWeight// property specifies the line width used to display characters in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.FontWeight}}}
++//control//{{{.FontWeight = }}}//value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++*Allowed values for //~FontWeight// are:
++| Symbolic name || Numeric value |
++|com.sun.star.awt.~FontWeight.DONTKNOW |The font weight is not specified/known. | 0 |
++|com.sun.star.awt.~FontWeight.THIN |specifies a 50% font weight. | 50 |
++|com.sun.star.awt.~FontWeight.ULTRALIGHT |specifies a 60% font weight. | 60 |
++|com.sun.star.awt.~FontWeight.LIGHT |specifies a 75% font weight. | 75 |
++|com.sun.star.awt.~FontWeight.SEMILIGHT |specifies a 90% font weight. | 90 |
++|com.sun.star.awt.~FontWeight.NORMAL |specifies a normal font weight. | 100 |
++|com.sun.star.awt.~FontWeight.SEMIBOLD |specifies a 110% font weight. | 110 |
++|com.sun.star.awt.~FontWeight.BOLD |specifies a 150% font weight. | 150 |
++|com.sun.star.awt.~FontWeight.ULTRABOLD |specifies a 175% font weight. | 175 |
++|com.sun.star.awt.~FontWeight.BLACK |specifies a 200% font weight.| 200 |
++*The //~FontWeight// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~FontWeight' not applicable in this context |
++|Value '...' is invalid for property '~FontWeight' |
++!!!See also
++[[FontBold]]
++[[FontItalic]]
++[[FontName]]
++[[FontSize]]
++[[FontUnderline]]
++[[ForeColor]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
The //~ForeColor// property specifies or determines the color (RGB) of the text in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~HiddenControl<br />~ImageButton<br />~ImageControl<br />~ScrollBar<br />~SpinButton<br />[[SubForm]]-- | None |All except<br />--~ImageControl<br />~ProgressBar<br />~ScrollBar<br />--  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.ForeColor}}}
++//control//{{{.ForeColor = }}}//value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++The //~ForeColor// property can be set at [[grid control|GridControl]] level, not at its individual //controls// level.
++!!!Error messages
++|Property '~ForeColor' not applicable in this context |
++|Value '...' is invalid for property '~ForeColor' |
++!!!See also
++[[BackColor]]
++[[BorderColor]]
++[[BorderStyle]]
++[[FontBold]]
++[[FontItalic]]
++[[FontName]]
++[[FontSize]]
++[[FontUnderline]]
++[[FontWeight]]
++[[TextAlign]]
++!!!Example
++<<tiddler "Color example">>
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Form// object describes
++*either one of the Forms located in a Base document (".odb" file),
++*or one of the forms contained in a non-Base (Writer, Calc, ...) document.
++The form can be either opened or closed. If the property [[IsLoaded]] returns //True// then the form is opened.
++!!!Functions returning a form object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Application]] |[[AllForms]] | [[Collection]] | Integer or String |{{{Application.AllForms("myForm")}}} returns an object corresponding with the {{{myForm}}} form |
++|~|[[Forms]] | [[Collection]] | Integer or String |{{{Application.Forms("myForm")}}} returns an object corresponding with the {{{myForm}}} form. {{{myForm}}} must be open. |
++||[[getObject]] || String |{{{getObject("Forms!myForm")}}} returns an object corresponding with the {{{myForm}}} form. {{{myForm}}} must be open. |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[AllowAdditions]] |||Specifies whether a user can add a record when using the form. |
++|[[AllowDeletions]] |||Specifies whether a user can delete a record when using the form. |
++|[[AllowEdits]] |||Specifies whether a user can modify a record when using the form. |
++|[[Bookmark]] |||specifies uniquely the current record of the form's underlying table, query or SQL statement. |
++|[[Caption]] |||Specifies the text that appears in the title bar. |
++|[[CurrentRecord]] |||Identifies the current record in the recordset being viewed on a form. |
++|[[Filter]] |||Specifies a subset of records to be displayed. |
++|[[FilterOn]] |||Specifies if the Filter has to be applied. |
++|[[Height]] |||Specifies the height of the form. |
++|[[IsLoaded]] || Y |True if form is open. |
++|[[Name]] || Y |Specifies the real and full (including its path, if any) name of the form |
++|[[ObjectType]] || Y |Returns "FORM" |
++|[[On form events|On (form event)]]|||Specifies the Basic macro executed when an event is triggered. |
++|[[OpenArgs]] || Y |Specifies the ~OpenArgs argument of an [[OpenForm]] action. |
++|[[OrderBy]] |||Specifies in which order the records should be displayed. |
++|[[OrderByOn]] |||Specifies if the ~OrderBy has to be applied. |
++|[[RecordSource]] |||Specifies the source of the data. |
++|[[Visible]] |||Shows or hides the form. |
++|[[Width]] |||Specifies the width of the form. |
++|Component | UNO | Y |com.sun.star.text.~TextDocument |
++|~ContainerWindow | UNO | Y ||
++|~DatabaseForm | UNO | Y |com.sun.star.form.component.~DataForm<br />com.sun.star.sdb.~ResultSet |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[Close|Close (method)]] | None | Boolean |Close the form. Always returns {{{True}}}. |
++|[[CurrentDb]] | None | Object |Return the [[database|Database]] object related to the [[standalone|Standalone Forms]] form, or {{{Nothing}}}. |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Form has the given property. |
++|[[Move]] | coordinates |~|Return True if Form has been moved successfully. |
++|[[Refresh]] | None |~|Refresh data with its most recent value in the database. |
++|[[Requery]] |~|~|Refresh the data displayed in the Form. |
++|[[SetFocus]] |~|~|Return True if focus set on Form successfully. |
++|[[setProperty]] | value<br />property |~|Return True if the given property could be set. |
++!!!Remarks
++Each //Form// [[object|Object Model]] has a Controls [[collection|Collection]] method, which contains all controls on the form. You can refer to a specific control on a form by referring to the [[Controls]] collection. 
++!!!Examples
++<<tiddler "Forms examples">>
++
++
++
The //Form// property refers to the //Form// associated with a [[subform control|SubForm]].
++!!!Applies to ...
++| !Pseudo object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | ~SubForm | None |A control on an open form representing a subset (subform) of the form |
++!!!Syntax
++//control//{{{.Form}}}
++!!!Returned values
++An object of type [[SubForm]]
++!!!Remarks
++The //Form// property is read-only.
++!!!Error messages
++| Property 'Form' not applicable in this context |
++!!!See also
++The [[SubForm]] object
++!!!Example
++<<tiddler "Subform example">>
++
++
++
The //Format// property determines the way data is displayed in controls of type date, time or formattedfield.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | ~DateField<br />~FormattedField<br />~TimeField | ~DateField<br />~FormattedField<br />~TimeField |A control on an open form or within a [[GridControl]] of one of the listed types |
++!!!Syntax
++//control//{{{.Format}}}
++//control//{{{.Format}}} = //value//
++!!!Returned values/Arguments
++{{{String}}}
++
++Valid values for ''__datefield controls__'' are :
++|Standard (short) |
++|Standard (short YY) |
++|Standard (short YYYY) |
++|Standard (long) |
++|DD/MM/YY |
++|MM/DD/YY |
++|YY/MM/DD |
++|DD/MM/YYYY |
++|MM/DD/YYYY |
++|YYYY/MM/DD |
++|~YY-MM-DD |
++|~YYYY-MM-DD |
++
++Valid values for ''__timefield controls__'' are :
++|24h short |13:45 |
++|24h long |13:45:00 |
++|12h short |01:45 PM |
++|12h long |01:45:00 PM |
++
++Other values are rejected.
++!!!Remarks
++The //Format// property is read-only for controls of type //~FormattedField//.
++!!!Error messages
++|Property 'Format' not applicable in this context |
++|Value '...' is invalid for property 'Format' |
++!!!Examples
++<<tiddler "Format example">>
++
++
++
Display the format of a formatted field
++//{{{
++Dim ocControl As Object
++	Set ocControl = Controls("myForm", "myFormattedField")
++	MsgBox ocControl.Format
++//}}}
++Change the format of a date field
++//{{{
++Dim ocControl As Object
++	Set ocControl = Controls("myForm", "myDateField")	
++	ocControl.Format = "YYYY-MM-DD"
++//}}}
++
++
++
The //Forms// [[collection|Collection]] describes instances of all __open forms__ present in the current Base document (".odb" file) or in the current non-Base document (".odt", ".ods", ... file) containing one or more [[standalone forms|Standalone Forms]].
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]Forms()}}} or {{{Forms()}}}
++{{{[Application.]Forms(index)}}}
++{{{[Application.]Forms(formname)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[Form]] object corresponding to the index-th item in the Forms() collection. The 1st form is Forms(0), the 2nd is Forms(1) and so on ... The last one is Forms.Count - 1.|
++| formname | string |A [[Form]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*~Access2Base supports hierarchical form names exactly like Base does it. The //formname// argument must contain the full pathname of the designated form.
++*You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection. If you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change. The Forms collection is indexed beginning with zero. If you refer to a form by its index, the first form opened is Forms(0), the second form opened is Forms(1), and so on. If you opened Form1 and then opened Form2, Form2 would be referenced in the Forms collection by its index as Forms(1). If you then closed Form1, Form2 would be referenced in the Forms collection by its index as Forms(0).
++*The //formname// argument is not case sensitive.
++*The returned Form object is always a main form.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection Forms() |
++|Form '...' not found |
++|Form '...' is currently not open|
++!!!See also ...
++[[AllForms]]
++!!!Examples
++<<tiddler "Forms examples">>
++
++
++
To display the name of all open forms (uses the [[Name]] property):
++//{{{
++Dim i As Integer, oCollection As Object
++	Set oCollection = Application.Forms()
++	For i = 0 To oCollection.Count - 1		'Forms without argument returns a Collection object
++		Print Application.Forms(i).Name,	'Forms(...) with an argument returns a Form object
++	Next i
++	Print
++//}}}
++Can shorter ... :
++//{{{
++Dim i As Integer
++	For i = 0 To Application.Forms.Count - 1	'Forms without argument returns a Collection object
++		Print Application.Forms(i).Name,	'Forms(...) with an argument returns a Form object
++	Next i
++	Print
++//}}}
++To know the size of an open form:
++//{{{
++Dim ofForm As Object
++	Set ofForm = Application.Forms("myForm")
++	MsgBox "Height = " & ofForm.Height & ", Width = " & ofForm.Width
++//}}}
++
++
++
<<list>>
++
++
++
The //~GetChunk// method returns all or a portion of the content of a binary [[Field]] belonging to the [[Fields]] collection of a [[Recordset]].
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.~DataType.BINARY<br />com.sun.star.sdbc.~DataType.VARBINARY<br />com.sun.star.sdbc.~DataType.LONGVARBINARY |
++!!!Syntax
++//chunk// = //field//{{{.GetChunk(}}}//offset, numbytes//{{{)}}}
++!!!Arguments
++| !Argument / Return value | !Type | !Description |
++|chunk | Variant |An array of integers. Its size is determined by the //numbytes// argument or by the number of remaining bytes to read, whichever is the smallest.<br />If the field contains {{{Null}}}, //~GetChunk// will return {{{Null}}} (to be tested with the {{{IsNull()}}} Basic builtin function). |
++|offset | Long |The number of bytes to skip before copying begins. |
++|numbytes | Long |The number of bytes you want to return. |
++!!!Remarks
++*Use //~GetChunk// to return a portion of the total data value at a time. You can use the [[AppendChunk]] method to reassemble the pieces. 
++*If offset is 0, //~GetChunk// begins copying from the first byte of the field. 
++*If numbytes is greater than the number of bytes in the field, //~GetChunk// returns the actual number of remaining bytes in the field. 
++!!!Error messages
++|Method '~GetChunk' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[AppendChunk]]
++[[ReadAllBytes]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "Chunk example">>
++
++
++
The //~GetHiddenAttribute// property specifies if a named window is currently hidden or visible.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]GetHiddenAttribute(}}}//{{{ObjectType, ObjectName}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{ObjectType}}} | No | acTable<br />acQuery<br />acForm<br />acReport<br />acDiagram (i.e. Relationships)<br />acBasicIDE<br />acDatabaseWindow<br />acDocument |The type of object to hide or to show. |
++|{{{ObjectName}}} | Yes | String |The name of the object. This argument is NOT case-sensitive.<br />The argument is mandatory when the //~ObjectType// argument is one of next values: //acTable//, //acQuery//, //acForm//, //acReport// or //acDocument//.<br />When the //~ObjectType// is equal to //acDocument//, the //~ObjectName// argument must contain the __filename__ of the targeted window. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acDiagram = 8
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++
++Const acBasicIDE = 101
++Const acDatabaseWindow = 102
++Const acDocument = 111
++//}}}
++!!!Returned values
++{{{Boolean}}}
++!!!Remarks
++*In //~MSAccess// the //~GetHiddenAttribute// property is related to the [[Application]] root object, not to the [[DoCmd]] one.
++*When the //~ObjectType// is {{{acTable}}}, {{{acQuery}}}, {{{acForm}}} or {{{acReport}}}, the named object MUST be open.
++!!!Error messages
++|Arguments are missing or are not initialized |
++|Argument nr. ... [Value = '...'] is invalid |
++|Object '...' not found |
++!!!See also
++[[Maximize]]
++[[Minimize]]
++[[MoveSize]]
++[[RunCommand]]
++[[SetFocus]]
++[[SelectObject]]
++[[SetHiddenAttribute]]
++!!!Example
++<<tiddler "SetHiddenAttribute example">>
++
++
++
The //~GetRows// method retrieves multiple rows from a [[Recordset]] object. 
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or a SQL statement. |
++!!!Syntax
++//recordset//{{{.GetRows(}}}//numrows//{{{)}}}
++| !Argument | !Optional | !Type | !Description | !Returned value |
++|recordset || [[Recordset object|Recordset]] |An open recordset |//~GetRows// returns a two-dimensional array. The first subscript identifies the field and the second identifies the row number. |
++|numrows | N | Long |Specifies the maximum number of rows to retrieve. |~|
++!!!Remarks
++//~GetRows// returns a two-dimensional zero-based array.
++For example, to get the first field value in the second row returned, use code like the following:
++//{{{
++Dim vVarRecords() As Variant, oRecordset As Object, vField1 As Variant
++	Set oRecordset = ... OpenRecordset(...)
++	Set vVarRecords = oRecordset.GetRows(1000)
++	vField1 = vVarRecords(0, 1).
++//}}}
++To get the second field value in the first row, use code like the following:
++//{{{
++Dim vField2 As Variant
++	vField2 = vVarRecords(1, 0)
++//}}}
++The {{{vVarRecords}}} variable automatically becomes a two-dimensional array when //~GetRows// returns data. Otherwise //~GetRows// will return an uninitialized array (i.e. the output of the Basic builtin {{{Array()}}} function).
++Each element of the returned array will be of the Basic type most close to the [[DataType]] of the original database field.
++A {{{Null}}} field value in the database will be returned as a {{{Null}}} value in the array resulting from the invocation of //~GetRows//. To be evaluated with the {{{IsNull()}}} Basic builtin function.
++
++If you request more rows than are available, then //~GetRows// returns only the number of available rows. You can use the Basic {{{UBound}}} function to determine how many rows //~GetRows// actually retrieved, because the array is sized to fit the number of returned rows.
++For example, you could use the following code to determine how many rows were actually returned:
++//{{{
++	numReturned = UBound(vVarRecords, 2) + 1
++//}}}
++You need to use "+ 1" because the first row returned is in the 0th element of the array. The number of rows that you can retrieve is constrained by the amount of available memory. You shouldn't use //~GetRows// to retrieve an entire table into an array if it is large.
++Because GetRows returns all fields of the //Recordset// into the array, including Memo fields, you might want to use a query that restricts the fields returned.
++
++Binary fields are not returned. Instead the corresponding element in the array returned by //~GetRows// contains the //length// of the field.
++
++After you call //~GetRows//, the current record is positioned at the next unread row. That is, //~GetRows// has the same effect on the current record as {{{recordset.Move(numrows)}}}. 
++If you are trying to retrieve all the rows by using multiple //~GetRows// calls, use the [[EOF|BOF, EOF]] property to be sure that you're at the end of the //Recordset//. //~GetRows// returns less than the number requested if it's at the end of the //Recordset//.
++
++Calling //~GetRows// cancels all not confirmed updates on the //recordset//.
++!!!Error messages
++|Argument nr.1 (Value='...') is invalid |
++|Recordset has been closed. Recordset action rejected |
++!!!See also
++[[BOF, EOF]]
++[[Move (recordset)]]
++[[OpenRecordset]]
++!!!Example
++<<tiddler "GetRows example">>
++
++
++
Create a new recordset, extract the data in blocks of 50 records
++//{{{
++Const dbReadOnly = 4
++Const cstNumRecs = 50
++Dim orsRecords As Object, vDataBlock() As Variant
++	Set orsRecords = Application.CurrentDb().OpenRecordset("EXPENSES", , , dbReadOnly)
++	With orsRecords
++		Do While Not .EOF()
++			Set vDataBlock = .GetRows(cstNumRecs)
++			'	... process data block ...
++			'	vDataBlock(i, j) = value in (i + 1)th field of (j + 1)th record
++		Loop
++		.mClose()
++	End With
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~GoToControl// action moves the focus to the named control in the active window. The active window is assumed to be a form.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]GoToControl(}}}//{{{ControlName}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{ControlName}}} | No | String |The name of the control to move the focus to. This argument is NOT case-sensitive. |
++!!!Remarks
++*If
++**the active window is not a form belonging to a Base document (".odb" suffix),
++**or if the active window is indeed a form but no control is found with the given ~ControlName,
++**or if such a control is found but it is not enabled,
++{{indent{then the ~GoToControl request is ignored.
++*You can also use the [[SetFocus]] method to move the focus to a control on a form or any of its subforms. This is the preferred method for moving the focus, especially to controls on subforms and nested subforms.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++!!!See also
++[[SetFocus]]
++!!!Example
++//{{{
++	SelectObject(acForm, "myForm")
++	GoToControl("myControl")
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~GoToRecord// action makes the specified record the current record in an open form, a table or a query datasheet.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]GoToRecord(}}}//{{{ObjectType, ObjectName, Record, Offset}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{ObjectType}}} | Yes | acActiveDataObject<br />acDataForm<br />acDataTable<br />acDataQuery |The type of object that contains the record you want to make current. Leave this argument blank to select the active window. |
++|{{{ObjectName}}} |~| String |The name of the object that contains the record you want to make the current record. If you leave the Object Type argument blank, leave this argument blank also.<br />This argument may also contain a [[shortcut|ShortCut Notation]] to a [[Form]] or a [[SubForm]]. |
++|{{{Record}}} |~| acFirst<br />acGoTo<br />acLast<br />acNewRec<br />acNext<br/>acPrevious |Specifies the record to make the current record. The default is //acNext//. |
++|{{{Offset}}} |~| Integer<br />Long |This argument specifies the record to make the current record. You can use the Offset argument in two ways:<br />- When the Record argument is //acNext// or //acPrevious//, the cursor moves the number of records forward or backward specified in the Offset argument.<br />- When the Record argument is //acGoTo//, the cursor moves to the record with the number equal to the Offset argument. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acActiveDataObject = -1
++Const acDataTable = 0
++Const acDataQuery = 1
++Const acDataForm = 2
++
++Const acFirst = 2
++Const acGoTo = 4
++Const acLast = 3
++Const acNewRec = 5
++Const acNext = 1
++Const acPrevious = 0
++//}}}
++!!!Remarks
++*If the targeted window (= combination of //~ObjectType// and //~ObjectName//) does not exist or is not open then the //~GoToRecord// action request is ignored.
++*The //~GoToRecord// action is most often started from an event. Clicking on a button in a form triggering the event might change the focus from the current form to the form containing the button. This could not be the desired effect. In that case use the [[SetFocus]] method on the targeted //form// or alternatively the [[SelectObject]] action, before executing the //~GoToRecord// statement.
++*The //~GoToRecord// action, when applied to a table or a query datasheet, __does NOT work in //~OpenOffice//__ (//~LibreOffice// OK).
++*When run from a //non-Base// document containing several forms, the first argument must be equal to {{{acDataForm}}} and the second one must be  a {{{string}}} containing either the name of the targeted form or a [[shortcut|ShortCut Notation]] to it.
++*An attempt to position the cursor beyond the first/last row in the result set leaves the cursor before/after the first/last row, respectively.
++*If {{{Record}}} = //acGoTo// then:
++**If the {{{Offset}}} is positive, the cursor moves to the given row number with respect to the beginning of the result set. The first row is row 1, the second is row 2, and so on.
++**If the given {{{Offset}}} is negative, the cursor moves to an absolute row position with respect to the end of the result set. For example, {{{Offset}}} = (-1) positions the cursor on the last row, {{{Offset}}} = (-2) indicates the next-to-last row, and so on.
++*Before moving to the indicated record, the current record is saved if it was either being created or being updated.
++*//~GoToRecord// returns {{{True}}} if the move was successful, {{{False}}} otherwise.
++!!!Error messages
++|Argument nr.X [Value = '...'] is invalid|
++!!!See also
++[[Bookmark]]
++[[OpenTable]]
++[[OpenQuery]]
++[[SelectObject]]
++[[SetFocus]]
++!!!Example
++<<tiddler "GoToRecord example">>
++
++
++
Jump to the 5th record before the last one
++//{{{
++Const acDataForm = 2
++	GoToRecord acDataForm, "myForm", acLast
++	GoToRecord acDataForm, "myForm", acPrevious, 5
++//}}}
++Jump to the last record of a table datasheet
++//{{{
++Const acDataTable = 0
++	GotoRecord acDataTable, "ARTICLE", acLast
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~GridControl// [[control|Control]] presents the records of a table or query in a tabular form.
++!!!Functions returning a ~GridControl control
++| !Function | !Type | !Arguments |!Description |
++|[[Controls]] | [[Collection]] | Integer<br />String |{{{Dim ofForm As Object}}}<br />{{{Set ofForm = Forms("myForm")}}}<br />{{{ofForm.Controls("myGridControl")}}} returns a control object corresponding with the {{{myGridControl}}} control in the {{{myForm}}} form. {{{myForm}}} must be open. |
++|[[getObject]] || String |{{{getObject("Forms!myForm!myGridControl")}}} returns a control object corresponding with the {{{myGridControl}}} control in the {{{myForm}}} form. {{{myForm}}} must be open. |
++!!!Properties
++| !Property | !Type | !Read only |!Description or UNO object |
++|[[Name]] || Y |Specifies the exact name of the control |
++|BackColor |||Specifies the color of the interior of a control. |
++|BorderColor |||Specifies the color of a control's border. |
++|BorderStyle |||Specifies how a control's border appears. |
++|[[ControlTipText]] |||Specifies the text that appears in a ~ScreenTip when you hold the mouse pointer over a control. |
++|[[ControlType]] || Y |Specifies the type of a control. |
++|[[Enabled]] |||Specifies if the cursor can access the control. |
++|[[FontBold]]<br />[[FontItalic]]<br />[[FontName]]<br />[[FontSize]]<br />[[FontUnderline]]<br />[[FontWeight]]<br />[[ForeColor]] |||Specify the font characteristics of all the columns of the grid. |
++|[[TabIndex]] |||Specifies a control's place in the tab order on a form. |
++|[[TabStop]] |||Specifies whether you can use the TAB key to move the focus to a control. |
++|[[Tag]] |||Stores extra information about a control. |
++|[[Visible]] |||Specifies if a control is visible or hidden. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~GridControl has the given property. |
++|[[Requery]] ||~|True if data reloaded in the ~GridControl |
++|[[SetFocus]] | none |~|Return True if focus set on Control successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++Each //~GridControl// [[control object|Object Model]] has a Controls [[collection|Collection]], which contains all controls on the gridcontrol. You can refer to a specific control on a gridcontrol by referring to its [[Controls]] collection. 
++!!!Example
++<<tiddler "Gridcontrol examples">>
++
++
++
Change font properties for ALL fields in a gridcontrol
++//{{{
++Dim ocGrid As Object
++	Set ocGrid = Forms("myForm").Controls("myGridControl")
++	ocGrid.FontBold = True
++//}}}
++To know the controls present in a gridcontrol (datagrid)
++//{{{
++Dim i As Integer, iCountGrid As Integer
++	iCountGrid = ocGrid.Controls().Count
++	For i = 0 To iCountGrid - 1
++		Print ocGrid.Controls(i).Name,
++	Next i
++	Print
++//}}}
++
++
++
The //Height// property specifies the height of a form or a dialog.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[Dialog]] |An active dialog |
++!!!Syntax
++//form//{{{.Height}}}
++//form//{{{.Height = }}}//value//
++//dialog//{{{.Height}}}
++//dialog//{{{.Height = }}}//value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++!!!Error messages
++|Form '...' is currently not open|
++|Dialog '...' not active |
++|Value '...' is invalid for property 'Height' |
++!!!See also
++[[Maximize]]
++[[Minimize]]
++[[Move]]
++[[Width]]
++!!!Example
++<<tiddler "Height & Width example">>
++
++
++
Modify height and width of a form
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	ofForm.Height = 300
++	ofForm.Width = 200
++//}}}
++
++
++
!NEW
++
++Read about ''[[BASEDOCUMENTER|http://www.access2base.com/basedocumenter]]'': a new ~LibreOffice __extension__ for producing a __HTML documentation__ of Base applications.
++~BaseDocumenter is based on the ~Access2Base library.
++!What is __~Access2Base__ ?
++
++{{firstletter{
++ @@color:#930;A@@
++ }}}''ccess2Base'' is a ~LibreOffice/~OpenOffice Basic library of macros for (business or personal) __application developers__ and __advanced users__.
++Their syntax and their meaning are directly inspired by //~MSAccess//. The macros are callable from
++*a ''~LibreOffice / ~OpenOffice Base'' application,
++*any ''~LibreOffice / ~OpenOffice document'' wanting to access data stored in databases.
++
++It is intended first to support people having a knowledge of ~MSAccess and willing to step over to a similar but free software, i.e. //~LibreOffice/~OpenOffice Base//.
++It is also useful for users having already a practical knowledge of ~LibreOffice/~OpenOffice (Base or other ...) and wanting to start building applications with it, while remaining focussed on the application or business logic only.
++
++//It is also recommended to people having tried to program in AOO/~LibO Basic with the standard ~LibreOffice/~OpenOffice UNO API and having given it up ...//
++
++The ''~Access2Base API'' is ''much more concise, intuitive, easy to learn'' and ''easy to use'' than the standard UNO API (API = Application Programming Interface).
++
++''
++~Access2Base is provided either
++>- __pre-installed as a standard feature in all versions of //~LibreOffice// since //~LibO version 4.2//__
++>- as an __extension__ downloadable from the //~LibreOffice// (versions <= 4.1) or //~OpenOffice// (all versions) download centers.
++The current and future versions of ~Access2Base (6.2.0) will be delivered only as a part of ~LibreOffice (>= 6.2).
++See the [[getting started instructions|Install]] for more details.
++''
++
++The implemented macros include:
++>1. a simplified and extensible ''__API__'' for [[forms|Forms]], [[dialogs|Dialog]] and [[controls|Controls]] manipulations similar with the ''//~MSAccess// object model''
++>2. an API for database access with the [[table|TableDef]], [[query|QueryDef]], [[recordset|Recordset]] and [[field|Field]] objects, aligned with the ''//DAO (Microsoft Data Access Object)// object model''
++>3. a number of actions with a syntax identical to their corresponding //~MSAccess// macros/actions including [[FindRecord]], [[RunCommand]], [[RunSQL]]  or [[SelectObject]]
++>4. the DLookup, DSum, ... database functions
++>5. the support of the [[shortcut|ShortCut Notation]] notations like {{{Forms!myForm!myControl}}}
+++
++>6. a consistent [[errors and exceptions handler|Error Handler]]
++>7. facilities for programming [[form, dialog and control events|Events Handler]]
++>8. the support of both //embedded forms// (in Base documents) and [[forms stored in non-Base documents|Standalone Forms]]
++!Compare ~Access2Base with ~MSAccess VBA
++<<tiddler "Access2Base vs. VBA">>
++!To know more ...
++[[Why Access2Base ?]]
++The [[Object model|Object Model]]
++[[A tutorial|Tutorial]]
++Browse the [[User's Guide]]
++A detailed [[comparison|MSAccessCoverage]] between //~Access2Base// and //~MSAccess 2013//
++!Getting started
++[[Download the extension and get started|Install]]
++!To give feedback ...
++<<tiddler "Contact">>
++
++
++

++
++
++
The //~HtmlEncode// property converts a string to an ~HTML-encoded string.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]HtmlEncode(}}}//{{{InputString}}}//, [//{{{OutputLength}}}//]{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Optional | !Type |!Description | !Returned value |
++|{{{InputString}}} | No | String |Maximum length of 64,000 characters. | String |
++|{{{OutputLength}}} | Yes | Integer<br />Long |The output string will be truncated after {{{OutputLength}}} characters. However an &-encoded character will remain complete. |~|
++!!!Remarks
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[OutputTo]]
++!!!Example
++<<tiddler "HtmlEncode example">>
++
++
++
Html encoding of a string
++Returned string: {{{Amounts in &euro;, not in &#163;. Montants affich&#233;s en &euro;, pas en &#163;.}}}
++//{{{
++Const cstString = "Amounts in €, not in £. Montants affichés en €, pas en £."
++	DebugPrint Application.HtmlEncode(cstString)
++//}}}
++
++
++
//{{{
++	MsgBox Application.Version & " - " & Application.ProductCode & " - " & Application.CurrentUser
++	MsgBox Application.CurrentDb.Version
++//}}}
++
++
++
(Q) Can I import the content of a directory in individual binary fields ?
++
++(R) Use the [[ReadAllBytes]] method. It's exactly its purpose !
++
++Let's consider next table:
++<<tiddler "CategoriesTable">>
++Run next Sub. The assumption is that each file in the directory has a name corresponding with the name of the category (after having substituted "/" in category names by a space).
++//{{{
++Sub ImportImages(psPath As String)
++
++Dim oTable As Object, oRecordset As Object, sCatName As String
++	Set oTable = Application.CurrentDb().TableDefs("CATEGORIES")
++	Set oRecordset = oTable.OpenRecordset()
++	
++	With oRecordset
++		Do While Not .EOF()
++			sCatName = Join(Split(.Fields("CATEGORYNAME").Value, "/"), " ")
++			.Edit
++			.Fields("Picture").ReadAllBytes(psPath & sCatName & ".png")
++			.Update
++			.MoveNext
++		Loop
++		.mClose()
++	End With
++	
++End Sub
++//}}}
++!!!See also
++[[Fields]]
++[[OpenRecordset]]
++[[Recordset]]
++[[TableDefs]]
++[[WriteAllBytes]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Images |||||Store images in a directory, adapt the //path// argument and run the //Main// Sub from the Basic IDE. |
++
++
++
The //Index// property specifies the index number for a [[CommandBarControl]] object in the [[CommandBarControls]] collection of [[CommandBar]]. The property is read-only.
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBarControl]] |An element of a ~CommandBar. |
++!!!Syntax
++//commandbarcontrol//{{{.Index}}}
++!!!Returned values / Arguments
++{{{Integer}}}
++!!!Remarks
++For compatibility reasons with Microsoft Access ''the //Index// property starts at 1'', not at 0.
++To retrieve a commandbarcontrol object from its collection and you know the value of its //Index// property, use that value minus 1 as argument of the ~CommandBarControls collection.
++
++
++
/***
++|Name|InlineJavascriptPlugin|
++|Source|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
++|Documentation|http://www.TiddlyTools.com/#InlineJavascriptPluginInfo|
++|Version|1.9.6|
++|Author|Eric Shulman|
++|License|http://www.TiddlyTools.com/#LegalStatements|
++|~CoreVersion|2.1|
++|Type|plugin|
++|Description|Insert Javascript executable code directly into your tiddler content.|
++''Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
++!!!!!Documentation
++>see [[InlineJavascriptPluginInfo]]
++!!!!!Revisions
++<<<
++2010.12.15 1.9.6 allow (but ignore) type="..." syntax
++|please see [[InlineJavascriptPluginInfo]] for additional revision details|
++2005.11.08 1.0.0 initial release
++<<<
++!!!!!Code
++***/
++//{{{
++version.extensions.InlineJavascriptPlugin= {major: 1, minor: 9, revision: 6, date: new Date(2010,12,15)};
++
++config.formatters.push( {
++	name: "inlineJavascript",
++	match: "\\<script",
++	lookahead: "\\<script(?: type=\\\"[^\\\"]*\\\")?(?: src=\\\"([^\\\"]*)\\\")?(?: label=\\\"([^\\\"]*)\\\")?(?: title=\\\"([^\\\"]*)\\\")?(?: key=\\\"([^\\\"]*)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",
++	handler: function(w) {
++		var lookaheadRegExp = new RegExp(this.lookahead,"mg");
++		lookaheadRegExp.lastIndex = w.matchStart;
++		var lookaheadMatch = lookaheadRegExp.exec(w.source)
++		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
++			var src=lookaheadMatch[1];
++			var label=lookaheadMatch[2];
++			var tip=lookaheadMatch[3];
++			var key=lookaheadMatch[4];
++			var show=lookaheadMatch[5];
++			var code=lookaheadMatch[6];
++			if (src) { // external script library
++				var script = document.createElement("script"); script.src = src;
++				document.body.appendChild(script); document.body.removeChild(script);
++			}
++			if (code) { // inline code
++				if (show) // display source in tiddler
++					wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
++				if (label) { // create 'onclick' command link
++					var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",wikifyPlainText(label));
++					var fixup=code.replace(/document.write\s*\(/gi,'place.bufferedHTML+=(');
++					link.code="function _out(place,tiddler){"+fixup+"\n};_out(this,this.tiddler);"
++					link.tiddler=w.tiddler;
++					link.onclick=function(){
++						this.bufferedHTML="";
++						try{ var r=eval(this.code);
++							if(this.bufferedHTML.length || (typeof(r)==="string")&&r.length)
++								var s=this.parentNode.insertBefore(document.createElement("span"),this.nextSibling);
++							if(this.bufferedHTML.length)
++								s.innerHTML=this.bufferedHTML;
++							if((typeof(r)==="string")&&r.length) {
++								wikify(r,s,null,this.tiddler);
++								return false;
++							} else return r!==undefined?r:false;
++						} catch(e){alert(e.description||e.toString());return false;}
++					};
++					link.setAttribute("title",tip||"");
++					var URIcode='javascript:void(eval(decodeURIComponent(%22(function(){try{';
++					URIcode+=encodeURIComponent(encodeURIComponent(code.replace(/\n/g,' ')));
++					URIcode+='}catch(e){alert(e.description||e.toString())}})()%22)))';
++					link.setAttribute("href",URIcode);
++					link.style.cursor="pointer";
++					if (key) link.accessKey=key.substr(0,1); // single character only
++				}
++				else { // run script immediately
++					var fixup=code.replace(/document.write\s*\(/gi,'place.innerHTML+=(');
++					var c="function _out(place,tiddler){"+fixup+"\n};_out(w.output,w.tiddler);";
++					try	 { var out=eval(c); }
++					catch(e) { out=e.description?e.description:e.toString(); }
++					if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
++				}
++			}
++			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
++		}
++	}
++} )
++//}}}
++
++// // Backward-compatibility for TW2.1.x and earlier
++//{{{
++if (typeof(wikifyPlainText)=="undefined") window.wikifyPlainText=function(text,limit,tiddler) {
++	if(limit > 0) text = text.substr(0,limit);
++	var wikifier = new Wikifier(text,formatter,null,tiddler);
++	return wikifier.wikifyPlain();
++}
++//}}}
++
++// // GLOBAL FUNCTION: $(...) -- 'shorthand' convenience syntax for document.getElementById()
++//{{{
++if (typeof($)=='undefined') { function $(id) { return document.getElementById(id.replace(/^#/,'')); } }
++//}}}
++
++
++
/***
++|Name|InlineJavascriptPluginInfo|
++|Source|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
++|Documentation|http://www.TiddlyTools.com/#InlineJavascriptPluginInfo|
++|Version|1.9.6|
++|Author|Eric Shulman|
++|License|http://www.TiddlyTools.com/#LegalStatements|
++|~CoreVersion|2.1|
++|Type|documentation|
++|Description|Documentation for InlineJavascriptPlugin|
++''Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated ~TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
++!!!!!Usage
++<<<
++This plugin adds wiki syntax for surrounding tiddler content with {{{<script>}}} and {{{</script>}}} markers, so that it can be recognized as embedded javascript code.  When a tiddler is rendered, the plugin automatically invokes any embedded scripts, which can be used to construct and return dynamically-generated output that is inserted into the tiddler content.
++{{{
++<script type="..." src="..." label="..." title="..." key="..." show>
++	/* javascript code goes here... */
++</script>
++}}}
++All parameters are //optional//.    When the ''show'' keyword is used, the plugin will also include the script source code in the output that it displays in the tiddler.  This is helpful when creating examples for documentation purposes (such as used in this tiddler!)
++
++__''Deferred execution from an 'onClick' link''__
++<script label="click here" title="mouseover tooltip text" key="X" show>
++	/* javascript code goes here... */
++	alert('you clicked on the link!');
++</script>
++By including a {{{label="..."}}} parameter in the initial {{{<script>}}} marker, the plugin will create a link to an 'onclick' script that will only be executed when that specific link is clicked, rather than running the script each time the tiddler is rendered.  You may also include a {{{title="..."}}} parameter to specify the 'tooltip' text that will appear whenever the mouse is moved over the onClick link text, and a {{{key="X"}}} parameter to specify an //access key// (which must be a //single// letter or numeric digit only).
++
++__''Loading scripts from external source files''__
++<script src="URL" show>
++	/* optional javascript code goes here... */
++</script>You can also load javascript directly from an external source URL, by including a src="..." parameter in the initial {{{<script>}}} marker (e.g., {{{<script src="demo.js"></script>}}}).  This is particularly useful when incorporating third-party javascript libraries for use in custom extensions and plugins.  The 'foreign' javascript code remains isolated in a separate file that can be easily replaced whenever an updated library file becomes available.
++
++In addition to loading the javascript from the external file, you can also use this feature to invoke javascript code contained within the {{{<script>...</script>}}} markers.  This code is invoked //after// the external script file has been processed, and can make immediate use of the functions and/or global variables defined by the external script file.
++>Note: To ensure that your javascript functions are always available when needed, you should load the libraries from a tiddler that is rendered as soon as your ~TiddlyWiki document is opened, such as MainMenu.  For example: put your {{{<script src="..."></script>}}} syntax into a separate 'library' tiddler (e.g., ~LoadScripts), and then add {{{<<tiddler LoadScripts>>}}} to MainMenu so that the library is loaded before any other tiddlers that rely upon the functions it defines. 
++>
++>Normally, loading external javascript in this way does not produce any direct output, and should not have any impact on the appearance of your MainMenu.  However, if your ~LoadScripts tiddler contains notes or other visible content, you can suppress this output by using 'inline CSS' in the MainMenu, like this: {{{@@display:none;<<tiddler LoadScripts>>@@}}}
++<<<
++!!!!!Creating dynamic tiddler content and accessing the ~TiddlyWiki DOM
++<<<
++An important difference between ~TiddlyWiki inline scripting and conventional embedded javascript techniques for web pages is the method used to produce output that is dynamically inserted into the document: in a typical web document, you use the {{{document.write()}}} (or {{{document.writeln()}}}) function to output text sequences (often containing HTML tags) that are then rendered when the entire document is first loaded into the browser window.
++
++However, in a ~TiddlyWiki document, tiddlers (and other DOM elements) are created, deleted, and rendered "on-the-fly", so writing directly to the global 'document' object does not produce the results you want (i.e., replacing the embedded script within the tiddler content), and instead will //completely replace the entire ~TiddlyWiki document in your browser window (which is clearly not a good thing!)//.  In order to allow scripts to use {{{document.write()}}}, the plugin automatically converts and buffers all HTML output so it can be safely inserted into your tiddler content, immediately following the script.
++
++''Note that {{{document.write()}}} can only be used to output "pure HTML" syntax.  To produce //wiki-formatted// output, your script should instead return a text value containing the desired wiki-syntax content'', which will then be automatically rendered immediately following the script.  If returning a text value is not sufficient for your needs, the plugin also provides an automatically-defined variable, 'place', that gives the script code ''direct access to the //containing DOM element//'' into which the tiddler output is being rendered.  You can use this variable to ''perform direct DOM manipulations'' that can, for example:
++* generate wiki-formatted output using {{{wikify("...content...",place)}}}
++* vary the script's actions based upon the DOM element in which it is embedded
++* access 'tiddler-relative' DOM information using {{{story.findContainingTiddler(place)}}}
++Note:
++''When using an 'onclick' script, the 'place' element actually refers to the onclick //link text// itself, instead of the containing DOM element.''  This permits you to directly reference or modify the link text to reflect any 'stateful' conditions that might set by the script.  To refer to the containing DOM element from within an 'onclick' script, you can use "place.parentNode" instead.
++<<<
++!!!!!Instant "bookmarklets"
++<<<
++You can also use an 'onclick' link to define a "bookmarklet": a small piece of javascript that can be ''invoked directly from the browser without having to be defined within the current document.''  This allows you to create 'stand-alone' commands that can be applied to virtually ANY ~TiddlyWiki document... even remotely-hosted documents that have been written by others!!  To create a bookmarklet, simply define an 'onclick' script and then grab the resulting link text and drag-and-drop it onto your browser's toolbar (or right-click and use the 'bookmark this link' command to add it to the browser's menu).
++
++Notes:
++*When writing scripts intended for use as bookmarklets, due to the ~URI-encoding required by the browser, ''you cannot not use ANY double-quotes (") within the bookmarklet script code.''
++*All comments embedded in the bookmarklet script must ''use the fully-delimited {{{/* ... */}}} comment syntax,'' rather than the shorter {{{//}}} comment syntax.
++*Most importantly, because bookmarklets are invoked directly from the browser interface and are not embedded within the ~TiddlyWiki document, there is NO containing 'place' DOM element surrounding the script.  As a result, ''you cannot use a bookmarklet to generate dynamic output in your document,''  and using {{{document.write()}}} or returning wiki-syntax text or making reference to the 'place' DOM element will halt the script and report a "Reference Error" when that bookmarklet is invoked.  
++Please see ~InstantBookmarklets for many examples of 'onclick' scripts that can also be used as bookmarklets.
++<<<
++!!!!!Special reserved function name
++<<<
++The plugin 'wraps' all inline javascript code inside a function, {{{_out()}}}, so that any return value you provide can be correctly handled by the plugin and inserted into the tiddler.  To avoid unpredictable results (and possibly fatal execution errors), this function should never be redefined or called from ''within'' your script code.
++<<<
++!!!!!$(...) 'shorthand' function
++<<<
++As described by Dustin Diaz [[here|http://www.dustindiaz.com/top-ten-javascript/]], the plugin defines a 'shorthand' function that allows you to write:
++{{{
++$(id)
++}}}
++in place of the normal standard javascript syntax:
++{{{
++document.getElementById(id)
++}}}
++This function is provided merely as a convenience for javascript coders that may be familiar with this abbreviation, in order to allow them to save a few bytes when writing their own inline script code.
++<<<
++!!!!!Examples
++<<<
++simple dynamic output:
++><script show>
++	document.write("The current date/time is: "+(new Date())+"<br>");
++	return "link to current user: [["+config.options.txtUserName+"]]\n";
++</script>
++dynamic output using 'place' to get size information for current tiddler:
++><script show>
++	if (!window.story) window.story=window;
++	var title=story.findContainingTiddler(place).getAttribute("tiddler");
++	var size=store.getTiddlerText(title).length;
++	return title+" is using "+size+" bytes";
++</script>
++dynamic output from an 'onclick' script, using {{{document.write()}}} and/or {{{return "..."}}}
++><script label="click here" show>
++	document.write("<br>The current date/time is: "+(new Date())+"<br>");
++	return "link to current user: [["+config.options.txtUserName+"]]\n";
++</script>
++creating an 'onclick' button/link that accesses the link text AND the containing tiddler:
++><script label="click here" title="clicking this link will show an 'alert' box" key="H" show>
++	if (!window.story) window.story=window;
++	var txt=place.firstChild.data;
++	var tid=story.findContainingTiddler(place).getAttribute('tiddler');
++	alert('Hello World!\nlinktext='+txt+'\ntiddler='+tid);
++</script>
++dynamically setting onclick link text based on stateful information:
++>{{block{
++{{{
++<script label="click here">
++	/* toggle "txtSomething" value */
++	var on=(config.txtSomething=="ON");
++	place.innerHTML=on?"enable":"disable";
++	config.txtSomething=on?"OFF":"ON";
++	return "\nThe current value is: "+config.txtSomething;
++</script><script>
++	/* initialize onclick link text based on current "txtSomething" value */
++	var on=(config.txtSomething=="ON");
++	place.lastChild.previousSibling.innerHTML=on?"disable":"enable";
++</script>
++}}}
++<script label="click here">
++	/* toggle "txtSomething" value */
++	var on=(config.txtSomething=="ON");
++	place.innerHTML=on?"enable":"disable";
++	config.txtSomething=on?"OFF":"ON";
++	return "\nThe current value is: "+config.txtSomething;
++</script><script>
++	/* initialize onclick link text based on current "txtSomething" value */
++	var on=(config.txtSomething=="ON");
++	place.lastChild.innerHTML=on?"enable":"disable";
++</script>
++}}}
++loading a script from a source url:
++>http://www.TiddlyTools.com/demo.js contains:
++>>{{{function inlineJavascriptDemo() { alert('Hello from demo.js!!') } }}}
++>>{{{displayMessage('InlineJavascriptPlugin: demo.js has been loaded');}}}
++>note: When using this example on your local system, you will need to download the external script file from the above URL and install it into the same directory as your document.
++>
++><script src="demo.js" show>
++	return "inlineJavascriptDemo() function has been defined"
++</script>
++><script label="click to invoke inlineJavascriptDemo()" key="D" show>
++	inlineJavascriptDemo();
++</script>
++<<<
++!!!!!Revisions
++<<<
++2010.12.15 1.9.6 allow (but ignore) type="..." syntax
++2009.04.11 1.9.5 pass current tiddler object into wrapper code so it can be referenced from within 'onclick' scripts
++2009.02.26 1.9.4 in $(), handle leading '#' on ID for compatibility with ~JQuery syntax
++2008.06.11 1.9.3 added $(...) function as 'shorthand' for document.getElementById()
++2008.03.03 1.9.2 corrected fallback declaration of wikifyPlainText() (fixes Safari "parse error")
++2008.02.23 1.9.1 in onclick function, use string instead of array for 'bufferedHTML' (fixes IE errors)
++2008.02.21 1.9.0 output from 'onclick' scripts (return value or document.write() calls) are now buffered and rendered into into a span following the script.  Also, added default 'return false' handling if no return value provided (prevents HREF from being triggered -- return TRUE to allow HREF to be processed).  Thanks to Xavier Verges for suggestion and preliminary code.
++2008.02.14 1.8.1 added backward-compatibility for use of wikifyPlainText() in ~TW2.1.3 and earlier
++2008.01.08 [*.*.*] plugin size reduction: documentation moved to ...Info tiddler
++2007.12.28 1.8.0 added support for key="X" syntax to specify custom access key definitions
++2007.12.15 1.7.0 autogenerate URI encoded HREF on links for onclick scripts.  Drag links to browser toolbar to create bookmarklets.  IMPORTANT NOTE: place is NOT defined when scripts are used as bookmarklets.  In addition, double-quotes will cause syntax errors.  Thanks to ~PaulReiber for debugging and brainstorming.
++2007.11.26 1.6.2 when converting "document.write()" function calls in inline code, allow whitespace between "write" and "(" so that "document.write ( foobar )" is properly converted.
++2007.11.16 1.6.1 when rendering "onclick scripts", pass label text through wikifyPlainText() to parse any embedded wiki-syntax to enable use of HTML entities or even TW macros to generate dynamic label text.
++2007.02.19 1.6.0 added support for title="..." to specify mouseover tooltip when using an onclick (label="...") script
++2006.10.16 1.5.2 add newline before closing '}' in 'function out_' wrapper.  Fixes error caused when last line of script is a comment.
++2006.06.01 1.5.1 when calling wikify() on script return value, pass hightlightRegExp and tiddler params so macros that rely on these values can render properly
++2006.04.19 1.5.0 added 'show' parameter to force display of javascript source code in tiddler output
++2006.01.05 1.4.0 added support 'onclick' scripts.  When label="..." param is present, a button/link is created using the indicated label text, and the script is only executed when the button/link is clicked.  'place' value is set to match the clicked button/link element.
++2005.12.13 1.3.1 when catching eval error in IE, e.description contains the error text, instead of e.toString().  Fixed error reporting so IE shows the correct response text.  Based on a suggestion by ~UdoBorkowski
++2005.11.09 1.3.0 for 'inline' scripts (i.e., not scripts loaded with src="..."), automatically replace calls to 'document.write()' with 'place.innerHTML+=' so script output is directed into tiddler content.  Based on a suggestion by ~BradleyMeck
++2005.11.08 1.2.0 handle loading of javascript from an external URL via src="..." syntax
++2005.11.08 1.1.0 pass 'place' param into scripts to provide direct DOM access 
++2005.11.08 1.0.0 initial release
++<<<
++
++
++
{{firstletter{
++ @@color:#930;D@@
++ }}}epending on the office suite you are using and its version, the installation instructions may vary.
++!For LIBREOFFICE users only
++The //~Access2Base// library is included in ~LibreOffice as from its version 4.2. If you run that or a later version, then ''~Access2Base is already installed'' on your device. As such ... skip the installation of the extension and go to the ''__Start using the library__'' paragraph below.
++If you are using ~Access2Base with ~LibreOffice in a version earlier than 4.2, then __REMOVE the ~Access2Base extension__ before installing ~LibreOffice 4.2 or later.
++| !~LibreOffice version | !Embedded ~Access2Base version | !Ịnstallation / upgrade instructions |
++| <= 4.1 | None |See ''__Install ~Access2Base as an extension__'' below. |
++| 4.2 | 1.0.0 |Go to ''__Start using the library__'' below. |
++| 4.3 | 1.1.0 |~|
++| 4.4 | 1.2.0 |~|
++| 5.0 | 1.3.0 |~|
++| 5.1 | 1.4.0 |~|
++| 5.2 | 1.5.0 |~|
++| 5.3 | 1.6.0 |~|
++| 5.4 | 1.7.0 |~|
++| 6.0 | 1.8.0 |~|
++| 6.1 | 1.9.0 |~|
++|''If you would like to benefit from the latest version of ~Access2Base (typically 1.9.0) but, for any reason, want to stay in an older version of ~LibreOffice (typically 6.0), then you might decide anyway to download and install the extension as described below.<br />This option is available only as from __~LibreOffice 4.2.6__.<br /><br />However, before upgrading later on ~LibreOffice to a newer major release (typically 6.1), first __REMOVE the ~Access2Base extension__.'' |>|>|
++!Install ~Access2Base as an extension (DEPRECATED)
++!!Download //~Access2Base// either from the
++*[[OpenOffice extensions repository|http://extensions.services.openoffice.org/en/project/access2base]]
++*[[LibreOffice extensions center|http://extensions.libreoffice.org/extension-center/access2base]]
++The downloaded contents are identical if their version numbers are identical too.
++>''Starting from version 6.2.0, ~Access2Base is not available as an extension anymore. To benefit from its features, install ~LibreOffice (>=) 6.2.''
++!!Install the //~Access2Base// extension
++The name of he downloaded file is __~Access2Base.oxt__. Select preferably the last proposed version.
++Note: //some browsers might download the extension as a .zip file; if this happens rename the downloaded file from .zip to .oxt//
++Install the extension as any other extension. To know more, follow the instructions in [[Installing an extension (AOO)|https://wiki.openoffice.org/wiki/Documentation/Administration_Guide/Using_Package_Manager]] or in [[Installing an extension (LibO)|https://wiki.documentfoundation.org/Documentation/HowTo/install_extension]]
++
++The Basic IDE ...
++... has now 2 more options:
++#The {{{Tools + Add-Ons + Access2Base Console ...}}} menu item opens the ~Access2Base console (see the [[Error Handler]]).
++#The {{{Help + Access2Base Online Help}}} menu item opens the current Help file in your preferred browser.
++!Start using the library
++To be able to invoke the //~Access2Base// API from a AOO/~LibO ".odb" file (the usual suffix for the front-end part of database documents) you have to
++*Have a minimal knowledge of the Basic IDE and of the Basic programming language.
++*Open in the main AOO/~LibO Base window the ".odb" file (the database document) on which you would like to apply ~Access2Base functions.
++*With {{{Tools + Macros + Organize Macros + OpenOffice/LibreOffice Basic...}}} open the Basic IDE and create a Basic module in the Standard library of the database document itself. The module should contain as a minimum next code:
++<<tiddler "Openconnection example">>
++*Assign in the main Base window with menu items {{{Tools + Customize...}}} ({{{Events}}} tab) the above Sub ("~DBOpen" in the example but use the name of your choice) to the //~OpenDocument// event. Save in the ".odb" file itself.
++*//Close// and re-//open// the ".odb" file. This will trigger the //~OpenDocument// event.
++*__Optionally__ associate next code with the //"View is going to be closed"// document event.
++//{{{
++Sub DBClose(Optional poEvent As Object)
++	Call CloseConnection()
++End Sub
++//}}}
++*Start programming macro's. Associate them with //form// or //control events// if relevant.
++Caution: the procedure is different for [[Standalone Forms]].
++!!If no database connection ...
++<<tiddler "RunWithoutConnection">>
++!!See also
++[[OpenConnection]]
++[[Standalone Forms]]
++!!Releases History
++<<tiddler "ReleaseNotes">>
++
++
++
You can use the //~IsLoaded// property to specify if a form or dialog is currently loaded.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |A form, either open or not |
++|[[Dialog]] |A dialog, active or not |
++!!!Syntax
++//form//{{{.IsLoaded}}}
++//dialog//{{{.IsLoaded}}}
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The //~IsLoaded// property is read-only
++!!!Error messages
++!!!See also
++!!!Example
++<<tiddler "IsLoaded example">>
++
++
++
List all forms and specify which ones are open
++//{{{
++Dim ofForm As Object, iCount As Integer, i As Integer
++	iCount = AllForms.Count
++	For i = 0 To iCount - 1
++		Set ofForm = AllForms(i)
++		With ofForm
++			Print "Form " & .Name & " is " & Iif(.IsLoaded, "", "NOT ") & "open"
++		End With
++	Next i
++	Print
++//}}}
++
++
++
The //Item// property identifies a member of a [[collection|Collection]] by its name or its index.
++!!!Applies to ...
++| !Collection |!Description |
++|[[AllDialogs]] |All dialogs present in any of the accessible dialog libraries |
++|[[AllForms]] |All forms, open or closed, in the current database document (".odb" file) |
++|[[Controls]] |All the controls of a //form//, a //dialog//, a //subform// or a //gridcontrol// |
++|[[Fields]] |All the fields of a //table//, a //query// or a //recordset// |
++|[[Forms]] |All open forms |
++|[[Properties|Properties (collection)]] |All properties of an object |
++|[[QueryDefs]] |All queries in the database |
++|[[Recordsets]] |All recordsets currently open |
++|[[TableDefs]] |All tables in the database |
++!!!Syntax
++//collection//{{{.Item(}}}//index//{{{)}}}
++//collection//{{{.Item(}}}//name//{{{)}}}
++!!!Arguments / Returned values
++| !Argument | !Type | !Returned value |
++|index | Integer<br />Long |An {{{Object}}} of the collection. |
++|name | String |~|
++!!!Remarks
++*The //Item// property is read-only.
++*The //index// argument must have a value in the interval 0 to {{{Count - 1}}}.
++!!!Error messages
++!!!See also
++[[Count]]
++!!!Example
++<<tiddler "Item example">>
++
++
++
Document all database queries
++//{{{
++Dim oQueryDefs As Object, oFields As Object, oProperties As Object, oProperty As Object
++Dim i As Integer, j As Integer, k As Integer
++	Set oQueryDefs = Application.CurrentDb().QueryDefs
++	for i = 0 to oQueryDefs.Count - 1
++		Set oFields = oQueryDefs.Item(i).Fields()
++		For j = 0 to oFields.Count - 1
++			Set oProperties = oFields.Item(j).Properties
++			for k = 0 to oProperties.Count - 1
++				Set oProperty = oProperties.Item(k)
++				DebugPrint oQueryDefs.Item(i).Name, oFields.Item(j).Name, _
++							oProperty.Name, oProperty.Value
++			next k
++		next j
++	next i
++//}}}
++
++
++
The //~ItemData// property returns the data in the bound column for the specified row in a combo box or list box.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] |A combo- or listbox on an open form or dialog, or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.ItemData}}}
++//control//{{{.ItemData(index)}}}
++!!!Returned values / Arguments
++{{{Array of Strings}}} (might be empty) if index is absent
++{{{String}}} (might be null string) if index is present
++!!!Remarks
++*The //~ItemData// property is read-only. To modify the list of items displayed in a //~ComboBox// or a //~ListBox//, use the [[RowSource]] and [[RowSourceType]] properties.
++*The //index// argument must have a (integer or long) value between 0 and (ListCount - 1)
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property '~ItemData' not applicable in this context |
++|Out of array range or incorrect array size for property '~ItemData'|
++!!!See also
++[[ListCount]]
++[[ListIndex]]
++[[MultiSelect]]
++[[RowSource]]
++[[RowSourceType]]
++[[Selected]]
++!!!Example
++*Combo box
++<<tiddler "ComboBox example">>
++*List box
++<<tiddler "ListBox example">>
++
++
++
(Q) I can't put all the numerous fields of a table on one single form. I need several forms and will navigate thru them with buttons. Of course, when I navigate thru records, I want to keep all open forms synchronized with the active one. How can I get that ?
++
++(R) The synchronization will be obtained by using subforms and filters. However the challenge is to have one single concise code to do all the job.
++
++Let's consider next tables:
++<<tiddler "OrdersTable">>
++<<tiddler "OrderDetailsTable">>
++<<tiddler "CustomersTable">>
++<<tiddler "ProductsTable">>
++<<tiddler "EmployeesTable">>
++We will use 4 forms:
++*a //main// form and its subform for displaying Orders and their ~OrderDetails.
++*3 //auxiliary// forms for displaying on request more details about the concerned Customer, Product or Employee.
++*3 buttons (one for each of the 3 //auxiliary// forms) available from the //main// form activating the corresponding //auxiliary// form.
++The trick is that when navigating among orders or order details, the open //auxiliary// forms remain synchronized with the //main// form and its subform.
++!!!Synchronize all forms
++Link next code to next events:
++*//After record change// in the form events list
++*//Mouse button pressed// control events of each of the 3 buttons
++*//After record change// in the ''sub''form events list
++//{{{
++Sub SyncForms(poEvent As Object)
++
++Dim ofForm As Object, oeEvent As Object, oTrigger As Object, oMainForm As Object
++Dim sFilter As String, sEmployee As String, sCustomer As String, sProduct As String
++Dim i As Integer, sForm As String
++Const cstMainForm = "Orders_Details_Sync_Cust-Prod-Emp"
++Const cstSuffix = "_Sync_Orders"		'	Suffix of auxiliary form names
++
++	Set oeEvent = Events(poEvent)
++	Set oTrigger = oeEvent.Source			'	Determine the trigger: one of the buttons ? or record navigation in main form ?
++							'	or record navigation in subform ?
++	Set oMainForm = AllForms(cstMainForm)
++	If Not oMainForm.IsLoaded Then Goto Exit_Sub	'	May happen at form loading or closure
++	
++	If Left(oTrigger.Name, Len("btn")) = "btn" Then			'	Triggered by buttons btnCustomers, btnProducts or btnEmployees
++		sForm = Right(oTrigger.Name, Len(oTrigger.Name)- Len("btn")) & cstSuffix
++		Set ofForm = AllForms(sForm)				'	AllForms() collects all forms, whether open or not
++		If ofForm.IsLoaded Then ofForm.SetFocus() Else OpenForm(sForm)
++	End If
++				
++	'Determine filters
++	sCustomer	= "[CustomerID]='" & oMainForm.Controls("txtCustomerID").Value & "'"	'	String !!!
++	sProduct	= "[ProductID]=" & oMainForm.Controls("SubForm").Form.Controls("SubForm_Grid").Controls("ProductID").Value
++	sEmployee	= "[EmployeeID]=" & oMainForm.Controls("fmtEmployeeID").Value
++	For i = 0 To Forms().Count - 1						'	Forms() collects all open forms
++		Set ofForm = Forms(i)
++		sFilter = ""
++		Select Case Split(ofForm.Name, cstSuffix)(0)
++			Case "Customers"	:	sFilter = sCustomer
++			Case "Products"		:	sFilter = sProduct
++			Case "Employees"	:	sFilter = sEmployee
++			Case Else	'	Ignore any other open form
++		End Select
++		If Len(sFilter) > 0 Then
++			ofForm.Filter = sFilter
++			ofForm.FilterOn = True
++		End If
++	Next i
++	
++Exit_Sub:
++	Set ofForm = Nothing
++	Set oeEvent = Nothing
++	Set oTrigger =Nothing
++	Set oMainForm = Nothing
++	Exit Sub
++End Sub
++//}}}
++!!!To close all the forms simultaneously when the main form is closed
++Link next Sub to the //Closed a sub component// event of the database file (Use the {{{Tools + Customize ... + Events}}} menu items).
++//{{{
++Sub SyncCloseForms(poEvent As Object)
++
++'	Fired at each component closure !!
++
++Dim oEvent As Object
++Const acForm = 2
++Const cstMainForm = "Orders_Details_Sync_Cust-Prod-Emp"
++	Set oEvent = Events(poEvent)
++	If UCase(oEvent.SubComponentName) <> UCase(cstMainForm) Then Exit Sub
++	DoCmd.mClose acForm, "Customers_Sync_Orders"
++	DoCmd.mClose acForm, "Employees_Sync_Orders"
++	DoCmd.mClose acForm, "Products_Sync_Orders"
++	Exit Sub
++
++End Sub
++//}}}
++!!!See also
++[[AllForms]]
++[[Close (method)]]
++[[Event]]
++[[Filter]]
++[[FilterOn]]
++[[Forms]]
++!!!Refer to ...
++| !Basic module | !Database event | !Form | !Form event | !~SubForm | !~SubForm event | !Control | !Control event |!Comments |
++|Synchro |Closed a sub-component | ~Orders_Details_Sync_Cust-Prod-Emp<br />~Customers_Sync_Orders<br />~Employees_Sync_Orders<br />~Products_Sync_Orders |After record change |~SubForm |After record change | btnCustomers<br />btnEmployees<br />btnProducts |Mouse button pressed ||
++
++
++
(Q) When browsing thru a //recordset//, how can I identify that I reached the end ?
++
++(R) In a [[Recordset object|Recordset]], if you try to move beyond the beginning or ending record, an error occurs. For example, if you try to use the [[MoveNext|Move (recordset)]] method when you are already at the last record of the //Recordset//, an error occurs. For this reason, it is helpful to know the limits of the //Recordset// object.
++
++The [[BOF|BOF, EOF]] property indicates whether the current position is at the beginning of the //Recordset//. If //BOF// is {{{True}}}, the current position is before the first record in the //Recordset//. The //BOF// property is also {{{True}}} if there are no records in the //Recordset// when it is opened. Similarly, the [[EOF|BOF, EOF]] property is {{{True}}} if the current position is after the last record in the //Recordset//, or if there are no records.
++
++The following code example shows how to use the //BOF// and //EOF// properties to detect the beginning and end of a //Recordset// object. This code fragment creates a //Recordset// based on the ''Orders table'' from the current database. It moves through the records, first from the beginning of the //Recordset// to the end, and then from the end of the //Recordset// to the beginning.
++//{{{
++Dim odbNorthwind As Object
++Dim orsOrders As Object
++	Set odbNorthwind = Application.CurrentDb
++	Set orsOrders = odbNorthwind.OpenRecordset("Orders")
++
++	' Do until ending of file.
++	Do Until orsOrders.EOF
++		' Manipulate the data. 
++		orsOrders.MoveNext			' Move to the next record.
++	Loop 
++
++	orsOrders.MoveLast				' Move to the last record.
++	' Do until beginning of file.
++	Do Until orsOrders.BOF
++		' Manipulate the data.
++		orsOrders.MovePrevious			' Move to the previous record.
++	Loop
++
++	orsOrders.mClose()
++//}}}
++Be aware that there is no current record immediately following the first loop. The //BOF// and //EOF// properties both have the following characteristics.
++*If the //Recordset// contains no records when you open it, both //BOF// and //EOF// are {{{True}}}.
++*When //BOF// or //EOF// is {{{True}}}, the property remains {{{True}}} until you move to an existing record, at which time the value of //BOF// or //EOF// becomes {{{False}}}.
++*At the moment you create or open a //Recordset// that contains at least one record, the first record is the current record, and both //BOF// and //EOF// are {{{False}}}.
++*If the first record is the current record when you use the [[MovePrevious|Move (recordset)]] method, //BOF// is set to {{{True}}}. If you use //~MovePrevious// while //BOF// is {{{True}}}, an error occurs. When this happens, //BOF// remains {{{True}}} and there is no current record.
++*Similarly, moving past the last record in the //Recordset// changes the value of the //EOF// property to True. If you use the //~MoveNext// method while //EOF// is {{{True}}}, an error occurs.
++!!!See also
++[[BOF, EOF]]
++[[MoveFirst, MoveLast, MoveNext, MovePrevious|Move (recordset)]]
++[[OpenRecordset]]
++!!!Refer to ...
++| !Basic module | !Sub |!Comments |
++|~HowTo |~FindLimitsRecordset ||
++
++
++
++
The //Lines// property returns a string containing the contents of a specified line or lines in a standard or a class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.Lines(}}}//line, numlines//{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Type | !Description | !Returned type |
++|module | Object |The concerned module. | String |
++|line | Long |The number of the first line to return. |~|
++|numlines | Long |The number of lines to return. |~|
++!!!Remarks
++The requested lines are returned as one single string. The individual lines are separated by a line feed (Chr(10)) character.
++Lines in a module are numbered beginning with 1. For example, if you read the //Lines// property with a value of 1 for the //line// argument and 1 for the //numlines// argument, the //Lines// property returns a string containing the text of the first line in the module.
++!!!Error messages
++|Property 'Lines' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[CountOfDeclarationLines]]
++[[CountOfLines]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
You can use the ~LinkChildFields property (along with the LinkMasterFields property together) to know how the records in a form are linked to records in a subform.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | [[SubForm]] | None |A subform of an open form or another subform |
++!!!Syntax
++//control//{{{.LinkChildFields}}}
++//control//{{{.LinkChildFields(index)}}}
++!!!Returned values
++Array of {{{Strings}}} or {{{String}}}
++!!!Remarks
++The ~LinkChildFields property is read-only.
++The array can be empty. In this case the {{{UBound()}}} function applied on that array will return {{{-1}}}.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property '~LinkChildFields' not applicable in this context |
++|Out of array range or incorrect array size for property '~LinkChildFields' |
++!!!See also
++[[LinkMasterFields]]
++!!!Example
++<<tiddler "Linkfields example">>
++
++
++
You can use the ~LinkMasterFields property (along with the LinkChildFields property together) to know how the records in a form are linked to records in a subform.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | [[SubForm]] | None |A subform of an open form or another subform |
++!!!Syntax
++//control//{{{.LinkMasterFields}}}
++//control//{{{.LinkMasterFields(index)}}}
++!!!Returned values
++Array of {{{Strings}}} or {{{String}}}
++!!!Remarks
++The ~LinkMasterFields property is read-only.
++The array can be empty. In this case the {{{UBound()}}} function applied on that array will return {{{-1}}}.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property '~LinkMasterFields' not applicable in this context |
++|Out of array range or incorrect array size for property '~LinkMasterFields' |
++!!!See also
++[[LinkChildFields]]
++!!!Example
++<<tiddler "Linkfields example">>
++
++
++
List all the master / children fields of a subform
++//{{{
++Dim ocSubform As Object, i As Integer, iCount As Integer
++	Set ocSubform = getValue("Forms!myForm!mySubform.Form")
++	iCount = UBound(ocSubform.LinkMasterFields)
++	For i = 0 To iCount
++		Print "Master " & ocSubform.LinkMasterFields(i) & " is linked to " & ocSubform.LinkChildFields(i),
++	Next i
++	Print
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~ListBox// describes a list box control. It has specific properties to manage the input list of potential values and to select one or more of them programmatically.
++A ~ListBox control is returned by the [[Controls]] collection or by the [[getObject]] shortcut.
++!!!Specific properties for list box management
++| !Property | !Type | !Read only | !Description |
++|[[ItemData]] | Variant array | Y |Returns the data for the specified row in a combo box or list box. |
++|[[ListCount]] | Integer<br />Long | Y |Determines the number of rows in a ~ListBox or the list box portion of a [[ComboBox]]. |
++|[[ListIndex]] | Integer<br />Long ||Determines which item is selected in a ~ListBox or a [[ComboBox]]. |
++|[[MultiSelect]] | Boolean ||Specifies whether a user can make multiple selections in a ~ListBox on a form. |
++|[[RowSource]] | String ||Specifies the source (tablename, queryname or SQL statement) of the data in a ~ListBox or a [[ComboBox]]. |
++|[[RowSourceType]] | Integer<br />Long ||Specifies the type of source (table, query or SQL statement) of the data in a ~ListBox or a [[ComboBox]]. |
++|[[Selected]] | Boolean array ||Specifies if an item in the data proposed by a ~ListBox is currently selected. |
++|[[Value]] | Variant ||Specifies the value contained in the (~MultiSelect = False !) ~ListBox. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[AddItem]] | String |Boolean|Add a new item to the list of displayed values. |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~ListBox has the given property. |
++|[[RemoveItem]] | String<br />Integer |~|Remove an item from the list of displayed values. |
++|[[Requery]] | none |~|True if data reloaded in the ~ListBox |
++|[[SetFocus]] |~|~|Return True if focus set on Control successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++*A //~ListBox// may or not have a second (hidden) column which is bound to the underlying data in the database. It is most often an index, the visible column being a readable label associated with that index. When it is the case the //Value// property contains the value in the index column.
++*If no item is selected in the //~ListBox//, the //~ListIndex// property is set to {{{-1}}} and the //Selected// array contains {{{False}}} in all its entries. If //~MutliSelect// is {{{True}}} then //~ListIndex// always returns {{{-1}}}
++!!!See also
++[[ComboBox]]
++!!!Example
++<<tiddler "ListBox example">>
++
++
++
Display the selected rows of a (multiselect) listbox
++//{{{
++Dim i As Integer, ocList As Object
++	Set ocList = getObject("Forms!myForm!myListBox")
++	For i = 0 To ocList.ListCount - 1
++		If ocList.Selected(i) Then Print i & " - " & ocList.ItemData(i),
++	Next i
++//}}}
++Select all options
++//{{{
++	For i = 0 To ocList.ListCount - 1
++		setSelected(ocList, True, i)
++	Next i
++	Print
++//}}}
++
++
++
You can use the //~ListCount property// to determine the number of rows in a list box or the list box portion of a combo box.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] |A combo- or listbox on an open form or dialog, or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.ListCount}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++The //~ListCount// property is read-only.
++!!!Error messages
++|Property '~ListCount' not applicable in this context |
++!!!See also
++[[ItemData]]
++[[ListIndex]]
++[[MultiSelect]]
++[[RowSource]]
++[[RowSourceType]]
++[[Selected]]
++!!!Example
++*Combo box
++<<tiddler "ComboBox example">>
++*List box
++<<tiddler "ListBox example">>
++
++
++
You can use the //~ListIndex// property to determine which item is selected in a list box or combo box.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] |A combo- or listbox on an open form or dialog, or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.ListIndex}}}
++//control//{{{.ListIndex}}} = //value//
++!!!Returned values / Arguments
++{{{Long}}} in interval [0, //~ListCount// - 1] or (-1)
++!!!Remarks
++If the control is a [[MultiSelect]] listbox, or if there is no item selected, then the //~ListIndex// property always returns {{{-1}}}
++!!!Error messages
++|Property '~ListIndex' not applicable in this context |
++|Value '...' is invalid for property '~ListIndex' |
++!!!See also
++[[ItemData]]
++[[ListCount]]
++[[MultiSelect]]
++[[RowSource]]
++[[RowSourceType]]
++[[Selected]]
++!!!Example
++*Combo box
++<<tiddler "ComboBox example">>
++*List box
++<<tiddler "ListBox example">>
++
++
++
The //Locked// property specifies if the control is read only.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |[[ComboBox]]<br />~CurrencyField<br />~DateField<br />~FileControl<br />~FormattedField<br />~ImageControl<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />~TextField<br />~TimeField | All except<br />--~CheckBox-- |[[ComboBox]]<br />~CurrencyField<br />~DateField<br />~FileControl<br />~FormattedField<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />~TextField<br />~TimeField |A control on an open form, a dialog or a [[GridControl]] |
++!!!Syntax
++//control//{{{.Locked}}}
++//control//{{{.Locked}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Property 'Locked' not applicable in this context |
++|Value '...' is invalid for property 'Locked' |
++!!!See also
++[[Enabled]]
++!!!Example
++<<tiddler "Enabled & Locked example">>
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} detailed info has been compiled in this page about which actions and which objects, as they exist in //~MSAccess 2013//, have been - partly or more completely - already implemented in //~Access2Base//. A @@background-color:#ff3;perspective for future developments@@ of //~Access2Base// is also given in terms of interest for users and of complexity of implementation.
++!Access objects
++| !OBJECTS |>|>|>|>| ''__FUNCTIONALITY__'' |>|>|>|background-color:#eee; ''__IMPLEMENTATION__'' | !Comments |
++|~| !Done | !Could be improved | !Very nice to have | !Nice to have | !Not applicable | !Out of Reach | !Complex | !Average | !Easy |~|
++|''"""AccessObject"""'' |  |  |  | X |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Generic object for forms, queries, ..., database objects""" |
++|''"""AccessObjectProperties"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Similar to Properties""" |
++|''"""AccessObjectProperty"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Similar to Property""" |
++|''"""AdditionalData"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Linked to ExportXML method""" |
++|''"""AllDatabaseDiagrams"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""AllForms"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""AllFunctions"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""List VBA code""" |
++|''"""AllMacros"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""MSAccess macro's <> LibO/AOO macro's""" |
++|''"""AllModules"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""List VBA code""" |
++|''"""AllQueries"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Redundant with QueryDefs collection""" |
++|background-color:#ff3;''"""AllReports"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  | |
++|''"""AllStoredProcedures"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""RDBMS dependent""" |
++|''"""AllTables"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Redundant with TableDefs collection""" |
++|''"""AllViews"""'' |  |  |  | X |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""RDBMS views are seen as Tables in Base""" |
++|''"""Application"""'' | X | X |  |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Extensions to form, report design are Out of Reach""" |
++|''"""Attachment"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Access database fields can hold file attachments""" |
++|''"""AutoCorrect"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Dictionaries/Thesaurus linked""" |
++|''"""BoundObjectFrame"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""For OLE objects stored in databases""" |
++|''"""CheckBox"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""CodeData"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""The database from which the code is executed""" |
++|''"""CodeProject"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""ComboBox"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""CommandButton"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""Control"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Most Control types do not match between MSAccess and Base""" |
++|''"""Controls"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""CurrentData"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""The server database, usually SQL Server""" |
++|''"""CurrentProject"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""CustomControl"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""ActiveX control""" |
++|''"""DependencyInfo"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Dependency between database objects (e.g. in which queries is a table used ?)""" |
++|''"""DependencyObjects"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""DoCmd"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""See DoCmd Actions sheet""" |
++|''"""EmptyCell"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Form or Report design mode""" |
++|''"""Entities"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Entity"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to Microsoft Business Connectivity Services (BCS)""" |
++|''"""Form"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""TBC event handling""" |
++|''"""FormatCondition"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Most Control types do not match between MSAccess and Base""" |
++|''"""FormatConditions"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Forms"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""GroupLevel"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to Report object""" |
++|''"""Hyperlink"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Too specific""" |
++|''"""Image"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""ImportExportSpecification"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""See TransferXXX actions in DoCmd""" |
++|''"""ImportExportSpecifications"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Label"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""Line"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control, for Dialogs only""" |
++|''"""ListBox"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""MacroError"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""MSAccess macro's !""" |
++|''"""Module"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""VBA Code""" |
++|''"""Modules"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""NavigationButton"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""NavigationControl"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""ObjectFrame"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Pictures in forms""" |
++|''"""Operation"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to Microsoft Business Connectivity Services (BCS)""" |
++|''"""Operations"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""OptionButton"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""OptionGroup"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Page"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Only for Dialogs""" |
++|background-color:#ff3;''"""PageBreak"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""See Report object""" |
++|''"""Pages"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Printer"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""TBC""" |
++|''"""Printers"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""Properties"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Rectangle"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No such objects in Base Forms""" |
++|''"""Reference"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Windows specific""" |
++|''"""References"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Report"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Reports"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X | |
++|''"""ReturnVar"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""MSAccess macro's specific""" |
++|''"""ReturnVars"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Screen"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""To manage active window""" |
++|''"""Section"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""To manage headers, footers, pages of a form""" |
++|''"""SharedResource"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Microsoft Office shared resources""" |
++|''"""SharedResources"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SmartTag"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Microsoft Office specific""" |
++|''"""SmartTagAction"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SmartTagActions"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SmartTagProperties"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SmartTagProperty"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SmartTags"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""SubForm"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""TBC event handling""" |
++|''"""TabControl"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Most Control types do not match between MSAccess and Base""" |
++|''"""TempVar"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""To store "Global" variables accessible from any document""" |
++|''"""TempVars"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""TextBox"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Inherited from Control""" |
++|''"""ToggleButton"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""WebBrowserControl"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Web frame in form""" |
++|''"""WebService"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to Microsoft Business Connectivity Services (BCS)""" |
++|''"""WebServices"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""WSParameter"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""WSParameters"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++!~DataAccess objects
++| !OBJECTS |>|>|>|>| ''__FUNCTIONALITY__'' |>|>|>|background-color:#eee; ''__IMPLEMENTATION__'' | !Comments |
++|~| !Done | !Could be improved | !Very nice to have | !Nice to have | !Not applicable | !Out of Reach | !Complex | !Average | !Easy |~|
++|''"""ComplexType"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""For multi-valued fields""" |
++|''"""Connection"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Confused with Database object""" |
++|''"""Connections"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Connections of a workspace""" |
++|''"""Container"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Useless generic object""" |
++|''"""Containers"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Database"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""RunSQL has been preferred to Execute method""" |
++|background-color:#ff3;''"""Databases"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Manage collection of all databases opened during a LibO/AOO session""" |
++|''"""DBEngine"""'' |  |  |  | X |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Database administration""" |
++|''"""Document"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""Documents"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Error"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Database errors management""" |
++|''"""Errors"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Field"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""See Relation object""" |
++|''"""Field2"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""For multi-valued fields""" |
++|''"""Fields"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Index"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Description of table indexes"""<br />"""Fields collection to be derived""" |
++|background-color:#ff3;''"""Indexes"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Parameter"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""To manage parameter queries""" |
++|background-color:#ff3;''"""Parameters"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  | |
++|''"""Properties"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""MSAccess supports user-defined properties for Database, TableDef, QueryDef and Index objects""" |
++|''"""Property"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""QueryDef"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""QueryDefs"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""Creation of temporary queries could be useful bt strongly depend on RDBMS""" |
++|''"""Recordset"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Recordset2"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""For multi-valued fields""" |
++|''"""Recordsets"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Not very useful""" |
++|background-color:#ff3;''"""Relation"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Relations"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  | |
++|''"""TableDef"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""TableDefs"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Workspace"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Transaction management and data security""" |
++|''"""Workspaces"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++!~DoCmd Actions
++| !ACTIONS |>|>|>|>| ''__FUNCTIONALITY__'' |>|>|>|background-color:#eee; ''__IMPLEMENTATION__'' | !Comments |
++|~| !Done | !Could be improved | !Very nice to have | !Nice to have | !Not applicable | !Out of Reach | !Complex | !Average | !Easy |~|
++|''"""AddMenu"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Menus are static in LibO/AOO"""<br />"""(except in shortcut menus)""" |
++|''"""ApplyFilter"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by the Filter and FilterOn properties for Forms"""<br />"""Applicable to table/query datasheet views""" |
++|''"""Beep"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Standard in LibO/AOO Basic""" |
++|''"""BrowseTo"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Browse thru forms and reports displayed in a tabbed interface""" |
++|''"""CancelEvent"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Exit Sub in procedure invoked by event""" |
++|''"""ClearMacroError"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Close"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""mClose i.o. Close""" |
++|background-color:#ff3;''"""CloseDatabase"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |"""Easy to reproduce with"""<br />"""SelectObject(acDatabaseWindow)"""<br />"""RunCommand("acCmdClose")""" |
++|''"""CopyDatabaseFile"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Copy database to server""" |
++|''"""CopyObject"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Only tables and queries"""<br />"""Between different databases, even from different RDBMS""" |
++|background-color:#ff3;''"""DeleteObject"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee; X |"""Replaceable by Delete method applied on TableDef/QueryDef objects""" |
++|''"""DoMenuItem"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Yet obsolete in MSAccess""" |
++|''"""Echo"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Hide or show the results of a macro while it runs""" |
++|''"""FindNext"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Limited to a grid control, very slow""" |
++|''"""FindRecord"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |~|
++|''"""GoToControl"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by SetFocus""" |
++|''"""GoToPage"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Yet obsolete in MSAccess""" |
++|''"""GoToRecord"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Enriched with subforms""" |
++|''"""Hourglass"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""SystemPointer interface not at application level in LibO/AOO""" |
++|''"""LockNavigationPane"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No navigation pane in LibO/AOO""" |
++|''"""Maximize"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""Minimize"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""MoveSize"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""NavigateTo"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No navigation pane in LibO/AOO""" |
++|''"""OpenDataAccessPage"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No data access pages in LibO/AOO""" |
++|background-color:#ff3;''"""OpenDiagram"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |"""Easy to reproduce with"""<br />"""SelectObject(acDatabaseWindow)"""<br />"""RunCommand(acCmdShowAllRelationships)"""<br />"""1 diagram by database !""" |
++|''"""OpenForm"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""The OpenArgs argument is (almost) meaningless""" |
++|''"""OpenFunction"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Function in SQL Server""" |
++|''"""OpenModule"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Access2Base not intended to manage interaction with Basic IDE""" |
++|''"""OpenQuery"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""The DataMode argument is ignored""" |
++|''"""OpenReport"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Filters, etc. are ignored.""" |
++|''"""OpenStoredProcedure"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Database specific""" |
++|''"""OpenTable"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""The DataMode argument is ignored""" |
++|''"""OpenView"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Views are seen as tables""" |
++|''"""OutputTo"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Supported output formats are different"""<br />"""TemplateFile, Encoding and OutputQuality arguments are ignored""" |
++|background-color:#ff3;''"""PrintOut"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Maybe with Print menu command ??""" |
++|''"""Quit"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|''"""RefreshRecord"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by the Refresh method""" |
++|background-color:#ff3;''"""Rename"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""Rename forms, querries, tables and reports""" |
++|''"""RepaintObject"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Yet obsolete in MSAccess""" |
++|''"""Requery"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by the Requery method""" |
++|background-color:#ff3;''"""Restore"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |"""Probably solved with IsMaximized=False tbc""" |
++|''"""RunCommand"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Where to find their arguments ??"""<br />"""VBA commands list derived from MSAccess 2003""" |
++|''"""RunDataMacro"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No concept of DataMacros in LibO/AOO""" |
++|''"""RunMacro"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""No concept of Macros in LibO/AOO""" |
++|''"""RunSavedImportExport"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Let's try TransferXXX first""" |
++|''"""RunSQL"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""Has dbSQLPassThrough option"""<br />"""Extended to database objects"""<br />"""UseTranasction argument not supported""" |
++|''"""Save"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Design views of Forms or Reports are not supported"""<br />"""Easily replaced by RunCommand(acCmdSave)""" |
++|''"""SearchForRecord"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |""""Where" parser ?""" |
++|''"""SelectObject"""'' | X | X |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""InNavigationPane not implemented""" |
++|''"""SendObject"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""TemplateFile argument ignored""" |
++|''"""SetDisplayedCategories"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Linked to navigation pane""" |
++|''"""SetFilter"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by the Filter and FilterOn properties for Forms"""<br />"""Doable for table/query datasheet views ?""" |
++|''"""SetMenuItem"""'' |  |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Yet obsolete in MSAccess""" |
++|''"""SetOrderBy"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Better replaced by the OrderBy and OrderByOn properties for Forms"""<br />"""Applicable to table/query datasheet views""" |
++|''"""SetParameter"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to (data)macros""" |
++|''"""SetProperty"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Much broader scope in Access2Base""" |
++|''"""SetWarnings"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to system messages""" |
++|''"""ShowAllRecords"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""ShowToolbar"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""Toolbars are static on LibO/AOO""" |
++|''"""SingleStep"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Related to (data)macros""" |
++|''"""TransferDatabase"""'' |  |  | X |  |  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Copy objects (forms, queries, tables, ...) between databases""" |
++|''"""TransferSharePointList"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""TransferSpreadsheet"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Calc only""" |
++|''"""TransferSQLDatabase"""'' |  |  |  |  | X |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |background-color:#eee;  |"""Copy full database w/ or wo/ data""" |
++|background-color:#ff3;''"""TransferText"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Fixed + variable length; Schema.ini file parser""" |
++!Other topics
++| !ACTIONS |>|>|>|>| ''__FUNCTIONALITY__'' |>|>|>|background-color:#eee; ''__IMPLEMENTATION__'' | !Comments |
++|~| !Done | !Could be improved | !Very nice to have | !Nice to have | !Not applicable | !Out of Reach | !Complex | !Average | !Easy |~|
++|''"""On properties"""'' | X |  |  |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""Assign programmatically events to macros""" |
++|background-color:#ff3;''"""Switchboard"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  |"""To be completely redesigned:"""<br />"""- to avoid use of table (only 1 database in Base ... !)"""<br />"""- Use of either (language-neutral) dialog box or shortcut menus""" |
++|background-color:#ff3;''"""Shortcut menus"""'' |  |  | X |  |  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |background-color:#eee;  | |
++|background-color:#ff3;''"""Error handling"""'' |  |  |  | X |  |background-color:#eee;  |background-color:#eee;  |background-color:#eee; X |background-color:#eee;  |"""Process A2B errors in user code""" |
++
++
++
[[Software Version: 6.2.0|ReleaseNotes]]
++[[Home|Home]]
++<<search>>
++[[Index|Full Index]]
++[[Getting started|Install]]
++[[The object model|Object Model]]
++[[Tutorial]]
++<<tagsTree Menu>>
++[[Thanks|Thanks]]
++[[Contact]]
++<<toggleSideBar "" "Toggle side bar" hide>>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Maximize// action maximizes the window containing the [[Form]] having the focus.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]Maximize()}}}
++!!!Remarks
++*The //Maximize// action is usually preceded by a [[SelectObject]] action or by a  [[SetFocus]] method applied on the targeted //form//.
++*//Maximize// returns {{{True}}} if the action was successful, {{{False}}} otherwise.
++!!!Error messages
++|No active form or control found |
++!!!See also
++[[Minimize]]
++[[SelectObject]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Maximize example">>
++
++
++
Set focus on targeted form and maximize it
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	ofForm.SetFocus
++	Maximize()			'	... or Minimize() ...
++	MsgBox ofForm.Width
++//}}}
++
++
++

++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Minimize// action minimizes the window containing the [[Form]] having the focus.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]Minimize()}}}
++!!!Remarks
++*The //Minimize// action is usually preceded by a [[SelectObject]] action or by a  [[SetFocus]] method applied on the targeted //form//.
++*//Minimize// returns {{{True}}} if the action was successful, {{{False}}} otherwise.
++!!!Error messages
++|No active form or control found |
++!!!See also
++[[Maximize]]
++[[SelectObject]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Maximize example">>	
++
++
++
(Q) Is it possible to mix calls to the //~Access2Base// API and to the //UNO// API in the same code ?
++
++(R) Yes, this is by the way exactly what //~Access2Base// does internally. Additionally most [[Access2Base objects|Object Model]] provide entries to useful //UNO// objects.
++
++!!!Documentation
++Next objects have within their properties one or more of them qualified as "UNO". Have a look at:
++*[[Database]]
++*[[Form]]
++*[[Control]] with the - very useful - //~ControlModel// and //~ControlView// properties
++*[[SubForm]]
++*[[Recordset]]
++*[[Field]] with the //Column// property
++!!!Example 1
++To get the character surrounding table and fieldnames in SQL statements for the current database:
++//{{{
++	MsgBox CurrentDb.MetaData.IdentifierQuoteString
++//}}}
++[[CurrentDb]] returns the current database object making its //metadata// property available.
++!!!Example 2
++Next function (inspired by a code snippet from [[XRay|http://bernard.marcelly.perso.sfr.fr/index2.html]]) returns the nature of a //UNO// object:
++//{{{
++Public Function getUNOTypeName(pvObject As Variant) As String
++' Return the symbolic name of the pvObject (UNO-object) type
++' Code-snippet from XRAY
++
++Dim oService As Object, vClass as Variant, sType As String
++	_getUNOTypeName = ""
++	On Local Error Resume Next
++	sType = pvObject.getImplementationName()
++	If sType = "" Then
++		oService = CreateUnoService("com.sun.star.reflection.CoreReflection")
++		vClass = oService.getType(pvObject)
++		If vClass.TypeClass = com.sun.star.uno.TypeClass.STRUCT  Then
++			getUNOTypeName = vClass.Name
++		End If
++		oService.Dispose()
++	End If
++	
++	getUNOTypeName = sType
++
++End Function	'	getUNOTypeName
++//}}}
++Next code will probably display //com.sun.star.comp.forms.~ODatabaseForm//
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("Orders_Browse")
++	MsgBox getUNOTypeName(ofForm.DatabaseForm)
++//}}}
++!!!Example 3
++To apply a font attribute that is not implemented within the //~Access2Base// API:
++//{{{
++Dim ocControl As Object
++	Set ocControl = Forms("Orders_Browse").Controls("txtCustomerID")
++	ocControl.ControlModel.FontStrikeout = com.sun.star.awt.FontStrikeout.DOUBLE
++//}}}
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Prerequisite |
++|Snippets |||||Form ~Orders_Browse must be open before running examples 2 and 3. |
++
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Module// object represents a module containing a Basic script. It might represent either a standard module or a class module.
++!!!Function returning a module object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Application]] |[[AllModules]] | [[Collection]] | Integer or String |{{{Application.AllModules("myModule")}}} returns an object corresponding with the {{{myModule}}} module stored in the current document |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[CountOfDeclarationLines]] || Y |Indicates the number of lines of code in the Declarations section of the module. |
++|[[CountOfLines]] || Y |Indicates the number of lines of code in the module. |
++|[[Lines]] || Y |Returns a string containing the contents of a specified line or lines in a module. |
++|[[Name]] || Y |Specifies the real name of the module |
++|[[ObjectType]] || Y |Returns "MODULE" |
++|[[ProcBodyLine]] || Y |Returns the number of the line at which the body of a specified procedure begins in the module. |
++|[[ProcCountLines]] || Y |Returns the number of lines in a specified procedure in the module. |
++|[[ProcOfLine]] || Y |Returns the name of the procedure that contains a specified line in the module. |
++|[[ProcStartLine]] || Y |Returns a value identifying the line at which a specified procedure begins in the module. |
++|[[Type]] || Y |Indicates whether a module is a standard module or a class module. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[Find]] | string to find | Boolean |Return True if the string was found. Other arguments contain its position (line and column). |
++!!!What does return the //Name// property of a  module ?
++To manage potential homonyms among libraries, the ''name'' of a module consists in 3 components:
++//{{{
++	SCOPE.LIBRARY.MODULE
++//}}}
++*The //SCOPE// is either
++**''{{{GLOBAL}}}'' grouping both the ''~LibreOffice/~OpenOffice Macros and Dialogs'' and the ''My Macros and Dialogs'' catalogs of libraries.
++**''{{{DOCUMENT}}}'' grouping the libraries stored in the current document.
++*The //LIBRARY// component is the name of the library. It is often equal to "''Standard''".
++!!!See also
++[[AllModules]]
++!!!Examples
++<<tiddler "Module example">>
++
++
++
Query the properties of a Basic module
++//{{{
++Const cstModule = "myModule"
++Const cstProc = "mySub"
++Const vbext_pk_Proc = 0			'	A Sub or Function procedure
++Const cstStringToFind = "some string"
++
++Dim oModule As Object, sProc As String, iProcType As Integer
++Dim vStartLine As Variant, vStartColumn As Variant, vEndLine As Variant, vEndColumn As Variant
++
++	Set oModule = Application.AllModules(cstModule)
++	With oModule
++		DebugPrint "Name = " & .Name
++		DebugPrint "# of lines = " & .CountOfLines
++		DebugPrint "# of declaration lines = " & .CountOfdeclarationLines
++		DebugPrint "Lines 26 to 31 = " & .Lines(26, 6)
++		DebugPrint "# of lines in proc " & cstProc & " = " & .ProcCountLines(cstProc, vbext_pk_Proc)
++		DebugPrint "Start line in proc " & cstProc & " = " & .ProcStartLine(cstProc, vbext_pk_Proc)
++		DebugPrint "Start body line in proc " & cstProc & " = " & .ProcBodyLine(cstProc, vbext_pk_Proc)
++		'	Line 35  is located within procedure sProc (of type iProcType)
++		sProc = .ProcOfLine(35, iProcType)
++		'	Arguments are left uninitialized to consider the whole module
++		If .Find(cstStringToFind, vStartLine, vStartColumn, vEndLine, vEndColumn) Then DebugPrint cstStringToFind & " found on line " & vStartLine
++	End With
++	TraceConsole()
++//}}}
++
++
++
The //Move// method moves the specified object to the coordinates specified by the argument values.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |The representation of an //~OpenOffice/~LibreOffice// database form |
++|[[Dialog]] |The representation of a Basic dialog |
++!!!Syntax
++//form//.{{{Move([}}}//Left//{{{], [}}}//Top//{{{], [}}}//Width//{{{], [}}}//Height//{{{])}}}
++//dialog//.{{{Move([}}}//Left//{{{], [}}}//Top//{{{], [}}}//Width//{{{], [}}}//Height//{{{])}}}
++| !Argument | !Type | !Description | !Returned value |
++| form |[[Form object|Form]] |Form to be moved |//True// if success. |
++| dialog |[[Dialog object|Dialog]] |Dialog to be moved |~|
++| Left | Integer<br />Long |The screen position for the left edge of the form relative to the left edge of the screen |~|
++| Top | Integer<br />Long |The screen position for the top edge of the form relative to the top edge of the screen |~|
++| Width | Integer<br />Long |The desired width of the form |~|
++| Height | Integer<br />Long |The desired height of the form |~|
++!!!Remarks
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[Height]]
++[[MoveSize]]
++[[Width]]
++!!!Example
++<<tiddler "Move example">>
++
++
++
The //Move//, //~MoveFirst//, //~MoveLast//, //~MoveNext// and //~MovePrevious// methods move the cursor either
++*to a record specified by its position
++*or to the first, last, next, or previous record
++in a specified [[Recordset]] object and make that record the current record.
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or a SQL statement. |
++!!!Syntax
++//recordset//{{{.Move(}}}//rows, startbookmark//{{{)}}}
++//recordset//{{{.MoveFirst}}}
++//recordset//{{{.MoveLast}}}
++//recordset//{{{.MoveNext}}}
++//recordset//{{{.MovePrevious}}}
++| !Argument | !Optional | !Type | !Description | !Returned value |
++|recordset || [[Recordset object|Recordset]] |An open recordset |//True// if success. |
++|rows || Long |Specifies the number of rows the position will move.<br />If rows is greater than 0, the position is moved forward (toward the end of the file).<br />If rows is less than 0, the position is moved backward (toward the beginning of the file). |~|
++|startbookmark | Y | Variant |Value identifying a bookmark. If you specify //startbookmark//, the //move// begins relative to this bookmark. Otherwise, //move// begins from the current record. |~|
++!!!Remarks
++*''Caution'' If you edit the current record, be sure you use the [[Update]] method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.
++*When using the //Move// method:
++**If you use //Move// to position the current record pointer before the first record, the current record pointer moves to the beginning of the file. If the //Recordset// contains no records and its [[BOF|BOF, EOF]] property is {{{True}}}, using this method to move backward causes an error.
++**If you use //Move// to position the current record pointer after the last record, the current record pointer position moves to the end of the file. If the //Recordset// contains no records and its [[EOF|BOF, EOF]] property is {{{True}}}, then using this method to move forward causes an error.
++**If either the [[BOF|BOF, EOF]] or [[EOF|BOF, EOF]] property is {{{True}}} and you attempt to use the //Move// method without a valid bookmark, a run-time error occurs.
++*When using //~MoveFirst, ~MoveLast, ~MoveNext// or //~MovePrevious// methods
++**When you open a //Recordset//, the first record is current and the [[BOF|BOF, EOF]] property is {{{False}}}. If the //Recordset// contains no records, the [[BOF|BOF, EOF]] property is {{{True}}}, and there is no current record.
++**If the first or last record is already current when you use //~MoveFirst// or //~MoveLast//, the current record doesn't change.
++**If you use //~MovePrevious// when the first record is current, the [[BOF|BOF, EOF]] property is {{{True}}}, and there is no current record. If you use //~MovePrevious// again, an error occurs, and [[BOF|BOF, EOF]] remains {{{True}}}.
++**If you use //~MoveNext// when the last record is current, the [[EOF|BOF, EOF]] property is {{{True}}}, and there is no current record. If you use //~MoveNext// again, an error occurs, and [[EOF|BOF, EOF]] remains {{{True}}}.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Action rejected in a forward-only or not bookmarkable recordset |
++|Recordset delivered no data. Action on current record rejected |
++|Recordset has been closed. Recordset action rejected |
++|Current record out of range |
++!!!See also
++[[Bookmark]]
++[[Bookmarkable]]
++[[OpenRecordset]]
++!!!Example
++<<tiddler "OpenRecordset example">>
++
++
++
Move a form to new left-top coordinates and resize it ...
++//{{{
++Dim ofForm As Object
++	Set ofForm = Forms("myForm")
++	ofForm.Move(100, 200, 500, 200)
++//}}}
++
++
++
(Q) Can I move easily items from one listbox to another ?
++
++(R) Let's implement the classical method of moving either the selected items or all the items from one listbox to another and reciprocally.
++
++A first listbox is loaded from the database. The second one is empty.
++The goal is to load the second listbox with a selection of items from the first one, thanks to 4 buttons:
++*{{{>}}} and {{{<}}} move all selected items from one listbox to the other one and remove them from the original one.
++*{{{>>}}} and {{{<<}}} empty the original box and move all its items to the other one.
++!!!Solution
++It consists in putting on a form:
++*2 [[listboxes|ListBox]] called //~LeftList// and //~RightList//
++*4 buttons called //~MoveOneRight// ({{{>}}}), //~MoveAllRight// ({{{>>}}}), //~MoveOneLeft// ({{{<}}}), //~MoveAllLeft// ({{{<<}}})
++The code associated with the events is mainly a matter of arrays redimensioning, trimming and housekeeping. Both listboxes must be reinitialized from the event macro after each button activation to remain synchronized.
++
++Let's assume next table:
++<<tiddler "ProductsTable">>
++The //~LeftList// box is loaded initially with the //~ProductName// field of the //Products// table.
++
++1. Associate next code with the //When loading// form event: after initial loading the //~LeftList// control will be dissociated from its bound field. Additionally 3 constants are defined at module level.
++//{{{
++Const cstForm		= "Products_FastSelect"
++Const cstLeftList	= "LeftList"
++Const cstRightList	= "RightList"
++
++Sub InitFirstList(poEvent As Object)
++'Activated when form opened
++Dim ocList As Object, sSource As String
++
++	Set ocList = Forms(cstForm).Controls(cstLeftList)
++	sSource = Join(ocList.ItemData, ";")
++	ocList.RowSourceType = com.sun.star.form.ListSourceType.VALUELIST	'	Cancel link with bound field
++	ocList.RowSource = sSource
++End Sub
++//}}}
++
++2. Associate the //Execute action// event of each of the 4 buttons with next macro:
++//{{{
++Sub MoveItems(poEvent As Object)
++Dim oEvent As Object, ocLeftList As Object, ocRightList As Object
++Dim i As Integer, vLeft() As Variant, vRight() As Variant, vSelected() As Variant
++Dim iMaxDim As Integer, iLeftSize As Integer, iRightSize As Integer, sSource As String
++	Set oEvent = Events(poEvent)
++	Set ocLeftList = Forms(cstForm).Controls(cstLeftList)
++	Set ocRightList = Forms(cstForm).Controls(cstRightList)
++	'	Initial load of arrays
++	vLeft = ocLeftList.ItemData
++	vRight = ocRightList.ItemData
++	iLeftSize = UBound(vLeft)
++	iRightSize = UBound(vRight)
++	iMaxDim = iLeftSize + 1 + iRightSize + 1
++	ReDim Preserve vLeft(iMaxDim)
++	ReDim Preserve vRight(iMaxDim)
++
++	Select Case oEvent.Source.Name
++		Case "MoveOneRight"		'	>
++			vSelected = ocLeftList.Selected
++			For i = 0 To iLeftSize
++				If vSelected(i) Then
++					iRightSize = iRightSize + 1
++					vRight(iRightSize) = vLeft(i)
++					vLeft(i) = ""
++				End If
++			Next i
++		Case "MoveAllRight"		'	>>
++			For i = 0 To iLeftSize
++				iRightSize = iRightSize + 1
++				vRight(iRightSize) = vLeft(i)
++				vLeft(i) = ""
++			Next i
++		Case "MoveOneLeft"		'	<
++			vSelected = ocRightList.Selected
++			For i = 0 To iRightSize
++				If vSelected(i) Then
++					iLeftSize = iLeftSize + 1
++					vLeft(iLeftSize) = vRight(i)
++					vRight(i) = ""
++				End If
++			Next i
++		Case "MoveAllLeft"		'	<<
++			For i = 0 To iRightSize
++				iLeftSize = iLeftSize + 1
++				vLeft(iLeftSize) = vRight(i)
++				vRight(i) = ""
++			Next i
++	End Select
++
++	'Reload listboxes
++	sSource = ""
++	For i = 0 To iLeftSize
++		If vLeft(i) <> "" Then sSource = sSource & vLeft(i) & ";"
++	Next i
++	If Len(sSource) = 0 Then ocLeftList.RowSource = "" Else ocLeftList.RowSource = Left(sSource, Len(sSource) - 1)	'	Remove last ";"
++	sSource = ""
++	For i = 0 To iRightSize
++		If vRight(i) <> "" Then sSource = sSource & vRight(i) & ";"
++	Next i
++	If Len(sSource) = 0 Then ocRightList.RowSource = "" Else ocRightList.RowSource = Left(sSource, Len(sSource) - 1)'	Remove last ";"
++
++	'Deselect listboxes
++	For i = 0 To ocLeftList.ListCount - 1
++		setSelected(ocLeftList, False, i)
++	Next i	
++	For i = 0 To ocRightList.ListCount - 1
++		setSelected(ocRightList, False, i)
++	Next i	
++End Sub
++//}}}
++!!!See also
++[[ListBox]]
++[[ListCount]]
++[[RowSource]]
++[[RowSourceType]]
++[[Selected]]
++[[Event]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~FastSelect |~Products_FastSelect |When loading |~MoveOneRight<br />~MoveAllRight<br />~MoveOneLeft<br />~MoveAllLeft |Execute action ||
++
++
++
The //~MoveSize// action moves the active window to the coordinates specified by the argument values.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]MoveSize([}}}//Left//{{{], [}}}//Top//{{{], [}}}//Width//{{{], [}}}//Height//{{{])}}}
++| !Argument | !Optional | !Type | !Description | !Returned value |
++| Left | Yes |Integer<br />Long |The screen position for the left edge of the window relative to the left edge of the screen | True if success |
++| Top |~| Integer<br />Long |The screen position for the top edge of the window relative to the top edge of the screen |~|
++| Width |~| Integer<br />Long |The desired width of the window |~|
++| Height |~| Integer<br />Long |The desired height of the window |~|
++!!!Remarks
++*The action applies to the active window. A window may be made active with the [[SelectObject]] action.
++*The //~MoveSize// action is also applicable to the Basic IDE window or the database window. However it will ignore any window opened by another application than the one having called the //~MoveSize// action..
++*The //~MoveSize// action applies to [[forms|Form]] or [[dialogs|Dialog]] only.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[Height]]
++[[Move]]
++[[SelectObject]]
++[[Width]]
++!!!Example
++<<tiddler "MoveSize example">>
++
++
++
Select an open form and resize it
++//{{{
++	SelectObject(acForm, "myForm")
++	MoveSize 100, 200, 500, 200
++//}}}
++
++
++
You can use the ~MultiSelect property to specify whether a user can make multiple selections in a list box on a form
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ListBox]] | [[ListBox]] | [[ListBox]] |A listbox on an open form or dialog, or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.MultiSelect}}}
++//control//{{{.MultiSelect}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++In ~MSAccess VBA the //~MultiSelect// property returns an integer value.
++!!!Error messages
++|Property '~MultiSelect' not applicable in this context |
++|Value '...' is invalid for property '~MultiSelect' |
++!!!See also
++[[ItemData]]
++[[ListCount]]
++[[ListIndex]]
++[[RowSource]]
++[[RowSourceType]]
++[[Selected]]
++!!!Example
++*Combo box
++<<tiddler "ComboBox example">>
++*List box
++<<tiddler "ListBox example">>
++
++
++
(Q) I have a listbox control (might be MultiSelect) on my form. I want to pass the selected items to select the data listed in a gridcontrol on the same form. How do I do this?
++
++(R) The criteria must be built as a character string and passed to the [[RecordSource]] of the form.
++
++Assuming next tables:
++<<tiddler "SuppliersTable">>
++<<tiddler "ProductsTable">>
++and a form
++*bound to the Table "Products"
++*containing an unbound listbox having as data source
++//{{{
++		SELECT "CompanyName" FROM "Suppliers" ORDER BY "CompanyName" ASC
++//}}}
++!!!(1) Solution for ~MultiSelect = No listbox
++We make the //Changed// event of the listbox control triggering next code:
++//{{{
++Sub SyncFormListBoxMono(poEvent As Object)
++
++Dim oEvent As Object, ocList As Object, oForm As Object
++Dim sSupplier As String, lSupplier As Long
++
++	Set oEvent = Events(poEvent)
++	Set ocList = oEvent.Source				'	Retrieve listbox object
++	Set oForm = ocList.Parent				'	Retrieve parent form
++	sSupplier = Join(Split(ocList.Value, "'"), "''")	'	For the case the company name contains quotes
++	lSupplier = DLookup("[SupplierID]", "[Suppliers]", "[CompanyName]='" & sSupplier & "'")
++	oForm.RecordSource = "SELECT [SupplierID], [ProductID], [ProductName], [UnitPrice] FROM [Products] WHERE [SupplierID]=" & lSupplier
++
++End Sub
++//}}}
++This will produce the requested effect.
++
++!!!(2) Solution for ~MultiSelect = Yes listbox
++A first variant is when the listbox is defined with ~MultiSelection = Yes
++//{{{
++Sub SyncFormListBoxMulti(poEvent As Object)
++
++Dim oEvent As Object, ocList As Object, oForm As Object
++Dim sSupplier As String, lSupplier As Long, i As Integer, sSQL As String
++Const cstCriteria = " OR [SupplierID]="
++
++	Set oEvent = Events(poEvent)
++	Set ocList = oEvent.Source				'	Retrieve listbox object
++	Set oForm = ocList.Parent				'	Retrieve parent form
++	sSQL = "SELECT [SupplierID], [ProductID], [ProductName], [UnitPrice] FROM [Products] WHERE [SupplierID]="
++	For i = 0 To UBound(oclist.Selected)
++		If ocList.Selected(i) Then
++			sSupplier = Join(Split(ocList.ItemData(i), "'"), "''")	'	For the case the company name contains quotes
++			lSupplier = DLookup("[SupplierID]", "[Suppliers]", "[CompanyName]='" & sSupplier & "'")
++			sSQL = sSQL & lSupplier & cstCriteria
++		End If
++	Next i
++	oForm.RecordSource = Left(sSQL, Len(sSQL) - Len(cstCriteria))	'	Trim SQL phrase
++
++End Sub
++//}}}
++
++!!!(3) Solution with form filtering
++Another variant is to use a filter. This lets the user the freedom to cancel the filtering option or to filter the data independently from the listbox. This freedom can be desired by the developer or not. ~MultiSelection is presumed False in the example:
++//{{{
++Sub SyncFormListBoxFilter(poEvent As Object)
++
++Dim oEvent As Object, ocList As Object, oForm As Object
++Dim sSupplier As String, lSupplier As Long
++
++	Set oEvent = Events(poEvent)
++	Set ocList = oEvent.Source				'	Retrieve listbox object
++	Set oForm = ocList.Parent				'	Retrieve parent form
++	sSupplier = Join(Split(ocList.Value, "'"), "''")	'	For the case the company name contains quotes
++	lSupplier = DLookup("[SupplierID]", "[Suppliers]", "[CompanyName]='" & sSupplier & "'")
++	oForm.Filter = "[SupplierID]=" & lSupplier
++	oForm.FilterOn = True
++
++End Sub
++//}}}
++!!!See also
++[[getObject]]
++[[Events Handler]]
++[[Filter]]
++[[Parent]]
++[[RecordSource]]
++!!!Refer to ...
++| !Solution | !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++| (1) |~ListBox |~Products_ListBoxFilter ||~SuppliersListBoxMono |Changed ||
++| (2) |~|~|~|~SuppliersListBoxMulti |~|~|
++
++
++
The //Name// property specifies the text string corresponding to the name of an object.
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBar]] |A tool-, menu- or statusbar |
++|[[Control]] |A control of an open form |
++|[[Database]] |A database the application is currently connected to |
++|[[Dialog]] |A dialog, active or not |
++|[[Field]] |A field within a //~TableDef//, a //~QueryDef// or a //Recordset// |
++|[[Form]] |A form, open or not, including its path name, if any |
++|[[Module]] |A Basic script |
++|[[OptionGroup]] |A group of radio buttons |
++|[[Property]] |A property of an object |
++|[[QueryDef]] |A query definition |
++|[[Recordset]] |A set of records related to a table, a query or a SQL statement |
++|[[SubForm]] |A subform of an open form |
++|[[TableDef]] |A table definition |
++|[[TempVar]] |A temporary variable |
++!!!Syntax
++//commandbar//{{{.Name}}}
++//control//{{{.Name}}}
++//database//{{{.Name}}}
++//dialog//{{{.Name}}}
++//form//{{{.Name}}}
++//module//{{{.Name}}}
++//optiongroup//{{{.Name}}}
++//property//{{{.Name}}}
++//querydef//{{{.Name}}}
++//recordset//{{{.Name}}}
++//subform//{{{.Name}}}
++//tabledef//{{{.Name}}}
++//tempvar//{{{.Name}}}
++!!!Returned values
++{{{String}}}
++!!!Remarks
++*The Name property is read-only.
++*When relevant the returned string contains the name of the object __as stored by ~LibreOffice/~OpenOffice Base__. In ~LibreOffice/~OpenOffice Base "myForm" is different from "MYFORM". At the opposite, in ~Access2Base, all references to a name as argument of a function are //''not case-sensitive''//.<br />Example: {{{Forms("myForm")}}} is identical to {{{Forms("MYFORM")}}}
++*The //Name// property of a recordset is artificially set by //~Access2Base//. See the [[Recordsets]] collection for more info.
++!!!Error messages
++!!!Example
++<<tiddler "Name example">>
++
++
++
Display exact name of the first open form
++Display all property names of that form
++//{{{
++Dim ofForm As Object, opProperty As Object, i As Integer
++	If Forms.Count > 0 Then
++		Set ofForm = Forms(0)
++		_Print ofForm.Name
++		For i = 0 To ofForm.Properties().Count - 1
++			Set opProperty = ofForm.Properties(i)
++			Print opProperty.Name,
++		Next i
++	End If
++	Print
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}}OO/~LibO Basic is a simple but still an object-oriented language. To know more about object-oriented programming in Basic, you can have a look at [[here|https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=58135]]
++To stay close to the syntax of the //~MSAccess// object model the implementation of ~Access2Base has been based on BASIC object classes.
++*Specific functions, sometimes called "Collections" will create instances of classes of type ''Form'', ''Subform'', ''Control'' or ''Database'', etc.
++*To use these instances in your own code, your local/global/... variables should be declared as being of type {{{Object}}}
++*The names of the ''properties'' and ''methods'' to be applied on those variables are identical in //~MSAccess// and in //~Access2Base//. Their arguments are identical as well. Note however that //~Access2Base// implements only a limited subset of the object model of //~MSAccess//. Note also that their semantics might differ from the original //~MSAccess// one. Read the current documentation carefully.
++*''Indirection'', i.e. accessing a property by its name given as a {{{string}}} argument, and ''introspection'', i.e. knowing which properties are available for any object, are supported for propertiesl.
++!The Object Model
++[img[The Access2Base object model|objectmodel.png]]
++!!Root classes
++| !Class | !Description | !Collections | !Properties | !Methods |
++|[[Application]] |The root class |[[AllDialogs]]<br />[[AllForms]]<br />[[AllModules]]<br />[[CommandBars]]<br />[[Events]]<br />[[Forms]]<br />[[TempVars]] |[[CurrentUser]]<br />[[HtmlEncode]]<br />[[ProductCode]]<br />[[Version]] |[[CurrentDb]]<br />[[DAvg]]<br />[[DCount]]<br />[[DLookup]]<br />[[DMin, DMax]]<br />[[DStDev, DStDevP]]<br />[[DSum]]<br />[[DVar, DVarP]]<br />[[OpenConnection]]<br />[[OpenDatabase]] |
++|[[DoCmd]] |A secondary root class from which a number of commands can be run ||[[GetHiddenAttribute]] |[[ApplyFilter]]<br />[[Close]]<br />[[CopyObject]]<br />[[FindNext]]<br />[[FindRecord]]<br />[[GoToControl]]<br />[[GoToRecord]]<br />[[Maximize]]<br />[[Minimize]]<br />[[MoveSize]]<br />[[OpenForm]]<br />[[OpenQuery]]<br />[[OpenReport]]<br />[[OpenSQL]]<br />[[OpenTable]]<br />[[OutputTo]]<br />[[Quit]]<br />[[RunApp]]<br />[[RunCommand]]<br />[[RunSQL]]<br />[[SelectObject]]<br />[[SendObject]]<br />[[SetHiddenAttribute]]<br />[[ShowAllRecords]]<br />[[SysCmd]] |
++|[[Collection]] |An array of objects accessible via their index or their name ||[[Count]]<br />[[Item]]<br />[[ObjectType]] |[[Add]]<br />[[Delete|Delete (table-query)]]<br />[[Remove]]<br />[[RemoveAll]] |
++!!Forms, dialogs, command bars and controls
++| !Class | !Description | !Collections | !Properties | !Methods |
++|[[Form]] |The representation of an //~OpenOffice/~LibreOffice// database form |[[Controls]]<br />[[OptionGroup|OptionGroup (Method)]]<br />[[Properties|Properties (collection)]] |[[AllowAdditions]]<br />[[AllowDeletions]]<br />[[AllowEdits]]<br />[[Bookmark]]<br />[[Caption]]<br />[[CurrentRecord]]<br />[[Filter]]<br />[[FilterOn]]<br />[[Height]]<br />[[IsLoaded]]<br />[[Name]]<br />[[ObjectType]]<br />[[On ... form events|On (form event)]]<br />[[OpenArgs]]<br />[[OrderBy]]<br />[[OrderByOn]]<br />[[Recordset|Recordset (property)]]<br />[[RecordSource]]<br />[[Visible]]<br />[[Width]] |[[Close]]<br />[[CurrentDb]]<br />[[Move]]<br />[[Refresh]]<br />[[Requery]]<br />[[SetFocus]] |
++|[[Dialog]] |The representation of a Basic dialog |[[Controls]]<br />[[OptionGroup|OptionGroup (Method)]]<br />[[Properties|Properties (collection)]] |[[Caption]]<br />[[Height]]<br />[[IsLoaded]]<br />[[Name]]<br />[[ObjectType]]<br />[[Visible]]<br />[[Width]] |[[Execute|Execute (dialog)]]<br />[[Move]]<br />[[Start]]<br />[[Terminate]] |
++|[[CommandBar]] |Identifies a toolbar, a menubar or the statusbar. |[[CommandBarControls]]<br />[[Controls]]<br />[[Properties|Properties (collection)]] |[[BuiltIn]]<br />[[Name]]<br />[[ObjectType]]<br />[[Visible]] |[[Reset]] |
++|[[Control]] |The representation of a control within a Form, a Dialog, a ~SubForm or an ~OptionGroup |[[Controls]]<br />[[Properties|Properties (collection)]] |[[BackColor]]<br />[[BorderColor]]<br />[[BorderStyle]]<br />[[Cancel]]<br />[[Caption]]<br />[[ControlSource]]<br />[[ControlTipText]]<br />[[ControlType]]<br />[[Count]]<br />[[Default]]<br />[[DefaultValue]]<br />[[Enabled]]<br />[[FontBold]]<br />[[FontItalic]]<br />[[FontName]]<br />[[FontSize]]<br />[[FontUnderline]]<br />[[FontWeight]]<br />[[ForeColor]]<br />[[Form|Form (subform)]]<br />[[Format]]<br />[[ItemData]]<br />[[ListCount]]<br />[[ListIndex]]<br />[[Locked]]<br />[[MultiSelect]]<br />[[Name]]<br />[[ObjectType]]<br />[[On ... control events|On (control event)]]<br />[[OptionValue]]<br />[[Parent]]<br />[[Picture]]<br />[[Required]]<br />[[RowSource]]<br />[[RowSourceType]]<br />[[Selected]]<br />[[SelLength]]<br />[[SelStart]]<br />[[SelText]]<br />[[SubType]]<br />[[TabIndex]]<br />[[TabStop]]<br />[[Tag]]<br />[[Text]]<br />[[TextAlign]]<br />[[TripleState]]<br />[[Value]]<br />[[Visible]] |[[AddItem]]<br />[[RemoveItem]]<br />[[Requery]]<br />[[SetFocus]] |
++|[[SubForm]] |Identifies a specific control which is a subform of a database form or another subform |[[Controls]]<br />[[OptionGroup|OptionGroup (Method)]]<br />[[Properties|Properties (collection)]] |[[AllowAdditions]]<br />[[AllowDeletions]]<br />[[AllowEdits]]<br />[[Filter]]<br />[[FilterOn]]<br />[[LinkChildFields]]<br />[[LinkMasterFields]]<br />[[Name]]<br />[[ObjectType]]<br />[[On ... form events|On (form event)]]<br />[[OrderBy]]<br />[[OrderByOn]]<br />[[Parent]]<br />[[Recordset|Recordset (property)]]<br />[[RecordSource]] |[[Refresh]]<br />[[Requery]] |
++|[[OptionGroup]] |Identifies a group of specific controls, i.e. radio buttons. |[[Controls]]<br />[[Properties|Properties (collection)]] |[[Count]]<br />[[Name]]<br />[[ObjectType]]<br />[[Value]] ||
++|[[CommandBarControl]] |Identifies a control within a ~CommandBar. |[[Execute|Execute (commandbarcontrol)]]<br />[[Properties|Properties (collection)]] |[[BeginGroup]]<br />[[BuiltIn]]<br />[[Caption]]<br />[[Index]]<br />[[ObjectType]]<br />[[OnAction]]<br />[[Parent]]<br />[[TooltipText]]<br />[[Type]]<br />[[Visible]] |
++!!Database access
++| !Class | !Description | !Collections | !Properties | !Methods |
++|[[Database]] |One of the databases to which the application is connected |[[Properties|Properties (collection)]]<br />[[TableDefs]]<br />[[QueryDefs]]<br />[[Recordsets]]|[[Connect]]<br />[[Name]]<br />[[ObjectType]]<br />[[Version]] |[[Close|Close (method)]]<br />[[CloseAllRecordsets]]<br />[[CreateQueryDef]]<br />[[DAvg]]<br />[[DCount]]<br />[[DLookup]]<br />[[DMin, DMax]]<br />[[DStDev, DStDevP]]<br />[[DSum]]<br />[[DVar, DVarP]]<br />[[OpenRecordset]] |
++|[[TableDef]] |The representation of a Table. |[[Fields]]<br />[[Properties|Properties (collection)]] |[[Name]]<br />[[ObjectType]] |[[OpenRecordset]] |
++|[[QueryDef]] |The representation of a Query. |[[Fields]]<br />[[Properties|Properties (collection)]] |[[Name]]<br />[[ObjectType]]<br />[[SQL]]<br />[[Type]] |[[Execute|Execute (query)]]<br />[[OpenRecordset]] |
++|[[Recordset]] |The representation of a set of records from a table, a query or a SQL statement. |[[Fields]]<br />[[Properties|Properties (collection)]] |[[AbsolutePosition]]<br />[[BOF|BOF, EOF]]<br />[[Bookmark]]<br />[[Bookmarkable]]<br />[[EditMode]]<br />[[EOF|BOF, EOF]]<br />[[Filter]]<br />[[Name]]<br />[[ObjectType]]<br />[[RecordCount]] |[[AddNew]]<br />[[CancelUpdate]]<br />[[Clone]]<br />[[Close|Close (method)]]<br />[[Delete]]<br />[[Edit]]<br />[[GetRows]]<br />[[Move|Move (recordset)]]<br />[[MoveFirst|Move (recordset)]]<br />[[MoveLast|Move (recordset)]]<br />[[MoveNext|Move (recordset)]]<br />[[MovePrevious|Move (recordset)]]<br />[[OpenRecordset]]<br />[[Update]] |
++|[[Field]] |The representation of a field of a table, a query or a recordset. |[[Properties|Properties (collection)]] |[[DataType]]<br />[[DataUpdatable]]<br />[[DbType|DataType]]<br />[[DefaultValue]]<br />[[Description]]<br />[[FieldSize]]<br />[[Name]]<br />[[ObjectType]]<br />[[Size]]<br />[[SourceField]]<br />[[SourceTable]]<br />[[TypeName|DataType]]<br />[[Value|Value (field)]] |[[AppendChunk]]<br />[[GetChunk]]<br />[[ReadAllBytes]]<br />[[ReadAllText]]<br />[[WriteAllBytes]]<br />[[WriteAllText]] |
++!!Other
++| !Class | !Description | !Collections | !Properties | !Methods |
++|[[Property]] |A name-value pair allowing objects introspection (see below) ||[[Name]]<br />[[ObjectType]]<br />[[Value]] ||
++|[[TempVar]] |The representation of a temporary variable ||[[Name]]<br />[[ObjectType]]<br />[[Value]] ||
++|[[Event|Events]] |A description of an occurred form, dialog or control event ||~ButtonLeft<br />~ButtonMiddle<br />~ButtonRight<br />~ClickCount<br />~ContextShortcut<br />~EventName<br />~EventSource<br />~EventType<br />~FocusChangeTemporary<br />~KeyAlt<br />~KeyChar<br />~KeyCode<br />~KeyCtrl<br />~KeyFunction<br />~KeyShift<br />[[ObjectType]]<br />Recommendation<br />~RowChangeAction<br />Source<br />~SubComponentName<br />~SubComponentType<br />~XPos<br />~YPos ||
++|[[Module]] |The representation of a Basic script ||[[CountOfDeclarationLines]]<br />[[CountOfLines]]<br />[[Lines]]<br />[[Name]]<br />[[ObjectType]]<br />[[ProcBodyLine]]<br />[[ProcCountLines]]<br />[[ProcOfLine]]<br />[[ProcStartLine]]<br />[[Type]] |[[Find]] |
++The object class is returned for all objects as a string by the [[ObjectType]] property.
++!Remark about the //Application// and //~DoCmd// classes
++The //Application// and //~DoCmd// classes may be instantiated only once. Their instance MUST be called {{{Application}}} and {{{DoCmd}}} respectively. In fact they are implemented as module names. 
++As an example, it is equivalent to write next statements:
++//{{{
++	DoCmd.OpenForm "anyform"
++//}}}
++or
++//{{{
++	OpenForm "anyform"
++//}}}
++This complies with the //~MSAccess// object model. Additionally this freedom solves potential homonymy issues between concurrent Basic libraries.
++!Collections - Functions returning objects
++Objects are created by the invocation of specific functions included in the API. In the calling procedure an object is defined as a variable of type //Object//.
++Example:
++//{{{
++Dim ofForm As Object			' Variant would also be correct
++	Set ofForm = AllForms("myForm")	' The Set verb is mandatory in MSAccess but optional in AOO/LibO Basic
++//}}}
++{{{ofForm}}} contains after execution the instance of an object of class Form.
++{{{AllForms}}} is called a [[collection|Collection]]. Individual members of a collection are reachable either by their index or by their name.
++!Properties
++!!!Property types
++Within an object class one can distinguish in the current documentation next 2 property types:
++| !Type of property | !Description |
++|UNO |The property refers to a UNO object that can be used from user macros to invoke directly alternative properties and methods to those supported by the //~Access2Base// API. |
++|Normal |Where it is really about in the //~Access2Base// software. Such a property complies with or is close to the //~MSAccess// object model. |
++!!!Property names
++The names of the properties are identical to their equivalent in //~MSAccess//.
++However
++*the semantics of the property might differ more or less,
++*their arguments might differ,
++*the returned values might be different.
++Read the documentation about each individual property for more info.
++!!!Get properties
++To get the value of a __normal__ property named "~MyProperty", write :
++{{indent{{{{vValue = myObject.MyProperty}}}
++Depending on the context an error message can be generated stopping the execution of the macro. The error message can be issued either by AOO/~LibO Basic or by the API.
++
++If the property is an array use :
++{{indent{{{{vValue = myObject.MyProperty(i)}}}
++!!!Set properties
++To set the value of a __normal__ property named "~MyProperty", use next syntax :
++{{indent{{{{myObject.MyProperty[(i)] = vValue}}}
++the optional argument being the index if the property returns an array.
++
++The macro will be stopped if the property setting failed.
++!!!Indirection
++To get the value of a __normal__ property of an object, one can write also:
++{{indent{{{{vValue = myObject.getProperty("MyProperty"[, i])}}}
++
++To set its value:
++{{indent{{{{myObject.setProperty("MyProperty", vValue[, i])}}}
++!!!Introspection
++Finally it is possible to get the value of ALL normal properties of an object with the //Properties// function as in next example:
++//{{{
++Dim ofForm As Object, i As Integer, oProperty As Object
++	Set ofForm = AllForms("myForm")
++	For i = 0 To ofForm.Properties().Count - 1
++		Set oProperty = ofForm.Properties(i)
++		Print oProperty.Name & " = " & oProperty.Value & " / ",
++	Next i
++	Print
++//}}}
++Additionally all objects have a {{{hasProperty}}} method indicating if the given property argument is applicable or not, like in:
++//{{{
++Dim ofForm As Object
++	Set ofForm = AllForms("myForm")
++	If ofForm.hasProperty("AllowEdits") Then
++		...
++	End If
++//}}}
++!Methods
++!!!Method names
++The names of the methods are identical to their equivalent in //~MSAccess//.
++However
++*when the name is a ''reserved word'' in AOO/~LibO Basic the name is preceded by a "m" (like in method). E.g. //mClose// replaces //Close//,
++*the semantics of the method might differ more or less,
++*the arguments might be different in number or in admitted values or value types.
++Read the documentation about each individual method for more info.
++!!!Syntax
++Example:
++//{{{
++Dim ofForm As Object
++	Set ofForm = AllForms("myForm")
++	ofForm.Move(100, 200)
++//}}}
++!Compatibility
++Existing programs written with //~Access2Base// in versions older than 0.9.0 ''will not run normally''. The invocation of properties and methods like in
++>{{{getPROPERTY(OBJECT)}}}
++>{{{setPROPERTY(OBJECT, }}}//value//{{{)}}}
++>{{{METHOD(OBJECT, }}}//arg1, ...//{{{)}}
++''is not supported anymore as from ~Access2Base 1.7.0''.
++
++
++
++
The //~ObjectType// property specifies the type of an [[object|Object Model]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Collection]] |A collection of objects |
++|[[CommandBar]] |A toolbar or a menu |
++|[[CommandBarControl]] |An element within a ~CommandBar |
++|[[Control]] |A control of an open form |
++|[[Database]] |The current database object |
++|[[Dialog]] |A dialog, active or not |
++|[[Event]] |An event object triggered by a form or control event |
++|[[Field]] |A field of a table, a query or a recordset |
++|[[Form]] |A form, open or not |
++|[[Module]] |A Basic script |
++|[[OptionGroup]] |A group of radio buttons |
++|[[Property]] |A property of an object |
++|[[QueryDef]] |A stored query definition |
++|[[Recordset]] |A set of records related to a table, a query or a SQL statement |
++|[[SubForm]] |A subform of an open form |
++|[[TableDef]] |A stored table definition |
++|[[TempVar]] |A temporary variable |
++!!!Syntax and returned values
++| !Syntax | !Returned string |
++|//collection//{{{.ObjectType}}} |"COLLECTION" |
++|//commandbar//{{{.ObjectType}}} |"COMMANDBAR" |
++|//commandbarcontrol//{{{.ObjectType}}} |"COMMANDBARCONTROL" |
++|//control//{{{.ObjectType}}} |"CONTROL" |
++|//database//{{{.ObjectType}}} |"DATABASE" |
++|//dialog//{{{.ObjectType}}} |"DIALOG" |
++|//event//{{{.ObjectType}}} |"EVENT" |
++|//field//{{{.ObjectType}}} |"FIELD" |
++|//form//{{{.ObjectType}}} |"FORM" |
++|//module//{{{.ObjectType}}} |"MODULE" |
++|//optiongroup//{{{.ObjectType}}} |"OPTIONGROUP" |
++|//property//{{{.ObjectType}}} |"PROPERTY" |
++|//querydef//{{{.ObjectType}}} |"QUERYDEF" |
++|//recordset//{{{.ObjectType}}} |"RECORDSET" |
++|//subform//{{{.ObjectType}}} |"SUBFORM" |
++|//tabledef//{{{.ObjectType}}} |"TABLEDEF" |
++|//tempvar//{{{.ObjectType}}} |"TEMPVAR" |
++!!!Remarks
++The //~ObjectType// property is read-only.
++
++
++

++
++
++
The //on ... control events// properties set or return the Basic script function which is executed when the event occurs.
++!!!Applies to ...
++The list below details which event is applicable on which control type. Additionally a distinction is made depending on the location of the control: within a [[form|Form]] (or [[subform|SubForm]]), a [[dialog|Dialog]] or a [[grid control|GridControl]].
++The last column indicates how the event is displayed in the properties box related to the control when the form or dialog is being edited.
++|!<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />EVENT| !<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />When applied to ... | !<br /><br /><br /><br /><br /><br />&nbsp;C&nbsp;<br />&nbsp;h&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;c&nbsp;<br />&nbsp;k&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;x&nbsp; | !<br /><br /><br /><br /><br /><br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;b&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;x&nbsp; | !<br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp; | !<br />&nbsp;C&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;c&nbsp;<br />&nbsp;y&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br /><br /><br />&nbsp;D&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;l&nbsp; | !<br /><br /><br /><br /><br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;x&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;L&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;e&nbsp; | !<br /><br /><br /><br /><br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;x&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;T&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;x&nbsp;<br />&nbsp;t&nbsp; | !&nbsp;F&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br />&nbsp;G&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;l&nbsp; | !<br /><br /><br /><br /><br /><br />&nbsp;G&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;p&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;x&nbsp; | !<br />&nbsp;H&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;l&nbsp; | !<br /><br /><br />&nbsp;I&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;g&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp; | !<br /><br />&nbsp;I&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;g&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;C&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;l&nbsp; | !<br /><br /><br /><br /><br /><br /><br />&nbsp;L&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;s&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;x&nbsp; | !<br />&nbsp;N&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;v&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;g&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;r&nbsp; | !<br /><br />&nbsp;N&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;c&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br />&nbsp;P&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br />&nbsp;P&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;g&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;s&nbsp;<br />&nbsp;s&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;r&nbsp; | !<br /><br /><br />&nbsp;R&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;d&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp; | !<br /><br /><br /><br /><br />&nbsp;S&nbsp;<br />&nbsp;c&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;a&nbsp;<br />&nbsp;r&nbsp; | !<br /><br /><br /><br />&nbsp;S&nbsp;<br />&nbsp;p&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;n&nbsp;<br />&nbsp;B&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;n&nbsp; | !<br /><br /><br /><br /><br /><br /><br />&nbsp;S&nbsp;<br />&nbsp;u&nbsp;<br />&nbsp;b&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;o&nbsp;<br />&nbsp;r&nbsp;<br />&nbsp;m&nbsp; | !<br /><br /><br /><br /><br />&nbsp;T&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;x&nbsp;<br />&nbsp;t&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br /><br /><br />&nbsp;T&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;m&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;F&nbsp;<br />&nbsp;i&nbsp;<br />&nbsp;e&nbsp;<br />&nbsp;l&nbsp;<br />&nbsp;d&nbsp; | !<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Event as displayed in the (english) Base user interface |
++| ''~OnActionPerformed'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||||||||||||background-color:#eee; X |||||background-color:#eee; X |||||| Execute action |
++|~| //Datagrid// |background-color:#eee; X |||||||||||||||||||||||||~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||||||||||||background-color:#eee; X |||||background-color:#eee; X ||||||~|
++| ''~OnAdjustmentValueChanged'' | //Form// |||||||||||||||||||||background-color:#eee; X |background-color:#eee; X |||| While adjusting |
++|~| //Datagrid// ||||||||||||||||||||||||||~|
++|~| //Dialog// |||||||||||||||||||||background-color:#eee; X |||||~|
++| ''~OnApproveAction'' | //Form// |||background-color:#eee; X ||||||||||background-color:#eee; X ||||||||||||| Approve action |
++|~| //Datagrid// ||||||||||||||||||||||||||~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnApproveReset'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Prior to reset |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnApproveUpdate'' | //Form// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X |background-color:#eee; X |||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Before updating |
++|~| //Datagrid// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnChanged'' | //Form// |||||||||||||||background-color:#eee; X |||||||||background-color:#eee; X || Changed |
++|~| //Datagrid// ||||||||||||||||||||||||background-color:#eee; X ||~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnErrorOccurred'' | //Form// ||background-color:#eee; X |||||||background-color:#eee; X |background-color:#eee; X |||||background-color:#eee; X ||||||||||| Error occurred |
++|~| //Datagrid// ||background-color:#eee; X |||||||background-color:#eee; X ||||||background-color:#eee; X |||||||||||~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnFocusGained'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | When receiving focus |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnFocusLost'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | When losing focus |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnItemStateChanged'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||||||||||||background-color:#eee; X |||||background-color:#eee; X |||||| Item status changed |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X |||||||||||||background-color:#eee; X |||||||||||~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||||||||||||background-color:#eee; X |||||background-color:#eee; X ||||||~|
++| ''~OnKeyPressed'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Key pressed |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnKeyReleased'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Key released |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMouseDragged'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse moved while key pressed |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMouseEntered'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse inside |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMouseExited'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse outside |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMouseMoved'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse moved |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMousePressed'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse button pressed |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnMouseReleased'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | Mouse button released |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnResetted'' | //Form// |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | After resetting |
++|~| //Datagrid// |background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++| ''~OnTextChanged'' | //Form// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X ||||||||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X | Text modified |
++|~| //Datagrid// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X ||||||||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++| ''~OnUpdated'' | //Form// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X |background-color:#eee; X |||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X |||background-color:#eee; X |background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X | After updating |
++|~| //Datagrid// ||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||background-color:#eee; X ||||||background-color:#eee; X ||background-color:#eee; X |background-color:#eee; X ||||||background-color:#eee; X |background-color:#eee; X |~|
++|~| //Dialog// ||||||||||||||||||||||||||~|
++
++!!!Syntax
++//control.//{{{OnActionPerformed}}}
++//control.//{{{OnActionPerformed}}}=//value//
++...etc...
++!!!Returned vales / Arguments
++{{{String}}}
++!!!Remarks
++*The //value// argument or the returned value is a string pointing to a Basic (or other ...) subroutine: see the [[Scripting Framework URI Specification|https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification]] for more info.<br />E.g.<br />&nbsp;&nbsp;&nbsp;&nbsp;{{{vnd.sun.star.script:Standard.myModule.myMacro?language=Basic&location=document}}}<br />designates the {{{myMacro}}} Function or Sub in the {{{myModule}}} module of the Basic {{{Standard}}} library belonging to the current document.<br />Note that ~Access2Base does not check the validity of the provided argument.
++*Use an empty string ("") to remove the current setting.
++*The new control events settings will ''NOT'' be saved in the form after its closure.
++!!!Error messages
++|Property 'On...' not applicable in this context |
++|"Value '...' is invalid for property 'On...' |
++!!!See also
++[[On (database event)]]
++[[On (dialog event)]]
++[[On (form event)]]
++!!!Example
++<<tiddler "On control event example">>
++
++
++
The //on ... database events// properties return the Basic script function which is executed when the event occurs.
++!!!Applies to ...
++The list below details which event is applicable on [[database documents|Database]].
++The last column indicates how the event is displayed in the //Events// tab of the //Tools + Customize// dialog box.
++| !EVENT | !DATABASE | !Event as dispayed in the (english) Base user interface |
++|~OnCreate | X |Document created |
++|~OnFocus | X |Activate Document |
++|~OnLoad | X |Open Document |
++|~OnLoadFinished | X |Document loading finished |
++|~OnModifyChanged | X |'Modified’ status was changed |
++|~OnNew | X |New Document |
++|~OnPrepareUnload | X |Document is going to be closed |
++|~OnPrepareViewClosing | X |View is going to be closed |
++|~OnSave | X |Save Document |
++|~OnSaveAs | X |Save Document As |
++|~OnSaveAsDone | X |Document has been saved as |
++|~OnSaveAsFailed | X |'Save as’ has failed |
++|~OnSaveDone | X |Document has been saved |
++|~OnSaveFailed | X |Saving of document failed |
++|~OnSubComponentClosed | X |Closed a sub component |
++|~OnSubComponentOpened | X |Loaded a sub component |
++|~OnTitleChanged | X |Document title changed |
++|~OnUnfocus | X |Deactivate Document |
++|~OnUnload | X |Document closed |
++|~OnViewClosed | X |View closed |
++|~OnViewCreated | X |View created |
++!!!Syntax
++//database.//{{{OnLoad}}}
++...etc...
++!!!Returned value
++{{{String}}}
++!!!Remarks
++*The returned value is a string pointing to a Basic (or other ...) subroutine: see the [[Scripting Framework URI Specification|https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification]] for more info.<br />E.g.<br />&nbsp;&nbsp;&nbsp;&nbsp;{{{vnd.sun.star.script:Standard.myModule.myMacro?language=Basic&location=document}}}<br />designates the {{{myMacro}}} Function or Sub in the {{{myModule}}} module of the Basic {{{Standard}}} library belonging to the current document.<br />Note that ~Access2Base does not check the validity of the provided argument.
++!!!Error messages
++|Property 'On...' not applicable in this context |
++!!!See also
++[[On (control event)]]
++[[On (dialog event)]]
++[[On (form event)]]
++
++
++
The //on ... dialog events// properties set or return the Basic script function which is executed when the event occurs.
++!!!Applies to ...
++The list below details which event is applicable on [[dialogs|Dialog]].
++The last column indicates how the event is displayed in the dialog properties box when the dialog is being edited.
++| !EVENT | !DIALOG | !Event as dispayed in the (english) Base user interface |
++|~OnFocusGained | X |When receiving focus |
++|~OnFocusLost | X |When losing focus |
++|~OnKeyPressed | X |Key pressed |
++|~OnKeyReleased | X |Key released |
++|~OnMouseDragged | X |Mouse moved while key pressed |
++|~OnMouseEntered | X |Mouse inside |
++|~OnMouseExited | X |Mouse outside |
++|~OnMouseMoved | X |Mouse moved |
++|~OnMousePressed | X |Mouse button pressed |
++|~OnMouseReleased | X |Mouse button released |
++!!!Syntax
++//dialog.//{{{OnFocusGained}}}
++//dialog.//{{{OnFocusGained}}}=//value//
++...etc...
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++*The //value// argument or the returned value is a string pointing to a Basic (or other ...) subroutine: see the [[Scripting Framework URI Specification|https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification]] for more info.<br />E.g.<br />&nbsp;&nbsp;&nbsp;&nbsp;{{{vnd.sun.star.script:Standard.myModule.myMacro?language=Basic&location=document}}}<br />designates the {{{myMacro}}} Function or Sub in the {{{myModule}}} module of the Basic {{{Standard}}} library belonging to the current document.<br />Note that ~Access2Base does not check the validity of the provided argument.
++*Use an empty string ("") to remove the current setting.
++*The dialog must at least be [[started|Start]] to change the script assigned to an event.
++*The new dialog events settings will ''NOT'' be saved in the dialog library after its closure.
++!!!Error messages
++|Property 'On...' not applicable in this context |
++|"Value '...' is invalid for property 'On...' |
++!!!See also
++[[On (control event)]]
++[[On (database event)]]
++[[On (form event)]]
++!!!Example
++<<tiddler "On dialog event example">>
++
++
++
The //on ... form events// properties set or return the Basic script function which is executed when the event occurs.
++!!!Applies to ...
++The list below details which event is applicable either on [[forms|Form]] or on [[subforms|SubForm]]. In fact, there is no difference.
++The last column indicates how the event is displayed in the form or (subform) control properties box when the form is being edited.
++| !EVENT | !FORM | !SUBFORM | !Event as dispayed in the (english) Base user interface |
++|~OnApproveCursorMove | X | X |Before record change |
++|~OnApproveParameter | X | X |Fill parameters |
++|~OnApproveReset | X | X |Prior to reset |
++|~OnApproveRowChange | X | X |Before record action |
++|~OnApproveSubmit | X | X |Before submitting |
++|~OnConfirmDelete | X | X |Confirm deletion |
++|~OnCursorMoved | X | X |After record change |
++|~OnErrorOccurred | X | X |Error occurred |
++|~OnLoaded | X | X |When loading |
++|~OnReloaded | X | X |When reloading |
++|~OnReloading | X | X |Before reloading |
++|~OnResetted | X | X |After resetting |
++|~OnRowChanged | X | X |After record action |
++|~OnUnloaded | X | X |When unloading |
++|~OnUnloading | X | X |Before unloading |
++!!!Syntax
++//form.//{{{OnApproveCursorMove}}}
++//form.//{{{OnApproveCursorMove}}}=//value//
++//subform.//{{{OnApproveCursorMove}}}
++//subform.//{{{OnApproveCursorMove}}}=//value//
++...etc...
++!!!Returned vales / Arguments
++{{{String}}}
++!!!Remarks
++*The //value// argument or the returned value is a string pointing to a Basic (or other ...) subroutine: see the [[Scripting Framework URI Specification|https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification]] for more info.<br />E.g.<br />&nbsp;&nbsp;&nbsp;&nbsp;{{{vnd.sun.star.script:Standard.myModule.myMacro?language=Basic&location=document}}}<br />designates the {{{myMacro}}} Function or Sub in the {{{myModule}}} module of the Basic {{{Standard}}} library belonging to the current document.<br />Note that ~Access2Base does not check the validity of the provided argument.
++*Use an empty string ("") to remove the current setting.
++*The new form events settings will ''NOT'' be saved in the form after its closure.
++!!!Error messages
++|Property 'On...' not applicable in this context |
++|"Value '...' is invalid for property 'On...' |
++!!!See also
++[[On (control event)]]
++[[On (database event)]]
++[[On (dialog event)]]
++!!!Example
++<<tiddler "On form event example">>
++
++
++
Change the behaviour of the form when a control gets the focus
++//{{{
++Dim ocControl As Object
++	Set ocControl = Application.Forms("myForm").Controls("myControl")
++	'	Change event "When receiving focus"
++	ocControl.OnFocusGained = "vnd.sun.star.script:Standard.myModule.myFunction?language=Basic&location=document"
++	'	Cancel the event "When losing focus"
++	ocControl.OnFocusLost = ""
++//}}}
++
++
++
Change the behaviour of the dialog when the mouse is pressed anywhere in the perimeter of the dialog
++//{{{
++Dim oDialog As Object
++	Set oDialog = Application.AllDialogs("myDialog")
++	oDialog.Start()
++	'	Change event "OnMousePressed"
++	'	The function might return True or False
++	oDialog.OnMousePressed = "vnd.sun.star.script:Standard.myModule.myFunction?language=Basic&location=document"
++	'	Cancel the event "OnKey Pressed"
++	oDialog.OnKeyPressed = ""
++//}}}
++
++
++
Change the behaviour of the form when the user erases a record from a subform
++//{{{
++Dim ocSubForm As Object
++	Set ocSubForm = Application.Forms("myForm").Controls("mySubForm").Form
++	'	Change event "Confirm deletion"
++	'	The function might return True or False
++	ocSubForm.OnConfirmDelete = "vnd.sun.star.script:Standard.myModule.myFunction?language=Basic&location=document"
++	'	Cancel the event "SQL Error occurred"
++	ocSubForm.OnErrorOccurred = ""
++//}}}
++
++
++
The //~OnAction// property gets or sets the name of a Basic procedure or a menu-command that will run when the user clicks on a [[CommandBarControl]].
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBarControl]] |A control belonging to a ~CommandBar. |
++!!!Syntax
++//commandbarcontrol//{{{.OnAction}}}
++//commandbarcontrol//{{{.OnAction}}} = //value//
++!!!Returned value / Argument
++The returned value is always a {{{String}}}.
++The argument may be either an {{{Integer/Long}}} or a {{{String}}}
++!!!Remarks
++The //value// argument can be 1 out of 3 types:
++*any valid argument of the [[RunCommand]] action;
++*any valid command with the leftmost characters = ''{{{".uno:"}}}'';
++*or a string pointing to a Basic (or other ...) subroutine: see the [[Scripting Framework URI Specification|https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification]] for more info.<br />E.g.<br />&nbsp;&nbsp;&nbsp;&nbsp;{{{vnd.sun.star.script:Standard.myModule.myMacro?language=Basic&location=document}}}<br />designates the {{{myMacro}}} Function or Sub in the {{{myModule}}} module of the Basic {{{Standard}}} library belonging to the current document.
++!!!Error messages
++|Property '~OnAction' not applicable in this context |
++|Value '...' is invalid for property '~OnAction |
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++[[Execute|Execute (commandbarcontrol)]]
++[[RunCommand]]
++!!!Example
++<<tiddler "CommandBarControl example">>
++
++
++
The //~OpenArgs// property determines the expression that was passed as argument of an [[OpenForm]] action.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++!!!Syntax
++//form//{{{.OpenArgs}}}
++!!!Returned values
++{{{Variant}}}
++!!!Remarks
++*The //~OpenArgs// property is read-only.
++*Being a variant, the ~OpenArgs argument of the OpenForm action might contain a complex value allowing complex processing (see example).
++*The //form// argument must be the [[object|Object Model]] returned by the OpenForm action. Otherwise, f.i. if the object is the usual output of a [[Forms]] method, the ~OpenArgs property always returns a zero-length string.<br />__This is a major restriction to the functionality provided by ~MSAccess__.
++*The //~OpenArgs// property applied to a [[standalone form|Standalone Forms]] stored in a non-Base (Writer, Calc, ...) document always returns a zero-length string.
++!!!Error messages
++!!!See also
++[[Tag]]
++!!!Example
++<<tiddler "OpenArgs example">>
++
++
++
In a 1st step open a form with the ~OpenArgs argument
++//{{{
++Dim ofForm As Object
++Const acNormal = 0
++	Set ofForm = OpenForm("myForm", acNormal, , , , , Array("MICKEY", "WINNIE"))
++//}}}
++In a 2nd step compute a filter based on the ~OpenArgs property
++//{{{
++Dim sFilter As String, i As Integer
++	sFilter = ""
++	For i = 0 To UBound(ofForm.OpenArgs)
++		sFilter = sFilter & Iif(i=0, "", " Or ") & "[EMPLOYEE].[NAME] LIKE '*" & ofForm.OpenArgs(i) & "*'"
++	Next i
++	ofForm.Filter = sFilter
++	ofForm.FilterOn = True
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he invocation of the //~OpenConnection// as a Sub is mandatory before any other use of the //~Access2Base// API. It initializes the resources needed to process inside the API the subsequent invocations to its methods and actions.
++*If the document is a Base document (suffix = ".odb") then a link is established with its database.
++*If the document is not a Base document (a Writer, Calc, ... document), then a link is established with each database associated with the [[standalone forms|Standalone Forms]] contained in the document.
++<<tiddler "ApplyApplication">>
++!!!Syntax when invoked from a usual Base document (.odb file)
++{{{Call [Application.]OpenConnection (ThisDatabaseDocument)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{ThisDatabaseDocument}}} | No | com.sun.star.comp.dba.~ODatabaseDocument |Must be exactly spelled as is. |
++!!!Syntax when invoked from document containing one or more standalone forms (Writer, Calc, ... file)
++{{{Call [Application.]OpenConnection (ThisComponent)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{ThisComponent}}} | No | ~SwXTextDocument |Must be exactly spelled as is. |
++!!!Remarks
++*If the access to the database requires a //login// and if not yet done, the user will be prompted for entering a username and a password.
++*The syntax that was valid up to //~Access2Base// version 1.0.0 is still accepted. However the //username// and //password// arguments are ignored.
++!!!See also
++[[CloseConnection]]
++[[CurrentDb]]
++[[Database]]
++[[Install]]
++[[OpenDatabase]]
++[[Standalone Forms]]
++!!!Example
++The Call ~OpenConnection sentence is usually invoked in the macro linked to the //~OpenDocument event// of the (Base or non-Base) document.
++<<tiddler "Openconnection example">>
++<<tiddler "CurrentDb example">>
++<<tiddler "Standalone Connect example">>
++
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenDatabase// method returns a [[Database]] object that establishes a link with an external database represented by a database document (".odb" file).
++The returned object allows data retrieval and update in the targeted database.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{Set }}}//{{{database}}}//{{{ = [Application.]OpenDatabase (connectionstring, [username], [password], [readonly])}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{connectionstring}}} || string |Either<br />- the name under which the targeted database is //registered//<br />- or the URL of the ".odb" file referring to the targeted database. |
++|{{{username}}} | Y | string |The connection parameters to the effective database, if any. |
++|{{{password}}} | Y |~|~|
++|{{{readonly}}} | Y | Boolean |If {{{True}}} updates of the database data will be forbidden.<br />Default = {{{False}}} |
++!!!Remarks
++*The resulting [[Database]] object must be kept by the program in a Basic variable with a scope that is compatible with the duration of the operations done on the database. F.i. a {{{Global}}}, a {{{Static}}} or a module-level {{{Public}}} variable sometimes fit best for that purpose.
++*After use the database should be closed with the [[Close|Close (method)]] method.
++!!!Error messages
++|Connection to the database is not active |
++!!!See also
++[[Close (method)]]
++[[Database]]
++[[CurrentDb]]
++[[OpenConnection]]
++[[Standalone Forms]]
++!!!Example
++<<tiddler "Opendatabase example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenForm// action opens a form in Form view or in form Design view. You can select data entry and window modes for the form and restrict the records that the form displays.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]OpenForm(}}}//{{{FormName, View, Filter, WhereCondition, DataMode, WindowMode, OpenArgs}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{FormName}}} | No | String |The name of the form to open. |
++|{{{View}}} | Yes | acDesign<br />acNormal<br />acPreview |The view in which the form will open.<br />//acNormal// and //acPreview// are equivalent. Default is //acNormal//. |
++|{{{Filter}}} |~| String |A valid __SQL WHERE clause__ (without the word WHERE). |
++|{{{WhereCondition}}} |~| String |A valid __SQL WHERE clause__ (without the word WHERE). |
++|{{{DataMode}}} |~| acFormAdd<br />acFormEdit<br />acFormPropertySettings<br />acFormReadOnly |Specifies if the user will be allowed to add new records (//acFormAdd//), add new and edit existing records (//acFormEdit//) or only read existing records (//acFormReadOnly//). //acFormPropertySettings// refers to the settings at form creation.<br />Only //acFormEdit// alows record deletions. |
++|{{{WindowMode}}} |~| acHidden<br />acWindowNormal |Default is //acWindowNormal//. |
++|{{{OpenArgs}}} |~| Variant |The argument is used to set the form's [[OpenArgs]] property. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acDesign = 1
++Const acNormal = 0
++Const acPreview = 2
++
++Const acFormAdd = 0
++Const acFormEdit = 1
++Const acFormPropertySettings = -1
++Const acFormReadOnly = 2
++
++Const acHidden = 1
++Const acWindowNormal = 0
++//}}}
++!!!Remarks
++*The //Filter// and //~WhereCondition// arguments are simply concatenated and applied as filter to the form:
++//{{{
++( Filter ) And ( WhereCondition )
++//}}}
++*The //~OpenForm// action returns a [[Form]] object.
++*If the //view// argument is //acDesign//, the form will get opened in Design mode. However any further action is not supported by the ~Access2Base API.
++*The //~OpenForm// action cannot open and  must not be triggered from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Action not applicable in this context |
++|Form '...' could not be opened |
++!!!See also
++[[AllowAdditions]]
++[[AllowDeletions]]
++[[AllowEdits]]
++[[Close]]
++[[Filter]]
++[[FilterOn]]
++[[OpenArgs]]
++[[OpenQuery]]
++[[OpenReport]]
++[[OpenSQL]]
++[[OpenTable]]
++!!!Example
++<<tiddler "Openform example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenQuery// action opens a query in normal view or in query design view.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]OpenQuery(}}}//{{{QueryName, View, DataMode}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{QueryName}}} | No | String |The name of the query to open. This argument is NOT case-sensitive. |
++|{{{View}}} | Yes | acViewDesign<br />acViewNormal<br />acViewPreview |The view in which the query will open.<br />//acViewNormal// and //acViewPreview// are equivalent. Default is //acViewNormal//. |
++|{{{DataMode}}} |~| acEdit |The user will be allowed to add new records and edit existing records. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acViewDesign = 1
++Const acViewNormal = 0
++Const acViewPreview = 2
++
++Const acEdit = 1
++//}}}
++!!!Remarks
++*If the //view// argument is //acDesign//, the query will get opened in Design mode. However any further action is not supported by the ~Access2Base API.
++*The //~OpenQuery// action must not be triggered from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Query '...' could not be opened |
++|Query '...' not found |
++|Action not applicable in this context |
++!!!See also
++[[Close]]
++[[OpenForm]]
++[[OpenReport]]
++[[OpenSQL]]
++[[OpenTable]]
++!!!Example
++//{{{
++Const acViewNormal = 0
++	OpenQuery("myQuery", acViewNormal)
++//}}}
++
++
++
Creates a new [[Recordset]] object and appends it to the [[Recordsets]] collection of the concerned [[database object|Database]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Database]] |The representation of a database. |
++|[[TableDef]] |The representation of a database table. |
++|[[QueryDef]] |The representation of a database query. |
++|[[Recordset]] |The representation of another recordset. |
++!!!Syntax
++For a database object:
++>Set //recordset// = //database//.{{{Openrecordset}}} (//source, type, option, lockedit//)
++For tabledef, querydef and recordset objects:
++>Set //recordset// = //tabledef//.{{{Openrecordset}}} (//type, option, lockedit//)
++>Set //recordset// = //querydef//.{{{Openrecordset}}} (//type, option, lockedit//)
++>Set //recordset// = //recordset//.{{{Openrecordset}}} (//type, option, lockedit//)
++!!!Arguments - Returned value
++| !Argument | !Type | !Optional | !Description | !Returned value |
++|source | String ||A table name, a query name, or an SQL statement that returns records | A [[recordset|Recordset]] object |
++|type | Integer<br />Long | Y |If the argument is present its only allowed value = //dbOpenForwardOnly//.<br />Forces one-directional browsing of the records. |~|
++|option | Integer<br />Long | Y |If the argument is present its only allowed value = //dbSQLPassThrough//.<br />Forces escape substitution before sending the SQL statement to the database. |~|
++|lockedit | Integer<br />Long | Y |If the argument is present its only allowed value = //dbReadOnly//.<br />Forces dirty read and prevents from database updates. |~|
++!!!Remarks
++*A recordset object MUST be closed by the [[close|Close (method)]] method __as soon as it becomes useless__ to avoid eventual record (dead)locks. To close all open recordsets at once, use the [[CloseAllRecordsets]] method.
++*If the //~OpenRecordset// method is applied to a //database// object and the //source// argument is not a SQL statement then the //source// is presumed to contain at first a TABLE name and secondly a QUERY name.
++*To include the constants in your own code, copy and paste next lines:
++//{{{
++Const dbOpenForwardOnly = 8
++Const dbSQLPassThrough = 64
++Const dbReadOnly = 4
++//}}}
++*To access the recordset linked to a [[form|Form]] or a [[subform|SubForm]] use the [[recordset property|Recordset (property)]].
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|SQL error, SQL statement = '...' |
++|Table/Query '...' not found |
++!!!See also
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[Filter]]
++[[Recordset object|Recordset]]
++[[Recordset property|Recordset (property)]]
++[[TableDefs]]
++[[TableDef]]
++[[QueryDefs]]
++[[QueryDef]]
++!!!Example
++<<tiddler "OpenRecordset example">>
++
++
++
Create a new recordset on table //Invoices// and count the records (not the most efficient way to do it ... !)
++//{{{
++Const dbReadOnly = 4
++Dim orsRecords As Object, lCount As Long
++	Set orsRecords = Application.CurrentDb().OpenRecordset("INVOICES", , , dbReadOnly)
++	lCount = 0
++	With orsRecords
++		If Not .BOF Then		'	An empty recordset has both .BOF and .EOF set to True
++			Do While Not .EOF
++				lCount = lCount + 1
++				.MoveNext
++			Loop
++		End If
++		.mClose()
++	End With
++	Print "Number of records = " & lCount
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenReport// action opens a report in normal view or in report design view.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]OpenReport(}}}//{{{ReportName, View}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{ReportName}}} | No | String |The name of the report to open. This argument is NOT case-sensitive. |
++|{{{View}}} | Yes | acViewDesign<br />acViewNormal<br />acViewPreview |The view in which the query will open.<br />//acViewNormal// and //acViewPreview// are equivalent. Default is //acViewNormal//. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acViewDesign = 1
++Const acViewNormal = 0
++Const acViewPreview = 2
++//}}}
++!!!Remarks
++*If the report was built with the Sun Report Builder extension, this extension is required to get the report open.
++*If the //view// argument is //acDesign//, the query will get opened in Design mode. However any further action is not supported by the ~Access2Base API.
++*The //~OpenReport// action must not be triggered from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Report '...' could not be opened |
++|Report '...' not found |
++|Action not applicable in this context |
++!!!See also
++[[Close]]
++[[OpenForm]]
++[[OpenQuery]]
++[[OpenSQL]]
++[[OpenTable]]
++!!!Example
++//{{{
++Const acViewNormal = 0
++	OpenQuery("myQuery", acViewNormal)
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenSQL// action opens a datasheet containing the data described by the provided SELECT SQL statement.
++<<tiddler "ApplyDoCmd">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object returned by the [[CurrentDb]] or [[OpenDatabase]] methods. |
++!!!Syntax
++{{{[DoCmd.]OpenSQL(}}}//{{{SQL, option}}}//{{{)}}}
++//{{{database}}}//{{{.OpenSQL(}}}//{{{SQL, option}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description |
++|database || Object |A database object opened with the //~OpenDatabase// method. |
++|SQL | No | String |A SELECT SQL statement. |
++|option | Yes | Integer<br />Long |If the argument is present its only allowed value = //dbSQLPassThrough//.<br />Forces escape substitution before sending the SQL statement to the database. |~|
++!!!Remarks
++*Statements
++//{{{
++DoCmd.OpenSQL( ... )
++//}}}
++and
++//{{{
++Application.CurrentDb().OpenSQL( ... )
++//}}}
++are equivalent.
++*The tablenames and columnnames used in the SQL statement may be surrounded by square brackets "[]". They will be replaced by the character(s) expected by their RDBMS (//Relational Database Management System//).
++*To include the constant in your own code, copy and paste next lines:
++//{{{
++Const dbSQLPassThrough = 64
++//}}}
++!!!Error messages
++If the syntax of the SQL statement is wrong a system error will be raised.
++!!!See also
++[[CurrentDb]]
++[[OpenDatabase]]
++[[OpenForm]]
++[[OpenQuery]]
++[[OpenReport]]
++[[OpenTable]]
++!!!Example
++//{{{
++	OpenSQL("SELECT * FROM [EMPLOYEES]")
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OpenTable// action opens a table in normal view or in table design view.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]OpenTable(}}}//{{{TableName, View, DataMode}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{TableName}}} | No | String |The name of the table to open. This argument is NOT case-sensitive. |
++|{{{View}}} | Yes | acViewDesign<br />acViewNormal<br />acViewPreview |The view in which the table will open.<br />//acViewNormal// and //acViewPreview// are equivalent. Default is //acViewNormal//. |
++|{{{DataMode}}} |~| acEdit |The user will be allowed to add new records and edit existing records. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acViewDesign = 1
++Const acViewNormal = 0
++Const acViewPreview = 2
++
++Const acEdit = 1
++//}}}
++!!!Remarks
++*If the //view// argument is //acDesign//, the table will get opened in Design mode. However any further action is not supported by the ~Access2Base API.
++*The //~OpenTable// action must not be triggered from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Table '...' could not be opened |
++|Table '...' not found |
++|Action not applicable in this context |
++!!!See also
++[[Close]]
++[[OpenForm]]
++[[OpenQuery]]
++[[OpenReport]]
++[[OpenSQL]]
++!!!Example
++//{{{
++Const acViewNormal = 0
++	OpenTable("myTable", acViewNormal)
++//}}}
++
++
++
//{{{
++Sub DBOpen(Optional poEvent As Object)
++	If GlobalScope.BasicLibraries.hasByName("Access2Base") Then
++		GlobalScope.BasicLibraries.loadLibrary("Access2Base")
++	End If
++	Call Application.OpenConnection(ThisDatabaseDocument)
++End Sub
++//}}}
++
++
++
List all table names of an external database
++//{{{
++Public oDatabase As Object
++
++Sub ScanTables()
++
++Dim oTable As Object, oField As Object, i As Integer
++	Set oDatabase = Application.OpenDatabase("/home/somedir/TT NorthWind.odb",,,)
++	With oDatabase
++		For i = 0 To .TableDefs.Count - 1
++			Set oTable = .TableDefs(i)
++			DebugPrint oTable.Name
++		Next i
++	End With
++	oDatabase.mClose()
++
++End Sub
++//}}}
++
++
++
Open a form
++//{{{
++	OpenForm "myForm"
++//}}}
++Open a form in read only mode
++//{{{
++	OpenForm "myForm", , , , acFormReadOnly
++//}}}
++Open a form in read only mode. The form must be hidden.
++//{{{
++Dim ofForm As Object
++	ofForm = OpenForm "myForm", , , , acFormReadOnly, acHidden
++//}}}
++Make it later visible
++//{{{
++	ofForm.Visible = True
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}}n //~OptionGroup// [[object|Object Model]] represents a set of [[RadioButton]] controls in a [[form|Form]], a [[subform|SubForm]] or a [[dialog|Dialog]], having in common the characteristic that selecting one button deselects automatically all the others.
++Most properties can be set at //~RadioButton// level and individually for each of them. However the key reason for having introduced //~OptionGroups// (an artificial entity with no equivalent in //~OpenOffice/~LibreOffice//) in //~Access2Base// is to give the programmer an easy mean to determine which //~RadioButton// is currently selected.
++!!!How to identify the set of //~RadioButtons// constituting an //~OptionGroup// ?
++| !Container | !Identification of the //~OptionGroup// |!Name of the //~OptionGroup// |
++|[[Form]]<br />[[SubForm]] |All the //~RadioButtons// sharing the same name |That unique name |
++|[[Dialog]] |All the //~RadioButtons// having contiguous //~TabIndexes//<br />(= //Order// in the control's property sheet) |The name of the __first__ //~RadioButton// of the set |
++!!!Function returning an ~OptionGroup object
++| !Parent object | !Method | !Arg |!Description |
++|[[Form]]<br />[[SubForm]]<br />[[Dialog]] |[[OptionGroup|OptionGroup (Method)]] | String |Returns an //~OptionGroup// object in the form, the subform or the dialog on which the method is applied having its argument as name. The name is the common name of all //radio buttons// belonging to the ~OptionGroup.|
++!!!Properties
++| !Property | !Read only | !Description or UNO object |
++|[[Name]] | Y |Specifies the exact name of the option group. |
++|[[Count]] | Y |Specifies the number of radio buttons belonging to the group. |
++|[[ObjectType]] | Y |Returns "OPTIONGROUP" |
++|[[Value]] ||Specifies the index of the radio button being currently selected. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~OptionGroup has the given property. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!Remarks
++The //Value// property holds a value between 0 and //Count// - 1.
++!!!See also
++[[Controls]]
++[[OptionGroup (Method)]]
++[[RadioButton]]
++[[TabIndex]]
++!!!Example
++<<tiddler "Optiongroup example">>
++
++
++
The //~OptionGroup// method returns an [[object|Object Model]] of type [[OptionGroup]]
++!!!Syntax
++//form//.{{{OptionGroup(}}}//groupname//{{{)}}}
++//subform//.{{{OptionGroup(}}}//groupname//{{{)}}}
++//dialog//.{{{OptionGroup(}}}//groupname//{{{)}}}
++| !ObjectType | !Argument |!Returned value |
++| [[Form]]<br />[[SubForm]] | String |An object of type //~OptionGroup// having the //groupname// as name. The name is the common name of all radio buttons sharing the same selection group. |
++| [[Dialog]] |~|An object of type //~OptionGroup// having the //groupname// as name. The name is the name of the first radio button belonging to the same selection group. |
++!!!Remarks
++The individual //~RadioButtons// can be retrieved with the [[Controls]] method applied to the //~OptionGroup// object. Use their //index// as second argument. The //index// is determined
++*in //forms// and //subforms// by the ~X-Y coordinates of the //~RadioButton// on the screen
++*in //dialogs// by the rank of the //~TabIndex// property in the sequence of contiguous //~TabIndexes// determining the //~OptionGroup//.
++The //index// starts from 0.
++!!!See also
++[[Controls]]
++[[OptionGroup]]
++[[RadioButton]]
++[[TabIndex]]
++!!!Example
++<<tiddler "Optiongroup example">>
++
++
++
The //~OptionValue// property specifies the value stored in the database as determined by the selected [[RadioButton]].
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | [[RadioButton]] | None |A control on an open form. |
++!!!Syntax
++//control//{{{.OptionValue}}}
++!!!Returned value
++{{{String}}}
++!!!Remarks
++The //~OptionValue// property is read-only.
++!!!Error messages
++!!!See also
++[[RadioButton]]
++[[OptionGroup]]
++!!!Example
++<<tiddler "OptionValue example">>
++
++
++
Browse thru the values to store in the database by button	
++//{{{
++Dim ofForm As Object, ocOptionGroup As Object, ocControl As Object, i as integer
++	Set ofForm = Forms("myform")
++	Set ocOptionGroup = ofForm.OptionGroup("myRadioButton")
++	ocOptionGroup.Value = 2
++	For i = 0 to ocOptionGroup.Count - 1
++		ocControl = ocOptionGroup.Controls(i)
++		Print ocControl.OptionValue & "/",
++	Next i
++//}}}
++
++
++
Change the currently selected radio button and modify its appearance
++//{{{
++Dim ofForm As Object, ocOptionGroup As Object, ocControl As Object, i as integer
++	Set ofForm = Forms("myform")
++	Set ocOptionGroup = ofForm.OptionGroup("myRadioButton")
++	ocOptionGroup.Value = 2
++	For i = 0 to ocOptionGroup.Count - 1
++		ocControl = ocOptionGroup.Controls(i)
++		If i = ocOptionGroup.Value Then
++			ocControl.ForeColor = RGB(255, 0 ,0)
++		Else
++			ocControl.ForeColor = RGB(0, 0 ,0)
++		End If
++	Next i
++//}}}
++
++
++
You can use the //OrderBy// property to specify how you want to sort records in a [[form|Form]] or a [[subform|SubForm]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.OrderBy}}}
++//form//{{{.OrderBy = }}}//value//
++//subform//{{{.OrderBy}}}
++//subform//{{{.OrderBy = }}}//value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++*The //~OrderBy// property is a string expression consisting of a ''ORDER BY'' SQL clause without the ORDER BY keywords. Like in //~MsAccess// __table names__, or __field names__ (e.g. when containing a space) may be surrounded by square brackets ([]).
++*The ordering sequence is effectively applied only when the [[OrderByOn]] property is set to {{{True}}}.
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~OrderBy' |
++!!!See also
++[[OrderByOn]]
++!!!Example
++<<tiddler "OrderBy example">>
++
++
++
Set and apply an ordering sequence on a form
++//{{{
++Dim ofForm As Object, sOrderBy As String
++	Set ofForm = Forms("myForm")
++	sOrderBy = "[DENOMINATION] DESC"
++	ofForm.OrderBy = sOrderBy
++	ofForm.OrderByOn = True
++//}}}
++
++
++
Use the //~OrderByOn// property to specify or determine whether the [[OrderBy]] property for a form is applied.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |An open form |
++|[[SubForm]] |A subform in an open form |
++!!!Syntax
++//form//{{{.OrderByOn}}}
++//form//{{{.OrderByOn = }}}//value//
++//subform//{{{.OrderByOn}}}
++//subform//{{{.OrderByOn = }}}//value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++When a //~OrderBy// is applied, the form is [[requeried|Requery]].
++!!!Error messages
++|Form '...' is currently not open|
++|Value '...' is invalid for property '~OrderByOn' |
++!!!See also
++[[OrderBy]]
++[[Requery]]
++!!!Example
++<<tiddler "OrderBy example">>
++
++
++
*Order Details table
++| !Fields | !Field Type | !Primary |
++|Discount | Float ||
++|~OrderID | ~BigInt | Y |
++|~ProductID | ~BigInt | Y |
++|Quantity | Integer ||
++|~UnitPrice | Number ||
++
++
++
*Orders table
++| !Fields | !Field Type | !Primary |
++|~CustomerID | Text ||
++|~EmployeeID | Integer ||
++|Freight | Number ||
++|~OrderDate | Date/Time ||
++|~OrderID | ~BigInt | Y |
++|~RequiredDate | Date/Time ||
++|~ShipAddress | Text ||
++|~ShipCity | Text ||
++|~ShipCountry | Text ||
++|~ShipName | Text ||
++|~ShippedDate | Date/Time ||
++|~ShipPostalCode | Text ||
++|~ShipRegion | Text ||
++|~ShipVia | Integer ||
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~OutputTo// action outputs the data located
++*in a specified [[form|Form]]
++*in a specified [[table|TableDef]] or [[query|QueryDef]]
++ to several output formats
++<<tiddler "ApplyDoCmd">>
++or, when applicable to a table or a query, to ...
++| !Object | !Description |
++|[[Database]] |A database object opened with the [[OpenDatabase]] or returned by the [[CurrentDb]] methods. |
++!!!Syntax
++{{{[DoCmd.]OutputTo(}}}//{{{ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, Quality}}}//{{{)}}}
++//database//{{{.OutputTo(}}}//{{{ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, Quality}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description | !Returned value |
++|{{{ObjectType}}} | No | acOutputTable<br />acOutputQuery<br />acOutputForm |The type of object to output. | {{{True}}} if success |
++|{{{ObjectName}}} | Yes | String |The valid name of an object of the type selected by the //~ObjectType// argument.<br />If the //~ObjectType// is acOutputForm and you want to output the active form, leave this argument blank. |~|
++|{{{OutputFormat}}} | Yes | acFormatPDF<br />acFormatODT<br />acFormatDOC<br />acFormatHTML<br />acFormatODS<br />acFormatXLS<br />acFormatXLSX<br />acFormatTXT |The output format, expressed as an acFormatXXX constant. If this argument is omitted, the user will be prompted for the output format. |~|
++|{{{OutputFile}}} | Yes | String |The full name, including the path, of the file you want to output the object to. If this argument is left blank, the user will be prompted for an output file name. |~|
++|{{{AutoStart}}} | Yes | Boolean |If {{{True}}}, specifies that you want the appropriate application to start immediately after the //~OutputTo// action runs, with the file specified by the //~OutputFile// argument opened. |~|
++|{{{TemplateFile}}} | Yes | String |Meaningful only if the //~ObjectType// argument is {{{acOutputTable}}} or {{{acOutputQuery}}}  and the //~OutputFormat// argument is HTML. Otherwise must contain the null-length string.<br />The full name, including the path, of the template file. |~|
++|{{{Encoding}}} | Yes | acUTF8Encoding |Meaningful only if the //~ObjectType// argument is {{{acOutputTable}}} or {{{acOutputQuery}}}. Otherwise must be zero. |~|
++|{{{Quality}}} | Yes | acExportQualityPrint<br />acExportQualityScreen |This argument is ignored. |~|
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Global Const acOutputTable = 0
++Global Const acOutputQuery = 1
++Global Const acOutputForm = 2
++
++Global Const acUTF8Encoding = 76
++
++Global Const acFormatPDF = "writer_pdf_Export"
++Global Const acFormatODT = "writer8"{{{date}}}<br />
++Global Const acFormatDOC = "MS Word 97"
++Global Const acFormatHTML = "HTML"
++Global Const acFormatODS = "calc8"
++Global Const acFormatXLS = "MS Excel 97"
++Global Const acFormatXLSX = "Calc MS Excel 2007 XML"
++Global Const acFormatTXT = "Text - txt - csv (StarCalc)"
++
++Global Const acExportQualityPrint = 0
++Global Const acExportQualityScreen = 1
++//}}}
++!!!Remarks
++*When applied to a table or a query data {{{DoCmd.OutputTo(...)}}} and {{{Application.CurrentDb().OutputTo(...)}}} are strictly equivalent.
++*The designated form MUST be open before the //~OutputTo// action is called.
++*If the {{{OutputFile}}} argument is not equal to space, and If the output file already exists, it will be overwritten without warning. If the user is prompted for the output file ({{{OutputFile}}} = space), the user will be requested to confirm the Save.
++*The {{{OutputFile}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++*Outputting a table or a query to a Calc, Excel or text file goes first through the generation of a Calc document which is saved via the adequate filter.
++*A text/csv file will always be encoded using the __Unicode (~UTF-8)__ character set. The choice of the field separator will depend on the locale setting for the decimal point: if it is a dot, then the field separator will be the comma, if it is a comma, then it will be the semi-colon. All text strings will be enclosed in double quotes.
++!!!Templating and styling
++Templates and CSS styles can be used when the output format is HTML and when the source of the exported data is a table or a query.
++The {{{TemplateFile}}} given as argument of the //~OutputTo// action may contain abreakny HTML tags, ~JavaScript code or any other element that is acceptable in a HTML page. ~Access2Base will leave them unchanged, except when a //token// is encountered. The only accepted tokens are
++| !Token | !Description |
++|{{{<!--Template_Title-->}}} |Will be replaced by the name of the table or the query. |
++|{{{<!--Template_Body-->}}} |Will be replaced by the effective data contained in the table or the query. |
++({{{<!--AccessTemplate_Title-->}}} and {{{<!--AccessTemplate_Body-->}}} are also accepted for compatibility with ~MSAccess)
++If the {{{TemplateFile}}} argument is absent, the default template used by ~Access2Base is:
++//{{{
++<!DOCTYPE html>
++<html>
++ <head>
++  <title><!--Template_Title--></title>
++ </head>
++ <body>
++  <!--Template_Body-->
++ </body>
++</html>
++//}}}
++To make CSS styling easy the data themselves will be generated together with next classes:
++| !Class | !Tags | !Typical usage |
++|{{{dbdatatable}}} | {{{<table>}}} |To not confuse the data table with other tables present in the template. |
++|{{{odd}}}<br />{{{even}}} | {{{<tr>}}} |To display alternate colors or backgrounds..|
++|{{{firstrow}}}<br />{{{lastrow}}} |~|To define specific borders above or under the first or the last row. |
++|{{{firstcol}}}<br />{{{lastcol}}} | {{{<th>}}}<br />{{{<td>}}} |To define specific borders on the left or the right of the first or the last column. |
++|{{{char}}}<br />{{{numeric}}}<br />{{{negative}}}<br />{{{date}}}<br />{{{bool}}}<br />{{{false}}}<br />{{{null}}} | {{{<td>}}} |To define display effects depending on the content of the table cell.<br />Like right justifying numbers, red fonts for negative numbers, special background for empty cells, etc. |
++//Body// output example:
++//{{{
++  <table class="dbdatatable">
++   <caption>myQuery</caption>
++   <thead>
++    <tr>
++     <th scope="col" class="firstcol">Month</th>
++     <th scope="col">Dept</th>
++     <th scope="col">Savings</th>
++     <th scope="col" class="lastcol">Comments</th>
++    </tr>
++   </thead>
++   <tfoot>
++   </tfoot>
++   <tbody>
++    <tr class="odd firstrow">
++     <td class="char firstcol">January</td>
++     <td class="char">Dept1</td>
++     <td class="numeric">100.0</td>
++     <td class="char lastcol">Some comments about this department</td>
++    </tr>
++    <tr class="even">
++     <td class="char firstcol">February</td>
++     <td class="char">Dept2</td>
++     <td class="numeric negative">-80.5</td>
++     <td class="char lastcol">No comment</td>
++    </tr>
++    <tr class="odd lastrow">
++     <td class="char firstcol">March</td>
++     <td class="char">Dept3</td>
++     <td class="numeric">75.9</td>
++     <td class="char null lastcol"></td>
++    </tr>
++   </tbody>
++  </table>
++//}}}
++!!!String encoding
++When exporting data from a table or a query, all strings will be "~UTF-8 encoded". See f.i. [[here|http://www.w3schools.com/charsets/ref_html_utf8.asp]] for more explanation.
++There are however a few exceptions. Some HTML tags (= NOT ALL) found within data strings will not be encoded. Typically links to pages located in <a> tags will remain unchanged.
++Next patterns will not be encoded:
++| !Pattern | !Remark |
++|{{{&quot;}}}<br />{{{&apos;}}} ||
++|{{{&amp;}}} |"&" will be encoded as {{{&amp;}}}. "{{{&amp;}}}" will not be encoded as {{{&amp;amp;}}} |
++|{{{&lt;}}}<br />{{{&gt;}}} ||
++|{{{&nbsp;}}} |Multiple normal spaces will probably appear as one single space |
++|{{{<pre>}}}<br />{{{</pre>}}} |To preserve spacing and line breaks |
++|{{{<br>}}} |To force a line break |
++|{{{<a href="..."}}}<br />{{{<a id="..."}}}<br />{{{</a>}}} |References to hyperlinks or anchors may be present and will be preserved in strings |
++|{{{<img src="..."}}} |~|
++|{{{<span class="..."}}}<br />{{{</span>}}} |The <span> tag provides a way to add a specific class name or other hook to a part of a text or a part of a document |
++|{{{<b> </b>}}}<br />{{{<u> </u>}}}<br />{{{<i> </i>}}} |Usual editing tags |
++!!!Error messages
++|Object '...' not found |
++|Action not applicable in this context |
++!!!See also
++[[HtmlEncode]]
++[[RunApp]]
++[[SelectObject]]
++[[SendObject]]
++!!!Examples
++<<tiddler "OutputTo example">>
++Additionally, styling examples can be found in [[Output table or query to html - styling examples|OutputToStyling]].
++
++
++
Output form in PDF format to a file (you will be prompted for the file name and location) and open the generated file (asynchronously)
++//{{{
++Const acOutputForm = 2
++Const acFormatPDF = "writer_pdf_Export"
++	OutputTo(acOutputForm, "myform", acFormatPDF,, True)
++//}}}
++
++
++
Q: How can I output data to a web page and make it nice to read ?
++
++R: Data can be inserted statically in a web page thanks to the [[OutputTo]] action which will export the data to a static HTML page. The exported output shall contain predefined classes which can help producing nice effects. See the examples below.
++
++For all the examples we will use the //~EmployeesList// query.
++The query embeds html tags to allow browsing from the last column rapidly to the employee's manager.
++//{{{
++SELECT
++	'<a id="' || "Employees"."EmployeeID" || '">' || "Employees"."LastName" || '</a>' AS "Last name"
++	, "Employees"."FirstName" AS "First name"
++	, "Employees"."BirthDate" AS "Birth"
++	, "Employees"."Extension" AS "Phone"
++	, "Employees"."HomePhone" AS "Home phone"
++	, "Employees"."Title"
++	, '<a href="#' || "ReportingTo"."EmployeeID" || '">' || "ReportingTo"."LastName" || '</a>' AS "Manager"
++FROM
++	{ OJ "Employees" AS "ReportingTo" RIGHT OUTER JOIN "Employees" ON "ReportingTo"."EmployeeID" = "Employees"."ReportsTo" }
++//}}}
++based on the //Employees// table:
++<<tiddler EmployeesTable>>
++The data will be generated by next statement:
++//{{{
++	DoCmd.OutputTo(acOutputQuery, "EmployeesList", acFormatHtml, sOutputFile, False, sTemplateFile, acUTF8Encoding)
++//}}}
++The template file contains nothing else but:
++//{{{
++<!DOCTYPE html>
++<html>
++ <head>
++  <title><!--Template_Title--></title>
++  <link rel="stylesheet" type="text/css" href="styleX.css">
++ </head>
++ <body>
++  <!--Template_Body-->
++ </body>
++</html>
++//}}}
++Only the content of the css stylesheet will vary in next examples.
++!!Raw data without styling effects
++!!!Stylesheet
++The stylesheet is empty.
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="270" frameborder="0" scrolling="yes" src="_outputto/output1.html" title="Raw Data"></iframe>
++</html>
++!!Specify the table and the table caption
++The ''.dbdatatable'' class designates the whole table. Use it to avoid confusion when other tables are present in the template file.
++!!!Stylesheet
++//{{{
++body {
++    font-size: 100%;
++}
++.dbdatatable {
++  padding: 0;
++  margin: 0;
++  border-collapse: collapse;
++  border: 1px solid #333;
++  font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
++  font-size: 0.9em;
++  color: #000;
++  background: #bcd0e4;
++}
++.dbdatatable caption {
++  caption-side: bottom;
++  font-size: 0.9em;
++  font-style: italic;
++  text-align: right;
++  padding: 0.5em 0;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="250" frameborder="0" scrolling="yes" src="_outputto/output2.html" title="Sample border"></iframe>
++</html>
++!!Specify the table cells
++Both the header row and data cells receive in the example the same styles. The bold character of table header cells is implicit.
++!!!Stylesheet
++Same as before + ...
++//{{{
++.dbdatatable th, .dbdatatable td {
++  border: 1px dotted #666;
++  padding: 0.5em;
++  text-align: left;
++  color: #632a39;
++  vertical-align: middle;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="380" frameborder="0" scrolling="yes" src="_outputto/output3.html" title="Sample border"></iframe>
++</html>
++!!Specify the header row
++Uppercases, white text.
++!!!Stylesheet
++Same as before + ...
++//{{{
++.dbdatatable th {
++  color: #fff;
++  background-color: #8fadcc;
++  text-transform: uppercase;
++  background-color: #7d98b3;
++  border-right: 1px dotted #666;
++  text-align: center;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="380" frameborder="0" scrolling="yes" src="_outputto/output4.html" title="Sample border"></iframe>
++</html>
++!!Specify alternate colors for the table rows
++Use the ''.odd'' and/or ''.even'' classes to specify different styles for the table rows
++!!!Stylesheet
++The same as before + ...
++//{{{
++.dbdatatable tr.odd th, .dbdatatable tr.odd td {
++  background-color: #fff;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="380" frameborder="0" scrolling="yes" src="_outputto/output5.html" title="Sample border"></iframe>
++</html>
++!!Specify a row appearance change when mouse hovers it
++!!!Stylesheet
++The same as before + ...
++//{{{
++.dbdatatable tr:hover td {
++  background-color: #632a2a;
++  color: #fff;
++}
++.dbdatatable tr:hover a {
++  background-color: #632a2a;
++  color: #fff;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="380" frameborder="0" scrolling="yes" src="_outputto/output6.html" title="Sample border"></iframe>
++</html>
++!!Specify cells depending on their content or type
++Use the ''.char'', ''.numeric'', ''.bool'', ''.date'', ''.negative'' and ''.null'' classes.
++!!!Stylesheet
++Same as before + ...
++//{{{
++.dbdatatable td.numeric {
++	text-align: right;
++}
++.dbdatatable td.negative {
++	color: red;
++}
++.dbdatatable td.null {
++	background-color: red;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="380" frameborder="0" scrolling="yes" src="_outputto/output7.html" title="Sample border"></iframe>
++</html>
++!!Emphasize first and last row borders
++Use the ''.firstrow'', ''.lastrow'', .''firstcol'' and/or ''.lastcol'' classes to mark their borders specifically
++!!!Stylesheet
++All Together
++//{{{
++body {
++    font-size: 100%;
++}
++.dbdatatable {
++  padding: 0;
++  margin: 0;
++  border-collapse: collapse;
++  border: 1px solid #333;
++  font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
++  font-size: 0.9em;
++  color: #000;
++  background: #bcd0e4;
++}
++.dbdatatable caption {
++  caption-side: bottom;
++  font-size: 0.9em;
++  font-style: italic;
++  text-align: right;
++  padding: 0.5em 0;
++}
++.dbdatatable th, .dbdatatable td {
++  border: 1px dotted #666;
++  padding: 0.5em;
++  text-align: left;
++  color: #632a39;
++  vertical-align: middle;
++}
++.dbdatatable th {
++  color: #fff;
++  background-color: #8fadcc;
++  text-transform: uppercase;
++  background-color: #7d98b3;
++  border-right: 1px dotted #666;
++  text-align: center;
++}
++.dbdatatable tr.odd th, .dbdatatable tr.odd td {
++  background-color: #fff;
++}
++.dbdatatable tr:hover td {
++  background-color: #632a2a;
++  color: #fff;
++}
++.dbdatatable tr:hover a {
++  background-color: #632a2a;
++  color: #fff;
++}
++.dbdatatable td.numeric {
++	text-align: right;
++}
++.dbdatatable td.negative {
++	color: red;
++}
++.dbdatatable td.null {
++	background-color: red;
++}
++.dbdatatable tr.firstrow {
++	border-top: 3px solid #444;
++}
++.dbdatatable tr.lastrow {
++	border-bottom: 3px solid #444;
++}
++//}}}
++!!!Result
++<html>
++<iframe style="background-color:#ffffff; border-color:#ffffff; border:none;" width="1000" height="390" frameborder="0" scrolling="yes" src="_outputto/output8.html" title="Sample border"></iframe>
++</html>
++
++
++
A dialog may have several pages that can be traversed by the user step by step. The //Page// property of the [[Dialog object|Dialog]] defines which page of the dialog is active. At runtime the next page of a dialog is displayed by increasing the page value by 1.
++
++The //Page// property of a control defines the page of the dialog on which the control is visible. For example, if a control has a page value of 1, it is only visible on page 1 of the dialog. If the page value of the dialog is increased from 1 to 2, then all controls with a page value of 1 disappear and all controls with a page value of 2 become visible.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a Dialog |!Description |
++|[[Dialog]] |>|>| NA |The page to be displayed |
++|[[Control]] | None | None | All |The page to which the control belongs |
++!!!Syntax
++//dialog//{{{.Page}}}
++//dialog//{{{.Page}}} = //value//
++//control//{{{.Page}}}
++//control//{{{.Page}}} = //value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++The page value 0 has a special role. If a control has a page value of 0, the control is displayed on all dialog pages. If a dialog has a page value of 0, all controls of the dialog are displayed, regardless of the page value of the individual controls. 
++!!!Error messages
++|Property 'Page' not applicable in this context |
++|Value '...' is invalid for property 'Page' |
++
++
++
<!--{{{-->
++<div class='header'>
++<div class='titleLine'>
++<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
++<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
++</div>
++</div>
++<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
++<div id='sidebar'>
++<div macro='gradient vert #ffffff #cc9900'><a> </a><div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
++</div>
++<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
++</div>
++<div id='displayArea'>
++<div id='messageArea'></div>
++<div id='tiddlersBar' refresh='none' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>
++<div id='tiddlerDisplay'></div>
++</div>
++<!--}}}-->
++
++
++
The //Parent// property returns the parent object of a [[Control]] or of a [[SubForm]].
++!!!Applies to ...
++| !Object |!Description |
++|[[SubForm]] |A subform of an open form. |
++|[[Control]] |A control of an open form. |
++|[[CommandBarControl]] |An element of a commandbar. |
++!!!Syntax
++//subform//{{{.Parent}}}
++//control//{{{.Parent}}}
++//commandbarcontrol//{{{.Parent}}}
++!!!Returned values
++{{{Object}}}
++!!!Remarks
++*The Parent property is read-only.
++*The parent can be itself an object of type [[Control]], [[SubForm]], [[Form]], [[Dialog]] or [[CommandBar]].
++!!!Error messages
++!!!Example
++<<tiddler "Parent example">>
++
++
++
Browse objects tree upwards
++//{{{
++Dim oSomeObject As Object
++	Set oSomeObject = getObject("Forms!Invoice!SubForm.Form!SubForm_Grid![SeqNr Invoice]")
++	While Not IsNull(oSomeObject)
++		Print oSomeObject.Name,
++		Set oSomeObject = oSomeObject.Parent
++	Wend
++//}}}
++
++
++
The //Picture// property specifies a bitmap or other type of graphic to be displayed on the specified control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when in a Dialog |!Description |
++|[[Control]] | ~CommandButton<br />~ImageButton<br />~ImageControl | None | ~CommandButton<br />~ImageControl |A control on an open form or a dialog of one of the listed types. |
++!!!Syntax
++//control//{{{.Picture}}}
++//control//{{{.Picture}}} = //value//
++!!!Returned value / Argument
++{{{String}}}
++!!!Remarks
++*The control MUST NOT be bound to a database field.
++*The {{{value}}} argument may be provided either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).<br />However the argument is always returned in the URL format.
++!!!Error messages
++|Property 'Picture' not applicable in this context |
++|Value '...' is invalid for property 'Caption' |
++!!!Example
++<<tiddler "Picture example">>
++
++
++
Modify the picture displayed in an ~ImageControl control.
++//{{{
++Dim ofForm As Object, ocControl As Object
++	Set ofForm = Forms("myForm")			'	Form must be open
++	Set ocControl = ofForm.Controls("MyImage")
++	ocControl.Picture = "C:\MyPicture.jpg"
++//}}}
++
++
++
The //~ProcBodyLine// property returns the number of the line at which the body of a specified procedure begins in a standard or a class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.ProcBodyLine(}}}//~ProcName, ~ProcKind//{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Type | !Optional | !Description | !Returned type |
++|module | Object ||The concerned module. | Long |
++|~ProcName | String | N |The name of a procedure in the module. |~|
++|~ProcKind | Integer | N |The type of procedure. It can be one of the following constants:<br />vbext_pk_Get<br />vbext_pk_Let<br />vbext_pk_Proc<br />vbext_pk_Set |~|
++!!!Remarks
++*Lines in a module are numbered beginning with 1.
++*The body of a procedure begins with the procedure definition, denoted by one of the following:
++**A {{{Sub}}} statement.
++**A {{{Function}}} statement.
++**A {{{Property Get}}} statement.
++**A {{{Property Let}}} statement.
++**A {{{Property Set}}} statement.
++*The //~ProcBodyLine// property returns a number that identifies the line on which the procedure definition begins. In contrast, the [[ProcStartLine]] property returns a number that identifies the line at which a procedure is separated from the preceding procedure in a module. Any comments that precede the procedure definition (the body of a procedure) are considered part of the procedure, but the //~ProcBodyLine// property ignores them.
++*The //~ProcStartLine// and //~ProcBodyLine// properties can have the same value, if the procedure definition is the first line of the procedure. If the procedure definition isn't the first line of the procedure, the //~ProcBodyLine// property will have a greater value than the //~ProcStartLine// property.
++*If useful, insert the following constants in your own code:
++//{{{
++Const vbext_pk_Get = 1			'	A Property Get procedure
++Const vbext_pk_Let = 2			'	A Property Let procedure
++Const vbext_pk_Proc = 0			'	A Sub or Function procedure
++Const vbext_pk_Set = 3			'	A Property Set procedure
++//}}}
++!!!Error messages
++|Property '~ProcBodyLine' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[ProcCountLines]]
++[[ProcOfLine]]
++[[ProcStartLine]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
The //~ProcCountLines// property eturns the number of lines in a specified procedure in a standard or a class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.ProcCountLines(}}}//~ProcName, ~ProcKind//{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Type | !Optional | !Description | !Returned type |
++|module | Object ||The concerned module. | Long |
++|~ProcName | String | N |The name of a procedure in the module. |~|
++|~ProcKind | Integer | N |The type of procedure. It can be one of the following constants:<br />vbext_pk_Get<br />vbext_pk_Let<br />vbext_pk_Proc<br />vbext_pk_Set |~|
++!!!Remarks
++*A procedure begins with any comments that immediately precede the procedure definition, denoted by one of the following:
++**A {{{Sub}}} statement.
++**A {{{Function}}} statement.
++**A {{{Property Get}}} statement.
++**A {{{Property Let}}} statement.
++**A {{{Property Set}}} statement.
++*The //~ProcCountLines// property returns the number of lines in a procedure, beginning with the line returned by the [[ProcStartLine]] property and ending with the line that ends the procedure. The procedure may be ended with {{{End Sub}}}, {{{End Function}}}, or {{{End Property}}}.
++*If useful, insert the following constants in your own code:
++//{{{
++Const vbext_pk_Get = 1			'	A Property Get procedure
++Const vbext_pk_Let = 2			'	A Property Let procedure
++Const vbext_pk_Proc = 0			'	A Sub or Function procedure
++Const vbext_pk_Set = 3			'	A Property Set procedure
++//}}}
++!!!Error messages
++|Property '~ProcCountLines' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[ProcBodyLine]]
++[[ProcOfLine]]
++[[ProcStartLine]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
The //~ProcOfLine// property returns the name of the procedure that contains a specified line in a standard or a class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.ProcOfLine(}}}//Line, ~ProcKind//{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Type | !Optional | !Description | !Returned type |
++|module | Object ||The concerned module. | String |
++|Line | Long | N |The number of a line in the module. |~|
++|~ProcKind | Integer | N |The type of procedure. After execution it will contain one of the following constants:<br />vbext_pk_Get<br />vbext_pk_Let<br />vbext_pk_Proc<br />vbext_pk_Set |~|
++!!!Remarks
++*Lines in a module are numbered beginning with 1.
++*For any given line number, the //~ProcOfLine// property returns the name of the procedure that contains that line. Since comments immediately preceding a procedure definition are considered part of that procedure, the //~ProcOfLine// property may return the name of a procedure for a line that isn't within the body of the procedure. The [[ProcStartLine]] property indicates the line on which a procedure begins; the [[ProcBodyLine]] property indicates the line on which the procedure definition begins (the body of the procedure).
++*Note that the //~ProcKind// argument indicates whether the line belongs to a {{{Sub}}} or {{{Function}}} procedure, a {{{Property Get}}} procedure, a {{{Property Let}}} procedure, or a {{{Property Set}}} procedure. To determine what type of procedure a line is in, pass a variable of type {{{Integer}}} to the ProcOfLine property, then check the value of that variable.
++*If useful, insert the following constants in your own code:
++//{{{
++Const vbext_pk_Get = 1			'	A Property Get procedure
++Const vbext_pk_Let = 2			'	A Property Let procedure
++Const vbext_pk_Proc = 0			'	A Sub or Function procedure
++Const vbext_pk_Set = 3			'	A Property Set procedure
++//}}}
++!!!Error messages
++|Property '~ProcOfLine' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[ProcBodyLine]]
++[[ProcCountLines]]
++[[ProcStartLine]]
++!!!Example
++<<tiddler "Module example">> in a standard or a class [[module|Module]].
++
++
++
++
The //~ProcStartLine// property returns a value identifying the line at which a specified procedure begins in a standard or a class [[module|Module]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Module]] |The representation of a Basic script. |
++!!!Syntax
++//module//{{{.ProcStartLine(}}}//~ProcName, ~ProcKind//{{{)}}}
++!!!Returned values / Arguments
++| !Argument | !Type | !Optional | !Description | !Returned type |
++|module | Object ||The concerned module. | Long |
++|~ProcName | String | N |The name of a procedure in the module. |~|
++|~ProcKind | Integer | N |The type of procedure. It can be one of the following constants:<br />vbext_pk_Get<br />vbext_pk_Let<br />vbext_pk_Proc<br />vbext_pk_Set |~|
++!!!Remarks
++*Lines in a module are numbered beginning with 1.
++*A procedure begins with any comments that immediately precede the procedure definition, denoted by one of the following:
++**A {{{Sub}}} statement.
++**A {{{Function}}} statement.
++**A {{{Property Get}}} statement.
++**A {{{Property Let}}} statement.
++**A {{{Property Set}}} statement.
++*The //~ProcStartLine// property returns the number of the line on which the specified procedure begins. The beginning of the procedure may include comments that precede the procedure definition.<br />To determine the line on which the procedure definition begins, use the [[ProcBodyLine]] property. This property returns the number of the line that begins with a {{{Sub}}}, {{{Function}}}, {{{Property Get}}}, {{{Property Let}}}, or {{{Property Set}}} statement.
++*The //~ProcStartLine// and //~ProcBodyLine// properties can have the same value, if the procedure definition is the first line of the procedure. If the procedure definition isn't the first line of the procedure, the //~ProcBodyLine// property will have a greater value than the //~ProcStartLine// property.
++*If useful, insert the following constants in your own code:
++//{{{
++Const vbext_pk_Get = 1			'	A Property Get procedure
++Const vbext_pk_Let = 2			'	A Property Let procedure
++Const vbext_pk_Proc = 0			'	A Sub or Function procedure
++Const vbext_pk_Set = 3			'	A Property Set procedure
++//}}}
++!!!Error messages
++|Property '~ProcStartLine' not applicable in this context |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[ProcBodyLine]]
++[[ProcCountLines]]
++[[ProcOfLine]]
++!!!Example
++<<tiddler "Module example">>
++
++
++
The //~ProductCode// property returns "~Access2Base x.y.z" where x.y.z equals the version number of the library.
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]ProductCode}}}
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++!!!Error messages
++!!!See also
++[[CurrentUser]]
++[[Version]]
++!!!Example
++<<tiddler "Identification example">>
++
++
++
*Products table
++| !Fields | !Field Type | !Primary |
++|~CategoryID | ~BigInt ||
++|~ProductName | Text ||
++|~QuantityPerUnit | Text ||
++|~ReorderLevel | Integer ||
++|~SupplierID | ~BigInt ||
++|~UnitPrice | Number ||
++|~UnitsInStock | Integer ||
++|~UnitsOnOrder | Integer ||
++|Discontinued | Boolean ||
++|~ProductID | ~BigInt | Y |
++|Picture | Image ||
++
++
++

++
++
++
The //Properties// collection describes instances of all __properties__ of an [[object|Object Model]]
++!!!Syntax
++//object//.{{{Properties()}}}
++//object//.{{{Properties(index)}}} or //object//.{{{Properties(propertyname)}}}
++| !Argument | !Type |!Returned value |
++|| absent |A [[Collection]] of the properties of the object |
++| index | integer<br />long |A [[property|Property]] object |
++| propertyname | string |~|
++!!!Remarks
++*Property [[collections|Collection]] are numbered from 0 to //object//.{{{Properties(...).Count - 1}}}
++*The //propertyname// argument is not case sensitive.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection Properties() |
++!!!See also
++[[Property]]
++[[hasProperty]]
++[[getProperty]]
++[[setProperty]]
++!!!Examples
++<<tiddler "Properties example">>
++
++
++
++
To list the value of each property of a form ...
++//{{{
++Dim ofForm As Object, i As Integer, iCount As Integer, oProperty As Object
++	Set ofForm = Forms("myForm")
++	iCount = ofForm.Properties.Count
++	For i = 0 To iCount - 1
++		Set oProperty = ofForm.Properties.Item(i)
++		Print oProperty.Name & "=" & oProperty).Value
++	Next i
++	Print
++//}}}
++
++
++
The {{{Property}}} [[object|Object Model]] describes a ~Name-Value pair of any property of any other object.
++!!!Functions returning a property object
++| !Parent object | !Function | !Type |!Description |
++| Any |[[Properties|Properties (collection)]] | [[Collection]] |//object//.{{{Properties(}}}//property-name//{{{)}}} returns a //Property// object. |
++!!!Properties of the returned object
++| !Property | !Type | !Description |
++|[[Name]] | String ||
++|[[ObjectType]] | String |Returns "PROPERTY" |
++|[[Value]] | Variant |The value of the considered property (might be an array). |
++!!!Syntax
++//property//{{{.Name}}}
++//property//{{{.Value}}}
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Property object has the given property. |
++!!!Remarks
++*All properties of a //Property// object are read-only.
++!!!See also
++[[Properties|Properties (collection)]]
++[[hasProperty]]
++[[getProperty]]
++[[setProperty]]
++!!!Example
++<<tiddler "Properties example">>
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}}//~QueryDef// [[object|Object Model]] describes one of the Queries located in a database document (".odb" file).
++!!!Function returning a //~QueryDef// object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Database]] |[[QueryDefs]] | [[Collection]] | Integer or String |{{{Application.CurrentDb().QueryDefs("myQuery")}}} returns an object corresponding with the {{{myQuery}}} query |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[Name]] || Y |Specifies the exact name of the query |
++|[[ObjectType]] || Y |Returns "QUERYDEF" |
++|[[SQL]] |||Specifies the SQL statement related to the query |
++|[[Type]] || Y |Classifies the query |
++|Query | UNO | Y |com.sun.star.sdb.dbaccess.~OQuery |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[Execute|Execute (query)]] | options | Boolean |Execute an action query. |
++|[[Fields]] | None<br />Index<br />Name | [[Collection]] |Return the collection of the fields belonging to the query. |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the //~QueryDef// has the given property. |
++|[[OpenRecordset]] | options | [[Recordset]] |Return a recordset object allowing access to the query data. |
++|[[setProperty]] | property<br />value | Boolean |Return True if the given property could be set. |
++!!!Remarks
++!!!See also
++[[TableDef]]
++!!!Examples
++<<tiddler "Datadef example">>
++
++
++
The //~QueryDefs// collection describes instances of all __queries__ present in the current database.
++!!!Syntax
++{{{database.QueryDefs()}}}
++{{{database.QueryDefs(index)}}}
++{{{database.QueryDefs(queryname)}}}
++| !Object | !Type | !Argument | !Type |!Returned value |
++|database |[[Database object|Database]] | absent ||A [[Collection]] object |
++|~|~| index | integer<br>long |A [[QueryDef]] object corresponding to the index-th item in the ~QueryDefs() collection. The 1st query is ~QueryDefs(0), the 2nd is ~QueryDefs(1) and so on ... The last one is ~QueryDefs.Count - 1.|
++|~|~| queryname | string |A [[QueryDef]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Methods
++| !Method | !Description |
++|[[Delete|Delete (table-query)]]|Delete an existing //~QueryDef//. |
++!!!Remarks
++The //queryname// argument is not case sensitive.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection ~QueryDefs() |
++|Query '...' not found |
++!!!See also ...
++[[CreateQueryDef]]
++[[TableDefs]]
++[[Recordsets]]
++!!!Example
++<<tiddler "Datadef example">>
++
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //Quit// action quits //~OpenOffice/~LibreOffice Base//. You can select one of several options for saving the database document before quitting.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]Quit(}}}//{{{Option}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{Option}}} | Yes | acQuitPrompt, acQuitSaveAll, acQuitSaveNone |//acQuitPrompt// Displays a dialog box that asks whether you want really to quit or not.<br />//acQuitSaveAll// (default) Saves all objects without displaying a dialog box.<br />//acQuitSaveNone// Quits without saving any objects. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acQuitPrompt = 0
++Const acQuitSaveAll = 1
++Const acQuitSaveNone = 2
++//}}}
++!!!Remarks
++*The Quit action has the same effect as clicking Exit on the File menu in the //~OpenOffice/~LibreOffice Base// window.
++*In //~MSAccess// the //Quit// method is linked to the [[Application]] object.
++*The //Quit// action must not be triggered from a [[standalone form|Standalone Forms]].
++!!!Error messages
++|Action not applicable in this context |
++!!!See also
++!!!Example
++Display next message box: ''Do you really want to quit the application ? Changed data will be saved.''
++If Yes pressed, the application will close.
++//{{{
++	DoCmd.Quit(acQuitPrompt)
++//}}}
++
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~RadioButton// [[control|Control]] enables the user to choose among one of several options.
++Radio buttons are grouped in the sense that selecting one deselects all the others.
++>In [[forms|Form]] and [[subforms|SubForm]] all //~RadioButtons// in a group share the same name (Name property). 
++>In [[dialogs|Dialog]] the //~RadioButtons// constituting a group have contiguous [[TabIndex]] properties.
++Usually, //~RadioButtons// are grouped in a group box. In //AOO/~LibO// group boxes play only a graphical role.
++!!!Specific properties of radio buttons
++| !Property | !Read only | !Description |
++|[[Name]] | Y |Specifies the exact name of the [[OptionGroup]]. |
++|[[OptionValue]] | Y |Specifies the value that is stored in the database when the radio button is selected and the record saved. |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~RadioButton has the given property. |
++|[[Requery]] ||~|True if data reloaded in the ~RadioButton |
++|[[SetFocus]] | none |~|Return True if focus set on Control successfully. |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++The ~RadioButton control has no //Value// property.
++To identify the selected radio button, use the [[OptionGroup method|OptionGroup (Method)]] and the [[Value]] property of the returned [[OptionGroup]] object.
++!!!See also
++[[OptionGroup (Method)]]
++[[OptionGroup]]
++[[TabIndex]]
++!!!Example
++<<tiddler "Optiongroup example">>
++
++
++
The //~ReadAllBytes// method imports the content of a file specified by its full name into a binary [[Field]] belonging to a [[Recordset]].
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.~DataType.BINARY<br />com.sun.star.sdbc.~DataType.VARBINARY<br />com.sun.star.sdbc.~DataType.LONGVARBINARY |
++!!!Syntax
++//field//{{{.ReadAllBytes(}}}//file//{{{)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++| file | String |The full name, including the path, of the file you want to import the data from. |
++!!!Remarks
++*The //~ReadAllBytes// method must be preceeded by a [[AddNew]] or [[Edit]] method and followed by an [[Update]] method, both applied to the concerned //Recordset//.
++*The {{{file}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++!!!Error messages
++|Method '~ReadAllBytes' not applicable in this context |
++|File access error on file '...' |
++|Recordset or field is not updatable |
++|Recordset update sequence error |
++!!!See also
++[[ReadAllText]]
++[[Value|Value (field)]]
++[[WriteAllBytes]]
++[[WriteAllText]]
++!!!Example
++<<tiddler "ReadAllBytes example">>
++
++
++
Save the image stored in a file into a new record
++//{{{
++Dim oRecordset As Object, sFile As String
++	sFile = "C:\..."
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Products")
++	With oRecordset
++		.AddNew			'	All fields are initialized with their default value
++		.Fields("IMAGE").ReadAllBytes(sFile)
++	'	 ... Other fields can be set by setting their Value property
++		.Update
++	End With
++	oRecordset.mClose()
++//}}}
++
++
++
The //~ReadAllText// method imports the content of a file specified by its full name into a memo [[Field]] belonging to a [[Recordset]].
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.DataType.LONGVARCHAR |
++!!!Syntax
++//field//{{{.ReadAllText(}}}//file//{{{)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++| file | String |The full name, including the path, of the file you want to import the data from. |
++!!!Remarks
++*The //~ReadAllText// method must be preceeded by a [[AddNew]] or [[Edit]] method and followed by an [[Update]] method, both applied to the concerned //Recordset//.
++*The {{{file}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++*The text file must NOT BE LONGER than 64K.
++!!!Error messages
++|Method '~ReadAllText' not applicable in this context |
++|File access error on file '...' |
++|Recordset or field is not updatable |
++|Recordset update sequence error |
++!!!See also
++[[ReadAllBytes]]
++[[Value|Value (field)]]
++[[WriteAllBytes]]
++[[WriteAllText]]
++!!!Example
++<<tiddler "ReadAllText example">>
++
++
++
Save the image stored in a file into a new record
++//{{{
++Dim oRecordset As Object, sFile As String
++	sFile = "C:\..."
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Products")
++	With oRecordset
++		.AddNew			'	All fields are initialized with their default value
++		.Fields("MEMOFIELD").ReadAllText(sFile)
++	'	 ... Other fields can be set by setting their Value property
++		.Update
++	End With
++	oRecordset.mClose()
++//}}}
++
++
++
You can use the //~RecordCount// property to specify the number of records accessed in a [[Recordset]] object.
++!!!Applies to ...
++| !Object |!Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement |
++!!!Syntax
++//recordset//{{{.RecordCount}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++*The //~RecordCount// property is read-only.
++*Use the //~RecordCount// property to find out how many records in a //Recordset// object have been accessed. The //~RecordCount// property doesn't indicate how many records are contained in a //Recordset// object until all records have been accessed. Once the last record has been accessed, the //~RecordCount// property indicates the total number of undeleted records in the //Recordset// object. To force the last record to be accessed, use the [[MoveLast|Move (recordset)]] method on the //Recordset// object. You can also use an SQL Count function to determine the approximate number of records your query will return.
++*Note: using the //~MoveLast// method to populate a newly opened //Recordset// negatively impacts performance. Unless it is necessary to have an accurate //~RecordCount// as soon as you open a //Recordset//, it's better to wait until you populate the //Recordset// with other portions of code before checking the //~RecordCount// property.
++!!!Error messages
++!!!See also
++[[MoveLast|Move (recordset)]]
++[[Recordset|Recordset (property)]]
++!!!Example
++<<tiddler "Filter2 example">>
++
++
++
You can use the //~RecordSource// property to specify the source of the data displayed in a form.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[SubForm]] |The subform of an open form |
++!!!Syntax
++//form//{{{.RecordSource}}}
++//form//{{{.RecordSource}}} = //value//
++//subform//{{{.RecordSource}}}
++//subform//{{{.RecordSource}}} = //value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++The //~RecordSource// property is a string expression consisting of either
++*a table name
++*a query name
++*a SQL statement including the SELECT verb
++However to modify the ~RecordSource property, use __only a SQL statement__. When the ~RecordSource property value is changed, the //form// or //subform// is reloaded automatically.
++
++After modification of the //~RecordSource// any preexisting filter on the form is reset.
++!!!Error messages
++|Form '...' is currently not open |
++|Value '...' is invalid for property '~RecordSource' |
++!!!See also
++[[ControlSource]]
++[[Requery]]
++!!!Example
++<<tiddler "RecordSource example">>
++
++
++
Set new data source on open form
++//{{{
++Dim ofForm As Object, sSQL As String
++	ofForm = Forms("myForm")
++	sSQL = "SELECT * FROM [EMPLOYEE] WHERE " _
++		& "[EMPLOYEE].[NAME] LIKE '*MICKEY*' Or [EMPLOYEE].[NAME] LIKE '*WINNIE*'"
++	ofForm.RecordSource = sSQL
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //Recordset// object represents the records in a base table or the records that result from running a query. A cursor technique allows to walk through the records of the recordset.
++!!!Functions returning a recordset object
++| !Parent object | !Method | !Type |
++|[[Database]] |[[Recordsets]] | [[Collection]] |
++|[[Database]] |[[OpenRecordset]] ||
++|[[TableDef]] |~|~|
++|[[QueryDef]] |~|~|
++|//Recordset// |[[OpenRecordset]] |~|
++|~|[[Clone]] |~|
++|[[Form]] |[[Recordset|Recordset (property)]] |~|
++|[[SubForm]] |~|~|
++!!!Properties
++| !Property | !Type | !Read only |!Description or UNO object |
++|[[AbsolutePosition]] |||Sets or returns the relative record number of a //Recordset//. |
++|[[BOF|BOF, EOF]] || Y |Specifies if the recordset cursor is placed before the first record. |
++|[[Bookmark]] |||Sets or returns a bookmark that uniquely identifies the current record in a //Recordset// object. |
++|[[Bookmarkable]] || Y |Returns a value that indicates whether a //Recordset// object supports bookmarks. |
++|[[EditMode]] || Y |Indicates the state of editing for the current record. |
++|[[EOF|BOF, EOF]] || Y |Specifies if the recordset cursor is placed after the last record. |
++|[[Filter]] |||Specifies a selection to be set on the current recordset before opening with [[OpenRecordset]] a new derived recordset. |
++|[[Name]] || Y |Specifies the name assigned by ~Access2Base to the recordset. |
++|[[ObjectType]] || Y |Returns "RECORDSET". |
++|[[RecordCount]] || Y |Returns the number of records of the recordset. |
++|~RowSet | UNO | Y |com.sun.star.comp.dba.~ORowSet |
++!!!Methods
++| !Method | !Description |
++|[[AddNew]] |Initiate the creation of a new record. |
++|[[CancelUpdate]] |Cancel on-going updates. |
++|[[Clone]] |Create a duplicate //Recordset// object that refers to the current one. |
++|[[Close|Close (method)]] |Close the //Recordset// object. The object is not usable anymore. |
++|[[Delete]] |Delete the current record. |
++|[[Edit]] |Initiate the update of fields in the current record. |
++|[[Fields]] |Access the collection of fields of the recordset. |
++|[[getProperty]] |Return the value of the given property. |
++|[[GetRows]] |Retrieve multiple rows at once. |
++|[[hasProperty]] |Return True if the Recordset has the given property. |
++|[[Move|Move (recordset)]]|Walk through the recordset. |
++|[[MoveFirst|Move (recordset)]] |~|
++|[[MoveLast|Move (recordset)]] |~|
++|[[MoveNext|Move (recordset)]] |~|
++|[[MovePrevious|Move (recordset)]] |~|
++|[[OpenRecordset]] |derive a new //Recordset// object from the current one. |
++|[[setProperty]] |Return True if the given property could be set. |
++|[[Update]] |Confirm on-going updates. |
++!!!Remarks
++*A new //Recordset// object is automatically added to the [[Recordsets]] collection when you open the object, and is automatically removed when you close it.
++*You can create as many //Recordset// object variables as needed. Different //Recordset// objects can access the same tables, queries, and fields without conflicting.
++*When you create a //Recordset// object, the current record is positioned to the first record if there are any records. If there are no records, the [[RecordCount]] property setting is 0, and the [[BOF|BOF, EOF]] and [[EOF|BOF, EOF]] property settings are {{{True}}}.
++*Information about the structure of a base table, such as the names and data types of each [[Field]] object, is contained in a [[TableDef]] object.
++!!!Example
++<<tiddler "OpenRecordset example">>
++
++
++
Returns a [[Recordset]] object representing the record source for the specified form or subform.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form. |
++|[[SubForm]] |A subform in an open form. |
++!!!Syntax
++//form//{{{.Recordset}}}
++//subform//{{{.Recordset}}}
++!!!Returned values
++[[Recordset object|Recordset]]
++!!!Remarks
++*The //Recordset// property is read-only.
++*The //Recordset// property returns the recordset object that provides the data being browsed in a form. However walking thru the form or walking thru the recordset will remain independent from each other.
++!!!Error messages
++|Property 'Recordset' not applicable in this context |
++!!!See also
++[[OpenRecordset]]
++[[Recordset]]
++!!!Example
++
++
++
The //Recordsets// collection describes instances of all __recordsets__ that are currently open in relation with a given [[database object|Database]].
++!!!Syntax
++{{{database.Recordsets()}}}
++{{{database.Recordsets(index)}}}
++{{{database.Recordsets(recordsetname)}}}
++| !Object | !Type | !Argument | !Type |!Returned value |
++|database |[[Database object|Database]] | absent ||A [[Collection]] object |
++|~|~| index | integer<br>long |A [[Recordset]] object corresponding to the index-th item in the ~Recordsets() collection. The 1st recordset is Recordsets(0), the 2nd is Recordsets(1) and so on ... The last one is Recordsets.Count - 1.|
++|~|~| recordsetname | string |A [[Recordset]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Remarks
++*The //recordsetname// argument is not case sensitive.
++*The name of a recordset is not chosen by the user or the programmer. It is defined as a unique name by ~Access2Base. As a consequence the use of the syntax based on the recordsetname requires the name to be kept somewhere to allow the retrieval of the recordset object. See the example.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection Recordsets() |
++|Recordset '...' not found |
++!!!See also ...
++[[QueryDefs]]
++[[TableDefs]]
++!!!Example
++<<tiddler "Recordsets example">>
++
++
++
A recordset is created somewhere
++//{{{
++Global sRSName As String
++'---------------------------------------
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().OpenRecordset("SELECT * FROM [PRODUCTS]")
++	sRSName = oRecordset.Name
++//}}}
++... then, elsewhere, for instance in an event ... next construction is valid:
++//{{{
++Dim oRecordset As Object
++	Set oRecordset = Application.CurrentDb().Recordsets(sRSName)
++	'...
++//}}}
++
++
++
++
The //Refresh// method immediately updates the records in the underlying record source for a specified form to reflect changes made to the data by you or other users in a multiuser environment.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |The representation of an open database form. |
++|[[SubForm]] |A subset of the [[Controls|Control]] present in a Form. |
++!!!Syntax
++//form.//{{{Refresh}}}
++//subform.//{{{Refresh}}}
++!!!Remarks
++!!!Error messages
++!!!See also
++[[RecordSource]]
++[[Requery]]
++!!!Example
++<<tiddler "Refresh example">>
++
++
++
Refresh the data in the current record of a form
++//{{{
++Dim ofForm As Object
++	Set ofForm = Application.Forms("myForm")
++	ofForm.Refresh
++//}}}
++
++
++
| !Release | !Date | !Description | !Embedded in ... |
++| 6.2.0 | 02/2019 |Support of hierarchical form names.<br />Support of (embedded) Firebird 3.0 database system. | ~LibreOffice 6.2 |
++| 1.9.0 | 07/2018 |Base forms may contain more than 1 root form, all belonging to a forms collection, each of them having its own data source (NB: ~MSAccess does not have that feature). It is now supported by ~Access2Base<br />A translation in german is provided (thanks to Gisbert Friege). | ~LibreOffice 6.1 |
++| 1.8.0 | 01/2018 |Database document and dialog events can be dynamically got and updated with the new [[On database events|On (database event)]] and [[On dialog events|On (dialog event)]]. | ~LibreOffice 6.0 |
++| 1.7.0 | 07/2017 |Form, subform and control events can be dynamically got and updated with the new [[On form events|On (form event)]]  and [[On control events|On (control event)]] properties.<br />The new [[module|Module]] object class and its properties and methods makes it easy to navigate through the Basic libraries attached to the current file or application. | ~LibreOffice 5.4 |
++| 1.6.0 | 01/2017 |The [[CopyObject]] action may copy tables (structure and data) from one database to another. As an experimental feature involved tables may even reside in different database systems.<br />The //database// class has received new properties: [[Name]], [[Connect]] and [[Version]].<br />Additionally, a spanish translation is provided (thanks to Iñigo Zuluaga). | ~LibreOffice 5.3 |
++| 1.5.0 | 08/2016 |More flexible management of (long) binary fields in databases with the addition of the [[GetChunk]] and [[AppendChunk]] methods to the [[field object|Field]].<br />Addition of the [[Picture]] property for //~ImageControl// controls. | ~LibreOffice 5.2 |
++| 1.4.0 | 01/2016 |The [[OutputTo]] action has been significantly enhanced. Output in one single Basic statement the content of a table or of a SELECT query into<br />- an html file. The data table can be embedded in a template file. Examples of table styling to make the output more attractive are available in this [[tutorial|OutputToStyling]];<br />- a Calc spreadsheet<br />- a text/csv file<br />The [[OpenQuery]] action is now applicable to action queries. | ~LibreOffice 5.1 |
++| 1.3.0 | 07/2015 |New [[CommandBars]] collection of [[CommandBar]] objects:<br />Easily show/hide menu bar, status bar, toolbars and toolbar elements. | ~LibreOffice 5.0 |
++| 1.2.0 | 01/2015 |All the methods which can meaningfully be used without a database connection (error handling, dialogs manipulations, status bar and window handling, commands launch, ...) have been reviewed and documented as acceptable before any //~OpenConnection// call.<br />A [[CloseConnection]] method has been added to allow freeing resources.<br />To pass values from one open document to another, use the [[TempVars]] collection of [[TempVar]] objects.<br />New properties for forms and subforms: [[OrderBy]] and [[OrderByOn]].<br />Additionally the new [[ApplyFilter]] and [[SetOrderBy]] actions are applicable on table or query datasheets, and on forms or subforms as well. Also the [[GoToRecord]] action has been extended to table and query datasheets.<br />Bug fixes and internal redesigns. | ~LibreOffice 4.4 |
++| 1.1.0 | 07/2014 |The ~Access2Base library can be run to access a database defined in any form defined in any AOO/~LibO document. Now the [[CurrentDb]] method may be associated with a form object, not only with the root class.<br />The [[OpenDatabase]] method allows any AOO/~LibO document or any Basic macro to get access to tables stored in any database.<br />The [[CopyObject]] (new) action copies query definitions and/or table d0000000efinitions and data.<br />Creation of table and fields without SQL with the [[CreateTableDef]], [[CreateField]] and [[Add]] methods.<br />The new [[GetRows]] method loads a given number of records from a recordset in a Basic array.<br />[[RunSQL]], [[OpenSQL]], database functions have been extended to be run from a database object, not only as a command.<br />New [[GetHiddenAttribute]] and [[SetHiddenAttribute]] actions hide or show any //AOO/~LibO// document or //Base// object. [[SelectObject]] scope has been extended accordingly.<br />The [[Description]] property of a //~TableDef// is writable.<br />Addition of the [[SelStart]], [[SelLength]] and [[SelText]] properties for text controls. | ~LibreOffice 4.3 |
++| 1.0.0 | 12/2013 |Inclusion of ~Access2Base code into the ~LibreOffice 4.2 build.<br />Code stabilisation, robustness improvements (naming collisions risks, error handler, ...)<br />Toggle sidebar in [[RunCommand]]<br/>Support of ~LibreOffice 4.2 new internal format for Time fields (compatibility with ~OpenOffice and older versions of ~LibreOffice is ensured). | ~LibreOffice 4.2 |
++| 0.9.5 | 08/2013 |Framework for database access:<br />[[TableDefs]], [[QueryDefs]], [[Recordsets]] and [[Fields]] collections.<br />[[TableDef]], [[QueryDef]], [[Recordset]] and [[Field]] objects.<br />Addition of the [[CurrentRecord]] and [[Recordset|Recordset (property)]] properties for //forms// and //subforms//.<br />Introspection improved with the [[Item]] property for //Collections//.<br />[[RunSQL]] and [[OpenSQL]] support //pass-through// mode of operation. ||
++| 0.9.1 | 04/2013 |Bug fixing.<br />Performance improvement when processing very large (1000+ items) listboxes.<br />Workaround implemented to survive the ~LibreOffice 4.0 bug described in [[BugZilla|https://www.libreoffice.org/bugzilla/show_bug.cgi?id=60752]].<br />Finalization of the [[Application]] object.<br />Implementation of the [[SysCmd]] method for the management of the status bars.<br />Redocumentation of the [[object model|Object Model]].<br />Addition of the [[Dialog]] object. <br />The [[Format]] property may be set programmatically for date and time controls.<br />Addition of the [[OpenSQL]] action. ||
++| 0.9.0 | 01/2013 |Complete internal redesign of code to allow more object-oriented syntaxes for property settings and method invocations.<br />E.g.<br />{{{form.height = 100}}}<br />{{{form.move(100,200)}}}<br />Old syntax still supported.<br />Consolidation of the object model with the [[Parent]], [[Source|Event]] and [[ObjectType]] properties.<br />Addition of a [[Close|Close (method)]] method to the //Form// object.<br />Several bugs corrections. ||
++| 0.8.9 | 10/2012 |Localization:<br />- of the 2 dialog forms<br />- of all strings (mainly error messages) used in the API<br />A french translation is provided.<br />For other languages, contributions are welcome. See [[Contact]]. ||
++| 0.8.6 | 09/2012 |Maintenance release. ||
++| 0.8.5 | 08/2012 |Introduction of new commands:<br />[[OutputTo]] for storing a form document as a PDF, DOC, ... file.<br />[[SendObject]] to send a form after transformation to PDF, DOC, ... by mail.<br />[[RunApp]] to start an external application. ||
++| 0.8.2 | 08/2012 |API implementation identical to 0.8.1<br />"Check for Updates ..." functionality of AAO/~LibO now detects ~Access2Base new versions. ||
++| 0.8.1 | 08/2012 |Maintenance release (bug in setValue method). ||
++| 0.8.0 | 07/2012 |Full support of [[standalone (Writer) forms|Standalone Forms]].<br />[[RadioButtons|RadioButton]] order is now determined by their ~X-Y coordinates on the screen.<br />Bug fixing in [[checkboxes controls|Control]] when linked to a database field.<br /> Support of "Currency" datatype in arguments to the API. Useful for controls of currency type. Converted to Double in internal processing. ||
++| 0.7.5 | 05/2012 |Support of [[Listboxes|ListBox]] with a separate column for bound fields.<br />Introduction of the [[Bookmark]] property of [[Form]] pseudo-objects.<br />New actions: [[ShowAllRecords]] and [[GoToControl]].<br />New methods for managing Listboxes content (with the //~ValueList// rowsource type): [[AddItem]] and [[RemoveItem]].<br />The [[RunSQL]] command accepts square brackets to surround field or table names. ||
++| 0.7.1 | 04/2012 |Correction of URL of online help. Clickable from Help menu in the Basic IDE. ||
++| 0.7.0 | 04/2012 |Bugs fixing in the [[SelectObject]] action (abort when help file open).<br />Extension of the scope of the [[SelectObject]] action.<br />Introduction of the [[RunCommand]] action. Documentation updated. ||
++| 0.6.0 | 04/2012 |New actions [[SelectObject]], [[Minimize]], [[Maximize]] and [[MoveSize]]<br />"~Access2Base Help" menu command in IDE opens Online help on [[www.access2base.com|http://www.access2base.com]]. ||
++| 0.5.1 | 03/2012 |"Out of array range" error message added for collections (i.o. "Invalid parameter"). ||
++| 0.5.0 | 03/2012 |First public release. ||
++
++
++
Erases a [[tempvar|TempVar]] object from the [[TempVars]] collection.
++!!!Applies to ...
++| !Object | !Description |
++|[[TempVars]] |The set of temporary variables. |
++!!!Syntax
++//application.~TempVars()//{{{.Remove(}}}//tempvarname//{{{)}}}
++| !Argument | !Type |!Returned value |
++|tempvarname | String |True if success.|
++!!!Remarks
++*The //tempvarname// argument is NOT case-sensitive.
++*By default, a //~TempVar// object remains in memory until ~LibO/AOO is closed. You can use the //Remove// method to remove a //~TempVar// object.
++!!!Error Messages
++|Temporary variable '...' not found |
++|Method 'Collection.Remove' not applicable in this context |
++!!!See also
++[[Add]]
++[[RemoveAll]]
++[[TempVar]]
++[[TempVars]]
++!!!Example
++<<tiddler "Tempvar example">>
++
++
++
Erases all [[tempvar|TempVar]] objects from the [[TempVars]] collection.
++!!!Applies to ...
++| !Object | !Description |
++|[[TempVars]] |The set of temporary variables. |
++!!!Syntax
++[Application.]{{{TempVars().RemoveAll()}}}
++!!!Remarks
++By default, a //~TempVar// object remains in memory until ~LibO/AOO is closed. You can use the //~RemoveAll// method to remove all //~TempVar// objects at once.
++!!!Error Messages
++|Method 'Collection.~RemoveAll' not applicable in this context |
++!!!See also
++[[Add]]
++[[Remove]]
++[[TempVar]]
++[[TempVars]]
++!!!Example
++<<tiddler "Tempvar example">>
++
++
++
The //~RemoveItem// method removes an item from the list of values displayed by the specified list box control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form or a dialog | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | [[ListBox]] | [[ListBox]] |A listbox on an open form, a dialog or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.RemoveItem(}}}//index//{{{)}}}
++| !Argument | !Type | !Description |
++| index | Integer<br />Long |The position in the list of the item to remove. |
++|~| String |The value of the item to remove. The comparison with the actual values in the list is case-sensitive. |
++!!!Remarks
++*The [[RowSourceType]] property (invalid in dialogs) of the concerned //~ListBox// must contain the value {{{com.sun.star.form.ListSourceType.VALUELIST}}}.
++*Combo boxes do not support this value. That's why //~RemoveItem// is applicable only on listboxes.
++*List item numbers start from zero. If the value of the {{{index}}} argument doesn't correspond to an existing item number, an error occurs.
++*//~RemoveItem// returns True if success, False otherwise. False is returned if {{{index}}} is a string and the string has not been found in the listbox.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Method not applicable in this context |
++!!!See also
++[[ListBox]]
++[[AddItem]]
++[[RowSource]]
++[[RowSourceType]]
++!!!Example
++<<tiddler "Addremoveitem example">>
++
++
++
The //Requery// method updates the data underlying a specified control that's on the active form by requerying the source of data for the control.
++If the target is a [[Form]] and the source is a //Parameter Query// the parameters are re-asked to the user.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |The representation of an //~OpenOffice/~LibreOffice// database form. |
++|[[SubForm]] |A subset of the [[Controls|Control]] present in a Form. |
++|[[ComboBox]] |A combobox control. |
++|[[ListBox]] |A listbox control. |
++!!!Syntax
++//form.//{{{Requery}}}
++//subform.//{{{Requery}}}
++//control.//{{{Requery}}}
++!!!Remarks
++If the targeted object is a Form or a ~SubForm the //Requery// method resets the current record to the first available in the record set.
++!!!Error messages
++!!!See also
++[[Filter]]
++[[FilterOn]]
++[[RecordSource]]
++[[Refresh]]
++[[RowSource]]
++!!!Example
++<<tiddler "Requery example">>
++
++
++
Reload the content of a combo box after a database change
++//{{{
++Dim ofForm As Object, ocCombo As Object
++	Set ofForm = Forms("myForm")
++	Set ocCombo = ofForm.Controls("myComboBox")
++	ocCombo.Requery
++//}}}
++
++
++
The //Required// property specifies whether a control must contain a value when the record is edited.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |~CheckBox<br />[[ComboBox]]<br />~CurrencyField<br />~DateField<br />~FormattedField<br />~ImageControl<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />[[RadioButton]]<br />~TextField<br />~TimeField | All except<br />--~CheckBox-- | None |A control on an open form or a [[GridControl]] |
++!!!Syntax
++//control//{{{.Required}}}
++//control//{{{.Required}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The //Required// property is not applicable to //controls// located in a [[Dialog]].
++!!!Error messages
++|Property 'Required' not applicable in this context |
++|Value '...' is invalid for property 'Required' |
++!!!Example
++<<tiddler "Required example">>
++
++
++
Force value in field to avoid error on Null value when saving record (e.g. in When Loading form event)
++{{{
++Dim ocControl As Object
++	Set ocControl = Controls("myForm", "myFormattedField")
++	ocControl.Required = True
++}}}
++
++
++
Resetting a built-in ||command bar|CommandBar]] restores the actions originally intended for the command bar and resets each of the command bar control's properties back to their original state.
++!!!Applies to ...
++| !Object | !Description |
++|[[CommandBar]] |The representation of a tool-, menu- or statusbar. |
++!!!Syntax
++//commandbar//{{{.Reset()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++!!!Error Messages
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++!!!Example
++<<tiddler "CommandBar example">>
++
++
++
You can use the //~RowSource// property (along with the [[RowSourceType]] property) to tell ~OpenOffice/~LibreOffice Base how to provide data to a list box or to a combo box.
++!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] |A combo- or listbox on an open form, a dialog or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.RowSource}}}
++//control//{{{.RowSource}}} = //value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++*The //value// argument must contain, depending on the value of the [[RowSourceType]] property, either
++| !~RowSourceType |!Argument of ~RowSource |
++|com.sun.star.form.~ListSourceType.TABLE |the exact name of a table |
++|com.sun.star.form.~ListSourceType.QUERY |the exact name of a query |
++|com.sun.star.form.~ListSourceType.SQL |a correct SQL SELECT statement |
++|com.sun.star.form.~ListSourceType.SQLPASSTHROUGH |~|
++|com.sun.star.form.~ListSourceType.TABLEFIELDS |a list of values separated by a semicolon (";") bundled in one single string |
++|com.sun.star.form.~ListSourceType.VALUELIST |~|
++*When the //~RowSource// property is changed the content of the combo- or listbox is refreshed.
++!!!Error messages
++|Property '~RowSource' not applicable in this context |
++|Value '...' is invalid for property '~RowSource' |
++!!!See also
++[[ItemData]]
++[[ListCount]]
++[[ListIndex]]
++[[MultiSelect]]
++[[Requery]]
++[[RowSourceType]]
++[[Selected]]
++!!!Example
++<<tiddler "RowSource example">>
++
++
++
Modify the content of a combo and a listbox 
++Select first item in the combobox
++Select all tems in the listbox
++//{{{
++Dim ocCombo As Object, ocList As Object
++
++	Set ocCombo = getObject("Forms!myForm!myComboBox")
++	ocCombo.RowSourceType = com.sun.star.form.ListSourceType.SQL
++	ocCombo.RowSource = "SELECT [SHORTNAME] FROM COMPANIES WHERE [SHORTNAME]<>'' ORDER BY [SHORTNAME]"
++	ocCombo.ListIndex = 0
++	
++	Set ocList = getObject("Forms!myForm!myListBox")
++	ocList.RowSourceType = com.sun.star.form.ListSourceType.VALUELIST
++	ocList.RowSource = "First;Second;Third"
++	ocList.Selected = Array(True, True, True)
++//}}}
++
++
++
You can use the //~RowSourceType// property (along with the [[RowSource]] property) to tell ~OpenOffice/~LibreOffice Base how to provide data to a list box or to a combo box.
++!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | [[ComboBox]]<br />[[ListBox]] | [[ComboBox]]<br />[[ListBox]] |A combo- or listbox on an open form or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.RowSourceType}}}
++//control//{{{.RowSourceType}}} = //value//
++!!!Returned values / Arguments
++{{{Integer}}}
++!!!Remarks
++*The //value// argument must contain, depending on the value of the [[RowSource]] property, one of next symbolic values:
++|com.sun.star.form.~ListSourceType.VALUELIST |
++|com.sun.star.form.~ListSourceType.TABLE |
++|com.sun.star.form.~ListSourceType.QUERY |
++|com.sun.star.form.~ListSourceType.SQL |
++|com.sun.star.form.~ListSourceType.SQLPASSTHROUGH |
++|com.sun.star.form.~ListSourceType.TABLEFIELDS |
++See the [[OpenOffice documentation|http://api.openoffice.org/docs/common/ref/com/sun/star/form/component/DatabaseListBox.html#ListSourceType]] for more details.
++*A //~ComboBox// control does not support the value {{{com.sun.star.form.ListSourceType.VALUELIST}}} for the //~RowSourceType// property.
++*When the //~RowSourceType// property is changed the content of the combo- or listbox is ''NOT'' refreshed.
++*The //~RowSourceType// property is not applicable to //list-// or //comboboxes// located in a [[Dialog]].
++!!!Error messages
++|Property '~RowSourceType' not applicable in this context |
++|Value '...' is invalid for property '~RowSourceType' |
++!!!See also
++[[ItemData]]
++[[ListCount]]
++[[ListIndex]]
++[[MultiSelect]]
++[[Requery]]
++[[RowSource]]
++[[Selected]]
++!!!Example
++<<tiddler "RowSource example">>
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~RunApp// action runs an external application given by its command line. The command line may be an executable file or a user file associated via its suffix with an executable application.<br />Use caution when running executable files or code in macros or applications. Executable files or code can be used to carry out actions that might compromise the security of your computer and data.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{Call [DoCmd.]RunApp(}}}//{{{CommandLine}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description | !Returned value |
++|{{{CommandLine}}} | No | String |The command line used to start the application<br />(including the path and any other necessary parameters, such as switches that run the application in a particular mode). | No return. {{{RunApp}}} is a Sub. |
++!!!Remarks
++*The application selected with this action loads and runs in the foreground. The macro containing this action continues to run after starting the application.
++*The {{{CommandLine}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++*Note that Basic provides an equivalent standard function {{{Shell}}}. It provides even more options. //~RunApp// is proposed here to improve compatibility with Visual Basic.
++!!!Error messages
++None
++!!!See also
++[[OutputTo]]
++!!!Example
++<<tiddler "RunApp example">>	
++
++
++
To open a PDF file
++//{{{
++	RunApp("C:\Users\MyName\Documents\Doc\Basic\OOBasic FormsAndDialogs.pdf")	'	Valid only in Windows
++//}}}
++
++
++
The absence of Macro Recorder in ~LibO/AOO Base and the lack of documentation makes the use of the numerous commands available in the software very difficult. The current help page tries to compensate partially this handicap.
++
++The //~RunCommand// action executes the command given as argument.
++Combined with the [[SelectObject]] action it enhances significantly the automation capabilities of applications using the //~Access2Base// API.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]RunCommand(}}}//{{{Command}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description | !Returned Value |
++| Command | No | String<br />Integer, Long |If numeric the Command is selected by using the VBA denomination. If the Type is a String, the ~LibO/AOO command-name is expected | Always returns True |
++!!!Commands List
++| !~LibO/AOO Command | !VBA Equivalent | !Context(s) |!Short description |
++|"About" |acCmdAboutMicrosoftAccess  | Any |About ~OpenOffice.org/~LibreOffice |
++|~|acCmdAboutOpenOffice | Any |About ~OpenOffice.org/~LibreOffice |
++|~|acCmdAboutLibreOffice | Any |About ~OpenOffice.org/~LibreOffice |
++|"~ActiveHelp" || Any |Extended Tips |
++|"~AddDirect" || Any |New |
++|"~AddField" || acForm (Design mode) |Add Field |
++|"~AutoControlFocus" || acForm (Design mode) |Automatic Control Focus |
++|"~AutoFilter" || acTable |~AutoFilter |
++|"~AutoPilotAddressDataSource" || Any |~AutoPilot: Address Data Source |
++|"~BasicBreak" || Any |Interrupt Macro |
++|"~BasicIDEAppear" |acCmdVisualBasicEditor  | Any |Edit Macros |
++|"~BasicStop" || acBasicIDE |Stop Macro |
++|"~BringToFront" |acCmdBringToFront  | Any |Bring to Front |
++|"~CheckBox" || acForm (Design mode) |Check Box |
++|"~ChooseMacro" || acBasicIDE |Select Macro |
++|"~CloseDoc" |acCmdClose  | Any |Close |
++|"~CloseWin" || Any |Close Window |
++|"~ConfigureDialog" |acCmdToolbarsCustomize  | Any |Customize |
++|"~ControlProperties" || Controls |Control |
++|"~ConvertToButton" |acCmdChangeToCommandButton  | Controls |Replace with Button |
++|"~ConvertToCheckBox" |acCmdChangeToCheckBox  | Controls |Replace with Check Box |
++|"~ConvertToCombo" |acCmdChangeToComboBox  | Controls |Replace with Combo Box |
++|"~ConvertToCurrency" || Controls |Replace with Currency Field |
++|"~ConvertToDate" || Controls |Replace with Date Field |
++|"~ConvertToEdit" |acCmdChangeToTextBox  | Controls |Replace with Text Box |
++|"~ConvertToFileControl" || Controls |Replace with File Selection |
++|"~ConvertToFixed" |acCmdChangeToLabel  | Controls |Replace with Label Field |
++|"~ConvertToFormatted" || Controls |Replace with Formatted Field |
++|"~ConvertToGroup" || Controls |Replace with Group Box |
++|"~ConvertToImageBtn" || Controls |Replace with Image Button |
++|"~ConvertToImageControl" |acCmdChangeToImage  | Controls |Replace with Image Control |
++|"~ConvertToList" |acCmdChangeToListBox  | Controls |Replace with List Box |
++|"~ConvertToNavigationBar" || Controls |Replace with Navigation Bar |
++|"~ConvertToNumeric" || Controls |Replace with Numerical Field |
++|"~ConvertToPattern" || Controls |Replace with Pattern Field |
++|"~ConvertToRadio" |acCmdChangeToOptionButton  | Controls |Replace with Radio Button |
++|"~ConvertToScrollBar" || Controls |Replace with Scrollbar |
++|"~ConvertToSpinButton" || Controls |Replace with Spin Button |
++|"~ConvertToTime" || Controls |Replace with Time Field |
++|"Copy" |acCmdCopy  | Any |Copy |
++|"~CurrencyField" || acForm (Design mode) |Currency Field |
++|"Cut" |acCmdCut  | Any |Cut |
++|"~DateField" || acForm (Design mode) |Date Field |
++|"~DBAddRelation" |acCmdCreateRelationship  | acDiagram |New Relation ... |
++|"~DBConvertToView" || acDatabaseWindow (Queries) |Create as View |
++|"~DBDelete" |acCmdDelete  | acDatabaseWindow |Delete |
++|"~DBDirectSQL" || acDatabaseWindow |SQL ... |
++|"~DBDSAdvancedSettings" || acDatabaseWindow |Advanced Settings ... |
++|"~DBDSConnectionType" || acDatabaseWindow |Connection Type ... |
++|"~DBDSProperties" |acCmdDatabaseProperties  | acDatabaseWindow |Properties ... |
++|"~DBEdit" || acDatabaseWindow |Edit ... |
++|"~DBEditSqlView" |acCmdSQLView  | acDatabaseWindow (Queries) |Edit in SQL View ... |
++|"~DBFormDelete" |acCmdRemove  | acDatabaseWindow (Forms) |Delete |
++|"~DBFormEdit" |acCmdDesignView  | acDatabaseWindow (Forms) |Edit ... |
++|"~DBFormOpen" |acCmdFormView  | acDatabaseWindow (Forms) |Open Database Object ... |
++|"~DBFormRename" || acDatabaseWindow (Forms) |Rename ... |
++|"~DBNewForm" |acCmdNewObjectForm  | acDatabaseWindow (Forms) |Form ... |
++|"~DBNewFormAutoPilot" || acDatabaseWindow (Forms) |Form Wizard ... |
++|"~DBNewQuery" || acDatabaseWindow (Queries) |Query (Design View) ... |
++|"~DBNewQueryAutoPilot" || acDatabaseWindow (Queries) |Query Wizard ... |
++|"~DBNewQuerySql" || acDatabaseWindow (Queries) |Query (SQL View) ... |
++|"~DBNewReport" || acDatabaseWindow (Reports) |Report ... |
++|"~DBNewReportAutoPilot" || acDatabaseWindow (Reports) |Report Wizard ... |
++|"~DBNewTable" |acCmdNewObjectTable  | acDatabaseWindow (Tables) |Table Design ... |
++|"~DBNewTableAutoPilot" || acDatabaseWindow (Tables) |Table Wizard ... |
++|"~DBNewView" |acCmdNewObjectView  | acDatabaseWindow (Tables) |View Design ... |
++|"~DBNewViewSQL" || acDatabaseWindow (Tables) |View (Simple) ... |
++|"~DBOpen" |acCmdOpenDatabase  | acDatabaseWindow |Open Database Object ... |
++|"~DBQueryDelete" |acCmdRemove  | acDatabaseWindow (Queries) |Delete |
++|"~DBQueryEdit" |acCmdDesignView  | acDatabaseWindow (Queries) |Edit ... |
++|"~DBQueryOpen" |acCmdNewObjectQuery  | acDatabaseWindow (Queries) |Open Database Object ... |
++|"~DBQueryRename" || acDatabaseWindow (Queries) |Rename ... |
++|"~DBRefreshTables" || acDatabaseWindow |Refresh Tables |
++|"~DBRelationDesign" |acCmdShowAllRelationships  | acDatabaseWindow |Relationships ... |
++|"~DBRename" || acDatabaseWindow |Rename ... |
++|"~DBReportDelete" |acCmdRemove  | acDatabaseWindow (Reports) |Delete |
++|"~DBReportEdit" |acCmdDesignView  | acDatabaseWindow (Reports) |Edit ... |
++|"~DBReportOpen" |acCmdNewObjectReport  | acDatabaseWindow (Reports) |Open Database Object ... |
++|"~DBReportRename" || acDatabaseWindow (Reports) |Rename ... |
++|"~DBSelectAll" |acCmdSelectAll  | acDatabaseWindow |Select All |
++|"~DBShowDocInfoPreview" || acDatabaseWindow |Document Information |
++|"~DBShowDocPreview" || acDatabaseWindow |Document |
++|"~DBTableDelete" |acCmdRemoveTable  | acDatabaseWindow (Tables) |Delete |
++|"~DBTableEdit" |acCmdDesignView  | acDatabaseWindow (Tables) |Edit ... |
++|"~DBTableFilter" || acDatabaseWindow (Tables) |Table Filter ... |
++|"~DBTableOpen" |acCmdOpenTable  | acDatabaseWindow (Tables) |Open Database Object ... |
++|"~DBTableRename" |acCmdRename  | acDatabaseWindow (Tables) |Rename ... |
++|"~DBUserAdmin" || acDatabaseWindow |User Administration ... |
++|"~DBViewForms" || acDatabaseWindow |Forms |
++|"~DBViewQueries" || acDatabaseWindow |Queries |
++|"~DBViewReports" || acDatabaseWindow |Reports |
++|"~DBViewTables" || acDatabaseWindow |Tables |
++|"Delete" |acCmdDelete  | Any |Delete Contents |
++|"~DeleteRecord" |acCmdDeleteRecord  | acForm |Delete Record |
++|"~DesignerDialog" || acForm (Design mode) |Styles and Formatting |
++|"Edit" || acForm (Design mode) |Text Box |
++|"~FirstRecord" || acForm |First Record |
++|"~FontDialog" || acForm (Design mode) |Character |
++|"~FontHeight" || acForm (Design mode) |Font Size |
++|"~FormattedField" || acForm (Design mode) |Formatted Field |
++|"~FormFilter" || acForm |~Form-Based Filters |
++|"~FormFiltered" |acCmdApplyFilterSort  | acForm |Apply Filter |
++|"~FormFilterExecute" || acForm |Apply ~Form-Based Filter |
++|"~FormFilterExit" || acForm |Close |
++|"~FormFilterNavigator" || acForm |Filter Navigation |
++|"~FormProperties" || acForm (Design mode) |Form |
++|"~FullScreen" || acForm |Full Screen |
++|"Gallery" || acForm |Gallery |
++|"Grid" || acForm (Design mode) |Table Control |
++|"~GridUse" |acCmdSnapToGrid  | acForm (Design mode) |Snap to Grid |
++|"~GridVisible" |acCmdViewGrid  | acForm (Design mode) |Display Grid |
++|"~GroupBox" || acForm (Design mode) |Group Box |
++|"~HelpIndex" || Any |~OpenOffice.org Help |
++|"~HelpSupport" || Any |Support |
++|"~HyperlinkDialog" |acCmdInsertHyperlink  | acForm (Design mode) |Hyperlink |
++|"Imagebutton" || acForm (Design mode) |Image Button |
++|"~ImageControl" || acForm (Design mode) |Image Control |
++|"Label" || acForm (Design mode) |Label Field |
++|"~LastRecord" |acCmdMaximumRecords  | acForm |Last Record |
++|"~ListBox" || acForm (Design mode) |List Box |
++|"~MacroDialog" || Any |~OpenOffice.org Basic |
++|"~MacroOrganizer" || Any |~OpenOffice.org Basic Macro Organizer |
++|"~MoreControls" || acForm (Design mode) |More Controls |
++|"~NavigationBar" || acForm (Design mode) |Navigation Bar |
++|"Navigator" |acCmdObjectBrowser  | acForm (Design mode) |Navigator |
++|"~NewDoc" || Any |New Document From Template |
++|"~NewRecord" || acForm |New Record |
++|"~NextRecord" || acForm |Next Record |
++|"~NumericField" || acForm (Design mode) |Numerical Field |
++|"Open" || Any |Open |
++|"~OptionsTreeDialog" || Any |Options |
++|"Organizer" || Any |Organize |
++|"~ParagraphDialog" || acForm (Design mode) |Paragraph |
++|"Paste" |acCmdPaste  | Any |Paste |
++|"~PasteSpecial" |acCmdPasteSpecial  | acForm (Design mode) |Paste Special ... |
++|"~PatternField" || acForm (Design mode) |Pattern Field |
++|"~PrevRecord" || acForm |Previous Record |
++|"Print" |acCmdPrint  | acForm, acReport (normal and design modes) |Print |
++|"~PrintDefault" || acForm, acReport (normal and design modes) |Print File Directly |
++|"~PrinterSetup" || acForm, acReport (normal and design modes) |Printer Settings |
++|"~PrintPreview" |acCmdPrintPreview  | acForm, acReport (normal and design modes) |Page Preview |
++|"Pushbutton" || acForm (Design mode) |Push Button |
++|"Quit" || acDatabaseWindow |Exit |
++|"~RadioButton" || acForm (Design mode) |Option Button |
++|"~RecSave" |acCmdSaveRecord  | acForm |Save Record |
++|"~RecSearch" |acCmdFind  | acForm |Find Record |
++|"~RecUndo" |acCmdUndo  | acForm |Undo: Data entry |
++|"Refresh" |acCmdRefresh  | acForm, acTable, acQuery |Refresh |
++|"Reload" || Any |Reload |
++|"~RemoveFilterSort" |acCmdRemoveFilterSort  | acForm |Remove Filter/Sort |
++|"~RunMacro" |acCmdRunMacro  | Any |Run Macro |
++|"Save" |acCmdSave  | Any |Save |
++|"~SaveAll" || Any |Save All |
++|"~SaveAs" |acCmdSaveAs  | Any |Save As |
++|"~SaveBasicAs" || acBasicIDE |Save BASIC |
++|"~ScriptOrganizer" || Any |Organize Macros |
++|"~ScrollBar" || acForm (Design mode) |Scrollbar |
++|"~SearchDialog" |acCmdFind  | acForm |Find & Replace |
++|"~SelectAll" |acCmdSelectAll  | Any |Select All |
++|~|acCmdSelectAllRecords  | Any |Select All |
++|"~SendToBack" |acCmdSendToBack  | Any |Send to Back |
++|"~ShowFmExplorer" || acForm (Design mode) |Form Navigator |
++|"Sidebar" || acForm |Toggle sidebar |
++|"~SortDown" |acCmdSortDescending  | acForm, acTable, acQuery |Sort Descending |
++|"Sortup" |acCmdSortAscending  | acForm, acTable, acQuery |Sort Ascending |
++|"~SpinButton" || acForm (Design mode) |Spin Button |
++|"~StatusBarVisible" || Any |Status Bar |
++|"~SwitchControlDesignMode" || acForm (Design mode) |Design Mode On/Off |
++|"~TabDialog" |acCmdTabOrder  | acForm (Design mode) |Activation Order |
++|"~UseWizards" || acForm (Design mode) |Wizards On/Off |
++|"~VersionDialog" || acForm (Design mode) |Versions |
++|"~ViewDataSourceBrowser" || acForm |Data Sources |
++|"~ViewFormAsGrid" |acCmdDatasheetView  | acForm |Data source as Table |
++|"Zoom" |acCmdZoomSelection  |  |Zoom |
++The (VBA) symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acDiagram = 8
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++
++Const acBasicIDE = 101
++Const acDatabaseWindow = 102
++//}}}
++and, or ...
++//{{{
++Const acCmdAboutMicrosoftAccess = 35
++Const acCmdAboutOpenOffice = 35
++Const acCmdAboutLibreOffice = 35
++Const acCmdVisualBasicEditor = 525
++Const acCmdBringToFront = 52
++Const acCmdClose = 58
++Const acCmdToolbarsCustomize = 165
++Const acCmdChangeToCommandButton = 501
++Const acCmdChangeToCheckBox = 231
++Const acCmdChangeToComboBox = 230
++Const acCmdChangeToTextBox = 227
++Const acCmdChangeToLabel = 228
++Const acCmdChangeToImage = 234
++Const acCmdChangeToListBox = 229
++Const acCmdChangeToOptionButton = 233
++Const acCmdCopy = 190
++Const acCmdCut = 189
++Const acCmdCreateRelationship = 150
++Const acCmdDelete = 337
++Const acCmdDatabaseProperties = 256
++Const acCmdSQLView = 184
++Const acCmdRemove = 366
++Const acCmdDesignView = 183
++Const acCmdFormView = 281
++Const acCmdNewObjectForm = 136
++Const acCmdNewObjectTable = 134
++Const acCmdNewObjectView = 350
++Const acCmdOpenDatabase = 25
++Const acCmdRemove = 366
++Const acCmdDesignView = 183
++Const acCmdNewObjectQuery = 135
++Const acCmdShowAllRelationships = 149
++Const acCmdRemove = 366
++Const acCmdDesignView = 183
++Const acCmdNewObjectReport = 137
++Const acCmdSelectAll = 333
++Const acCmdRemoveTable = 84
++Const acCmdDesignView = 183
++Const acCmdOpenTable = 221
++Const acCmdRename = 143
++Const acCmdDelete = 337
++Const acCmdDeleteRecord = 223
++Const acCmdApplyFilterSort = 93
++Const acCmdSnapToGrid = 62
++Const acCmdViewGrid = 63
++Const acCmdInsertHyperlink = 259
++Const acCmdMaximumRecords = 508
++Const acCmdObjectBrowser = 200
++Const acCmdPaste = 191
++Const acCmdPasteSpecial = 64
++Const acCmdPrint = 340
++Const acCmdPrintPreview = 54
++Const acCmdSaveRecord = 97
++Const acCmdFind = 30
++Const acCmdUndo = 292
++Const acCmdRefresh = 18
++Const acCmdRemoveFilterSort = 144
++Const acCmdRunMacro = 31
++Const acCmdSave = 20
++Const acCmdSaveAs = 21
++Const acCmdFind = 30
++Const acCmdSelectAll = 333
++Const acCmdSelectAllRecords = 109
++Const acCmdSendToBack = 53
++Const acCmdSortDescending = 164
++Const acCmdSortAscending = 163
++Const acCmdTabOrder = 41
++Const acCmdDatasheetView = 282
++Const acCmdZoomSelection = 371
++//}}}
++!!!Remarks
++*//~RunCommand// always returns {{{True}}}. If the argument does not exist, or if the request is not appropriate to the context, the request is ignored.
++*The Command argument, when of type {{{String}}}, is not case-sensitive.
++*Above list of commands is not exhaustive. Other commands could succeed as well. However if the command to execute is not in the above list the argument MUST correspond exactly (... be properly cased as should ...) with the argument expected by a {{{executeDispatch()}}} UNO statement.
++*If the given Command argument is of type {{{String}}} and starts with "{{{.uno:}}}", the command is executed literally without any other parsing.
++*The ~LibO/AOO command and its VBA equivalent are //presumed// to be similar or equivalent. The ~RunCommand action always executes a ~LibO/AOO command. There is no emulation of the VBA command.
++*The //Context// column indicates one or more contexts in which the command has been tested and executed successfully. This is not a guarantee that it will succeed in the given context nor that other contexts could not also provide the same functionality. When the context is __//Any//__ this only means that the command is likely to succeed in any context.
++*The //~RunCommand// action is very often preceded by a [[SelectObject]] action to activate the correct context.
++*Most commands open a dialog box. Today the ~LibO/AOO documentation does not contain any indication about arguments that could bypass the dialog. The only ways to discover them are either to scan the software sources (what I did not do !) or to record the macro. But //~LibO/AOO Base// has no //Macro Recorder// (although Forms have ...!?) implemented.
++!!!Error messages
++|Arguments are missing or are not initialized |
++!!!See also
++[[SelectObject]]
++!!!Examples
++<<tiddler "RunCommand example">>
++
++
++
Open a form, and display it with its data source grid ...
++//{{{
++	OpenForm("myForm")
++	RunCommand(acCmdDatasheetView)		'	or RunCommand("ViewFormAsGrid")
++//}}}
++Next Sub linked to the "When loading" event ALWAYS opens a form with its datagrid ...
++//{{{
++Sub DisplayGrid(oEvent As Object)
++	RunCommand(acCmdDatasheetView)
++End Sub
++//}}}
++To open a form in design mode with automatic display of Form properties ...
++//{{{
++	OpenForm("myForm", acDesign)
++	RunCommand("FormProperties")
++//}}}
++To enter an SQL statement at any time, execute next code ...
++//{{{
++	SelectObject(acDatabaseWindow)
++	RunCommand("DBDirectSQL")
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~RunSQL// action executes the SQL statement given as argument. The statement must execute an action. Typical statements are: INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX.
++<<tiddler "ApplyDoCmd">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object returned by the [[CurrentDb]] or [[OpenDatabase]] methods. |
++!!!Syntax
++{{{[DoCmd.]RunSQL(}}}//{{{SQL, option}}}//{{{)}}}
++//{{{database}}}//{{{.RunSQL(}}}//{{{SQL, option}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description |
++|database || Object |A database object opened with the //~OpenDatabase// method. |
++|SQL | No | String |Specifies the statement to execute |
++|option | Yes | Integer<br />Long |If the argument is present its only allowed value = //dbSQLPassThrough//.<br />Forces escape substitution before sending the SQL statement to the database. |~|
++The action returns False if the execution of the SQL statement failed.
++!!!Remarks
++*Statements
++//{{{
++DoCmd.RunSQL( ... )
++//}}}
++and
++//{{{
++Application.CurrentDb().RunSQL( ... )
++//}}}
++are equivalent.
++*RDBMS system commands can also be executed with {{{RunSQL}}}. E.g. next command, which is valid for an HSQLDB database, will close the database connection and compact the data contained in the database. See the respective RDBMS manuals for more details.
++//{{{
++SHUTDOWN COMPACT
++//}}}
++*To test the SQL string: copy and paste it to or from the text box displayed when activating the {{{Tools}}} + {{{SQL ...}}} menu item.
++*The field or table names of the SQL argument may be surrounded by square brackets [], especially when they contain special characters like spaces. The brackets will be replaced by the appropriate quoting chaaracter(s), e.g. the double-quote for the HSQLDB database management system.
++*The supplied SQL string must obviously be syntactically correct. Pay particularly attention to single and double quotes. See the "[[How to include values in SQL statements|UseVariablesInSQL]]" topic in this matter.
++*To include the constant in your own code, copy and paste next line:
++//{{{
++Const dbSQLPassThrough = 64
++//}}}
++!!!Error messages
++|Arguments are missing or are not initialized |
++|SQL Error, SQL statement = '...' |
++!!!See also
++[[CurrentDb]]
++[[OpenDatabase]]
++!!!Example
++<<tiddler "Runsql example">>
++
++
++
Before the execution of the //~OpenConnection// verb, of if its execution failed, or after a //~CloseConnection// verb execution, next methods are nevertheless available:
++| !Method | !Description |
++|[[DebugPrint]] |All error handling routines. |
++|[[TraceConsole]] |~|
++|[[TraceError]] |~|
++|[[TraceLevel]] |~|
++|[[TraceLog]] |~|
++|[[TempVars]] |The collection of [[TempVar]] objects to share and pass values among documents. |
++|[[AllDialogs]] |Access to the collection of dialogs, the [[Dialog]] objects and their [[Controls|Control]]. |
++|[[AllModules]] |Access to the collection of Basic modules and the [[Module]] objects. |
++|[[CurrentDb]] |Returns {{{Nothing}}} if no database connection available. |
++|[[CurrentUser]] |Context information. |
++|[[ProductCode]] |~|
++|[[Version]] |(When applied to Application).|
++|[[OpenDatabase]] |Access to external database. |
++|[[CommandBars]] |Manage menu-, status- and toolbars. |
++|[[SysCmd]] |Status bar, progress meter handling. |
++|[[GetHiddenAttribute]] |Window handling when no forms, queries, tables, reports implied. |
++|[[Maximize]] |~|
++|[[Minimize]] |~|
++|[[MoveSize]] |~|
++|[[SelectObject]] |~|
++|[[SetHiddenAttribute]] |~|
++|[[RunApp]] |External commands calls. |
++|[[RunCommand]] |~|
++
++
++
++
Create a new database table
++//{{{
++	If DoCmd.RunSQL( _
++		"CREATE TABLE customer (" _
++			& "First_Name char(50)" _
++			& ", Last_Name char(50)" _
++			& ", Address char(50)" _
++			& ", City char(50)" _
++			& ", Country char(25)" _
++			& ", Birth_Date date" _
++			& ")") Then MsgBox "Customer table has been created !"
++//}}}
++
++
++
You can use the //SQL// property to specify the statement contained in a [[QueryDef]] object.
++!!!Applies to ...
++| !Object |!Description |
++|[[QueryDef]] |The representation of a database query |
++!!!Syntax
++//querydef//{{{.SQL}}}
++//querydef//{{{.SQL = }}}//value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++*The SQL statement may be either a SELECT query, or an action query (data update, data manipulation, ...).
++*The SQL statement may be set programmatically. The SQL string MUST then contain a SELECT statement.
++*When the query is updated the change is immediate in the database document file (with ".odb" suffix) without having to save the query. However the change will be made persistent only if the user confirms the update by saving the database document itself. Alternatively the programmer could provide the Save command, e.g. with a statement like {{{RunCommand("Save")}}}
++*In the SQL statement table- and fieldnames may be surrounded with square brackets [] to improve readability. They will be substituted with the appropriate surrounding character.
++!!!Error messages
++|Property '...' not applicable in this context |
++|Value '...' is invalid for property 'SQL' |
++!!!See also
++[[Type]]
++!!!Example
++<<tiddler "SQL example">>
++
++
++
Modify the SQL statement of a stored query
++//{{{
++Dim oQuery As Object
++	Set oQuery = Application.CurrentDb().QueryDefs("myQuery")
++	oQuery.SQL = "SELECT * FROM [PRODUCTS]"
++//}}}
++
++
++
(Q) Can I have a search box and trigger the search thru all the records related to a form ?
++
++(R) Use the [[FindRecord]] and [[FindNext]] actions.
++
++The feature is illustrated thru the use of a [[standalone form|Standalone Forms]].
++
++!!!Solution
++Design the //standalone// form taking into account:
++*The //~FindRecord// action works only on data displayed in a tabular form, i.e. through the use of a [[grid control|GridControl]].
++*You will observe that the execution is slow: indeed //~FindRecord// will literally scroll thru the data and refresh the display accordingly. The solution is not adapted for very large tables of data.
++
++Design next 4 fields and buttons:
++#The search box: a simple //text box//, name = //~SearchText//. In the //Properties// window set its //Default text// property to "(search)". Link its //When receiving focus// event to the //~CleanSearch// procedure.
++#A //checkbox// called //~MatchCase// indicating if the search must or not respect upper and lower cases.
++#A search start button : link the //execute action// event with the //~ButtonStart// procedure.
++#A //next// button : link the //execute action// event with the //~ButtonNext// procedure.
++
++Now the code:
++The //~CleanSearch// procedure empties the search box when its content is the default value:
++//{{{
++Const cstDefault = "(search)"
++
++Sub CleanSearch(poEvent As Object)
++Dim oEvent As Object, oField As Object
++	Set oEvent = Application.Events(poEvent)
++	Set oField  = oEvent.Source
++	If oField.Value = cstDefault Then oField.Value = ""
++End Sub
++//}}}
++The //cstDefault// constant is set outside the //Sub...End Sub// to be available also in next procedures:
++//{{{
++Sub ButtonStart(poEvent As Object)
++Dim ofForm As Object, sSearch As String, bMatch As Boolean
++	Set ofForm = Application.Forms(0)		'	standalone form itself
++	sSearch = ofForm.Controls("SearchText").Value
++	If sSearch = "" Or sSearch = cstDefault Then
++		MsgBox "The search box is not initialized. Please do and retry.", 16, "Search"
++		ofForm.Controls("SearchText").SetFocus()
++	Else
++		bMatch = ofForm.Controls("MatchCase").Value
++		DoCmd.Findrecord sSearch, acAnyWhere, bmatch, acDown, , acAll, True
++	End If
++End Sub
++
++Sub ButtonNext(poEvent As Object)
++	DoCmd.FindNext
++End Sub
++//}}}
++!!!See also
++[[FindRecord]]
++[[FindNext]]
++[[GridControl]]
++[[SetFocus]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Code |//TT Northwind Standalone.odt// ||~SearchText |When receiving focus |Enter a search text and press //Start//. |
++|~|~|~|btnStart<br />btnNext |Execute action |~|
++
++
++
The //~SelLength// property specifies or determines the number of characters selected in a text box.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |>|>| ~PatternField<br />~TextField  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.SelLength}}}
++//control//{{{.SelLength = }}}//value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++*The //~SelLength// property uses an integer value in the range 0 to the total number of characters in a text box.
++*To set or return this property for a control, the control must have the focus. To move the focus to a control, use the [[SetFocus]] method.
++!!!Error messages
++|Property '~SelLength' not applicable in this context |
++|Value '...' is invalid for property '~SelLength' |
++!!!See also
++[[SelStart]]
++[[SelText]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Selection example">>
++
++
++
The //~SelStart// property specifies or determines the starting point of the selected text in a control or the position of the insertion point if no text is selected.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |>|>| ~PatternField<br />~TextField  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.SelStart}}}
++//control//{{{.SelStart = }}}//value//
++!!!Returned values / Arguments
++{{{Long}}}
++!!!Remarks
++*The //~SelStart// property uses an integer value in the range 1 to the total number of characters in a text box + 1.
++*To set or return this property for a control, the control must have the focus. To move the focus to a control, use the [[SetFocus]] method.
++*Changing the SelStart property cancels the selection, places the insertion point in the text at the left of the ~SelStart-th character, and sets the [[SelLength]] property to 0.
++!!!Error messages
++|Property '~SelStart' not applicable in this context |
++|Value '...' is invalid for property '~SelStart' |
++!!!See also
++[[SelLength]]
++[[SelText]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Selection example">>
++
++
++
The //~SelText// property returns a string containing the selected text. If no text is selected, the //~SelText// property contains an empty string ("").
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |>|>| ~PatternField<br />~TextField  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.SelText}}}
++//control//{{{.SelText = }}}//value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++*If the control contains the selected text when this property is set, the selected text is replaced by the new //~SelText// setting. Otherwise selection is not cahnged.
++*To set or return this property for a control, the control must have the focus. To move the focus to a control, use the [[SetFocus]] method.
++!!!Error messages
++|Property '~SelStart' not applicable in this context |
++|Value '...' is invalid for property '~SelStart' |
++!!!See also
++[[SelLength]]
++[[SelStart]]
++[[SetFocus]]
++!!!Example
++<<tiddler "Selection example">>
++
++
++
(Q) Can I make a search box where the proposed choices are dynamically limited to those starting with the letters typed by the user ?
++
++(R) There are several solutions. One of them is presented below.
++
++The implemented module is triggered each time a character is entered.
++Accepted characters are :
++*Letters, either lower or upper cased, and the space character
++*The BACKSPACE which cancels the last entered letter
++*The ESCAPE key which cancels the complete string of characters.
++Other keys are ignored.
++
++The goal is to minimize the reload of the data from the database, as it is an operation that could take a long time while the user is keying letters in ...
++
++!!!Solution
++It consists in:
++*A [[listbox|ListBox]]. It is reinitialized with database data at each //form loading//, and, while the focus is on the box, at each BACKSPACE key and at each ESCAPE key pressing.
++*After each letter pressed by the user the box keeps only the subset of the initial data that corresponds with the entered characters, without database access. The control is temporarily converted from an SQL [[RowSourceType]] to a VALUELIST one.
++*The succession of letters is kept into the [[Tag]] property of the //listbox//.
++Let's assume next table:
++<<tiddler "ProductsTable">>
++The //listbox// will help to converge as quickly as possible to the searched product name.
++
++1. Associate next code with the //When loading// form event:
++//{{{
++Sub InitList(Optional poEvent As Object)	'	Optional because also called from CaptureChar routine
++'Activated when form opened and when ESC key is pressed in listbox
++
++Const cstForm = "Products_FastSearch"
++Const cstList = "FastList"
++Dim ocList As Object, sSource As String
++
++	Set ocList = Forms(cstForm).Controls(cstList)
++	If Not IsMissing(poEvent) Then ocList.Tag = ""		'	Initialized only when form opened
++
++	ocList.RowSourceType = com.sun.star.form.ListSourceType.SQL
++	ocList.RowSource = "SELECT [ProductName] FROM [Products] ORDER BY [ProductName] ASC"	'Requery implicit
++
++	sSource = Join(ocList.ItemData, ";")
++	ocList.RowSourceType = com.sun.star.form.ListSourceType.VALUELIST	'	For performance
++	ocList.RowSource = sSource
++	
++End Sub
++//}}}
++2. Associate next routine with the //Key pressed// event of the concerned //listbox// control :
++//{{{
++Sub CaptureChar(poEvent As Object)
++
++Dim oEvent As Object, ocList As Object, sTag As String, i As Integer
++Dim vList() As Variant, vNewList() As Variant, iNew As Integer
++	Set oEvent = Events(poEvent)
++	If oEvent.EventType <> "KEYEVENT" Then Exit Sub
++
++'Accepted keys: A-Z, a-z, BACKSPACE, ESCAPE. All other keys ignored
++'Tag property of list box is used to keep sequence of entered characters
++	With oEvent
++		Set ocList = oEvent.Source
++		Select Case True
++			Case .KeyAlt, .KeyCtrl	:	Exit Sub
++			Case .KeyCode = com.sun.star.awt.Key.ESCAPE
++				ocList.Tag = ""
++				Call InitList()
++				Exit Sub
++			Case .KeyCode = com.sun.star.awt.Key.BACKSPACE
++				If Len(ocList.Tag) > 0 Then
++					sTag = ocList.Tag
++					ocList.Tag = Left(sTag, Len(sTag) - 1)	'	Reduce length of Tag
++					Call InitList()
++				End If
++			Case (UCase(.KeyChar) >= "A" And UCase(.KeyChar) <= "Z") Or (.KeyCode = com.sun.star.awt.Key.SPACE)
++				ocList.Tag = ocList.Tag & .KeyChar
++			Case Else		:	Exit Sub
++		End Select
++	End With
++
++	With ocList		'	Process Tag
++		sTag = .Tag
++		vList() = Split(.RowSource, ";")
++		.RowSource = ""
++		vNewList() = Array()	'	Otherwise Redim protests
++		If UBound(vList) >= 0 Then
++			ReDim vNewList(0 To UBound(vList))	'	Resized later
++			iNew = 0		'	Counts valid entries in vList
++			For i = 0 To UBound(vList)
++				If Len(vList(i)) >= Len(sTag) Then
++					If UCase(Left(vList(i), Len(sTag))) = UCase(sTag) Then	'	Case not sensitive
++						vNewList(iNew) = vList(i)
++						iNew = iNew + 1
++					End If
++				End If
++			Next i
++			If iNew > 0 Then
++				ReDim Preserve vNewList(0 To iNew - 1)
++				.RowSource = Join(vNewlist, ";")	'Apply new list after Tag selection
++				.ListIndex = 0				'Select first element
++			End If
++		End If
++	End With
++	
++End Sub
++//}}}
++!!!See also
++[[Event]]
++[[ItemData]]
++[[ListIndex]]
++[[RowSource]]
++[[RowSourceType]]
++[[Tag]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~FastSearch |~Products_FastSearch |When loading |~FastList |Key pressed |Select the listbox, enter characters => the listbox content changes. |
++
++
++
The //~SelectObject// action moves the focus to the specified window.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]SelectObject(}}}//{{{ObjectType, ObjectName, InDatabaseWindow}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description | !Returned Value |
++|{{{ObjectType}}} | No | acTable<br />acQuery<br />acForm<br />acReport<br />acDiagram (i.e. Relationships)<br />acDocument<br />acBasicIDE<br />acDatabaseWindow |The type of object to set the focus on. | True if sucess |
++|{{{ObjectName}}} | Yes | String |The name of the object to set the focus on. This argument is NOT case-sensitive.<br />The argument is mandatory when the //~ObjectType// argument is one of next values: //acTable//, //acQuery//, //acForm//, //acReport// or //acDocument//.<br />When the //~ObjectType// is equal to //acDocument//, the //~ObjectName// argument must contain the __filename__ of the window to be selected. |~|
++|{{{InDatabaseWindow}}} | Yes | Boolean |Specifies if the object has to be selected in the Database Window.<br />Must be FALSE. |~|
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acDiagram = 8
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++
++Const acBasicIDE = 101
++Const acDatabaseWindow = 102
++Const acDocument = 111
++//}}}
++!!!Remarks
++If the selected window is minimized or hidden, the //~SelectObject// action will reset the minimized or hidden status.
++!!!Error messages
++|Arguments are missing or are not initialized |
++|Argument nr. ... [Value = '...'] is invalid |
++|Object '...' not found |
++!!!See also
++[[GetHiddenAttribute]]
++[[Maximize]]
++[[Minimize]]
++[[MoveSize]]
++[[RunCommand]]
++[[SetFocus]]
++[[SetHiddenAttribute]]
++!!!Example
++<<tiddler "SelectObject example">>
++
++
++
Select the database window and minimize it, then set focus on an open form.
++//{{{
++Const acForm = 2
++Const acDatabaseWindow = 102
++	DoCmd.SelectObject(acDatabaseWindow)
++	DoCmd.Minimize()
++	DoCmd.SelectObject(acForm, "myForm")
++	DoCmd.Maximize()
++//}}}
++Put the focus on a Writer document
++//{{{
++Const acDocument = 111
++	DoCmd.SelectObject(acDocument, "myWriterDocument.odt")
++//}}}
++
++
++
The //Selected// property determines if the specified row in a list box is currently selected.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | [[ListBox]] | [[ListBox]] | [[ListBox]] |A listbox on an open form, dialog or in a [[GridControl]]|
++!!!Syntax
++//control//{{{.Selected}}}
++//control//{{{.Selected(}}}//index//{{{)}}}
++//control//{{{.Selected}}} = //value//
++{{{setSelected(}}}//control, value, index//{{{)}}}
++!!!Returned values / Arguments
++{{{Array of Booleans}}} (might be empty) if index is absent.
++{{{Boolean}}} if index is present
++!!!Remarks
++*It is better to use the [[Value]] property for non-multiselect listboxes.
++*Selecting an item in a [[combobox|ComboBox]] is done with the [[Value]] property.
++*The //index// argument must have a (integer or long) value between 0 and (//~ListCount// - 1)
++*If //index// is absent //control//{{{.Selected}}} returns an array dimensioned as [0 ... //~ListCount// - 1]. If the listbox is empty the returned array is also empty.
++*If //index// is absent the //value// argument must be an array dimensioned as [0 ... //~ListCount// - 1].
++*The use of {{{setSelected(}}}//control, value, index//{{{)}}} as syntax is due to the incapacity of Basic to accept //Optional// arguments in //Property Let// routines.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property 'Selected' not applicable in this context |
++|Out of array range or incorrect array size for property 'Selected'|
++!!!See also
++[[ItemData]]
++[[ListCount]]
++[[ListIndex]]
++[[MultiSelect]]
++[[RowSource]]
++[[RowSourceType]]
++[[Value]]
++!!!Example
++*List box
++<<tiddler "ListBox example">>
++
++
++
Search a string in a text column and select it when found
++//{{{
++Dim ofForm As Object, ocControl As Object
++Const cstSearch = "WINNIE"
++	Set ofForm = Forms("myForm")
++	Set ocControl =ofForm.Controls("myGridControl").Controls("mytextField")
++	With ocControl
++		.SetFocus()
++		DoCmd.FindRecord(cstSearch, acAnyWhere, True, , , acCurrent, True)	'	Find first occurrence
++		.SelText = cstSearch
++		MsgBox "String '" & cstSearch & "' found in position " & .SelStart & ". Length = " .SelLength
++	End With
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //~SendObject// action outputs the data in the specified object (currently only a form) to several output formats and inserts it into an e-mail. Recipients, subject and other elements can be inserted automatically as well.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]SendObject(}}}//{{{ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description | !Returned value |
++|{{{ObjectType}}} | Yes | acSendNoObject<br />acSendForm |The type of object to output.<br />If absent the default value is {{{acSendNoObject}}}. | {{{True}}} if success |
++|{{{ObjectName}}} | Yes | String |The valid name of an object of the type selected by the //~ObjectType// argument. If you want to output the active object, specify the object's type for the {{{ObjectType}}} argument and leave this argument blank.<br />If the {{{ObjectType}}} argument is left empty or is equal to the default value, if this argument is not empty, then it will be interpreted as the full path name of the file to attach to the mail. |~|
++|{{{OutputFormat}}} | Yes | acFormatPDF<br />acFormatODT<br />acFormatDOC<br />acFormatHTML |The output format, expressed as an acFormatXXX constant. If this argument is omitted, te user will be prompted for the output format. |~|
++|{{{To}}} | Yes | String |The recipients of the message whose names you want to put on the To line in the mail message.<br />Separate the recipients' names you specify in this argument (and in the Cc and Bcc arguments) with a semicolon (;).<br />If the mail application can't identify the recipients' names, the message isn't sent and an error occurs. |~|
++|{{{Cc}}} | Yes | String |The message recipients whose names you want to put on the Cc ("carbon copy") line in the mail message. |~|
++|{{{Bcc}}} | Yes | String |The message recipients whose names you want to put on the Bcc ("blind carbon copy") line in the mail message. |~|
++|{{{Subject}}} | Yes | String |The subject of the message. This text appears on the Subject line in the mail message. |~|
++|{{{MessageText}}} | Yes | String |Any text you want to include in the message in addition to the database object or the attachment. This text appears in the main body of the mail message. If you leave this argument blank, no additional text is included in the mail message.<br />If you leave the {{{ObjectType}}} and {{{ObjectName}}} arguments blank, you can use this argument to send a mail message without any database object. |~|
++|{{{EditMessage}}} | Yes | Boolean |Specifies whether the message can be edited before it's sent. If you select {{{True}}}, the electronic mail application starts automatically, and the message can be edited. If you select {{{False}}}, the message is sent without the user having a chance to edit the message.<br />The default is {{{True}}}. |~|
++|{{{TemplateFile}}} | Yes | String |If present, must be a null-length string. |~|
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acSendForm = 2
++Const acSendNoObject = -1
++
++Const acFormatPDF = "writer_pdf_Export"
++Const acFormatODT = "writer8"
++Const acFormatDOC = "MS Word 97"
++Const acFormatHTML = "HTML"
++//}}}
++!!!Remarks
++*//~Access2Base// uses for the sending of the mail the most appropriate of next protocols:
++| !Protocol | !Used when | !Limitations | !Consequence |
++|mailto: |{{{ObjectType}}} left empty or = {{{acSendNoObject}}} and {{{ObjectName}}} left blank. |No attachments<br />Message edition always allowed. |The {{{EditMessage}}} argument is ignored. |
++|~XSimpleMailMessage<br />UNO interface |~LibreOffice<br />~OpenOffice 3.X |No Body insertion |The {{{MessageText}}} argument is ignored. |
++|~|~|Maximum 1 "To" recipient |All the "To" recipients as from the 2nd in the list are added to the "Cc" recipients list. |
++|~XSystemMailProvider<br />UNO interface |~OpenOffice 4.X |Maximum 1 "To" recipient |All the "To" recipients as from the 2nd in the list are added to the "Cc" recipients list. |
++*If a form has to be sent, the designated form MUST be open before the //~SendObject// action is called.
++*If the {{{ObjectName}}} argument is a file name then it may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++*When the form is transformed into another format, //~Access2Base// will use as temporary directory the directory mentioned in the //AOO/~LibO// {{{Options}}} for the {{{Paths/Temporary files}}} parameter.
++!!!Error messages
++|Object '...' not found |
++|Action not applicable in this context |
++|File access error on file '...' |
++|Mail service could not be activated |
++!!!See also
++[[OutputTo]]
++[[SelectObject]]
++!!!Example
++<<tiddler "SendObject example">>	
++
++
++
To send a message without attachments, with a body. The mail client will open before the message being sent.
++//{{{
++	DoCmd.SendObject( , , , "abc@def.com;ghi@def.com","xyz@abc.eu",,"This is the subject", "This is" & chr(13) & "the body")
++//}}}
++To send a file as attachment. The body will however be ignored. The mail client will open before the message being sent.
++//{{{
++	Const acFormatPDF = "writer_pdf_Export"
++	DoCmd.SendObject(, "file:///C:/Users/MyName/Documents/Doc/Access2Base/access2base.html" _
++		, acFormatPDF, "abc@def.com;me@sdf.eu", "aaa@kk.it;bbb@kk.it", "me@mail.be", "This is the subject", "This is" & chr(13) & "the body" _
++		)
++//}}}
++To send a form in PDF as attachment in the mail, the mail client will not propose to edit the message
++//{{{
++	Const acFormatPDF = "writer_pdf_Export"
++	DoCmd.SendObject(acSendForm, "myForm", acFormatPDF, "toyou@yourmail.eu", , , "Read carefully the attached file", , False)
++//}}}
++
++
++
The //~SetFocus// method moves the focus to the specified form or to the specified control on the active form.
++!!!Applies to ...
++| !Object | !Description |
++|[[Form]] |The representation of a form |
++|[[Control]] |The representation of a control within a [[form|Form]], a [[subform|SubForm]] or a [[gridcontrol|GridControl]] |
++!!!Syntax
++//form//.{{{SetFocus}}}
++//control//.{{{SetFocus}}}
++!!!Returned value
++//True// if success.
++!!!Remarks
++!!!Error messages
++|Control '...' not found in gridcontrol '...' |
++!!!See also
++[[Bookmark]]
++[[FindRecord]]
++[[GoToRecord]]
++[[SelectObject]]
++!!!Example
++<<tiddler "SetFocus example">>
++
++
++
Set focus on named control
++//{{{
++Dim sControl As String
++	getObject("Forms!myForm!myControl").SetFocus
++//}}}
++
++
++
The //~SetHiddenAttribute// action hides or shows the specified window.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]SetHiddenAttribute(}}}//{{{ObjectType, ObjectName, Hidden}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description | !Returned Value |
++|{{{ObjectType}}} | No | acTable<br />acQuery<br />acForm<br />acReport<br />acDiagram (i.e. Relationships)<br />acBasicIDE<br />acDatabaseWindow<br />acDocument |The type of object to hide or show. | True if sucess |
++|{{{ObjectName}}} | Yes | String |The name of the object to hide or to show. This argument is NOT case-sensitive.<br />The argument is mandatory when the //~ObjectType// argument is one of next values: //acTable//, //acQuery//, //acForm//, //acReport// or //acDocument//.<br />When the //~ObjectType// is equal to //acDocument//, the //~ObjectName// argument must contain the __filename__ of the targeted window. |~|
++|{{{Hidden}}} | Yes | Boolean |{{{True}}} (default value) hides the object window.<br />{{{False}}}.makes the object visible again and sets the __focus__ on the window. |~|
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acDiagram = 8
++Const acForm = 2
++Const acQuery = 1
++Const acReport = 3
++Const acTable = 0
++
++Const acBasicIDE = 101
++Const acDatabaseWindow = 102
++Const acDocument = 111
++//}}}
++!!!Remarks
++*In //~MSAccess// the //~SetHiddenAttribute// action is related to the [[Application]] root object, not to the [[DoCmd]] one.
++*When the //~ObjectType// is {{{acTable}}}, {{{acQuery}}}, {{{acForm}}} or {{{acReport}}}, the named object MUST be open.
++*Before hiding the database window, be sure that a (programmatic) mean exists to make it visible again and be able to close the Base application.
++!!!Error messages
++|Arguments are missing or are not initialized |
++|Argument nr. ... [Value = '...'] is invalid |
++|Object '...' not found |
++!!!See also
++[[GetHiddenAttribute]]
++[[Maximize]]
++[[Minimize]]
++[[MoveSize]]
++[[RunCommand]]
++[[SetFocus]]
++[[SelectObject]]
++!!!Example
++<<tiddler "SetHiddenAttribute example">>
++
++
++
Hide the database window, select an open and visible form then maximize it.
++//{{{
++Const acForm = 2
++Const acDatabaseWindow = 102
++	DoCmd.SetHiddenAttribute(acDatabaseWindow)
++	If Not GetHiddenAttribute(acForm, "myForm") Then
++		DoCmd.SelectObject(acForm, "myForm")
++		DoCmd.Maximize()
++	End If
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;W @@
++ }}}hen you run the //~SetOrderBy// action, the sort is applied to the table, form or datasheet (for example, query result) that is active and has the focus.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]SetOrderBy(}}}//{{{[orderby], [controlname]}}}//{{{)}}}
++| !Argument | !Optional | !Type |!Description |
++|{{{orderby}}} | Yes | String |The name of the field or fields on which you want to sort records. When you use more than one field name, separate the names with a comma (,). |
++|{{{controlname}}} |~|~|The name of a subform of the active form. |
++!!!Remarks
++*The //~SetOrderBy// action must not be called from a [[standalone form|Standalone Forms]].
++*The //~SetOrderBy// action is applied on the current window. To make a window current, use the [[SelectObject]] action. If the current window is neither a form, a table datasheet or a query datasheet, the //~SetOrderBy// action returns {{{False}}} and ignores the request.
++*The //~SetOrderBy// action, when applied to a table or a query datasheet, __does NOT work in //~OpenOffice//__ (//~LibreOffice// OK).
++*To sort a table or a query with //~SetOrderBy//, the table or the query must be open. Eventually use therefore the [[OpenTable]] or [[OpenQuery]] actions.
++*If //controlname// is present, the active window is expected to be a form.  Otherwise //~SetOrderBy// refurns {{{False}}} and the request is ignored. The //controlname// is NOT case-sensitive. If //controlname// does not exist in the active form or is not the name of one of its [[subforms|SubForm]] then the action generates a run-time error.
++*When records are sorted with //~SetOrderBy// the first record (if it exists ...) becomes the current record.
++*Once applied, the sorting sequence is preserved for subsequent table or query openings during the same //~LibreOffice/~OpenOffice// session. It will become persistent when the database file ("*.odb") is saved.
++*In the orderby argument, record and field names may be surrounded by square brackets. They will be replaced with the correct character surrounding such names in SQL statements targeted to be run on the concerned RDBMS (Relational Database Management System).
++*To sort records in descending order, type DESC immediately after the field that needs to be sorted in descending order.
++*Giving the null-length string ("") as orderby argument resets any pre-existing sorting sequence.
++!!!Error messages
++|Argument nr.X [Value = '...'] is invalid|
++|Control '...' not found in parent (form, grid or dialog) '...' |
++|Subform '...' not found in parent form '...' |
++!!!See also
++[[ApplyFilter]]
++[[Filter]]
++[[FilterOn]]
++[[GoToRecord]]
++[[SelectObject]]
++[[SetFocus]]
++!!!Example
++<<tiddler "SetOrderBy example">>
++
++
++
Sort the records of a subform
++//{{{
++Dim sSetOrderBy As String
++Const cstFormName = "INVOICE"
++Const cstSubFormName = "SubForm"
++	OpenForm(cstFormName)
++	sSetOrderBy = "[PURCHASE_PRICE] DESC"
++	SelectObject(acForm, cstFormName)
++	DoCmd.SetOrderBy(sSetOrderBy, cstSubFormName)
++//}}}
++
++
++
*Shippers table
++| !Fields | !Field Type | !Primary |
++|~CompanyName |Text ||
++|Phone |Text ||
++|~ShipperID |~BigInt | Y |
++
++
++
The shortcut n{{firstletter{
++ @@color:#930;T@@
++ }}}ation allows to reach an [[object|Object Model]] or anyone of its properties by mean of a call to one single function. The first argument of the function is a ''STRING'' designating unambiguously the target [[form|Form]], [[dialog|Dialog]] or [[control|Control]], or one of their properties.
++!!!The shortcut notation
++The //shortcut notation// binds several //components// by mean of two operators:
++*The "!" (exclamation mark)<br />The component on the left of the "!" is a //parent// of the component on its right. A //parent// may be a [[collection|Collection]] or an [[object|Object Model]] containing other //objects//, just like __a form contains controls__.<br />The first component must be a collection.
++| ! Allowed collections | ! |
++| [[Forms]] |The form must be open. |
++| [[Dialogs|AllDialogs]] |The dialog must be active but not necessarily in execution. |
++| [[TempVars]] |The invoked temporary variable must exist. |
++*The "." (dot)<br />The dot separates an object on its left from one of the properties of the object on its right.
++Note that the //shortcut notation// is NOT case-sensitive.
++!!!Remarks
++In //~MSAccess// the shortcut notation is a construction recognized as such by the Visual Basic interpreter. It can be used directly in expressions.
++In //~Access2Base// the notation is given as a {{{String}}} argument to the [[getObject]], [[getValue]] and a few other functions.
++!!!Examples
++*The //myForm// form:
++//{{{
++Forms!myForm
++//}}}
++*The //myDialog// dialog:
++//{{{
++Dialogs!myDialog
++//}}}
++*The //myVar// variable
++//{{{
++TempVars!myVar
++//}}}
++*The [[AllowEdits]] property of //myForm//:
++//{{{
++Forms!myForm.AllowEdits
++//}}}
++*The [[Visible]] property of //myDialog//:
++//{{{
++Dialogs!myDialog.Visible
++//}}}
++*A control in //myForm//:
++//{{{
++Forms!myForm!myControl
++//}}}
++*The [[BackColor]] property of //myControl//:
++//{{{
++Forms!myForm!myControl.BackColor
++Dialogs!myDialog!myControl.BackColor
++//}}}
++*A control in a subform:
++//{{{
++Forms!myForm!mySubForm.Form!mySubcontrol
++//}}}
++*The [[ControlTipText]] property of a control in a [[gridcontrol|GridControl]] located itself in a subform:
++//{{{
++Forms!myForm!mySubForm.Form!myGridControl!mySubControl.ControlTipText
++//}}}
++!!!Associated functions
++| !Function | !Description |
++|[[getObject]] |Returns an object corresponding with its argument. |
++|[[getValue]] |Returns a property of the object corresponding with its argument. |
++|[[setValue]] |Sets a property of the object corresponding with its first argument. |
++
++>[[To know more ...|ShortcutNotationMore]]
++
++
++
(Q) Can I reach any control on any form with the shortcut notation ?
++
++(R) The [[ShortCut Notation]] is a very rapid mean to reach the control or form you want and ...
++*get with the [[getObject]] function its corresponding //~Access2Base// [[form|Form]] or [[control|Control]] [[object|Object Model]]
++*get or set - with [[getValue]] or [[setValue]] - any property of the targetted object
++
++The //shortcut notation// binds several //components// by mean of two operators:
++*The "!" (exclamation mark)<br />The component on the left of the "!" is a //parent// of the component on its right. A //parent// may be a [[collection|Collection]] or an [[object|Object Model]] containing other //objects//, just like __a form contains controls__.<br />The first component must be a collection, the only allowed collections being [[Forms]] and [[Dialogs|AllDialogs]].
++*The "." (dot)<br />The dot separates an object on its left from one of the properties of the object on its right.
++
++Note also that a shortcut is NOT case-sensitive.
++
++Let's assume
++#//Mainform// is the name of the top level FORM
++#//Subform1// is the name of the subform CONTROL on //Mainform//
++#//Subform2// is the name of the subform CONTROL on //Subform1//
++#//~Subform2_Grid// is the name of the grid CONTROL contained in //Subform2//
++!!!To refer to a form property, like [[RecordSource]]
++|On //Mainform// |Forms!Mainform.~RecordSource |
++|On //Subform1// |Forms!Mainform!Subform1.Form.~RecordSource |
++|On //Subform2// |Forms!Mainform!Subform1.Form!Subform2.Form.~RecordSource |
++!!!To refer to a control
++|On //Mainform// |Forms!Mainform!~ControlName |
++|On //Subform1// |Forms!Mainform!Subform1.Form!~ControlName |
++|On //Subform2// |Forms!Mainform!Subform1.Form!Subform2.Form!~ControlName |
++|On //~Subform2_Grid// |Forms!Mainform!Subform1.Form!Subform2.Form!~Subform2_Grid!~ControlName |
++!!!To refer to a control property, like [[Enabled]]
++|On //Mainform// |Forms!Mainform!~ControlName.Enabled |
++|On //Subform1// |Forms!Mainform!Subform1.Form!~ControlName.Enabled |
++|On //Subform2// |Forms!Mainform!Subform1.Form!Subform2.Form!~ControlName.Enabled |
++|On //~Subform2_Grid// |Forms!Mainform!Subform1.Form!Subform2.Form!~Subform2_Grid!~ControlName.Enabled |
++!!!To refer to a subform or grid control property, like [[Name]]
++|On //Subform1// |Forms!Mainform!Subform1.Name |
++|On //Subform2// |Forms!Mainform!Subform1.Form!Subform2.Name |
++|On //~Subform2_Grid// |Forms!Mainform!Subform1.Form!Subform2.Form!~Subform2_Grid.Name |
++
++
++

++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he //ShowAllRecords// action removes any existing filters and sorts that may exist on the current table, query, or form.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]ShowAllRecords()}}}
++!!!Remarks
++*The //~ShowAllrecords// action is usually preceded by a [[SelectObject]] action or by the [[SetFocus]] method applied on the targeted //form//.
++*//~ShowAllRecords// returns {{{True}}} if the action was successful, {{{False}}} otherwise.
++*The //~ShowAllrecords// action must not be triggered from a [[standalone form|Standalone Forms]]. Use the [[FilterOn]] property instead.
++!!!Error messages
++|Action not applicable in this context |
++!!!See also
++[[FilterOn]]
++[[SelectObject]]
++[[SetFocus]]
++!!!Example
++<<tiddler "ShowAllRecords example">>
++
++
++
Reset existing filter or sort on an open form
++//{{{
++	SelectObject(acForm, "myForm")
++	ShowAllRecords
++//}}}
++
++
++
(Q) Can I easily simulate a tabbed interface (like in Calc ... ?) in a database form ?
++
++(R) A tabbed interface is for building wizards stepping from a page to the next or hiding/unhiding portions of a form when a button is clicked.
++This feature is builtin In a [[dialog|Dialog]]. See the [[Page]] property of dialogs and/or dialog [[controls|Control]].
++
++However in a form we will have to be more creative by:
++*making use of the concept of //sections// (remember that a database form is finally a Writer document ...). Indeed //sections// can be made programmatically hidden or visible very simply.
++*managing them by mixing the //~Access2Base// and //UNO// API's
++You have to understand that a //section// in a Writer document is nothing else than a set of __contiguous paragraphs__.
++If we anchor a control on the form to a paragraph, and if that paragraph is included a a //section//, when hiding the //section// the control will be made hidden as well.
++
++The concept has been derived from a topic from the (french) [[OpenOffice forum|https://forum.openoffice.org/fr/forum/viewtopic.php?f=29&t=23703]].
++
++In next example we have put the main form - except its 2 top buttons //Orders// and //Details// - , in the first section, and a subform in the second one.This allows us to obtain next result:
++
++[img[tabbed_orders.png]]
++and after having pressed the //Details// button:
++
++[img[tabbed_details.png]]
++!!!The code behind the top buttons
++//{{{
++Public Sub SelectTab(Optional poEvent As Object)
++Dim oEvent As Object, oForm As Object
++	Set oEvent = Application.Events(poEvent)
++	Set oForm = Forms("Orders_Tabbed")
++	If oEvent.Source.Name = "btnOrders" Then
++		oForm.Component.TextSections.getByIndex(1).IsVisible = False
++		oForm.Component.TextSections.getByIndex(0).IsVisible = True
++		oEvent.Source.Value = True
++		oForm.Controls("btnDetails").Value = False
++	Else			'	btnDetails
++		oForm.Component.TextSections.getByIndex(0).IsVisible = False
++		oForm.Component.TextSections.getByIndex(1).IsVisible = True
++		oEvent.Source.Value = True
++		oForm.Controls("btnOrders").Value = False
++	End If	
++End Sub
++//}}}
++The code manages
++*the visibility of each section : see the //~TextSections// property of text components;
++*the toggle status of the upper buttons : see the [[Value]] property of command buttons.
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Tabbed |~Orders_Tabbed ||btnOrders<br />btnDetails |Execute action ||
++
++
++
{{indent{It's about converting ''PEOPLE'', not data
++
++
++
//[[Access2Base|Home]]//
++
++
++
http://www.access2base.com/
++
++
++
Returns a value that indicates the maximum size, in bytes, of a [[Field object|Field]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a table, a query or a recordset. |
++!!!Syntax
++//field//{{{.Size}}}
++!!!Returned values
++{{{Long}}}
++!!!Remarks
++*The //Size// property is read-only.
++*For fields (other than Memo type fields) that contain character data, the //Size// property indicates the maximum number of characters that the field can hold. For numeric fields, the //Size// property indicates the number of decimal digits that the field can hold.
++*For Long Binary and Memo Field objects, //Size// is always set to 0. To determine the size of a [[Field object|Field]] of the Memo or Long Binary types, use the [[FieldSize property|FieldSize]].
++!!!Error messages
++|Property 'Size' not applicable in this context |
++!!!See also
++[[DataType]]
++[[FieldSize]]
++!!!Example
++
++
++

++
++
++
Returns a value that indicates the name of the field that is the original source of the data for a [[Field object|Field]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a [[TableDef]] or a [[QueryDef]]. |
++!!!Syntax
++//field//{{{.SourceField}}}
++!!!Returned values
++{{{String}}}
++!!!Remarks
++*The value returned by the //~SourceField// property of a field belonging to a //~TableDef// is probably not relevant. It is however applicable.
++*The //~SourceField// property is not valid for a [[Recordset]] object.
++!!!Error messages
++!!!See also
++[[SourceTable]]
++!!!Example
++
++
++
returns a value that indicates the name of the table that is the original source of the data for a [[Field object|Field]].
++!!!Applies to ...
++| !Object |!Description |
++|[[Field]] |The representation of a field of a [[TableDef]], a [[QueryDef]] or a [[Recordset]]. |
++!!!Syntax
++//field//{{{.SourceTable}}}
++!!!Returned values
++{{{String}}}
++!!!Remarks
++The value returned by the //~SourceTable// property of a field belonging to a //~TableDef// is probably not relevant. It is however applicable.
++!!!Error messages
++!!!See also
++[[SourceField]]
++!!!Example
++
++
++

++
++
++
/***
++|''Name:''|SpecificA2BPlugin|
++|''Description:''|Forces readOnly to true or false. Useful to distribute a ReadOnly version of Access2Base help file. Set value to //true// in code below.|
++!Code
++***/
++//{{{
++readOnly = (window.location.protocol == "file:") ? true : config.options.chkHttpReadOnly;
++//}}}
++/***
++|''Description:''|Modify tiddler tooltip for anonymisation.<br>Standard value: "%0 - %1, %2".|
++!Code
++***/
++//{{{
++merge(config.messages,{
++	tiddlerLinkTooltip: "%0 - Click to open",
++});
++//}}}
++/***
++|''Description''|Modify the header of the List macro.|
++!Code
++***/
++//{{{
++config.macros.list.all.prompt = "All topics in alphabetical order";
++//}}}
++
++
++
++
Connect all standalone form contained in a non-Base document to their target databases:
++//{{{
++Sub DBOpen(Optional poEvent As Object)
++	If GlobalScope.BasicLibraries.hasByName("Access2Base") then
++		GlobalScope.BasicLibraries.loadLibrary("Access2Base")
++	End If
++	Call Application.OpenConnection(ThisComponent)
++End Sub
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;S@@
++ }}}//tandalone forms// are stored in non-Base AOO/~LibO documents (Writer, Calc, ...), usually (but not necessarily) built from a normal //form// Base object. These forms and controls may be linked with data located in databases by referring to a Base document (".odb" file) in the __data tab__ of the form properties.
++
++>''Each such form may access a separate database document !''
++
++To make such forms, documentation is available on several forums, e.g. [[here|http://user.services.openoffice.org/en/forum/viewtopic.php?t=40493]].
++
++//~Access2Base// may be invoked from macros stored in documents containing one or more //standalone forms//. However NOT ALL the properties, methods, actions etc. are meaningful in such a context.
++Find below the status by function. If not mentioned a function is available without restriction.
++
++In addition a //standalone form// does see the //Table// and //Query// objects stored within the database document (".odb" file) where it is connected with.
++At the opposite:
++|A //standalone form// ''CANNOT INTERACT'' with  (either standalone or embedded) forms stored in ''OTHER DOCUMENTS''.<br />If it is necessary to exchange data between individual //~LibO/AOO// applications, use [[TempVar]] objects. Their scope is the whole //~LibO/AOO// session. |
++|A //standalone form// can ''READ and MODIFY DATA'' in its related database, can ''READ its DESIGN'' but cannot modify it. |
++Several documents containing standalone forms might be opened at the same time, all using the //~Access2Base// API.
++!!Use the ~Access2Base library
++To be able to invoke the //~Access2Base// API from a non-Base AOO/~LibO document you have to
++*Have a minimal knowledge of the Basic IDE and of the Basic programming language.
++*Open the targeted document and edit at least next macro:
++<<tiddler "Standalone Connect example">>
++*Assign with menu items {{{Tools + Customize...}}} ({{{Events}}} tab) the above Sub ("~DBOpen" in the example but use the name of your choice) to the //~OpenDocument// event. Save in the document file itself.
++*__Optionally__ associate next code with the //"View is going to be closed"// document event.
++//{{{
++Sub DBClose(Optional poEvent As Object)
++	Call CloseConnection()
++End Sub
++//}}}
++*//Close// and re-//open// the file. This will trigger the //~OpenDocument// event.
++*Start programming macro's. Associate them with //form// or //control events// if relevant
++!!Next functions are available __with limitations__
++| !Function | !Limitation |
++|[[AllForms]] |The //~AllForms// collection is limited to the //standalone forms// stored in the same document.<br />When a document contains one single form - which is very often the case - the smart syntax for invoking that single form is simply:<br />{{{AllForms(0)}}}<br />which will return a //form object// representing the single //standalone form// itself, giving subsequently access to its individual controls. |
++|[[FindRecord]] |If the form contains subforms and if the targeted field to search on is in that subform, then the //~OnlyCurrentField// argument must be a {{{string}}} containing a [[shortcut|ShortCut Notation]] if the targeted grid or grid column is in the subform. |
++|[[GoToRecord]] |The //~ObjectType// argument must be equal to {{{acDataForm}}} and the //~ObjectName// argument must be  a {{{string}}} containing either the name of the targeted form or a [[shortcut|ShortCut Notation]] to it. |
++|[[SelectObject]] |The objects opened from a Base document (".odb") - tables, queries, etc. - can be selected from a //standalone form//.<br />Similarly //Standalone forms// can be selected from a Base document (".odb") via their filenames.<br />However no interaction is possible between them thru the //~Access2Base// API. As an example it is not possible to know from the current //standalone form// the content of a //control// located in another //database form// or a //standalone form// belonging to another document. |
++|[[Height]]<br />[[Width]]<br />[[Move]] |These methods, even when applied to a specific form, act on the containing window, i.e. on all its forms. |
++|[[OpenArgs]] |The //~OpenArg// (read-only) property always returns a zero-length string. |
++!!Next functions are not available
++//~Access2Base// will generate an error (or sometimes ignore the request) if one of next functions is invoked from a //standalone form// context.
++| !Function | !Comment |
++|[[ApplyFilter]] |Use the [[Filter]] and [[FilterOn]] form properties instead. |
++|[[Close]] |Forbidden when applied to a form or another database object.<br />Closing a [[Recordset]] is allowed. |
++|[[CopyObject]] |A standalone form has limited access to database objects. The offered facilities are mainly [[recordset|Recordset]] manipulations thru tables and queries. |
++|[[OpenForm]], [[OpenQuery]], [[OpenReport]], [[OpenTable]] |~|
++|[[CreateQueryDef]] |~|
++|[[CreateTableDef]], [[CreateField]], [[Add]] |~|
++|[[Delete (table-query)]] |~|
++|[[GoToControl]] |Use the [[SetFocus]] method instead. |
++|[[Quit]] ||
++|[[ShowAllRecords]] |Use the [[FilterOn]] and/or [[OrderByOn]] form properties instead. |
++!!See also ...
++[[CloseConnection]]
++[[OpenConnection]]
++
++
++
The //Start// method initializes the specified [[dialog|Dialog]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Dialog]] |The representation of a Basic dialog |
++!!!Syntax
++//dialog//.{{{Start}}}
++| !Returned value |
++|//True// if success. |
++!!!Remarks
++The //Start// method makes the controls of the dialog available to the programmer. The display of the dialog will be triggered by the [[Execute|Execute (dialog)]] method.
++!!!Error messages
++|Dialog unknown |
++|Dialog already started |
++!!!See also
++[[AllDialogs]]
++[[EndExecute]]
++[[Execute|Execute (dialog)]]
++[[Terminate]]
++!!!Example
++<<tiddler "Dialog example">>
++
++
++
/***
++!~TiddlyWiki Classic Color Scheme
++Designed by Jeremy Ruston
++http://tiddlystyles.com/#theme:Classic
++
++To use this color scheme copy the ~ClassicTiddlyWiki contents into a tiddler and name it 'StyleSheet' also grab the ~ClassicTemplate and copy its contents into a tiddler named 'PageTemplate'.
++
++!Colors Used
++*@@bgcolor(#630):color(#fff): #630@@
++*@@bgcolor(#930): #930@@
++*@@bgcolor(#996633): #963@@
++*@@bgcolor(#c90): #c90@@
++*@@bgcolor(#cf6): #cf6@@
++*@@bgcolor(#cc9): #cc9@@
++*@@bgcolor(#ba9): #ba9@@
++*@@bgcolor(#996): #996@@
++*@@bgcolor(#300):color(#fff): #300@@
++*@@bgcolor(#000000):color(#fff): #000@@
++*@@bgcolor(#666): #666@@
++*@@bgcolor(#888): #888@@
++*@@bgcolor(#aaa): #aaa@@
++*@@bgcolor(#ddd): #ddd@@
++*@@bgcolor(#eee): #eee@@
++*@@bgcolor(#ffffff): #fff@@
++*@@bgcolor(#f00): #f00@@
++*@@bgcolor(#ff3): #ff3@@
++!Generic Rules /%==============================================%/
++***/
++/*{{{*/
++body {
++ background: #fff;
++ color: #000;
++}
++
++a{
++ color: #963;
++}
++
++a:hover{
++ background: #963;
++ color: #fff;
++}
++
++a img{
++ border: 0;
++}
++
++h1,h2,h3,h4,h5 {
++ background: #cc9;
++}
++/*}}}*/
++/***
++!Header /%==================================================%/
++***/
++/*{{{*/
++.header{
++ background: #300;
++}
++
++.titleLine {
++ color: #fff;
++ padding: 5em 0em 1em .5em;
++}
++
++.titleLine a {
++ color: #cf6;
++}
++
++.titleLine a:hover {
++ background: transparent;
++}
++/*}}}*/
++/***
++!Main Menu /%=================================================%/
++***/
++/*{{{*/
++#mainMenu .button {
++ color: #930;
++}
++
++#mainMenu .button:hover {
++ color: #cf6;
++ background: #930;
++}
++
++#mainMenu li{
++ list-style: none;
++}
++/*}}}*/
++/***
++!Sidebar options /%=================================================%/
++~TiddlyLinks and buttons are treated identically in the sidebar and slider panel
++***/
++/*{{{*/
++#sidebar {
++ background: #c90;
++ right: 0;
++}
++
++#sidebarOptions a{
++ color: #930;
++ border: 0;
++ margin: 0;
++ padding: .25em .5em;
++}
++
++#sidebarOptions a:hover {
++ color: #cf6;
++ background: #930;
++}
++
++#sidebarOptions a:active {
++ color: #930;
++ background: #cf6;
++}
++
++#sidebarOptions .sliderPanel {
++ background: #eea;
++ margin: 0;
++}
++
++#sidebarOptions .sliderPanel a {
++ color: #930;
++}
++
++#sidebarOptions .sliderPanel a:hover {
++ color: #cf6;
++ background: #930;
++}
++
++#sidebarOptions .sliderPanel a:active {
++ color: #930;
++ background: #cf6;
++}
++/*}}}*/
++/***
++!Sidebar tabs /%=================================================%/
++***/
++/*{{{*/
++.tabSelected,.tabContents {
++ background: #eea;
++ border: 0;
++}
++
++.tabUnselected {
++ background: #c90;
++}
++
++#sidebarTabs {
++ background: #c90;
++}
++
++#sidebarTabs .tabSelected{
++ color: #cf6;
++ background: #963;
++}
++
++#sidebarTabs .tabUnselected {
++ color: #cf6;
++ background: #930;
++}
++
++#sidebarTabs .tabContents{
++ background: #963;
++}
++
++#sidebarTabs .txtMoreTab .tabSelected,
++#sidebarTabs .txtMoreTab .tabSelected:hover{
++ background: #930;
++ color: #cf6;
++}
++
++#sidebarTabs .txtMoreTab .tabUnselected,
++#sidebarTabs .txtMoreTab .tabUnselected:hover{
++ background: #300;
++ color: #cf6;
++}
++
++#sidebarTabs .txtMoreTab .tabContents {
++ background: #930;
++}
++
++#sidebarTabs .tabContents a {
++ color: #cf6;
++ border: 0;
++}
++
++#sidebarTabs .button.highlight,
++#sidebarTabs .tabContents a:hover {
++ background: #cf6;
++ color: #300;
++}
++/*}}}*/
++/***
++!Message Area /%=================================================%/
++***/
++/*{{{*/
++#messageArea {
++ background: #930;
++ color: #fff;
++}
++
++#messageArea a:link, #messageArea a:visited {
++ color: #c90;
++}
++
++#messageArea a:hover {
++ color: #963;
++ background: transparent;
++}
++
++#messageArea a:active {
++ color: #fff;
++}
++/*}}}*/
++/***
++!Popup /%=================================================%/
++***/
++/*{{{*/
++.popup {
++ background: #eea;
++ border: 1px solid #930;
++}
++
++.popup hr {
++ color: #963;
++ background: #963;
++ border-bottom: 1px;
++}
++
++.popup li.disabled {
++ color: #ba9;
++}
++
++.popup li a, .popup li a:visited {
++ color: #300;
++}
++
++.popup li a:hover {
++ background: #930;
++ color: #eea;
++}
++/*}}}*/
++/***
++!Tiddler Display /%=================================================%/
++***/
++/*{{{*/
++.tiddler .button {
++ color: #930;
++}
++
++.tiddler .button:hover {
++ color: #cf6;
++ background: #930;
++}
++
++.tiddler .button:active {
++ color: #fff;
++ background: #c90;
++}
++
++.shadow .title {
++ color: #888;
++}
++
++.title {
++ color: #422;
++}
++
++.subtitle {
++ color: #866;
++}
++
++.toolbar {
++ color: #aaa;
++}
++
++.toolbar a,
++.toolbar a:hover{
++ border: 0;
++}
++
++.tagging, .tagged {
++ border: 1px solid #fff;
++ background-color: #ffc;
++}
++
++.selected .tagging, .selected .tagged {
++ border: 1px solid #aa6;
++ background-color: #ffc;
++}
++
++.tagging .listTitle, .tagged .listTitle {
++color: #999999;
++}
++
++.footer {
++ color: #ddd;
++}
++
++.selected .footer {
++ color: #888;
++}
++
++.sparkline {
++ background: #eea;
++ border: 0;
++}
++
++.sparktick {
++ background: #930;
++}
++
++.errorButton {
++ color: #ff0;
++ background: #f00;
++}
++
++.zoomer {
++ color: #963;
++ border: 1px solid #963;
++}
++/*}}}*/
++/***
++''The viewer is where the tiddler content is displayed'' /%------------------------------------------------%/
++***/
++/*{{{*/
++.viewer .button {
++ background: #c90;
++ color: #300;
++ border-right: 1px solid #300;
++ border-bottom: 1px solid #300;
++}
++
++.viewer .button:hover {
++ background: #eea;
++ color: #c90;
++}
++
++.viewer .imageLink{
++ background: transparent;
++}
++
++.viewer blockquote {
++ border-left: 3px solid #666;
++}
++
++.viewer table {
++ border: 2px solid #303030;
++}
++
++.viewer th, thead td {
++ background: #996;
++ border: 1px solid #606060;
++ color: #fff;
++}
++
++.viewer td, .viewer tr {
++ border: 1px solid #606060;
++}
++
++.viewer pre {
++ border: 1px solid #963;
++ background: #eea;
++}
++
++.viewer code {
++ color: #630;
++}
++
++.viewer hr {
++ border: 0;
++ border-top: dashed 1px #606060;
++ color: #666;
++}
++
++.highlight, .marked {
++ background: #ff3;
++}
++/*}}}*/
++/***
++''The editor replaces the viewer in the tiddler'' /%------------------------------------------------%/
++***/
++/*{{{*/
++.editor input {
++ border: 1px solid #000;
++}
++
++.editor textarea {
++ border: 1px solid #000;
++ width: 100%;
++}
++
++.editorFooter {
++ color: #aaa;
++}
++
++.editorFooter a {
++ color: #930;
++}
++
++.editorFooter a:hover {
++ color: #cf6;
++ background: #930;
++}
++
++.editorFooter a:active {
++ color: #fff;
++ background: #c90;
++}
++/*}}}*/
++/***
++!Specific addition for ~Access2Base /%=================================================%/
++***/
++/*{{{*/
++@media print {#mainMenu {display: none ! important;}}
++@media print {#topMenu {display: none ! important;}}
++@media print {#sidebar {display: none ! important;}}
++@media print {#messageArea {display: none ! important;}} 
++@media print {#toolbar {display: none ! important;}}
++@media print {.header {display: none ! important;}}
++@media print {.tiddler .subtitle {display: none ! important;}}
++@media print {.tiddler .toolbar {display; none ! important; }}
++@media print {.tiddler .tagging {display; none ! important; }}
++@media print {.tiddler .tagged {display; none ! important; }}
++
++#mainMenu {
++ position:absolute;
++ left:0;
++ width:13em;
++ text-align:right;
++ line-height:1.6em;
++ padding:1.5em 0.5em 0.5em 0.5em;
++ font-size:1.1em;
++}
++#displayArea {
++ margin:1em 17em 0 16em;
++}
++
++.titleLine {
++ color: #fff;
++ padding: 3em 0em 1em .5em;
++}
++
++.firstletter{ float:left; width:0.75em; font-size:400%; font-family:times,arial; line-height:60%; } 
++
++.tiddler .subtitle { display:none; } 
++
++/*}}}*/
++/*~StyleSheetShortcuts*/
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}} //~SubForm// [[object|Object Model]] represents a subset of the controls of an open //form//. The open form is called the "parent form" or "master". ~SubForms are used mainly to access more than one table (or query) from a //form//. Each additional table requires its own //subform//.
++!!!Properties returning a subform object
++| !Parent object | !Property |!Description |
++|[[Control]] |[[Form|Form (subform)]] |A //subform// is a //Control// like another. The //Form// property of a control of type //~SubForm// will return a //~SubForm// object. |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[AllowAdditions]] |||Specifies whether a user can add a record when using the subform. |
++|[[AllowDeletions]] |||Specifies whether a user can delete a record when using the subform. |
++|[[AllowEdits]] |||Specifies whether a user can modify a record when using the subform. |
++|[[CurrentRecord]] |||Identifies the current record in the recordset being viewed on the subform. |
++|[[Filter]] |||Specifies a subset of records to be displayed. |
++|[[FilterOn]] |||Specifies if the Filter has to be applied. |
++|[[LinkChildFields]]<br />[[LinkMasterFields]] || Y |Specifies how records in the subform (//child//) are linked to records in its parent (//master//) form. |
++|[[Name]] || Y |Specifies the exact name of the subform control. |
++|[[ObjectType]] || Y |Returns "SUBFORM" |
++|[[OrderBy]] |||Specifies in which order the records should be displayed. |
++|[[OrderByOn]] |||Specifies if the ~OrderBy has to be applied. |
++|[[Parent]] || Y |Returns the parent object of the subform. |
++|[[RecordSource]] |||Specifies the source of the data. |
++|~ParentComponent | UNO | Y |com.sun.star.text.~TextDocument |
++|~DatabaseForm | UNO | Y |com.sun.star.form.component.~DataForm<br />com.sun.star.sdb.~ResultSet |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the Dialog has the given property. |
++|[[Requery]] ||~|True if data reloaded in ~SubForm |
++|[[setProperty]] | property<br />value |~|Return True if the given property could be set. |
++!!!Remarks
++Each //~SubForm// [[object|Object Model]] has a Controls [[collection|Collection]], which contains all controls on the subform. You can refer to a specific control on a subform by referring to the [[Controls]] collection. 
++!!!Example
++<<tiddler "Subform example">>
++
++
++
The types of control can be recognized thru the use either of the //~SubType// or the [[ControlType]] properties. The ~SubType property has no correspondent within ~MSAccess but has the advantage to identify all control types.
++See the correspondence table below.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl |!Description |
++|[[Control]] | All | All |A control on an open form |
++!!!Syntax
++//control//{{{.SubType}}}
++!!!Returned values
++{{{String}}}
++
++Table of values:
++<<tiddler "ControlTypesList">>
++!!!Remarks
++The ~SubType property is read-only.
++!!!Error messages
++!!!See also
++[[ControlType]]
++!!!Example
++<<tiddler "ControlType example">>
++
++
++
List all the controls of a subform
++//{{{
++Dim ocSubform As Object, osfSubform As Object, i As Integer, iCount As Integer
++	Set ocSubform = Controls("FACTURE", "subform")
++	Set osfSubform = ocSubform.Form
++	iCount = osfSubform.Controls().Count
++	For i = 0 To iCount - 1
++		Print osfSubform.Controls(i).Name,
++	Next i
++	Print
++//}}}
++
++
++
*Suppliers table
++| !Fields | !Field Type | !Primary |
++|Address | Text ||
++|City | Text ||
++|~ComanyName | Text ||
++|~ContactName | Text ||
++|~ContactTitle | Text ||
++|Country | Text ||
++|Fax | Text ||
++|~HomePage | Text ||
++|Phone | Text ||
++|~PostalCode | Text ||
++|Region | Text ||
++|~SupplierID | ~BigInt | Y |
++
++
++
(Q) How can I limit the contents of one combo/list box based on what's selected in another combo/list box ?
++
++(R) An easy way to do this would be to assign a dynamic SQL statement to the [[RowSource]] property of the secondary combo/list box at runtime.
++
++Our goal in the example is to select in a 1st combo box a CITY, in the 2nd combo the LASTNAME of the employees (working in CITY) to filter finally only the //Orders// placed by the concerned //Employee//.
++Considering
++<<tiddler "EmployeesTable">>
++
++*Initialize the //List content// entry of the 1st combo box with:
++//{{{
++		SELECT DISTINCT "City" FROM "Employees"
++//}}}
++*Assign next Sub to the //Text modified// event of the 1st combo box:
++//{{{
++Sub Update2ndCombo(poEvent As Object)
++
++Dim ocCombo1 As Object, ocCombo2 As Object, sSQL As String
++	Set ocCombo1 = Events(poEvent).Source
++	Set ocCombo2 = ocCombo1.Parent.Controls("EmployeeName")
++	sSQL = "SELECT DISTINCT [LastName] FROM [Employees] WHERE [Employees].[City]='" & ocCombo1.Value & "'"
++	ocCombo2.RowSourceType = com.sun.star.form.ListSourceType.SQL
++	ocCombo2.RowSource = sSQL
++	
++End Sub
++//}}}
++*Initilialize the //List content// entry of the 2nd combo box with:
++//{{{
++		SELECT DISTINCT "LastName" FROM "Employees"
++//}}}
++*Assign next Sub to the //Text modified// event of the 2nd combo box:
++//{{{
++Sub UpdateMainForm(poEvent As Object)
++
++Dim ofForm As Object, ocCombo As Object, sSQL As String, lEmpID As Integer
++	Set ocCombo = Events(poEvent).Source
++	Set ofForm = ocCombo.Parent
++	lEmpID = DLookup("[EmployeeID]", "[Employees]", "[LastName]='" & ocCombo.Value & "'")
++	ofForm.Filter = "[EmployeeID]=" & lEmpID
++	ofForm.FilterOn = True
++	
++End Sub
++//}}}
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~ComboBox |~Orders_2Combos ||~EmployeeCity |Text modified ||
++|~|~|~|~EmployeeName |~|~|
++
++
++
The //~SysCmd// method displays a progress meter or optional specified text in the status bar. By calling the //~SysCmd// method with the various progress meter actions, you can display a progress meter in the status bar for an operation that has a known duration or number of steps, and update it to indicate the progress of the operation.
++<<tiddler "ApplyDoCmd">>
++!!!Syntax
++{{{[DoCmd.]SysCmd(}}}//{{{Action, Text, Value}}}//{{{)}}}
++| !Argument | !Optional | !Type<br />or<br />Symbol |!Description |
++|{{{Action}}} | No | acSysCmdAccessVer |Returns "~LibreOffice x.y.z" or "~OpenOffice x.y.z" where x.y.z is the version number.<br />Use [[Application.Version|Application]] instead. |
++|~|~| acSysCmdSetStatus |Sets the status bar text to the //text// argument. |
++|~|~| acSysCmdClearStatus |Resets the status bar to its usual content. |
++|~|~| acSysCmdInitMeter |Initializes the progress meter. You must specify the //Text// and //Value// arguments when you use this action. |
++|~|~| acSysCmdUpdateMeter |Updates the progress meter with the specified value. You must specify the text argument when you use this action. |
++|~|~| acSysCmdRemoveMeter |Removes the progress meter. |
++|~|~| acSysCmdRuntime |Returns //True// (–1) if a run-time version of //~LibO/AOO// is running.<br />Always returns //False//. |
++|~|~| acSysCmdAccessDir<br /> acSysCmdClearHelpTopic<br />acSysCmdGetObjectState<br />acSysCmdGetWorkgroupFile<br />acSysCmdIniFile<br />acSysCmdProfile |Returns //True// without doing anything. |
++|{{{Text}}} | Yes | String |A string expression identifying the text to be displayed left-aligned in the status bar. This argument is required when the //action// argument is ''acSysCmdInitMeter'', ''acSysCmdUpdateMeter'', or ''acSysCmdSetStatus''.<br />This argument isn't valid for other action argument values. |
++|{{{Value}}} | Yes | Integer<br />Long |A numeric expression that controls the display of the progress meter. This argument is required when the //action// argument is ''acSysCmdInitMeter''.<br />This argument isn't valid for other action argument values. |
++The symbolic constants can be included in your code by copying and pasting next lines:
++//{{{
++Const acSysCmdAccessVer = 7
++Const acSysCmdClearStatus = 5
++Const acSysCmdInitMeter = 1
++Const acSysCmdRemoveMeter = 3
++Const acSysCmdSetStatus = 4
++Const acSysCmdUpdateMeter = 2
++Const acSysCmdRuntime = 6
++
++Const acSysCmdAccessDir = 9
++Const acSysCmdClearHelpTopic = 11
++Const acSysCmdGetObjectState = 10
++Const acSysCmdGetWorkgroupFile = 13
++Const acSysCmdIniFile = 8
++Const acSysCmdProfile = 12
++//}}}
++!!!Remarks
++*In //~MSAccess// the //~SysCmd// method is linked to the [[Application]] object.
++*The //~SysCmd// method will be often preceeded with a [[SelectObject]] action.
++*Only status bars of //forms// and //reports// can be managed with the //~SysCmd// method. When another window is active the method is ignored.
++*To display a progress meter in the status bar, you must first call the //~SysCmd// method with the ''acSysCmdInitMeter'' action argument, and the text and value arguments. When the action argument is ''acSysCmdInitMeter'', the value argument is the maximum value of the meter, or 100 percent.<br />To update the meter to show the progress of the operation, call the //~SysCmd// method with the ''acSysCmdUpdateMeter'' action argument and the text and value arguments. When the action argument is ''acSysCmdUpdateMeter'', the //~SysCmd// method uses the value argument to calculate the percentage displayed by the meter. For example, if you set the maximum value to 200 and then update the meter with a value of 100, the progress meter will be half-filled.
++*When a progress meter has been initiated with a ''acSysCmdInitMeter'' action argument, all subsequent calls to //~SysCmd// to feed the meter will be applied on the status bar of the same window even if other windows become active in the mean time.
++*You can also change the text that's displayed in the status bar of the currently active window by calling the //~SysCmd// method with the ''acSysCmdSetStatus'' action argument and the text argument.<br />If the progress meter is already displayed when you set the text by calling the //~SysCmd// method with the ''acSysCmdSetStatus'' action argument, the //~SysCmd// method automatically removes the meter, __even if the progress meter is on another - non active - window__.
++!!!Error messages
++|Arguments are missing or are not initialized |
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[SelectObject]]
++!!!Example
++<<tiddler "SysCmd example">>
++
++
++
To have a help text displayed in the status bar when a field receives the focus, link next code with the //When receiving focus// event of the concerned field:
++//{{{
++Sub DisplayHelp(poEvent As Object)
++'	Display help text in status bar when focus set on control
++
++Dim oEvent As Object, ocControl As Object, sHelp As String
++	On Error Resume Next		'	Never display an error message in a "When receiving focus" event or you might have to kill AOO/LibO !!
++	Set oEvent = Application.Events(poEvent)
++	Set ocControl = oEvent.Source
++	sHelp = ocControl.ControlTipText
++	If Len(sHelp) > 0 Then Application.SysCmd(acSysCmdSetStatus, sHelp)
++	
++End Sub
++//}}}
++
++
++
The //~TabIndex// property specifies a control's place in the tab order on a form or dialog.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~FixedText<br />~GroupBox<br />~HiddenControl<br />[[SubForm]]-- | None | All |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.TabIndex}}}
++//control//{{{.TabIndex}}} = //value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++The default {{{-1}}} is used to indicate that the tab-order of this control should be determined automatically.
++!!!Error messages
++|Property '~TabIndex' not applicable in this context |
++|Value '...' is invalid for property '~TabIndex' |
++!!!See also
++[[TabStop]]
++!!!Example
++<<tiddler "TabIndex example">>
++
++
++
List all controls in ~TabIndex ascending sequence. Only initialized ~TabIndexes are included.
++//{{{
++Dim ofForm As Object, ocControl As Object, i As Integer, iCount As Integer
++Dim sNames() As String
++	Set ofForm = Forms("myForm")
++	iCount = ofForm.Controls().Count
++	ReDim sNames(0 To iCount - 1)
++	For i = 0 To iCount - 1
++		Set ocControl = ofForm.Controls(i)
++		If ocControl.hasProperty("TABINDEX") Then
++			If ocControl.TabIndex > 0 And ocControl.TabIndex < iCount Then sNames(ocControl.TabIndex) = ocControl.Name
++		End If
++	Next i
++	For i = 0 To iCount - 1
++		If sNames(i) <> "" Then Print sNames(i),
++	Next i
++	Print
++//}}}
++Reset Tab sequence to automatic
++//{{{
++	For i = 0 To iCount - 1
++		If sNames(i) <> "" Then
++			Set ocControl = ofForm.Controls(sNames(i))
++			ocControl.TabIndex = -1
++		End If
++	Next i
++//}}}
++
++
++
The //~TabStop// property specifies if the focus can be set on a control by using .the TAB key.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~FixedText<br />~GroupBox<br />~HiddenControl<br />[[SubForm]]-- | None | All except --~FixedLine<br />~GroupBox<br />~ProgressBar-- |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.TabStop}}}
++//control//{{{.TabStop}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++!!!Error messages
++|Property '~TabStop' not applicable in this context |
++|Value '...' is invalid for property '~TabStop' |
++!!!See also
++[[TabIndex]]
++!!!Example
++<<tiddler "TabStop example">>
++
++
++
List all controls having ~TabStop = True
++//{{{
++Dim ofForm As Object, ocControl As Object, i As Integer
++	Set ofForm = Forms("myForm")
++	For i = 0 To ofForm.Controls().Count - 1
++		Set ocControl = ofForm.Controls(i)
++		If ocControl.hasProperty("TABSTOP") Then
++			If ocControl.TabStop Then Print ocControl.Name,
++		End If
++	Next i
++	Print
++//}}}
++Forbid access to myControl via Tab key
++//{{{
++	Set ocControl = ofForm.Controls("myControl")
++	ocControl.TabStop = False
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;A@@
++ }}}//~TableDef// [[object|Object Model]] describes one of the Tables located in the database document (".odb" file).
++!!!Function returning a //~TableDef// object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Database]] |[[TableDefs]] | [[Collection]] | Integer or String |{{{Application.CurrentDb().TableDefs("myTable")}}} returns an object corresponding with the {{{myTable}}} table |
++!!!Properties
++| !Property | !Type | !Read only | !Description or UNO object |
++|[[Name]] || Y |Specifies the exact name of the table |
++|[[ObjectType]] || Y |Returns "TABLEDEF" |
++|Table | UNO | Y |com.sun.star.sdb.dbaccess.~ODBTable |
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[Fields]] | None<br />Index<br />Name | [[Collection]] |Return the collection of the fields belonging to the table. |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the //~TableDef// has the given property. |
++|[[OpenRecordset]] | options | [[Recordset]] |Return a recordset object allowing access to the table data. |
++!!!Remarks
++A table //name// might consist in up to 3 components separated by a dot (".") character :
++*A //catalog// name
++*A //schema// name
++*A //table// name
++The first two components are optional:
++//{{{
++[[catalogname.]schemaname.]tablename
++//}}}
++The presence of one or two optional components is determined by the Relational ~DataBase Management System (RDBMS) in usage.
++HSQLDB will not require more than the //tablename//. ~MySQL will require at least the //schemaname//.
++Scrolling thru the [[TableDefs]] collection - see the example below - can help identifying the required naming scheme.
++!!!See also
++[[QueryDef]]
++!!!Examples
++<<tiddler "Datadef example">>
++
++
++
The //~TableDefs// collection describes instances of all __tables__ present in the related database.
++!!!Syntax
++{{{database.TableDefs()}}}
++{{{database.TableDefs(index)}}}
++{{{database.TableDefs(tablename)}}}
++| !Object | !Type | !Argument | !Type |!Returned value |
++|database |[[Database object|Database]] | absent ||A [[Collection]] object |
++|~|~| index | integer<br>long |A [[TableDef]] object corresponding to the index-th item in the ~TableDefs() collection. The 1st table is ~TableDefs(0), the 2nd is ~TableDefs(1) and so on ... The last one is ~TableDefs.Count - 1.|
++|~|~| tablename | string |A [[TableDef]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Methods
++| !Method | !Description |
++|[[Add]] |Finalize the creation of a new //~TableDef// initiated with [[CreateTableDef]]. |
++|[[Delete|Delete (table-query)]]|Delete an existing //~TableDef//. |
++!!!Remarks
++The //tablename// argument is not case sensitive.
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range or incorrect array size for collection ~TableDefs() |
++|Table '...' not found |
++!!!See also ...
++[[CreateTableDef]]
++[[QueryDefs]]
++[[Recordsets]]
++!!!Example
++<<tiddler "Datadef example">>
++
++
++
++
The //Tag// property stores extra information about a [[Control]].
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |All except<br />--~SubForm<br />-- | All | All |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.Tag}}}
++//control//{{{.Tag}}} = //value//
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++You can use this property to assign an identification string to a control without affecting any of its other property settings or causing other side effects. The //Tag// property is useful when you need to check the identity of a control that is passed as a variable to a procedure.
++!!!Error messages
++|Value '...' is invalid for property 'Tag' |
++!!!See also
++[[OpenArgs]]
++!!!Example
++<<tiddler "Tag example">>
++
++
++
Associate a tag value to a control
++//{{{
++Dim ofForm As Object, ocControl As Object, sTag As String
++	sTag = "This is an informative message"
++	Set ofForm = Forms("myForm")
++	Set ocControl = ofForm.Controls("myControl")
++	ocControl.Tag = sTag
++//}}}
++Usage: f.i. displaying the tag content in a info textbox when the control receives the focus
++
++
++
++
/***
++|''Name:''|TagsTreePlugin|
++|''Description:''|Displays tags hierachy as a tree of tagged tiddlers.<br>Can be used to create dynamic outline navigation.|
++|''Version:''|1.0.1|
++|''Date:''|Jan 04,2008|
++|''Source:''|http://visualtw.ouvaton.org/VisualTW.html|
++|''Author:''|Pascal Collin|
++|''License:''|[[BSD open source license|License]]|
++|''~CoreVersion:''|2.1.0|
++|''Browser:''|Firefox 2.0; InternetExplorer 6.0|
++!Demo
++On the plugin [[homepage|http://visualtw.ouvaton.org/VisualTW.html]] :
++*Try to tag some <<newTiddler>> with a tag displayed in the menu and edit MainMenu.
++*Look at some tags like [[Plugins]] or [[menu]].
++!Installation
++#import the plugin,
++#save and reload,
++#optionally, edit TagsTreeStyleSheet.
++! Usage
++{{{<<tagsTree>>}}} macro accepts the following //optional// parameters.
++|!#|!parameter|!description|!by default|
++|1|{{{root}}}|Uses {{{root}}} tag as tree root|- In a //tiddler// content or template : uses the tiddler as root tag.<br>- In the //page// content or template (by ex MainMenu) : displays all untagged tags.|
++|2|{{{excludeTag}}}|Excludes all such tagged tiddlers from the tree|Uses default excludeLists tag|
++|3|{{{level}}}|Expands nodes until level {{{level}}}.<br>Value {{{0}}} hides expand/collapse buttons.|Nodes are collapsed on first level|
++|4|{{{depth}}}|Hierachy depth|6 levels depth (H1 to H6 header styles)|
++|5|{{{sortField}}}|Alternate sort field. By example : "index".|Sorts tags and tiddlers alphabetically (on their title)|
++|6|{{{labelField}}}|Alertnate label field. By example : "label".|Displays tiddler's title|
++
++!Useful addons
++*[[FieldsEditorPlugin]] : //create//, //edit//, //view// and //delete// commands in toolbar <<toolbar fields>>.
++*[[TaggerPlugin]] : Provides a drop down listing current tiddler tags, and allowing toggling of tags.
++!Advanced Users
++You can change the global defaults for TagsTreePlugin, like default {{{level}}} value or level styles, by editing or overriding the first config.macros.tagsTree attributes below.
++!Code
++***/
++//{{{
++config.macros.tagsTree = {
++	expand : "+",
++	collapse : "–",
++	depth : 6,
++	level : 1,
++	sortField : "",	
++	labelField : "",
++	styles : ["h1","h2","h3","h4","h5","h6"],
++	trees : {}
++}
++
++config.macros.tagsTree.handler = function(place,macroName,params,wikifier,paramString,tiddler)
++{
++	var root = params[0] ? params[0] : (tiddler ? tiddler.title : null);
++	var excludeTag = params[1] ? params[1] : "excludeTagsTree";
++	var level = params[2] ? params[2] : config.macros.tagsTree.level;
++	var depth = params[3] ? params[3] : config.macros.tagsTree.depth;
++	var sortField = params[4] ? params[4] : config.macros.tagsTree.sortField;
++	var labelField = params[5] ? params[5] : config.macros.tagsTree.labelField;
++	var showButtons = (level>0);
++	var id = config.macros.tagsTree.getId(place);
++	if (config.macros.tagsTree.trees[id]==undefined) config.macros.tagsTree.trees[id]={};
++	config.macros.tagsTree.createSubTree(place,id,root,excludeTag,[],level>0 ? level : 1,depth, sortField, labelField,showButtons);
++}
++
++config.macros.tagsTree.createSubTree = function(place, id, root, excludeTag, ancestors, level, depth, sortField, labelField,showButtons){
++	var childNodes = root ? this.getChildNodes(root, ancestors) : this.getRootTags(excludeTag);
++	var isOpen = (level>0) || (!showButtons);
++	if (root && this.trees[id][root]!=undefined) isOpen = this.trees[id][root]; 
++	if (root && ancestors.length) {
++		var t = store.getTiddler(root);
++		if (childNodes.length && depth>0) {
++			var wrapper = createTiddlyElement(place , this.styles[Math.min(Math.max(ancestors.length,1),6)-1],null,"branch");
++			if (showButtons) {
++				b = createTiddlyButton(wrapper, isOpen ? config.macros.tagsTree.collapse : config.macros.tagsTree.expand, null, config.macros.tagsTree.onClick);
++				b.setAttribute("treeId",id);
++				b.setAttribute("tiddler",root);					
++			}
++			createTiddlyText(createTiddlyLink(wrapper, root),t&&labelField ? t.fields[labelField] ? t.fields[labelField] : root : root);
++		}
++		else 
++			createTiddlyText(createTiddlyLink(place, root,false,"leaf"),t&&labelField ? t.fields[labelField] ? t.fields[labelField] : root : root);
++	}
++	if (childNodes.length && depth) {
++		var d = createTiddlyElement(place,"div",null,"subtree");
++		d.style.display= isOpen ? "block" : "none";
++		if (sortField)
++			childNodes.sort(function(a, b){
++				var fa=a.fields[sortField];
++				var fb=b.fields[sortField];
++				return (fa==undefined && fb==undefined) ? a.title < b.title ? -1 : a.title > b.title ? 1 : 0 : (fa==undefined && fb!=undefined) ? 1 :(fa!=undefined && fb==undefined) ? -1 : fa < fb ? -1 : fa > fb ? 1 : 0;
++			})
++		for (var cpt=0; cpt<childNodes.length; cpt++)
++			this.createSubTree(d, id, childNodes[cpt].title, excludeTag, ancestors.concat(root), level-1, depth-1, sortField, labelField, showButtons);	
++	}	
++}
++
++config.macros.tagsTree.onClick = function(e){
++	var id = this.getAttribute("treeId");
++	var tiddler = this.getAttribute("tiddler");	
++	var n = this.parentNode.nextSibling;
++	var isOpen = n.style.display != "none";
++	if(config.options.chkAnimate && anim && typeof Slider == "function")
++		anim.startAnimating(new Slider(n,!isOpen,null,"none"));
++	else
++		n.style.display = isOpen ? "none" : "block";
++	this.firstChild.nodeValue = isOpen ? config.macros.tagsTree.expand : config.macros.tagsTree.collapse;
++	config.macros.tagsTree.trees[id][tiddler]=!isOpen;
++	return false;
++}
++
++config.macros.tagsTree.getChildNodes = function(root ,ancestors){
++	var childs = store.getTaggedTiddlers(root);
++	var result = new Array();
++	for (var cpt=0; cpt<childs.length; cpt++)
++		if (childs[cpt].title!=root && ancestors.indexOf(childs[cpt].title)==-1) result.push(childs[cpt]);
++	return result;
++}
++
++config.macros.tagsTree.getRootTags = function(excludeTag){
++	var tags = store.getTags(excludeTag);
++	tags.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
++	var result = new Array();
++	for (var cpt=0; cpt<tags.length; cpt++) {
++		var t = store.getTiddler(tags[cpt][0]);
++		if (!t || t.tags.length==0) result.push(t ? t : {title:tags[cpt][0],fields:{}});
++	}
++	return result;
++}
++
++config.macros.tagsTree.getId = function(element){
++	while (!element.id && element.parentNode) element=element.parentNode;
++	return element.id ? element.id : "<html>";
++}
++
++config.shadowTiddlers.TagsTreeStyleSheet = "/*{{{*/\n";
++config.shadowTiddlers.TagsTreeStyleSheet +=".leaf, .subtree {display:block; margin-left : 0.5em}\n";
++config.shadowTiddlers.TagsTreeStyleSheet +=".subtree {margin-bottom:0.5em}\n";
++config.shadowTiddlers.TagsTreeStyleSheet +="#mainMenu {text-align:left}\n";
++config.shadowTiddlers.TagsTreeStyleSheet +=".branch .button {border:1px solid #DDD; color:#AAA;font-size:9px;padding:0 2px;margin-right:0.3em;vertical-align:middle;text-align:center;}\n";
++config.shadowTiddlers.TagsTreeStyleSheet +="/*}}}*/";
++
++store.addNotification("TagsTreeStyleSheet", refreshStyles); 
++
++config.shadowTiddlers.MainMenu="<<tagsTree>>"
++
++config.shadowTiddlers.PageTemplate = config.shadowTiddlers.PageTemplate.replace(/id='mainMenu' refresh='content' /,"id='mainMenu' refresh='content' force='true' ")
++
++//}}}
++
++
++
/*{{{*/
++.leaf, .subtree {
++ display:block;
++ margin-left : 0.5em
++}
++.subtree {
++ margin-bottom:0.5em
++}
++
++#mainMenu {
++ text-align:left
++}
++.branch {
++ border:1px solid #DDD;
++ color:#AAA;
++ font-size:12px;
++ padding:0 2px;
++ margin-right:0.3em;
++ vertical-align:middle;
++ text-align:left;
++}
++.button {
++ border:1px solid #DDD;
++ font-size:12px;
++ padding:0 2px;
++ margin-right:0.7em;
++ vertical-align:
++ middle;
++ text-align:center;
++}
++/*}}}*/
++
++
++
The //~TempVar// [[object|Object Model]] represents a persistent variable that can be used from any Basic macro as soon as the //~Access2Base// library has been loaded.
++Each //~TempVar// is created the first time with the [[Add]] method applied on the [[TempVars]] collection. It can be removed at any time with the [[Remove]] or [[RemoveAll]] methods. Their scope is the whole //~LibO/AOO// session. They are very similar to Basic {{{Global}}} variables, except that they can be enumerated thru the TempVars collection and that their names can be managed as usual strings instead of being hardcoded.
++!!!Functions returning a //~TempVar// object
++| !Parent object | !Function | !Type | !Argument |!Description |
++|[[Application]] |[[TempVars]] | [[Collection]] | Integer or String |{{{Application.TempVars("myVar")}}} returns an object corresponding with the {{{myVar}}} temporary variable. |
++||[[getObject]] || String |{{{getObject("TempVars!myVar")}}} returns an object corresponding with the {{{myVar}}} variable. |
++!!!Properties of the returned object
++| !Property | !Type | !Description |
++|[[Name]] | String |Returns the real name of the variable, i.e. the name used at its creation. |
++|[[ObjectType]] | String |Returns "TEMPVAR" |
++|[[Value]] | Variant |The value of the considered variable (might be any value that can be stored in a {{{Variant}}} including arrays or objects). |
++!!!Syntax
++//tempvar//{{{.Name}}}
++//tempvar//{{{.Value}}}
++//tempvar//{{{.Value = }}}//expression//
++!!!Methods
++| !Method | !Argument(s) | !Return | !Description |
++|[[getProperty]] | property | Variant |Return the value of the given property. |
++|[[hasProperty]] | property | Boolean |Return True if the ~TempVar object has the given property. |
++!!!Remarks
++!!!See also
++[[TempVars]]
++[[hasProperty]]
++[[getProperty]]
++[[setProperty]]
++!!!Example
++<<tiddler "Tempvar example">>
++
++
++
The //~TempVars// collection represents the collection of [[TempVar]] objects..
++<<tiddler "ApplyApplication">>
++!!!Syntax
++{{{[Application.]TempVars()}}}
++{{{[Application.]TempVars(index)}}}
++{{{[Application.]TempVars(tempvarname)}}}
++| !Argument #1 | !Type |!Returned value |
++|| absent |A [[Collection]] object |
++| index | integer<br>long |A [[TempVar]] object corresponding to the index-th item in the ~TempVars() collection. The 1st temporary var is ~TempVars(0), the 2nd is ~TempVars(1) and so on ... The last one is ~TempVars.Count - 1.|
++| tempvarname | string |A [[TempVar]] object having the argument as name. The argument is NOT case-sensitive.|
++!!!Methods
++| !Method | !Description |
++|[[Add]] |Use the //Add// method to create a //~TempVar// object. |
++|[[Remove]] |Use the //Remove// method to delete a //~TempVar// object from the //~TempVars// collection. |
++|[[RemoveAll]] |Use the //~RemoveAll// method to delete all //~TempVar// objects from the //~TempVars// collection. |
++!!!Remarks
++*The //tempvarname// argument is not case sensitive.
++*A //~TempVar// object can be reached either from the //~TempVars// collection of by using the [[shortcut notation|ShortCut Notation]]
++//{{{
++getValue("TempVars!tempvarname")
++//}}}
++!!!Error messages
++|Argument nr. 1 [Value = '...'] is invalid |
++|Out of array range |
++|Temporary variable '...' not found |
++!!!See also ...
++[[Add]]
++[[getObject]]
++[[getValue]]
++[[Remove]]
++[[RemoveAll]]
++[[setValue]]
++[[TempVar]]
++!!!Examples
++<<tiddler "Tempvar example">>
++
++
++
++
Set, get and remove temporary variables, enumerate their values
++//{{{
++Dim oVars As Object, i As Integer
++	Set oVars = TempVars()
++	oVars.RemoveAll()				'	Empty the collection
++	oVars.Add("First",12345)
++	oVars.Add("Second","anything")
++	oVars.Add("Third","else")
++	oVars.Remove("SECOND")
++	oVars.Item("ThiRD").Value = "other value"
++	oVars.Add("Fourth","somethinG")
++	Print oVars.Count,
++	Print getValue("Tempvars!fourth"),
++	For i = 0 to oVars.Count - 1
++		Print oVars.Item(i).Value,
++	Next i
++//}}}
++
++
++
The //Terminate// method finalizes the specified [[dialog|Dialog]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Dialog]] |The representation of a Basic dialog |
++!!!Syntax
++//dialog//.{{{Terminate}}}
++| !Returned value |
++|//True// if success. |
++!!!Remarks
++The //Terminate// method makes the controls of the dialog unavailable to the programmer. The dialog must have been started with the [[Start]] method applied on the same dialog object.
++!!!Error messages
++|Dialog unknown |
++|Dialog '...' not active |
++!!!See also
++[[AllDialogs]]
++[[EndExecute]]
++[[Execute|Execute (dialog)]]
++[[Start]]
++!!!Example
++<<tiddler "Dialog example">>
++
++
++
The //Text// property specifies the text displayed in a Control. This property is __read-only__.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |[[ComboBox]]<br />~DateField<br />~FileControl<br />~FormattedField<br />~PatternField<br />~TextField<br />~TimeField |[[ComboBox]]<br />~DateField<br />~FormattedField<br />~PatternField<br />~TextField<br />~TimeField |[[ComboBox]]<br />~DateField<br />~FileControl<br />~FormattedField<br />~PatternField<br />~TextField<br />~TimeField |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.Text}}}
++!!!Returned values
++{{{String}}}
++!!!Remarks
++To set the text contained in a Control, use the [[Value]] or [[Caption]] properties.
++!!!Error messages
++|Property 'Text' not applicable in this context |
++!!!See also
++[[Caption]]
++[[Value]]
++!!!Example
++<<tiddler "Text example">>
++
++
++
Display the text as displayed in a DATEFIELD control (depends on the regional settings)
++//{{{
++Dim ofForm As Object, ocDate As Object, vValue As Variant, sText As String
++	Set ofForm = OpenForm("myForm")
++	ocDate = ofForm.Controls("myDateField")
++	sText = ocDate.Text
++	vValue = ocDate.Value
++	MsgBox sText & " - " & Day(vValue) & "/" & Month(vValue) & "/" & Year(vValue)
++//}}}
++
++
++
The //~TextAlign// property specifies the text alignment in a Control.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] |~CheckBox<br />[[ComboBox]]<br />~CommandButton<br />~CurrencyField<br />~DateField<br />~FixedText<br />~FormattedField<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />[[RadioButton]]<br />~TextField<br />~TimeField | All |~CheckBox<br />[[ComboBox]]<br />~CommandButton<br />~CurrencyField<br />~DateField<br />~FileControl<br />~FixedText<br />~FormattedField<br />[[ListBox]]<br />~NumericField<br />~PatternField<br />[[RadioButton]]<br />~TextField<br />~TimeField  |A control on an open form or dialog |
++!!!Syntax
++//control//{{{.TextAlign}}}
++//control//{{{.TextAlign = }}}//value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++The allowed values for ~TextAlign are:
++>0: Left
++>1: Center
++>2: Right
++!!!Error messages
++|Property '~TextAlign' not applicable in this context |
++|Value '...' is invalid for property '~TextAlign' |
++!!!See also
++[[FontBold]]
++[[FontItalic]]
++[[FontName]]
++[[FontSize]]
++[[FontUnderline]]
++[[FontWeight]]
++[[ForeColor]]
++!!!Example
++<<tiddler "Font example">>
++
++
++
Next people have directly or indirectly contributed to the birth and the success of the ~Access2Base API:
++*''Bernard Marcelly'' because I would have abandoned the project without the existence of ~XRayTool, the inspector of API objects, See [[here|http://bernard.marcelly.perso.sfr.fr/index2.html]].
++*''Jeremy Ruston'' who developed the remarkable personal wiki which served as template for the documentation of ~Access2Base. See [[TiddlyWiki, a reusable non-linear personal web notebook|http://www.tiddlywiki.com/]].
++*''Andrew Pitonyak'' I found a number of promising examples in [[Base Macro programming|http://www.pitonyak.org/database/AndrewBase.pdf]].
++*''Roberto Benitez'', his [[BaseTools|http://extensions.services.openoffice.org/en/project/BaseTools]] extension was a first step in the direction of the implementation of an ~MSAccess-like API. A few snippets in my code are inspired by his work.
++*''DACM'', after a few database corruptions I was very happy to implement his recommendations found on the ~OpenOffice forum (see a.o. [[Avoid data loss by avoiding "Embedded databases"|http://user.services.openoffice.org/en/forum/viewtopic.php?p=162653#p162653]]) !!
++*''Lionel Mamane'', who is my mentor and my sponsor inside the //~LibreOffice// developers community.
++*''Iñigo Zuluaga'', who provides the spanish translation of what in the source code requires such a translation.
++*''Gisbert Friege'', who provides the german translation since version 1.9.0.
++
++Many thanks to all of them.
++
++
++
/***
++|''Name:''|TiddlersBarPlugin|
++|''Description:''|A bar to switch between tiddlers through tabs (like browser tabs bar).|
++|''Version:''|1.2.5|
++|''Date:''|Jan 18,2008|
++|''Source:''|http://visualtw.ouvaton.org/VisualTW.html|
++|''Author:''|Pascal Collin|
++|''License:''|[[BSD open source license|License]]|
++|''~CoreVersion:''|2.1.0|
++|''Browser:''|Firefox 2.0; InternetExplorer 6.0, others|
++!Demos
++On [[homepage|http://visualtw.ouvaton.org/VisualTW.html]], open several tiddlers to use the tabs bar.
++!Installation
++#import this tiddler from [[homepage|http://visualtw.ouvaton.org/VisualTW.html]] (tagged as systemConfig)
++#save and reload
++#''if you're using a custom [[PageTemplate]]'', add {{{<div id='tiddlersBar' refresh='none' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>}}} before {{{<div id='tiddlerDisplay'></div>}}}
++#optionally, adjust StyleSheetTiddlersBar
++!Tips
++*Doubleclick on the tiddlers bar (where there is no tab) create a new tiddler.
++*Tabs include a button to close {{{x}}} or save {{{!}}} their tiddler.
++*By default, click on the current tab close all others tiddlers.
++!Configuration options 
++<<option chkDisableTabsBar>> Disable the tabs bar (to print, by example).
++<<option chkHideTabsBarWhenSingleTab >> Automatically hide the tabs bar when only one tiddler is displayed. 
++<<option txtSelectedTiddlerTabButton>> ''selected'' tab command button.
++<<option txtPreviousTabKey>> previous tab access key.
++<<option txtNextTabKey>> next tab access key.
++!Code
++***/
++//{{{
++config.options.chkDisableTabsBar = config.options.chkDisableTabsBar ? config.options.chkDisableTabsBar : false;
++config.options.chkHideTabsBarWhenSingleTab  = config.options.chkHideTabsBarWhenSingleTab  ? config.options.chkHideTabsBarWhenSingleTab  : false;
++config.options.txtSelectedTiddlerTabButton = config.options.txtSelectedTiddlerTabButton ? config.options.txtSelectedTiddlerTabButton : "closeOthers";
++config.options.txtPreviousTabKey = config.options.txtPreviousTabKey ? config.options.txtPreviousTabKey : "";
++config.options.txtNextTabKey = config.options.txtNextTabKey ? config.options.txtNextTabKey : "";
++config.macros.tiddlersBar = {
++	tooltip : "see ",
++	tooltipClose : "click here to close this tab",
++	tooltipSave : "click here to save this tab",
++	promptRename : "Enter tiddler new name",
++	currentTiddler : "",
++	previousState : false,
++	previousKey : config.options.txtPreviousTabKey,
++	nextKey : config.options.txtNextTabKey,	
++	tabsAnimationSource : null, //use document.getElementById("tiddlerDisplay") if you need animation on tab switching.
++	handler: function(place,macroName,params) {
++		var previous = null;
++		if (config.macros.tiddlersBar.isShown())
++			story.forEachTiddler(function(title,e){
++				if (title==config.macros.tiddlersBar.currentTiddler){
++					var d = createTiddlyElement(null,"span",null,"tab tabSelected");
++					config.macros.tiddlersBar.createActiveTabButton(d,title);
++					if (previous && config.macros.tiddlersBar.previousKey) previous.setAttribute("accessKey",config.macros.tiddlersBar.nextKey);
++					previous = "active";
++				}
++				else {
++					var d = createTiddlyElement(place,"span",null,"tab tabUnselected");
++					var btn = createTiddlyButton(d,title,config.macros.tiddlersBar.tooltip + title,config.macros.tiddlersBar.onSelectTab);
++					btn.setAttribute("tiddler", title);
++					if (previous=="active" && config.macros.tiddlersBar.nextKey) btn.setAttribute("accessKey",config.macros.tiddlersBar.previousKey);
++					previous=btn;
++				}
++				var isDirty =story.isDirty(title);
++				var c = createTiddlyButton(d,isDirty ?"!":"x",isDirty?config.macros.tiddlersBar.tooltipSave:config.macros.tiddlersBar.tooltipClose, isDirty ? config.macros.tiddlersBar.onTabSave : config.macros.tiddlersBar.onTabClose,"tabButton");
++				c.setAttribute("tiddler", title);
++				if (place.childNodes) {
++					place.insertBefore(document.createTextNode(" "),place.firstChild); // to allow break line here when many tiddlers are open
++					place.insertBefore(d,place.firstChild); 
++				}
++				else place.appendChild(d);
++			})
++	}, 
++	refresh: function(place,params){
++		removeChildren(place);
++		config.macros.tiddlersBar.handler(place,"tiddlersBar",params);
++		if (config.macros.tiddlersBar.previousState!=config.macros.tiddlersBar.isShown()) {
++			story.refreshAllTiddlers();
++			if (config.macros.tiddlersBar.previousState) story.forEachTiddler(function(t,e){e.style.display="";});
++			config.macros.tiddlersBar.previousState = !config.macros.tiddlersBar.previousState;
++		}
++	},
++	isShown : function(){
++		if (config.options.chkDisableTabsBar) return false;
++		if (!config.options.chkHideTabsBarWhenSingleTab) return true;
++		var cpt=0;
++		story.forEachTiddler(function(){cpt++});
++		return (cpt>1);
++	},
++	selectNextTab : function(){  //used when the current tab is closed (to select another tab)
++		var previous="";
++		story.forEachTiddler(function(title){
++			if (!config.macros.tiddlersBar.currentTiddler) {
++				story.displayTiddler(null,title);
++				return;
++			}
++			if (title==config.macros.tiddlersBar.currentTiddler) {
++				if (previous) {
++					story.displayTiddler(null,previous);
++					return;
++				}
++				else config.macros.tiddlersBar.currentTiddler=""; 	// so next tab will be selected
++			}
++			else previous=title;
++			});		
++	},
++	onSelectTab : function(e){
++		var t = this.getAttribute("tiddler");
++		if (t) story.displayTiddler(null,t);
++		return false;
++	},
++	onTabClose : function(e){
++		var t = this.getAttribute("tiddler");
++		if (t) {
++			if(story.hasChanges(t) && !readOnly) {
++				if(!confirm(config.commands.cancelTiddler.warning.format([t])))
++				return false;
++			}
++			story.closeTiddler(t);
++		}
++		return false;
++	},
++	onTabSave : function(e) {
++		var t = this.getAttribute("tiddler");
++		if (!e) e=window.event;
++		if (t) config.commands.saveTiddler.handler(e,null,t);
++		return false;
++	},
++	onSelectedTabButtonClick : function(event,src,title) {
++		var t = this.getAttribute("tiddler");
++		if (!event) event=window.event;
++		if (t && config.options.txtSelectedTiddlerTabButton && config.commands[config.options.txtSelectedTiddlerTabButton])
++			config.commands[config.options.txtSelectedTiddlerTabButton].handler(event, src, t);
++		return false;
++	},
++	onTiddlersBarAction: function(event) {
++		var source = event.target ? event.target.id : event.srcElement.id; // FF uses target and IE uses srcElement;
++		if (source=="tiddlersBar") story.displayTiddler(null,'New Tiddler',DEFAULT_EDIT_TEMPLATE,false,null,null);
++	},
++	createActiveTabButton : function(place,title) {
++		if (config.options.txtSelectedTiddlerTabButton && config.commands[config.options.txtSelectedTiddlerTabButton]) {
++			var btn = createTiddlyButton(place, title, config.commands[config.options.txtSelectedTiddlerTabButton].tooltip ,config.macros.tiddlersBar.onSelectedTabButtonClick);
++			btn.setAttribute("tiddler", title);
++		}
++		else
++			createTiddlyText(place,title);
++	}
++}
++
++story.coreCloseTiddler = story.coreCloseTiddler? story.coreCloseTiddler : story.closeTiddler;
++story.coreDisplayTiddler = story.coreDisplayTiddler ? story.coreDisplayTiddler : story.displayTiddler;
++
++story.closeTiddler = function(title,animate,unused) {
++	if (title==config.macros.tiddlersBar.currentTiddler)
++		config.macros.tiddlersBar.selectNextTab();
++	story.coreCloseTiddler(title,false,unused); //disable animation to get it closed before calling tiddlersBar.refresh
++	var e=document.getElementById("tiddlersBar");
++	if (e) config.macros.tiddlersBar.refresh(e,null);
++}
++
++story.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle){
++	story.coreDisplayTiddler(config.macros.tiddlersBar.tabsAnimationSource,tiddler,template,animate,unused,customFields,toggle);
++	var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;  
++	if (config.macros.tiddlersBar.isShown()) {
++		story.forEachTiddler(function(t,e){
++			if (t!=title) e.style.display="none";
++			else e.style.display="";
++		})
++		config.macros.tiddlersBar.currentTiddler=title;
++	}
++	var e=document.getElementById("tiddlersBar");
++	if (e) config.macros.tiddlersBar.refresh(e,null);
++}
++
++var coreRefreshPageTemplate = coreRefreshPageTemplate ? coreRefreshPageTemplate : refreshPageTemplate;
++refreshPageTemplate = function(title) {
++	coreRefreshPageTemplate(title);
++	if (config.macros.tiddlersBar) config.macros.tiddlersBar.refresh(document.getElementById("tiddlersBar"));
++}
++
++ensureVisible=function (e) {return 0} //disable bottom scrolling (not useful now)
++
++config.shadowTiddlers.StyleSheetTiddlersBar = "/*{{{*/\n";
++config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar .button {border:0}\n";
++config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar .tab {white-space:nowrap}\n";
++config.shadowTiddlers.StyleSheetTiddlersBar += "#tiddlersBar {padding : 1em 0.5em 2px 0.5em}\n";
++config.shadowTiddlers.StyleSheetTiddlersBar += ".tabUnselected .tabButton, .tabSelected .tabButton {padding : 0 2px 0 2px; margin: 0 0 0 4px;}\n";
++config.shadowTiddlers.StyleSheetTiddlersBar += ".tiddler, .tabContents {border:1px [[ColorPalette::TertiaryPale]] solid;}\n";
++config.shadowTiddlers.StyleSheetTiddlersBar +="/*}}}*/";
++store.addNotification("StyleSheetTiddlersBar", refreshStyles);
++
++config.refreshers.none = function(){return true;}
++config.shadowTiddlers.PageTemplate=config.shadowTiddlers.PageTemplate.replace(/<div id='tiddlerDisplay'><\/div>/m,"<div id='tiddlersBar' refresh='none' ondblclick='config.macros.tiddlersBar.onTiddlersBarAction(event)'></div>\n<div id='tiddlerDisplay'></div>");
++
++//}}}
++
++
++
(Q) Some of the records in my database have values that are longer than the width of the bound control on the form.  Is there a way I can display the complete text without requiring the user to click in the field and using arrow keys to read the value ?
++
++(R) Form controls have a property called [[ControlTipText]] (what you see in the yellow tooltip popup if you place the mouse over a control for some time). This property can be easily used to display the complete value of the actual control itself. 
++!!!Solution
++Fire next code from the //After record change// event of a form:
++//{{{
++Sub setTipText(poEvent As Object)
++
++Dim ofForm As Object, ocControl As Object, i As Integer, sValue As String
++Const cstMin = 10
++Const cstMax = 200
++	Set ofForm = Events(poEvent).Source
++	For i = 0 To ofForm.Controls.Count - 1
++		Set ocControl = ofForm.Controls(i)
++		sValue = CStr(ocControl.Value)
++		If Len(sValue) > cstMin Then
++			If Len(sValue) > cstMax Then
++				ocControl.ControlTiptext = Left(sValue, cstMax)
++			Else
++				ocControl.ControlTiptext = sValue
++			End If
++		End If
++	Next i
++	
++End Sub
++//}}}
++You will have noted that the tip text is modified only if long enough and truncated if the value is too long.
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|~TipText |~Orders_Browse |After record change ||||
++
++
++
/***
++
++|Name|ToggleSideBarMacro|
++|Created by|SaqImtiaz|
++|Location|http://tw.lewcid.org/#ToggleSideBarMacro|
++|Version|1.0|
++|Requires|~TW2.x|
++!Description:
++Provides a button for toggling visibility of the SideBar. You can choose whether the SideBar should initially be hidden or displayed.
++
++!Demo
++<<toggleSideBar "Toggle Sidebar">>
++
++!Usage:
++{{{<<toggleSideBar>>}}} <<toggleSideBar>>
++additional options:
++{{{<<toggleSideBar label tooltip show/hide>>}}} where:
++label = custom label for the button,
++tooltip = custom tooltip for the button,
++show/hide = use one or the other, determines whether the sidebar is shown at first or not.
++(default is to show the sidebar)
++
++You can add it to your tiddler toolbar, your MainMenu, or where you like really.
++If you are using a horizontal MainMenu and want the button to be right aligned, put the following in your StyleSheet:
++{{{ .HideSideBarButton {float:right;} }}}
++
++!History
++*23-07-06: version 1.0: completely rewritten, now works with custom stylesheets too, and easier to customize start behaviour. 
++*20-07-06: version 0.11
++*27-04-06: version 0.1: working.
++
++!Code
++***/
++//{{{
++config.macros.toggleSideBar={};
++
++config.macros.toggleSideBar.settings={
++         styleHide :  "#sidebar { display: none;}\n"+"#contentWrapper #displayArea { margin-right: 1em;}\n"+"",
++         styleShow : " ",
++         arrow1: "«",
++         arrow2: "»"
++};
++
++config.macros.toggleSideBar.handler=function (place,macroName,params,wikifier,paramString,tiddler)
++{
++          var tooltip= params[1]||'toggle sidebar';
++          var mode = (params[2] && params[2]=="hide")? "hide":"show";
++          var arrow = (mode == "hide")? this.settings.arrow1:this.settings.arrow2;
++          var label= (params[0]&&params[0]!='.')?params[0]+" "+arrow:arrow;
++          var theBtn = createTiddlyButton(place,label,tooltip,this.onToggleSideBar,"button HideSideBarButton");
++          if (mode == "hide")
++             { 
++             (document.getElementById("sidebar")).setAttribute("toggle","hide");
++              setStylesheet(this.settings.styleHide,"ToggleSideBarStyles");
++             }
++};
++
++config.macros.toggleSideBar.onToggleSideBar = function(){
++          var sidebar = document.getElementById("sidebar");
++          var settings = config.macros.toggleSideBar.settings;
++          if (sidebar.getAttribute("toggle")=='hide')
++             {
++              setStylesheet(settings.styleShow,"ToggleSideBarStyles");
++              sidebar.setAttribute("toggle","show");
++              this.firstChild.data= (this.firstChild.data).replace(settings.arrow1,settings.arrow2);
++              }
++          else
++              {    
++               setStylesheet(settings.styleHide,"ToggleSideBarStyles");
++               sidebar.setAttribute("toggle","hide");
++               this.firstChild.data= (this.firstChild.data).replace(settings.arrow2,settings.arrow1);
++              }
++
++     return false;
++}
++
++setStylesheet(".HideSideBarButton .button {font-weight:bold; padding: 0 5px;}\n","ToggleSideBarButtonStyles");
++
++//}}}
++
++
++
|~ViewToolbar|closeTiddler closeOthers +editTiddler > permalink references|
++|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|
++
++
++
The //~TooltipText// property specifies the text that appears in a ~ScreenTip when you hold the mouse pointer over a toolbar control.
++!!!Applies to ...
++| !Object |!Description |
++|[[CommandBarControl]] |A control belonging to a CommandBar. |
++!!!Syntax
++//commandbarcontrol//{{{.TooltipText}}}
++//commanbarcontrol//{{{.TooltipText}}} = //value//{{{)}}}
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++!!!Error messages
++|Property '~TooltipText' not applicable in this context |
++|Value '...' is invalid for property '~TooltipText' |
++!!!See also
++[[CommandBar]]
++[[CommandBarControl]]
++!!!Example
++<<tiddler "CommandBarControl example">>
++
++
++
!!!Role
++Display a dialog box for error handling settings and registered errors viewing. This routine is typically called from a button or a menu item.
++
++[img[tracelog dialog.png]]
++!!!Syntax
++~TraceConsole has no arguments.
++{{{TraceConsole()}}}
++!!!User interface
++| !Control | !Description |
++|Clear the list |All the entries are erased from the list. |
++|Set minimal trace level |All the calls for logging an event (TraceLog) having a level below the indicated level are ignored. |
++|Set max number of entries |Determines the size of the circular buffer containing the logged events. When changed the existing list is always erased. |
++|Dump to file |Open a File Save As ... window to save all the current entries in APPEND mode to a text file. |
++!!!Remarks
++When //~Access2Base// has been installed as an extension the //~TraceConsole// function can be activated by executing, when in the Basic IDE, next menu command: 
++>{{{Tools + Add-Ons + Access2Base Console ...}}}.
++!!!See also
++[[DebugPrint]]
++[[Error Handler]]
++[[TraceError]]
++[[TraceLevel]]
++[[TraceLog]]
++
++
++
!!!Role
++Manages errors:
++- registers the error in the error logging circular buffer
++- informs the end-user
++- stops the program or continues
++!!!Syntax
++{{{TraceError(TraceLevel, ErrorCode, ErrorProcedure, ErrorLine)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++|~TraceLevel | String |The level of the occurred event. See [[error handling generalities|Error Handler]] for more details.<br />The call to ~TraceError is __ignored__ if the given level is lower than the current minimal trace level. |
++|~ErrorCode | Integer |The numeric code of the error. Normally the output of the AOO/~LibO Basic {{{Err}}} function. |
++|~ErrorProcedure | String |The name of the procedure where the error occurred. |
++|~ErrorLine | Integer |The line number where the error occurred. Normally the output of the AOO/~LibO Basic {{{Erl}}} function. |
++!!!See also
++[[DebugPrint]]
++[[Error Handler]]
++[[TraceConsole]]
++[[TraceLevel]]
++[[TraceLog]]
++!!!Example
++<<tiddler "TraceError example">>
++
++
++
Trap an error:
++//{{{
++Function ShowError()
++
++	On Local Error Goto Error_Function
++Dim i As Integer, j As Integer
++	i = 10
++	j = i / 0
++	REM ...
++
++Exit_Function:
++	Exit Function
++Error_Function:
++	TraceError("ERROR", Err, "ShowError", Erl)
++	Goto Exit_Function
++End Function	'	ShowError
++//}}}
++The execution of
++>{{{ShowError()}}}
++will result in the display of next message to the user:
++
++[img[traceerror msgbox.png]]
++
++
++
!!!Role
++Set the minimal level as from which an error should be logged in the circular buffer managed by the [[Access2Base error handler|Error Handler]].
++!!!Syntax
++{{{Call TraceLevel(newTraceLevel)}}}
++!!!Argument
++| !newTraceLevel | !Type |!Description |
++|"DEBUG" | String |To report values of variables during the program execution. The report is NOT user visible. |
++|"INFO" |~|To report any event |
++|"WARNING" |~|To report some abnormal event. |
++|"ERROR" |~|To report an error trapped by a user program. |
++|"FATAL" |~|To report an error detected by ~Access2Base (f.i. "Form does not exist ..." etc.). |
++|"ABORT" |~|To report an error inside the ~Access2Base API itself. Do not use for programmer or user errors. |
++!!!Remark
++When the argument is absent, or equal to space, the minimal error level is reset to its default, i.e. {{{"ERROR"}}}. If the provided argument is different from the above list, the program execution continues without interruption.
++!!!See also
++[[DebugPrint]]
++[[Error Handler]]
++[[TraceConsole]]
++[[TraceError]]
++[[TraceLog]]
++
++
++
!!!Role
++Registers in the Traces circular buffer a new entry.
++!!!Syntax
++{{{TraceLog(TraceLevel, Text, [MessageBox])}}}
++!!!Arguments
++| !Argument | !Type | !Default | !Description |
++|~TraceLevel | String ||The level of the occurred event. See [[error handling generalities|Error Handler]] for more details.<br />The call to //~TraceLog// is __ignored__ if the given level is lower than the current minimal trace level. |
++|Text | String ||Text to be recorded. |
++|~MessageBox | Boolean | True |Indicates if the Text must also be displayed to the user in a message box. |
++!!!See also
++[[DebugPrint]]
++[[Error Handler]]
++[[TraceConsole]]
++[[TraceError]]
++[[TraceLevel]]
++!!!Example
++<<tiddler "TraceLog example">>
++
++
++
~TraceLog some information
++//{{{
++	TraceLog("WARNING", "You should be more careful !!")
++//}}}
++Next message will be displayed to the user if the current minimal trace level is at least "WARNING".
++
++[img[tracelog msgbox.png]]
++
++
++
The //~TripleState// property specifies how a check box will display {{{Null}}} values.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Control]] | ~CheckBox | ~CheckBox | ~CheckBox |A control on an open form, dialog or ~GridControl. |
++!!!Syntax
++//control//{{{.TripleState}}}
++//control//{{{.TripleState}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++The ~TripleState property uses the following settings:
++|True |The control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null. |
++|False (Default) |The control will cycle through states for Yes and No values. Null values display as if they were No values. |
++!!!Error messages
++|Property '~TripleState' not applicable in this context |
++|Value '...' is invalid for property '~TripleState' |
++!!!Example
++<<tiddler "Triplestate example">>
++
++
++
Identify if a checkbox accept Null values
++//{{{
++Dim ofForm As Object,ocControl As Object
++	Set ofForm = Forms("myform")
++	Set ocControl = ofForm.Controls("myChkBox")
++	MsgBox ocControl.TripleState
++//}}}
++
++
++
Consider the list below as a set of examples you should browse thru depending on your needs, more than a tutorial to read from top to bottom.
++!!Optionally, download and install the examples
++(Almost) all examples below require a prior installation of the __last version__ of //~Access2Base// to run satisfactorily.
++
++Most examples have been implemented in a database that can be ''downloaded [[HERE|http://www.access2base.com/_howtos/TT NorthWind.zip]].''
++Note that the database has been designed to illustrate the individual examples not to be a fully functional application. The data has been converted from the well-known //~NorthWind// database for Microsoft Access.
++
++Additionally, everyone will understand that ...
++>The attached code is distributed in the hope that it will be useful,
++>but WITHOUT ANY WARRANTY; without even the implied warranty of
++>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
++#Download the file.
++#Unzip all the files in one single directory of your choice.
++#//Open// one of next 3 files, allow the execution of macros and explore the proposed forms and code. All forms, queries, Basic code in those files refer to one or more of next examples.
++##''"TT ~NorthWind.odb"'' Base file
++##''"TT ~NorthWind ~StandAlone.odt"'' Writer file
++##''"TT ~NorthWind Calc.ods"'' Calc file
++!!Easy How to's
++#[[Find out if a form is open|FindOutFormOpen]]
++#[[Enumerate all controls on a form|EnumerateControls]]
++#[[Find out if a table exists|FindOutTableExists]]
++#[[Use Variables and Controls in SQL|UseVariablesInSQL]]
++#[[Create a recordset from a table, a query or a form|CreateRecordsetFrom]]
++#[[Add a record to a recordset|AddRecordToRecordset]]
++#[[Count the number of records in a recordset|CountRecordsRecordset]]
++#[[Detect the limits of recordset|LimitsRecordset]]
++!!Generalities
++#[[Mix Access2Base and UNO objects in the same code|MixAccess2baseAndUNO]]
++#[[Manipulate the database window|DatabaseWindow]]
++#[[More about the shortcut notation|ShortcutNotationMore]]
++#[[DLookup usage samples|DLookupSamples]]
++!!About Forms
++#[[Simulate calculated fields|CalculatedField]]
++#[[Use a (Multi-select) listbox to select the data displayed in a form|MultiSelectListboxSelectForm]]
++#[[Fill Fields automatically on form based on a control's value|FillAutoControlValue]]
++#[[Carry current value of a control to new records|CarryToNewRecord]]
++#[[Browse recursively thru all controls of a form/subform|BrowseThruControls]]
++#[[Use ControlTipText to display textbox value|TipTextForLongValues]]
++#[[Ask before saving record|AskBeforeSaving]]
++#[[Limit content of combo/list boxes|Sync2Combos]]
++#[[Zoom on image|ZoomOnImage]]
++#[[Adding "All" to a list- or combobox|AddAllToBox]]
++#[[Keep several linked forms synchronized|KeepFormsSynchro]]
++#[[Simulate a Google search box|SelectListboxOnFirstLetters]]
++#[[Moving items between 2 listboxes with >, >>, < and << buttons|MoveItemsBetweenListboxes]]
++#[[Simulate a tabbed interface in a form|SimulateTabbed]]
++!!About standalone forms
++#[[Search a character string thru all the records|SearchStandalone]]
++!!About dialogs
++#[[Insert a calculator in the user interface|CalculatorDialog]]
++!!About tables, queries and recordsets
++#[[Explore tables and fields|ExploreTables]]
++#[[Extract data from a database table|ExtractDataTable]]
++#[[Find the position of the current record of a recordset|FindPositionRecordset]]
++#[[Design a generic DMedian function|DMedian function]]
++#[[Compute the value corresponding with a given percentile|DPercentile]]
++#[[Import images in the database|ImportImages]]
++#[[Export images from the database to the file system|ExportImages]]
++#[[CrossTab queries|CrossTabQuery]]
++#[[Access data dynamically from a Calc spreadsheet|DbaccessFromCalc]]
++#[[Output table or query to html - styling examples|OutputToStyling]]
++
++
++
The //Type// property specifies the type of a [[query|QueryDef]], a [[commandbarcontrol|CommandBarControl]] or a [[Basic module|Module].
++!!!Applies to ...
++| !Object |!Description |
++|[[QueryDef]] |A stored query definition. |
++|[[CommandBarControl]] |An element of a [[CommandBar]]. |
++|[[Module]] |A Basic script. |
++!!!Syntax and returned values
++| !Syntax |!Returned value |>|
++|//querydef//{{{.pType}}} |dbQAction |A query that copies or changes data. Action queries include append, delete, make-table, and update queries. Delete and update queries change existing data; append and make-table queries copy existing data. In contrast, select queries return data records. An SQL pass-through query may also be an action query. |
++|~|dbQAppend |An action query that adds new records to the end of an existing table or query. Append queries don't return records (rows). |
++|~|dbQDDL |An SQL query that can create, alter, or delete a table, or create or delete an index in a database. |
++|~|dbQDelete |An action query that deletes a set of rows that match the criteria you specify. A delete query doesn’t return rows. |
++|~|dbQMakeTable |An action query that creates a new table from the Recordset object of an existing query. |
++|~|dbQSelect |A query that asks a question about the data stored in your tables and returns a Recordset object without changing the data. |
++|~|dbQSetOperation |An select query that creates a Recordset object containing data from all specified records in two or more tables with any duplicate records removed. To include the duplicates, add the keyword ALL. <br />For instance, a union query of the Customers table and the Suppliers table results in a Recordset that contains all suppliers that are also customers. |
++|~|dbQSQLPassThrough |An SQL query you use to send commands directly to the database (server). Pass-through queries are used to execute SQL queries and system-specific commands written by using SQL dialects known only to the server.<br />A pass-through query may or may not return records. |
++|~|dbQUpdate |An action query that changes a set of records according to criteria you specify. An update query doesn’t return any records. |
++|//commandbarcontrol//{{{.pType}}} |msoControlButton |The only supported value describing a command button. |
++|//module//{{{.pType}}} |acClassModule |The specified module is a class module. |
++|~|acStandardModule |The specified module is a susal, standard module. |
++!!!Remarks
++*The //Type// property is read-only.
++*The values returned by the //Type// property applied to a query may be combined. In fact they are summed. For instance an update query is also an action query. The property will return in such case the value dbQAction + dbQUpdate.<br />To test a single value, use next construction:
++//{{{
++	If (querydef.pType And dbQAction) <> 0 Then ...		'	is an action query
++//}}}
++*You can incorporate next constant definitions in your own code if useful:
++//{{{
++Const dbQAction = 240
++Const dbQAppend = 64
++Const dbQDDL = 4
++Const dbQDelete = 32
++Const dbQMakeTable = 128
++Const dbQSelect = 0
++Const dbQSetOperation = 8
++Const dbQSQLPassThrough = 1
++Const dbQUpdate = 16
++
++Const msoControlButton = 1
++
++Const acClassModule = 1
++Const acStandardModule = 0
++//}}}
++!!!Example
++<<tiddler "Type example">>
++
++
++
List all queries with type and sql statement
++//{{{
++Dim i As Integer, odbDatabase As Object, oQuery As Object
++	Set odbDatabase = Application.CurrentDb()
++	With odbDatabase
++		For i = 0 To .QueryDefs().Count - 1
++			Set oQuery = .QueryDefs(i)
++			DebugPrint oQuery.Name, oQuery.pType, oQuery.SQL
++		Next i
++	End With
++//}}}
++
++
++
Saves the contents of the edit buffer to an updatable [[Recordset object|Recordset]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Recordset]] |A set of records derived from a table, a query or an SQL statement. |
++!!!Syntax
++//recordset//{{{.Update()}}}
++!!!Returned value
++{{{True}}} if success.
++!!!Remarks
++*To edit a record, use the [[Edit method|Edit]] to copy the contents of the current record to the edit buffer. If you don't use //Edit// first, an error occurs when you use //Update// or attempt to change a field's value.
++*To create a new record use the [[AddNew method|AddNew]].
++*''Caution'' Changes to the current record are lost if: 
++**You use the //Edit// or //~AddNew// method, and then move to another record without first using //Update//.
++**You use //Edit// or //~AddNew//, and then use //Edit// or //AddNew// again without first using Update.
++**You set the [[Bookmark property|Bookmark]] to another record.
++**You close the //Recordset// without first using //Update//.
++**You cancel the //Edit// or //~AddNew// operation by using [[CancelUpdate]]. 
++!!!Error Messages
++|Recordset or field is not updatable |
++|Current row has been deleted |
++|Recordset update sequence error |
++!!!See also
++[[AddNew]]
++[[CancelUpdate]]
++[[Close|Close (method)]]
++[[CloseAllRecordsets]]
++[[DefaultValue]]
++[[Edit]]
++[[Update]]
++[[Value|Value (field)]]
++!!!Example
++<<tiddler "AddNew example">>
++<<tiddler "Edit example">>
++
++
++
(Q) In code behind my form, I'm trying to reference the value contained in a control on my form in a SQL statement. But I'm not successful in doing this. I'm using the following syntax:
++--{{{sSQL = "SELECT * FROM Employees WHERE [LastName] = myControl.Value"}}}--
++What am I doing wrong??
++
++(R) In order to reference values contained in form controls, you have to use the & operator and concatenate the results. The positioning of quotes is also important.
++!!!Solution
++*In an SQL statement query-, table- and fieldnames are surrounded with a special character which is __depending on the used Relational Database Management System__. When used in character strings whose SQL nature is recognizable (in [[form filtering|Filter]], in a [[RunSQL]] action, a [[RecordSource]] or [[ControlSource]] property, ...), //~Access2Base// will substitute the square brackets ([ ... ]) with the correct character.<br />In next examples the resulting SQL statement is assumed to be used for such a purpose, reason why it still contains square brackets.
++*When the WHERE clause refers to a numeric field, it is sufficient to concatenate the SQL sentence and the value, like in:
++//{{{
++		sSQL = "SELECT * FROM Employees WHERE [Age] >= " & myNumericControl.Value
++//}}}
++*A bit more complicated is the reference to a date field. Simplest is to use the ISO representation of a date '''~YYYY-MM-DD''' (between single quotes):
++//{{{
++		Dim sDate As String
++		Const cstQuote = "'"		'	Single quote
++		sDate = Format(myDateControl.Value), "YYYY-MM-DD")
++		sSQL = "SELECT * FROM Employees WHERE [BirthDate] = " & cstQuote & sDate & cstQuote
++//}}}
++*Similarly if the database field is of Date/Time type, the time should be added in the SQL statement. However the "time" control in the form is separated from the "date" one.
++//{{{
++		Dim sDateTime As String
++		Const cstQuote = "'"		'	Single quote
++		sDateTime = Format(myDateControl.Value + myTimeControl.Value, "YYYY-MM-DD HH:MM:SS")
++		sSQL = "SELECT * FROM Employees WHERE [BirthDateTime] = " & cstQuote & sDateTime & cstQuote
++//}}}
++*Finally for simple strings, it seems easy. Just surround them with single quotes. However, if the string itself is able to contain a single quote, it is safer to anticipate its doubling:
++//{{{
++		Dim sName As String
++		Const cstQuote = "'"		'	Single quote
++		sName = Join(Split(myCharControl.Value, cstQuote), cstQuote & cstQuote)		'	Replace ' by ''
++		sSQL = "SELECT * FROM Employees WHERE [LastName] = " & cstQuote & sName & cstQuote
++//}}}
++
++
++
{{firstletter{
++ @@color:#930;T@@
++ }}}he reader is assumed to have already a reasonable knowledge of //~LibO/AOO Basic// and of the //~LibO/AOO Basic// IDE. The knowledge of the //~LibreOffice/~OpenOffice UNO API// is not required. A basic knowledge of the //~MSAccess// object model is an advantage.
++!DEFINITIONS
++!!!What are objects ?
++AOO/~LibO Basic is a rudimentary object-oriented language.
++To stay close to the syntax of the //~MSAccess// object model the implementation of ~Access2Base has nevertheless been based on BASIC object classes. Their main characteristics are :
++**Use of classes of types ''Form'', ''Subform'' or ''Control'', etc.
++**In BASIC code using these classes, variables should be declared as being of type {{{Object}}}.
++**''Property'' and ''method'' names are identical in //~MSAccess// and in //~Access2Base//. Note however that //~Access2Base// implements only a limited subset of the object model of //~MSAccess//. Note also that their semantics might differ from the original //~MSAccess// one. Read the current documentation carefully.
++**Support of indirection and introspection for properties.
++**2 ROOT objects: [[Application]] and [[DoCmd]].
++**The [[CurrentDb]] method returns a [[Database]] object. It might be (and most often is ...) the database related to the only opened Base document (".odb") or any of the databases related to one of the [[standalone forms|Standalone Forms]] stored in a non-Base (Writer, Calc, ...) document.
++!!!What are [[collections ?|Collection]]
++**Their [[Count]] and [[Item]] properties
++**Their [[Add]], [[Delete|Delete (table-query)]], [[Remove]] and [[RemoveAll]] methods
++>''Here is the complete [[Object Model]]''
++!FORMS, DIALOGS and CONTROLS
++!!Introduction
++*The [[AllForms]] collection - all forms
++*The [[Forms]] collection - all active forms
++*The [[AllDialogs]] collection - all available dialogs
++*The [[Form]] object - one single active form
++*The [[Dialog]] object - one single active dialog
++*The [[Controls]] collection - all controls of an active form or dialog
++*The [[Control]] object - one single control on an active form or dialog
++!!Properties
++*Form properties
++**[[Name]]
++**[[AllowAdditions]], [[AllowDeletions]], [[AllowEdits]] - is a form updatable ?
++**[[RecordSource]], [[Filter]], [[FilterOn]], [[OrderBy]], [[OrderByOn]] - which data are queried and in which sequence ?
++**[[Recordset|Recordset (property)]] - to query the same data programmatically
++**[[IsLoaded]] - is the form active ?
++**[[Caption]], [[Height]], [[Width]], [[Visible]] - how is the form formatted ?
++**[[Bookmark]], [[CurrentRecord]] - how to identify the current record and go back to it afterwards, how to identify the current record number ?
++**[[OpenArgs]]
++**[[On ... form events|On (form event)]] - which routine is triggered when an event occurs ?
++*Dialog properties
++**[[Name]]
++**[[IsLoaded]] - is the dialog active ?
++**[[Caption]], [[Height]], [[Width]], [[Visible]] - how is the dialog formatted ?
++*Control properties
++**[[Name]]
++**[[ControlType]], [[SubType]] - control typology ?
++**[[BackColor]], [[BorderColor]], [[BorderStyle]], [[ControlTipText]]<br />[[FontBold]], [[FontItalic]], [[FontName]], [[FontSize]], [[FontUnderline]], [[FontWeight]], [[ForeColor]]<br />[[Format]], [[TextAlign]], [[Visible]], [[TripleState]]<br />[[Cancel]], [[Caption]], [[Default]]<br />            - how is the control's look & feel ?
++**[[Page]] - define the set of controls of a dialog displayed page by page
++**[[Enabled]], [[Locked]], [[Required]] - is the control read-only ... ?
++**[[SelStart]], [[SelLength]] and [[SelText]] - what are the characters selected by the user, where is the insertion point in a textbox control ?
++**[[DefaultValue]], [[Tag]], [[Text]], [[Value]], [[Picture]] - what is the content of the control ?
++**[[TabIndex]], [[TabStop]] - what is the tab sequence of the control ?
++**[[ControlSource]] - which data is linked to the control ?
++**[[Parent]] - which object contains the control ?
++**[[On ... control events|On (control event)]] - which routine is triggered when an event occurs ?
++!!Methods
++*[[Move]] - move and resize a form or dialog
++*[[Refresh]], [[Requery]] - requery the underlying data of a form or a control
++*[[SetFocus]] - set the cursor somewhere
++*Manage dialogs with the [[Start]], [[Execute|Execute (dialog)]], [[EndExecute]] and [[Terminate]] methods
++!!Special controls
++!!!Subforms
++*What is a [[subform|SubForm]] ?
++*The [[form|Form (subform)]] property of a control
++*Subform properties
++**[[Name]]
++**[[AllowAdditions]], [[AllowDeletions]], [[AllowEdits]] - is a subform updatable ?
++**[[RecordSource]], [[Filter]], [[FilterOn]], [[OrderBy]], [[OrderByOn]] - which data are queried and in which sequence ?
++**[[Recordset|Recordset (property)]] - to query the same data programmatically
++**[[LinkChildFields]], [[LinkMasterFields]] - how is the subform related to its parent form ?
++**[[Parent]] - which (other sub)form contains the subform ?
++!!!Gridcontrols
++*Tabular display of data via a [[gridcontrol|GridControl]]
++*Use of the [[Controls]] collection to find the columns of a gridcontrol
++!!!List- and Comboboxes
++*What is a [[ListBox]] ? What is a [[ComboBox]] ?
++*List- and combobox properties
++**[[ItemData]], [[RowSource]], [[RowSourceType]] - which data in the box and where does it come from ?
++**[[ListCount]], [[ListIndex]] - how long is the list and which item is currently selected ?
++**[[MultiSelect]], [[Selected]] - how to manage multi-select listboxes ?
++*Listbox methods
++**[[AddItem]], [[RemoveItem]] - manage its content
++!!!~OptionGroup and ~RadioButton controls
++*How are [[OptionGroups|OptionGroup]] and [[RadioButtons|RadioButton]] related ?
++*How many radio buttons in an options group ([[Count]])?
++*The [[OptionGroup|OptionGroup (Method)]] method of a (sub)form
++*The [[OptionValue]] property of a ~RadioButton
++!!DATABASE ACCESS
++!!!Info about the database
++*The [[Name]] provides the file name of the Base document ("{{{xxx.odb}}}").
++*The [[Connect]] property returns the connection string between the Base document and the effective database.
++*The [[Version]] property describes the database system supporting the actual database and its version.
++!!!Database tables
++*Use of the [[TableDefs]] collection to access individual tables
++*Each [[TableDef]] object represents a table
++*When applied to the //~TableDefs// collection the [[CreateTableDef]] and [[Add]] methods create a new table in the database
++*The [[Fields]] collection applied to a ~TableDef object gives access to each individual field of the concerned table
++*The [[OpenRecordset]] method gives access to the individual records of the table
++!!!Database queries
++*Use of the [[QueryDefs]] collection to access individual queries
++*Each [[QueryDef]] object represents a query
++*The [[Fields]] collection applied to the ~QueryDef object gives access to each individual field of the concerned query
++*The [[OpenRecordset]] method gives access to the individual records of the query
++*The [[SQL]] property of the querydef allows getting and setting the SQL statement related to the query
++!!!Access to the records in a table, a query or an arbitrary SQL statement
++*Such a set of records is represented by a [[Recordset]] object
++*A recordset object is created via the [[OpenRecordset]] method. A recordset can be explored forward or backward starting from its //current position//
++*The individual fields of a recordset are accessed from its [[Fields]] collection
++*Properties of a recordset
++**[[RecordCount]] - know the total number of records in the recordset
++**[[BOF and EOF|BOF, EOF]] - identify if the current position is //before the first// or //after the last// record
++**[[AbsolutePosition]] - know or set the position of the current record
++**[[Bookmarkable]] and [[Bookmark]] to remember the current record to prepare a later return to it
++**[[Filter]] helps preparing to build a new recordset which will be a subset of the current one
++*Methods of a recordset
++**[[Move|Move (recordset)]], [[MoveFirst|Move (recordset)]], [[MoveLast|Move (recordset)]], [[MoveNext|Move (recordset)]], [[MovePrevious|Move (recordset)]] - navigate thru the recordset and set its new current record
++**[[OpenRecordset]] - open a new recordset based on a preset [[Filter]]
++**[[AddNew]], [[Edit]], [[Update]] and [[CancelUpdate]] - add new records or update the current record. With the [[EditMode]] property, know the current editing status
++**[[GetRows]] - Read a set of records at once into an array.
++**[[Close|Close (method)]] - closing a recordset after use is ''mandatory'' !
++!!!Access to the individual fields of a table, a query or any recordset
++*Such a set of fields is represented by a [[Fields]] collection of indivudual [[Field]] objects
++*New fields can be added to a table thru the [[CreateField]] method.
++*Properties of a field
++**[[Name]] - the name of the field as given by the source SQL statement
++**[[Description]] - to know the help text associated with a field when the table is listed in design view
++**[[DataType]], [[DbType|DataType]], [[TypeName|DataType]] and [[Size]] - know the type of the field in the database and its size
++**[[SourceTable]] and [[SourceField]] - identify the names of the underlying table and field
++**[[DataUpdatable]] - know if that specific field may be updated
++**[[DefaultValue]] - get or set the value that will be preset in new records
++**[[Value|Value (field)]] - get the current value of the field or modify it
++*Methods of a field (only for text and binary fields)
++**[[WriteAllText]] and [[WriteAllBytes]] - export the content of a (text or binary) database field into a file identified by its name
++**[[ReadAllText]] and [[ReadAllBytes]] - import the content of a (text or binary) file identified by its name directly into a database field
++**[[GetChunk]] and [[AppendChunk]] - move the content of a binary field by chunks and store it by chunk into another binary field
++!TEMPORARY VARIABLES
++[[Temporary variables|TempVar]] are variables that can be created or removed at any time by any macro. They help passing values through macros or ~LibO/AOO applications sharing the same ~Access2Base API.
++They are gathered in the [[TempVars]] collection.
++Their value can be get or set with the [[Value]] property.
++!INTROSPECTION
++All objects have an [[ObjectType]] property
++Specific methods are available to manage property //indirection// and property //introspection//.
++*[[hasProperty]] determines if an object has a given property
++*[[getProperty]] and [[setProperty]] help managing the values of properties
++See also the [[Property]] object and the [[Properties|Properties (collection)]] collection.
++!SHORTCUTS
++A [[shortcut|ShortCut Notation]] is a character string designating unambiguously forms and controls. Next functions help managing them:
++*[[getObject]] returns the corresponding object
++*[[getValue]] and [[setValue]] get and set their properties
++!ACTIONS
++*[[OpenForm]], [[OpenTable]], [[OpenQuery]], [[OpenReport]], [[Close]] - open or close //~OpenOffice/~LibreOffice Base// objects
++*[[CopyObject]] - copy tables and/or queries
++*[[RunSQL]] - run action SQL statements
++*[[OpenSQL]] - display the data related to a SELECT SQL statement
++*[[FindRecord]], [[FindNext]] - search strings or values in gridcontrols
++*[[GoToRecord]] - move back-and forward in form records
++*[[ApplyFilter]], [[SetOrderBy]], [[ShowAllRecords]] - set or remove filters and sorting sequences
++*[[GoToControl]] - move the focus to a control simply by its name
++*[[SelectObject]], [[SetHiddenAttribute]], [[GetHiddenAttribute]] - browse thru open windows, hide them dynamically
++*[[Maximize]], [[Minimize]], [[MoveSize]] - move and resize windows
++*[[RunCommand]] - run //AOO/~LibO// menu commands
++*[[RunApp]] - run an external application
++*[[OutputTo]] - export data to a Calc spreadsheet, a text/csv (comma-separated-value) file or to a formatted html page
++*[[SendObject]] - output a form in another format (PDF, ...) and send it as attachment of a mail
++*[[Quit]] - quit the application
++!DATABASE FUNCTIONS
++*Search a single value with [[DLookup]]
++*Make totals or similar computations with [[DSum]], [[DAvg]], [[DCount]], [[DMin and DMax|DMin, DMax]]
++*Make use of statistical functions with  the [[DStDev, DStDevP]], [[DVar and DVarP|DVar, DVarP]] functions
++!ERROR HANDLING
++*The [[Introduction about error handling|Error Handler]] - to read first
++*[[TraceLevel]] sets the minimal level for error messages to be traced
++*The [[TraceError]] function may be used by one's own Basic code
++*[[TraceLog]] is for user messages or internal debugging information
++*Use [[DebugPrint]] for debugging
++*The logged information can be displayed by mean of [[TraceConsole]].
++!EVENTS HANDLING
++*The [[Introduction about event handling|Events Handler]] - to read first
++*The [[Events]] collection of ...
++*... the [[Event]] objects with their specific properties
++
++
++
++
++
The //Value// property specifies what is the current value of a [[Control]], an [[OptionGroup]], a [[TempVar]] or a [[Property]]
++!!!Applies to ...
++| !Object | !Type of control | !Type |!Remarks (not all control types are valid in //~GridControls// !) |
++|[[Control]] |~CheckBox | Boolean<br />Integer<br />Long |Meaning:<br />0 = Not selected<br />1 = Selected<br />2 = Don't know<br />A checkbox also accepts boolean values {{{True/False}}}. |
++|~|~CommandButton | Boolean |Always {{{False}}} except if button has a //Toggle// attribute and it is pressed in, then {{{True}}}. |
++|~|[[ComboBox]]<br />[[ListBox]] | String<br />Numeric<br />Date |The {{{Value}}} property is {{{Null}}} for a multiselect ~ListBox control.<br />Type must be {{{String}}} for a Combo.<br />Otherwise the {{{Value}}} property always refers to the content of the __bound column__ (if it exists). |
++|~|~CurrencyField<br />~NumericField<br />~ProgressBar<br />~ScrollBar<br />~SpinButton | Numeric |Determines the numeric value associated with the control.<br />The value associated with a ~ProgressBar, a ~ScrollBar or a ~SpinButton must be numeric and set between the minimum and maximum values preset when the control was designed. |
++|~|~FormattedField | Numeric<br />String<br />Date<br />Boolean |A ~FormattedField most of the time contains a numeric value. However it also accepts, {{{Date}}}, {{{Boolean}}} or {{{String}}} values if they are compatible with the set format. |
++|~|~DateField<br />~TimeField | Date<br />Long |The expected {{{Value}}} is of type {{{Date}}} for ~DateFields.<br />For ~TimeFields it is a numeric value of the form {{{HHMMSSCC}}} (the highest possible value is 23595999). |
++|~|~FileControl<br />~HiddenControl<br />~PatternField<br />~TextField | String |The {{{string}}} contained in the control. |
++|[[OptionGroup]]|| Integer |Specifies the currently selected [[RadioButton]]. The buttons are counted as 0, 1, ... from left to right and from top to bottom. |
++|[[Property]]|~| Variant |Returns the property value. |
++|[[TempVar]]|~| Variant |The //Value// of a //~TempVar// is normally a string or a numeric value. However this is not controlled by the API. Any {{{Variant}}} content will be accepted, including arrays or objects, without restriction. Use of objects should be handled by the programmer with care. |
++!!!Syntax
++//control//{{{.Value}}}
++//control//{{{.Value}}} = //value//
++//optiongroup//{{{.Value}}}
++//optiongroup//{{{.Value}}} = //value//
++//property//{{{.Value}}}
++//tempvar//{{{.Value}}}
++//tempvar//{{{.Value}}} = //value//
++!!!Returned values / Arguments
++{{{Variant}}} (see the remarks in the table above)
++!!!Remarks
++*The //Value// property returns always a single value. For multiselect [[ListBox]] controls the //Value// property returns a {{{Null}}}.
++*The //Value// for a [[ListBox]] is the value of the ''bound field'', i.e. the value of the field in the underlying record in the database.
++*If the control or the optiongroup is bound to a database field, changing the value in the control programmatically __''modifies''__ also __''the value in the database''__ accordingly.
++*The //Value// of a //Property// is read-only.
++!!!Error messages
++|Property 'Value' not applicable in this context |
++|Value '...' is invalid for property 'value' |
++!!!See also
++[[getValue]]
++[[setValue]]
++[[OptionGroup]]
++!!!Example
++<<tiddler "Value example">>
++
++
++
The //Value// property specifies what is the current value of a [[Field]].
++The setting or return value is a {{{Variant}}} data type that evaluates to a value appropriate for the data type, as specified by the [[type properties|DataType]] of the field.
++!!!Applies to ...
++| !Object | !Type of field | !Type of the //Value// property | !Comment |
++|[[Field]] |com.sun.star.sdbc.~DataType.BIT<br />com.sun.star.sdbc.~DataType.BOOLEAN | vbBoolean ||
++|~|com.sun.star.sdbc.~DataType.TINYINT | vbInteger |Ranging from −32768 to 32767, inclusive |
++|~|com.sun.star.sdbc.~DataType.SMALLINT<br />com.sun.star.sdbc.~DataType.INTEGER | vbLong |Ranging from −2147483648 to 2147483647, inclusive |
++|~|com.sun.star.sdbc.~DataType.BIGINT | vbBigInt |Ranging from −9223372036854775808 to 9223372036854775807, inclusive|
++|~|com.sun.star.sdbc.~DataType.FLOAT | vbSingle |Absolute value ranging from 3.402823 x 10E38 to 1.401298 x 10E-45 |
++|~|com.sun.star.sdbc.~DataType.REAL<br />com.sun.star.sdbc.~DataType.DOUBLE | vbDouble |Absolute value ranging from 1.79769313486232 x 10E308 to 4.94065645841247 x10E-324 |
++|~|com.sun.star.sdbc.~DataType.NUMERIC<br />com.sun.star.sdbc.~DataType.DECIMAL | vbDouble<br />vbLong |//vbDouble// if non-integer value, //vbLong// otherwise. |
++|~|com.sun.star.sdbc.~DataType.CHAR<br />com.sun.star.sdbc.~DataType.VARCHAR | vbString ||
++|~|com.sun.star.sdbc.~DataType.LONGVARCHAR | vbString |Error if length > 64K.<br />To get a memo field exceeding the maximum length, use the [[WriteAllText]] method. |
++|~|com.sun.star.sdbc.~DataType.DATE<br />com.sun.star.sdbc.~DataType.TIME<br />com.sun.star.sdbc.~DataType.TIMESTAMP | vbDate |Use the Basic built-in date functions to<br />- build the argument (f.i. //~DateSerial// and //~TimeSerial//)<br />- process the returned value (f.i. //~DatePart//) |
++|~|com.sun.star.sdbc.~DataType.BINARY<br />com.sun.star.sdbc.~DataType.VARBINARY<br />com.sun.star.sdbc.~DataType.LONGVARBINARY | vbLong |The binary content of the field is returned under the form of an array of integer values, one by binary character.<br />The dimension of the array must not exceed 64,000. To get/set a binary field exceeding the maximum size, use the [[GetChunk]]/[[AppendChunk]] methods, or alternatively the [[WriteAllBytes]]/[[ReadAllBytes]] methods. |
++|~|com.sun.star.sdbc.~DataType.CLOB | NA ||
++|~|com.sun.star.sdbc.~DataType.BLOB | NA ||
++!!!Syntax
++//field//{{{.Value}}}
++//field//{{{.Value}}} = //value//
++!!!Returned values / Arguments
++{{{Variant}}} (see the table above)
++!!!Remarks
++*If the database field contains {{{Null}}} the //Value// property will contain {{{Null}}} as well. To be tested with the {{{IsNull()}}} BASIC builtin function.
++*To set the database field to {{{Null}}} set simply the //Value// property to {{{Null}}} as well.
++*Setting the //Value// property will be rejected if either the [[AddNew]] or the [[Edit]] method has not been applied on the concerned [[Recordset]] first. The modifications will be applied when the [[Update]] Method is applied on the same //recordset// object. If the //Update// method is never applied, or if the [[CancelUpdate]] method is invoked instead, the database will not be impacted.
++*If the field to update is numeric (TINYINT, SMALLINT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC, DECIMAL) the //Value// property may be of any numeric type.
++*Trying to __set the //Value// property__ in an inappropriate context (for example, the //Value// property of a //Field// object in the [[Fields collection|Fields]] of a [[TableDef object|TableDef]]) will cause an error.
++*When the application is __getting the //Value// property__ in an erroneous context, the returned value will always be //empty// (to be tested in your code with the Basic {{{IsEmpty}}} builtin function).
++*Next Basic type constants may be included in your own code, if relevant:
++//{{{
++REM VarType constants
++Const vbEmpty = 0
++Const vbNull = 1
++Const vbInteger = 2
++Const vbLong = 3
++Const vbSingle = 4
++Const vbDouble = 5
++Const vbCurrency = 6
++Const vbDate = 7
++Const vbString = 8
++Const vbObject = 9
++Const vbBoolean = 11
++Const vbVariant = 12
++Const vbByte = 17
++Const vbUShort = 18
++Const vbULong = 19
++Const vbBigint = 35
++Const vbDecimal = 37
++//}}}
++!!!Error messages
++|Property 'Value' not applicable in this context |
++|Value '...' is invalid for property 'value' |
++|Field length (...) exceeds maximum length. Use WriteAllText instead |
++!!!See also
++[[Value (controls)|Value]]
++[[AppendChunk]]
++[[GetChunk]]
++[[ReadAllBytes]]
++[[ReadAllText]]
++[[WriteAllBytes]]
++[[WriteAllText]]
++!!!Example
++<<tiddler "AddNew example">>
++<<tiddler "Edit example">>
++
++
++
Set new value in text field depending on value in combo box
++//{{{
++Dim ofForm As Object, ocCombo As Object, ocText As Object
++Dim vDesc As Variant
++	Set ofForm = Forms("myForm")
++	Set ocCombo = ofForm.Controls("myComboBox")
++	vDesc = DLookup("DENOMINATION", "CATEGORIES", "[CODE CATEGORY]='" & ocCombo.Value & "'")
++	If Not IsNull(vDesc) Then
++		Set ocText = ofForm.Controls("myTextBox")
++		ocText.Value = vDesc
++	End If
++//}}}
++
++
++
++
The //Version// property returns 
++* either ''~LibreOffice w.x.y.z'' or ''~OpenOffice w.x.y.z'' where w.x.y.z is the version number.
++*or the name and version of the database engine, f.i. ''HSQL Database Engine 1.8.0''.
++<<tiddler "ApplyApplication">>
++or to ...
++| !Object | !Description |
++|[[Database]] |A database object returned by the [[CurrentDb]] or [[OpenDatabase]] methods. |
++!!!Syntax
++{{{[Application.]Version}}}
++{{{database.Version}}}
++!!!Returned values / Arguments
++{{{String}}}
++!!!Remarks
++The //Version// property is read-only.
++!!!Error messages
++!!!See also
++[[Connect]]
++[[CurrentUser]]
++[[ProductCode]]
++!!!Example
++<<tiddler "Identification example">>
++
++
++
<!--{{{-->
++<div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
++<div class='title' macro='view title'></div>
++<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
++<div class='tagging' macro='tagging'></div>
++<div class='tagged' macro='tags'></div>
++<div class='viewer' macro='view text wikified'></div>
++<div class='tagClear'></div>
++<div style='float:center;' macro='tiddler BookMarkTiddler'></div>
++<!--}}}-->
++
++
++
The //Visible// property specifies or determines if a //form//, //dialog// or a //control// in a form, subform or dialog, or if a //commandbar// or a //commandbarcontrol// in a commandbar, is hidden or visible.
++!!!Applies to ...
++| !Object | !Type when<br />in a form | !Type when<br />in a ~GridControl | !Type when<br />in a dialog |!Description |
++|[[Form]] ||||An open form. |
++|[[Dialog]] |~|~|~|An active dialog. |
++|[[Control]] |All except<br />--~HiddenControl<br />[[SubForm]]-- | None | All |A control on an open form or dialog. |
++|[[CommandBar]] ||||A toolbar. |
++|[[CommandBarControl]] |~|~|~|An element of a toolbar. |
++!!!Syntax
++//form//{{{.Visible}}}
++//form//{{{.Visible}}} = //value//
++//dialog//{{{.Visible}}}
++//dialog//{{{.Visible}}} = //value//
++//control//{{{.Visible}}}
++//control//{{{.Visible}}} = //value//
++//commandbar//{{{.Visible}}}
++//commandbar//{{{.Visible}}} = //value//
++//commandbarcontrol//{{{.Visible}}}
++//commandbarcontrol//{{{.Visible}}} = //value//
++!!!Returned values / Arguments
++{{{Boolean}}}
++!!!Remarks
++A [[subform|SubForm]] cannot be made hidden programmatically. Neither exists a tabbed interface for forms.
++To simulate anyhow such a tabbed interface, one can store in the form several groups of controls by mean of subforms. To make visible one subform while hiding the other ones, have a look at the second example below.
++
++A tabbed interface in [[dialogs|Dialog]] is easy to simulate thru the [[Page]] property.
++!!!Error messages
++|Form '...' is currently not open |
++|Dialog '...' not active |
++|Property 'Visible' not applicable in this context |
++|Value '...' is invalid for property 'Visible' |
++!!!Examples
++<<tiddler "Visible example">>
++
++
++
Hide a control on a form
++//{{{
++Dim ocControl As Object
++	Set ocControl = Controls("myForm", "myControl")
++	ocControl.Visible = False
++//}}}
++
++A subform cannot be made hidden; simulate it by hiding each of its controls
++//{{{
++Dim ofSubform As Object, ocControl As Object, i As Integer
++	Set ofSubform = getValue("Forms!myForm!mySubForm.Form")
++	For i = 0 To ofSubForm.Controls().Count - 1
++		Set ocControl = ofSubForm.Controls(i)
++		If ocControl.hasProperty("Visible") Then ocControl.Visible = False
++	Next i
++//}}}
++
++
++
!!Observation:
++{{firstletter{
++ @@color:#930;O@@
++ }}}penOffice/~LibreOffice Calc, Writer, Impress softwares have proved to be valid alternatives to their //~MSOffice// equivalents. __Base has obviously not reached the same success__
++
++>''//~Access2Base// has simply the ambition to close a small part of the gap, i.e. provide a quite simple programming interface.''
++
++If you compare
++*The number of objects, constants, services, interfaces, methods, properties, enumerations in the whole ~OpenOffice/~LibreOffice API - including indeed also Calc, Writer, etc. - is about 20,000.
++* The number of collections, objects, methods, properties, constants in the whole //~MSAccess// API - indeed only //~MSAccess// oriented - is about 1,600 including 800 constants.
++you will admit that both softwares are functionally extremely rich but also that //~OpenOffice/~LibreOffice requires from an application developer undoubtedly a huge initial effort !//
++
++AND ... can anyone tell me: __why should an application developer know and use the same API as the developer of the software itself ?__
++
++Additionally
++*Calc and Writer applications, in most cases, do not require any script programming 
++*Base, at the opposite, does require such __automation__ capacity __for most business or personal applications__. As a minimum to validate the entered data and avoid database corruption.
++!!Conclusion => the 80/20 rule
++>''Why not implement the few % of the //~MSAccess// API in //~OpenOffice/~LibreOffice// that cover 80% of the needs ?''
++An inventory of the coverage by //~Access2Base// of the //~MSAccess// API has been done in the [[MSAccess coverage|MSAccessCoverage]] page.
++
++
++
The //Width// property specifies the width of a form or a dialog.
++!!!Applies to ...
++| !Object |!Description |
++|[[Form]] |An open form |
++|[[Dialog]] |An active dialog |
++!!!Syntax
++//form//{{{.Width}}}
++//form//{{{.Width = }}}//value//
++//dialog//{{{.Width}}}
++//dialog//{{{.Width = }}}//value//
++!!!Returned values / Arguments
++{{{Integer}}} or {{{Long}}}
++!!!Remarks
++!!!Error messages
++|Form '...' is currently not open |
++|Dialog '...' not active |
++|Value '...' is invalid for property 'Width' |
++!!!See also
++[[Height]]
++[[Maximize]]
++[[Minimize]]
++[[Move]]
++!!!Example
++<<tiddler "Height & Width example">>
++
++
++
The //~WriteAllBytes// method writes the content of a binary [[Field]] belonging to a [[Recordset]] to a file specified by its full name.
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.~DataType.BINARY<br />com.sun.star.sdbc.~DataType.VARBINARY<br />com.sun.star.sdbc.~DataType.LONGVARBINARY |
++!!!Syntax
++//field//{{{.WriteAllBytes(}}}//file//{{{)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++| file | String |The full name, including the path, of the file you want to output the data to. |
++!!!Remarks
++The {{{file}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++!!!Error messages
++|Method '~WriteAllBytes' not applicable in this context |
++|File access error on file '...' |
++|Field is null or empty. Action rejected |
++!!!See also
++[[ReadAllBytes]]
++[[ReadAllText]]
++[[Value|Value (field)]]
++[[WriteAllText]]
++!!!Example
++<<tiddler "WriteAllBytes example">>
++
++
++
Save the image stored in the 1st record database to a file
++//{{{
++Dim oRecordset As Object, oImage As Object, vValue As Variant, sFile As String
++	sFile = "C:\TestImage.jpg"
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Products")	'	Current record = 1st
++	With oRecordset
++		Set oImage = .Fields("IMAGE")
++		vValue = oImage.Value
++		If Not IsNull(vValue) Then		'A null field in the database returns a null value property
++			If vValue > 0 Then		'The value property of a binary field returns its LENGTH
++				oImage.WriteAllBytes(sFile)
++			End If
++		End If
++	End With
++	oRecordset.mClose()
++//}}}
++
++
++
The //~WriteAllText// method writes the content of a memo [[Field]] belonging to a [[Recordset]] to a file specified by its full name.
++!!!Applies to ...
++| !Object | !Type of field |
++|[[Field]] |com.sun.star.sdbc.~DataType.LONGVARCHAR |
++!!!Syntax
++//field//{{{.WriteAllText(}}}//file//{{{)}}}
++!!!Arguments
++| !Argument | !Type | !Description |
++| file | String |The full name, including the path, of the file you want to output the data to. |
++!!!Remarks
++The {{{file}}} argument may be expressed either in the (recommended) URL format (i.e. "{{{file:// ...}}}") or by using the operating system usual syntax (e.g. "{{{C:\...}}}" in Windows).
++!!!Error messages
++|Method '~WriteAllText' not applicable in this context |
++|File access error on file '...' |
++|Field is null or empty. Action rejected |
++!!!See also
++[[ReadAllBytes]]
++[[ReadAllText]]
++[[Value|Value (field)]]
++[[WriteAllBytes]]
++!!!Example
++<<tiddler "WriteAllText example">>
++
++
++
Save the text stored in a memo field in the 1st record to a file
++//{{{
++Dim oRecordset As Object, oMemo As Object, vValue As Variant, lSize As Long, sFile As String
++	sFile = "C:\SomeFile.txt"
++	Set oRecordset = Application.CurrentDb().OpenRecordset("Products")	'	Current record = 1st
++	With oRecordset
++		Set oMemo = .Fields("DetailedDescription")
++		lSize = oMemo.FieldSize
++		If lSize < 64000 Then vValue = oMemo.Value	'	If you want to manipulate the resulting string ...
++		If Not IsNull(vValue) Then				'A null field in the database returns a null value property
++			If Len(vValue) > 0 Then
++				oMemo.WriteAllText(sFile)
++			End If
++		End If
++	End With
++	oRecordset.mClose()
++//}}}
++
++
++
++
(Q) How can I enlarge a picture by moving the mouse above it ?
++
++(R) Bind 2 different image controls with different sizes to the same database field.
++
++Considering next table:
++<<tiddler "ProductsTable">>
++and a form having a small (for thumbnail display) and a large image control, both bound to the same //Picture// database field ...
++!!!Solution based on mouse movements
++... use the (small) control's //Mouse inside// and //Mouse outside// events to let appear and disappear the large image.
++Link to them next code:
++//{{{
++Sub ZoomInOut(poEvent As Object)
++Dim ofForm As Object, ocZoom As Object
++	Set ofForm = Events(poEvent).Source.Parent
++	Set ocZoom = ofForm.Controls("imgZoom")
++	ocZoom.Visible = Not ocZoom.Visible
++End Sub
++//}}}
++To ensure the right behaviour, we reset the //Visible// property //After// each //record change//:
++//{{{
++Sub ZoomInit(poEvent As Object)
++Dim ofForm As Object, ocZoom As Object
++	Set ofForm = Events(poEvent).Source
++	Set ocZoom = ofForm.Controls("imgZoom")
++	ocZoom.Visible = False
++End Sub
++//}}}
++!!!See also
++[[Visible]]
++[[Events Handler]]
++!!!Refer to ...
++| !Basic module | !Form | !Form event | !Control | !Control event |!Comments |
++|Zoom |~Products_ZoomImage |After record change |imgPicture |Mouse inside<br />Mouse outside ||
++
++
++
!usage
++{{{[img[calculator.png]]}}}
++[img[calculator.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/calculator.png
++!url
++
++!data
++
++
++
++
++
!usage
++{{{[img[dbaccess_from_calc.png]]}}}
++[img[dbaccess_from_calc.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/dbaccess_from_calc.png
++!url
++
++!data
++
++
++
++
++
The //getObject// function returns an [[object|Object Model]] designated by its [[shortcut notation|ShortCut Notation]].
++!!!Syntax
++{{{getObject(}}}//shortcut//{{{)}}}
++| !Shortcut |!Returned value |
++| String |An object of types [[Form]], [[Dialog]] or [[Control]]. Other types are currently not supported. |
++!!!See also
++[[ShortCut Notation]]
++[[getValue]]
++[[setValue]]
++!!!Example
++//{{{
++getObject("Forms!myForm!mySubForm.Form!myGridControl!mySubControl")
++//}}}
++is equivalent to
++//{{{
++Forms("myForm").Controls("mySubForm").Form.Controls("myGridControl").Controls("mySubControl")
++//}}}
++
++
++
The //getProperty// method returns the current value of any property of any [[object|Object Model]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Collection]] |An array of objects accessible via their index or their names |
++|[[Control]] |The representation of a control within a form, a subform, a gridcontrol or a dialog.<br />The control may be any control type including a [[gridcontrol|GridControl]]. |
++|[[Database]] |The representation of a database |
++|[[Event|Events]] |A description of an occurred  form or control event |
++|[[Field]] |Identifies a field within a //~TableDef//, a //~QueryDef// or a //Recordset// |
++|[[Form]] |The representation of a database form |
++|[[OptionGroup]] |Identifies a group of radio buttons within a form or a subform. |
++|[[Property]] |A name-value pair allowing objects introspection |
++|[[QueryDef]] |Corresponds with a query definition |
++|[[Recordset]] |Identifies a set of records related to a table, a query or a SQL statement |
++|[[SubForm]] |Identifies a specific control which is a subform of a database form or another subform |
++|[[TableDef]] |Corresponds with a table definition |
++|[[TempVar]] |Represents a temporary variable |
++!!!Syntax
++//collection//.{{{getProperty}}}(//property-name//{{{)}}}
++//control//.{{{getProperty(}}}//property-name//{{{)}}}
++//control//.{{{getProperty(}}}//property-name//{{{, }}}//index//{{{)}}}
++//database//.{{{getProperty(}}}//property-name//{{{)}}}
++//event//.{{{getProperty(}}}//property-name//{{{)}}}
++//field//.{{{getProperty(}}}//property-name//{{{)}}}
++//form//.{{{getProperty(}}}//property-name//{{{)}}}
++//optiongroup//.{{{getProperty(}}}//property-name//{{{)}}}
++//property//.{{{getProperty(}}}//property-name//{{{)}}}
++//querydef//.{{{getProperty(}}}//property-name//{{{)}}}
++//recordset//.{{{getProperty(}}}//property-name//{{{)}}}
++|//subform//.{{{getProperty(}}}//property-name//{{{)}}}
++//subform//.{{{getProperty(}}}//property-name//{{{, }}}//index//{{{)}}}
++//tabledef//.{{{getProperty(}}}//property-name//{{{)}}}
++//tempvar//.{{{getProperty(}}}//property-name//{{{)}}}
++| !Applied to | !Type | !Argument #1 | !Type | !Argument #2 | !Type |!Returned value |
++|collection | [[Collection object|Collection]] | property-name | String |||Variant or Variant array. |
++|control | [[Control object|Control]] |~|~| index | absent |~|
++|~|~|~|~|~| Integer<br />Long |Variant (or index-th array entry). |
++|database | [[Database object|Database]] |~|~|||Variant. |
++|event | [[Event object|Event]] |~|~|~|~|~|
++|field | [[Field object|Field]] |~|~|~|~|Variant. |
++|form | [[Form object|Form]] |~|~|~|~|Variant. |
++|optiongroup | [[Optiongroup object|OptionGroup]] |~|~|~|~|Variant. |
++|property | [[Property object|Property]] |~|~|~|~|Variant or Variant array. |
++|querydef | [[QueryDef object|QueryDef]] |~|~|~|~|Variant. |
++|recordset | [[Recordset object|Recordset]] |~|~|~|~|Variant. |
++|tabledef | [[TableDef object|TableDef]] |~|~|~|~|Variant. |
++|subform | [[Subform object|SubForm]] |~|~| index | absent |Variant or Variant array. |
++|~|~|~|~|~| Integer<br />Long |Variant (or index-th array entry). |
++|tempvar | [[TempVar object|TempVar]] |~|~|||Variant. |
++!!!Remarks
++The //index// argument must have a (integer or long) value between 0 and the size of the array associated with the considered //property// - 1
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property '...' not applicable in this context |
++|Out of array range or incorrect array size for property '...' |
++!!!See also
++[[Property]]
++[[Properties|Properties (collection)]]
++[[hasProperty]]
++[[setProperty]]
++!!!Example
++
++
++
++
The //getValue// function returns a property of an [[object|Object Model]] designated by its [[shortcut notation|ShortCut Notation]].
++!!!Syntax
++{{{getValue(}}}//shortcut//{{{)}}}
++| !Shortcut | !Returned value |
++| String | Variant |
++!!!Remark
++If the last component of the //shortcut// is not a property (i.e. the last operator is not a ".") then the property [[Value]] is assumed.
++!!!See also
++[[ShortCut Notation]]
++[[getObject]]
++[[setValue]]
++The [[Value]] property
++!!!Example
++//{{{
++getValue("Forms!myForm!mySubForm.Form!myGridControl!mySubControl.ControlTipText")
++//}}}
++is equivalent to
++//{{{
++Forms("myForm").Controls("mySubForm").Form.Controls("myGridControl").Controls("mySubControl").ControlTipText
++//}}}
++
++
++
The //hasProperty// method returns //True// if an [[object|Object Model]] has a specific //property//.
++!!!Applies to ...
++| !Object | !Description |
++|[[Collection]] |An array of objects accessible via their index or their names |
++|[[Database]] |The representation of a database object |
++|[[Form]] |The representation of a database form |
++|[[Control]] |The representation of a control within a form, a subform, a gridcontrol or a dialog.<br />The control may be any control type including a [[gridcontrol|GridControl]]. |
++|[[SubForm]] |Identifies a specific control which is a subform of a database form or another subform |
++|[[OptionGroup]] |Identifies a group of radio buttons within a form or a subform. |
++|[[TableDef]] |Corresponds with a table definition |
++|[[QueryDef]] |Corresponds with a query definition |
++|[[Recordset]] |Identifies a set of records related to a table, a query or a SQL statement |
++|[[Field]] |Identifies a field within a //~TableDef//, a //~QueryDef// or a //Recordset// |
++|[[Property]] |A name-value pair allowing objects introspection |
++|[[Event|Events]] |A description of an occurred  form or control event |
++!!!Syntax
++//object//.{{{hasProperty(}}}//property-name//{{{)}}}
++| !Argument | !Type |!Returned value |
++| property-name | String | Boolean |
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++!!!See also
++[[Property]]
++[[Properties|Properties (collection)]]
++[[getProperty]]
++[[setProperty]]
++!!!Example
++<<tiddler "setProperty example">>
++
++
++
!usage
++{{{[img[objectmodel.png]]}}}
++[img[objectmodel.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/objectmodel.png
++!url
++
++!data
++
++
++
++
++
The //setProperty// method modifies the current value of any modifiable property of [[objects|Object Model]].
++!!!Applies to ...
++| !Object | !Description |
++|[[Control]] |The representation of a control within a form, a subform, a gridcontrol or a dialog.<br />The control may be any control type including a [[gridcontrol|GridControl]]. |
++|[[Field]] |Identifies a field within a //~TableDef//, a //~QueryDef// or a //Recordset// |
++|[[Form]] |The representation of a database form |
++|[[OptionGroup]] |Identifies a group of radio buttons within a form or a subform. |
++|[[QueryDef]] |Corresponds with a query definition |
++|[[Recordset]] |Identifies a set of records related to a table, a query or a SQL statement |
++|[[SubForm]] |Identifies a specific control which is a subform of a database form or another subform |
++|[[TempVar]] |Represents a temporary variable |
++!!!Syntax
++//control//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//control//.{{{setProperty(}}}//property-name, value, index//{{{)}}}
++//field//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//form//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//optiongroup//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//querydef//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//recordset//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//subform//.{{{setProperty(}}}//property-name, value//{{{)}}}
++//tempvar//.{{{setProperty(}}}//property-name, value//{{{)}}}
++| !Applied to | !Type | !Argument #1 | !Type | !Argument #2 | !Type | !Argument #3 | !Type | !Returned value |
++| control | [[Control object|Control]] | property-name | String | value | Variant | index | absent |{{{True}}} if success. |
++|~|~|~|~|~|~|~| Integer<br />Long |~|
++| field | [[Field object|Field]] |~|~|~|~|||~|
++| form | [[Form object|Form]] |~|~|~|~|~|~|~|
++| optiongroup | [[Optiongroup object|OptionGroup]] |~|~|~|~|~|~|~|
++| querydef | [[QueryDef object|QueryDef]] |~|~|~|~|~|~|~|
++| recordset | [[Recordset object|Recordset]] |~|~|~|~|~|~|~|
++| subform | [[Subform object|SubForm]] |~|~|~|~|~|~|~|
++| tempvar | [[Subform object|SubForm]] |~|~|~|~|~|~|~|
++!!!Remarks
++The //index// argument must have a (integer or long) value between 0 and the size of the array associated with the considered //property// - 1.
++!!!Error messages
++|Argument nr. ... [Value = '...'] is invalid |
++|Property '...' not applicable in this context |
++|Value '...' is invalid for property '...' |
++|Out of array range or incorrect array size for property '...' |
++!!!See also
++[[Property]]
++[[Properties|Properties (collection)]]
++[[hasProperty]]
++[[getProperty]]
++!!!Example
++<<tiddler "setProperty example">>
++
++
++
++
Set all enabled controls on a form in italic
++//{{{
++Dim ofForm As Object, i As Integer, iCount As Integer, ocControl As Object
++     Set ofForm = Forms("myForm")
++     iCount = ofForm.Controls().Count
++     For i = 0 To iCount - 1
++     	Set ocControl = ofForm.Controls(i)
++     	If ocControl.hasProperty("FONTITALIC") Then
++     		If ocControl.hasProperty("ENABLED") Then
++     			If ocControl.Enabled Then ocControl.setProperty("FONTITALIC", True)
++     		End If
++     	End If
++     Next i
++//}}}
++
++
++
The //setValue// function sets a property of an [[object|Object Model]] designated by its [[shortcut notation|ShortCut Notation]].
++!!!Syntax
++{{{setValue(}}}//shortcut, value//{{{)}}}
++| !Shortcut | !Value |!Returned value |
++| String | Variant |Boolean. True if success. |
++!!!Remark
++If the last component of the //shortcut// is not a property (i.e. the last operator is not a ".") then the property [[Value]] is assumed.
++The //setValue// does not allow to set a single element of an array if the property value is an array. However setting all the elements at once is allowed.
++!!!See also
++[[ShortCut Notation]]
++[[getObject]]
++[[getValue]]
++The [[Value]] property
++!!!Example
++//{{{
++setValue("Forms!myForm!mySubForm.Form!myGridControl!mySubControl.ControlTipText", "New tip")
++//}}}
++is equivalent to
++//{{{
++Forms("myForm").Controls("mySubForm").Form.Controls("myGridControl").Controls("mySubControl").ControlTipText = "New tip"
++//}}}
++
++
++
Type the text for 'systemConfig'
++
++
++
!usage
++{{{[img[tabbed_details.png]]}}}
++[img[tabbed_details.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/tabbed_details.png
++!url
++
++!data
++
++
++
++
++
!usage
++{{{[img[tabbed_orders.png]]}}}
++[img[tabbed_orders.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/tabbed_orders.png
++!url
++
++!data
++
++
++
++
++
!usage
++{{{[img[traceerror msgbox.png]]}}}
++[img[traceerror msgbox.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/traceerror msgbox.png
++!url
++
++!data
++
++
++
++
++
!usage
++{{{[img[tracelog dialog.png]]}}}
++[img[tracelog dialog.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/tracelog dialog.png
++!url
++
++!data
++
++
++
++
++
!usage
++{{{[img[tracelog msgbox.png]]}}}
++[img[tracelog msgbox.png]]
++!notes
++//none//
++!type
++image/png
++!file
++./_wikiimages/tracelog msgbox.png
++!url
++
++!data
++
++
++
++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ diff --git a/debian/patches/apparmor-allow-java.security.diff b/debian/patches/apparmor-allow-java.security.diff new file mode 100644 index 000000000..e4b8ae6ea --- /dev/null +++ b/debian/patches/apparmor-allow-java.security.diff @@ -0,0 +1,14 @@ +diff --git a/sysui/desktop/apparmor/program.soffice.bin b/sysui/desktop/apparmor/program.soffice.bin +index 2fc7fd6b5735..3fd82b08431e 100644 +--- a/sysui/desktop/apparmor/program.soffice.bin ++++ b/sysui/desktop/apparmor/program.soffice.bin +@@ -144,6 +144,9 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + /usr/lib{,32,64}/jvm/** r, + /usr/lib{,32,64}/jvm/**/jre/bin/java mix, + /usr/lib{,32,64}/jvm/**/bin/java mix, ++ # should be included in the jvm/** above but there it is ++ # a symlink, so apparmor still doesn't allow it... ++ /etc/java-??-openjdk/security/java.security r, + INSTDIR-** rw, + INSTDIR-**.so m, + INSTDIR-program/soffice.bin mix, diff --git a/debian/patches/apparmor-cleanups.diff b/debian/patches/apparmor-cleanups.diff new file mode 100644 index 000000000..c4b17e995 --- /dev/null +++ b/debian/patches/apparmor-cleanups.diff @@ -0,0 +1,105 @@ +From b3c157faeb945fd689fcc8561a520d9e611a7419 Mon Sep 17 00:00:00 2001 +From: Vincas Dargis +Date: Sat, 4 Aug 2018 17:40:05 +0300 +Subject: [PATCH] apparmor: use dri-enumerate abstraction + +Remove backported rule and use new dri-enumerate abstraction instead. +dri-enumerate is available in AppArmor 2.13, which recently migrated +into Debian Buster. + +Change-Id: I64919edc1882f7bc1e65cfb94686464c5350f699 +--- + sysui/desktop/apparmor/program.soffice.bin | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysui/desktop/apparmor/program.soffice.bin b/sysui/desktop/apparmor/program.soffice.bin +index 2fc7fd6b5735..33ad6f933ef6 100644 +--- a/sysui/desktop/apparmor/program.soffice.bin ++++ b/sysui/desktop/apparmor/program.soffice.bin +@@ -82,6 +82,7 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + #include + #include + #include ++ #include + #include + #include + #include +@@ -179,7 +179,6 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + #Likely moving to abstractions in the future + owner @{HOME}/.icons/*/cursors/* r, + /etc/fstab r, # Solid::DeviceNotifier::instance() TODO: deny? +- /sys/devices/pci[0-9]*/**/{device,subsystem_device,subsystem_vendor,uevent,vendor} r, # for libdrm + /usr/share/*-fonts/conf.avail/*.conf r, + /usr/share/fonts-config/conf.avail/*.conf r, + /{,var/}run/udev/data/+usb:* r, # Solid::Device::listFromQuery() + +From 5054f7067cc5ee43933893b682e02540fce043b4 Mon Sep 17 00:00:00 2001 +From: Rene Engelhard +Date: Sat, 20 Jun 2020 15:33:34 +0200 +Subject: deb#962903 #include to allow /tmp/something/* + +Change-Id: I6377db152ededc4d46ba7bbbaa9bc66210964e18 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96770 +Tested-by: Jenkins +Reviewed-by: Thorsten Behrens +--- + sysui/desktop/apparmor/program.senddoc | 4 ++-- + sysui/desktop/apparmor/program.soffice.bin | 3 ++- + sysui/desktop/apparmor/program.xpdfimport | 5 ++--- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/sysui/desktop/apparmor/program.senddoc b/sysui/desktop/apparmor/program.senddoc +index d659ec9b98b3..969130f4ea90 100644 +--- a/sysui/desktop/apparmor/program.senddoc ++++ b/sysui/desktop/apparmor/program.senddoc +@@ -17,8 +17,8 @@ + profile libreoffice-senddoc INSTDIR-program/senddoc { + #include + +- owner /tmp/lu** rw, #makes files like luRRRRR.tmp/lubRRRR.tmp where R is random +- #Note, usually it's lub or luc, don't know why. ++ #include ++ + /{usr/,}bin/sh rmix, + /{usr/,}bin/bash rmix, + /{usr/,}bin/dash rmix, +diff --git a/sysui/desktop/apparmor/program.soffice.bin b/sysui/desktop/apparmor/program.soffice.bin +index 212eb7c62b15..42053db2abef 100644 +--- a/sysui/desktop/apparmor/program.soffice.bin ++++ b/sysui/desktop/apparmor/program.soffice.bin +@@ -92,6 +92,8 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + #include + #include + ++ #include ++ + #List directories for file browser + / r, + /**/ r, +@@ -116,7 +118,6 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + owner @{HOME}/.config/soffice.binrc.lock rwk, + owner @{HOME}/.cache/fontconfig/** rw, + owner @{HOME}/.config/gtk-???/bookmarks r, #Make bookmarks work +- owner /tmp/psp[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]* rw, #/tmp/psp1534203998 (printing to file) + + owner /{,var/}run/user/*/dconf/user rw, + owner @{HOME}/.config/dconf/user r, +diff --git a/sysui/desktop/apparmor/program.xpdfimport b/sysui/desktop/apparmor/program.xpdfimport +index efe10dce020d..f8bfbfe8fa49 100644 +--- a/sysui/desktop/apparmor/program.xpdfimport ++++ b/sysui/desktop/apparmor/program.xpdfimport +@@ -17,9 +17,8 @@ + profile libreoffice-xpdfimport INSTDIR-program/xpdfimport { + #include + +- owner /tmp/* r, #Seems to need to read file created with pattern /tmp/RRRRRR +- owner /tmp/lu** rw, #makes files like luRRRRR.tmp/lubRRRR.tmp where R is random +- #Note, usually it's lub or luc, don't know why. ++ #include ++ + /usr/share/poppler/** r, + /usr/share/libreoffice/share/config/* r, + owner @{HOME}/.config/libreoffice{,dev}/?/user/uno_packages/cache/log.txt rw, +-- +cgit v1.2.1 + diff --git a/debian/patches/apparmor-complain.diff b/debian/patches/apparmor-complain.diff new file mode 100644 index 000000000..8f96fd304 --- /dev/null +++ b/debian/patches/apparmor-complain.diff @@ -0,0 +1,26 @@ +diff --git a/sysui/desktop/apparmor/program.oosplash b/sysui/desktop/apparmor/program.oosplash +index fef54b7ee384..9dde31a63615 100644 +--- a/sysui/desktop/apparmor/program.oosplash ++++ b/sysui/desktop/apparmor/program.oosplash +@@ -12,7 +12,7 @@ + + #include + +-profile libreoffice-oopslash INSTDIR-program/oosplash { ++profile libreoffice-oopslash INSTDIR-program/oosplash flags=(complain) { + #include + #include + +diff --git a/sysui/desktop/apparmor/program.soffice.bin b/sysui/desktop/apparmor/program.soffice.bin +index b4baeab8f5ee..7861c9eac9bd 100644 +--- a/sysui/desktop/apparmor/program.soffice.bin ++++ b/sysui/desktop/apparmor/program.soffice.bin +@@ -60,7 +60,7 @@ + + #include + +-profile libreoffice-soffice INSTDIR-program/soffice.bin { ++profile libreoffice-soffice INSTDIR-program/soffice.bin flags=(complain) { + #include + + #include diff --git a/debian/patches/apparmor-mesa.diff b/debian/patches/apparmor-mesa.diff new file mode 100644 index 000000000..dd6dd20a6 --- /dev/null +++ b/debian/patches/apparmor-mesa.diff @@ -0,0 +1,10 @@ +--- a/sysui/desktop/apparmor/program.soffice.bin-old 2018-11-09 23:04:59.858704214 +0100 ++++ b/sysui/desktop/apparmor/program.soffice.bin 2018-11-09 23:05:28.050949237 +0100 +@@ -87,6 +87,7 @@ + #include + #include + #include ++ #include + #include + #include + #include diff --git a/debian/patches/apparmor-opencl.diff b/debian/patches/apparmor-opencl.diff new file mode 100644 index 000000000..462f376bc --- /dev/null +++ b/debian/patches/apparmor-opencl.diff @@ -0,0 +1,20 @@ +apparmor: Add opencl support + +AppArmor in Debian Buster now has OpenCL abstractions. + +Include OpenCL abstractions to fix OpenCL usage in Calc. +Index: libreoffice-6.1.4/sysui/desktop/apparmor/program.soffice.bin +=================================================================== +--- libreoffice-6.1.4.orig/sysui/desktop/apparmor/program.soffice.bin 2019-01-14 19:29:25.000000000 +0200 ++++ libreoffice-6.1.4/sysui/desktop/apparmor/program.soffice.bin 2019-01-16 18:43:17.051781559 +0200 +@@ -98,6 +98,10 @@ + + #include + ++ #include ++ #include ++ #include ++ + #List directories for file browser + / r, + /**/ r, diff --git a/debian/patches/apparmor-updates.diff b/debian/patches/apparmor-updates.diff new file mode 100644 index 000000000..1f71f8d14 --- /dev/null +++ b/debian/patches/apparmor-updates.diff @@ -0,0 +1,13 @@ +diff --git a/sysui/desktop/apparmor/program.soffice.bin b/sysui/desktop/apparmor/program.soffice.bin +index 42053db2abef..83bd9d11f93c 100644 +--- a/sysui/desktop/apparmor/program.soffice.bin ++++ b/sysui/desktop/apparmor/program.soffice.bin +@@ -101,7 +101,7 @@ profile libreoffice-soffice INSTDIR-program/soffice.bin { + owner @{libo_user_dirs}/**/ rw, #allow creating directories that we own + owner @{libo_user_dirs}/**~lock.* rw, #lock file support + owner @{libo_user_dirs}/**.@{libreoffice_ext} rwk, #Open files rw with the right exts +- owner @{libo_user_dirs}/{,**/}lu??????????{,?}.tmp rwk, #Temporary file used when saving ++ owner @{libo_user_dirs}/{,**/}lu???????????{,?}.tmp rwk, #Temporary file used when saving + owner @{libo_user_dirs}/{,**/}.directory r, #Read directory settings on KDE + + # Settings diff --git a/debian/patches/appstream-ignore-startcenter.diff b/debian/patches/appstream-ignore-startcenter.diff new file mode 100644 index 000000000..4251d6492 --- /dev/null +++ b/debian/patches/appstream-ignore-startcenter.diff @@ -0,0 +1,10 @@ +--- a/sysui/desktop/menus/startcenter.desktop ++++ b/sysui/desktop/menus/startcenter.desktop +@@ -31,6 +31,7 @@ StartupNotify=true + X-GIO-NoFuse=true + StartupWMClass=libreoffice-startcenter + X-KDE-Protocols=file,http,ftp,webdav,webdavs ++X-AppStream-Ignore=True + + ##Define Actions + Actions=Writer;Calc;Impress;Draw;Base;Math; diff --git a/debian/patches/avoid-empty-java.class.path.diff b/debian/patches/avoid-empty-java.class.path.diff new file mode 100644 index 000000000..2f5251269 --- /dev/null +++ b/debian/patches/avoid-empty-java.class.path.diff @@ -0,0 +1,90 @@ +From 5e8f64e50f97d39e83a3358697be14db03566878 Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Mon, 21 Feb 2022 11:55:21 +0100 +Subject: Avoid unnecessary empty -Djava.class.path= + +Change-Id: Idcfe7321077b60381c0273910b1faeb444ef1fd8 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130242 +Tested-by: Jenkins +Reviewed-by: Stephan Bergmann +--- + jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 16 +++++++++++++--- + jvmfwk/source/framework.cxx | 8 ++++++-- + jvmfwk/source/fwkbase.cxx | 3 +++ + 3 files changed, 22 insertions(+), 5 deletions(-) + +diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +index 29de226211f1..e55b914edf13 100644 +--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx ++++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +@@ -712,17 +712,22 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( + // all versions below 1.5.1 + options.emplace_back("abort", reinterpret_cast(abort_handler)); + bool hasStackSize = false; ++#ifdef UNX ++ // Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2) ++ // in the class path in order to have applet support: ++ OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion); ++#endif + for (int i = 0; i < cOptions; i++) + { + OString opt(arOptions[i].optionString); + #ifdef UNX +- // Until java 1.5 we need to put a plugin.jar or javaplugin.jar (<1.4.2) +- // in the class path in order to have applet support: + if (opt.startsWith("-Djava.class.path=")) + { +- OString sAddPath = getPluginJarPath(pInfo->sVendor, pInfo->sLocation,pInfo->sVersion); + if (!sAddPath.isEmpty()) ++ { + opt += OStringChar(SAL_PATHSEPARATOR) + sAddPath; ++ sAddPath.clear(); ++ } + } + #endif + if (opt == "-Xint") { +@@ -767,6 +772,11 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( + } + #endif + } ++#ifdef UNX ++ if (!sAddPath.isEmpty()) { ++ options.emplace_back("-Djava.class.path=" + sAddPath, nullptr); ++ } ++#endif + + std::unique_ptr sarOptions(new JavaVMOption[options.size()]); + for (std::vector
+ ++ ++ ++ EUR ++ ++ ++ HRK ++ ++ ++ 7.53450 ++ ++ + + + +diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx +index 31c42a4b728a..67fcd9f787f8 100644 +--- a/sc/source/core/tool/interpr2.cxx ++++ b/sc/source/core/tool/interpr2.cxx +@@ -3235,7 +3235,8 @@ static bool lclConvertMoney( const OUString& aSearchUnit, double& rfRate, int& r + { "SKK", 30.1260, 2 }, + { "EEK", 15.6466, 2 }, + { "LVL", 0.702804, 2 }, +- { "LTL", 3.45280, 2 } ++ { "LTL", 3.45280, 2 }, ++ { "HRK", 7.53450, 2 } + }; + + for (const auto & i : aConvertTable) +-- +cgit v1.2.1 + +From b1a2f727ca99ecd3402d4b051b99cbfd24266e59 Mon Sep 17 00:00:00 2001 +From: Eike Rathke +Date: Fri, 22 Jul 2022 22:17:11 +0200 +Subject: Related: tdf#150011 Add HRK Croatian Kuna to Euro conversion wizard + +Maybe just for completeness, it's removed from menu but might be +callable as macro. + +Change-Id: Iade0be845186d3deb2f00f4aaa230c0b344cea72 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137372 +Reviewed-by: Eike Rathke +Tested-by: Jenkins +--- + wizards/source/euro/Init.xba | 16 ++++++++++++++++ + wizards/source/resources/resources_en_US.properties | 1 + + 2 files changed, 17 insertions(+) + +diff --git a/wizards/source/euro/Init.xba b/wizards/source/euro/Init.xba +index 623a0a53be46..9f56c503a347 100644 +--- a/wizards/source/euro/Init.xba ++++ b/wizards/source/euro/Init.xba +@@ -89,6 +89,7 @@ Public sCurrSLOVAK as String + Public sCurrESTONIAN as String + Public sCurrLATVIAN as String + Public sCurrLITHUANIAN as String ++Public sCurrCROATIAN as String + + Public sPrgsRETRIEVAL as String + Public sPrgsCONVERTING as String +@@ -214,6 +215,7 @@ Dim LocWorkPath as String + sCurrESTONIAN = GetResText("CURRENCIES_16") + sCurrLATVIAN = GetResText("CURRENCIES_17") + sCurrLITHUANIAN = GetResText("CURRENCIES_18") ++ sCurrCROATIAN = GetResText("CURRENCIES_19") + .cmdCancel.Label = sCANCEL + .cmdHelp.Label = sHELP + .cmdBack.Label = GetResText("STEP_ZERO_2") +@@ -393,6 +395,11 @@ Sub InitializeLanguages() + LangIDValue(18,0,1) = "LT" + LangIDValue(18,0,2) = "-427" + ++' CURRENCIES_CROATIAN ++ LangIDValue(19,0,0) = "hr" ++ LangIDValue(19,0,1) = "HR" ++ LangIDValue(19,0,2) = "-41A" ++ + End Sub + + +@@ -572,6 +579,15 @@ Dim i as Integer + CurrValue(18,4) = "Lt" + CurrValue(18,5) = "LTL" + ++ CurrValue(19,0) = sCurrCROATIAN ++ ' real conversion rate ++ CurrValue(19,1) = 7.53450 ++ ' rounded conversion rate ++ CurrValue(19,2) = 7.5 ++ CurrValue(19,3) = "kn" ++ CurrValue(19,4) = "kn" ++ CurrValue(19,5) = "HRK" ++ + i = -1 + CurrSymbolList(0) = "" + CurrSymbolList(1) = "" +diff --git a/wizards/source/resources/resources_en_US.properties b/wizards/source/resources/resources_en_US.properties +index 32f9104e97e0..8649b2500e6a 100644 +--- a/wizards/source/resources/resources_en_US.properties ++++ b/wizards/source/resources/resources_en_US.properties +@@ -448,6 +448,7 @@ CURRENCIES_15=Slovak Koruna + CURRENCIES_16=Estonian Kroon + CURRENCIES_17=Latvian Lats + CURRENCIES_18=Lithuanian Litas ++CURRENCIES_19=Croatian Kuna + STEP_LASTPAGE_0=Progress + STEP_LASTPAGE_1=Retrieving the relevant documents... + STEP_LASTPAGE_2=Converting the documents... +-- +cgit v1.2.1 + diff --git a/debian/patches/ignore-LO-special-purpose-hyperlinks-per-default.diff b/debian/patches/ignore-LO-special-purpose-hyperlinks-per-default.diff new file mode 100644 index 000000000..1c7a7edb5 --- /dev/null +++ b/debian/patches/ignore-LO-special-purpose-hyperlinks-per-default.diff @@ -0,0 +1,237 @@ +From f9c43426ab2941d240213a50bf67d70d85e3f060 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Fri, 3 Nov 2023 17:26:25 +0000 +Subject: default to ignoring libreoffice special-purpose protocols in calc + hyperlink +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: Ib9f62be3acc05f24ca234dec0fec21e24579e9de +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158911 +Tested-by: Jenkins +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit b6062623b4d69c79e90e9365ac7c5e7f11986793) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159045 +Reviewed-by: Eike Rathke +(cherry picked from commit 672716d09c54cb6fdd59baa7da4b8393cf104cd2) +--- + dbaccess/source/core/dataaccess/ModelImpl.cxx | 3 ++- + include/sfx2/docmacromode.hxx | 4 ++- + include/sfx2/objsh.hxx | 3 +++ + include/sfx2/strings.hrc | 1 + + sc/source/core/data/global.cxx | 35 ++++++++++++++++++++++++++- + sfx2/source/doc/docmacromode.cxx | 8 ++++-- + sfx2/source/doc/objmisc.cxx | 8 +++++- + sfx2/source/doc/objxtor.cxx | 1 + + sfx2/source/inc/objshimp.hxx | 3 ++- + 9 files changed, 59 insertions(+), 7 deletions(-) + +diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx +index 21e45033ea4f..20e77a97cc8e 100644 +--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx ++++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx +@@ -1142,7 +1142,8 @@ bool ODatabaseModelImpl::checkMacrosOnLoading() + { + Reference< XInteractionHandler > xInteraction; + xInteraction = m_aMediaDescriptor.getOrDefault( "InteractionHandler", xInteraction ); +- return m_aMacroMode.checkMacrosOnLoading( xInteraction ); ++ const bool bHasMacros = m_aMacroMode.hasMacros(); ++ return m_aMacroMode.checkMacrosOnLoading(xInteraction, false /*HasValidContentSignature*/, bHasMacros); + } + + void ODatabaseModelImpl::resetMacroExecutionMode() +diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx +index bd4f13fb016c..0cfca92db308 100644 +--- a/include/sfx2/docmacromode.hxx ++++ b/include/sfx2/docmacromode.hxx +@@ -261,6 +261,8 @@ namespace sfx2 + */ + static bool storageHasMacros( const css::uno::Reference< css::embed::XStorage >& _rxStorage ); + ++ bool hasMacros() const; ++ + static bool containerHasBasicMacros( const css::uno::Reference< css::script::XLibraryContainer >& xContainter ); + /** checks the macro execution mode while loading the document. + +@@ -288,7 +290,7 @@ namespace sfx2 + bool + checkMacrosOnLoading( + const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, +- bool bHasValidContentSignature = false ++ bool bHasValidContentSignature, bool bHasMacros + ); + + private: +diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx +index 2a56ebe88e07..43df4605fe1d 100644 +--- a/include/sfx2/objsh.hxx ++++ b/include/sfx2/objsh.hxx +@@ -418,6 +418,9 @@ public: + void SetMacroCallsSeenWhileLoading(); + bool GetMacroCallsSeenWhileLoading() const; + ++ // true if the document had macros (or similar) on load to trigger warning user ++ bool GetHadCheckedMacrosOnLoad() const; ++ + const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const; + bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo ); + +diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc +index 1db36e733c0c..29950ba68ca1 100644 +--- a/include/sfx2/strings.hrc ++++ b/include/sfx2/strings.hrc +@@ -103,6 +103,7 @@ + #define STR_GB NC_("STR_GB", "GB") + #define STR_QUERY_LASTVERSION NC_("STR_QUERY_LASTVERSION", "Cancel all changes?") + #define STR_NO_WEBBROWSER_FOUND NC_("STR_NO_WEBBROWSER_FOUND", "Opening \"$(ARG1)\" failed with error code $(ARG2) and message: \"$(ARG3)\"\nMaybe no web browser could be found on your system. In that case, please check your Desktop Preferences or install a web browser (for example, Firefox) in the default location requested during the browser installation.") ++#define STR_DANGEROUS_TO_OPEN NC_("STR_DANGEROUS_TO_OPEN", "It might be dangerous to open \"$(ARG1)\".\nDo you really want to open it?") + #define STR_NO_ABS_URI_REF NC_("STR_NO_ABS_URI_REF", "\"$(ARG1)\" is not an absolute URL that can be passed to an external application to open it.") + #define STR_GID_INTERN NC_("STR_GID_INTERN", "Internal") + #define STR_GID_APPLICATION NC_("STR_GID_APPLICATION", "Application") +diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx +index 050fd823b4ee..9696f7d9414d 100644 +--- a/sc/source/core/data/global.cxx ++++ b/sc/source/core/data/global.cxx +@@ -26,7 +26,9 @@ + #include + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -37,6 +39,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -789,7 +793,7 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno + + OUString aUrlName( rURL ); + SfxViewFrame* pFrame = nullptr; +- const SfxObjectShell* pObjShell = nullptr; ++ SfxObjectShell* pObjShell = nullptr; + OUString aReferName; + if ( pScActiveViewShell ) + { +@@ -823,6 +827,35 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno + aUrlName = aNewUrlName; + } + ++ if (INetURLObject(aUrlName).IsExoticProtocol()) ++ { ++ // Default to ignoring exotic protocols ++ bool bAllow = false; ++ if (pObjShell) ++ { ++ // If the document had macros when loaded then follow the allowed macro-mode ++ if (pObjShell->GetHadCheckedMacrosOnLoad()) ++ bAllow = pObjShell->AdjustMacroMode(); ++ else // otherwise ask the user, defaulting to cancel ++ { ++ assert(pFrame && "if we have pObjShell we have pFrame"); ++ //Reuse URITools::onOpenURI warning string ++ std::unique_ptr xQueryBox(Application::CreateMessageDialog(pFrame->GetWindow().GetFrameWeld(), ++ VclMessageType::Warning, VclButtonsType::YesNo, ++ SfxResId(STR_DANGEROUS_TO_OPEN))); ++ xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)", ++ INetURLObject::decode(aUrlName, INetURLObject::DecodeMechanism::Unambiguous))); ++ xQueryBox->set_default_response(RET_NO); ++ bAllow = xQueryBox->run() == RET_YES; ++ } ++ } ++ if (!bAllow) ++ { ++ SAL_WARN("sc", "ScGlobal::OpenURL ignoring: " << aUrlName); ++ return; ++ } ++ } ++ + SfxStringItem aUrl( SID_FILE_NAME, aUrlName ); + SfxStringItem aTarget( SID_TARGETNAME, rTarget ); + if ( nScClickMouseModifier & KEY_SHIFT ) // control-click -> into new window +diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx +index 4d15ad30cb01..50782c3cd1b2 100644 +--- a/sfx2/source/doc/docmacromode.cxx ++++ b/sfx2/source/doc/docmacromode.cxx +@@ -458,8 +458,12 @@ namespace sfx2 + return bHasMacros; + } + ++ bool DocumentMacroMode::hasMacros() const ++ { ++ return m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading(); ++ } + +- bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) ++ bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature, bool bHasMacros ) + { + bool bAllow = false; + if ( SvtSecurityOptions().IsMacroDisabled() ) +@@ -469,7 +473,7 @@ namespace sfx2 + } + else + { +- if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) ++ if (bHasMacros) + { + if (m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) + m_bNeedsContentSigned = true; +diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx +index f71358b568fa..c7418ef127fd 100644 +--- a/sfx2/source/doc/objmisc.cxx ++++ b/sfx2/source/doc/objmisc.cxx +@@ -954,9 +954,15 @@ void SfxObjectShell::CheckSecurityOnLoading_Impl() + + // check macro security + const bool bHasValidContentSignature = HasValidSignatures(); +- pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature ); ++ const bool bHasMacros = pImpl->aMacroMode.hasMacros(); ++ pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature, bHasMacros ); ++ pImpl->m_bHadCheckedMacrosOnLoad = bHasMacros; + } + ++bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const ++{ ++ return pImpl->m_bHadCheckedMacrosOnLoad; ++} + + void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) + { +diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx +index 510c35daf59f..a707bb7c4a27 100644 +--- a/sfx2/source/doc/objxtor.cxx ++++ b/sfx2/source/doc/objxtor.cxx +@@ -237,6 +237,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) + ,m_bAllowShareControlFileClean( true ) + ,m_bConfigOptionsChecked( false ) + ,m_bMacroCallsSeenWhileLoading( false ) ++ ,m_bHadCheckedMacrosOnLoad( false ) + ,lErr(ERRCODE_NONE) + ,nEventId ( SfxEventHintId::NONE ) + ,nLoadedFlags ( SfxLoadedFlags::ALL ) +diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx +index 3d7b0b69c945..4afdd706d05e 100644 +--- a/sfx2/source/inc/objshimp.hxx ++++ b/sfx2/source/inc/objshimp.hxx +@@ -91,7 +91,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess + m_bSharedXMLFlag:1, // whether the document should be edited in shared mode + m_bAllowShareControlFileClean:1, // whether the flag should be stored in xml file + m_bConfigOptionsChecked:1, // whether or not the user options are checked after the Options dialog is closed. +- m_bMacroCallsSeenWhileLoading:1; // whether or not the user options are checked after the Options dialog is closed. ++ m_bMacroCallsSeenWhileLoading:1, // whether or not macro calls were seen when loading document. ++ m_bHadCheckedMacrosOnLoad:1; // if document contained macros (or calls) when loaded + + IndexBitSet aBitSet; + ErrCode lErr; +-- +cgit v1.2.1 + diff --git a/debian/patches/improve-macro-checks.diff b/debian/patches/improve-macro-checks.diff new file mode 100644 index 000000000..920b2fb17 --- /dev/null +++ b/debian/patches/improve-macro-checks.diff @@ -0,0 +1,145 @@ +diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx +index 9533518bee9d..aa120240688e 100644 +--- a/include/sfx2/docmacromode.hxx ++++ b/include/sfx2/docmacromode.hxx +@@ -220,7 +220,8 @@ namespace sfx2 + if and only if macro execution in this document is allowed. + */ + bool adjustMacroMode( +- const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction ++ const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, ++ bool bHasValidContentSignature = false + ); + + /** determines whether macro execution is disallowed +@@ -286,11 +287,13 @@ namespace sfx2 + */ + bool + checkMacrosOnLoading( +- const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction ++ const css::uno::Reference< css::task::XInteractionHandler >& _rxInteraction, ++ bool bHasValidContentSignature = false + ); + + private: + std::shared_ptr< DocumentMacroMode_Data > m_xData; ++ bool m_bNeedsContentSigned; + }; + + +diff --git a/include/svtools/sfxecode.hxx b/include/svtools/sfxecode.hxx +index a57c6b9e966f..fe6f26dc3623 100644 +--- a/include/svtools/sfxecode.hxx ++++ b/include/svtools/sfxecode.hxx +@@ -36,6 +36,7 @@ class ErrCode; + #define ERRCODE_SFX_CANTCREATEBACKUP ErrCode(ErrCodeArea::Sfx, ErrCodeClass::Create, 50) + #define ERRCODE_SFX_MACROS_SUPPORT_DISABLED ErrCode(WarningFlag::Yes, ErrCodeArea::Sfx, ErrCodeClass::NONE, 51) + #define ERRCODE_SFX_DOCUMENT_MACRO_DISABLED ErrCode(WarningFlag::Yes, ErrCodeArea::Sfx, ErrCodeClass::NONE, 52) ++#define ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_CONTENT_UNSIGNED ErrCode(WarningFlag::Yes, ErrCodeArea::Sfx, ErrCodeClass::NONE, 53) + #define ERRCODE_SFX_SHARED_NOPASSWORDCHANGE ErrCode(WarningFlag::Yes, ErrCodeArea::Sfx, ErrCodeClass::NONE, 54) + #define ERRCODE_SFX_INCOMPLETE_ENCRYPTION ErrCode(WarningFlag::Yes, ErrCodeArea::Sfx, ErrCodeClass::NONE, 55) + #define ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_MAC \ +diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx +index bbb3b629de2b..c49f7cec00c6 100644 +--- a/sfx2/source/doc/docmacromode.cxx ++++ b/sfx2/source/doc/docmacromode.cxx +@@ -111,6 +111,10 @@ namespace sfx2 + #endif + } + ++ void lcl_showMacrosDisabledUnsignedContentError( const Reference< XInteractionHandler >& rxHandler, bool& rbAlreadyShown ) ++ { ++ lcl_showGeneralSfxErrorOnce( rxHandler, ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_CONTENT_UNSIGNED, rbAlreadyShown ); ++ } + + bool lcl_showMacroWarning( const Reference< XInteractionHandler >& rxHandler, + const OUString& rDocumentLocation ) +@@ -123,7 +127,8 @@ namespace sfx2 + + //= DocumentMacroMode + DocumentMacroMode::DocumentMacroMode( IMacroDocumentAccess& rDocumentAccess ) +- :m_xData( std::make_shared( rDocumentAccess ) ) ++ :m_xData( std::make_shared( rDocumentAccess ) ), ++ m_bNeedsContentSigned(false) + { + } + +@@ -139,7 +144,7 @@ namespace sfx2 + return false; + } + +- bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& rxInteraction ) ++ bool DocumentMacroMode::adjustMacroMode( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) + { + sal_uInt16 nMacroExecutionMode = m_xData->m_rDocumentAccess.getCurrentMacroExecMode(); + +@@ -237,6 +242,14 @@ namespace sfx2 + lcl_showDocumentMacrosDisabledError(rxInteraction, m_xData->m_bDocMacroDisabledMessageShown); + return disallowMacroExecution(); + } ++ else if ( m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading() && ++ bHasTrustedMacroSignature && ++ !bHasValidContentSignature) ++ { ++ // When macros are signed, and the document has events which call macros, the document content needs to be signed too. ++ lcl_showMacrosDisabledUnsignedContentError(rxInteraction, m_xData->m_bDocMacroDisabledMessageShown); ++ return disallowMacroExecution(); ++ } + else if ( bHasTrustedMacroSignature ) + { + // there is trusted macro signature, allow macro execution +@@ -391,7 +404,7 @@ namespace sfx2 + } + + +- bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction ) ++ bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) + { + bool bAllow = false; + if ( SvtSecurityOptions().IsMacroDisabled() ) +@@ -403,7 +416,9 @@ namespace sfx2 + { + if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) + { +- bAllow = adjustMacroMode( rxInteraction ); ++ if (m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) ++ m_bNeedsContentSigned = true; ++ bAllow = adjustMacroMode( rxInteraction, bHasValidContentSignature ); + } + else if ( !isMacroExecutionDisallowed() ) + { +diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx +index 81fcb4027535..5148ed0c62b6 100644 +--- a/sfx2/source/doc/objmisc.cxx ++++ b/sfx2/source/doc/objmisc.cxx +@@ -942,7 +942,8 @@ void SfxObjectShell::CheckSecurityOnLoading_Impl() + CheckEncryption_Impl( xInteraction ); + + // check macro security +- pImpl->aMacroMode.checkMacrosOnLoading( xInteraction ); ++ const bool bHasValidContentSignature = HasValidSignatures(); ++ pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature ); + } + + +@@ -1598,7 +1599,7 @@ bool SfxObjectShell::AdjustMacroMode() + + CheckEncryption_Impl( xInteraction ); + +- return pImpl->aMacroMode.adjustMacroMode( xInteraction ); ++ return pImpl->aMacroMode.adjustMacroMode( xInteraction, true /*TODO*/ ); + } + + vcl::Window* SfxObjectShell::GetDialogParent( SfxMedium const * pLoadingMedium ) +diff --git a/svtools/inc/errtxt.hrc b/svtools/inc/errtxt.hrc +index 9847148d4c3d..009badd70b54 100644 +--- a/svtools/inc/errtxt.hrc ++++ b/svtools/inc/errtxt.hrc +@@ -119,6 +119,7 @@ const ErrMsgCode RID_ERRHDL[] = + { NC_("RID_ERRHDL", "The maximum number of documents that can be opened at the same time has been reached. You need to close one or more documents before you can open a new document."), ERRCODE_SFX_NOMOREDOCUMENTSALLOWED }, + { NC_("RID_ERRHDL", "Could not create backup copy.") , ERRCODE_SFX_CANTCREATEBACKUP }, + { NC_("RID_ERRHDL", "An attempt was made to execute a macro.\nFor security reasons, macro support is disabled."), ERRCODE_SFX_MACROS_SUPPORT_DISABLED }, ++ { NC_("RID_ERRHDL", "Execution of macros is disabled. Macros are signed, but the document (containing document events) is not signed."), ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_CONTENT_UNSIGNED }, + { NC_("RID_ERRHDL", "This document contains macros.\n\nMacros may contain viruses. Execution of macros is disabled due to the current macro security setting in %PRODUCTNAME - Preferences - %PRODUCTNAME - Security.\n\nTherefore, some functionality may not be available.") , ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_MAC }, + { NC_("RID_ERRHDL", "This document contains macros.\n\nMacros may contain viruses. Execution of macros is disabled due to the current macro security setting in Tools - Options - %PRODUCTNAME - Security.\n\nTherefore, some functionality may not be available.") , ERRCODE_SFX_DOCUMENT_MACRO_DISABLED }, + { NC_("RID_ERRHDL", "The encrypted document contains unexpected non-encrypted streams.\n\nThis could be the result of document manipulation.\n\nWe recommend that you do not trust the content of the current document.\nExecution of macros is disabled for this document.\n ") , ERRCODE_SFX_INCOMPLETE_ENCRYPTION }, diff --git a/debian/patches/install-fixes.diff b/debian/patches/install-fixes.diff new file mode 100644 index 000000000..891bb321c --- /dev/null +++ b/debian/patches/install-fixes.diff @@ -0,0 +1,166 @@ +diff --git a/bin/distro-install-file-lists b/bin/distro-install-file-lists +index eaabf9c..c1b1ec6 100755 +--- libreoffice-3.5.0/bin/distro-install-file-lists ++++ libreoffice-3.5.0/bin/distro-install-file-lists +@@ -8,6 +8,8 @@ + exit 1 + fi + ++export OOO_VENDOR=Debian ++ + BUILDDIR=`pwd` + FILELISTSDIR="$BUILDDIR/file-lists" + +@@ -351,152 +351,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then + remove_duplicity_from_flists common_list.txt lang_bg_list.txt $INSTALLDIR/presets/config/styles.sod + # the British fixes can be removed after the issue #54113 is fixed + remove_duplicity_from_flists common_list.txt lang_en-GB_list.txt $INSTALLDIR/presets/config/standard.sog +- +-else +- +- echo "Creating package directories..." +- +- test -d pkg && rm -r pkg || : +- +- # Create package tree (needed by Debian's dpkg) +- # create_package_directory +- create_package_directory() +- { +- listfile=$1 +- directory="$2" +- perl -nl \ +- -e " if(/^%dir (.*)/) +- {system('mkdir', '-p', '-m', '755', \"$directory\".\$1);} +- else +- {rename('./'.\$_, \"$directory\".\$_);} +- " \ +- $listfile +- } +- +- create_package_directory gid_Module_Root_Ure_Hidden pkg/ure +- +- create_package_directory gid_Module_Root pkg/libreoffice-common +- create_package_directory gid_Module_Root_Brand pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_Images pkg/libreoffice-common +- create_package_directory gid_Module_Oo_Linguistic pkg/libreoffice-common +- create_package_directory gid_Module_Optional_Xsltfiltersamples pkg/libreoffice-common +- create_package_directory gid_Module_Optional_Grfflt pkg/libreoffice-draw +- create_package_directory gid_Module_Prg_Calc_Bin pkg/libreoffice-calc +- create_package_directory gid_Module_Prg_Math_Bin pkg/libreoffice-math +- create_package_directory gid_Module_Prg_Draw_Bin pkg/libreoffice-draw +- create_package_directory gid_Module_Prg_Wrt_Bin pkg/libreoffice-writer +- create_package_directory gid_Module_Prg_Impress_Bin pkg/libreoffice-impress +- create_package_directory gid_Module_Prg_Base_Bin pkg/libreoffice-base +- create_package_directory gid_Module_Brand_Prg_Calc pkg/libreoffice-calc +- create_package_directory gid_Module_Brand_Prg_Math pkg/libreoffice-math +- create_package_directory gid_Module_Brand_Prg_Draw pkg/libreoffice-draw +- create_package_directory gid_Module_Brand_Prg_Wrt pkg/libreoffice-writer +- create_package_directory gid_Module_Brand_Prg_Impress pkg/libreoffice-impress +- create_package_directory gid_Module_Brand_Prg_Base pkg/libreoffice-base +- create_package_directory gid_Module_Pyuno pkg/python-uno +- create_package_directory gid_Module_Optional_Gnome pkg/libreoffice-gnome +- +- create_package_directory gid_Module_Root_Files_2 pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_3 pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_4 pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_5 pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_6 pkg/libreoffice-common +- create_package_directory gid_Module_Root_Files_7 pkg/libreoffice-common +- if [ -e gid_Module_Optional_Pymailmerge ]; then +- create_package_directory gid_Module_Optional_Pymailmerge pkg/libreoffice-emailmerge +- else # post m26 +- mkdir -p pkg/libreoffice-emailmerge/$INSTALLDIR/program +- mv pkg/libreoffice-common/$INSTALLDIR/program/mailmerge.py \ +- pkg/libreoffice-emailmerge/$INSTALLDIR/program/mailmerge.py +- fi +- create_package_directory gid_Module_Optional_OGLTrans pkg/libreoffice-ogltrans +- +- create_package_directory gid_Module_Root_SDK pkg/libreoffice-dev +- +- for l in `echo $WITH_LANG_LIST`; do +- for p in Impress Draw Math Calc Base Writer; do +- create_package_directory gid_Module_Langpack_${p}_`echo $l | sed -e s/-/_/g` pkg/libreoffice-l10n-$l +- done +- create_package_directory gid_Module_Langpack_Basis_`echo $l | sed -e s/-/_/g` pkg/libreoffice-l10n-$l +- create_package_directory gid_Module_Langpack_Brand_`echo $l | sed -e s/-/_/g` pkg/libreoffice-l10n-$l +- create_package_directory gid_Module_Langpack_Resource_`echo $l | sed -e s/-/_/g` pkg/libreoffice-l10n-$l +- create_package_directory gid_Module_Helppack_Help_`echo $l | sed -e s/-/_/g` pkg/libreoffice-help-$l +- +- # some help files are in _Langpack_{Writer,Impress,...}_ +- # move them from -l10n to -help +- if [ "$l" = "en-US" ]; then d=en; else d=$l; fi +- mv pkg/libreoffice-l10n-$l/$INSTALLDIR/help/$d/* \ +- pkg/libreoffice-help-$l/$INSTALLDIR/help/$d && \ +- rmdir pkg/libreoffice-l10n-$l/$INSTALLDIR/help/$d +- done +- +- # move_wrappers [...] +- move_wrappers() +- { +- directory=$1 +- shift +- mkdir -m755 -p "$directory"/usr/bin +- while test -n "$1"; do +- mv usr/*bin/"$1$BINSUFFIX" "$directory"/usr/bin +- shift +- done +- } +- move_wrappers pkg/libreoffice-common soffice unopkg +- if test "$COMPAT_OOWRAPPERS" = "YES" ; then +- move_wrappers pkg/libreoffice-common ooffice oofromtemplate +- move_wrappers pkg/libreoffice-base oobase +- move_wrappers pkg/libreoffice-writer oowriter ooweb +- move_wrappers pkg/libreoffice-calc oocalc +- move_wrappers pkg/libreoffice-impress ooimpress +- move_wrappers pkg/libreoffice-math oomath +- move_wrappers pkg/libreoffice-draw oodraw +- fi +- move_wrappers pkg/libreoffice-common libreoffice lofromtemplate +- move_wrappers pkg/libreoffice-base lobase +- move_wrappers pkg/libreoffice-writer lowriter loweb +- move_wrappers pkg/libreoffice-calc localc +- move_wrappers pkg/libreoffice-impress loimpress +- move_wrappers pkg/libreoffice-math lomath +- move_wrappers pkg/libreoffice-draw lodraw +- +- # Move all libraries, binaries, *.rdb from -common to -core +- for d in $INSTALLDIR/program $INSTALLDIR/program; do \ +- if [ ! -d $DESTDIR/pkg/libreoffice-core/$d ]; then \ +- mkdir -p $DESTDIR/pkg/libreoffice-core/$d; \ +- fi && +- ( cd pkg/libreoffice-common/$d +- find -maxdepth 1 \ +- -regex '\./\(.*\.so.*\|.*\.bin\|pagein\|msfontextract\|.*\.rdb\|javaldx\|uri-encode\)' \ +- -exec mv {} $DESTDIR/pkg/libreoffice-core/$d \; +- ); \ +- done +- +- # install additional ooo-build scripts & misc stuff +- mkdir -p pkg/libreoffice-common/usr/share/man/man1 +- if test "$COMPAT_OOWRAPPERS" = "YES" ; then +- mv usr/share/man/man1/openoffice$BINSUFFIX.1 \ +- pkg/libreoffice-common/usr/share/man/man1 +- fi +- mv usr/share/man/man1/libreoffice$BINSUFFIX.1 \ +- pkg/libreoffice-common/usr/share/man/man1 +- mkdir -p pkg/libreoffice-common/etc/bash_completion.d +- if test "$COMPAT_OOWRAPPERS" = "YES" ; then +- mv etc/bash_completion.d/ooffice$BINSUFFIX.sh \ +- pkg/libreoffice-common/etc/bash_completion.d +- fi +- mv etc/bash_completion.d/libreoffice$BINSUFFIX.sh \ +- pkg/libreoffice-common/etc/bash_completion.d +- mv .$INSTALLDIR/program/java-set-classpath \ +- pkg/libreoffice-common/$INSTALLDIR/program +- if echo $WITH_LANG_LIST | grep -q en-US; then +- for i in forms/resume.ott officorr/project-proposal.ott; do \ +- mkdir -p pkg/libreoffice-common/$INSTALLDIR/share/template/en-US/`dirname $i`; \ +- mv .$INSTALLDIR/share/template/en-US/$i \ +- pkg/libreoffice-common/$INSTALLDIR/share/template/en-US/$i; \ +- done; \ +- fi +- # Warn for any remaining files +- find . -path './pkg' -prune -o -not -name 'gid_Module_*' -not -type d -exec echo "File not packaged: {}" \; + fi + + # mark the config files diff --git a/debian/patches/javadoc-optional.diff b/debian/patches/javadoc-optional.diff new file mode 100644 index 000000000..704ae20ec --- /dev/null +++ b/debian/patches/javadoc-optional.diff @@ -0,0 +1,153 @@ +Gemeinsame Unterverzeichnisse: odk-old/config und odk/config. +Gemeinsame Unterverzeichnisse: odk-old/docs und odk/docs. +Gemeinsame Unterverzeichnisse: odk-old/examples und odk/examples. +diff --git a/odk/Module_odk.mk b/odk/Module_odk.mk +index 32bdfc1..a174932 100644 +--- a/odk/Module_odk.mk ++++ b/odk/Module_odk.mk +@@ -43,11 +43,13 @@ ifneq ($(ENABLE_JAVA),) + $(eval $(call gb_Module_add_targets,odk,\ + $(if $(and $(BUILD_UNOWINREG),$(filter GCC,$(COM))),CustomTarget_unowinreg)\ + CustomTarget_classes \ +- CustomTarget_javadoc \ +- GeneratedPackage_odk_javadoc \ + GeneratedPackage_uno_loader_classes \ + $(if $(filter WNT,$(OS)),Library_unowinreg) \ + Package_unowinreg \ ++ $(if $(JAVADOC),\ ++ CustomTarget_javadoc \ ++ GeneratedPackage_odk_javadoc \ ++ ) \ + )) + endif + +Gemeinsame Unterverzeichnisse: odk-old/pack und odk/pack. +Gemeinsame Unterverzeichnisse: odk-old/qa und odk/qa. +Gemeinsame Unterverzeichnisse: odk-old/settings und odk/settings. +Gemeinsame Unterverzeichnisse: odk-old/source und odk/source. +Gemeinsame Unterverzeichnisse: odk-old/util und odk/util. +--- a/configure.ac-old 2013-05-27 18:32:42.187305241 +0200 ++++ b/configure.ac 2013-05-27 18:44:29.131286710 +0200 +@@ -2057,6 +2057,18 @@ AC_ARG_WITH(doxygen, + documentation. Not relevant in the --disable-odk case.]), + ,with_doxygen=yes) + ++AC_ARG_WITH( ++ [javadoc], ++ AS_HELP_STRING( ++ [--with-javadoc], ++ [Specifies the javadoc executable to use when generating ODK Java ++ documentation. --without-javadoc disables generation of ODK Java ++ documentation. Not relevant in the --disable-odk case.]) ++ [ ++ Usage: --with-javadoc= ++ ],, ++ [with_javadoc=yes]) ++ + AC_ARG_WITH(visual-studio, + AS_HELP_STRING([--with-visual-studio=<2019>], + [Specify which Visual Studio version to use in case several are +@@ -6290,34 +6302,44 @@ + dnl =================================================================== + dnl Checks for javadoc + dnl =================================================================== +-if test "$ENABLE_JAVA" != ""; then ++if test "$ENABLE_JAVA" != "" -a "$enable_odk" != no; then + if test -z "$with_jdk_home"; then + AC_PATH_PROG(JAVADOC, javadoc) + else +- _javadoc_path="$with_jdk_home/bin/javadoc" +- dnl Check if there is a javadoc at all. +- if test -x "$_javadoc_path"; then +- JAVADOC=$_javadoc_path +- else +- AC_PATH_PROG(JAVADOC, javadoc) +- fi +- fi +- if test -z "$JAVADOC"; then +- AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home]) +- fi +- if test "$build_os" = "cygwin"; then +- if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then +- JAVADOC="${JAVADOC}.exe" +- fi +- JAVADOC=`win_short_path_for_make "$JAVADOC"` +- fi ++ if test "$with_javadoc" = "yes"; then ++ _javadoc_path="$with_jdk_home/bin/javadoc" ++ dnl Check if there is a javadoc at all. ++ if test -x "$_javadoc_path"; then ++ JAVADOC=$_javadoc_path ++ else ++ AC_PATH_PROG(JAVADOC, javadoc) ++ fi ++ if test -z "$JAVADOC"; then ++ AC_MSG_ERROR([$_javadoc_path not found set with_jdk_home]) ++ fi ++ if test "$build_os" = "cygwin"; then ++ if test x`echo "$JAVADOC" | $GREP -i '\.exe$'` = x; then ++ JAVADOC="${JAVADOC}.exe" ++ fi ++ JAVADOC=`win_short_path_for_make "$JAVADOC"` ++ fi + +- if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then +- JAVADOCISGJDOC="yes" ++ if test `$JAVADOC --version 2>&1 | $GREP -c "gjdoc"` -gt 0; then ++ JAVADOCISGJDOC="yes" ++ fi ++ else ++ unset JAVADOC ++ fi + fi ++else ++ unset JAVADOC + fi + AC_SUBST(JAVADOCISGJDOC) + ++if test "$JAVADOCISGJDOC" = "yes"; then ++ unset JAVADOC ++fi ++ + if test "$ENABLE_JAVA" != ""; then + # check if JAVA_HOME was (maybe incorrectly?) set automatically to /usr + if test "$JAVA_HOME" = "/usr" -a "x$with_jdk_home" = "x"; then +diff --git a/odk/CustomTarget_check.mk b/odk/CustomTarget_check.mk +index a9b542d..707829a 100644 +--- a/odk/CustomTarget_check.mk ++++ b/odk/CustomTarget_check.mk +@@ -35,7 +35,7 @@ $(call gb_CustomTarget_get_workdir,odk/check)/checkbin : \ + $(if $(filter WNT,$(OS)),$(call gb_Package_get_target,odk_config_win)) \ + $(call gb_Package_get_target,odk_docs) \ + $(call gb_Package_get_target,odk_html) \ +- $(if $(ENABLE_JAVA),$(call gb_GeneratedPackage_get_target,odk_javadoc)) \ ++ $(if $(JAVADOC),$(call gb_GeneratedPackage_get_target,odk_javadoc)) \ + $(call gb_Package_get_target,odk_settings) \ + $(call gb_Package_get_target,odk_settings_generated) \ + $(if $(ENABLE_JAVA),$(call gb_Package_get_target,odk_unowinreg)) +diff --git a/odk/util/check.pl b/odk/util/check.pl +index 899b42c..2c7a780 100644 +--- a/odk/util/check.pl ++++ b/odk/util/check.pl +@@ -188,7 +188,7 @@ if (-d "$SdkDir") { + # improvement required + my $solar_java = $ENV{"ENABLE_JAVA"}; + my $JDK = $ENV{"JDK"}; +- if (defined($solar_java) && $solar_java ne "" && (!defined($JDK) || $JDK ne "gcj")) { ++ if (defined($solar_java) && $solar_java ne "" && $ENV{"JAVADOC"} ne "") { + print "check java docu: "; + if (check_dir("docs/java/ref")) { + if (!check_file("docs/java/ref/index.html")) { +diff --git a/Repository.mk b/Repository.mk +index 5f2654b..471210f 100644 +--- a/Repository.mk ++++ b/Repository.mk +@@ -834,7 +841,7 @@ $(eval $(call gb_Helper_register_packages_for_install,sdk,\ + offapi_idl \ + udkapi_idl \ + $(if $(ENABLE_JAVA), \ +- odk_javadoc \ ++ $(if $(JAVADOC),odk_javadoc) \ + odk_uno_loader_classes \ + odk_unowinreg \ + ) \ diff --git a/debian/patches/jdbc-driver-classpaths.diff b/debian/patches/jdbc-driver-classpaths.diff new file mode 100644 index 000000000..8f4a1660e --- /dev/null +++ b/debian/patches/jdbc-driver-classpaths.diff @@ -0,0 +1,35 @@ +diff --git a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu +index 9be30a2..59c87cb 100644 +--- a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu ++++ b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu +@@ -147,6 +147,30 @@ + + + ++ ++ ++ ++ ++ file:///usr/share/java/mariadb-java-client.jar ++ ++ ++ ++ ++ file:///usr/share/java/mysql.jar ++ ++ ++ ++ ++ file:///usr/share/java/posgresql.jar ++ ++ ++ ++ ++ file:///usr/share/java/jtds.jar ++ ++ ++ ++ + + + diff --git a/debian/patches/jurt-soffice-location.diff b/debian/patches/jurt-soffice-location.diff new file mode 100644 index 000000000..aa334d8ea --- /dev/null +++ b/debian/patches/jurt-soffice-location.diff @@ -0,0 +1,20 @@ +commit b71107fb12e3c3125e0cb62c5a4f6636a80c6408 +Author: Bjoern Michaelsen +AuthorDate: Tue Jun 7 11:52:37 2011 +0200 +Commit: Bjoern Michaelsen +CommitDate: Tue Jun 7 11:52:37 2011 +0200 + + on debian-based systems, we know where our soffice binary is + +diff --git a/jurt/com/sun/star/lib/util/NativeLibraryLoader.java b/jurt/com/sun/star/lib/util/NativeLibraryLoader.jav +index da22980..36664ca 100644 +--- libreoffice-3.5.0/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java ++++ libreoffice-3.5.0/ridljar/com/sun/star/lib/util/NativeLibraryLoader.java +@@ -111,6 +111,8 @@ public final class NativeLibraryLoader { + } + } + } ++ if (name.equals("soffice")) ++ return new File("/usr/lib/libreoffice/program/soffice"); + return null; + } diff --git a/debian/patches/liborcus-0.16.diff b/debian/patches/liborcus-0.16.diff new file mode 100644 index 000000000..a544ec7ca --- /dev/null +++ b/debian/patches/liborcus-0.16.diff @@ -0,0 +1,1255 @@ +From 109ed8f775dddfede012d56d078abd70b45490c0 Mon Sep 17 00:00:00 2001 +From: Kohei Yoshida +Date: Wed, 9 Sep 2020 21:23:48 -0400 +Subject: Upgrade liborcus to 0.16.0. + +Change-Id: Iae29fb26417dfc161698a81bee84e81545969065 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102502 +Tested-by: Jenkins +Reviewed-by: Kohei Yoshida +--- + RepositoryExternal.mk | 4 +- + configure.ac | 2 +- + download.lst | 4 +- + ...1-Mark-all-untentionally-unused-variables.patch | 376 +++++++++++++++++++++ + external/liborcus/ExternalPackage_liborcus.mk | 8 +- + external/liborcus/ExternalProject_liborcus.mk | 4 +- + external/liborcus/Library_orcus-parser.mk | 1 + + external/liborcus/Library_orcus.mk | 4 + + external/liborcus/UnpackedTarball_liborcus.mk | 1 + + external/liborcus/libtool.patch.0 | 10 +- + external/liborcus/windows-constants-hack.patch | 2 +- + sc/source/filter/inc/orcusinterface.hxx | 21 +- + sc/source/filter/orcus/interface.cxx | 82 +++-- + sc/source/filter/orcus/xmlcontext.cxx | 7 +- + sc/source/ui/xmlsource/xmlsourcedlg.cxx | 6 +- + 15 files changed, 480 insertions(+), 52 deletions(-) + create mode 100644 external/liborcus/0001-Mark-all-untentionally-unused-variables.patch + +diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk +index d9fa980d7f24..1f0a91de142a 100644 +--- a/RepositoryExternal.mk ++++ b/RepositoryExternal.mk +@@ -3270,7 +3270,7 @@ $(call gb_LinkTarget_set_include,$(1),\ + ) + + $(call gb_LinkTarget_add_libs,$(1),\ +- -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.15 \ ++ -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.16 \ + ) + + $(if $(SYSTEM_BOOST), \ +@@ -3289,7 +3289,7 @@ $(call gb_LinkTarget_set_include,$(1),\ + ) + + $(call gb_LinkTarget_add_libs,$(1),\ +- -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.15 \ ++ -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.16 \ + ) + + endef +diff --git a/configure.ac b/configure.ac +index 8e8d5eb662d9..06398bfa99a7 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -10126,7 +10126,7 @@ AC_SUBST(ENABLE_FUZZERS) + dnl =================================================================== + dnl Orcus + dnl =================================================================== +-libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.15 >= 0.15.0]) ++libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.16 >= 0.16.0]) + if test "$with_system_orcus" != "yes"; then + if test "$SYSTEM_BOOST" = "TRUE"; then + # =========================================================== +diff --git a/download.lst b/download.lst +index ee4ba8a1c83b..345ddd19537b 100644 +--- a/download.lst ++++ b/download.lst +@@ -206,8 +206,8 @@ export OPENLDAP_SHA256SUM := cdd6cffdebcd95161a73305ec13fc7a78e9707b46ca9f84fb89 + export OPENLDAP_TARBALL := openldap-2.4.45.tgz + export OPENSSL_SHA256SUM := 14cb464efe7ac6b54799b34456bd69558a749a4931ecfd9cf9f71d7881cac7bc + export OPENSSL_TARBALL := openssl-1.0.2t.tar.gz +-export ORCUS_SHA256SUM := cfb2aa60825f2a78589ed030c07f46a1ee16ef8a2d1bf2279192fbc1ae5a5f61 +-export ORCUS_TARBALL := liborcus-0.15.4.tar.bz2 ++export ORCUS_SHA256SUM := 854c6ec167ace59baa2984e175bac7b5b2af91bfde4bb10d2088b87a51ed76ec ++export ORCUS_TARBALL := liborcus-0.16.0.tar.bz2 + export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b6330f6a383dc4be34439aca5e9fb + export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz + export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d +diff --git a/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch b/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch +new file mode 100644 +index 000000000000..b0f6a572aff7 +--- /dev/null ++++ b/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch +@@ -0,0 +1,376 @@ ++From 6d34c41b661a9e8dddf6d08bf1f3c1fd4f5581da Mon Sep 17 00:00:00 2001 ++From: Kohei Yoshida ++Date: Fri, 11 Sep 2020 21:39:09 -0400 ++Subject: [PATCH] Mark all untentionally unused variables. ++ ++--- ++ include/orcus/css_parser.hpp | 70 ++++++++++++++++++++++++------ ++ include/orcus/csv_parser.hpp | 5 ++- ++ include/orcus/json_parser.hpp | 15 +++++-- ++ include/orcus/sax_parser.hpp | 35 ++++++++++++--- ++ include/orcus/sax_token_parser.hpp | 20 +++++++-- ++ include/orcus/yaml_parser.hpp | 10 ++++- ++ 6 files changed, 124 insertions(+), 31 deletions(-) ++ ++diff --git a/include/orcus/css_parser.hpp b/include/orcus/css_parser.hpp ++index cdfae5e0..3e96980b 100644 ++--- a/include/orcus/css_parser.hpp +++++ b/include/orcus/css_parser.hpp ++@@ -31,23 +31,44 @@ namespace orcus { ++ class css_handler ++ { ++ public: ++- void at_rule_name(const char* p, size_t n) {} +++ void at_rule_name(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++- void simple_selector_type(const char* p, size_t n) {} +++ void simple_selector_type(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++- void simple_selector_class(const char* p, size_t n) {} +++ void simple_selector_class(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++- void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe) {} +++ void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe) +++ { +++ (void)pe; +++ } ++ ++- void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc) {} +++ void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc) +++ { +++ (void)pc; +++ } ++ ++- void simple_selector_id(const char* p, size_t n) {} +++ void simple_selector_id(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++ void end_simple_selector() {} ++ ++ void end_selector() {} ++ ++- void combinator(orcus::css::combinator_t combinator) {} +++ void combinator(orcus::css::combinator_t combinator) +++ { +++ (void)combinator; +++ } ++ ++ /** ++ * Called at each property name. ++@@ -55,7 +76,10 @@ public: ++ * @param p pointer to the char-array containing the property name string. ++ * @param n length of the property name string. ++ */ ++- void property_name(const char* p, size_t n) {} +++ void property_name(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++ /** ++ * Called at each ordinary property value string. ++@@ -63,7 +87,10 @@ public: ++ * @param p pointer to the char-array containing the value string. ++ * @param n length of the value string. ++ */ ++- void value(const char* p, size_t n) {} +++ void value(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++ /** ++ * Called at each RGB color value of a property. ++@@ -72,7 +99,10 @@ public: ++ * @param green value of green (0-255) ++ * @param blue value of blue (0-255) ++ */ ++- void rgb(uint8_t red, uint8_t green, uint8_t blue) {} +++ void rgb(uint8_t red, uint8_t green, uint8_t blue) +++ { +++ (void)red; (void)green; (void)blue; +++ } ++ ++ /** ++ * Called at each RGB color value of a property with alpha transparency ++@@ -83,7 +113,10 @@ public: ++ * @param blue value of blue (0-255) ++ * @param alpha alpha transparency value ++ */ ++- void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha) {} +++ void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha) +++ { +++ (void)red; (void)green; (void)blue; (void)alpha; +++ } ++ ++ /** ++ * Called at each HSL color value of a property. ++@@ -92,7 +125,10 @@ public: ++ * @param sat saturation ++ * @param light lightness ++ */ ++- void hsl(uint8_t hue, uint8_t sat, uint8_t light) {} +++ void hsl(uint8_t hue, uint8_t sat, uint8_t light) +++ { +++ (void)hue; (void)sat; (void)light; +++ } ++ ++ /** ++ * Called at each HSL color value of a property with alpha transparency ++@@ -103,7 +139,10 @@ public: ++ * @param light lightness ++ * @param alpha alpha value ++ */ ++- void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha) {} +++ void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha) +++ { +++ (void)hue; (void)sat; (void)light; (void)alpha; +++ } ++ ++ /** ++ * Called at each URL value of a property. ++@@ -111,7 +150,10 @@ public: ++ * @param p pointer to the char-array containing the URL value string. ++ * @param n length of the URL value string. ++ */ ++- void url(const char* p, size_t n) {} +++ void url(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++ /** ++ * Called when the parsing begins. ++diff --git a/include/orcus/csv_parser.hpp b/include/orcus/csv_parser.hpp ++index a873b0f2..27b4f924 100644 ++--- a/include/orcus/csv_parser.hpp +++++ b/include/orcus/csv_parser.hpp ++@@ -47,7 +47,10 @@ public: ++ * the text content is guaranteed to be valid so long as ++ * the original CSV stream content is valid. ++ */ ++- void cell(const char* p, size_t n, bool transient) {} +++ void cell(const char* p, size_t n, bool transient) +++ { +++ (void)p; (void)n; (void)transient; +++ } ++ }; ++ ++ template ++diff --git a/include/orcus/json_parser.hpp b/include/orcus/json_parser.hpp ++index 51a3d7cc..ef22b3a8 100644 ++--- a/include/orcus/json_parser.hpp +++++ b/include/orcus/json_parser.hpp ++@@ -54,7 +54,10 @@ public: ++ * pointer points to somewhere in the JSON stream being ++ * parsed. ++ */ ++- void object_key(const char* p, size_t len, bool transient) {} +++ void object_key(const char* p, size_t len, bool transient) +++ { +++ (void)p; (void)len; (void)transient; +++ } ++ ++ /** ++ * Called when the closing curly brace of an object is encountered. ++@@ -87,14 +90,20 @@ public: ++ * pointer points to somewhere in the JSON stream being ++ * parsed. ++ */ ++- void string(const char* p, size_t len, bool transient) {} +++ void string(const char* p, size_t len, bool transient) +++ { +++ (void)p; (void)len; (void)transient; +++ } ++ ++ /** ++ * Called when a numeric value is encountered. ++ * ++ * @param val numeric value. ++ */ ++- void number(double val) {} +++ void number(double val) +++ { +++ (void)val; +++ } ++ }; ++ ++ /** ++diff --git a/include/orcus/sax_parser.hpp b/include/orcus/sax_parser.hpp ++index 73c17d06..3b21bfdf 100644 ++--- a/include/orcus/sax_parser.hpp +++++ b/include/orcus/sax_parser.hpp ++@@ -30,7 +30,10 @@ public: ++ * ++ * @param param struct containing doctype declaration data. ++ */ ++- void doctype(const orcus::sax::doctype_declaration& param) {} +++ void doctype(const orcus::sax::doctype_declaration& param) +++ { +++ (void)param; +++ } ++ ++ /** ++ * Called when <?... is encountered, where the '...' may be an ++@@ -39,28 +42,40 @@ public: ++ * ++ * @param decl name of the identifier. ++ */ ++- void start_declaration(const orcus::pstring& decl) {} +++ void start_declaration(const orcus::pstring& decl) +++ { +++ (void)decl; +++ } ++ ++ /** ++ * Called when the closing tag (>) of a <?... ?> is encountered. ++ * ++ * @param decl name of the identifier. ++ */ ++- void end_declaration(const orcus::pstring& decl) {} +++ void end_declaration(const orcus::pstring& decl) +++ { +++ (void)decl; +++ } ++ ++ /** ++ * Called at the start of each element. ++ * ++ * @param elem information of the element being parsed. ++ */ ++- void start_element(const orcus::sax::parser_element& elem) {} +++ void start_element(const orcus::sax::parser_element& elem) +++ { +++ (void)elem; +++ } ++ ++ /** ++ * Called at the end of each element. ++ * ++ * @param elem information of the element being parsed. ++ */ ++- void end_element(const orcus::sax::parser_element& elem) {} +++ void end_element(const orcus::sax::parser_element& elem) +++ { +++ (void)elem; +++ } ++ ++ /** ++ * Called when a segment of a text content is parsed. Each text content ++@@ -76,7 +91,10 @@ public: ++ * a non-text value or be interned within the scope of ++ * the callback. ++ */ ++- void characters(const orcus::pstring& val, bool transient) {} +++ void characters(const orcus::pstring& val, bool transient) +++ { +++ (void)val; (void)transient; +++ } ++ ++ /** ++ * Called upon parsing of an attribute of an element. Note that when ++@@ -86,7 +104,10 @@ public: ++ * ++ * @param attr struct containing attribute information. ++ */ ++- void attribute(const orcus::sax::parser_attribute& attr) {} +++ void attribute(const orcus::sax::parser_attribute& attr) +++ { +++ (void)attr; +++ } ++ }; ++ ++ /** ++diff --git a/include/orcus/sax_token_parser.hpp b/include/orcus/sax_token_parser.hpp ++index 1452bc27..6b1b1de4 100644 ++--- a/include/orcus/sax_token_parser.hpp +++++ b/include/orcus/sax_token_parser.hpp ++@@ -71,7 +71,10 @@ public: ++ * ++ * @param decl struct containing the attributes of the XML declaration. ++ */ ++- void declaration(const orcus::xml_declaration_t& decl) {} +++ void declaration(const orcus::xml_declaration_t& decl) +++ { +++ (void)decl; +++ } ++ ++ /** ++ * Called at the start of each element. ++@@ -79,7 +82,10 @@ public: ++ * @param elem struct containing the element's information as well as all ++ * the attributes that belong to the element. ++ */ ++- void start_element(const orcus::xml_token_element_t& elem) {} +++ void start_element(const orcus::xml_token_element_t& elem) +++ { +++ (void)elem; +++ } ++ ++ /** ++ * Called at the end of each element. ++@@ -87,7 +93,10 @@ public: ++ * @param elem struct containing the element's information as well as all ++ * the attributes that belong to the element. ++ */ ++- void end_element(const orcus::xml_token_element_t& elem) {} +++ void end_element(const orcus::xml_token_element_t& elem) +++ { +++ (void)elem; +++ } ++ ++ /** ++ * Called when a segment of a text content is parsed. Each text content ++@@ -103,7 +112,10 @@ public: ++ * a non-text value or be interned within the scope of ++ * the callback. ++ */ ++- void characters(const orcus::pstring& val, bool transient) {} +++ void characters(const orcus::pstring& val, bool transient) +++ { +++ (void)val; (void)transient; +++ } ++ }; ++ ++ /** ++diff --git a/include/orcus/yaml_parser.hpp b/include/orcus/yaml_parser.hpp ++index 797ebbec..8d16fbc7 100644 ++--- a/include/orcus/yaml_parser.hpp +++++ b/include/orcus/yaml_parser.hpp ++@@ -72,14 +72,20 @@ public: ++ * @param p pointer to the first character of the string value. ++ * @param len length of the string value. ++ */ ++- void string(const char* p, size_t n) {} +++ void string(const char* p, size_t n) +++ { +++ (void)p; (void)n; +++ } ++ ++ /** ++ * Called when a numeric value is encountered. ++ * ++ * @param val numeric value. ++ */ ++- void number(double val) {} +++ void number(double val) +++ { +++ (void)val; +++ } ++ ++ /** ++ * Called when a boolean 'true' keyword is encountered. ++-- ++2.25.1 ++ +diff --git a/external/liborcus/ExternalPackage_liborcus.mk b/external/liborcus/ExternalPackage_liborcus.mk +index 21dd1bfb1ce5..747691809d2e 100644 +--- a/external/liborcus/ExternalPackage_liborcus.mk ++++ b/external/liborcus/ExternalPackage_liborcus.mk +@@ -12,11 +12,11 @@ $(eval $(call gb_ExternalPackage_ExternalPackage,liborcus,liborcus)) + $(eval $(call gb_ExternalPackage_use_external_project,liborcus,liborcus)) + + ifeq ($(OS),MACOSX) +-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.15.0.dylib,src/liborcus/.libs/liborcus-0.15.0.dylib)) +-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.15.0.dylib,src/parser/.libs/liborcus-parser-0.15.0.dylib)) ++$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.16.0.dylib,src/liborcus/.libs/liborcus-0.16.0.dylib)) ++$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.16.0.dylib,src/parser/.libs/liborcus-parser-0.16.0.dylib)) + else ifeq ($(DISABLE_DYNLOADING),) +-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.15.so.0,src/liborcus/.libs/liborcus-0.15.so.0.0.0)) +-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.15.so.0,src/parser/.libs/liborcus-parser-0.15.so.0.0.0)) ++$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.16.so.0,src/liborcus/.libs/liborcus-0.16.so.0.0.0)) ++$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.16.so.0,src/parser/.libs/liborcus-parser-0.16.so.0.0.0)) + endif + + # vim: set noet sw=4 ts=4: +diff --git a/external/liborcus/ExternalProject_liborcus.mk b/external/liborcus/ExternalProject_liborcus.mk +index 136fa538397e..c2a8cdcbe4a3 100644 +--- a/external/liborcus/ExternalProject_liborcus.mk ++++ b/external/liborcus/ExternalProject_liborcus.mk +@@ -123,8 +123,8 @@ $(call gb_ExternalProject_get_state_target,liborcus,build) : + $(MAKE) \ + $(if $(filter MACOSX,$(OS)),\ + && $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \ +- $(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.15.0.dylib \ +- $(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.15.0.dylib \ ++ $(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.16.0.dylib \ ++ $(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.16.0.dylib \ + ) \ + ) + $(call gb_Trace_EndRange,liborcus,EXTERNAL) +diff --git a/external/liborcus/Library_orcus-parser.mk b/external/liborcus/Library_orcus-parser.mk +index d3cbddbb8cec..4e46591b98fe 100644 +--- a/external/liborcus/Library_orcus-parser.mk ++++ b/external/liborcus/Library_orcus-parser.mk +@@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus-parser,\ + UnpackedTarball/liborcus/src/parser/tokens \ + UnpackedTarball/liborcus/src/parser/types \ + UnpackedTarball/liborcus/src/parser/xml_namespace \ ++ UnpackedTarball/liborcus/src/parser/xml_writer \ + UnpackedTarball/liborcus/src/parser/yaml_parser_base \ + UnpackedTarball/liborcus/src/parser/zip_archive \ + UnpackedTarball/liborcus/src/parser/zip_archive_stream \ +diff --git a/external/liborcus/Library_orcus.mk b/external/liborcus/Library_orcus.mk +index ea99e7509fbf..0a0ca582882a 100644 +--- a/external/liborcus/Library_orcus.mk ++++ b/external/liborcus/Library_orcus.mk +@@ -85,6 +85,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\ + UnpackedTarball/liborcus/src/liborcus/odf_tokens \ + UnpackedTarball/liborcus/src/liborcus/ods_content_xml_context \ + UnpackedTarball/liborcus/src/liborcus/ods_content_xml_handler \ ++ UnpackedTarball/liborcus/src/liborcus/ods_dde_links_context \ + UnpackedTarball/liborcus/src/liborcus/ods_session_data \ + UnpackedTarball/liborcus/src/liborcus/ooxml_content_types \ + UnpackedTarball/liborcus/src/liborcus/ooxml_global \ +@@ -103,6 +104,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\ + UnpackedTarball/liborcus/src/liborcus/orcus_xls_xml \ + UnpackedTarball/liborcus/src/liborcus/orcus_xlsx \ + UnpackedTarball/liborcus/src/liborcus/orcus_xml \ ++ UnpackedTarball/liborcus/src/liborcus/orcus_xml_impl \ + UnpackedTarball/liborcus/src/liborcus/orcus_xml_map_def \ + UnpackedTarball/liborcus/src/liborcus/session_context \ + UnpackedTarball/liborcus/src/liborcus/spreadsheet_iface_util \ +@@ -134,7 +136,9 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\ + UnpackedTarball/liborcus/src/liborcus/xml_simple_stream_handler \ + UnpackedTarball/liborcus/src/liborcus/xml_stream_handler \ + UnpackedTarball/liborcus/src/liborcus/xml_stream_parser \ ++ UnpackedTarball/liborcus/src/liborcus/xml_structure_mapper \ + UnpackedTarball/liborcus/src/liborcus/xml_structure_tree \ ++ UnpackedTarball/liborcus/src/liborcus/xpath_parser \ + UnpackedTarball/liborcus/src/liborcus/yaml_document_tree \ + )) + +diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk +index e5e33b0b1249..4736dbccab4b 100644 +--- a/external/liborcus/UnpackedTarball_liborcus.mk ++++ b/external/liborcus/UnpackedTarball_liborcus.mk +@@ -20,6 +20,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\ + external/liborcus/gcc9.patch.0 \ + external/liborcus/libtool.patch.0 \ + external/liborcus/fix-pch.patch.0 \ ++ external/liborcus/0001-Mark-all-untentionally-unused-variables.patch \ + )) + + ifeq ($(OS),WNT) +diff --git a/external/liborcus/libtool.patch.0 b/external/liborcus/libtool.patch.0 +index aa6ffa908ec3..663dbd8099d7 100644 +--- a/external/liborcus/libtool.patch.0 ++++ b/external/liborcus/libtool.patch.0 +@@ -1,11 +1,11 @@ +---- ltmain.sh.sav 2018-09-14 23:47:13.000000000 +0200 +-+++ ltmain.sh 2019-05-05 23:11:30.406904472 +0200 +-@@ -7278,7 +7278,7 @@ func_mode_link () ++--- ltmain.sh.orig 2020-09-09 21:20:23.069433984 -0400 +++++ ltmain.sh 2020-09-09 21:27:13.168073996 -0400 ++@@ -7373,7 +7373,7 @@ + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ +-- -specs=*|-fsanitize=*) +-+ -specs=*|-fsanitize=*|-fuse-ld=*) ++- -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) +++ -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" +diff --git a/external/liborcus/windows-constants-hack.patch b/external/liborcus/windows-constants-hack.patch +index 876bc1688a31..51aabfa1fb47 100644 +--- a/external/liborcus/windows-constants-hack.patch ++++ b/external/liborcus/windows-constants-hack.patch +@@ -8,7 +8,7 @@ index ae571f5..539ce18 100644 + + -#include "constants.inl" + +#define ORCUS_MAJOR_VERSION 0 +-+#define ORCUS_MINOR_VERSION 11 +++#define ORCUS_MINOR_VERSION 16 + +#define ORCUS_MICRO_VERSION 0 + + namespace orcus { +diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx +index b298c711d234..00aea6764957 100644 +--- a/sc/source/filter/inc/orcusinterface.hxx ++++ b/sc/source/filter/inc/orcusinterface.hxx +@@ -62,6 +62,11 @@ public: + { + return mnTextEncoding; + } ++ ++ ScDocumentImport& getDoc() const ++ { ++ return mrDoc; ++ } + }; + + class ScOrcusRefResolver : public orcus::spreadsheet::iface::import_reference_resolver +@@ -71,20 +76,28 @@ class ScOrcusRefResolver : public orcus::spreadsheet::iface::import_reference_re + public: + ScOrcusRefResolver( const ScOrcusGlobalSettings& rGS ); + +- orcus::spreadsheet::address_t resolve_address(const char* p, size_t n) override; +- orcus::spreadsheet::range_t resolve_range(const char* p, size_t n) override; ++ orcus::spreadsheet::src_address_t resolve_address(const char* p, size_t n) override; ++ orcus::spreadsheet::src_range_t resolve_range(const char* p, size_t n) override; + }; + + class ScOrcusNamedExpression : public orcus::spreadsheet::iface::import_named_expression + { + ScDocumentImport& mrDoc; + const ScOrcusGlobalSettings& mrGlobalSettings; +- SCTAB mnTab; //< negative if global, else >= 0 for sheet-local named expressions. ++ ScAddress maBasePos; ++ OUString maName; ++ OUString maExpr; ++ const SCTAB mnTab; //< negative if global, else >= 0 for sheet-local named expressions. + + public: + ScOrcusNamedExpression( ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS, SCTAB nTab = -1 ); + +- virtual void define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) override; ++ void reset(); ++ ++ virtual void set_base_position(const orcus::spreadsheet::src_address_t& pos) override; ++ virtual void set_named_expression(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) override; ++ virtual void set_named_range(const char* p_name, size_t n_name, const char* p_range, size_t n_range) override; ++ virtual void commit() override; + }; + + class ScOrcusSharedStrings : public orcus::spreadsheet::iface::import_shared_strings +diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx +index 220f7ce057f9..aa96eb21d405 100644 +--- a/sc/source/filter/orcus/interface.cxx ++++ b/sc/source/filter/orcus/interface.cxx +@@ -46,6 +46,7 @@ + #include + + #include ++#include + + using namespace com::sun::star; + +@@ -158,51 +159,54 @@ orcus::spreadsheet::formula_grammar_t ScOrcusGlobalSettings::get_default_formula + ScOrcusRefResolver::ScOrcusRefResolver( const ScOrcusGlobalSettings& rGS ) : + mrGlobalSettings(rGS) {} + +-os::address_t ScOrcusRefResolver::resolve_address(const char* p, size_t n) ++os::src_address_t ScOrcusRefResolver::resolve_address(const char* p, size_t n) + { + OUString aStr(p, n, mrGlobalSettings.getTextEncoding()); + + ScAddress aAddr; +- aAddr.Parse(aStr, nullptr, ++ aAddr.Parse(aStr, &mrGlobalSettings.getDoc().getDoc(), + formula::FormulaGrammar::extractRefConvention( + mrGlobalSettings.getCalcGrammar())); + +- os::address_t ret; +- ret.column = 0; +- ret.row = 0; +- +- if (aAddr.IsValid()) ++ if (!aAddr.IsValid()) + { +- ret.column = aAddr.Col(); +- ret.row = aAddr.Row(); ++ std::ostringstream os; ++ os << "'" << std::string(p, n) << "' is not a valid address expression."; ++ throw orcus::invalid_arg_error(os.str()); + } + ++ os::src_address_t ret; ++ ret.sheet = aAddr.Tab(); ++ ret.column = aAddr.Col(); ++ ret.row = aAddr.Row(); ++ + return ret; + } + +-os::range_t ScOrcusRefResolver::resolve_range(const char* p, size_t n) ++os::src_range_t ScOrcusRefResolver::resolve_range(const char* p, size_t n) + { + OUString aStr(p, n, mrGlobalSettings.getTextEncoding()); + + ScRange aRange; +- aRange.Parse(aStr, nullptr, ++ aRange.Parse(aStr, &mrGlobalSettings.getDoc().getDoc(), + formula::FormulaGrammar::extractRefConvention( + mrGlobalSettings.getCalcGrammar())); + +- os::range_t ret; +- ret.first.column = 0; +- ret.first.row = 0; +- ret.last.column = 0; +- ret.last.row = 0; +- +- if (aRange.IsValid()) ++ if (!aRange.IsValid()) + { +- ret.first.column = aRange.aStart.Col(); +- ret.first.row = aRange.aStart.Row(); +- ret.last.column = aRange.aEnd.Col(); +- ret.last.row = aRange.aEnd.Row(); ++ std::ostringstream os; ++ os << "'" << std::string(p, n) << "' is not a valid range expression."; ++ throw orcus::invalid_arg_error(os.str()); + } + ++ os::src_range_t ret; ++ ret.first.sheet = aRange.aStart.Tab(); ++ ret.first.column = aRange.aStart.Col(); ++ ret.first.row = aRange.aStart.Row(); ++ ret.last.sheet = aRange.aEnd.Tab(); ++ ret.last.column = aRange.aEnd.Col(); ++ ret.last.row = aRange.aEnd.Row(); ++ + return ret; + } + +@@ -210,20 +214,46 @@ ScOrcusNamedExpression::ScOrcusNamedExpression( + ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS, SCTAB nTab ) : + mrDoc(rDoc), mrGlobalSettings(rGS), mnTab(nTab) {} + +-void ScOrcusNamedExpression::define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) ++void ScOrcusNamedExpression::reset() ++{ ++ maBasePos.SetTab(0); ++ maBasePos.SetCol(0); ++ maBasePos.SetRow(0); ++ maName.clear(); ++ maExpr.clear(); ++} ++ ++void ScOrcusNamedExpression::set_base_position(const orcus::spreadsheet::src_address_t& pos) ++{ ++ maBasePos.SetTab(pos.sheet); ++ maBasePos.SetCol(pos.column); ++ maBasePos.SetRow(pos.row); ++} ++ ++void ScOrcusNamedExpression::set_named_expression(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) ++{ ++ maName = OUString(p_name, n_name, mrGlobalSettings.getTextEncoding()); ++ maExpr = OUString(p_exp, n_exp, mrGlobalSettings.getTextEncoding()); ++} ++ ++void ScOrcusNamedExpression::set_named_range(const char* /*p_name*/, size_t /*n_name*/, const char* /*p_range*/, size_t /*n_range*/) + { +- OUString aName(p_name, n_name, mrGlobalSettings.getTextEncoding()); +- OUString aExpr(p_exp, n_exp, mrGlobalSettings.getTextEncoding()); ++ throw std::runtime_error("ScOrcusNamedExpression::set_named_range not implemented yet."); ++} + ++void ScOrcusNamedExpression::commit() ++{ + ScRangeName* pNames = mnTab >= 0 ? mrDoc.getDoc().GetRangeName(mnTab) : mrDoc.getDoc().GetRangeName(); + if (!pNames) + return; + + ScRangeData* pRange = new ScRangeData( +- &mrDoc.getDoc(), aName, aExpr, ScAddress(), ScRangeData::Type::Name, ++ &mrDoc.getDoc(), maName, maExpr, maBasePos, ScRangeData::Type::Name, + mrGlobalSettings.getCalcGrammar()); + + pNames->insert(pRange, false); ++ ++ reset(); // make sure to reset the state for the next run. + } + + ScOrcusFactory::CellStoreToken::CellStoreToken(const ScAddress& rPos, Type eType) +diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx +index f886dd555a66..1f3ee58220a0 100644 +--- a/sc/source/filter/orcus/xmlcontext.cxx ++++ b/sc/source/filter/orcus/xmlcontext.cxx +@@ -89,10 +89,9 @@ void populateTree( + rTreeCtrl.set_image(*xEntry, rParam.maImgElementRepeat, -1); + } + +- orcus::xml_structure_tree::entity_names_type aNames; ++ orcus::xml_structure_tree::entity_names_type aNames = rWalker.get_attributes(); + + // Insert attributes. +- rWalker.get_attributes(aNames); + for (const orcus::xml_structure_tree::entity_name& rAttrName : aNames) + { + OUString sAttr(toString(rAttrName, rWalker)); +@@ -106,7 +105,7 @@ void populateTree( + rTreeCtrl.set_image(*xAttr, rParam.maImgAttribute, -1); + } + +- rWalker.get_children(aNames); ++ aNames = rWalker.get_children(); + + // Non-leaf if it has child elements, leaf otherwise. + rEntryData.mbLeafNode = aNames.empty(); +@@ -266,7 +265,7 @@ void ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam) + std::for_each(rLink.maFieldPaths.begin(), rLink.maFieldPaths.end(), + [&filter](const OString& rFieldPath) + { +- filter.append_field_link(rFieldPath.getStr()); ++ filter.append_field_link(rFieldPath.getStr(), orcus::pstring()); + } + ); + +diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx +index 1eb2e4b06077..167ecae315ae 100644 +--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx ++++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx +@@ -49,8 +49,12 @@ OUString getXPath( + if (pData) + rNamespaces.push_back(pData->mnNamespaceID); + ++ // element separator is '/' whereas attribute separator is '/@' in xpath. + aBuf.insert(0, rTree.get_text(*xEntry, 0)); +- aBuf.insert(0, isAttribute(rTree, *xEntry) ? '@' : '/'); ++ if (isAttribute(rTree, *xEntry)) ++ aBuf.insert(0, "/@"); ++ else ++ aBuf.insert(0, '/'); + } + while (rTree.iter_parent(*xEntry)); + +-- +cgit v1.2.1 + +From 1821dde6601193cc0ddf87fc020de708544d9700 Mon Sep 17 00:00:00 2001 +From: Kohei Yoshida +Date: Mon, 28 Sep 2020 16:19:54 -0400 +Subject: Update liborcus to 0.16.1. + +Change-Id: I27e87278545c1d41381b1ab8a49f6f6a07681bfb +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103590 +Tested-by: Jenkins +Reviewed-by: Kohei Yoshida +--- + download.lst | 4 +- + ...1-Mark-all-untentionally-unused-variables.patch | 376 --------------------- + external/liborcus/UnpackedTarball_liborcus.mk | 1 - + 3 files changed, 2 insertions(+), 379 deletions(-) + delete mode 100644 external/liborcus/0001-Mark-all-untentionally-unused-variables.patch + +diff --git a/download.lst b/download.lst +index a4782bb2b9ef..48af3c5e9198 100644 +--- a/download.lst ++++ b/download.lst +@@ -206,8 +206,8 @@ export OPENLDAP_SHA256SUM := cdd6cffdebcd95161a73305ec13fc7a78e9707b46ca9f84fb89 + export OPENLDAP_TARBALL := openldap-2.4.45.tgz + export OPENSSL_SHA256SUM := 14cb464efe7ac6b54799b34456bd69558a749a4931ecfd9cf9f71d7881cac7bc + export OPENSSL_TARBALL := openssl-1.0.2t.tar.gz +-export ORCUS_SHA256SUM := 854c6ec167ace59baa2984e175bac7b5b2af91bfde4bb10d2088b87a51ed76ec +-export ORCUS_TARBALL := liborcus-0.16.0.tar.bz2 ++export ORCUS_SHA256SUM := c700d1325f744104d9fca0d5a019434901e9d51a16eedfb05792f90a298587a4 ++export ORCUS_TARBALL := liborcus-0.16.1.tar.bz2 + export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b6330f6a383dc4be34439aca5e9fb + export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz + export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d +diff --git a/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch b/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch +deleted file mode 100644 +index b0f6a572aff7..000000000000 +--- a/external/liborcus/0001-Mark-all-untentionally-unused-variables.patch ++++ /dev/null +@@ -1,376 +0,0 @@ +-From 6d34c41b661a9e8dddf6d08bf1f3c1fd4f5581da Mon Sep 17 00:00:00 2001 +-From: Kohei Yoshida +-Date: Fri, 11 Sep 2020 21:39:09 -0400 +-Subject: [PATCH] Mark all untentionally unused variables. +- +---- +- include/orcus/css_parser.hpp | 70 ++++++++++++++++++++++++------ +- include/orcus/csv_parser.hpp | 5 ++- +- include/orcus/json_parser.hpp | 15 +++++-- +- include/orcus/sax_parser.hpp | 35 ++++++++++++--- +- include/orcus/sax_token_parser.hpp | 20 +++++++-- +- include/orcus/yaml_parser.hpp | 10 ++++- +- 6 files changed, 124 insertions(+), 31 deletions(-) +- +-diff --git a/include/orcus/css_parser.hpp b/include/orcus/css_parser.hpp +-index cdfae5e0..3e96980b 100644 +---- a/include/orcus/css_parser.hpp +-+++ b/include/orcus/css_parser.hpp +-@@ -31,23 +31,44 @@ namespace orcus { +- class css_handler +- { +- public: +-- void at_rule_name(const char* p, size_t n) {} +-+ void at_rule_name(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +-- void simple_selector_type(const char* p, size_t n) {} +-+ void simple_selector_type(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +-- void simple_selector_class(const char* p, size_t n) {} +-+ void simple_selector_class(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +-- void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe) {} +-+ void simple_selector_pseudo_element(orcus::css::pseudo_element_t pe) +-+ { +-+ (void)pe; +-+ } +- +-- void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc) {} +-+ void simple_selector_pseudo_class(orcus::css::pseudo_class_t pc) +-+ { +-+ (void)pc; +-+ } +- +-- void simple_selector_id(const char* p, size_t n) {} +-+ void simple_selector_id(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +- void end_simple_selector() {} +- +- void end_selector() {} +- +-- void combinator(orcus::css::combinator_t combinator) {} +-+ void combinator(orcus::css::combinator_t combinator) +-+ { +-+ (void)combinator; +-+ } +- +- /** +- * Called at each property name. +-@@ -55,7 +76,10 @@ public: +- * @param p pointer to the char-array containing the property name string. +- * @param n length of the property name string. +- */ +-- void property_name(const char* p, size_t n) {} +-+ void property_name(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +- /** +- * Called at each ordinary property value string. +-@@ -63,7 +87,10 @@ public: +- * @param p pointer to the char-array containing the value string. +- * @param n length of the value string. +- */ +-- void value(const char* p, size_t n) {} +-+ void value(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +- /** +- * Called at each RGB color value of a property. +-@@ -72,7 +99,10 @@ public: +- * @param green value of green (0-255) +- * @param blue value of blue (0-255) +- */ +-- void rgb(uint8_t red, uint8_t green, uint8_t blue) {} +-+ void rgb(uint8_t red, uint8_t green, uint8_t blue) +-+ { +-+ (void)red; (void)green; (void)blue; +-+ } +- +- /** +- * Called at each RGB color value of a property with alpha transparency +-@@ -83,7 +113,10 @@ public: +- * @param blue value of blue (0-255) +- * @param alpha alpha transparency value +- */ +-- void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha) {} +-+ void rgba(uint8_t red, uint8_t green, uint8_t blue, double alpha) +-+ { +-+ (void)red; (void)green; (void)blue; (void)alpha; +-+ } +- +- /** +- * Called at each HSL color value of a property. +-@@ -92,7 +125,10 @@ public: +- * @param sat saturation +- * @param light lightness +- */ +-- void hsl(uint8_t hue, uint8_t sat, uint8_t light) {} +-+ void hsl(uint8_t hue, uint8_t sat, uint8_t light) +-+ { +-+ (void)hue; (void)sat; (void)light; +-+ } +- +- /** +- * Called at each HSL color value of a property with alpha transparency +-@@ -103,7 +139,10 @@ public: +- * @param light lightness +- * @param alpha alpha value +- */ +-- void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha) {} +-+ void hsla(uint8_t hue, uint8_t sat, uint8_t light, double alpha) +-+ { +-+ (void)hue; (void)sat; (void)light; (void)alpha; +-+ } +- +- /** +- * Called at each URL value of a property. +-@@ -111,7 +150,10 @@ public: +- * @param p pointer to the char-array containing the URL value string. +- * @param n length of the URL value string. +- */ +-- void url(const char* p, size_t n) {} +-+ void url(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +- /** +- * Called when the parsing begins. +-diff --git a/include/orcus/csv_parser.hpp b/include/orcus/csv_parser.hpp +-index a873b0f2..27b4f924 100644 +---- a/include/orcus/csv_parser.hpp +-+++ b/include/orcus/csv_parser.hpp +-@@ -47,7 +47,10 @@ public: +- * the text content is guaranteed to be valid so long as +- * the original CSV stream content is valid. +- */ +-- void cell(const char* p, size_t n, bool transient) {} +-+ void cell(const char* p, size_t n, bool transient) +-+ { +-+ (void)p; (void)n; (void)transient; +-+ } +- }; +- +- template +-diff --git a/include/orcus/json_parser.hpp b/include/orcus/json_parser.hpp +-index 51a3d7cc..ef22b3a8 100644 +---- a/include/orcus/json_parser.hpp +-+++ b/include/orcus/json_parser.hpp +-@@ -54,7 +54,10 @@ public: +- * pointer points to somewhere in the JSON stream being +- * parsed. +- */ +-- void object_key(const char* p, size_t len, bool transient) {} +-+ void object_key(const char* p, size_t len, bool transient) +-+ { +-+ (void)p; (void)len; (void)transient; +-+ } +- +- /** +- * Called when the closing curly brace of an object is encountered. +-@@ -87,14 +90,20 @@ public: +- * pointer points to somewhere in the JSON stream being +- * parsed. +- */ +-- void string(const char* p, size_t len, bool transient) {} +-+ void string(const char* p, size_t len, bool transient) +-+ { +-+ (void)p; (void)len; (void)transient; +-+ } +- +- /** +- * Called when a numeric value is encountered. +- * +- * @param val numeric value. +- */ +-- void number(double val) {} +-+ void number(double val) +-+ { +-+ (void)val; +-+ } +- }; +- +- /** +-diff --git a/include/orcus/sax_parser.hpp b/include/orcus/sax_parser.hpp +-index 73c17d06..3b21bfdf 100644 +---- a/include/orcus/sax_parser.hpp +-+++ b/include/orcus/sax_parser.hpp +-@@ -30,7 +30,10 @@ public: +- * +- * @param param struct containing doctype declaration data. +- */ +-- void doctype(const orcus::sax::doctype_declaration& param) {} +-+ void doctype(const orcus::sax::doctype_declaration& param) +-+ { +-+ (void)param; +-+ } +- +- /** +- * Called when <?... is encountered, where the '...' may be an +-@@ -39,28 +42,40 @@ public: +- * +- * @param decl name of the identifier. +- */ +-- void start_declaration(const orcus::pstring& decl) {} +-+ void start_declaration(const orcus::pstring& decl) +-+ { +-+ (void)decl; +-+ } +- +- /** +- * Called when the closing tag (>) of a <?... ?> is encountered. +- * +- * @param decl name of the identifier. +- */ +-- void end_declaration(const orcus::pstring& decl) {} +-+ void end_declaration(const orcus::pstring& decl) +-+ { +-+ (void)decl; +-+ } +- +- /** +- * Called at the start of each element. +- * +- * @param elem information of the element being parsed. +- */ +-- void start_element(const orcus::sax::parser_element& elem) {} +-+ void start_element(const orcus::sax::parser_element& elem) +-+ { +-+ (void)elem; +-+ } +- +- /** +- * Called at the end of each element. +- * +- * @param elem information of the element being parsed. +- */ +-- void end_element(const orcus::sax::parser_element& elem) {} +-+ void end_element(const orcus::sax::parser_element& elem) +-+ { +-+ (void)elem; +-+ } +- +- /** +- * Called when a segment of a text content is parsed. Each text content +-@@ -76,7 +91,10 @@ public: +- * a non-text value or be interned within the scope of +- * the callback. +- */ +-- void characters(const orcus::pstring& val, bool transient) {} +-+ void characters(const orcus::pstring& val, bool transient) +-+ { +-+ (void)val; (void)transient; +-+ } +- +- /** +- * Called upon parsing of an attribute of an element. Note that when +-@@ -86,7 +104,10 @@ public: +- * +- * @param attr struct containing attribute information. +- */ +-- void attribute(const orcus::sax::parser_attribute& attr) {} +-+ void attribute(const orcus::sax::parser_attribute& attr) +-+ { +-+ (void)attr; +-+ } +- }; +- +- /** +-diff --git a/include/orcus/sax_token_parser.hpp b/include/orcus/sax_token_parser.hpp +-index 1452bc27..6b1b1de4 100644 +---- a/include/orcus/sax_token_parser.hpp +-+++ b/include/orcus/sax_token_parser.hpp +-@@ -71,7 +71,10 @@ public: +- * +- * @param decl struct containing the attributes of the XML declaration. +- */ +-- void declaration(const orcus::xml_declaration_t& decl) {} +-+ void declaration(const orcus::xml_declaration_t& decl) +-+ { +-+ (void)decl; +-+ } +- +- /** +- * Called at the start of each element. +-@@ -79,7 +82,10 @@ public: +- * @param elem struct containing the element's information as well as all +- * the attributes that belong to the element. +- */ +-- void start_element(const orcus::xml_token_element_t& elem) {} +-+ void start_element(const orcus::xml_token_element_t& elem) +-+ { +-+ (void)elem; +-+ } +- +- /** +- * Called at the end of each element. +-@@ -87,7 +93,10 @@ public: +- * @param elem struct containing the element's information as well as all +- * the attributes that belong to the element. +- */ +-- void end_element(const orcus::xml_token_element_t& elem) {} +-+ void end_element(const orcus::xml_token_element_t& elem) +-+ { +-+ (void)elem; +-+ } +- +- /** +- * Called when a segment of a text content is parsed. Each text content +-@@ -103,7 +112,10 @@ public: +- * a non-text value or be interned within the scope of +- * the callback. +- */ +-- void characters(const orcus::pstring& val, bool transient) {} +-+ void characters(const orcus::pstring& val, bool transient) +-+ { +-+ (void)val; (void)transient; +-+ } +- }; +- +- /** +-diff --git a/include/orcus/yaml_parser.hpp b/include/orcus/yaml_parser.hpp +-index 797ebbec..8d16fbc7 100644 +---- a/include/orcus/yaml_parser.hpp +-+++ b/include/orcus/yaml_parser.hpp +-@@ -72,14 +72,20 @@ public: +- * @param p pointer to the first character of the string value. +- * @param len length of the string value. +- */ +-- void string(const char* p, size_t n) {} +-+ void string(const char* p, size_t n) +-+ { +-+ (void)p; (void)n; +-+ } +- +- /** +- * Called when a numeric value is encountered. +- * +- * @param val numeric value. +- */ +-- void number(double val) {} +-+ void number(double val) +-+ { +-+ (void)val; +-+ } +- +- /** +- * Called when a boolean 'true' keyword is encountered. +--- +-2.25.1 +- +diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk +index 4736dbccab4b..e5e33b0b1249 100644 +--- a/external/liborcus/UnpackedTarball_liborcus.mk ++++ b/external/liborcus/UnpackedTarball_liborcus.mk +@@ -20,7 +20,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\ + external/liborcus/gcc9.patch.0 \ + external/liborcus/libtool.patch.0 \ + external/liborcus/fix-pch.patch.0 \ +- external/liborcus/0001-Mark-all-untentionally-unused-variables.patch \ + )) + + ifeq ($(OS),WNT) +-- +cgit v1.2.1 + diff --git a/debian/patches/make-package-modules-not-suck.diff b/debian/patches/make-package-modules-not-suck.diff new file mode 100644 index 000000000..2f29277ec --- /dev/null +++ b/debian/patches/make-package-modules-not-suck.diff @@ -0,0 +1,200 @@ +diff --git a/scp2/InstallModule_draw.mk b/scp2/InstallModule_draw.mk +index a7c02be..d48edf2 100644 +--- a/scp2/InstallModule_draw.mk ++++ b/scp2/InstallModule_draw.mk +@@ -10,6 +10,7 @@ + $(eval $(call gb_InstallModule_InstallModule,scp2/draw)) + + $(eval $(call gb_InstallModule_use_auto_install_libs,scp2/draw,\ ++ draw \ + draw_brand \ + )) + +diff --git a/scp2/source/draw/module_draw.scp b/scp2/source/draw/module_draw.scp +index 8737579..0913c61 100644 +--- a/scp2/source/draw/module_draw.scp ++++ b/scp2/source/draw/module_draw.scp +@@ -18,6 +18,7 @@ + + #include "macros.inc" + ++#include "AutoInstall/draw" + #include "AutoInstall/draw_brand" + + Module gid_Module_Prg_Draw +@@ -34,7 +35,8 @@ Module gid_Module_Prg_Draw_Bin + Sortkey = "100"; + Default = YES; + Styles = (HIDDEN_ROOT); +- Files = (gid_File_Extra_Urldesktop_Draw,gid_File_Extra_Urlnew_Draw,gid_File_Extra_Urlstart_Draw,gid_File_Extra_Urltasks_Draw, ++ Files = (auto_draw_ALL, ++ gid_File_Extra_Urldesktop_Draw,gid_File_Extra_Urlnew_Draw,gid_File_Extra_Urlstart_Draw,gid_File_Extra_Urltasks_Draw, + gid_File_Share_Registry_Draw_Xcd, + gid_File_Tmp_Userinstall_Draw_Inf); + End +diff --git a/scp2/AutoInstall.mk b/scp2/AutoInstall.mk +index 7d2a347..a15ac52 100644 +--- a/scp2/AutoInstall.mk ++++ b/scp2/AutoInstall.mk +@@ -17,6 +17,7 @@ $(eval $(call gb_AutoInstall_add_module,base_brand,,LIBO_EXECUTABLE,,PACKAGE_FIL + $(eval $(call gb_AutoInstall_add_module,brand,,LIBO_EXECUTABLE,,PACKAGE_FILELIST)) + $(eval $(call gb_AutoInstall_add_module,calc,LIBO_LIB_FILE,,,PACKAGE_FILELIST)) + $(eval $(call gb_AutoInstall_add_module,calc_brand,,LIBO_EXECUTABLE,,PACKAGE_FILELIST)) ++$(eval $(call gb_AutoInstall_add_module,draw,LIBO_LIB_FILE)) + $(eval $(call gb_AutoInstall_add_module,draw_brand,,LIBO_EXECUTABLE,,PACKAGE_FILELIST)) + $(eval $(call gb_AutoInstall_add_module,extensions_ct2n,,,,PACKAGE_FILELIST)) + $(eval $(call gb_AutoInstall_add_module,extensions_bsh,,,LIBO_JAR_FILE)) +diff --git a/Repository.mk b/Repository.mk +index 36b35b7a4262..25f202cb0983 100644 +--- a/Repository.mk ++++ b/Repository.mk +@@ -245,13 +245,29 @@ $(eval $(call gb_Helper_register_executables_for_install,UREBIN,ure,\ + + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,base, \ + abp \ ++ calc \ ++ dba \ ++ dbahsql \ ++ $(call gb_Helper_optional,DBCONNECTIVITY, \ ++ dbase \ ++ dbaxml) \ + dbp \ + dbu \ ++ $(call gb_Helper_optional,DBCONNECTIVITY,flat) \ ++ $(if $(ENABLE_JAVA),jdbc) \ ++ $(call gb_Helper_optional,DBCONNECTIVITY,mysql_jdbc) \ ++ $(call gb_Helper_optional,MARIADBC,$(call gb_Helper_optional,DBCONNECTIVITY,mysqlc)) \ ++ odbc \ ++)) ++ ++$(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,base, \ ++ $(call gb_Helper_optional,DBCONNECTIVITY,dbpool2) \ ++ $(if $(ENABLE_JAVA),hsqldb) \ ++ sdbc2 \ + )) + + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \ + analysis \ +- $(call gb_Helper_optional,DBCONNECTIVITY,calc) \ + date \ + pricing \ + sc \ +@@ -263,6 +279,14 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \ + $(call gb_Helper_optional,SCRIPTING,vbaobj) \ + )) + ++$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,draw, \ ++ animcore \ ++ sd \ ++ sdd \ ++ sdfilt \ ++ sdui \ ++)) ++ + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \ + svgfilter \ + wpftdraw \ +@@ -271,10 +295,10 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \ + )) + + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,impress, \ +- animcore \ + PresenterScreen \ + PresentationMinimizer \ + wpftimpress \ ++ slideshow \ + )) + + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,onlineupdate, \ +@@ -349,11 +349,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + configmgr \ + ctl \ + cui \ +- dba \ +- dbahsql \ +- $(call gb_Helper_optional,DBCONNECTIVITY, \ +- dbase \ +- dbaxml) \ + dbtools \ + deploymentmisc \ + $(if $(filter-out MACOSX WNT,$(OS)),desktopbe1) \ +@@ -366,7 +386,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + evtatt \ + expwrap \ + $(call gb_Helper_optional,DBCONNECTIVITY, \ +- flat \ + file) \ + filterconfig \ + fps_office \ +@@ -387,7 +406,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + gie \ + hyphen \ + icg \ +- $(if $(ENABLE_JAVA),jdbc) \ + $(if $(ENABLE_LDAP),ldapbe2) \ + $(if $(filter WNT,$(OS)),WinUserInfoBe) \ + localebe1 \ +@@ -403,10 +421,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + msfilter \ + $(call gb_Helper_optional,SCRIPTING,msforms) \ + mtfrenderer \ +- $(call gb_Helper_optional,DBCONNECTIVITY,mysql_jdbc) \ +- $(call gb_Helper_optional,MARIADBC,$(call gb_Helper_optional,DBCONNECTIVITY,mysqlc)) \ + numbertext \ +- odbc \ + odfflatxml \ + offacc \ + oox \ +@@ -419,13 +434,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + sb \ + $(call gb_Helper_optional,DBCONNECTIVITY,sdbt) \ + scn \ +- sd \ +- sdd \ +- sdfilt \ +- sdui \ + sfx \ + simplecanvas \ +- slideshow \ + sot \ + $(if $(filter-out iOS,$(OS)),spell) \ + $(if $(DISABLE_GUI),,spl) \ +@@ -437,7 +447,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ + svt \ + svx \ + svxcore \ +- sw \ + syssh \ + textconversiondlgs \ + textfd \ +@@ -522,6 +531,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,writer, \ + hwp \ + $(if $(ENABLE_LWP),lwpft) \ + msword \ ++ sw \ + swd \ + swui \ + t602filter \ +@@ -600,14 +610,12 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \ + cached1 \ + collator_data \ + comphelper \ +- $(call gb_Helper_optional,DBCONNECTIVITY,dbpool2) \ + $(call gb_Helper_optional,BREAKPAD,crashreport) \ + deployment \ + deploymentgui \ + dict_ja \ + dict_zh \ + embobj \ +- $(if $(ENABLE_JAVA),hsqldb) \ + i18nutil \ + index_data \ + $(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), libreofficekitgtk) \ +@@ -623,7 +631,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \ + emboleobj \ + package2 \ + $(call gb_Helper_optional,SCRIPTING,scriptframe) \ +- sdbc2 \ + sofficeapp \ + srtrs1 \ + $(if $(filter $(OS),WNT),sysdtrans) \ diff --git a/debian/patches/mediwiki-oor-replace.diff b/debian/patches/mediwiki-oor-replace.diff new file mode 100644 index 000000000..ed04c917e --- /dev/null +++ b/debian/patches/mediwiki-oor-replace.diff @@ -0,0 +1,51 @@ +diff --git a/swext/mediawiki/src/registry/data/org/openoffice/Office/OptionsDialog.xcu b/swext/mediawiki/src/registry/data/org/openoffice/Office/OptionsDialog.xcu +index 2b35ced08f31..0c96070dd4f0 100644 +--- a/swext/mediawiki/src/registry/data/org/openoffice/Office/OptionsDialog.xcu ++++ b/swext/mediawiki/src/registry/data/org/openoffice/Office/OptionsDialog.xcu +@@ -18,9 +18,9 @@ + --> + + +- ++ + +- ++ + + com.sun.wiki-publisher + +diff --git a/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Filter.xcu b/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Filter.xcu +index 3309b503824c..261e470b253b 100644 +--- a/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Filter.xcu ++++ b/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Filter.xcu +@@ -19,7 +19,7 @@ + + + +- ++ + 0 + MediaWiki + com.sun.star.text.TextDocument +@@ -31,7 +31,7 @@ + + EXPORT ALIEN 3RDPARTYFILTER + +- ++ + 0 + MediaWiki + com.sun.star.text.WebDocument +diff --git a/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Types.xcu b/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Types.xcu +index 15e4f850041a..ce7cd0763b79 100644 +--- a/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Types.xcu ++++ b/swext/mediawiki/src/registry/data/org/openoffice/TypeDetection/Types.xcu +@@ -19,7 +19,7 @@ + + + +- ++ + com.sun.star.comp.filters.XMLFilterDetect + + txt diff --git a/debian/patches/mention-java-common-package.diff b/debian/patches/mention-java-common-package.diff new file mode 100644 index 000000000..24fbbc0a8 --- /dev/null +++ b/debian/patches/mention-java-common-package.diff @@ -0,0 +1,35 @@ +diff --git a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx +index 718902caba6f..3c8499b5a42c 100644 +--- a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx ++++ b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx +@@ -141,6 +141,9 @@ static bool findAndSelect(JavaInfo ** ppInfo) + if (errcode == JFW_E_NO_JAVA_FOUND) + { + fprintf(stderr,"javaldx: Could not find a Java Runtime Environment!\n"); ++ fprintf(stderr,"Please ensure that a JVM and the package libreoffice-java-common\n"); ++ fprintf(stderr,"is installed.\n"); ++ fprintf(stderr,"If it is already installed then try removing ~/.config/libreoffice/4/user/config/javasettings_Linux_*.xml\n"); + return false; + } + else if (errcode != JFW_E_NONE && errcode != JFW_E_DIRECT_MODE) +diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc +index f9dc617f4313..874b0400cbc5 100644 +--- a/include/svtools/strings.hrc ++++ b/include/svtools/strings.hrc +@@ -281,13 +281,13 @@ + + #define STR_SVT_DEFAULT_SERVICE_LABEL NC_("STR_SVT_DEFAULT_SERVICE_LABEL", "$user$'s $service$") + +-#define STR_WARNING_JAVANOTFOUND NC_("STR_WARNING_JAVANOTFOUND", "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. Please install a JRE and restart %PRODUCTNAME.") ++#define STR_WARNING_JAVANOTFOUND NC_("STR_WARNING_JAVANOTFOUND", "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. Please install a JRE (and libreoffice-java-common) and restart %PRODUCTNAME.") + #define STR_WARNING_JAVANOTFOUND_WIN NC_("STR_WARNING_JAVANOTFOUND_WIN", "%PRODUCTNAME requires a %BITNESS-bit Java runtime environment (JRE) to perform this task. Please install a JRE and restart %PRODUCTNAME.") + #define STR_WARNING_JAVANOTFOUND_MAC NC_("STR_WARNING_JAVANOTFOUND_MAC", "%PRODUCTNAME requires Oracle's Java Development Kit (JDK) on macOS 10.10 or greater to perform this task. Please install them and restart %PRODUCTNAME.") + #define STR_WARNING_INVALIDJAVASETTINGS_MAC NC_("STR_WARNING_INVALIDJAVASETTINGS_MAC", "The %PRODUCTNAME configuration has been changed. Under %PRODUCTNAME - Preferences - %PRODUCTNAME - Advanced, select the Java runtime environment you want to have used by %PRODUCTNAME.") +-#define STR_WARNING_INVALIDJAVASETTINGS NC_("STR_WARNING_INVALIDJAVASETTINGS", "The %PRODUCTNAME configuration has been changed. Under Tools - Options - %PRODUCTNAME - Advanced, select the Java runtime environment you want to have used by %PRODUCTNAME.") ++#define STR_WARNING_INVALIDJAVASETTINGS NC_("STR_WARNING_INVALIDJAVASETTINGS", "The %PRODUCTNAME configuration has been changed. Under Tools - Options - %PRODUCTNAME - Advanced, select the Java runtime environment you want to have used by %PRODUCTNAME. Maybe you also need to install libreoffice-java-common.") + #define STR_ERROR_JVMCREATIONFAILED_MAC NC_("STR_ERROR_JVMCREATIONFAILED_MAC", "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under %PRODUCTNAME - Preferences - %PRODUCTNAME - Advanced.") +-#define STR_ERROR_JVMCREATIONFAILED NC_("STR_ERROR_JVMCREATIONFAILED", "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under Tools - Options - %PRODUCTNAME - Advanced.") ++#define STR_ERROR_JVMCREATIONFAILED NC_("STR_ERROR_JVMCREATIONFAILED", "%PRODUCTNAME requires a Java runtime environment (JRE) to perform this task. The selected JRE is defective. Please select another version or install a new JRE and select it under Tools - Options - %PRODUCTNAME - Advanced or install libreoffice-java-common if not already installed.") + #define STR_WARNING_JAVANOTFOUND_TITLE NC_("STR_WARNING_JAVANOTFOUND_TITLE", "JRE Required") + #define STR_WARNING_INVALIDJAVASETTINGS_TITLE NC_("STR_WARNING_INVALIDJAVASETTINGS_TITLE", "Select JRE") + #define STR_ERROR_JVMCREATIONFAILED_TITLE NC_("STR_ERROR_JVMCREATIONFAILED_TITLE", "JRE is Defective") diff --git a/debian/patches/no-check-if-root.diff b/debian/patches/no-check-if-root.diff new file mode 100644 index 000000000..95ebbb329 --- /dev/null +++ b/debian/patches/no-check-if-root.diff @@ -0,0 +1,26 @@ +--- a/Makefile.in 2017-07-28 06:09:37.072183489 +0000 ++++ b/Makefile.in 2017-10-18 12:43:59.215567467 +0000 +@@ -57,14 +57,6 @@ else # MAKE_RESTARTS + + .DEFAULT_GOAL := build + +-check-if-root: +- @if test ! `uname` = 'Haiku' -a `id -u` = 0 && ! grep -q 'lxc\|docker' /proc/self/cgroup && ! grep -q 'libpod_parent' /proc/self/cgroup; then \ +- echo; \ +- echo 'Building LibreOffice as root is a very bad idea, use a regular user.'; \ +- echo; \ +- exit 1; \ +- fi +- + gb_Side ?= host + + include $(BUILDDIR)/config_$(gb_Side).mk +@@ -252,7 +244,7 @@ endif + # + # Bootstrap + # +-bootstrap: check-if-root compilerplugins ++bootstrap: compilerplugins + + # + # Build diff --git a/debian/patches/no-opencl-per-default.diff b/debian/patches/no-opencl-per-default.diff new file mode 100644 index 000000000..d17e9c059 --- /dev/null +++ b/debian/patches/no-opencl-per-default.diff @@ -0,0 +1,26 @@ +From b54cfe9d3d22fdd40f7015bd343df8620c983779 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Mon, 27 Mar 2017 11:47:01 +0100 +Subject: [PATCH] Resolves: rhbz#1432468 disable opencl by default + +Change-Id: Ie037fcabdd219f195425979dd721501fb5527573 +--- + officecfg/registry/schema/org/openoffice/Office/Common.xcs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +index 946bd32..284d694 100644 +--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs ++++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs +@@ -5670,7 +5670,7 @@ + Determines whether OpenCL can be used, when available, to speed up + some operations. +
+- true ++ false +
+ + +-- +2.9.3 + diff --git a/debian/patches/no-openssl.diff b/debian/patches/no-openssl.diff new file mode 100644 index 000000000..a5c26903a --- /dev/null +++ b/debian/patches/no-openssl.diff @@ -0,0 +1,357 @@ +don't add -lssl etc if not needed (because we use system-postgresql) + +diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk +index 0fc7d25..952b140 100644 +--- a/RepositoryExternal.mk ++++ b/RepositoryExternal.mk +@@ -2911,9 +2917,10 @@ $(call gb_LinkTarget_add_libs,$(1),\ + $(call gb_UnpackedTarball_get_dir,postgresql)/src/interfaces/libpq/libpq$(gb_StaticLibrary_PLAINEXT) \ + ) + +-ifeq ($(OS),WNT) + $(call gb_LinkTarget_use_external,$(1),openssl) + ++ifeq ($(OS),WNT) ++ + $(call gb_LinkTarget_use_system_win32_libs,$(1),\ + secur32 \ + ws2_32 \ +diff --git a/connectivity/Library_postgresql-sdbc-impl.mk b/connectivity/Library_postgresql-sdbc-impl.mk +index 0580a8b..7e8b778 100644 +--- a/connectivity/Library_postgresql-sdbc-impl.mk ++++ b/connectivity/Library_postgresql-sdbc-impl.mk +@@ -46,7 +46,6 @@ $(eval $(call gb_Library_use_externals,postgresql-sdbc-impl,\ + boost_headers \ + postgresql \ + $(if $(filter-out MSC,$(COM)), \ +- openssl \ + $(if $(ENABLE_LDAP),openldap) \ + nss3 \ + plc4 \ + +... and don't uselessly check for openssl in configure + +diff --git a/config_host.mk.in b/config_host.mk.in +index ddd144e..19f8368 100644 +--- a/config_host.mk.in ++++ b/config_host.mk.in +@@ -93,7 +93,6 @@ export DEFAULT_BRAND_IMAGES=@DEFAULT_BRAND_IMAGES@ + export DICT_SYSTEM_DIR=@DICT_SYSTEM_DIR@ + export DISABLE_CVE_TESTS=@DISABLE_CVE_TESTS@ + export DISABLE_DYNLOADING=@DISABLE_DYNLOADING@ +-export DISABLE_OPENSSL=@DISABLE_OPENSSL@ + export DISABLE_PYTHON=@DISABLE_PYTHON@ + export DLOPEN_LIBS=@DLOPEN_LIBS@ + export DLLTOOL=@DLLTOOL@ +@@ -438,8 +439,6 @@ export OOO_JUNIT_JAR=@OOO_JUNIT_JAR@ + export BFFVALIDATOR=@BFFVALIDATOR@ + export OOO_JUNIT_JAR=@OOO_JUNIT_JAR@ + export OOO_VENDOR=@OOO_VENDOR@ +-export OPENSSL_CFLAGS=$(gb_SPACE)@OPENSSL_CFLAGS@ +-export OPENSSL_LIBS=$(gb_SPACE)@OPENSSL_LIBS@ + export OPENSYMBOL_TTF=@OPENSYMBOL_TTF@ + export ORCUS_CFLAGS=$(gb_SPACE)@ORCUS_CFLAGS@ + export ORCUS_LIBS=$(gb_SPACE)@ORCUS_LIBS@ +@@ -569,7 +568,6 @@ export SYSTEM_ODBC_HEADERS=@SYSTEM_ODBC_HEADERS@ + export SYSTEM_ODBC_HEADERS=@SYSTEM_ODBC_HEADERS@ + export SYSTEM_ODFGEN=@SYSTEM_ODFGEN@ + export SYSTEM_OPENLDAP=@SYSTEM_OPENLDAP@ +-export SYSTEM_OPENSSL=@SYSTEM_OPENSSL@ + export SYSTEM_PAGEMAKER=@SYSTEM_PAGEMAKER@ + export SYSTEM_POPPLER=@SYSTEM_POPPLER@ + export SYSTEM_POSTGRESQL=@SYSTEM_POSTGRESQL@ +diff --git a/configure.ac b/configure.ac +index 3862386..45d5e25 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -9422,67 +9422,6 @@ else + AC_MSG_RESULT([no]) + fi + +-dnl =================================================================== +-dnl Check for system openssl +-dnl =================================================================== +-DISABLE_OPENSSL= +-AC_MSG_CHECKING([whether to disable OpenSSL usage]) +-if test "$enable_openssl" = "yes"; then +- AC_MSG_RESULT([no]) +- if test "$_os" = Darwin ; then +- # OpenSSL is deprecated when building for 10.7 or later. +- # +- # http://stackoverflow.com/questions/7406946/why-is-apple-deprecating-openssl-in-macos-10-7-lion +- # http://stackoverflow.com/questions/7475914/libcrypto-deprecated-on-mac-os-x-10-7-lion +- +- with_system_openssl=no +- libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl]) +- elif test "$_os" = "NetBSD" -o "$_os" = "OpenBSD" -o "$_os" = "DragonFly" \ +- && test "$with_system_openssl" != "no"; then +- with_system_openssl=yes +- SYSTEM_OPENSSL=TRUE +- OPENSSL_CFLAGS= +- OPENSSL_LIBS="-lssl -lcrypto" +- else +- libo_CHECK_SYSTEM_MODULE([openssl],[OPENSSL],[openssl]) +- fi +- if test "$with_system_openssl" = "yes"; then +- AC_MSG_CHECKING([whether openssl supports SHA512]) +- AC_LANG_PUSH([C]) +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]],[[ +- SHA512_CTX context; +-]])],[AC_MSG_RESULT([yes])],[AC_MSG_ERROR([no, openssl too old. Need >= 0.9.8.])]) +- AC_LANG_POP(C) +- fi +-else +- AC_MSG_RESULT([yes]) +- DISABLE_OPENSSL=TRUE +- +- # warn that although OpenSSL is disabled, system libraries may depend on it +- AC_MSG_WARN([OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies]) +- add_warning "OpenSSL has been disabled. No code compiled here will make use of it but system libraries may create indirect dependencies" +-fi +- +-AC_SUBST([DISABLE_OPENSSL]) +- +-if test "$enable_cipher_openssl_backend" = yes && test "$DISABLE_OPENSSL" = TRUE; then +- if test "$libo_fuzzed_enable_cipher_openssl_backend" = yes; then +- AC_MSG_NOTICE([Resetting --enable-cipher-openssl-backend=no]) +- enable_cipher_openssl_backend=no +- else +- AC_MSG_ERROR([--enable-cipher-openssl-backend needs OpenSSL, but --disable-openssl was given.]) +- fi +-fi +-AC_MSG_CHECKING([whether to enable the OpenSSL backend for rtl/cipher.h]) +-ENABLE_CIPHER_OPENSSL_BACKEND= +-if test "$enable_cipher_openssl_backend" = yes; then +- AC_MSG_RESULT([yes]) +- ENABLE_CIPHER_OPENSSL_BACKEND=TRUE +-else +- AC_MSG_RESULT([no]) +-fi +-AC_SUBST([ENABLE_CIPHER_OPENSSL_BACKEND]) +- + dnl =================================================================== + dnl Check for building gnutls + dnl =================================================================== + +.. and without these gbuild still wants it ... + +diff --git a/external/Module_external.mk b/external/Module_external.mk +index 44280e3..44c1c63 100644 +--- a/external/Module_external.mk ++++ b/external/Module_external.mk +@@ -82,7 +82,6 @@ $(eval $(call gb_Module_add_moduledirs,external,\ + $(call gb_Helper_optional,NSS,nss) \ + $(call gb_Helper_optional,ODFGEN,libodfgen) \ + $(call gb_Helper_optional,OPENLDAP,openldap) \ +- $(call gb_Helper_optional,OPENSSL,openssl) \ + $(call gb_Helper_optional,ORCUS,liborcus) \ + $(call gb_Helper_optional,OWNCLOUD_ANDROID_LIB,owncloud-android-lib) \ + $(call gb_Helper_optional,PAGEMAKER,libpagemaker) \ +diff --git a/oox/CppunitTest_oox_tokenmap.mk b/oox/CppunitTest_oox_tokenmap.mk +index 9eac2a5..ef6d5c9 100644 +--- a/oox/CppunitTest_oox_tokenmap.mk ++++ b/oox/CppunitTest_oox_tokenmap.mk +@@ -20,19 +20,10 @@ $(eval $(call gb_CppunitTest_use_sdk_api,oox_tokenmap)) + + $(eval $(call gb_CppunitTest_use_library_objects,oox_tokenmap,oox)) + +-ifeq ($(TLS),OPENSSL) +-$(eval $(call gb_CppunitTest_use_externals,oox_tokenmap,\ +- openssl \ +- openssl_headers \ +-)) +-else +-ifeq ($(TLS),NSS) + $(eval $(call gb_CppunitTest_use_externals,oox_tokenmap,\ + plc4 \ + nss3 \ + )) +-endif +-endif + + $(eval $(call gb_CppunitTest_use_libraries,oox_tokenmap,\ + avmedia \ +diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk +index fcd7215..a178883 100644 +--- a/oox/Library_oox.mk ++++ b/oox/Library_oox.mk +@@ -67,19 +67,10 @@ $(eval $(call gb_Library_use_externals,oox,\ + boost_headers \ + )) + +-ifeq ($(TLS),OPENSSL) +-$(eval $(call gb_Library_use_externals,oox,\ +- openssl \ +- openssl_headers \ +-)) +-else +-ifeq ($(TLS),NSS) + $(eval $(call gb_Library_use_externals,oox,\ + plc4 \ + nss3 \ + )) +-endif +-endif + + $(eval $(call gb_Library_set_componentfile,oox,oox/util/oox)) + +diff --git a/ucb/CppunitTest_ucb_webdav_local_neon.mk b/ucb/CppunitTest_ucb_webdav_local_neon.mk +index 20e827b..9b869f9 100644 +--- a/ucb/CppunitTest_ucb_webdav_local_neon.mk ++++ b/ucb/CppunitTest_ucb_webdav_local_neon.mk +@@ -34,7 +34,6 @@ $(eval $(call gb_CppunitTest_use_externals,ucb_webdav_local_neon,\ + boost_headers \ + libxml2 \ + neon \ +- openssl \ + )) + + $(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_local_neon,\ +diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk +index 37f3c8f..2167dd2 100644 +--- a/ucb/Library_ucpdav1.mk ++++ b/ucb/Library_ucpdav1.mk +@@ -30,7 +30,6 @@ $(eval $(call gb_Library_use_externals,ucpdav1,\ + boost_headers \ + libxml2 \ + neon \ +- openssl \ + )) + + $(eval $(call gb_Library_use_custom_headers,ucpdav1,\ +@@ -66,7 +65,6 @@ else # WITH_WEBDAV == serf + $(eval $(call gb_Library_use_externals,ucpdav1,\ + boost_headers \ + apr \ +- openssl \ + serf \ + zlib \ + )) +diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk +index 0fc7d25..fe5a208 100644 +--- a/RepositoryExternal.mk ++++ b/RepositoryExternal.mk +@@ -1525,75 +1525,6 @@ endif # ENABLE_HARFBUZZ + + ifeq ($(DISABLE_OPENSSL),TRUE) + +-gb_ExternalProject__use_openssl:= +-gb_LinkTarget__use_openssl_headers:= +-gb_LinkTarget__use_openssl:= +- +-else # !DISABLE_OPENSSL +- +-ifneq ($(SYSTEM_OPENSSL),) +- +-gb_LinkTarget__use_openssl_headers:= +-gb_ExternalProject__use_openssl:= +- +-define gb_LinkTarget__use_openssl +-$(call gb_LinkTarget_set_include,$(1),\ +- $$(INCLUDE) \ +- $(OPENSSL_CFLAGS) \ +-) +-$(call gb_LinkTarget_add_libs,$(1),$(OPENSSL_LIBS)) +- +-endef +- +-else # !SYSTEM_OPENSSL +- +-$(eval $(call gb_Helper_register_packages_for_install,ooo, \ +- openssl \ +-)) +- +-define gb_ExternalProject__use_openssl +-$(call gb_ExternalProject_use_package,$(1),openssl) +- +-endef +- +-define gb_LinkTarget__use_openssl_headers +-$(call gb_LinkTarget_use_external_project,$(1),openssl) +-$(call gb_LinkTarget_set_include,$(1),\ +- -I$(call gb_UnpackedTarball_get_dir,openssl)/include \ +- $$(INCLUDE) \ +-) +- +-endef +- +-define gb_LinkTarget__use_openssl +-$(call gb_LinkTarget_use_package,$(1),openssl) +-ifeq ($(OS),WNT) +-$(call gb_LinkTarget_add_libs,$(1),\ +- $(call gb_UnpackedTarball_get_dir,openssl)/out32dll/ssleay32.lib \ +- $(call gb_UnpackedTarball_get_dir,openssl)/out32dll/libeay32.lib \ +-) +-else +-$(call gb_LinkTarget_add_libs,$(1),\ +- $(call gb_UnpackedTarball_get_dir,openssl)/libssl.a \ +- $(call gb_UnpackedTarball_get_dir,openssl)/libcrypto.a \ +-) +-$(call gb_LinkTarget_use_external_project,$(1),openssl) +-ifeq ($(OS),SOLARIS) +-$(call gb_LinkTarget_add_libs,$(1),\ +- -lnsl \ +- -lsocket \ +-) +-endif +-endif +- +-endef +- +-endif # SYSTEM_OPENSSL +-endif # DISABLE_OPENSSL +- +- +-ifeq ($(DISABLE_OPENSSL),TRUE) +- + define gb_LinkTarget__use_gnutls + $(call gb_LinkTarget_set_include,$(1),\ + $$(INCLUDE) \ +diff --git a/ucb/CppunitTest_ucb_webdav_neon_opts.mk b/ucb/CppunitTest_ucb_webdav_neon_opts.mk +index 91e167b..21e5257 100644 +--- a/ucb/CppunitTest_ucb_webdav_neon_opts.mk ++++ b/ucb/CppunitTest_ucb_webdav_neon_opts.mk +@@ -34,7 +34,6 @@ $(eval $(call gb_CppunitTest_use_externals,ucb_webdav_neon_opts,\ + boost_headers \ + libxml2 \ + neon \ +- openssl \ + )) + + $(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_neon_opts,\ +diff --git a/ucb/CppunitTest_ucb_webdav_propfindcache.mk b/ucb/CppunitTest_ucb_webdav_propfindcache.mk +index ebbaee7..e2d064e 100644 +--- a/ucb/CppunitTest_ucb_webdav_propfindcache.mk ++++ b/ucb/CppunitTest_ucb_webdav_propfindcache.mk +@@ -34,7 +34,6 @@ $(eval $(call gb_CppunitTest_use_externals,ucb_webdav_propfindcache,\ + boost_headers \ + libxml2 \ + neon \ +- openssl \ + )) + + $(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_propfindcache,\ +diff --git a/ucb/CppunitTest_ucb_webdav_res_access.mk b/ucb/CppunitTest_ucb_webdav_res_access.mk +index ac48f87..c7d151e 100644 +--- a/ucb/CppunitTest_ucb_webdav_res_access.mk ++++ b/ucb/CppunitTest_ucb_webdav_res_access.mk +@@ -34,7 +34,6 @@ $(eval $(call gb_CppunitTest_use_externals,ucb_webdav_res_access,\ + boost_headers \ + libxml2 \ + neon \ +- openssl \ + )) + + $(eval $(call gb_CppunitTest_use_custom_headers,ucb_webdav_res_access,\ +diff --git a/connectivity/Library_mysqlc.mk b/connectivity/Library_mysqlc.mk +index f765fb1e305f..0999b46d3eec 100644 +--- a/connectivity/Library_mysqlc.mk ++++ b/connectivity/Library_mysqlc.mk +@@ -12,7 +12,6 @@ $(eval $(call gb_Library_Library,mysqlc)) + $(eval $(call gb_Library_use_externals,mysqlc,\ + boost_headers \ + mariadb-connector-c \ +- openssl \ + )) + + $(eval $(call gb_Library_set_include,mysqlc,\ diff --git a/debian/patches/no-packagekit-per-default.diff b/debian/patches/no-packagekit-per-default.diff new file mode 100644 index 000000000..a496c7021 --- /dev/null +++ b/debian/patches/no-packagekit-per-default.diff @@ -0,0 +1,21 @@ +diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu +index 3d138551b593..9cb9831f3236 100644 +--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu ++++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu +@@ -551,13 +551,13 @@ + + + +- true ++ false + + +- true ++ false + + +- true ++ false + + + diff --git a/debian/patches/pdfium-m68k.diff b/debian/patches/pdfium-m68k.diff new file mode 100644 index 000000000..8b9df41fa --- /dev/null +++ b/debian/patches/pdfium-m68k.diff @@ -0,0 +1,20 @@ +don't break pdfium build on m68k + +FIXME: Make this set by autoconf, most of the defines in build_config.h are not actually +used anyway in pdfium... + +diff --git a/external/pdfium/configs/build_config.h b/external/pdfium/configs/build_config.h +index 22084c0a0836..6fd080e644fb 100644 +--- a/external/pdfium/configs/build_config.h ++++ b/external/pdfium/configs/build_config.h +@@ -118,6 +118,9 @@ + #define ARCH_CPU_ARM_FAMILY 1 + #define ARCH_CPU_ARM64 1 + #define ARCH_CPU_64_BITS 1 ++#elif defined(__m68k__) ++#define ARCH_CPU_M68K 1 ++#define ARCH_CPU_32_BITS 1 + #else + #error Please add support for your architecture in build/build_config.h + #endif + diff --git a/debian/patches/reportdesign-mention-package.diff b/debian/patches/reportdesign-mention-package.diff new file mode 100644 index 000000000..f85471bf0 --- /dev/null +++ b/debian/patches/reportdesign-mention-package.diff @@ -0,0 +1,13 @@ +diff --git a/dbaccess/inc/strings.hrc b/dbaccess/inc/strings.hrc +index 47068f43d09e..1f8b9a2331b6 100644 +--- a/dbaccess/inc/strings.hrc ++++ b/dbaccess/inc/strings.hrc +@@ -349,7 +349,7 @@ + #define STR_WARNINGS_DURING_CONNECT NC_("STR_WARNINGS_DURING_CONNECT", "Warnings were encountered while connecting to the data source. Press \"$buttontext$\" to view them.") + #define STR_NAMED_OBJECT_ALREADY_EXISTS NC_("STR_NAMED_OBJECT_ALREADY_EXISTS", "The name '$#$' already exists.\nPlease enter another name." ) + // #i96130# use hard coded name +-#define RID_STR_EXTENSION_NOT_PRESENT NC_("RID_STR_EXTENSION_NOT_PRESENT", "The report, \"$file$\", requires the Report Builder feature.") ++#define RID_STR_EXTENSION_NOT_PRESENT NC_("RID_STR_EXTENSION_NOT_PRESENT", "The report, \"$file$\", requires the Report Builder feature. For this, install the package 'libreoffice-report-builder'.") + + #define STR_COULDNOTCREATE_DRIVERMANAGER NC_("STR_COULDNOTCREATE_DRIVERMANAGER", "Cannot connect to the SDBC driver manager (#servicename#).") + #define STR_NOREGISTEREDDRIVER NC_("STR_NOREGISTEREDDRIVER", "A driver is not registered for the URL #connurl#.") diff --git a/debian/patches/reuse-AllowedLinkProtocolFromDocument-1.diff b/debian/patches/reuse-AllowedLinkProtocolFromDocument-1.diff new file mode 100644 index 000000000..95ec93adc --- /dev/null +++ b/debian/patches/reuse-AllowedLinkProtocolFromDocument-1.diff @@ -0,0 +1,261 @@ +From 530830fdae0f9092fbd93c7be315b2055a841bf3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Wed, 15 Nov 2023 11:39:24 +0000 +Subject: reuse AllowedLinkProtocolFromDocument in writer +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +reorg calc hyperlink check to reuse elsewhere + +Change-Id: I20ae3c5df15502c3a0a366fb4a2924c06ffac3d0 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159487 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit e6a7537762e19fde446441edd10d301f9b37ce75) + +reuse AllowedLinkProtocolFromDocument in writer + +Change-Id: Iacf5e313fc6ca5f7d69ca6986a036f0e1ab1f2a0 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159488 +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit 32535dfa82200b54296838b52285c054fbe5e51d) + +combine these hyperlink dispatchers into one call + +Change-Id: Icb7822e811013de648ccf2fbb23a5f0be9e29bb0 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159489 +Tested-by: Caolán McNamara +Reviewed-by: Caolán McNamara +(cherry picked from commit 0df175ccc6ea542bc5801f631ff72bed187042eb) + +we can have just one LoadURL for writer + +Change-Id: Ia0162ee1c275292fcf200bad4662e4c2c6b7b972 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159557 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 521ca9cf6acbae96cf95d9740859c9682212013d) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159858 +Tested-by: Jenkins CollaboraOffice +Reviewed-by: Miklos Vajna +(cherry picked from commit e32b8601dbd63cf01497889601d6c9c1241106d6) +--- + include/sfx2/objsh.hxx | 7 +++++-- + sc/source/core/data/global.cxx | 32 ++---------------------------- + sfx2/source/doc/objmisc.cxx | 27 +++++++++++++++++++++++++ + sw/source/uibase/shells/drwtxtex.cxx | 8 ++------ + sw/source/uibase/wrtsh/wrtsh2.cxx | 38 +++++++++++++++++++++++------------- + 5 files changed, 60 insertions(+), 52 deletions(-) + +diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx +index 43df4605fe1d..2a65b7a93e7e 100644 +--- a/include/sfx2/objsh.hxx ++++ b/include/sfx2/objsh.hxx +@@ -202,6 +202,9 @@ private: + + SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet ); + ++ // true if the document had macros (or similar) on load to trigger warning user ++ SAL_DLLPRIVATE bool GetHadCheckedMacrosOnLoad() const; ++ + protected: + SfxObjectShell(SfxObjectCreateMode); + SfxObjectShell(SfxModelFlags); // see sfxmodelfactory.hxx +@@ -418,8 +421,8 @@ public: + void SetMacroCallsSeenWhileLoading(); + bool GetMacroCallsSeenWhileLoading() const; + +- // true if the document had macros (or similar) on load to trigger warning user +- bool GetHadCheckedMacrosOnLoad() const; ++ // true if this type of link, from a document, is allowed by the user to be passed to uno:OpenDoc ++ static bool AllowedLinkProtocolFromDocument(const OUString& rUrl, SfxObjectShell* pObjShell, weld::Window* pDialogParent); + + const css::uno::Sequence< css::beans::PropertyValue >& GetModifyPasswordInfo() const; + bool SetModifyPasswordInfo( const css::uno::Sequence< css::beans::PropertyValue >& aInfo ); +diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx +index 9696f7d9414d..3295a38a0243 100644 +--- a/sc/source/core/data/global.cxx ++++ b/sc/source/core/data/global.cxx +@@ -26,9 +26,7 @@ + #include + #include + #include +-#include + #include +-#include + #include + #include + #include +@@ -827,34 +825,8 @@ void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgno + aUrlName = aNewUrlName; + } + +- if (INetURLObject(aUrlName).IsExoticProtocol()) +- { +- // Default to ignoring exotic protocols +- bool bAllow = false; +- if (pObjShell) +- { +- // If the document had macros when loaded then follow the allowed macro-mode +- if (pObjShell->GetHadCheckedMacrosOnLoad()) +- bAllow = pObjShell->AdjustMacroMode(); +- else // otherwise ask the user, defaulting to cancel +- { +- assert(pFrame && "if we have pObjShell we have pFrame"); +- //Reuse URITools::onOpenURI warning string +- std::unique_ptr xQueryBox(Application::CreateMessageDialog(pFrame->GetWindow().GetFrameWeld(), +- VclMessageType::Warning, VclButtonsType::YesNo, +- SfxResId(STR_DANGEROUS_TO_OPEN))); +- xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)", +- INetURLObject::decode(aUrlName, INetURLObject::DecodeMechanism::Unambiguous))); +- xQueryBox->set_default_response(RET_NO); +- bAllow = xQueryBox->run() == RET_YES; +- } +- } +- if (!bAllow) +- { +- SAL_WARN("sc", "ScGlobal::OpenURL ignoring: " << aUrlName); +- return; +- } +- } ++ if (!SfxObjectShell::AllowedLinkProtocolFromDocument(aUrlName, pObjShell, pFrame ? pFrame->GetWindow().GetFrameWeld() : nullptr)) ++ return; + + SfxStringItem aUrl( SID_FILE_NAME, aUrlName ); + SfxStringItem aTarget( SID_TARGETNAME, rTarget ); +diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx +index c7418ef127fd..f372de7fe4b1 100644 +--- a/sfx2/source/doc/objmisc.cxx ++++ b/sfx2/source/doc/objmisc.cxx +@@ -964,6 +964,33 @@ bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const + return pImpl->m_bHadCheckedMacrosOnLoad; + } + ++bool SfxObjectShell::AllowedLinkProtocolFromDocument(const OUString& rUrl, SfxObjectShell* pObjShell, weld::Window* pDialogParent) ++{ ++ if (!INetURLObject(rUrl).IsExoticProtocol()) ++ return true; ++ // Default to ignoring exotic protocols ++ bool bAllow = false; ++ if (pObjShell) ++ { ++ // If the document had macros when loaded then follow the allowed macro-mode ++ if (pObjShell->GetHadCheckedMacrosOnLoad()) ++ bAllow = pObjShell->AdjustMacroMode(); ++ else // otherwise ask the user, defaulting to cancel ++ { ++ //Reuse URITools::onOpenURI warning string ++ std::unique_ptr xQueryBox(Application::CreateMessageDialog(pDialogParent, ++ VclMessageType::Warning, VclButtonsType::YesNo, ++ SfxResId(STR_DANGEROUS_TO_OPEN))); ++ xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)", ++ INetURLObject::decode(rUrl, INetURLObject::DecodeMechanism::Unambiguous))); ++ xQueryBox->set_default_response(RET_NO); ++ bAllow = xQueryBox->run() == RET_YES; ++ } ++ } ++ SAL_WARN_IF(!bAllow, "sfx.appl", "SfxObjectShell::AllowedLinkProtocolFromDocument ignoring: " << rUrl); ++ return bAllow; ++} ++ + void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) + { + OUString aVersion; +diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx +index 60bdf16380be..0e3ba07c3973 100644 +--- a/sw/source/uibase/shells/drwtxtex.cxx ++++ b/sw/source/uibase/shells/drwtxtex.cxx +@@ -545,12 +545,8 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) + const SvxFieldData* pField = pOLV->GetFieldAtCursor(); + if (const SvxURLField* pURLField = dynamic_cast(pField)) + { +- SfxStringItem aUrl(SID_FILE_NAME, pURLField->GetURL()); +- SfxStringItem aTarget(SID_TARGETNAME, pURLField->GetTargetFrame()); +- SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, false); +- SfxBoolItem aBrowsing(SID_BROWSE, true); +- GetView().GetViewFrame()->GetDispatcher()->ExecuteList( +- SID_OPENDOC, SfxCallMode::SYNCHRON, { &aUrl, &aTarget, &aNewView, &aBrowsing }); ++ ::LoadURL(GetShell(), pURLField->GetURL(), LoadUrlFlags::NONE, ++ pURLField->GetTargetFrame()); + } + } + break; +diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx +index 3197c596e52a..7a4088f0c497 100644 +--- a/sw/source/uibase/wrtsh/wrtsh2.cxx ++++ b/sw/source/uibase/wrtsh/wrtsh2.cxx +@@ -490,30 +490,24 @@ bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, LoadUrlFlags nFilter ) + return bRet; + } + +-void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, +- const OUString& rTargetFrameName ) ++static void LoadURL(SwView& rView, const OUString& rURL, LoadUrlFlags nFilter, ++ const OUString& rTargetFrameName) + { +- OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" ); +- if( rURL.isEmpty() ) +- return ; ++ SwDocShell* pDShell = rView.GetDocShell(); ++ OSL_ENSURE( pDShell, "No DocShell?!"); ++ SfxViewFrame* pViewFrame = rView.GetViewFrame(); + +- // The shell could be 0 also!!!!! +- if ( dynamic_cast( &rVSh) == nullptr ) ++ if (!SfxObjectShell::AllowedLinkProtocolFromDocument(rURL, pDShell, pViewFrame->GetWindow().GetFrameWeld())) + return; + + // We are doing tiledRendering, let the client handles the URL loading, + // unless we are jumping to a TOC mark. + if (comphelper::LibreOfficeKit::isActive() && !rURL.startsWith("#")) + { +- rVSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8().getStr()); ++ rView.libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8().getStr()); + return; + } + +- //A CursorShell is always a WrtShell +- SwWrtShell &rSh = static_cast(rVSh); +- +- SwDocShell* pDShell = rSh.GetView().GetDocShell(); +- OSL_ENSURE( pDShell, "No DocShell?!"); + OUString sTargetFrame(rTargetFrameName); + if (sTargetFrame.isEmpty() && pDShell) + { +@@ -528,7 +522,6 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, + OUString sReferer; + if( pDShell && pDShell->GetMedium() ) + sReferer = pDShell->GetMedium()->GetName(); +- SfxViewFrame* pViewFrame = rSh.GetView().GetViewFrame(); + SfxFrameItem aView( SID_DOCFRAME, pViewFrame ); + SfxStringItem aName( SID_FILE_NAME, rURL ); + SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame ); +@@ -554,6 +547,23 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, + SfxCallMode::ASYNCHRON|SfxCallMode::RECORD ); + } + ++void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, ++ const OUString& rTargetFrameName ) ++{ ++ OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" ); ++ if( rURL.isEmpty() ) ++ return ; ++ ++ // The shell could be 0 also!!!!! ++ if ( dynamic_cast( &rVSh) == nullptr ) ++ return; ++ ++ //A CursorShell is always a WrtShell ++ SwWrtShell &rSh = static_cast(rVSh); ++ ++ ::LoadURL(rSh.GetView(), rURL, nFilter, rTargetFrameName); ++} ++ + void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, + const sal_uInt16 nAction ) + { +-- +cgit v1.2.1 + diff --git a/debian/patches/reuse-AllowedLinkProtocolFromDocument-2.diff b/debian/patches/reuse-AllowedLinkProtocolFromDocument-2.diff new file mode 100644 index 000000000..fc603e02b --- /dev/null +++ b/debian/patches/reuse-AllowedLinkProtocolFromDocument-2.diff @@ -0,0 +1,82 @@ +From ddbc78e7879671574e79cc3b93a0ccd362bad30e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Wed, 22 Nov 2023 21:14:41 +0000 +Subject: reuse AllowedLinkProtocolFromDocument in impress/draw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: I73ca4f087946a45dbf92d69a0dc1e769de9b5690 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159843 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit f0942eed2eb328b04856f20613f5226d66b66a20) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159759 +Reviewed-by: Michael Stahl +Signed-off-by: Xisco Fauli +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159884 +Reviewed-by: Miklos Vajna +Signed-off-by: Xisco Fauli +--- + sd/source/ui/app/sdmod1.cxx | 29 ++++++++++++++++++----------- + 1 file changed, 18 insertions(+), 11 deletions(-) + +diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx +index 3d84ddb0da56..8d42653545ea 100644 +--- a/sd/source/ui/app/sdmod1.cxx ++++ b/sd/source/ui/app/sdmod1.cxx +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -193,26 +194,32 @@ void SdModule::Execute(SfxRequest& rReq) + { + bool bIntercept = false; + ::sd::DrawDocShell* pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() ); +- if (pDocShell) ++ ::sd::ViewShell* pViewShell = pDocShell ? pDocShell->GetViewShell() : nullptr; ++ if (pViewShell) + { +- ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); +- if (pViewShell) ++ if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) ) + { +- if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) ) ++ // Prevent documents from opening while the slide ++ // show is running, except when this request comes ++ // from a shape interaction. ++ if (rReq.GetArgs() == nullptr) + { +- // Prevent documents from opening while the slide +- // show is running, except when this request comes +- // from a shape interaction. +- if (rReq.GetArgs() == nullptr) +- { +- bIntercept = true; +- } ++ bIntercept = true; + } + } + } + + if (!bIntercept) + { ++ if (const SfxStringItem* pURLItem = rReq.GetArg(SID_FILE_NAME)) ++ { ++ if (!pViewShell || !SfxObjectShell::AllowedLinkProtocolFromDocument(pURLItem->GetValue(), ++ pViewShell->GetObjectShell(), ++ pViewShell->GetFrameWeld())) ++ { ++ return; ++ } ++ } + SfxGetpApp()->ExecuteSlot(rReq, SfxGetpApp()->GetInterface()); + } + else +-- +cgit v1.2.1 + diff --git a/debian/patches/sc-opengl-optional.diff b/debian/patches/sc-opengl-optional.diff new file mode 100644 index 000000000..20a5cbe21 --- /dev/null +++ b/debian/patches/sc-opengl-optional.diff @@ -0,0 +1,26 @@ +diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx +index c657bd81defc..d5678c089f41 100644 +--- a/sc/source/core/data/global.cxx ++++ b/sc/source/core/data/global.cxx +@@ -71,6 +71,8 @@ + #include + #include + ++#include ++ + tools::SvRef ScGlobal::xDrawClipDocShellRef; + SvxSearchItem* ScGlobal::pSearchItem = nullptr; + ScAutoFormat* ScGlobal::pAutoFormat = nullptr; +@@ -472,7 +474,11 @@ void ScGlobal::InitPPT() + { + OutputDevice* pDev = Application::GetDefaultDevice(); + +- if (comphelper::LibreOfficeKit::isActive() || OpenGLWrapper::isVCLOpenGLEnabled()) ++ if (comphelper::LibreOfficeKit::isActive() ++#if defined HAVE_FEATURE_OPENGL && defined HAVE_FEATURE_UI ++|| OpenGLWrapper::isVCLOpenGLEnabled() ++#endif ++) + { + // LOK: the below limited precision is not enough for RowColumnHeader. + // OpenGL: limited precision breaks AA of text in charts. diff --git a/debian/patches/sc-stack-parameter-count.diff b/debian/patches/sc-stack-parameter-count.diff new file mode 100644 index 000000000..31d969cc6 --- /dev/null +++ b/debian/patches/sc-stack-parameter-count.diff @@ -0,0 +1,221 @@ +From 48ce354351d58f4a63c45d0c56156ff1268bd050 Mon Sep 17 00:00:00 2001 +From: Eike Rathke +Date: Thu, 16 Feb 2023 20:20:31 +0100 +Subject: [PATCH] Obtain actual 0-parameter count for OR(), AND() and + 1-parameter functions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +OR and AND for legacy infix notation are classified as binary +operators but in fact are functions with parameter count. In case +no argument is supplied, GetByte() returns 0 and for that case the +implicit binary operator 2 parameters were wrongly assumed. +Similar for functions expecting 1 parameter, without argument 1 +was assumed. For "real" unary and binary operators the compiler +already checks parameters. Omit OR and AND and 1-parameter +functions from this implicit assumption and return the actual 0 +count. + +Change-Id: Ie05398c112a98021ac2875cf7b6de994aee9d882 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147173 +Reviewed-by: Eike Rathke +Tested-by: Jenkins +(cherry picked from commit e7ce9bddadb2db222eaa5f594ef1de2e36d57e5c) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147129 +Reviewed-by: Caolán McNamara +(cherry picked from commit d6599a2af131994487d2d9223a4fd32a8c3ddc49) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147132 +Reviewed-by: Xisco Fauli +Tested-by: Caolán McNamara +--- + formula/source/core/api/token.cxx | 13 +++++-------- + sc/source/core/tool/interpr4.cxx | 10 +++++++++- + 2 files changed, 14 insertions(+), 9 deletions(-) + +From 48ce354351d58f4a63c45d0c56156ff1268bd050 Mon Sep 17 00:00:00 2001 +From: Eike Rathke +Date: Thu, 16 Feb 2023 20:20:31 +0100 +Subject: [PATCH] Obtain actual 0-parameter count for OR(), AND() and + 1-parameter functions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +OR and AND for legacy infix notation are classified as binary +operators but in fact are functions with parameter count. In case +no argument is supplied, GetByte() returns 0 and for that case the +implicit binary operator 2 parameters were wrongly assumed. +Similar for functions expecting 1 parameter, without argument 1 +was assumed. For "real" unary and binary operators the compiler +already checks parameters. Omit OR and AND and 1-parameter +functions from this implicit assumption and return the actual 0 +count. + +Change-Id: Ie05398c112a98021ac2875cf7b6de994aee9d882 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147173 +Reviewed-by: Eike Rathke +Tested-by: Jenkins +(cherry picked from commit e7ce9bddadb2db222eaa5f594ef1de2e36d57e5c) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147129 +Reviewed-by: Caolán McNamara +(cherry picked from commit d6599a2af131994487d2d9223a4fd32a8c3ddc49) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147132 +Reviewed-by: Xisco Fauli +Tested-by: Caolán McNamara +--- + formula/source/core/api/token.cxx | 13 +++++-------- + sc/source/core/tool/interpr4.cxx | 10 +++++++++- + 2 files changed, 14 insertions(+), 9 deletions(-) + +From ef9af49e1060bfb2a15db81ba10703ebd520bbf6 Mon Sep 17 00:00:00 2001 +From: Eike Rathke +Date: Mon, 27 Feb 2023 16:10:06 +0100 +Subject: [PATCH] Always push a result, even if it's only an error +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +PERCENTILE() and QUARTILE() if an error was passed as argument (or +an error encountered during obtaining arguments) omitted to push +an error result, only setting the error. + +Fallout from + + commit f336f63da900d76c2bf6e5690f1c8a7bd15a0aa2 + CommitDate: Thu Mar 3 16:28:59 2016 +0000 + + tdf#94635 Add FORECAST.ETS functions to Calc + +Change-Id: I23e276fb0ce735cfd6383cc963446499dcf819f4 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147922 +Reviewed-by: Eike Rathke +Tested-by: Jenkins +(cherry picked from commit 64914560e279c71ff1233f4bab851e2a292797e6) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147901 +Reviewed-by: Caolán McNamara +Reviewed-by: Michael Stahl +Tested-by: Christian Lohmaier +Reviewed-by: Christian Lohmaier +--- + sc/source/core/tool/interpr3.cxx | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff -urN libreoffice-7-0-4.old/formula/source/core/api/token.cxx libreoffice-7-0-4/formula/source/core/api/token.cxx +--- libreoffice-7-0-4.old/formula/source/core/api/token.cxx 2021-10-27 07:29:16.182034576 +0200 ++++ libreoffice-7-0-4/formula/source/core/api/token.cxx 2023-05-22 19:05:09.572018039 +0200 +@@ -93,17 +93,14 @@ + return 0; // parameters and specials + // ocIf... jump commands not for FAP, have cByte then + //2do: bool parameter whether FAP or not? +- else if ( GetByte() ) ++ else if (GetByte()) + return GetByte(); // all functions, also ocExternal and ocMacro +- else if (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP) +- return 2; // binary +- else if ((SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP) +- || eOp == ocPercentSign) +- return 1; // unary ++ else if (SC_OPCODE_START_BIN_OP <= eOp && eOp < SC_OPCODE_STOP_BIN_OP && eOp != ocAnd && eOp != ocOr) ++ return 2; // binary operators, compiler checked; OR and AND legacy but are functions ++ else if ((SC_OPCODE_START_UN_OP <= eOp && eOp < SC_OPCODE_STOP_UN_OP) || eOp == ocPercentSign) ++ return 1; // unary operators, compiler checked + else if (SC_OPCODE_START_NO_PAR <= eOp && eOp < SC_OPCODE_STOP_NO_PAR) + return 0; // no parameter +- else if (SC_OPCODE_START_1_PAR <= eOp && eOp < SC_OPCODE_STOP_1_PAR) +- return 1; // one parameter + else if (FormulaCompiler::IsOpCodeJumpCommand( eOp )) + return 1; // only the condition counts as parameter + else +diff -urN libreoffice-7-0-4.old/sc/source/core/inc/interpre.hxx libreoffice-7-0-4/sc/source/core/inc/interpre.hxx +--- libreoffice-7-0-4.old/sc/source/core/inc/interpre.hxx 2021-10-27 07:29:17.774042923 +0200 ++++ libreoffice-7-0-4/sc/source/core/inc/interpre.hxx 2023-05-22 19:05:09.576018095 +0200 +@@ -235,6 +235,7 @@ + inline bool MustHaveParamCount( short nAct, short nMust ); + inline bool MustHaveParamCount( short nAct, short nMust, short nMax ); + inline bool MustHaveParamCountMin( short nAct, short nMin ); ++ inline bool MustHaveParamCountMinWithStackCheck( short nAct, short nMin ); + void PushParameterExpected(); + void PushIllegalParameter(); + void PushIllegalArgument(); +@@ -1089,6 +1090,17 @@ + return false; + } + ++inline bool ScInterpreter::MustHaveParamCountMinWithStackCheck( short nAct, short nMin ) ++{ ++ assert(sp >= nAct); ++ if (sp < nAct) ++ { ++ PushParameterExpected(); ++ return false; ++ } ++ return MustHaveParamCountMin( nAct, nMin); ++} ++ + inline bool ScInterpreter::CheckStringPositionArgument( double & fVal ) + { + if (!std::isfinite( fVal)) +diff -urN libreoffice-7-0-4.old/sc/source/core/tool/interpr1.cxx libreoffice-7-0-4/sc/source/core/tool/interpr1.cxx +--- libreoffice-7-0-4.old/sc/source/core/tool/interpr1.cxx 2023-05-20 18:17:05.645488480 +0200 ++++ libreoffice-7-0-4/sc/source/core/tool/interpr1.cxx 2023-05-22 19:06:29.129145235 +0200 +@@ -7528,7 +7528,7 @@ + void ScInterpreter::ScSubTotal() + { + sal_uInt8 nParamCount = GetByte(); +- if ( MustHaveParamCountMin( nParamCount, 2 ) ) ++ if ( MustHaveParamCountMinWithStackCheck( nParamCount, 2 ) ) + { + // We must fish the 1st parameter deep from the stack! And push it on top. + const FormulaToken* p = pStack[ sp - nParamCount ]; +@@ -7575,7 +7575,7 @@ + void ScInterpreter::ScAggregate() + { + sal_uInt8 nParamCount = GetByte(); +- if ( MustHaveParamCountMin( nParamCount, 3 ) ) ++ if ( MustHaveParamCountMinWithStackCheck( nParamCount, 3 ) ) + { + const FormulaError nErr = nGlobalError; + nGlobalError = FormulaError::NONE; +diff -urN libreoffice-7-0-4.old/sc/source/core/tool/interpr3.cxx libreoffice-7-0-4/sc/source/core/tool/interpr3.cxx +--- libreoffice-7-0-4.old/sc/source/core/tool/interpr3.cxx 2021-10-27 07:29:17.798043049 +0200 ++++ libreoffice-7-0-4/sc/source/core/tool/interpr3.cxx 2023-05-22 19:05:09.584018209 +0200 +@@ -3478,7 +3478,7 @@ + GetNumberSequenceArray( 1, aArray, false ); + if ( aArray.empty() || nGlobalError != FormulaError::NONE ) + { +- SetError( FormulaError::NoValue ); ++ PushNoValue(); + return; + } + if ( bInclusive ) +@@ -3501,7 +3501,7 @@ + GetNumberSequenceArray( 1, aArray, false ); + if ( aArray.empty() || nGlobalError != FormulaError::NONE ) + { +- SetError( FormulaError::NoValue ); ++ PushNoValue(); + return; + } + if ( bInclusive ) +diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx +index 347377ed0a90..80a0e3027bc3 100644 +--- a/sc/source/core/tool/interpr4.cxx ++++ b/sc/source/core/tool/interpr4.cxx +@@ -4023,7 +4023,15 @@ StackVar ScInterpreter::Interpret() + else if (sp >= pCur->GetParamCount()) + nStackBase = sp - pCur->GetParamCount(); + else +- nStackBase = sp; // underflow?!? ++ { ++ SAL_WARN("sc.core", "Stack anomaly at " << aPos.Format( ++ ScRefFlags::VALID | ScRefFlags::FORCE_DOC | ScRefFlags::TAB_3D, pDok) ++ << " eOp: " << static_cast(eOp) ++ << " params: " << static_cast(pCur->GetParamCount()) ++ << " nStackBase: " << nStackBase << " sp: " << sp); ++ nStackBase = sp; ++ assert(!"underflow"); ++ } + } + + switch( eOp ) diff --git a/debian/patches/search-usr-share-for-images.diff b/debian/patches/search-usr-share-for-images.diff new file mode 100644 index 000000000..6b91fcc12 --- /dev/null +++ b/debian/patches/search-usr-share-for-images.diff @@ -0,0 +1,137 @@ +diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx +index 41c4f56..93d80f1 100644 +--- a/vcl/inc/impimagetree.hxx ++++ b/vcl/inc/impimagetree.hxx +@@ -85,6 +85,10 @@ private: + typedef boost::unordered_map< + rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > IconCache; + ++ // we want to search zip files (icons) also in /usr/share/ ++ ::rtl::OUString m_datadir; // /usr/share/ ++ ::rtl::OUString m_libdir; // /usr/lib or /usr/lib64 ++ + rtl::OUString m_style; + Zips m_zips; + CheckStyleCache m_checkStyleCache; +@@ -92,6 +96,7 @@ private: + + void setStyle(rtl::OUString const & style ); + ++ void addUrlToZips(const rtl::OUString &url); + void resetZips(); + + bool checkStyleCacheLookup( rtl::OUString const & style, bool &exists ); +diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx +index 03442fc..cfe6c45 100644 +--- a/vcl/source/gdi/impimagetree.cxx ++++ b/vcl/source/gdi/impimagetree.cxx +@@ -121,7 +121,11 @@ void loadFromStream( + + } + +-ImplImageTree::ImplImageTree() {} ++ImplImageTree::ImplImageTree() ++{ ++ m_datadir = ::rtl::OUString::createFromAscii ( "/usr/share/" ); ++ m_libdir = ::rtl::OUString::createFromAscii ( "/usr/lib/" ); ++} + + ImplImageTree::~ImplImageTree() {} + +@@ -259,6 +263,22 @@ void ImplImageTree::setStyle(rtl::OUString const & style) { + } + } + ++void ImplImageTree::addUrlToZips(const rtl::OUString &url) { ++ if ( url.getLength() == 0 ) ++ return; ++ m_zips.push_back( ++ std::make_pair( ++ url, ++ css::uno::Reference< css::container::XNameAccess >())); ++ sal_Int32 nLibDirPos = url.indexOf( m_libdir ); ++ if ( nLibDirPos >= 0 ) { ++ m_zips.push_back( ++ std::make_pair( ++ url.replaceAt( nLibDirPos, m_libdir.getLength(), m_datadir ), ++ css::uno::Reference< css::container::XNameAccess >())); ++ } ++} ++ + void ImplImageTree::resetZips() { + m_zips.clear(); + { +@@ -284,19 +304,14 @@ void ImplImageTree::resetZips() { + b.appendAscii(RTL_CONSTASCII_STRINGPARAM("_brand.zip")); + bool ok = u.Append(b.makeStringAndClear(), INetURLObject::ENCODE_ALL); + OSL_ASSERT(ok); (void) ok; +- m_zips.push_back( +- std::make_pair( +- u.GetMainURL(INetURLObject::NO_DECODE), +- css::uno::Reference< css::container::XNameAccess >())); ++ addUrlToZips(u.GetMainURL(INetURLObject::NO_DECODE)); + } + { + rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM( + "$BRAND_BASE_DIR/share/config/images_brand.zip")); + rtl::Bootstrap::expandMacros(url); +- m_zips.push_back( +- std::make_pair( +- url, css::uno::Reference< css::container::XNameAccess >())); ++ addUrlToZips(url); + } + { + rtl::OUString url( +@@ -310,10 +310,7 @@ + b.appendAscii(RTL_CONSTASCII_STRINGPARAM(".zip")); + bool ok = u.Append(b.makeStringAndClear(), INetURLObject::ENCODE_ALL); + OSL_ASSERT(ok); (void) ok; +- m_zips.push_back( +- std::make_pair( +- u.GetMainURL(INetURLObject::NO_DECODE), +- css::uno::Reference< css::container::XNameAccess >())); ++ addUrlToZips(u.GetMainURL(INetURLObject::NO_DECODE)); + } + if ( m_style == "default" ) + { +@@ -321,9 +333,7 @@ void ImplImageTree::resetZips() { + RTL_CONSTASCII_USTRINGPARAM( + "$BRAND_BASE_DIR/share/config/images.zip")); + rtl::Bootstrap::expandMacros(url); +- m_zips.push_back( +- std::make_pair( +- url, css::uno::Reference< css::container::XNameAccess >())); ++ addUrlToZips(url); + } + } + +diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx +index e55fe5d..848bed7 100644 +--- a/xmlhelp/source/cxxhelp/provider/provider.cxx ++++ b/xmlhelp/source/cxxhelp/provider/provider.cxx +@@ -335,7 +335,7 @@ void ContentProvider::init() + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( " " )) + + setupextension ); + +- uno::Sequence< rtl::OUString > aImagesZipPaths( 2 ); ++ uno::Sequence< rtl::OUString > aImagesZipPaths( 3 ); + xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" ); + + rtl::OUString aPath( getKey( xHierAccess, "Path/Current/UserConfig" ) ); +@@ -344,6 +344,15 @@ void ContentProvider::init() + + aPath = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/share/config")); + rtl::Bootstrap::expandMacros(aPath); ++ aImagesZipPaths[ 2 ] = aPath; ++ ++ // try also /usr/share and even before /usr/lib ++ ::rtl::OUString aDataDir = ::rtl::OUString::createFromAscii ( "/usr/share/" ); ++ ::rtl::OUString aLibDir = ::rtl::OUString::createFromAscii ( "/usr/lib/" ); ++ sal_Int32 nLibDirPos = aPath.indexOf( aLibDir ); ++ ++ if ( nLibDirPos >= 0 ) ++ aPath = aPath.replaceAt( nLibDirPos, aLibDir.getLength(), aDataDir ); + aImagesZipPaths[ 1 ] = aPath; + + uno::Reference< uno::XComponentContext > xContext; diff --git a/debian/patches/sensible-lomua.diff b/debian/patches/sensible-lomua.diff new file mode 100644 index 000000000..6b98bbc4d --- /dev/null +++ b/debian/patches/sensible-lomua.diff @@ -0,0 +1,50 @@ +Index: libreoffice-3.6.2~rc1/officecfg/registry/data/org/openoffice/Office/Common.xcu +=================================================================== +--- libreoffice-3.6.2~rc1.orig/officecfg/registry/data/org/openoffice/Office/Common.xcu 2012-10-07 21:03:17.662850386 -0400 ++++ libreoffice-3.6.2~rc1/officecfg/registry/data/org/openoffice/Office/Common.xcu 2012-10-07 21:03:57.174850591 -0400 +@@ -655,7 +655,7 @@ + + + +- ++ sensible-lomua + + + +Index: libreoffice-3.6.2~rc1/shell/source/unix/misc/senddoc.sh +=================================================================== +--- libreoffice-3.6.2~rc1.orig/shell/source/unix/misc/senddoc.sh 2012-10-07 21:03:17.662850386 -0400 ++++ libreoffice-3.6.2~rc1/shell/source/unix/misc/senddoc.sh 2012-10-07 21:29:13.074858447 -0400 +@@ -59,6 +59,32 @@ + shift + fi + ++case `basename "$MAILER"` in ++ sensible-lomua) ++ if [ -x /usr/bin/xdg-email ] ; then ++ MAILER=/usr/bin/xdg-email ++ elif [ -n "$KDE_FULL_SESSION" -a -x /usr/bin/kde-open ] \ ++ || [ -x /usr/bin/gnome-open ] \ ++ || [ -x /usr/bin/xdg-open ]; then ++ # use an undefined mailer, to trigger the default handling ++ MAILER=undefined ++ elif [ -n "$GNOME_DESKTOP_SESSION_ID" -a -x /usr/bin/evolution ]; then ++ MAILER=/usr/bin/evolution ++ elif [ -n "$KDE_FULL_SESSION" -a -x /usr/bin/kmail ]; then ++ MAILER=/usr/bin/kmail ++ elif [ -x /usr/bin/evolution ]; then ++ # default ++ MAILER=/usr/bin/evolution ++ elif [ -x /usr/bin/icedove ]; then ++ # fallback ++ MAILER=/usr/bin/icedove ++ elif [ -x /usr/bin/thunderbird ]; then ++ # fallback ++ MAILER=/usr/bin/thunderbird ++ fi ++ ;; ++esac ++ + # autodetect mail client from executable name + case $(basename "$MAILER" | sed 's/-.*$//') in + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..1e2a8909c --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,78 @@ +no-check-if-root.diff +debian-opt.diff +jurt-soffice-location.diff +split-evoab.diff +debian-debug.diff +#fix-system-lpsolve-build.diff +build-against-shared-lpsolve.diff +install-fixes.diff +mention-java-common-package.diff +help-msg-add-package-info.diff +sensible-lomua.diff +reportdesign-mention-package.diff +jdbc-driver-classpaths.diff +#search-usr-share-for-images.diff +make-package-modules-not-suck.diff +mediwiki-oor-replace.diff +debian-hardened-buildflags-CPPFLAGS.diff +debian-hardened-buildflags-no-LO-fstack-protector-strong.diff +disable-flaky-tests.diff +#dont-touch-urd.diff +fix-internal-hsqldb-build.diff +javadoc-optional.diff +hppa-is-32bit.diff +no-packagekit-per-default.diff +system-officeotron-and-odfvalidator.diff +no-openssl.diff +cppunit-optional.diff +#disable-unused-test-programs.diff +apparmor-complain.diff +hide-math-desktop-file.patch +appstream-ignore-startcenter.diff +disable-java-in-odk-build-examples-on-zero-vm.diff +do-not-hide-test-output.diff +apparmor-allow-java.security.diff +apparmor-cleanups.diff +apparmor-mesa.diff +disableClassPathURLCheck.diff +use-mariadb-java-instead-of-mysql-java.diff +apparmor-opencl.diff +fix-uicheck-tests-on-i386.patch +fix-flaky-bridgetest.diff +add-access2base-doc.diff +sc-opengl-optional.diff +fix-lo-xlate-lang-nb.diff +disable-shortcuts_tab_navigation-uitest.diff +no-opencl-per-default.diff +bigendian.diff +liborcus-0.16.diff +bash-completion-DRAWDOCS-pdf.diff +fix-bluez-external.diff +unowinreg-static-libgcc.diff +pdfium-m68k.diff +apparmor-updates.diff +xmlsecurity-replace-XSecParser-implementation.diff +xmlsecurity-XSecParser-confused-about-multiple-timestamps.diff +xmlsecurity-ignore-elements-in-ds:Object-that-arent-signed.diff +default-to-CertificateValidity::INVALID.diff +xmlsecurity-improve-handling-of-multiple-X509Data-elements.diff +hrk-euro.diff +b0404f80577de9ff69e58390c6f6ef949fdb0139.patch +0001-CVE-2022-26305-compare-authors-using-Thumbprint.patch +0002-CVE-2022-26307-make-hash-encoding-match-decoding.patch +0003-CVE-2022-26306-add-Initialization-Vectors-to-passwor.patch +0004-CVE-2022-2630-6-7-add-infobar-to-prompt-to-refresh-t.patch +fix-e_book_client_connect_direct_sync-sig.diff +ZDI-CAN-17859.diff +hrk-euro-default.diff +avoid-empty-java.class.path.diff +CVE-2023-2255.diff +sc-stack-parameter-count.diff +escape-url-passed-to-gstreamer.diff +improve-macro-checks.diff +floating-frame-targets-unneeded-protocols.diff +warn-about-exotic-protocols-as-well.diff +ignore-LO-special-purpose-hyperlinks-per-default.diff +reuse-AllowedLinkProtocolFromDocument-1.diff +reuse-AllowedLinkProtocolFromDocument-2.diff +work-around-expired-certificiate-in-test.diff diff --git a/debian/patches/split-evoab.diff b/debian/patches/split-evoab.diff new file mode 100644 index 000000000..f56356009 --- /dev/null +++ b/debian/patches/split-evoab.diff @@ -0,0 +1,61 @@ +diff --git a/scp2/source/gnome/file_gnome.scp b/scp2/source/gnome/file_gnome.scp +index c7a13c8..a3f59a6 100644 +--- a/scp2/source/gnome/file_gnome.scp ++++ b/scp2/source/gnome/file_gnome.scp +@@ -25,3 +25,13 @@ File gid_File_Share_Registry_Gnome_Xcd + Name = "gnome.xcd"; + End + #endif ++ ++#ifdef ENABLE_EVOAB2 ++File gid_File_Share_Registry_Evoab_Xcd ++ TXT_FILE_BODY; ++ Styles = (PACKED); ++ Dir = gid_Brand_Dir_Share_Registry; ++ Name = "evoab.xcd"; ++End ++#endif ++ +diff --git a/scp2/source/gnome/module_gnome.scp b/scp2/source/gnome/module_gnome.scp +index 08d9efe..492e274 100644 +--- a/scp2/source/gnome/module_gnome.scp ++++ b/scp2/source/gnome/module_gnome.scp +@@ -31,6 +31,9 @@ Module gid_Module_Optional_Gnome + #if ENABLE_GIO + ,gid_File_Share_Registry_Gnome_Xcd + #endif ++#ifdef ENABLE_EVOAB2 ++ ,gid_File_Share_Registry_Evoab_Xcd ++#endif + ); + End + +diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk +index 510b444..3ff190f 100644 +--- a/postprocess/CustomTarget_registry.mk ++++ b/postprocess/CustomTarget_registry.mk +@@ -331,8 +331,9 @@ ifneq ($(WITH_WEBDAV),) + postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/ucb/Configuration-webdav.xcu + endif + ifeq ($(ENABLE_EVOAB2),TRUE) +-postprocess_FILES_main += $(call gb_XcuModuleTarget_get_target,connectivity/registry/evoab2)/org/openoffice/Office/DataAccess/Drivers-evoab2.xcu +-postprocess_FILES_main += $(postprocess_MOD)/org/openoffice/Office/DataAccess-evoab2.xcu ++postprocess_XCDS += evoab.xcd ++postprocess_FILES_evoab += $(call gb_XcuModuleTarget_get_target,connectivity/registry/evoab2)/org/openoffice/Office/DataAccess/Drivers-evoab2.xcu ++postprocess_FILES_evoab += $(postprocess_MOD)/org/openoffice/Office/DataAccess-evoab2.xcu + postprocess_DRIVERS += evoab + endif + ifeq ($(ENABLE_JAVA),TRUE) +diff --git a/scp2/InstallModule_gnome.mk b/scp2/InstallModule_gnome.mk +index c33f4f52d67b..8f06c0273eff 100644 +--- a/scp2/InstallModule_gnome.mk ++++ b/scp2/InstallModule_gnome.mk +@@ -19,4 +19,8 @@ $(eval $(call gb_InstallModule_add_localized_scpfiles,scp2/gnome,\ + scp2/source/gnome/module_gnome \ + )) + ++$(eval $(call gb_InstallModule_define_if_set,scp2/gnome,\ ++ ENABLE_EVOAB2 \ ++)) ++ + # vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/debian/patches/system-officeotron-and-odfvalidator.diff b/debian/patches/system-officeotron-and-odfvalidator.diff new file mode 100644 index 000000000..971608ef9 --- /dev/null +++ b/debian/patches/system-officeotron-and-odfvalidator.diff @@ -0,0 +1,16 @@ +diff --git a/bin/odfvalidator.sh.in b/bin/odfvalidator.sh.in +index 56e2f29..9415ef6 100644 +--- a/bin/odfvalidator.sh.in ++++ b/bin/odfvalidator.sh.in +@@ -1,2 +1,2 @@ + #!/usr/bin/env bash +-java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar @TARFILE_LOCATION@/@ODFVALIDATOR_JAR@ "$@" ++java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar /usr/share/java/odfvalidator.jar "$@" +diff --git a/bin/officeotron.sh.in b/bin/officeotron.sh.in +index 7281f1b..6eab5b5 100644 +--- a/bin/officeotron.sh.in ++++ b/bin/officeotron.sh.in +@@ -1,2 +1,2 @@ + #!/usr/bin/env bash +-java -jar @TARFILE_LOCATION@/@OFFICEOTRON_JAR@ "$@" ++java -jar /usr/share/java/officeotron.jar "$@" diff --git a/debian/patches/unowinreg-static-libgcc.diff b/debian/patches/unowinreg-static-libgcc.diff new file mode 100644 index 000000000..d3e600f6b --- /dev/null +++ b/debian/patches/unowinreg-static-libgcc.diff @@ -0,0 +1,13 @@ +diff --git a/odk/CustomTarget_unowinreg.mk b/odk/CustomTarget_unowinreg.mk +index 3a46ddfd6860..a847e1d6bb38 100644 +--- a/odk/CustomTarget_unowinreg.mk ++++ b/odk/CustomTarget_unowinreg.mk +@@ -19,7 +19,7 @@ $(call gb_CustomTarget_get_workdir,odk/unowinreg)/unowinreg.dll : \ + $(if $(filter FREEBSD,$(OS)),-I$(JAVA_HOME)/include/freebsd \ + -I$(JAVA_HOME)/include/bsd -I$(JAVA_HOME)/include/linux,\ + $(if $(filter NETBSD,$(OS)),-I$(JAVA_HOME)/include/netbsd))) \ +- -shared -o $@ $< \ ++ -shared -static-libgcc -o $@ $< \ + -Wl,--kill-at -lkernel32 -ladvapi32 && \ + $(MINGWSTRIP) $@ + diff --git a/debian/patches/use-mariadb-java-instead-of-mysql-java.diff b/debian/patches/use-mariadb-java-instead-of-mysql-java.diff new file mode 100644 index 000000000..a88823c39 --- /dev/null +++ b/debian/patches/use-mariadb-java-instead-of-mysql-java.diff @@ -0,0 +1,59 @@ +>From 1172166889764ae0e77488e5d173f33961b9859b Mon Sep 17 00:00:00 2001 +From: Markus Koschany +Date: Fri, 9 Nov 2018 23:06:15 +0100 +Subject: [PATCH] mariadb + +--- + connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java | 4 ++-- + .../mysql/org/openoffice/Office/DataAccess/Drivers.xcu | 2 +- + connectivity/source/drivers/mysql/YDriver.cxx | 4 ++-- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java b/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java +index 3817add48da6..ace57bd35d98 100644 +--- a/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java ++++ b/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java +@@ -64,7 +64,7 @@ public class JdbcLongVarCharTest extends ComplexTestCase + */ + String url = System.getenv("CONNECTIVITY_TEST_MYSQL_DRIVER_JDBC"); + com.sun.star.beans.PropertyValue prop[] = new PropertyValue[1]; +- prop[0] = new PropertyValue("JavaDriverClass", 0, "com.mysql.jdbc.Driver", PropertyState.DIRECT_VALUE); ++ prop[0] = new PropertyValue("JavaDriverClass", 0, "org.mariadb.jdbc.Driver", PropertyState.DIRECT_VALUE); + + // get the remote office component context + XMultiServiceFactory xServiceManager = param.getMSF(); +diff --git a/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu +index 77988448f..acd8bfdaf 100644 +--- a/connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu ++++ b/connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu +@@ -33,7 +33,7 @@ + + + +- com.mysql.jdbc.Driver ++ org.mariadb.jdbc.Driver + + + +diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx +index 95094265e..c0ad7802e 100644 +--- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx ++++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx +@@ -54,7 +54,7 @@ namespace + OUString getJavaDriverClass(css::uno::Sequence const& info) + { + return comphelper::NamedValueCollection(info).getOrDefault("JavaDriverClass", +- OUString("com.mysql.jdbc.Driver")); ++ OUString("org.mariadb.jdbc.Driver")); + } + } + +@@ -170,7 +170,7 @@ Sequence lcl_convertProperties(T_DRIVERTYPE _eType, + if (!jdc) + { + aProps.push_back(PropertyValue("JavaDriverClass", 0, +- makeAny(OUString("com.mysql.jdbc.Driver")), ++ makeAny(OUString("org.mariadb.jdbc.Driver")), + PropertyState_DIRECT_VALUE)); + } + } diff --git a/debian/patches/warn-about-exotic-protocols-as-well.diff b/debian/patches/warn-about-exotic-protocols-as-well.diff new file mode 100644 index 000000000..3ce5f4875 --- /dev/null +++ b/debian/patches/warn-about-exotic-protocols-as-well.diff @@ -0,0 +1,79 @@ +From b245f1e20e67c1e73a702425ab41df8eb58452e3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Sat, 4 Nov 2023 19:57:51 +0000 +Subject: warn about exotic protocols as well +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: I50dcf4f36cd20d75f5ad3876353143268740a50f +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151834 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +(cherry picked from commit 1305f70cff8a81a58a5a6d9c96c5bb032005389e) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159034 +Reviewed-by: Eike Rathke +(cherry picked from commit 2e1bcbb550d54278b366ec619cc5280d44d6aba4) +--- + sw/source/filter/html/htmlplug.cxx | 2 +- + sw/source/filter/xml/xmltexti.cxx | 2 +- + tools/source/fsys/urlobj.cxx | 3 ++- + xmloff/source/draw/ximpshap.cxx | 2 +- + 4 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx +index eb707040adb2..112975f98511 100644 +--- a/sw/source/filter/html/htmlplug.cxx ++++ b/sw/source/filter/html/htmlplug.cxx +@@ -1089,7 +1089,7 @@ void SwHTMLParser::InsertFloatingFrame() + + OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + +- if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) ++ if (INetURLObject(sHRef).IsExoticProtocol()) + NotifyMacroEventRead(); + + xSet->setPropertyValue("FrameURL", uno::makeAny( sHRef ) ); +diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx +index 169cbdc1534d..caf300f239c6 100644 +--- a/sw/source/filter/xml/xmltexti.cxx ++++ b/sw/source/filter/xml/xmltexti.cxx +@@ -856,7 +856,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra + OUString sHRef = URIHelper::SmartRel2Abs( + INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ); + +- if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) ++ if (INetURLObject(sHRef).IsExoticProtocol()) + GetXMLImport().NotifyMacroEventRead(); + + xSet->setPropertyValue("FrameURL", +diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx +index ab6e885639db..1ef2b7e0b2af 100644 +--- a/tools/source/fsys/urlobj.cxx ++++ b/tools/source/fsys/urlobj.cxx +@@ -4776,7 +4776,8 @@ bool INetURLObject::IsExoticProtocol() const + return m_eScheme == INetProtocol::Slot || + m_eScheme == INetProtocol::Macro || + m_eScheme == INetProtocol::Uno || +- isSchemeEqualTo(u"vnd.sun.star.script"); ++ isSchemeEqualTo(u"vnd.sun.star.script") || ++ isSchemeEqualTo(u"service"); + } + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx +index 44b5177501f1..30c303690d97 100644 +--- a/xmloff/source/draw/ximpshap.cxx ++++ b/xmloff/source/draw/ximpshap.cxx +@@ -3269,7 +3269,7 @@ void SdXMLFloatingFrameShapeContext::StartElement( const css::uno::Reference< cs + + if( !maHref.isEmpty() ) + { +- if (INetURLObject(maHref).GetProtocol() == INetProtocol::Macro) ++ if (INetURLObject(maHref).IsExoticProtocol()) + GetImport().NotifyMacroEventRead(); + + xProps->setPropertyValue("FrameURL", Any(maHref) ); +-- +cgit v1.2.1 + diff --git a/debian/patches/work-around-expired-certificiate-in-test.diff b/debian/patches/work-around-expired-certificiate-in-test.diff new file mode 100644 index 000000000..f4f87dba4 --- /dev/null +++ b/debian/patches/work-around-expired-certificiate-in-test.diff @@ -0,0 +1,24 @@ +diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx +index 1898d3f1377f..be3d9ebd3253 100644 +--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx ++++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx +@@ -2829,7 +2829,8 @@ void DesktopLOKTest::testInsertCertificate_PEM_ODT() + } + + int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); +- CPPUNIT_ASSERT_EQUAL(int(1), nState); ++ // OK or NOTVALIDATED (signature is OK, but certificate could not be validated) ++ CPPUNIT_ASSERT(nState == 1 || nState == 4); + } + + void DesktopLOKTest::testInsertCertificate_PEM_DOCX() +@@ -2886,7 +2887,8 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX() + } + + int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); +- CPPUNIT_ASSERT_EQUAL(int(5), nState); ++ // PARTIAL_OK or NOTVALIDATED_PARTIAL_OK ++ CPPUNIT_ASSERT(nState == 5 || nState == 6); + } + + void DesktopLOKTest::testSignDocument_PEM_PDF() diff --git a/debian/patches/xmlsecurity-XSecParser-confused-about-multiple-timestamps.diff b/debian/patches/xmlsecurity-XSecParser-confused-about-multiple-timestamps.diff new file mode 100644 index 000000000..51327d5ee --- /dev/null +++ b/debian/patches/xmlsecurity-XSecParser-confused-about-multiple-timestamps.diff @@ -0,0 +1,393 @@ +From abe77c4fcb9ea97d9fff07eaea6d8863bcba5b02 Mon Sep 17 00:00:00 2001 +From: Michael Stahl +Date: Thu, 18 Feb 2021 19:22:31 +0100 +Subject: xmlsecurity: XSecParser confused about multiple timestamps +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +LO writes timestamp both to dc:date and xades:SigningTime elements. + +The parser tries to avoid reading multiple dc:date, preferring the first +one, but doesn't care about multiple xades:SigningTime, for undocumented +reasons. + +Ideally something should check all read values for consistency. + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111160 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 4ab8d9c09a5873ca0aea56dafa1ab34758d52ef7) + +xmlsecurity: remove XSecController::setPropertyId() + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111252 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit d2a345e1163616fe3201ef1d6c758e2e819214e0) + +Change-Id: Ic018ee89797a1c8a4f870ae102af48006de930ef +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111908 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +--- + include/svl/sigstruct.hxx | 7 ++- + xmlsecurity/inc/xsecctl.hxx | 5 +- + xmlsecurity/source/helper/ooxmlsecparser.cxx | 4 +- + xmlsecurity/source/helper/xsecctl.cxx | 2 +- + xmlsecurity/source/helper/xsecparser.cxx | 81 ++++++++++++++-------------- + xmlsecurity/source/helper/xsecparser.hxx | 6 --- + xmlsecurity/source/helper/xsecsign.cxx | 4 +- + xmlsecurity/source/helper/xsecverify.cxx | 39 ++++++-------- + 8 files changed, 68 insertions(+), 80 deletions(-) + +diff --git a/include/svl/sigstruct.hxx b/include/svl/sigstruct.hxx +index 38c1ee5ed142..d62ecb09634c 100644 +--- a/include/svl/sigstruct.hxx ++++ b/include/svl/sigstruct.hxx +@@ -103,6 +103,9 @@ struct SignatureInformation + // XAdES EncapsulatedX509Certificate values + std::set maEncapsulatedX509Certificates; + ++ OUString ouSignatureId; ++ // signature may contain multiple time stamps - check they're consistent ++ bool hasInconsistentSigningTime = false; + //We also keep the date and time as string. This is done when this + //structure is created as a result of a XML signature being read. + //When then a signature is added or another removed, then the original +@@ -115,8 +118,8 @@ struct SignatureInformation + //and the converted time is written back, then the string looks different + //and the signature is broken. + OUString ouDateTime; +- OUString ouSignatureId; +- OUString ouPropertyId; ++ /// The Id attribute of the element that contains the . ++ OUString ouDateTimePropertyId; + /// Characters of the element inside the signature. + OUString ouDescription; + /// The Id attribute of the element that contains the . +diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx +index 324f1c43388b..759a660d90ad 100644 +--- a/xmlsecurity/inc/xsecctl.hxx ++++ b/xmlsecurity/inc/xsecctl.hxx +@@ -271,8 +271,8 @@ private: + void setGpgCertificate( OUString const & ouGpgCert ); + void setGpgOwner( OUString const & ouGpgOwner ); + +- void setDate( OUString const & ouDate ); +- void setDescription(const OUString& rDescription); ++ void setDate(OUString const& rId, OUString const& ouDate); ++ void setDescription(OUString const& rId, OUString const& rDescription); + void setCertDigest(const OUString& rCertDigest); + void setValidSignatureImage(const OUString& rValidSigImg); + void setInvalidSignatureImage(const OUString& rInvalidSigImg); +@@ -283,7 +283,6 @@ public: + + private: + void setId( OUString const & ouId ); +- void setPropertyId( OUString const & ouPropertyId ); + + css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > prepareSignatureToRead( + sal_Int32 nSecurityId ); +diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx +index c22e8c2261bf..a200de60c07a 100644 +--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx ++++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx +@@ -192,12 +192,12 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) + } + else if (rName == "mdssi:Value") + { +- m_pXSecController->setDate(m_aMdssiValue); ++ m_pXSecController->setDate("", m_aMdssiValue); + m_bInMdssiValue = false; + } + else if (rName == "SignatureComments") + { +- m_pXSecController->setDescription(m_aSignatureComments); ++ m_pXSecController->setDescription("", m_aSignatureComments); + m_bInSignatureComments = false; + } + else if (rName == "X509IssuerName") +diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx +index cac30006b6a7..e3df9a85f6da 100644 +--- a/xmlsecurity/source/helper/xsecctl.cxx ++++ b/xmlsecurity/source/helper/xsecctl.cxx +@@ -815,7 +815,7 @@ void XSecController::exportSignature( + pAttributeList = new SvXMLAttributeList(); + pAttributeList->AddAttribute( + "Id", +- signatureInfo.ouPropertyId); ++ signatureInfo.ouDateTimePropertyId); + pAttributeList->AddAttribute( + "Target", + "#" + signatureInfo.ouSignatureId); +diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx +index 0aecb1854f8c..1418b7b43b46 100644 +--- a/xmlsecurity/source/helper/xsecparser.cxx ++++ b/xmlsecurity/source/helper/xsecparser.cxx +@@ -974,6 +974,9 @@ class XSecParser::XadesSigningCertificateContext + class XSecParser::XadesSigningTimeContext + : public XSecParser::Context + { ++ private: ++ OUString m_Value; ++ + public: + XadesSigningTimeContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap) +@@ -981,20 +984,14 @@ class XSecParser::XadesSigningTimeContext + { + } + +- virtual void StartElement( +- css::uno::Reference const& /*xAttrs*/) override +- { +- m_rParser.m_ouDate.clear(); +- } +- + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setDate( m_rParser.m_ouDate ); ++ m_rParser.m_pXSecController->setDate("", m_Value); + } + + virtual void Characters(OUString const& rChars) override + { +- m_rParser.m_ouDate += rChars; ++ m_Value += rChars; + } + }; + +@@ -1100,35 +1097,20 @@ class XSecParser::DcDateContext + : public XSecParser::Context + { + private: +- bool m_isIgnore = false; ++ OUString & m_rValue; + + public: + DcDateContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) ++ std::unique_ptr pOldNamespaceMap, ++ OUString & rValue) + : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) + { + } + +- virtual void StartElement( +- css::uno::Reference const& /*xAttrs*/) override +- { +- m_isIgnore = !m_rParser.m_ouDate.isEmpty(); +- } +- +- virtual void EndElement() override +- { +- if (!m_isIgnore) +- { +- m_rParser.m_pXSecController->setDate( m_rParser.m_ouDate ); +- } +- } +- + virtual void Characters(OUString const& rChars) override + { +- if (!m_isIgnore) +- { +- m_rParser.m_ouDate += rChars; +- } ++ m_rValue += rChars; + } + }; + +@@ -1136,29 +1118,32 @@ class XSecParser::DcDescriptionContext + : public XSecParser::Context + { + private: +- OUString m_Value; ++ OUString & m_rValue; + + public: + DcDescriptionContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) ++ std::unique_ptr pOldNamespaceMap, ++ OUString & rValue) + : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) + { + } + +- virtual void EndElement() override +- { +- m_rParser.m_pXSecController->setDescription(m_Value); +- } +- + virtual void Characters(OUString const& rChars) override + { +- m_Value += rChars; ++ m_rValue += rChars; + } + }; + + class XSecParser::DsSignaturePropertyContext + : public XSecParser::Context + { ++ private: ++ enum class SignatureProperty { Unknown, Date, Description }; ++ SignatureProperty m_Property = SignatureProperty::Unknown; ++ OUString m_Id; ++ OUString m_Value; ++ + public: + DsSignaturePropertyContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap) +@@ -1169,10 +1154,22 @@ class XSecParser::DsSignaturePropertyContext + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- OUString const ouIdAttr(m_rParser.HandleIdAttr(xAttrs)); +- if (!ouIdAttr.isEmpty()) ++ m_Id = m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual void EndElement() override ++ { ++ switch (m_Property) + { +- m_rParser.m_pXSecController->setPropertyId( ouIdAttr ); ++ case SignatureProperty::Unknown: ++ SAL_INFO("xmlsecurity.helper", "Unknown property in ds:Object ignored"); ++ break; ++ case SignatureProperty::Date: ++ m_rParser.m_pXSecController->setDate(m_Id, m_Value); ++ break; ++ case SignatureProperty::Description: ++ m_rParser.m_pXSecController->setDescription(m_Id, m_Value); ++ break; + } + } + +@@ -1182,11 +1179,13 @@ class XSecParser::DsSignaturePropertyContext + { + if (nNamespace == XML_NAMESPACE_DC && rName == "date") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ m_Property = SignatureProperty::Date; ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_Value); + } + if (nNamespace == XML_NAMESPACE_DC && rName == "description") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ m_Property = SignatureProperty::Description; ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_Value); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx +index 93efcb766e3e..7a0eb08bca28 100644 +--- a/xmlsecurity/source/helper/xsecparser.hxx ++++ b/xmlsecurity/source/helper/xsecparser.hxx +@@ -97,12 +97,6 @@ private: + class DsSignatureContext; + class DsigSignaturesContext; + +- /* +- * the following members are used to reserve the signature information, +- * including X509IssuerName, X509SerialNumber, and X509Certificate,etc. +- */ +- OUString m_ouDate; +- + std::stack> m_ContextStack; + std::unique_ptr m_pNamespaceMap; + +diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx +index b9648ed64397..1e1688767f00 100644 +--- a/xmlsecurity/source/helper/xsecsign.cxx ++++ b/xmlsecurity/source/helper/xsecsign.cxx +@@ -128,8 +128,8 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon + if (nStorageFormat != embed::StorageFormats::OFOPXML) + { + internalSignatureInfor.signatureInfor.ouSignatureId = createId(); +- internalSignatureInfor.signatureInfor.ouPropertyId = createId(); +- internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, digestID, internalSignatureInfor.signatureInfor.ouPropertyId, -1, OUString() ); ++ internalSignatureInfor.signatureInfor.ouDateTimePropertyId = createId(); ++ internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, digestID, internalSignatureInfor.signatureInfor.ouDateTimePropertyId, -1, OUString() ); + size++; + + if (bXAdESCompliantIfODF) +diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx +index c826971b1c7d..cdca811cc2cb 100644 +--- a/xmlsecurity/source/helper/xsecverify.cxx ++++ b/xmlsecurity/source/helper/xsecverify.cxx +@@ -317,7 +317,7 @@ void XSecController::setGpgOwner( OUString const & ouGpgOwner ) + isi.signatureInfor.ouGpgOwner = ouGpgOwner; + } + +-void XSecController::setDate( OUString const & ouDate ) ++void XSecController::setDate(OUString const& rId, OUString const& ouDate) + { + if (m_vInternalSignatureInformations.empty()) + { +@@ -325,17 +325,31 @@ void XSecController::setDate( OUString const & ouDate ) + return; + } + InternalSignatureInformation &isi = m_vInternalSignatureInformations.back(); ++ // there may be multiple timestamps in a signature - check them for consistency ++ if (!isi.signatureInfor.ouDateTime.isEmpty() ++ && isi.signatureInfor.ouDateTime != ouDate) ++ { ++ isi.signatureInfor.hasInconsistentSigningTime = true; ++ } + (void)utl::ISO8601parseDateTime( ouDate, isi.signatureInfor.stDateTime); + isi.signatureInfor.ouDateTime = ouDate; ++ if (!rId.isEmpty()) ++ { ++ isi.signatureInfor.ouDateTimePropertyId = rId; ++ } + } + +-void XSecController::setDescription(const OUString& rDescription) ++void XSecController::setDescription(OUString const& rId, OUString const& rDescription) + { + if (m_vInternalSignatureInformations.empty()) + return; + + InternalSignatureInformation& rInformation = m_vInternalSignatureInformations.back(); + rInformation.signatureInfor.ouDescription = rDescription; ++ if (!rId.isEmpty()) ++ { ++ rInformation.signatureInfor.ouDescriptionPropertyId = rId; ++ } + } + + void XSecController::setSignatureBytes(const uno::Sequence& rBytes) +@@ -429,27 +443,6 @@ void XSecController::setId( OUString const & ouId ) + isi.signatureInfor.ouSignatureId = ouId; + } + +-void XSecController::setPropertyId( OUString const & ouPropertyId ) +-{ +- if (m_vInternalSignatureInformations.empty()) +- { +- SAL_INFO("xmlsecurity.helper","XSecController::setPropertyId: no signature"); +- return; +- } +- InternalSignatureInformation &isi = m_vInternalSignatureInformations.back(); +- +- if (isi.signatureInfor.ouPropertyId.isEmpty()) +- { +- // ID attribute is for the date. +- isi.signatureInfor.ouPropertyId = ouPropertyId; +- } +- else +- { +- // ID attribute is for the description. +- isi.signatureInfor.ouDescriptionPropertyId = ouPropertyId; +- } +-} +- + /* public: for signature verify */ + void XSecController::collectToVerify( const OUString& referenceId ) + { +-- +cgit v1.2.1 + diff --git a/debian/patches/xmlsecurity-ignore-elements-in-ds:Object-that-arent-signed.diff b/debian/patches/xmlsecurity-ignore-elements-in-ds:Object-that-arent-signed.diff new file mode 100644 index 000000000..5e0a9d7ee --- /dev/null +++ b/debian/patches/xmlsecurity-ignore-elements-in-ds:Object-that-arent-signed.diff @@ -0,0 +1,740 @@ +From 94ce59dd02fcfcaa1eb4f195b45a9a2edbd58242 Mon Sep 17 00:00:00 2001 +From: Michael Stahl +Date: Fri, 19 Feb 2021 17:56:21 +0100 +Subject: xmlsecurity: ignore elements in ds:Object that aren't signed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: I2e4411f0907b89e7ad6e0185cee8f12b600515e8 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111253 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 2bfa00e6bf4b2a310a8b8f5060acec85b5f7a3ce) +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111909 +Reviewed-by: Caolán McNamara +--- + xmlsecurity/inc/xsecctl.hxx | 1 + + xmlsecurity/source/helper/xsecparser.cxx | 290 +++++++++++++++++++++---------- + xmlsecurity/source/helper/xsecparser.hxx | 1 + + xmlsecurity/source/helper/xsecverify.cxx | 19 ++ + 4 files changed, 221 insertions(+), 90 deletions(-) + +diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx +index 759a660d90ad..ec3669128d24 100644 +--- a/xmlsecurity/inc/xsecctl.hxx ++++ b/xmlsecurity/inc/xsecctl.hxx +@@ -252,6 +252,7 @@ private: + /// Sets algorithm from . + void setSignatureMethod(svl::crypto::SignatureMethodAlgorithm eAlgorithmID); + void switchGpgSignature(); ++ bool haveReferenceForId(OUString const& rId) const; + void addReference( + const OUString& ouUri, + sal_Int32 nDigestID, +diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx +index 1418b7b43b46..f46277f96ea1 100644 +--- a/xmlsecurity/source/helper/xsecparser.cxx ++++ b/xmlsecurity/source/helper/xsecparser.cxx +@@ -95,6 +95,42 @@ auto XSecParser::Context::CreateChildContext( + return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } + ++/** ++note: anything in ds:Object should be trusted *only* if there is a ds:Reference ++ to it so it is signed (exception: the xades:EncapsulatedX509Certificate). ++ ds:SignedInfo precedes all ds:Object. ++ ++ There may be multiple ds:Signature for purpose of counter-signatures ++ but the way XAdES describes these, only the ds:SignatureValue element ++ would be referenced, so requiring a ds:Reference for anything in ++ ds:Object shouldn't cause issues. ++ */ ++class XSecParser::ReferencedContextImpl ++ : public XSecParser::Context ++{ ++ protected: ++ bool m_isReferenced; ++ ++ public: ++ ReferencedContextImpl(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_isReferenced(isReferenced) ++ { ++ } ++ ++ OUString CheckIdAttrReferenced(css::uno::Reference const& xAttrs) ++ { ++ OUString const id(m_rParser.HandleIdAttr(xAttrs)); ++ if (!id.isEmpty() && m_rParser.m_pXSecController->haveReferenceForId(id)) ++ { ++ m_isReferenced = true; ++ } ++ return id; ++ } ++}; ++ + class XSecParser::LoPGPOwnerContext + : public XSecParser::Context + { +@@ -228,21 +264,29 @@ class XSecParser::DsX509CertificateContext + }; + + class XSecParser::DsX509SerialNumberContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + DsX509SerialNumberContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setX509SerialNumber(m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setX509SerialNumber(m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned X509SerialNumber"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -252,21 +296,29 @@ class XSecParser::DsX509SerialNumberContext + }; + + class XSecParser::DsX509IssuerNameContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + DsX509IssuerNameContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setX509IssuerName(m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setX509IssuerName(m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned X509IssuerName"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -276,12 +328,13 @@ class XSecParser::DsX509IssuerNameContext + }; + + class XSecParser::DsX509IssuerSerialContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + DsX509IssuerSerialContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + +@@ -291,11 +344,11 @@ class XSecParser::DsX509IssuerSerialContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerName") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_DS && rName == "X509SerialNumber") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + // missing: ds:X509SKI, ds:X509SubjectName, ds:X509CRL + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); +@@ -318,7 +371,8 @@ class XSecParser::DsX509DataContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerSerial") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ // can't require KeyInfo to be signed so pass in *true* ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), true); + } + if (nNamespace == XML_NAMESPACE_DS && rName == "X509Certificate") + { +@@ -787,21 +841,29 @@ class XSecParser::XadesUnsignedPropertiesContext + }; + + class XSecParser::LoSignatureLineIdContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + LoSignatureLineIdContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setSignatureLineId(m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setSignatureLineId(m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned SignatureLineId"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -811,21 +873,29 @@ class XSecParser::LoSignatureLineIdContext + }; + + class XSecParser::LoSignatureLineValidImageContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + LoSignatureLineValidImageContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setValidSignatureImage(m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setValidSignatureImage(m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned SignatureLineValidImage"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -835,21 +905,29 @@ class XSecParser::LoSignatureLineValidImageContext + }; + + class XSecParser::LoSignatureLineInvalidImageContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + LoSignatureLineInvalidImageContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setInvalidSignatureImage(m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setInvalidSignatureImage(m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned SignatureLineInvalidImage"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -859,12 +937,13 @@ class XSecParser::LoSignatureLineInvalidImageContext + }; + + class XSecParser::LoSignatureLineContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + LoSignatureLineContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + +@@ -874,22 +953,22 @@ class XSecParser::LoSignatureLineContext + { + if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineId") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineValidImage") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineInvalidImage") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } + }; + + class XSecParser::XadesCertDigestContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; +@@ -897,14 +976,22 @@ class XSecParser::XadesCertDigestContext + + public: + XadesCertDigestContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setCertDigest(m_Value/* FIXME , m_nReferenceDigestID*/); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setCertDigest(m_Value/* FIXME , m_nReferenceDigestID*/); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned CertDigest"); ++ } + } + + virtual std::unique_ptr CreateChildContext( +@@ -924,12 +1011,13 @@ class XSecParser::XadesCertDigestContext + }; + + class XSecParser::XadesCertContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + XadesCertContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + +@@ -939,23 +1027,24 @@ class XSecParser::XadesCertContext + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "CertDigest") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "IssuerSerial") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } + }; + + class XSecParser::XadesSigningCertificateContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + XadesSigningCertificateContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + +@@ -965,28 +1054,36 @@ class XSecParser::XadesSigningCertificateContext + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "Cert") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } + }; + + class XSecParser::XadesSigningTimeContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + OUString m_Value; + + public: + XadesSigningTimeContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void EndElement() override + { +- m_rParser.m_pXSecController->setDate("", m_Value); ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setDate("", m_Value); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned SigningTime"); ++ } + } + + virtual void Characters(OUString const& rChars) override +@@ -996,19 +1093,20 @@ class XSecParser::XadesSigningTimeContext + }; + + class XSecParser::XadesSignedSignaturePropertiesContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + XadesSignedSignaturePropertiesContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_rParser.HandleIdAttr(xAttrs); ++ CheckIdAttrReferenced(xAttrs); + } + + virtual std::unique_ptr CreateChildContext( +@@ -1017,15 +1115,15 @@ class XSecParser::XadesSignedSignaturePropertiesContext + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SigningTime") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SigningCertificate") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLine") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + // missing: xades:SignaturePolicyIdentifier, xades:SignatureProductionPlace, xades:SignerRole + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); +@@ -1033,19 +1131,20 @@ class XSecParser::XadesSignedSignaturePropertiesContext + }; + + class XSecParser::XadesSignedPropertiesContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + XadesSignedPropertiesContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_rParser.HandleIdAttr(xAttrs); ++ CheckIdAttrReferenced(xAttrs); + } + + virtual std::unique_ptr CreateChildContext( +@@ -1054,7 +1153,7 @@ class XSecParser::XadesSignedPropertiesContext + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SignedSignatureProperties") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + // missing: xades:SignedDataObjectProperties + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); +@@ -1062,19 +1161,20 @@ class XSecParser::XadesSignedPropertiesContext + }; + + class XSecParser::XadesQualifyingPropertiesContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + XadesQualifyingPropertiesContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_rParser.HandleIdAttr(xAttrs); ++ CheckIdAttrReferenced(xAttrs); + } + + virtual std::unique_ptr CreateChildContext( +@@ -1083,7 +1183,7 @@ class XSecParser::XadesQualifyingPropertiesContext + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SignedProperties") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "UnsignedProperties") + { +@@ -1136,7 +1236,7 @@ class XSecParser::DcDescriptionContext + }; + + class XSecParser::DsSignaturePropertyContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + private: + enum class SignatureProperty { Unknown, Date, Description }; +@@ -1146,30 +1246,38 @@ class XSecParser::DsSignaturePropertyContext + + public: + DsSignaturePropertyContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_Id = m_rParser.HandleIdAttr(xAttrs); ++ m_Id = CheckIdAttrReferenced(xAttrs); + } + + virtual void EndElement() override + { +- switch (m_Property) ++ if (m_isReferenced) ++ { ++ switch (m_Property) ++ { ++ case SignatureProperty::Unknown: ++ SAL_INFO("xmlsecurity.helper", "Unknown property in ds:Object ignored"); ++ break; ++ case SignatureProperty::Date: ++ m_rParser.m_pXSecController->setDate(m_Id, m_Value); ++ break; ++ case SignatureProperty::Description: ++ m_rParser.m_pXSecController->setDescription(m_Id, m_Value); ++ break; ++ } ++ } ++ else + { +- case SignatureProperty::Unknown: +- SAL_INFO("xmlsecurity.helper", "Unknown property in ds:Object ignored"); +- break; +- case SignatureProperty::Date: +- m_rParser.m_pXSecController->setDate(m_Id, m_Value); +- break; +- case SignatureProperty::Description: +- m_rParser.m_pXSecController->setDescription(m_Id, m_Value); +- break; ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned SignatureProperty"); + } + } + +@@ -1192,19 +1300,20 @@ class XSecParser::DsSignaturePropertyContext + }; + + class XSecParser::DsSignaturePropertiesContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + DsSignaturePropertiesContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ std::unique_ptr pOldNamespaceMap, ++ bool const isReferenced) ++ : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_rParser.HandleIdAttr(xAttrs); ++ CheckIdAttrReferenced(xAttrs); + } + + virtual std::unique_ptr CreateChildContext( +@@ -1213,26 +1322,27 @@ class XSecParser::DsSignaturePropertiesContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureProperty") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } + }; + + class XSecParser::DsObjectContext +- : public XSecParser::Context ++ : public XSecParser::ReferencedContextImpl + { + public: + DsObjectContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap) +- : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ // init with "false" here - the Signature element can't be referenced by its child ++ : XSecParser::ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), false) + { + } + + virtual void StartElement( + css::uno::Reference const& xAttrs) override + { +- m_rParser.HandleIdAttr(xAttrs); ++ CheckIdAttrReferenced(xAttrs); + } + + virtual std::unique_ptr CreateChildContext( +@@ -1241,11 +1351,11 @@ class XSecParser::DsObjectContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureProperties") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "QualifyingProperties") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); + } + // missing: ds:Manifest + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); +diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx +index 7a0eb08bca28..7674bf28b84d 100644 +--- a/xmlsecurity/source/helper/xsecparser.hxx ++++ b/xmlsecurity/source/helper/xsecparser.hxx +@@ -56,6 +56,7 @@ public: + class Context; + private: + class UnknownContext; ++ class ReferencedContextImpl; + class LoPGPOwnerContext; + class DsPGPKeyPacketContext; + class DsPGPKeyIDContext; +diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx +index cdca811cc2cb..92ebfb6c72e8 100644 +--- a/xmlsecurity/source/helper/xsecverify.cxx ++++ b/xmlsecurity/source/helper/xsecverify.cxx +@@ -143,6 +143,25 @@ void XSecController::switchGpgSignature() + #endif + } + ++bool XSecController::haveReferenceForId(OUString const& rId) const ++{ ++ if (m_vInternalSignatureInformations.empty()) ++ { ++ SAL_INFO("xmlsecurity.helper","XSecController::haveReferenceForId: no signature"); ++ return false; ++ } ++ InternalSignatureInformation const& rIsi(m_vInternalSignatureInformations.back()); ++ for (SignatureReferenceInformation const& rSri : rIsi.signatureInfor.vSignatureReferenceInfors) ++ { ++ if (rSri.nType == SignatureReferenceType::SAMEDOCUMENT ++ && rSri.ouURI == rId) // ouUri has # stripped ++ { ++ return true; ++ } ++ } ++ return false; ++} ++ + void XSecController::addReference( const OUString& ouUri, sal_Int32 nDigestID, const OUString& ouType ) + { + if (m_vInternalSignatureInformations.empty()) +-- +cgit v1.2.1 + diff --git a/debian/patches/xmlsecurity-improve-handling-of-multiple-X509Data-elements.diff b/debian/patches/xmlsecurity-improve-handling-of-multiple-X509Data-elements.diff new file mode 100644 index 000000000..988574269 --- /dev/null +++ b/debian/patches/xmlsecurity-improve-handling-of-multiple-X509Data-elements.diff @@ -0,0 +1,1597 @@ +From a1cf770c2d7ca3e153e0b1f01ddcc313bc2bed7f Mon Sep 17 00:00:00 2001 +From: Michael Stahl +Date: Thu, 25 Feb 2021 14:17:48 +0100 +Subject: xmlsecurity: improve handling of multiple X509Data elements +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Combine everything related to a certificate in a new struct X509Data. + +The CertDigest is not actually written in the X509Data element but in +xades:Cert, so try to find the matching entry in +XSecController::setX509CertDigest(). + +There was a confusing interaction with PGP signatures, where ouGpgKeyID +was used for import, but export wrote the value from ouCertDigest +instead - this needed fixing. + +The main point of this is enforcing a constraint from xmldsig-core 4.5.4: + + All certificates appearing in an X509Data element MUST relate to the + validation key by either containing it or being part of a certification + chain that terminates in a certificate containing the validation key. + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111254 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 9e82509b09f5fe2eb77bcdb8fd193c71923abb67) + +xmlsecurity: improve handling of multiple certificates per X509Data + +It turns out that an X509Data element can contain an arbitrary number of +each of its child elements. + +How exactly certificates of an issuer chain may or should be distributed +across multiple X509Data elements isn't terribly obvious. + +One thing that is clear is that any element that refers to or contains +one particular certificate has to be a child of the same X509Data +element, although in no particular order, so try to match the 2 such +elements that the parser supports in XSecController::setX509Data(). + +Presumably the only way it makes sense to have multiple signing +certificates is if they all contain the same key but are signed by +different CAs. This case isn't handled currently; CheckX509Data() will +complain there's not a single chain and validation of the certificates +will fail. + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111500 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 5af5ea893bcb8a8eb472ac11133da10e5a604e66) + +xmlsecurity: add EqualDistinguishedNames() + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111545 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 1d3da3486d827dd5e7a3bf1c7a533f5aa9860e42) + +xmlsecurity: avoid exception in DigitalSignaturesDialog::getCertificate() + +Fallback to PGP if there's no X509 signing certificate because +CheckX509Data() failed prevents the dialog from popping up. + +To avoid confusing the user in this situation, the dialog should +show no certificate, which is already the case. + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111664 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 90b725675c2964f4a151d802d9afedd8bc2ae1a7) + +xmlsecurity: fix crash in DocumentDigitalSignatures::isAuthorTrusted() + +If the argument is null. + +This function also should use EqualDistinguishedNames(). + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111667 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit ca98e505cd69bf95d8ddb9387cf3f8e03ae4577d) + +Change-Id: I9633a980b0c18d58dfce24fc59396a833498a77d +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111910 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +--- + include/svl/sigstruct.hxx | 32 +++- + svl/source/crypto/cryptosign.cxx | 16 +- + sw/source/core/edit/edfcol.cxx | 3 +- + xmlsecurity/inc/biginteger.hxx | 3 + + xmlsecurity/inc/xmlsignaturehelper.hxx | 12 ++ + xmlsecurity/inc/xsecctl.hxx | 14 +- + .../source/component/documentdigitalsignatures.cxx | 54 ++++--- + .../source/dialogs/digitalsignaturesdialog.cxx | 15 +- + .../source/helper/documentsignaturehelper.cxx | 63 +++++--- + .../source/helper/documentsignaturemanager.cxx | 12 ++ + xmlsecurity/source/helper/ooxmlsecexporter.cxx | 22 ++- + xmlsecurity/source/helper/ooxmlsecparser.cxx | 22 ++- + xmlsecurity/source/helper/pdfsignaturehelper.cxx | 8 +- + xmlsecurity/source/helper/xmlsignaturehelper.cxx | 161 +++++++++++++++++++++ + xmlsecurity/source/helper/xsecctl.cxx | 80 ++++++---- + xmlsecurity/source/helper/xsecparser.cxx | 144 +++++++++--------- + xmlsecurity/source/helper/xsecsign.cxx | 30 ++-- + xmlsecurity/source/helper/xsecverify.cxx | 124 +++++++++++++--- + .../xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 47 ++++++ + .../xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx | 2 + + .../source/xmlsec/nss/x509certificate_nssimpl.cxx | 25 ++++ + .../source/xmlsec/nss/xmlsignature_nssimpl.cxx | 3 + + 22 files changed, 678 insertions(+), 214 deletions(-) + +diff --git a/include/svl/sigstruct.hxx b/include/svl/sigstruct.hxx +index d62ecb09634c..6d53e048d47b 100644 +--- a/include/svl/sigstruct.hxx ++++ b/include/svl/sigstruct.hxx +@@ -89,9 +89,30 @@ struct SignatureInformation + sal_Int32 nSecurityId; + css::xml::crypto::SecurityOperationStatus nStatus; + SignatureReferenceInformations vSignatureReferenceInfors; +- OUString ouX509IssuerName; +- OUString ouX509SerialNumber; +- OUString ouX509Certificate; ++ struct X509CertInfo ++ { ++ OUString X509IssuerName; ++ OUString X509SerialNumber; ++ OUString X509Certificate; ++ /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature. ++ OUString CertDigest; ++ /// The certificate owner (aka subject). ++ OUString X509Subject; ++ }; ++ typedef std::vector X509Data; ++ // note: at parse time, it's unkown which one is the signing certificate; ++ // ImplVerifySignatures() figures it out and puts it at the back ++ std::vector X509Datas; ++ ++ X509CertInfo const* GetSigningCertificate() const ++ { ++ if (X509Datas.empty()) ++ { ++ return nullptr; ++ } ++ assert(!X509Datas.back().empty()); ++ return & X509Datas.back().back(); ++ } + + OUString ouGpgKeyID; + OUString ouGpgCertificate; +@@ -124,8 +145,6 @@ struct SignatureInformation + OUString ouDescription; + /// The Id attribute of the element that contains the . + OUString ouDescriptionPropertyId; +- /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature. +- OUString ouCertDigest; + /// Valid and invalid signature line images + css::uno::Reference aValidSignatureImage; + css::uno::Reference aInvalidSignatureImage; +@@ -140,9 +159,6 @@ struct SignatureInformation + /// For PDF: the byte range doesn't cover the whole document. + bool bPartialDocumentSignature; + +- /// The certificate owner (aka subject). +- OUString ouSubject; +- + svl::crypto::SignatureMethodAlgorithm eAlgorithmID; + + SignatureInformation( sal_Int32 nId ) +diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx +index 573c06ba5826..a015f00576a4 100644 +--- a/svl/source/crypto/cryptosign.cxx ++++ b/svl/source/crypto/cryptosign.cxx +@@ -2094,8 +2094,12 @@ bool Signing::Verify(const std::vector& aData, + aDerCert[i] = pCertificate->derCert.data[i]; + OUStringBuffer aBuffer; + comphelper::Base64::encode(aBuffer, aDerCert); +- rInformation.ouX509Certificate = aBuffer.makeStringAndClear(); +- rInformation.ouSubject = OUString(pCertificate->subjectName, PL_strlen(pCertificate->subjectName), RTL_TEXTENCODING_UTF8); ++ SignatureInformation::X509Data temp; ++ temp.emplace_back(); ++ temp.back().X509Certificate = aBuffer.makeStringAndClear(); ++ temp.back().X509Subject = OUString(pCertificate->subjectName, PL_strlen(pCertificate->subjectName), RTL_TEXTENCODING_UTF8); ++ rInformation.X509Datas.clear(); ++ rInformation.X509Datas.emplace_back(temp); + } + + PRTime nSigningTime; +@@ -2274,8 +2278,12 @@ bool Signing::Verify(const std::vector& aData, + aDerCert[i] = pSignerCertContext->pbCertEncoded[i]; + OUStringBuffer aBuffer; + comphelper::Base64::encode(aBuffer, aDerCert); +- rInformation.ouX509Certificate = aBuffer.makeStringAndClear(); +- rInformation.ouSubject = GetSubjectName(pSignerCertContext); ++ SignatureInformation::X509Data temp; ++ temp.emplace_back(); ++ temp.back().X509Certificate = aBuffer.makeStringAndClear(); ++ temp.back().X509Subject = GetSubjectName(pSignerCertContext); ++ rInformation.X509Datas.clear(); ++ rInformation.X509Datas.emplace_back(temp); + } + + if (bNonDetached) +diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx +index d0154b4886ef..b2299ec42213 100644 +--- a/sw/source/core/edit/edfcol.cxx ++++ b/sw/source/core/edit/edfcol.cxx +@@ -402,7 +402,8 @@ std::pair lcl_MakeParagraphSignatureFieldText(const SignatureDes + valid = valid + && aInfo.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED; + +- msg = SwResId(STR_SIGNED_BY) + ": " + aInfo.ouSubject + ", " + ++ assert(aInfo.GetSigningCertificate()); // it was valid ++ msg = SwResId(STR_SIGNED_BY) + ": " + aInfo.GetSigningCertificate()->X509Subject + ", " + + aDescr.msDate; + msg += (!aDescr.msUsage.isEmpty() ? (" (" + aDescr.msUsage + "): ") : OUString(": ")); + msg += (valid ? SwResId(STR_VALID) : SwResId(STR_INVALID)); +diff --git a/xmlsecurity/inc/biginteger.hxx b/xmlsecurity/inc/biginteger.hxx +index d07ecf45d8af..8b4d8a9143b5 100644 +--- a/xmlsecurity/inc/biginteger.hxx ++++ b/xmlsecurity/inc/biginteger.hxx +@@ -31,6 +31,9 @@ namespace xmlsecurity + { + XSECXMLSEC_DLLPUBLIC OUString bigIntegerToNumericString( const css::uno::Sequence< sal_Int8 >& serial ); + XSECXMLSEC_DLLPUBLIC css::uno::Sequence< sal_Int8 > numericStringToBigInteger ( const OUString& serialNumber ); ++ ++XSECXMLSEC_DLLPUBLIC bool EqualDistinguishedNames(OUString const& rName1, ++ OUString const& rName2); + } + + #endif +diff --git a/xmlsecurity/inc/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsignaturehelper.hxx +index 2437686ea31b..a12309ef4d0a 100644 +--- a/xmlsecurity/inc/xmlsignaturehelper.hxx ++++ b/xmlsecurity/inc/xmlsignaturehelper.hxx +@@ -28,6 +28,9 @@ + #include "xmlsignaturehelper.hxx" + #include "xsecctl.hxx" + ++#include ++#include ++ + class DateTime; + class UriBindingHelper; + +@@ -93,6 +96,15 @@ public: + // After signing/verifying, get information about signatures + SignatureInformation GetSignatureInformation( sal_Int32 nSecurityId ) const; + SignatureInformations GetSignatureInformations() const; ++ /// ImplVerifySignature calls this to figure out which X509Data is the ++ /// signing certificate and update the internal state with the result. ++ /// @return ++ /// A sequence with the signing certificate at the back on success. ++ /// An empty sequence on failure. ++ std::vector> ++ CheckAndUpdateSignatureInformation( ++ css::uno::Reference const& xSecEnv, ++ SignatureInformation const& rInfo); + + // See XSecController for documentation + void StartMission(const css::uno::Reference& xSecurityContext); +diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx +index ec3669128d24..ca6c169798c2 100644 +--- a/xmlsecurity/inc/xsecctl.hxx ++++ b/xmlsecurity/inc/xsecctl.hxx +@@ -263,9 +263,13 @@ private: + sal_Int32 nDigestID ); + void setReferenceCount() const; + +- void setX509IssuerName( OUString const & ouX509IssuerName ); +- void setX509SerialNumber( OUString const & ouX509SerialNumber ); +- void setX509Certificate( OUString const & ouX509Certificate ); ++ void setX509Data( ++ std::vector> & rX509IssuerSerials, ++ std::vector const& rX509Certificates); ++ void setX509CertDigest( ++ OUString const& rCertDigest, sal_Int32 const nReferenceDigestID, ++ OUString const& rX509IssuerName, OUString const& rX509SerialNumber); ++ + void setSignatureValue( OUString const & ouSignatureValue ); + void setDigestValue( sal_Int32 nDigestID, OUString const & ouDigestValue ); + void setGpgKeyID( OUString const & ouKeyID ); +@@ -274,7 +278,6 @@ private: + + void setDate(OUString const& rId, OUString const& ouDate); + void setDescription(OUString const& rId, OUString const& rDescription); +- void setCertDigest(const OUString& rCertDigest); + void setValidSignatureImage(const OUString& rValidSigImg); + void setInvalidSignatureImage(const OUString& rInvalidSigImg); + void setSignatureLineId(const OUString& rSignatureLineId); +@@ -303,6 +306,9 @@ public: + + SignatureInformation getSignatureInformation( sal_Int32 nSecurityId ) const; + SignatureInformations getSignatureInformations() const; ++ /// only verify can figure out which X509Data is the signing certificate ++ void UpdateSignatureInformation(sal_Int32 nSecurityId, ++ std::vector const& rDatas); + + static void exportSignature( + const css::uno::Reference< css::xml::sax::XDocumentHandler >& xDocumentHandler, +diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx +index d149bf5e30b2..8f1fe7c2785d 100644 +--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx ++++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx +@@ -529,30 +529,36 @@ DocumentDigitalSignatures::ImplVerifySignatures( + const SignatureInformation& rInfo = aSignInfos[n]; + css::security::DocumentSignatureInformation& rSigInfo = arInfos[n]; + +- if (rInfo.ouGpgCertificate.isEmpty()) // X.509 ++ if (!rInfo.X509Datas.empty()) // X.509 + { +- if (!rInfo.ouX509Certificate.isEmpty()) +- rSigInfo.Signer = xSecEnv->createCertificateFromAscii(rInfo.ouX509Certificate); +- if (!rSigInfo.Signer.is()) +- rSigInfo.Signer = xSecEnv->getCertificate( +- rInfo.ouX509IssuerName, +- xmlsecurity::numericStringToBigInteger(rInfo.ouX509SerialNumber)); +- +- // On Windows checking the certificate path is buggy. It does name matching (issuer, subject name) +- // to find the parent certificate. It does not take into account that there can be several certificates +- // with the same subject name. +- try ++ std::vector> certs( ++ rSignatureHelper.CheckAndUpdateSignatureInformation( ++ xSecEnv, rInfo)); ++ if (certs.empty()) + { +- rSigInfo.CertificateStatus = xSecEnv->verifyCertificate( +- rSigInfo.Signer, Sequence>()); ++ rSigInfo.CertificateStatus = css::security::CertificateValidity::INVALID; + } +- catch (SecurityException&) ++ else + { +- OSL_FAIL("Verification of certificate failed"); +- rSigInfo.CertificateStatus = css::security::CertificateValidity::INVALID; ++ rSigInfo.Signer = certs.back(); ++ // get only intermediates ++ certs.pop_back(); ++ // On Windows checking the certificate path is buggy. It does name matching (issuer, subject name) ++ // to find the parent certificate. It does not take into account that there can be several certificates ++ // with the same subject name. ++ try ++ { ++ rSigInfo.CertificateStatus = xSecEnv->verifyCertificate( ++ rSigInfo.Signer, comphelper::containerToSequence(certs)); ++ } ++ catch (SecurityException&) ++ { ++ SAL_WARN("xmlsecurity.comp", "Verification of certificate failed"); ++ rSigInfo.CertificateStatus = css::security::CertificateValidity::INVALID; ++ } + } + } +- else if (xGpgSecEnv.is()) // GPG ++ else if (!rInfo.ouGpgCertificate.isEmpty() && xGpgSecEnv.is()) // GPG + { + // TODO not ideal to retrieve cert by keyID, might + // collide, or PGPKeyID format might change - can't we +@@ -638,15 +644,19 @@ void DocumentDigitalSignatures::showCertificate( + } + + sal_Bool DocumentDigitalSignatures::isAuthorTrusted( +- const Reference< css::security::XCertificate >& Author ) ++ const Reference& xAuthor) + { +- OUString sSerialNum = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() ); ++ if (!xAuthor.is()) ++ { ++ return false; ++ } ++ OUString sSerialNum = xmlsecurity::bigIntegerToNumericString(xAuthor->getSerialNumber()); + + Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors(); + + return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(), +- [&Author, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { +- return ( rAuthor[0] == Author->getIssuerName() ) ++ [&xAuthor, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) { ++ return xmlsecurity::EqualDistinguishedNames(rAuthor[0], xAuthor->getIssuerName()) + && ( rAuthor[1] == sSerialNum ); + }); + } +diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +index ef67c7167c04..18ccaf2d2166 100644 +--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx ++++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +@@ -588,7 +588,7 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() + if (!rInfo.ouGpgCertificate.isEmpty()) + aType = "OpenPGP"; + // XML based: XAdES or not. +- else if (!rInfo.ouCertDigest.isEmpty()) ++ else if (rInfo.GetSigningCertificate() && !rInfo.GetSigningCertificate()->CertDigest.isEmpty()) + aType = "XAdES"; + else + aType = "XML-DSig"; +@@ -700,8 +700,8 @@ uno::Reference DigitalSignaturesDialog::getCertificate(c + uno::Reference xCert; + + //First we try to get the certificate which is embedded in the XML Signature +- if (xSecEnv.is() && !rInfo.ouX509Certificate.isEmpty()) +- xCert = xSecEnv->createCertificateFromAscii(rInfo.ouX509Certificate); ++ if (xSecEnv.is() && rInfo.GetSigningCertificate() && !rInfo.GetSigningCertificate()->X509Certificate.isEmpty()) ++ xCert = xSecEnv->createCertificateFromAscii(rInfo.GetSigningCertificate()->X509Certificate); + else { + //There must be an embedded certificate because we use it to get the + //issuer name. We cannot use /Signature/KeyInfo/X509Data/X509IssuerName +@@ -713,9 +713,12 @@ uno::Reference DigitalSignaturesDialog::getCertificate(c + } + + //In case there is no embedded certificate we try to get it from a local store +- if (!xCert.is() && xSecEnv.is()) +- xCert = xSecEnv->getCertificate( rInfo.ouX509IssuerName, xmlsecurity::numericStringToBigInteger( rInfo.ouX509SerialNumber ) ); +- if (!xCert.is() && xGpgSecEnv.is()) ++ if (!xCert.is() && xSecEnv.is() && rInfo.GetSigningCertificate()) ++ { ++ xCert = xSecEnv->getCertificate(rInfo.GetSigningCertificate()->X509IssuerName, ++ xmlsecurity::numericStringToBigInteger(rInfo.GetSigningCertificate()->X509SerialNumber)); ++ } ++ if (!xCert.is() && xGpgSecEnv.is() && !rInfo.ouGpgKeyID.isEmpty()) + xCert = xGpgSecEnv->getCertificate( rInfo.ouGpgKeyID, xmlsecurity::numericStringToBigInteger("") ); + + SAL_WARN_IF( !xCert.is(), "xmlsecurity.dialogs", "Certificate not found and can't be created!" ); +diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx +index 482ae6cc4126..ddff308ee52f 100644 +--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx ++++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx +@@ -492,6 +492,29 @@ void DocumentSignatureHelper::writeDigestMethod( + xDocumentHandler->endElement("DigestMethod"); + } + ++static void WriteXadesCert( ++ uno::Reference const& xDocumentHandler, ++ SignatureInformation::X509CertInfo const& rCertInfo) ++{ ++ xDocumentHandler->startElement("xd:Cert", uno::Reference(new SvXMLAttributeList())); ++ xDocumentHandler->startElement("xd:CertDigest", uno::Reference(new SvXMLAttributeList())); ++ DocumentSignatureHelper::writeDigestMethod(xDocumentHandler); ++ xDocumentHandler->startElement("DigestValue", uno::Reference(new SvXMLAttributeList())); ++ assert(!rCertInfo.CertDigest.isEmpty()); ++ xDocumentHandler->characters(rCertInfo.CertDigest); ++ xDocumentHandler->endElement("DigestValue"); ++ xDocumentHandler->endElement("xd:CertDigest"); ++ xDocumentHandler->startElement("xd:IssuerSerial", uno::Reference(new SvXMLAttributeList())); ++ xDocumentHandler->startElement("X509IssuerName", uno::Reference(new SvXMLAttributeList())); ++ xDocumentHandler->characters(rCertInfo.X509IssuerName); ++ xDocumentHandler->endElement("X509IssuerName"); ++ xDocumentHandler->startElement("X509SerialNumber", uno::Reference(new SvXMLAttributeList())); ++ xDocumentHandler->characters(rCertInfo.X509SerialNumber); ++ xDocumentHandler->endElement("X509SerialNumber"); ++ xDocumentHandler->endElement("xd:IssuerSerial"); ++ xDocumentHandler->endElement("xd:Cert"); ++} ++ + void DocumentSignatureHelper::writeSignedProperties( + const uno::Reference& xDocumentHandler, + const SignatureInformation& signatureInfo, +@@ -508,26 +531,26 @@ void DocumentSignatureHelper::writeSignedProperties( + xDocumentHandler->characters(sDate); + xDocumentHandler->endElement("xd:SigningTime"); + xDocumentHandler->startElement("xd:SigningCertificate", uno::Reference(new SvXMLAttributeList())); +- xDocumentHandler->startElement("xd:Cert", uno::Reference(new SvXMLAttributeList())); +- xDocumentHandler->startElement("xd:CertDigest", uno::Reference(new SvXMLAttributeList())); +- writeDigestMethod(xDocumentHandler); +- +- xDocumentHandler->startElement("DigestValue", uno::Reference(new SvXMLAttributeList())); +- // TODO: this is empty for gpg signatures currently +- //assert(!signatureInfo.ouCertDigest.isEmpty()); +- xDocumentHandler->characters(signatureInfo.ouCertDigest); +- xDocumentHandler->endElement("DigestValue"); +- +- xDocumentHandler->endElement("xd:CertDigest"); +- xDocumentHandler->startElement("xd:IssuerSerial", uno::Reference(new SvXMLAttributeList())); +- xDocumentHandler->startElement("X509IssuerName", uno::Reference(new SvXMLAttributeList())); +- xDocumentHandler->characters(signatureInfo.ouX509IssuerName); +- xDocumentHandler->endElement("X509IssuerName"); +- xDocumentHandler->startElement("X509SerialNumber", uno::Reference(new SvXMLAttributeList())); +- xDocumentHandler->characters(signatureInfo.ouX509SerialNumber); +- xDocumentHandler->endElement("X509SerialNumber"); +- xDocumentHandler->endElement("xd:IssuerSerial"); +- xDocumentHandler->endElement("xd:Cert"); ++ assert(signatureInfo.GetSigningCertificate() || !signatureInfo.ouGpgKeyID.isEmpty()); ++ if (signatureInfo.GetSigningCertificate()) ++ { ++ // how should this deal with multiple X509Data elements? ++ // for now, let's write all of the certificates ... ++ for (auto const& rData : signatureInfo.X509Datas) ++ { ++ for (auto const& it : rData) ++ { ++ WriteXadesCert(xDocumentHandler, it); ++ } ++ } ++ } ++ else ++ { ++ // for PGP, write empty mandatory X509IssuerName, X509SerialNumber ++ SignatureInformation::X509CertInfo temp; ++ temp.CertDigest = signatureInfo.ouGpgKeyID; ++ WriteXadesCert(xDocumentHandler, temp); ++ } + xDocumentHandler->endElement("xd:SigningCertificate"); + xDocumentHandler->startElement("xd:SignaturePolicyIdentifier", uno::Reference(new SvXMLAttributeList())); + xDocumentHandler->startElement("xd:SignaturePolicyImplied", uno::Reference(new SvXMLAttributeList())); +diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx +index 79d2cdf26b61..7252c54e74ab 100644 +--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx ++++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx +@@ -586,6 +586,18 @@ void DocumentSignatureManager::read(bool bUseTempStream, bool bCacheLastSignatur + bCacheLastSignature); + maSignatureHelper.EndMission(); + ++ // this parses the XML independently from ImplVerifySignatures() - check ++ // certificates here too ... ++ for (auto const& it : maSignatureHelper.GetSignatureInformations()) ++ { ++ if (!it.X509Datas.empty()) ++ { ++ uno::Reference const xSecEnv( ++ getSecurityEnvironment()); ++ getSignatureHelper().CheckAndUpdateSignatureInformation(xSecEnv, it); ++ } ++ } ++ + maCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations(); + } + else +diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx +index fe4d0df89a5d..d2c29041338f 100644 +--- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx ++++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx +@@ -200,13 +200,21 @@ void OOXMLSecExporter::Impl::writeKeyInfo() + { + m_xDocumentHandler->startElement( + "KeyInfo", uno::Reference(new SvXMLAttributeList())); +- m_xDocumentHandler->startElement( +- "X509Data", uno::Reference(new SvXMLAttributeList())); +- m_xDocumentHandler->startElement( +- "X509Certificate", uno::Reference(new SvXMLAttributeList())); +- m_xDocumentHandler->characters(m_rInformation.ouX509Certificate); +- m_xDocumentHandler->endElement("X509Certificate"); +- m_xDocumentHandler->endElement("X509Data"); ++ assert(m_rInformation.GetSigningCertificate()); ++ for (auto const& rData : m_rInformation.X509Datas) ++ { ++ m_xDocumentHandler->startElement( ++ "X509Data", uno::Reference(new SvXMLAttributeList())); ++ for (auto const& it : rData) ++ { ++ m_xDocumentHandler->startElement( ++ "X509Certificate", ++ uno::Reference(new SvXMLAttributeList())); ++ m_xDocumentHandler->characters(it.X509Certificate); ++ m_xDocumentHandler->endElement("X509Certificate"); ++ } ++ m_xDocumentHandler->endElement("X509Data"); ++ } + m_xDocumentHandler->endElement("KeyInfo"); + } + +diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx +index a200de60c07a..a25872fc057d 100644 +--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx ++++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx +@@ -185,9 +185,22 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) + m_pXSecController->setSignatureValue(m_aSignatureValue); + m_bInSignatureValue = false; + } ++ else if (rName == "X509Data") ++ { ++ std::vector> X509IssuerSerials; ++ std::vector X509Certificates; ++ if (!m_aX509Certificate.isEmpty()) ++ { ++ X509Certificates.emplace_back(m_aX509Certificate); ++ } ++ if (!m_aX509IssuerName.isEmpty() && !m_aX509SerialNumber.isEmpty()) ++ { ++ X509IssuerSerials.emplace_back(m_aX509IssuerName, m_aX509SerialNumber); ++ } ++ m_pXSecController->setX509Data(X509IssuerSerials, X509Certificates); ++ } + else if (rName == "X509Certificate") + { +- m_pXSecController->setX509Certificate(m_aX509Certificate); + m_bInX509Certificate = false; + } + else if (rName == "mdssi:Value") +@@ -202,17 +215,18 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) + } + else if (rName == "X509IssuerName") + { +- m_pXSecController->setX509IssuerName(m_aX509IssuerName); + m_bInX509IssuerName = false; + } + else if (rName == "X509SerialNumber") + { +- m_pXSecController->setX509SerialNumber(m_aX509SerialNumber); + m_bInX509SerialNumber = false; + } ++ else if (rName == "xd:Cert") ++ { ++ m_pXSecController->setX509CertDigest(m_aCertDigest, css::xml::crypto::DigestID::SHA1, m_aX509IssuerName, m_aX509SerialNumber); ++ } + else if (rName == "xd:CertDigest") + { +- m_pXSecController->setCertDigest(m_aCertDigest); + m_bInCertDigest = false; + } + else if (rName == "Object") +diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx +index b0795cb8f33f..843000a9c326 100644 +--- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx ++++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx +@@ -85,8 +85,12 @@ PDFSignatureHelper::GetDocumentSignatureInformations( + security::DocumentSignatureInformation& rExternal = aRet[i]; + rExternal.SignatureIsValid + = rInternal.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED; +- if (!rInternal.ouX509Certificate.isEmpty()) +- rExternal.Signer = xSecEnv->createCertificateFromAscii(rInternal.ouX509Certificate); ++ if (rInternal.GetSigningCertificate() ++ && !rInternal.GetSigningCertificate()->X509Certificate.isEmpty()) ++ { ++ rExternal.Signer = xSecEnv->createCertificateFromAscii( ++ rInternal.GetSigningCertificate()->X509Certificate); ++ } + rExternal.PartialDocumentSignature = rInternal.bPartialDocumentSignature; + + // Verify certificate. +diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx +index 22c056e70da1..bcb79039e342 100644 +--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx ++++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include + +@@ -45,6 +46,8 @@ + #include + #include + ++#include ++ + #define NS_DOCUMENTSIGNATURES "http://openoffice.org/2004/documentsignatures" + #define NS_DOCUMENTSIGNATURES_ODF_1_2 "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0" + #define OOXML_SIGNATURE_ORIGIN "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin" +@@ -547,4 +550,162 @@ void XMLSignatureHelper::CreateAndWriteOOXMLSignature(const uno::ReferenceendDocument(); + } + ++/** check this constraint from xmldsig-core 4.5.4: ++ ++ All certificates appearing in an X509Data element MUST relate to the ++ validation key by either containing it or being part of a certification ++ chain that terminates in a certificate containing the validation key. ++ */ ++static auto CheckX509Data( ++ uno::Reference const& xSecEnv, ++ std::vector const& rX509CertInfos, ++ std::vector> & rCerts, ++ std::vector & rSorted) -> bool ++{ ++ assert(rCerts.empty()); ++ assert(rSorted.empty()); ++ if (rX509CertInfos.empty()) ++ { ++ SAL_WARN("xmlsecurity.comp", "no X509Data"); ++ return false; ++ } ++ std::vector> certs; ++ for (SignatureInformation::X509CertInfo const& it : rX509CertInfos) ++ { ++ if (!it.X509Certificate.isEmpty()) ++ { ++ certs.emplace_back(xSecEnv->createCertificateFromAscii(it.X509Certificate)); ++ } ++ else ++ { ++ certs.emplace_back(xSecEnv->getCertificate( ++ it.X509IssuerName, ++ xmlsecurity::numericStringToBigInteger(it.X509SerialNumber))); ++ } ++ if (!certs.back().is()) ++ { ++ SAL_WARN("xmlsecurity.comp", "X509Data cannot be parsed"); ++ return false; ++ } ++ } ++ ++ // first, search one whose issuer isn't in the list, or a self-signed one ++ std::optional start; ++ for (size_t i = 0; i < certs.size(); ++i) ++ { ++ for (size_t j = 0; ; ++j) ++ { ++ if (j == certs.size()) ++ { ++ if (start) ++ { ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: certificate has no issuer but already have start of chain: " << certs[i]->getSubjectName()); ++ return false; ++ } ++ start = i; // issuer isn't in the list ++ break; ++ } ++ if (xmlsecurity::EqualDistinguishedNames(certs[i]->getIssuerName(), certs[j]->getSubjectName())) ++ { ++ if (i == j) // self signed ++ { ++ if (start) ++ { ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: certificate is self-signed but already have start of chain: " << certs[i]->getSubjectName()); ++ return false; ++ } ++ start = i; ++ } ++ break; ++ } ++ } ++ } ++ std::vector chain; ++ if (!start) ++ { ++ // this can only be a cycle? ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: cycle detected"); ++ return false; ++ } ++ chain.emplace_back(*start); ++ ++ // second, check that there is a chain, no tree or cycle... ++ for (size_t i = 0; i < certs.size(); ++i) ++ { ++ assert(chain.size() == i + 1); ++ for (size_t j = 0; j < certs.size(); ++j) ++ { ++ if (chain[i] != j) ++ { ++ if (xmlsecurity::EqualDistinguishedNames( ++ certs[chain[i]]->getSubjectName(), certs[j]->getIssuerName())) ++ { ++ if (chain.size() != i + 1) // already found issuee? ++ { ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: certificate issued 2 others: " << certs[chain[i]]->getSubjectName()); ++ return false; ++ } ++ chain.emplace_back(j); ++ } ++ } ++ } ++ if (i == certs.size() - 1) ++ { // last one: must be a leaf ++ if (chain.size() != i + 1) ++ { ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: certificate in cycle: " << certs[chain[i]]->getSubjectName()); ++ return false; ++ } ++ } ++ else if (chain.size() != i + 2) ++ { // not issuer of another? ++ SAL_WARN("xmlsecurity.comp", "X509Data do not form a chain: certificate issued 0 others: " << certs[chain[i]]->getSubjectName()); ++ return false; ++ } ++ } ++ ++ // success ++ assert(chain.size() == rX509CertInfos.size()); ++ for (auto const& it : chain) ++ { ++ rSorted.emplace_back(rX509CertInfos[it]); ++ rCerts.emplace_back(certs[it]); ++ } ++ return true; ++} ++ ++std::vector> ++XMLSignatureHelper::CheckAndUpdateSignatureInformation( ++ uno::Reference const& xSecEnv, ++ SignatureInformation const& rInfo) ++{ ++ // if the check fails, it's not possible to determine which X509Data ++ // contained the signing certificate - the UI cannot display something ++ // useful in this case, so prevent anything misleading by clearing the ++ // X509Datas. ++ ++ std::vector> certs; ++ std::vector datas; ++ // TODO: for now, just merge all X509Datas together for checking... ++ // (this will probably break round-trip of signature with multiple X509Data, ++ // no idea if that is a problem) ++ SignatureInformation::X509Data temp; ++ SignatureInformation::X509Data tempResult; ++ for (auto const& rData : rInfo.X509Datas) ++ { ++ for (auto const& it : rData) ++ { ++ temp.emplace_back(it); ++ } ++ } ++ if (CheckX509Data(xSecEnv, temp, certs, tempResult)) ++ { ++ datas.emplace_back(tempResult); ++ } ++ ++ // rInfo is a copy, update the original ++ mpXSecController->UpdateSignatureInformation(rInfo.nSecurityId, datas); ++ return certs; ++} ++ + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx +index e3df9a85f6da..6bd88e24f91e 100644 +--- a/xmlsecurity/source/helper/xsecctl.cxx ++++ b/xmlsecurity/source/helper/xsecctl.cxx +@@ -734,7 +734,7 @@ void XSecController::exportSignature( + xDocumentHandler->startElement( + "PGPKeyID", + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); +- xDocumentHandler->characters( signatureInfo.ouCertDigest ); ++ xDocumentHandler->characters(signatureInfo.ouGpgKeyID); + xDocumentHandler->endElement( "PGPKeyID" ); + + /* Write PGPKeyPacket element */ +@@ -758,43 +758,50 @@ void XSecController::exportSignature( + } + else + { +- /* Write X509Data element */ +- xDocumentHandler->startElement( +- "X509Data", +- css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); ++ assert(signatureInfo.GetSigningCertificate()); ++ for (auto const& rData : signatureInfo.X509Datas) + { +- /* Write X509IssuerSerial element */ ++ /* Write X509Data element */ + xDocumentHandler->startElement( +- "X509IssuerSerial", ++ "X509Data", + css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); + { +- /* Write X509IssuerName element */ +- xDocumentHandler->startElement( +- "X509IssuerName", +- css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); +- xDocumentHandler->characters( signatureInfo.ouX509IssuerName ); +- xDocumentHandler->endElement( "X509IssuerName" ); +- +- /* Write X509SerialNumber element */ +- xDocumentHandler->startElement( +- "X509SerialNumber", +- css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); +- xDocumentHandler->characters( signatureInfo.ouX509SerialNumber ); +- xDocumentHandler->endElement( "X509SerialNumber" ); +- } +- xDocumentHandler->endElement( "X509IssuerSerial" ); +- +- /* Write X509Certificate element */ +- if (!signatureInfo.ouX509Certificate.isEmpty()) +- { +- xDocumentHandler->startElement( +- "X509Certificate", +- css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); +- xDocumentHandler->characters( signatureInfo.ouX509Certificate ); +- xDocumentHandler->endElement( "X509Certificate" ); ++ for (auto const& it : rData) ++ { ++ /* Write X509IssuerSerial element */ ++ xDocumentHandler->startElement( ++ "X509IssuerSerial", ++ css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); ++ { ++ /* Write X509IssuerName element */ ++ xDocumentHandler->startElement( ++ "X509IssuerName", ++ css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); ++ xDocumentHandler->characters(it.X509IssuerName); ++ xDocumentHandler->endElement( "X509IssuerName" ); ++ ++ /* Write X509SerialNumber element */ ++ xDocumentHandler->startElement( ++ "X509SerialNumber", ++ css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); ++ xDocumentHandler->characters(it.X509SerialNumber); ++ xDocumentHandler->endElement( "X509SerialNumber" ); ++ } ++ xDocumentHandler->endElement( "X509IssuerSerial" ); ++ ++ /* Write X509Certificate element */ ++ if (!it.X509Certificate.isEmpty()) ++ { ++ xDocumentHandler->startElement( ++ "X509Certificate", ++ css::uno::Reference< css::xml::sax::XAttributeList > (new SvXMLAttributeList())); ++ xDocumentHandler->characters(it.X509Certificate); ++ xDocumentHandler->endElement( "X509Certificate" ); ++ } ++ } + } ++ xDocumentHandler->endElement( "X509Data" ); + } +- xDocumentHandler->endElement( "X509Data" ); + } + } + xDocumentHandler->endElement( "KeyInfo" ); +@@ -913,6 +920,15 @@ void XSecController::exportOOXMLSignature(const uno::Reference& + aExporter.writeSignature(); + } + ++void XSecController::UpdateSignatureInformation(sal_Int32 const nSecurityId, ++ std::vector const& rDatas) ++{ ++ SignatureInformation aInf( 0 ); ++ int const nIndex = findSignatureInfor(nSecurityId); ++ assert(nIndex != -1); // nothing should touch this between parsing and verify ++ m_vInternalSignatureInformations[nIndex].signatureInfor.X509Datas = rDatas; ++} ++ + SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const + { + SignatureInformation aInf( 0 ); +diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx +index f46277f96ea1..f2e00fca99c9 100644 +--- a/xmlsecurity/source/helper/xsecparser.cxx ++++ b/xmlsecurity/source/helper/xsecparser.cxx +@@ -243,98 +243,79 @@ class XSecParser::DsX509CertificateContext + : public XSecParser::Context + { + private: +- OUString m_Value; ++ OUString & m_rValue; + + public: + DsX509CertificateContext(XSecParser & rParser, +- std::unique_ptr pOldNamespaceMap) ++ std::unique_ptr pOldNamespaceMap, ++ OUString & rValue) + : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) + { + } + +- virtual void EndElement() override +- { +- m_rParser.m_pXSecController->setX509Certificate(m_Value); +- } +- + virtual void Characters(OUString const& rChars) override + { +- m_Value += rChars; ++ m_rValue += rChars; + } + }; + + class XSecParser::DsX509SerialNumberContext +- : public XSecParser::ReferencedContextImpl ++ : public XSecParser::Context + { + private: +- OUString m_Value; ++ OUString & m_rValue; + + public: + DsX509SerialNumberContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap, +- bool const isReferenced) +- : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) +- { +- } +- +- virtual void EndElement() override ++ OUString & rValue) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) + { +- if (m_isReferenced) +- { +- m_rParser.m_pXSecController->setX509SerialNumber(m_Value); +- } +- else +- { +- SAL_INFO("xmlsecurity.helper", "ignoring unsigned X509SerialNumber"); +- } + } + + virtual void Characters(OUString const& rChars) override + { +- m_Value += rChars; ++ m_rValue += rChars; + } + }; + + class XSecParser::DsX509IssuerNameContext +- : public XSecParser::ReferencedContextImpl ++ : public XSecParser::Context + { + private: +- OUString m_Value; ++ OUString & m_rValue; + + public: + DsX509IssuerNameContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap, +- bool const isReferenced) +- : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) +- { +- } +- +- virtual void EndElement() override ++ OUString & rValue) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) + { +- if (m_isReferenced) +- { +- m_rParser.m_pXSecController->setX509IssuerName(m_Value); +- } +- else +- { +- SAL_INFO("xmlsecurity.helper", "ignoring unsigned X509IssuerName"); +- } + } + + virtual void Characters(OUString const& rChars) override + { +- m_Value += rChars; ++ m_rValue += rChars; + } + }; + + class XSecParser::DsX509IssuerSerialContext +- : public XSecParser::ReferencedContextImpl ++ : public XSecParser::Context + { ++ private: ++ OUString & m_rX509IssuerName; ++ OUString & m_rX509SerialNumber; ++ + public: + DsX509IssuerSerialContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap, +- bool const isReferenced) +- : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) ++ OUString & rIssuerName, OUString & rSerialNumber) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rX509IssuerName(rIssuerName) ++ , m_rX509SerialNumber(rSerialNumber) + { + } + +@@ -344,20 +325,27 @@ class XSecParser::DsX509IssuerSerialContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerName") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_rX509IssuerName); + } + if (nNamespace == XML_NAMESPACE_DS && rName == "X509SerialNumber") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_rX509SerialNumber); + } + // missing: ds:X509SKI, ds:X509SubjectName, ds:X509CRL + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } + }; + ++/// can't be sure what is supposed to happen here because the spec is clear as mud + class XSecParser::DsX509DataContext + : public XSecParser::Context + { ++ private: ++ // sigh... "No ordering is implied by the above constraints." ++ // so store the ball of mud in vectors and try to figure it out later. ++ std::vector> m_X509IssuerSerials; ++ std::vector m_X509Certificates; ++ + public: + DsX509DataContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap) +@@ -365,18 +353,24 @@ class XSecParser::DsX509DataContext + { + } + ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setX509Data(m_X509IssuerSerials, m_X509Certificates); ++ } ++ + virtual std::unique_ptr CreateChildContext( + std::unique_ptr pOldNamespaceMap, + sal_uInt16 const nNamespace, OUString const& rName) override + { + if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerSerial") + { +- // can't require KeyInfo to be signed so pass in *true* +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), true); ++ m_X509IssuerSerials.emplace_back(); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_X509IssuerSerials.back().first, m_X509IssuerSerials.back().second); + } + if (nNamespace == XML_NAMESPACE_DS && rName == "X509Certificate") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ m_X509Certificates.emplace_back(); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_X509Certificates.back()); + } + // missing: ds:X509SKI, ds:X509SubjectName, ds:X509CRL + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); +@@ -968,30 +962,20 @@ class XSecParser::LoSignatureLineContext + }; + + class XSecParser::XadesCertDigestContext +- : public XSecParser::ReferencedContextImpl ++ : public XSecParser::Context + { + private: +- OUString m_Value; +- sal_Int32 m_nReferenceDigestID = css::xml::crypto::DigestID::SHA1; ++ OUString & m_rDigestValue; ++ sal_Int32 & m_rReferenceDigestID; + + public: + XadesCertDigestContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap, +- bool const isReferenced) +- : ReferencedContextImpl(rParser, std::move(pOldNamespaceMap), isReferenced) +- { +- } +- +- virtual void EndElement() override ++ OUString & rDigestValue, sal_Int32 & rReferenceDigestID) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rDigestValue(rDigestValue) ++ , m_rReferenceDigestID(rReferenceDigestID) + { +- if (m_isReferenced) +- { +- m_rParser.m_pXSecController->setCertDigest(m_Value/* FIXME , m_nReferenceDigestID*/); +- } +- else +- { +- SAL_INFO("xmlsecurity.helper", "ignoring unsigned CertDigest"); +- } + } + + virtual std::unique_ptr CreateChildContext( +@@ -1000,11 +984,11 @@ class XSecParser::XadesCertDigestContext + { + if (nNamespace == XML_NAMESPACE_DS && rName == "DigestMethod") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_nReferenceDigestID); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_rReferenceDigestID); + } + if (nNamespace == XML_NAMESPACE_DS && rName == "DigestValue") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_Value); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_rDigestValue); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +@@ -1013,6 +997,12 @@ class XSecParser::XadesCertDigestContext + class XSecParser::XadesCertContext + : public XSecParser::ReferencedContextImpl + { ++ private: ++ sal_Int32 m_nReferenceDigestID = css::xml::crypto::DigestID::SHA1; ++ OUString m_CertDigest; ++ OUString m_X509IssuerName; ++ OUString m_X509SerialNumber; ++ + public: + XadesCertContext(XSecParser & rParser, + std::unique_ptr pOldNamespaceMap, +@@ -1021,17 +1011,29 @@ class XSecParser::XadesCertContext + { + } + ++ virtual void EndElement() override ++ { ++ if (m_isReferenced) ++ { ++ m_rParser.m_pXSecController->setX509CertDigest(m_CertDigest, m_nReferenceDigestID, m_X509IssuerName, m_X509SerialNumber); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "ignoring unsigned xades:Cert"); ++ } ++ } ++ + virtual std::unique_ptr CreateChildContext( + std::unique_ptr pOldNamespaceMap, + sal_uInt16 const nNamespace, OUString const& rName) override + { + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "CertDigest") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_CertDigest, m_nReferenceDigestID); + } + if (nNamespace == XML_NAMESPACE_XADES132 && rName == "IssuerSerial") + { +- return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_isReferenced); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_X509IssuerName, m_X509SerialNumber); + } + return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx +index 1e1688767f00..fd33a320d9bd 100644 +--- a/xmlsecurity/source/helper/xsecsign.cxx ++++ b/xmlsecurity/source/helper/xsecsign.cxx +@@ -193,6 +193,7 @@ void XSecController::signAStream( sal_Int32 securityId, const OUString& uri, boo + } + } + ++// note: this is called when creating a new signature from scratch + void XSecController::setX509Certificate( + sal_Int32 nSecurityId, + const OUString& ouX509IssuerName, +@@ -206,10 +207,13 @@ void XSecController::setX509Certificate( + if ( index == -1 ) + { + InternalSignatureInformation isi(nSecurityId, nullptr); +- isi.signatureInfor.ouX509IssuerName = ouX509IssuerName; +- isi.signatureInfor.ouX509SerialNumber = ouX509SerialNumber; +- isi.signatureInfor.ouX509Certificate = ouX509Cert; +- isi.signatureInfor.ouCertDigest = ouX509CertDigest; ++ isi.signatureInfor.X509Datas.clear(); ++ isi.signatureInfor.X509Datas.emplace_back(); ++ isi.signatureInfor.X509Datas.back().emplace_back(); ++ isi.signatureInfor.X509Datas.back().back().X509IssuerName = ouX509IssuerName; ++ isi.signatureInfor.X509Datas.back().back().X509SerialNumber = ouX509SerialNumber; ++ isi.signatureInfor.X509Datas.back().back().X509Certificate = ouX509Cert; ++ isi.signatureInfor.X509Datas.back().back().CertDigest = ouX509CertDigest; + isi.signatureInfor.eAlgorithmID = eAlgorithmID; + m_vInternalSignatureInformations.push_back( isi ); + } +@@ -217,16 +221,19 @@ void XSecController::setX509Certificate( + { + SignatureInformation &si + = m_vInternalSignatureInformations[index].signatureInfor; +- si.ouX509IssuerName = ouX509IssuerName; +- si.ouX509SerialNumber = ouX509SerialNumber; +- si.ouX509Certificate = ouX509Cert; +- si.ouCertDigest = ouX509CertDigest; ++ si.X509Datas.clear(); ++ si.X509Datas.emplace_back(); ++ si.X509Datas.back().emplace_back(); ++ si.X509Datas.back().back().X509IssuerName = ouX509IssuerName; ++ si.X509Datas.back().back().X509SerialNumber = ouX509SerialNumber; ++ si.X509Datas.back().back().X509Certificate = ouX509Cert; ++ si.X509Datas.back().back().CertDigest = ouX509CertDigest; + } + } + + void XSecController::setGpgCertificate( + sal_Int32 nSecurityId, +- const OUString& ouCertDigest, ++ const OUString& ouKeyDigest, + const OUString& ouCert, + const OUString& ouOwner) + { +@@ -237,16 +244,17 @@ void XSecController::setGpgCertificate( + InternalSignatureInformation isi(nSecurityId, nullptr); + isi.signatureInfor.ouGpgCertificate = ouCert; + isi.signatureInfor.ouGpgOwner = ouOwner; +- isi.signatureInfor.ouCertDigest = ouCertDigest; ++ isi.signatureInfor.ouGpgKeyID = ouKeyDigest; + m_vInternalSignatureInformations.push_back( isi ); + } + else + { + SignatureInformation &si + = m_vInternalSignatureInformations[index].signatureInfor; ++ si.X509Datas.clear(); // it is a PGP signature now + si.ouGpgCertificate = ouCert; + si.ouGpgOwner = ouOwner; +- si.ouCertDigest = ouCertDigest; ++ si.ouGpgKeyID = ouKeyDigest; + } + } + +diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx +index 92ebfb6c72e8..89141ed1dfd4 100644 +--- a/xmlsecurity/source/helper/xsecverify.cxx ++++ b/xmlsecurity/source/helper/xsecverify.cxx +@@ -22,6 +22,7 @@ + #include + #include "xsecparser.hxx" + #include "ooxmlsecparser.hxx" ++#include + #include + #include + #include +@@ -240,7 +241,9 @@ void XSecController::setReferenceCount() const + } + } + +-void XSecController::setX509IssuerName( OUString const & ouX509IssuerName ) ++void XSecController::setX509Data( ++ std::vector> & rX509IssuerSerials, ++ std::vector const& rX509Certificates) + { + if (m_vInternalSignatureInformations.empty()) + { +@@ -248,29 +251,52 @@ void XSecController::setX509IssuerName( OUString const & ouX509IssuerName ) + return; + } + InternalSignatureInformation &isi = m_vInternalSignatureInformations.back(); +- isi.signatureInfor.ouX509IssuerName = ouX509IssuerName; +-} +- +-void XSecController::setX509SerialNumber( OUString const & ouX509SerialNumber ) +-{ +- if (m_vInternalSignatureInformations.empty()) ++ SignatureInformation::X509Data data; ++ // due to the excessive flexibility of the spec it's possible that there ++ // is both a reference to a cert and the cert itself in one X509Data ++ for (OUString const& it : rX509Certificates) + { +- SAL_INFO("xmlsecurity.helper","XSecController::setX509SerialNumber: no signature"); +- return; ++ try ++ { ++ data.emplace_back(); ++ data.back().X509Certificate = it; ++ uno::Reference const xSecEnv(m_xSecurityContext->getSecurityEnvironment()); ++ uno::Reference const xCert(xSecEnv->createCertificateFromAscii(it)); ++ if (!xCert.is()) ++ { ++ SAL_INFO("xmlsecurity.helper", "cannot parse X509Certificate"); ++ continue; // will be handled in CheckX509Data ++ } ++ OUString const issuerName(xCert->getIssuerName()); ++ OUString const serialNumber(xmlsecurity::bigIntegerToNumericString(xCert->getSerialNumber())); ++ auto const iter = std::find_if(rX509IssuerSerials.begin(), rX509IssuerSerials.end(), ++ [&](auto const& rX509IssuerSerial) { ++ return xmlsecurity::EqualDistinguishedNames(issuerName, rX509IssuerSerial.first) ++ && serialNumber == rX509IssuerSerial.second; ++ }); ++ if (iter != rX509IssuerSerials.end()) ++ { ++ data.back().X509IssuerName = iter->first; ++ data.back().X509SerialNumber = iter->second; ++ rX509IssuerSerials.erase(iter); ++ } ++ } ++ catch (uno::Exception const&) ++ { ++ SAL_INFO("xmlsecurity.helper", "cannot parse X509Certificate"); ++ } + } +- InternalSignatureInformation &isi = m_vInternalSignatureInformations.back(); +- isi.signatureInfor.ouX509SerialNumber = ouX509SerialNumber; +-} +- +-void XSecController::setX509Certificate( OUString const & ouX509Certificate ) +-{ +- if (m_vInternalSignatureInformations.empty()) ++ // now handle any that are left... ++ for (auto const& it : rX509IssuerSerials) + { +- SAL_INFO("xmlsecurity.helper","XSecController::setX509Certificate: no signature"); +- return; ++ data.emplace_back(); ++ data.back().X509IssuerName = it.first; ++ data.back().X509SerialNumber = it.second; ++ } ++ if (!data.empty()) ++ { ++ isi.signatureInfor.X509Datas.push_back(data); + } +- InternalSignatureInformation &isi = m_vInternalSignatureInformations.back(); +- isi.signatureInfor.ouX509Certificate = ouX509Certificate; + } + + void XSecController::setSignatureValue( OUString const & ouSignatureValue ) +@@ -380,13 +406,67 @@ void XSecController::setSignatureBytes(const uno::Sequence& rBytes) + rInformation.signatureInfor.aSignatureBytes = rBytes; + } + +-void XSecController::setCertDigest(const OUString& rCertDigest) ++void XSecController::setX509CertDigest( ++ OUString const& rCertDigest, sal_Int32 const /*TODO nReferenceDigestID*/, ++ OUString const& rX509IssuerName, OUString const& rX509SerialNumber) + { + if (m_vInternalSignatureInformations.empty()) + return; + + InternalSignatureInformation& rInformation = m_vInternalSignatureInformations.back(); +- rInformation.signatureInfor.ouCertDigest = rCertDigest; ++ for (auto & rData : rInformation.signatureInfor.X509Datas) ++ { ++ for (auto & it : rData) ++ { ++ if (xmlsecurity::EqualDistinguishedNames(it.X509IssuerName, rX509IssuerName) ++ && it.X509SerialNumber == rX509SerialNumber) ++ { ++ it.CertDigest = rCertDigest; ++ return; ++ } ++ } ++ } ++ // fall-back: read the actual certificates ++ for (auto & rData : rInformation.signatureInfor.X509Datas) ++ { ++ for (auto & it : rData) ++ { ++ if (!it.X509Certificate.isEmpty()) ++ { ++ try ++ { ++ uno::Reference const xSecEnv(m_xSecurityContext->getSecurityEnvironment()); ++ uno::Reference const xCert(xSecEnv->createCertificateFromAscii(it.X509Certificate)); ++ if (!xCert.is()) ++ { ++ SAL_INFO("xmlsecurity.helper", "cannot parse X509Certificate"); ++ } ++ else if (xmlsecurity::EqualDistinguishedNames(xCert->getIssuerName(),rX509IssuerName) ++ && xmlsecurity::bigIntegerToNumericString(xCert->getSerialNumber()) == rX509SerialNumber) ++ { ++ it.CertDigest = rCertDigest; ++ // note: testInsertCertificate_PEM_DOCX requires these! ++ it.X509SerialNumber = rX509SerialNumber; ++ it.X509IssuerName = rX509IssuerName; ++ return; ++ } ++ } ++ catch (uno::Exception const&) ++ { ++ SAL_INFO("xmlsecurity.helper", "cannot parse X509Certificate"); ++ } ++ } ++ } ++ } ++ if (!rInformation.signatureInfor.ouGpgCertificate.isEmpty()) ++ { ++ SAL_INFO_IF(rCertDigest != rInformation.signatureInfor.ouGpgKeyID, ++ "xmlsecurity.helper", "PGPKeyID vs CertDigest mismatch"); ++ } ++ else ++ { ++ SAL_INFO("xmlsecurity.helper", "cannot find X509Data for CertDigest"); ++ } + } + + namespace { +diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +index 0e619b2802f8..244cd46ac564 100644 +--- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx ++++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +@@ -26,6 +26,7 @@ + #include + #include "x509certificate_mscryptimpl.hxx" + #include ++#include + #include "sanextension_mscryptimpl.hxx" + + #include "oid.hxx" +@@ -649,4 +650,50 @@ Sequence SAL_CALL X509Certificate_MSCryptImpl::getSupportedServiceName + return { OUString() }; + } + ++namespace xmlsecurity { ++ ++static bool EncodeDistinguishedName(OUString const& rName, CERT_NAME_BLOB & rBlob) ++{ ++ LPCWSTR pszError; ++ if (!CertStrToNameW(X509_ASN_ENCODING, ++ reinterpret_cast(rName.getStr()), CERT_X500_NAME_STR, ++ nullptr, nullptr, &rBlob.cbData, &pszError)) ++ { ++ SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << WindowsErrorString(GetLastError()) << "; " << reinterpret_cast(pszError)); ++ return false; ++ } ++ rBlob.pbData = new BYTE[rBlob.cbData]; ++ if (!CertStrToNameW(X509_ASN_ENCODING, ++ reinterpret_cast(rName.getStr()), CERT_X500_NAME_STR, ++ nullptr, rBlob.pbData, &rBlob.cbData, &pszError)) ++ { ++ SAL_INFO("xmlsecurity.xmlsec", "CertStrToNameW failed: " << WindowsErrorString(GetLastError()) << "; " << reinterpret_cast(pszError)); ++ return false; ++ } ++ return true; ++} ++ ++bool EqualDistinguishedNames( ++ OUString const& rName1, OUString const& rName2) ++{ ++ CERT_NAME_BLOB blob1; ++ if (!EncodeDistinguishedName(rName1, blob1)) ++ { ++ return false; ++ } ++ CERT_NAME_BLOB blob2; ++ if (!EncodeDistinguishedName(rName2, blob2)) ++ { ++ delete[] blob1.pbData; ++ return false; ++ } ++ bool const ret(CertCompareCertificateName(X509_ASN_ENCODING, ++ &blob1, &blob2) == TRUE); ++ delete[] blob2.pbData; ++ delete[] blob1.pbData; ++ return ret; ++} ++ ++} // namespace xmlsecurity ++ + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx +index dcbad0348091..c699c950f351 100644 +--- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx ++++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx +@@ -18,6 +18,7 @@ + */ + + #include ++#include + #include + #include + +@@ -254,6 +255,7 @@ SAL_CALL XMLSignature_MSCryptImpl::validate( + ++nReferenceGood; + } + } ++ SAL_INFO("xmlsecurity.xmlsec", "xmlSecDSigCtxVerify status " << pDsigCtx->status << ", references good " << nReferenceGood << " of " << nReferenceCount); + + if (rs == 0 && nReferenceCount == nReferenceGood) + { +diff --git a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx +index 1a323d33f32f..d6143a81883c 100644 +--- a/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx ++++ b/xmlsecurity/source/xmlsec/nss/x509certificate_nssimpl.cxx +@@ -31,6 +31,7 @@ + #include + #include "x509certificate_nssimpl.hxx" + ++#include + #include + + #include "sanextension_nssimpl.hxx" +@@ -533,4 +534,28 @@ sal_Bool SAL_CALL X509Certificate_NssImpl::supportsService(const OUString& servi + /* XServiceInfo */ + Sequence SAL_CALL X509Certificate_NssImpl::getSupportedServiceNames() { return { OUString() }; } + ++namespace xmlsecurity { ++ ++bool EqualDistinguishedNames( ++ OUString const& rName1, OUString const& rName2) ++{ ++ CERTName *const pName1(CERT_AsciiToName(OUStringToOString(rName1, RTL_TEXTENCODING_UTF8).getStr())); ++ if (pName1 == nullptr) ++ { ++ return false; ++ } ++ CERTName *const pName2(CERT_AsciiToName(OUStringToOString(rName2, RTL_TEXTENCODING_UTF8).getStr())); ++ if (pName2 == nullptr) ++ { ++ CERT_DestroyName(pName1); ++ return false; ++ } ++ bool const ret(CERT_CompareName(pName1, pName2) == SECEqual); ++ CERT_DestroyName(pName2); ++ CERT_DestroyName(pName1); ++ return ret; ++} ++ ++} // namespace xmlsecurity ++ + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx +index 32e4335a5207..b41d754f7407 100644 +--- a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx ++++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx +@@ -26,6 +26,8 @@ + + #include "securityenvironment_nssimpl.hxx" + ++#include ++ + #include + #include + +@@ -261,6 +263,7 @@ SAL_CALL XMLSignature_NssImpl::validate( + ++nReferenceGood; + } + } ++ SAL_INFO("xmlsecurity.xmlsec", "xmlSecDSigCtxVerify status " << pDsigCtx->status << ", references good " << nReferenceGood << " of " << nReferenceCount); + + if (rs == 0 && pDsigCtx->status == xmlSecDSigStatusSucceeded && nReferenceCount == nReferenceGood) + { +-- +cgit v1.2.1 + diff --git a/debian/patches/xmlsecurity-replace-XSecParser-implementation.diff b/debian/patches/xmlsecurity-replace-XSecParser-implementation.diff new file mode 100644 index 000000000..861c4e226 --- /dev/null +++ b/debian/patches/xmlsecurity-replace-XSecParser-implementation.diff @@ -0,0 +1,2170 @@ +From ad5930e87e788780a255523f106deb1dde5d7b37 Mon Sep 17 00:00:00 2001 +From: Michael Stahl +Date: Fri, 12 Feb 2021 16:42:51 +0100 +Subject: xmlsecurity: replace XSecParser implementation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Implement Namespaces in XML and follow xmldsig-core and XAdES schemas. + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110833 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 12b15be8f4f930a04d8056b9219ac969b42a9784) + +xmlsecurity: move XSecParser state into contexts + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111158 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit 59df9e70ce1a7ec797b836bda7f9642912febc53) + +xmlsecurity: move XSecParser Reference state into contexts + +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111159 +Tested-by: Jenkins +Reviewed-by: Michael Stahl +(cherry picked from commit cfeb89a758b5f0ec406f0d72444e52ed2f47b85e) + +Change-Id: I03537b51bb757ecbfa63a826b38de543c70ba032 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111907 +Tested-by: Jenkins +Reviewed-by: Caolán McNamara +--- + include/xmloff/xmlimp.hxx | 6 +- + include/xmloff/xmlnmspe.hxx | 7 + + include/xmloff/xmltoken.hxx | 13 + + xmloff/source/core/xmlimp.cxx | 26 +- + xmloff/source/core/xmltoken.cxx | 13 + + xmloff/source/token/tokens.txt | 10 + + xmlsecurity/source/helper/xsecparser.cxx | 1634 ++++++++++++++++++++++++------ + xmlsecurity/source/helper/xsecparser.hxx | 99 +- + 8 files changed, 1427 insertions(+), 381 deletions(-) + +diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx +index 7f08609189ab..86871b7df445 100644 +--- a/include/xmloff/xmlimp.hxx ++++ b/include/xmloff/xmlimp.hxx +@@ -240,8 +240,12 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper< + + static void initializeNamespaceMaps(); + void registerNamespaces(); +- std::unique_ptr processNSAttributes( ++public: ++ static std::unique_ptr processNSAttributes( ++ std::unique_ptr & rpNamespaceMap, ++ SvXMLImport *const pImport, + const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList); ++private: + void Characters(const OUString& aChars); + + css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator; +diff --git a/include/xmloff/xmlnmspe.hxx b/include/xmloff/xmlnmspe.hxx +index d45832f02d81..cabdcc7578e2 100644 +--- a/include/xmloff/xmlnmspe.hxx ++++ b/include/xmloff/xmlnmspe.hxx +@@ -69,6 +69,13 @@ constexpr sal_uInt16 XML_NAMESPACE_TCD = 34; // text conversion di + constexpr sal_uInt16 XML_NAMESPACE_DLG = 35; + constexpr sal_uInt16 XML_NAMESPACE_REPORT = 36; + constexpr sal_uInt16 XML_NAMESPACE_VERSIONS_LIST = 37; ++// OOo extension digital signatures, used in ODF 1.1 ++constexpr sal_uInt16 XML_NAMESPACE_DSIG_OOO = 38; ++// ODF 1.2 digital signature namespaces ++constexpr sal_uInt16 XML_NAMESPACE_DSIG = 39; ++constexpr sal_uInt16 XML_NAMESPACE_DS = 40; ++constexpr sal_uInt16 XML_NAMESPACE_XADES132 = 41; ++constexpr sal_uInt16 XML_NAMESPACE_XADES141 = 42; + + // namespaces for ODF extended formats + constexpr sal_uInt16 XML_NAMESPACE_EXT_BASE = 50; +diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx +index 49178ebdc996..b6956245ed17 100644 +--- a/include/xmloff/xmltoken.hxx ++++ b/include/xmloff/xmltoken.hxx +@@ -135,6 +135,19 @@ namespace xmloff::token { + XML_NP_GRDDL, + XML_N_GRDDL, + ++ // OOo extension digital signatures, used in ODF 1.1 ++ XML_NP_DSIG_OOO, ++ XML_N_DSIG_OOO, ++ // ODF 1.2 digital signatures ++ XML_NP_DSIG, ++ XML_N_DSIG, ++ XML_NP_DS, ++ XML_N_DS, ++ XML_NP_XADES132, ++ XML_N_XADES132, ++ XML_NP_XADES141, ++ XML_N_XADES141, ++ + // ODF Enhanced namespaces + XML_NP_OFFICE_EXT, + XML_N_OFFICE_EXT, +diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx +index 0c9e9d06cfd4..18429cc4860f 100644 +--- a/xmloff/source/core/xmlimp.cxx ++++ b/xmloff/source/core/xmlimp.cxx +@@ -665,6 +665,8 @@ void SAL_CALL SvXMLImport::endDocument() + } + + std::unique_ptr SvXMLImport::processNSAttributes( ++ std::unique_ptr & rpNamespaceMap, ++ SvXMLImport *const pImport, // TODO??? + const uno::Reference< xml::sax::XAttributeList >& xAttrList) + { + std::unique_ptr pRewindMap; +@@ -672,12 +674,13 @@ std::unique_ptr SvXMLImport::processNSAttributes( + for( sal_Int16 i=0; i < nAttrCount; i++ ) + { + const OUString& rAttrName = xAttrList->getNameByIndex( i ); +- if ( rAttrName == "office:version" ) ++ if (pImport && rAttrName == "office:version") + { +- mpImpl->aODFVersion = xAttrList->getValueByIndex( i ); ++ pImport->mpImpl->aODFVersion = xAttrList->getValueByIndex( i ); + + // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2 +- if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( mpImpl->aODFVersion ) ) ++ if (pImport->mpImpl->mStreamName == "content.xml" ++ && !pImport->IsODFVersionConsistent(pImport->mpImpl->aODFVersion)) + { + throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!", + uno::Reference< uno::XInterface >(), +@@ -691,8 +694,8 @@ std::unique_ptr SvXMLImport::processNSAttributes( + { + if( !pRewindMap ) + { +- pRewindMap = std::move(mpNamespaceMap); +- mpNamespaceMap.reset(new SvXMLNamespaceMap(*pRewindMap)); ++ pRewindMap = std::move(rpNamespaceMap); ++ rpNamespaceMap.reset(new SvXMLNamespaceMap(*pRewindMap)); + } + const OUString& rAttrValue = xAttrList->getValueByIndex( i ); + +@@ -700,18 +703,18 @@ std::unique_ptr SvXMLImport::processNSAttributes( + ? OUString() + : rAttrName.copy( 6 ) ); + // Add namespace, but only if it is known. +- sal_uInt16 nKey = mpNamespaceMap->AddIfKnown( aPrefix, rAttrValue ); ++ sal_uInt16 nKey = rpNamespaceMap->AddIfKnown( aPrefix, rAttrValue ); + // If namespace is unknown, try to match a name with similar + // TC Id and version + if( XML_NAMESPACE_UNKNOWN == nKey ) + { + OUString aTestName( rAttrValue ); + if( SvXMLNamespaceMap::NormalizeURI( aTestName ) ) +- nKey = mpNamespaceMap->AddIfKnown( aPrefix, aTestName ); ++ nKey = rpNamespaceMap->AddIfKnown( aPrefix, aTestName ); + } + // If that namespace is not known, too, add it as unknown + if( XML_NAMESPACE_UNKNOWN == nKey ) +- mpNamespaceMap->Add( aPrefix, rAttrValue ); ++ rpNamespaceMap->Add( aPrefix, rAttrValue ); + + } + } +@@ -724,7 +727,8 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, + // SAL_INFO("svg", "startElement " << rName); + // Process namespace attributes. This must happen before creating the + // context, because namespace declaration apply to the element name itself. +- std::unique_ptr pRewindMap(processNSAttributes(xAttrList)); ++ std::unique_ptr pRewindMap( ++ processNSAttributes(mpNamespaceMap, this, xAttrList)); + + // Get element's namespace and local name. + OUString aLocalName; +@@ -898,7 +902,7 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element, + + maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList ); + std::unique_ptr pRewindMap( +- processNSAttributes( maNamespaceAttrList.get() )); ++ processNSAttributes(mpNamespaceMap, this, maNamespaceAttrList.get())); + assert( dynamic_cast( xContext.get() ) != nullptr ); + SvXMLImportContext *pContext = static_cast( xContext.get() ); + if (pRewindMap) +@@ -2251,7 +2255,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::endDocument() + void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName, + const uno::Reference< xml::sax::XAttributeList >& xAttrList ) + { +- mrImport->processNSAttributes(xAttrList); ++ SvXMLImport::processNSAttributes(mrImport->mpNamespaceMap, mrImport.get(), xAttrList); + OUString aLocalName; + sal_uInt16 nPrefix = mrImport->mpNamespaceMap->GetKeyByAttrName( rName, &aLocalName ); + Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast( +diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx +index 8d9a70f5e082..91c014f5756f 100644 +--- a/xmloff/source/core/xmltoken.cxx ++++ b/xmloff/source/core/xmltoken.cxx +@@ -144,6 +144,19 @@ namespace xmloff::token { + TOKEN( "grddl", XML_NP_GRDDL ), + TOKEN( "http://www.w3.org/2003/g/data-view#", XML_N_GRDDL ), + ++ // OOo extension digital signatures, used in ODF 1.1 ++ TOKEN( "dsigooo", XML_NP_DSIG_OOO ), ++ TOKEN( "http://openoffice.org/2004/documentsignatures", XML_N_DSIG_OOO ), ++ // ODF 1.2 digital signature namespaces ++ TOKEN( "dsig", XML_NP_DSIG ), ++ TOKEN( "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0", XML_N_DSIG ), ++ TOKEN( "ds", XML_NP_DS ), ++ TOKEN( "http://www.w3.org/2000/09/xmldsig#", XML_N_DS ), ++ TOKEN( "xades132", XML_NP_XADES132 ), ++ TOKEN( "http://uri.etsi.org/01903/v1.3.2#", XML_N_XADES132 ), ++ TOKEN( "xades141", XML_NP_XADES141 ), ++ TOKEN( "http://uri.etsi.org/01903/v1.4.1#", XML_N_XADES141 ), ++ + // ODF Enhanced namespaces + TOKEN( "officeooo", XML_NP_OFFICE_EXT ), + TOKEN( "http://openoffice.org/2009/office", XML_N_OFFICE_EXT ), +diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt +index 34b9af91e03c..495e519ffb2d 100644 +--- a/xmloff/source/token/tokens.txt ++++ b/xmloff/source/token/tokens.txt +@@ -72,6 +72,16 @@ xhtml + N_XHTML_DUMMY + grddl + N_GRDDL_DUMMY ++dsigooo ++N_DSIG_OOO_DUMMY ++dsig ++N_DSIG_DUMMY ++ds ++N_DS_DUMMY ++xades132 ++N_XADES132_DUMMY ++xades141 ++N_XADES141_DUMMY + officeooo + N_OFFICE_EXT_DUMMY + formx +diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx +index 9f2bbe074a1b..0aecb1854f8c 100644 +--- a/xmlsecurity/source/helper/xsecparser.cxx ++++ b/xmlsecurity/source/helper/xsecparser.cxx +@@ -21,476 +21,1468 @@ + #include "xsecparser.hxx" + #include + #include ++ ++#include ++#include ++ + #include + #include + #include + ++class XSecParser::Context ++{ ++ protected: ++ friend class XSecParser; ++ XSecParser & m_rParser; ++ private: ++ std::unique_ptr m_pOldNamespaceMap; + +-XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper, +- XSecController* pXSecController) +- : m_bInX509IssuerName(false) +- , m_bInX509SerialNumber(false) +- , m_bInX509Certificate(false) +- , m_bInGpgCertificate(false) +- , m_bInGpgKeyID(false) +- , m_bInGpgOwner(false) +- , m_bInCertDigest(false) +- , m_bInEncapsulatedX509Certificate(false) +- , m_bInSigningTime(false) +- , m_bInDigestValue(false) +- , m_bInSignatureValue(false) +- , m_bInDate(false) +- , m_bInDescription(false) +- , m_bInSignatureLineId(false) +- , m_bInSignatureLineValidImage(false) +- , m_bInSignatureLineInvalidImage(false) +- , m_pXSecController(pXSecController) +- , m_bReferenceUnresolved(false) +- , m_nReferenceDigestID(css::xml::crypto::DigestID::SHA1) +- , m_rXMLSignatureHelper(rXMLSignatureHelper) ++ public: ++ Context(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : m_rParser(rParser) ++ , m_pOldNamespaceMap(std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual ~Context() = default; ++ ++ virtual void StartElement( ++ css::uno::Reference const& /*xAttrs*/) ++ { ++ } ++ ++ virtual void EndElement() ++ { ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const /*nNamespace*/, OUString const& /*rName*/); ++ ++ virtual void Characters(OUString const& /*rChars*/) ++ { ++ } ++}; ++ ++// it's possible that an unsupported element has an Id attribute and a ++// ds:Reference digesting it - probably this means XSecController needs to know ++// about it. (For known elements, the Id attribute is only processed according ++// to the schema.) ++class XSecParser::UnknownContext ++ : public XSecParser::Context + { ++ public: ++ UnknownContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++}; ++ ++auto XSecParser::Context::CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const /*nNamespace*/, OUString const& /*rName*/) ++-> std::unique_ptr ++{ ++ // default: create new base context ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } + +-OUString XSecParser::getIdAttr(const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) ++class XSecParser::LoPGPOwnerContext ++ : public XSecParser::Context + { +- OUString ouIdAttr = xAttribs->getValueByName("id"); ++ private: ++ OUString m_Value; + +- if (ouIdAttr.isEmpty()) +- { +- ouIdAttr = xAttribs->getValueByName("Id"); +- } ++ public: ++ LoPGPOwnerContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } + +- return ouIdAttr; +-} ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setGpgOwner(m_Value); ++ } + +-/* +- * XDocumentHandler +- */ +-void SAL_CALL XSecParser::startDocument( ) ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsPGPKeyPacketContext ++ : public XSecParser::Context + { +- m_bInX509IssuerName = false; +- m_bInX509SerialNumber = false; +- m_bInX509Certificate = false; +- m_bInGpgCertificate = false; +- m_bInGpgKeyID = false; +- m_bInGpgOwner = false; +- m_bInSignatureValue = false; +- m_bInDigestValue = false; +- m_bInDate = false; +- m_bInDescription = false; ++ private: ++ OUString m_Value; + +- if (m_xNextHandler.is()) +- { +- m_xNextHandler->startDocument(); +- } +-} ++ public: ++ DsPGPKeyPacketContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } + +-void SAL_CALL XSecParser::endDocument( ) ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setGpgCertificate(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsPGPKeyIDContext ++ : public XSecParser::Context + { +- if (m_xNextHandler.is()) +- { +- m_xNextHandler->endDocument(); +- } +-} ++ private: ++ OUString m_Value; + +-void SAL_CALL XSecParser::startElement( +- const OUString& aName, +- const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) ++ public: ++ DsPGPKeyIDContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setGpgKeyID(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsPGPDataContext ++ : public XSecParser::Context + { +- try +- { +- OUString ouIdAttr = getIdAttr(xAttribs); +- if (!ouIdAttr.isEmpty()) ++ public: ++ DsPGPDataContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& /*xAttrs*/) override ++ { ++ m_rParser.m_pXSecController->switchGpgSignature(); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "PGPKeyID") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "PGPKeyPacket") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "PGPOwner") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::DsX509CertificateContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ DsX509CertificateContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setX509Certificate(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsX509SerialNumberContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ DsX509SerialNumberContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setX509SerialNumber(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsX509IssuerNameContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ DsX509IssuerNameContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setX509IssuerName(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsX509IssuerSerialContext ++ : public XSecParser::Context ++{ ++ public: ++ DsX509IssuerSerialContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerName") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "X509SerialNumber") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: ds:X509SKI, ds:X509SubjectName, ds:X509CRL ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::DsX509DataContext ++ : public XSecParser::Context ++{ ++ public: ++ DsX509DataContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "X509IssuerSerial") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "X509Certificate") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: ds:X509SKI, ds:X509SubjectName, ds:X509CRL ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::DsKeyInfoContext ++ : public XSecParser::Context ++{ ++ public: ++ DsKeyInfoContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "X509Data") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "PGPData") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: ds:KeyName, ds:KeyValue, ds:RetrievalMethod, ds:SPKIData, ds:MgmtData ++ // (old code would read ds:Transform inside ds:RetrievalMethod but ++ // presumably that was a bug) ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++ ++}; ++ ++class XSecParser::DsSignatureValueContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ DsSignatureValueContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setSignatureValue(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::DsDigestValueContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString & m_rValue; ++ ++ public: ++ DsDigestValueContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap, ++ OUString & rValue) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rValue(rValue) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& /*xAttrs*/) override ++ { ++ m_rValue.clear(); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_rValue += rChars; ++ } ++}; ++ ++class XSecParser::DsDigestMethodContext ++ : public XSecParser::Context ++{ ++ private: ++ sal_Int32 & m_rReferenceDigestID; ++ ++ public: ++ DsDigestMethodContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap, ++ sal_Int32 & rReferenceDigestID) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rReferenceDigestID(rReferenceDigestID) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); ++ ++ SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); ++ if (!ouAlgorithm.isEmpty()) ++ { ++ SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 ++ && ouAlgorithm != ALGO_XMLDSIGSHA256 ++ && ouAlgorithm != ALGO_XMLDSIGSHA512, ++ "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); ++ if (ouAlgorithm == ALGO_XMLDSIGSHA1) ++ m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; ++ else if (ouAlgorithm == ALGO_XMLDSIGSHA256) ++ m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; ++ else if (ouAlgorithm == ALGO_XMLDSIGSHA512) ++ m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; ++ else ++ m_rReferenceDigestID = 0; ++ } ++ } ++}; ++ ++class XSecParser::DsTransformContext ++ : public XSecParser::Context ++{ ++ private: ++ bool & m_rIsC14N; ++ ++ public: ++ DsTransformContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap, ++ bool & rIsC14N) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rIsC14N(rIsC14N) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); ++ ++ if (ouAlgorithm == ALGO_C14N) ++ /* ++ * a xml stream ++ */ ++ { ++ m_rIsC14N = true; ++ } ++ } ++}; ++ ++class XSecParser::DsTransformsContext ++ : public XSecParser::Context ++{ ++ private: ++ bool & m_rIsC14N; ++ ++ public: ++ DsTransformsContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap, ++ bool & rIsC14N) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ , m_rIsC14N(rIsC14N) ++ { ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "Transform") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_rIsC14N); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::DsReferenceContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_URI; ++ OUString m_Type; ++ OUString m_DigestValue; ++ bool m_IsC14N = false; ++ // Relevant for ODF. The digest algorithm selected by the DigestMethod ++ // element's Algorithm attribute. @see css::xml::crypto::DigestID. ++ sal_Int32 m_nReferenceDigestID = css::xml::crypto::DigestID::SHA1; ++ ++ public: ++ DsReferenceContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ ++ m_URI = xAttrs->getValueByName("URI"); ++ SAL_WARN_IF(m_URI.isEmpty(), "xmlsecurity.helper", "URI is empty"); ++ // Remember the type of this reference. ++ m_Type = xAttrs->getValueByName("Type"); ++ } ++ ++ virtual void EndElement() override ++ { ++ if (m_URI.startsWith("#")) ++ { ++ /* ++ * remove the first character '#' from the attribute value ++ */ ++ m_rParser.m_pXSecController->addReference(m_URI.copy(1), m_nReferenceDigestID, m_Type); ++ } ++ else ++ { ++ if (m_IsC14N) // this is determined by nested ds:Transform ++ { ++ m_rParser.m_pXSecController->addStreamReference(m_URI, false, m_nReferenceDigestID); ++ } ++ else ++ /* ++ * it must be an octet stream ++ */ ++ { ++ m_rParser.m_pXSecController->addStreamReference(m_URI, true, m_nReferenceDigestID); ++ } ++ } ++ ++ m_rParser.m_pXSecController->setDigestValue(m_nReferenceDigestID, m_DigestValue); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "Transforms") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_IsC14N); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "DigestMethod") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_nReferenceDigestID); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "DigestValue") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_DigestValue); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::DsSignatureMethodContext ++ : public XSecParser::Context ++{ ++ public: ++ DsSignatureMethodContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); ++ if (ouAlgorithm == ALGO_ECDSASHA1 || ouAlgorithm == ALGO_ECDSASHA256 ++ || ouAlgorithm == ALGO_ECDSASHA512) ++ { ++ m_rParser.m_pXSecController->setSignatureMethod(svl::crypto::SignatureMethodAlgorithm::ECDSA); ++ } ++ } ++}; ++ ++class XSecParser::DsSignedInfoContext ++ : public XSecParser::Context ++{ ++ public: ++ DsSignedInfoContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setReferenceCount(); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureMethod") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "Reference") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: ds:CanonicalizationMethod ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::XadesEncapsulatedX509CertificateContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ XadesEncapsulatedX509CertificateContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->addEncapsulatedX509Certificate(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::XadesCertificateValuesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesCertificateValuesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "EncapsulatedX509Certificate") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: xades:OtherCertificate ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::XadesUnsignedSignaturePropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesUnsignedSignaturePropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "CertificateValues") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: ++ // xades:CounterSignature ++ // ^ old code would read a ds:Signature inside it? ++ // xades:SignatureTimeStamp ++ // xades:CompleteCertificateRefs ++ // xades:CompleteRevocationRefs ++ // xades:AttributeCertificateRefs ++ // xades:AttributeRevocationRefs ++ // xades:SigAndRefsTimeStamp ++ // xades:RefsOnlyTimeStamp ++ // xades:RevocationValues ++ // xades:AttrAuthoritiesCertValues ++ // ^ old code: was equivalent to CertificateValues ??? ++ // xades:AttributeRevocationValues ++ // xades:ArchiveTimeStamp ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::XadesUnsignedPropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesUnsignedPropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override ++ { ++ m_rParser.HandleIdAttr(xAttrs); ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "UnsignedSignatureProperties") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: xades:UnsignedDataObjectProperties ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); ++ } ++}; ++ ++class XSecParser::LoSignatureLineIdContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ LoSignatureLineIdContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setSignatureLineId(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::LoSignatureLineValidImageContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ LoSignatureLineValidImageContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setValidSignatureImage(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override + { +- m_pXSecController->collectToVerify( ouIdAttr ); ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::LoSignatureLineInvalidImageContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ LoSignatureLineInvalidImageContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual void EndElement() override ++ { ++ m_rParser.m_pXSecController->setInvalidSignatureImage(m_Value); ++ } ++ ++ virtual void Characters(OUString const& rChars) override ++ { ++ m_Value += rChars; ++ } ++}; ++ ++class XSecParser::LoSignatureLineContext ++ : public XSecParser::Context ++{ ++ public: ++ LoSignatureLineContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) ++ { ++ } ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineId") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineValidImage") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLineInvalidImage") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } ++}; + +- if ( aName == "Signature" ) ++class XSecParser::XadesCertDigestContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ sal_Int32 m_nReferenceDigestID = css::xml::crypto::DigestID::SHA1; ++ ++ public: ++ XadesCertDigestContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_rXMLSignatureHelper.StartVerifySignatureElement(); +- m_pXSecController->addSignature(); +- if (!ouIdAttr.isEmpty()) +- { +- m_pXSecController->setId( ouIdAttr ); +- } + } +- else if (aName == "SignatureMethod") ++ ++ virtual void EndElement() override + { +- OUString ouAlgorithm = xAttribs->getValueByName("Algorithm"); +- if (ouAlgorithm == ALGO_ECDSASHA1 || ouAlgorithm == ALGO_ECDSASHA256 +- || ouAlgorithm == ALGO_ECDSASHA512) +- m_pXSecController->setSignatureMethod(svl::crypto::SignatureMethodAlgorithm::ECDSA); ++ m_rParser.m_pXSecController->setCertDigest(m_Value/* FIXME , m_nReferenceDigestID*/); + } +- else if ( aName == "Reference" ) ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- OUString ouUri = xAttribs->getValueByName("URI"); +- SAL_WARN_IF( ouUri.isEmpty(), "xmlsecurity.helper", "URI is empty" ); +- // Remember the type of this reference. +- OUString ouType = xAttribs->getValueByName("Type"); +- if (ouUri.startsWith("#")) ++ if (nNamespace == XML_NAMESPACE_DS && rName == "DigestMethod") + { +- /* +- * remove the first character '#' from the attribute value +- */ +- m_pXSecController->addReference( ouUri.copy(1), m_nReferenceDigestID, ouType ); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_nReferenceDigestID); + } +- else ++ if (nNamespace == XML_NAMESPACE_DS && rName == "DigestValue") + { +- /* +- * remember the uri +- */ +- m_currentReferenceURI = ouUri; +- m_bReferenceUnresolved = true; ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap), m_Value); + } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "DigestMethod") ++}; ++ ++class XSecParser::XadesCertContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesCertContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- OUString ouAlgorithm = xAttribs->getValueByName("Algorithm"); ++ } + +- SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); +- if (!ouAlgorithm.isEmpty()) ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override ++ { ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "CertDigest") + { +- SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 +- && ouAlgorithm != ALGO_XMLDSIGSHA256 +- && ouAlgorithm != ALGO_XMLDSIGSHA512, +- "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); +- if (ouAlgorithm == ALGO_XMLDSIGSHA1) +- m_nReferenceDigestID = css::xml::crypto::DigestID::SHA1; +- else if (ouAlgorithm == ALGO_XMLDSIGSHA256) +- m_nReferenceDigestID = css::xml::crypto::DigestID::SHA256; +- else if (ouAlgorithm == ALGO_XMLDSIGSHA512) +- m_nReferenceDigestID = css::xml::crypto::DigestID::SHA512; +- else +- m_nReferenceDigestID = 0; ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } +- } +- else if (aName == "Transform") +- { +- if ( m_bReferenceUnresolved ) ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "IssuerSerial") + { +- OUString ouAlgorithm = xAttribs->getValueByName("Algorithm"); +- +- if (ouAlgorithm == ALGO_C14N) +- /* +- * a xml stream +- */ +- { +- m_pXSecController->addStreamReference( m_currentReferenceURI, false, m_nReferenceDigestID ); +- m_bReferenceUnresolved = false; +- } ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "X509IssuerName") +- { +- m_ouX509IssuerName.clear(); +- m_bInX509IssuerName = true; +- } +- else if (aName == "X509SerialNumber") ++}; ++ ++class XSecParser::XadesSigningCertificateContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesSigningCertificateContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_ouX509SerialNumber.clear(); +- m_bInX509SerialNumber = true; + } +- else if (aName == "X509Certificate") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_ouX509Certificate.clear(); +- m_bInX509Certificate = true; ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "Cert") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "PGPData") ++}; ++ ++class XSecParser::XadesSigningTimeContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesSigningTimeContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->switchGpgSignature(); + } +- else if (aName == "PGPKeyID") ++ ++ virtual void StartElement( ++ css::uno::Reference const& /*xAttrs*/) override + { +- m_ouGpgKeyID.clear(); +- m_bInGpgKeyID = true; ++ m_rParser.m_ouDate.clear(); + } +- else if (aName == "PGPKeyPacket") ++ ++ virtual void EndElement() override + { +- m_ouGpgCertificate.clear(); +- m_bInGpgCertificate = true; ++ m_rParser.m_pXSecController->setDate( m_rParser.m_ouDate ); + } +- else if (aName == "loext:PGPOwner") ++ ++ virtual void Characters(OUString const& rChars) override + { +- m_ouGpgOwner.clear(); +- m_bInGpgOwner = true; ++ m_rParser.m_ouDate += rChars; + } +- else if (aName == "SignatureValue") ++}; ++ ++class XSecParser::XadesSignedSignaturePropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesSignedSignaturePropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_ouSignatureValue.clear(); +- m_bInSignatureValue = true; + } +- else if (aName == "DigestValue" && !m_bInCertDigest) ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_ouDigestValue.clear(); +- m_bInDigestValue = true; ++ m_rParser.HandleIdAttr(xAttrs); + } +- else if (aName == "xd:CertDigest") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_ouCertDigest.clear(); +- m_bInCertDigest = true; ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SigningTime") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SigningCertificate") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_LO_EXT && rName == "SignatureLine") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ // missing: xades:SignaturePolicyIdentifier, xades:SignatureProductionPlace, xades:SignerRole ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- // FIXME: Existing code here in xmlsecurity uses "xd" as the namespace prefix for XAdES, +- // while the sample document attached to tdf#76142 uses "xades". So accept either here. Of +- // course this is idiotic and wrong, the right thing would be to use a proper way to parse +- // XML that would handle namespaces correctly. I have no idea how substantial re-plumbing of +- // this code that would require. +- else if (aName == "xd:EncapsulatedX509Certificate" || aName == "xades:EncapsulatedX509Certificate") ++}; ++ ++class XSecParser::XadesSignedPropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesSignedPropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_ouEncapsulatedX509Certificate.clear(); +- m_bInEncapsulatedX509Certificate = true; + } +- else if (aName == "xd:SigningTime" || aName == "xades:SigningTime") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_ouDate.clear(); +- m_bInSigningTime = true; ++ m_rParser.HandleIdAttr(xAttrs); + } +- else if ( aName == "SignatureProperty" ) ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- if (!ouIdAttr.isEmpty()) ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SignedSignatureProperties") + { +- m_pXSecController->setPropertyId( ouIdAttr ); ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } ++ // missing: xades:SignedDataObjectProperties ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "dc:date") +- { +- if (m_ouDate.isEmpty()) +- m_bInDate = true; +- } +- else if (aName == "dc:description") ++}; ++ ++class XSecParser::XadesQualifyingPropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ XadesQualifyingPropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_ouDescription.clear(); +- m_bInDescription = true; + } +- else if (aName == "loext:SignatureLineId") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_ouSignatureLineId.clear(); +- m_bInSignatureLineId = true; ++ m_rParser.HandleIdAttr(xAttrs); + } +- else if (aName == "loext:SignatureLineValidImage") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_ouSignatureLineValidImage.clear(); +- m_bInSignatureLineValidImage = true; ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "SignedProperties") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "UnsignedProperties") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "loext:SignatureLineInvalidImage") ++}; ++ ++class XSecParser::DcDateContext ++ : public XSecParser::Context ++{ ++ private: ++ bool m_isIgnore = false; ++ ++ public: ++ DcDateContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_ouSignatureLineInvalidImage.clear(); +- m_bInSignatureLineInvalidImage = true; + } + +- if (m_xNextHandler.is()) ++ virtual void StartElement( ++ css::uno::Reference const& /*xAttrs*/) override + { +- m_xNextHandler->startElement(aName, xAttribs); ++ m_isIgnore = !m_rParser.m_ouDate.isEmpty(); + } +- } +- catch (css::uno::Exception& ) +- {//getCaughtException MUST be the first line in the catch block +- css::uno::Any exc = cppu::getCaughtException(); +- throw css::xml::sax::SAXException( +- "xmlsecurity: Exception in XSecParser::startElement", +- nullptr, exc); +- } +- catch (...) +- { +- throw css::xml::sax::SAXException( +- "xmlsecurity: unexpected exception in XSecParser::startElement", nullptr, +- css::uno::Any()); +- } +-} + +-void SAL_CALL XSecParser::endElement( const OUString& aName ) +-{ +- try +- { +- if (aName == "DigestValue" && !m_bInCertDigest) ++ virtual void EndElement() override + { +- m_bInDigestValue = false; ++ if (!m_isIgnore) ++ { ++ m_rParser.m_pXSecController->setDate( m_rParser.m_ouDate ); ++ } + } +- else if ( aName == "Reference" ) ++ ++ virtual void Characters(OUString const& rChars) override + { +- if ( m_bReferenceUnresolved ) +- /* +- * it must be an octet stream +- */ ++ if (!m_isIgnore) + { +- m_pXSecController->addStreamReference( m_currentReferenceURI, true, m_nReferenceDigestID ); +- m_bReferenceUnresolved = false; ++ m_rParser.m_ouDate += rChars; + } +- +- m_pXSecController->setDigestValue( m_nReferenceDigestID, m_ouDigestValue ); + } +- else if ( aName == "SignedInfo" ) ++}; ++ ++class XSecParser::DcDescriptionContext ++ : public XSecParser::Context ++{ ++ private: ++ OUString m_Value; ++ ++ public: ++ DcDescriptionContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->setReferenceCount(); + } +- else if ( aName == "SignatureValue" ) ++ ++ virtual void EndElement() override + { +- m_pXSecController->setSignatureValue( m_ouSignatureValue ); +- m_bInSignatureValue = false; ++ m_rParser.m_pXSecController->setDescription(m_Value); + } +- else if (aName == "X509IssuerName") ++ ++ virtual void Characters(OUString const& rChars) override + { +- m_pXSecController->setX509IssuerName( m_ouX509IssuerName ); +- m_bInX509IssuerName = false; ++ m_Value += rChars; + } +- else if (aName == "X509SerialNumber") ++}; ++ ++class XSecParser::DsSignaturePropertyContext ++ : public XSecParser::Context ++{ ++ public: ++ DsSignaturePropertyContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->setX509SerialNumber( m_ouX509SerialNumber ); +- m_bInX509SerialNumber = false; + } +- else if (aName == "X509Certificate") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_pXSecController->setX509Certificate( m_ouX509Certificate ); +- m_bInX509Certificate = false; ++ OUString const ouIdAttr(m_rParser.HandleIdAttr(xAttrs)); ++ if (!ouIdAttr.isEmpty()) ++ { ++ m_rParser.m_pXSecController->setPropertyId( ouIdAttr ); ++ } + } +- else if (aName == "PGPKeyID") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_pXSecController->setGpgKeyID( m_ouGpgKeyID ); +- m_bInGpgKeyID = false; ++ if (nNamespace == XML_NAMESPACE_DC && rName == "date") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DC && rName == "description") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "PGPKeyPacket") ++}; ++ ++class XSecParser::DsSignaturePropertiesContext ++ : public XSecParser::Context ++{ ++ public: ++ DsSignaturePropertiesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->setGpgCertificate( m_ouGpgCertificate ); +- m_bInGpgCertificate = false; + } +- else if (aName == "loext:PGPOwner") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_pXSecController->setGpgOwner( m_ouGpgOwner ); +- m_bInGpgOwner = false; ++ m_rParser.HandleIdAttr(xAttrs); + } +- else if (aName == "xd:CertDigest") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_pXSecController->setCertDigest( m_ouCertDigest ); +- m_bInCertDigest = false; ++ if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureProperty") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "xd:EncapsulatedX509Certificate" || aName == "xades:EncapsulatedX509Certificate") ++}; ++ ++class XSecParser::DsObjectContext ++ : public XSecParser::Context ++{ ++ public: ++ DsObjectContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->addEncapsulatedX509Certificate( m_ouEncapsulatedX509Certificate ); +- m_bInEncapsulatedX509Certificate = false; + } +- else if (aName == "xd:SigningTime" || aName == "xades:SigningTime") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_pXSecController->setDate( m_ouDate ); +- m_bInSigningTime = false; ++ m_rParser.HandleIdAttr(xAttrs); + } +- else if (aName == "dc:date") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- if (m_bInDate) ++ if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureProperties") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_XADES132 && rName == "QualifyingProperties") + { +- m_pXSecController->setDate( m_ouDate ); +- m_bInDate = false; ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); + } ++ // missing: ds:Manifest ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "dc:description") ++}; ++ ++class XSecParser::DsSignatureContext ++ : public XSecParser::Context ++{ ++ public: ++ DsSignatureContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->setDescription( m_ouDescription ); +- m_bInDescription = false; + } +- else if (aName == "loext:SignatureLineId") ++ ++ virtual void StartElement( ++ css::uno::Reference const& xAttrs) override + { +- m_pXSecController->setSignatureLineId( m_ouSignatureLineId ); +- m_bInSignatureLineId = false; ++ OUString const ouIdAttr(m_rParser.HandleIdAttr(xAttrs)); ++ m_rParser.m_rXMLSignatureHelper.StartVerifySignatureElement(); ++ m_rParser.m_pXSecController->addSignature(); ++ if (!ouIdAttr.isEmpty()) ++ { ++ m_rParser.m_pXSecController->setId( ouIdAttr ); ++ } + } +- else if (aName == "loext:SignatureLineValidImage") ++ ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_pXSecController->setValidSignatureImage( m_ouSignatureLineValidImage ); +- m_bInSignatureLineValidImage = false; ++ if (nNamespace == XML_NAMESPACE_DS && rName == "SignedInfo") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "SignatureValue") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "KeyInfo") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ if (nNamespace == XML_NAMESPACE_DS && rName == "Object") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- else if (aName == "loext:SignatureLineInvalidImage") ++}; ++ ++class XSecParser::DsigSignaturesContext ++ : public XSecParser::Context ++{ ++ public: ++ DsigSignaturesContext(XSecParser & rParser, ++ std::unique_ptr pOldNamespaceMap) ++ : XSecParser::Context(rParser, std::move(pOldNamespaceMap)) + { +- m_pXSecController->setInvalidSignatureImage( m_ouSignatureLineInvalidImage ); +- m_bInSignatureLineInvalidImage = false; + } + +- if (m_xNextHandler.is()) ++ virtual std::unique_ptr CreateChildContext( ++ std::unique_ptr pOldNamespaceMap, ++ sal_uInt16 const nNamespace, OUString const& rName) override + { +- m_xNextHandler->endElement(aName); ++ if (nNamespace == XML_NAMESPACE_DS && rName == "Signature") ++ { ++ return std::make_unique(m_rParser, std::move(pOldNamespaceMap)); ++ } ++ return XSecParser::Context::CreateChildContext(std::move(pOldNamespaceMap), nNamespace, rName); + } +- } +- catch (css::uno::Exception& ) +- {//getCaughtException MUST be the first line in the catch block +- css::uno::Any exc = cppu::getCaughtException(); +- throw css::xml::sax::SAXException( +- "xmlsecurity: Exception in XSecParser::endElement", +- nullptr, exc); +- } +- catch (...) +- { +- throw css::xml::sax::SAXException( +- "xmlsecurity: unexpected exception in XSecParser::endElement", nullptr, +- css::uno::Any()); +- } ++}; ++ ++ ++XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper, ++ XSecController* pXSecController) ++ : m_pNamespaceMap(new SvXMLNamespaceMap) ++ , m_pXSecController(pXSecController) ++ , m_rXMLSignatureHelper(rXMLSignatureHelper) ++{ ++ using namespace xmloff::token; ++ m_pNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML), XML_NAMESPACE_XML ); ++ m_pNamespaceMap->Add( "_dsig_ooo", GetXMLToken(XML_N_DSIG_OOO), XML_NAMESPACE_DSIG_OOO ); ++ m_pNamespaceMap->Add( "_dsig", GetXMLToken(XML_N_DSIG), XML_NAMESPACE_DSIG ); ++ m_pNamespaceMap->Add( "_ds", GetXMLToken(XML_N_DS), XML_NAMESPACE_DS ); ++ m_pNamespaceMap->Add( "_xades132", GetXMLToken(XML_N_XADES132), XML_NAMESPACE_XADES132); ++ m_pNamespaceMap->Add( "_xades141", GetXMLToken(XML_N_XADES141), XML_NAMESPACE_XADES141); ++ m_pNamespaceMap->Add( "_dc", GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); ++ m_pNamespaceMap->Add( "_office_libo", ++ GetXMLToken(XML_N_LO_EXT), XML_NAMESPACE_LO_EXT); + } + +-void SAL_CALL XSecParser::characters( const OUString& aChars ) ++OUString XSecParser::HandleIdAttr(css::uno::Reference const& xAttrs) + { +- if (m_bInX509IssuerName) +- { +- m_ouX509IssuerName += aChars; +- } +- else if (m_bInX509SerialNumber) +- { +- m_ouX509SerialNumber += aChars; +- } +- else if (m_bInX509Certificate) +- { +- m_ouX509Certificate += aChars; +- } +- else if (m_bInGpgCertificate) ++ OUString ouIdAttr = getIdAttr(xAttrs); ++ if (!ouIdAttr.isEmpty()) + { +- m_ouGpgCertificate += aChars; ++ m_pXSecController->collectToVerify( ouIdAttr ); + } +- else if (m_bInGpgKeyID) ++ return ouIdAttr; ++} ++ ++OUString XSecParser::getIdAttr(const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) ++{ ++ OUString ouIdAttr = xAttribs->getValueByName("id"); ++ ++ if (ouIdAttr.isEmpty()) + { +- m_ouGpgKeyID += aChars; ++ ouIdAttr = xAttribs->getValueByName("Id"); + } +- else if (m_bInGpgOwner) ++ ++ return ouIdAttr; ++} ++ ++/* ++ * XDocumentHandler ++ */ ++void SAL_CALL XSecParser::startDocument( ) ++{ ++ if (m_xNextHandler.is()) + { +- m_ouGpgOwner += aChars; ++ m_xNextHandler->startDocument(); + } +- else if (m_bInSignatureValue) ++} ++ ++void SAL_CALL XSecParser::endDocument( ) ++{ ++ if (m_xNextHandler.is()) + { +- m_ouSignatureValue += aChars; ++ m_xNextHandler->endDocument(); + } +- else if (m_bInDigestValue && !m_bInCertDigest) ++} ++ ++void SAL_CALL XSecParser::startElement( ++ const OUString& rName, ++ const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) ++{ ++ assert(m_pNamespaceMap); ++ std::unique_ptr pRewindMap( ++ SvXMLImport::processNSAttributes(m_pNamespaceMap, nullptr, xAttribs)); ++ ++ OUString localName; ++ sal_uInt16 const nPrefix(m_pNamespaceMap->GetKeyByAttrName(rName, &localName)); ++ ++ std::unique_ptr pContext; ++ ++ if (m_ContextStack.empty()) + { +- m_ouDigestValue += aChars; ++ if ((nPrefix == XML_NAMESPACE_DSIG || nPrefix == XML_NAMESPACE_DSIG_OOO) ++ && localName == "document-signatures") ++ { ++ pContext.reset(new DsigSignaturesContext(*this, std::move(pRewindMap))); ++ } ++ else ++ { ++ throw css::xml::sax::SAXException( ++ "xmlsecurity: unexpected root element", nullptr, ++ css::uno::Any()); ++ } + } +- else if (m_bInDate) ++ else + { +- m_ouDate += aChars; ++ pContext = m_ContextStack.top()->CreateChildContext( ++ std::move(pRewindMap), nPrefix, localName); + } +- else if (m_bInDescription) ++ ++ m_ContextStack.push(std::move(pContext)); ++ assert(!pRewindMap); ++ ++ try + { +- m_ouDescription += aChars; ++ m_ContextStack.top()->StartElement(xAttribs); ++ ++ if (m_xNextHandler.is()) ++ { ++ m_xNextHandler->startElement(rName, xAttribs); ++ } + } +- else if (m_bInCertDigest) +- { +- m_ouCertDigest += aChars; ++ catch (css::uno::Exception& ) ++ {//getCaughtException MUST be the first line in the catch block ++ css::uno::Any exc = cppu::getCaughtException(); ++ throw css::xml::sax::SAXException( ++ "xmlsecurity: Exception in XSecParser::startElement", ++ nullptr, exc); + } +- else if (m_bInEncapsulatedX509Certificate) ++ catch (...) + { +- m_ouEncapsulatedX509Certificate += aChars; ++ throw css::xml::sax::SAXException( ++ "xmlsecurity: unexpected exception in XSecParser::startElement", nullptr, ++ css::uno::Any()); + } +- else if (m_bInSigningTime) ++} ++ ++void SAL_CALL XSecParser::endElement(const OUString& rName) ++{ ++ assert(!m_ContextStack.empty()); // this should be checked by sax parser? ++ ++ try + { +- m_ouDate += aChars; ++ m_ContextStack.top()->EndElement(); ++ ++ if (m_xNextHandler.is()) ++ { ++ m_xNextHandler->endElement(rName); ++ } + } +- else if (m_bInSignatureLineId) +- { +- m_ouSignatureLineId += aChars; ++ catch (css::uno::Exception& ) ++ {//getCaughtException MUST be the first line in the catch block ++ css::uno::Any exc = cppu::getCaughtException(); ++ throw css::xml::sax::SAXException( ++ "xmlsecurity: Exception in XSecParser::endElement", ++ nullptr, exc); + } +- else if (m_bInSignatureLineValidImage) ++ catch (...) + { +- m_ouSignatureLineValidImage += aChars; ++ throw css::xml::sax::SAXException( ++ "xmlsecurity: unexpected exception in XSecParser::endElement", nullptr, ++ css::uno::Any()); + } +- else if (m_bInSignatureLineInvalidImage) ++ ++ if (m_ContextStack.top()->m_pOldNamespaceMap) + { +- m_ouSignatureLineInvalidImage += aChars; ++ m_pNamespaceMap = std::move(m_ContextStack.top()->m_pOldNamespaceMap); + } ++ m_ContextStack.pop(); ++} ++ ++void SAL_CALL XSecParser::characters(const OUString& rChars) ++{ ++ assert(!m_ContextStack.empty()); // this should be checked by sax parser? ++ m_ContextStack.top()->Characters(rChars); + + if (m_xNextHandler.is()) + { +- m_xNextHandler->characters(aChars); ++ m_xNextHandler->characters(rChars); + } + } + +diff --git a/xmlsecurity/source/helper/xsecparser.hxx b/xmlsecurity/source/helper/xsecparser.hxx +index d9b079aa3116..93efcb766e3e 100644 +--- a/xmlsecurity/source/helper/xsecparser.hxx ++++ b/xmlsecurity/source/helper/xsecparser.hxx +@@ -25,6 +25,10 @@ + + #include + ++#include ++ ++#include ++ + class XMLSignatureHelper; + class XSecController; + +@@ -48,47 +52,59 @@ class XSecParser: public cppu::WeakImplHelper + ******************************************************************************/ + { + friend class XSecController; ++public: ++ class Context; + private: ++ class UnknownContext; ++ class LoPGPOwnerContext; ++ class DsPGPKeyPacketContext; ++ class DsPGPKeyIDContext; ++ class DsPGPDataContext; ++ class DsX509CertificateContext; ++ class DsX509SerialNumberContext; ++ class DsX509IssuerNameContext; ++ class DsX509IssuerSerialContext; ++ class DsX509DataContext; ++ class DsKeyInfoContext; ++ class DsSignatureValueContext; ++ class DsDigestValueContext; ++ class DsDigestMethodContext; ++ class DsTransformContext; ++ class DsTransformsContext; ++ class DsReferenceContext; ++ class DsSignatureMethodContext; ++ class DsSignedInfoContext; ++ class XadesEncapsulatedX509CertificateContext; ++ class XadesCertificateValuesContext; ++ class XadesUnsignedSignaturePropertiesContext; ++ class XadesUnsignedPropertiesContext; ++ class LoSignatureLineIdContext; ++ class LoSignatureLineValidImageContext; ++ class LoSignatureLineInvalidImageContext; ++ class LoSignatureLineContext; ++ class XadesCertDigestContext; ++ class XadesCertContext; ++ class XadesSigningCertificateContext; ++ class XadesSigningTimeContext; ++ class XadesSignedSignaturePropertiesContext; ++ class XadesSignedPropertiesContext; ++ class XadesQualifyingPropertiesContext; ++ class DcDateContext; ++ class DcDescriptionContext; ++ class DsSignaturePropertyContext; ++ class DsSignaturePropertiesContext; ++ class DsObjectContext; ++ class DsSignatureContext; ++ class DsigSignaturesContext; ++ + /* + * the following members are used to reserve the signature information, + * including X509IssuerName, X509SerialNumber, and X509Certificate,etc. + */ +- OUString m_ouX509IssuerName; +- OUString m_ouX509SerialNumber; +- OUString m_ouX509Certificate; +- OUString m_ouGpgCertificate; +- OUString m_ouGpgKeyID; +- OUString m_ouGpgOwner; +- OUString m_ouCertDigest; +- OUString m_ouEncapsulatedX509Certificate; +- OUString m_ouDigestValue; +- OUString m_ouSignatureValue; + OUString m_ouDate; +- /// Characters of a element, as just read from XML. +- OUString m_ouDescription; +- OUString m_ouSignatureLineId; +- OUString m_ouSignatureLineValidImage; +- OUString m_ouSignatureLineInvalidImage; + +- /* +- * whether inside a particular element +- */ +- bool m_bInX509IssuerName; +- bool m_bInX509SerialNumber; +- bool m_bInX509Certificate; +- bool m_bInGpgCertificate; +- bool m_bInGpgKeyID; +- bool m_bInGpgOwner; +- bool m_bInCertDigest; +- bool m_bInEncapsulatedX509Certificate; +- bool m_bInSigningTime; +- bool m_bInDigestValue; +- bool m_bInSignatureValue; +- bool m_bInDate; +- bool m_bInDescription; +- bool m_bInSignatureLineId; +- bool m_bInSignatureLineValidImage; +- bool m_bInSignatureLineInvalidImage; ++ std::stack> m_ContextStack; ++ std::unique_ptr m_pNamespaceMap; + + /* + * the XSecController collaborating with XSecParser +@@ -101,22 +117,9 @@ private: + css::uno::Reference< + css::xml::sax::XDocumentHandler > m_xNextHandler; + +- /* +- * this string is used to remember the current handled reference's URI, +- * +- * because it can be decided whether a stream reference is xml based or binary based +- * only after the Transforms element is read in, so we have to reserve the reference's +- * URI when the startElement event is met. +- */ +- OUString m_currentReferenceURI; +- bool m_bReferenceUnresolved; +- +- // Relevant for ODF. The digest algorithm selected by the current DigestMethod element's +- // Algorithm attribute in the current Reference element. From css::xml::crypto::DigestID. +- sal_Int32 m_nReferenceDigestID; + XMLSignatureHelper& m_rXMLSignatureHelper; + +-private: ++ OUString HandleIdAttr(css::uno::Reference const& xAttrs); + static OUString getIdAttr(const css::uno::Reference< + css::xml::sax::XAttributeList >& xAttribs ); + +-- +cgit v1.2.1 + -- cgit v1.2.3