summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extensions/inc/abpilot.hrc12
-rw-r--r--extensions/inc/bibliography.hrc14
-rw-r--r--extensions/inc/dbpilots.hrc16
-rw-r--r--extensions/inc/propctrlr.hrc12
-rw-r--r--extensions/inc/update.hrc16
-rw-r--r--extensions/source/propctrlr/formgeometryhandler.cxx2
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.cxx2
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.hxx2
-rw-r--r--forms/source/component/Columns.hxx34
-rw-r--r--forms/source/helper/resettable.cxx2
-rw-r--r--forms/source/inc/resettable.hxx2
-rw-r--r--forms/source/inc/togglestate.hxx2
-rw-r--r--forms/source/misc/InterfaceContainer.cxx54
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.hrc26
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx856
15 files changed, 526 insertions, 526 deletions
diff --git a/extensions/inc/abpilot.hrc b/extensions/inc/abpilot.hrc
index 80dc3567c472..ad2c4b1115c2 100644
--- a/extensions/inc/abpilot.hrc
+++ b/extensions/inc/abpilot.hrc
@@ -23,12 +23,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
-#ifndef EXTENSIONS_ABPILOT_HRC
-#define EXTENSIONS_ABPILOT_HRC
-
-#include "extensio.hrc"
-
+
+#ifndef EXTENSIONS_ABPILOT_HRC
+#define EXTENSIONS_ABPILOT_HRC
+
+#include "extensio.hrc"
+
#define HID_ABSPILOT_PREVIOUS ( HID_ABP_START + 0)
#define HID_ABSPILOT_NEXT ( HID_ABP_START + 1)
#define HID_ABSPILOT_CANCEL ( HID_ABP_START + 2)
diff --git a/extensions/inc/bibliography.hrc b/extensions/inc/bibliography.hrc
index f66f63319c79..c67060e18edf 100644
--- a/extensions/inc/bibliography.hrc
+++ b/extensions/inc/bibliography.hrc
@@ -23,12 +23,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
-#ifndef EXTENSIONS_BIBLIOGRAPHY_HRC
-#define EXTENSIONS_BIBLIOGRAPHY_HRC
-
-#include "extensio.hrc"
-
+
+#ifndef EXTENSIONS_BIBLIOGRAPHY_HRC
+#define EXTENSIONS_BIBLIOGRAPHY_HRC
+
+#include "extensio.hrc"
+
#define HID_BIB_CHANGESOURCE ( HID_BIBLIO_START + 0)
#define HID_BIB_MAPPINGDLG ( HID_BIBLIO_START + 1)
#define HID_BIB_TBX_TABLE ( HID_BIBLIO_START + 2)
@@ -83,4 +83,4 @@
#error help id range overflow (BIBLIO)
#endif
-#endif // EXTENSIONS_BIBLIOGRAPHY_HRC
+#endif // EXTENSIONS_BIBLIOGRAPHY_HRC
diff --git a/extensions/inc/dbpilots.hrc b/extensions/inc/dbpilots.hrc
index 051ab4a049c6..46ee01805938 100644
--- a/extensions/inc/dbpilots.hrc
+++ b/extensions/inc/dbpilots.hrc
@@ -23,12 +23,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
-#ifndef EXTENSIONS_DBPILOT_HRC
-#define EXTENSIONS_DBPILOT_HRC
-
-#include "extensio.hrc"
-
+
+#ifndef EXTENSIONS_DBPILOT_HRC
+#define EXTENSIONS_DBPILOT_HRC
+
+#include "extensio.hrc"
+
#define HID_GHIDWIZARD_PREVIOUS ( HID_DBP_START + 0)
#define HID_GHIDWIZARD_NEXT ( HID_DBP_START + 1)
#define HID_GHIDWIZARD_CANCEL ( HID_DBP_START + 2)
@@ -51,5 +51,5 @@
#if HID_DBP_LAST > HID_DBP_END
#error help id range overflow (DBP)
#endif
-
-#endif // EXTENSIONS_DBPILOT_HRC
+
+#endif // EXTENSIONS_DBPILOT_HRC
diff --git a/extensions/inc/propctrlr.hrc b/extensions/inc/propctrlr.hrc
index f42e7c9653ec..6961319f4dda 100644
--- a/extensions/inc/propctrlr.hrc
+++ b/extensions/inc/propctrlr.hrc
@@ -23,12 +23,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
-#ifndef EXTENSIONS_PROPCTRLR_HRC
-#define EXTENSIONS_PROPCTRLR_HRC
-
-#include "extensio.hrc"
-
+
+#ifndef EXTENSIONS_PROPCTRLR_HRC
+#define EXTENSIONS_PROPCTRLR_HRC
+
+#include "extensio.hrc"
+
#define HID_PROP_INPUT_REQUIRED ( HID_PROPC_START + 0)
#define HID_PROP_GROUPBOX ( HID_PROPC_START + 1)
#define HID_PROP_CONTROLSOURCE ( HID_PROPC_START + 2)
diff --git a/extensions/inc/update.hrc b/extensions/inc/update.hrc
index c71ce0baf3c3..2cd1f8f69f12 100644
--- a/extensions/inc/update.hrc
+++ b/extensions/inc/update.hrc
@@ -23,12 +23,12 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
-#ifndef EXTENSIONS_UPDATE_HRC
-#define EXTENSIONS_UPDATE_HRC
-
-#include "extensio.hrc"
-
+
+#ifndef EXTENSIONS_UPDATE_HRC
+#define EXTENSIONS_UPDATE_HRC
+
+#include "extensio.hrc"
+
#define HID_CHECK_FOR_UPD_DLG ( HID_UPDATE_START + 0)
#define HID_CHECK_FOR_UPD_CLOSE ( HID_UPDATE_START + 1)
#define HID_CHECK_FOR_UPD_PAUSE ( HID_UPDATE_START + 2)
@@ -45,5 +45,5 @@
#if HID_UPDATE_LAST > HID_UPDATE_END
#error help id range overflow (UPDATE)
#endif
-
-#endif // EXTENSIONS_UPDATE_HRC
+
+#endif // EXTENSIONS_UPDATE_HRC
diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx
index ca01ce451f36..31a2b9315238 100644
--- a/extensions/source/propctrlr/formgeometryhandler.cxx
+++ b/extensions/source/propctrlr/formgeometryhandler.cxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
diff --git a/extensions/source/propctrlr/propertycontrolextender.cxx b/extensions/source/propctrlr/propertycontrolextender.cxx
index 616a6203bc1c..d06ab54e0a79 100644
--- a/extensions/source/propctrlr/propertycontrolextender.cxx
+++ b/extensions/source/propctrlr/propertycontrolextender.cxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
diff --git a/extensions/source/propctrlr/propertycontrolextender.hxx b/extensions/source/propctrlr/propertycontrolextender.hxx
index 29e4138a6c39..0e74284c6f9b 100644
--- a/extensions/source/propctrlr/propertycontrolextender.hxx
+++ b/extensions/source/propctrlr/propertycontrolextender.hxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
#ifndef EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
#define EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
diff --git a/forms/source/component/Columns.hxx b/forms/source/component/Columns.hxx
index 34f4fad58e5d..f52d8db1afa9 100644
--- a/forms/source/component/Columns.hxx
+++ b/forms/source/component/Columns.hxx
@@ -28,23 +28,23 @@
#ifndef _FRM_COLUMNS_HXX
#define _FRM_COLUMNS_HXX
-#include "cloneable.hxx"
-#include "frm_strings.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/io/XObjectInputStream.hpp>
-#include <com/sun/star/io/XObjectOutputStream.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-/** === end UNO includes === **/
-
-#include <comphelper/broadcasthelper.hxx>
-#include <comphelper/componentcontext.hxx>
-#include <comphelper/propagg.hxx>
-#include <comphelper/proparrhlp.hxx>
-#include <comphelper/uno3.hxx>
-#include <cppuhelper/compbase2.hxx>
-#include <cppuhelper/component.hxx>
+#include "cloneable.hxx"
+#include "frm_strings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/component.hxx>
using namespace comphelper;
diff --git a/forms/source/helper/resettable.cxx b/forms/source/helper/resettable.cxx
index c76a63c3d0f0..0210c0ead56c 100644
--- a/forms/source/helper/resettable.cxx
+++ b/forms/source/helper/resettable.cxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_forms.hxx"
diff --git a/forms/source/inc/resettable.hxx b/forms/source/inc/resettable.hxx
index 9d3f085ea1f9..1e743806fb23 100644
--- a/forms/source/inc/resettable.hxx
+++ b/forms/source/inc/resettable.hxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
#ifndef FORMS_RESETTABLE_HXX
#define FORMS_RESETTABLE_HXX
diff --git a/forms/source/inc/togglestate.hxx b/forms/source/inc/togglestate.hxx
index 291cc3ab71db..30efa6f14ed5 100644
--- a/forms/source/inc/togglestate.hxx
+++ b/forms/source/inc/togglestate.hxx
@@ -23,7 +23,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
#ifndef FORMS_TOGGLESTATE_HXX
#define FORMS_TOGGLESTATE_HXX
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index 2db62692a3ab..ab605dbb9324 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -28,33 +28,33 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_forms.hxx"
-#include "frm_resource.hrc"
-#include "frm_resource.hxx"
-#include "InterfaceContainer.hxx"
-#include "property.hrc"
-#include "services.hxx"
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/container/XNamed.hpp>
-#include <com/sun/star/io/WrongFormatException.hpp>
-#include <com/sun/star/io/XMarkableStream.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-
-#include <comphelper/container.hxx>
-#include <comphelper/enumhelper.hxx>
-#include <comphelper/eventattachermgr.hxx>
-#include <comphelper/property.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/types.hxx>
-#include <cppuhelper/exc_hlp.hxx>
-#include <cppuhelper/queryinterface.hxx>
-#include <rtl/logfile.hxx>
-#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
-
-#include <algorithm>
-#include <memory>
+#include "frm_resource.hrc"
+#include "frm_resource.hxx"
+#include "InterfaceContainer.hxx"
+#include "property.hrc"
+#include "services.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include <com/sun/star/io/XMarkableStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/eventattachermgr.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <rtl/logfile.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+#include <memory>
//.........................................................................
namespace frm
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.hrc b/xmlsecurity/source/dialogs/digitalsignaturesdialog.hrc
index 08343bfbb29f..d63b44834f2c 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.hrc
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.hrc
@@ -1,5 +1,5 @@
-/*************************************************************************
- *
+/*************************************************************************
+ *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
@@ -23,14 +23,14 @@
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
- ************************************************************************/
-
-#if ! defined INCLUDED_DIGITALSIGNATURESDIALOG_HRC
-#define INCLUDED_DIGITALSIGNATURESDIALOG_HRC
-
-//global.hrc in xmlsecurity/inc starts at 1000
-#define RID_DIGITALSIGNATUREDLG_START 2000
-
-#define RID_XMLSECDLG_OLD_ODF_FORMAT RID_DIGITALSIGNATUREDLG_START
-#define MSG_XMLSECDLG_QUERY_REMOVEDOCSIGNBEFORESIGN (RID_DIGITALSIGNATUREDLG_START + 1)
-#endif
+ ************************************************************************/
+
+#if ! defined INCLUDED_DIGITALSIGNATURESDIALOG_HRC
+#define INCLUDED_DIGITALSIGNATURESDIALOG_HRC
+
+//global.hrc in xmlsecurity/inc starts at 1000
+#define RID_DIGITALSIGNATUREDLG_START 2000
+
+#define RID_XMLSECDLG_OLD_ODF_FORMAT RID_DIGITALSIGNATUREDLG_START
+#define MSG_XMLSECDLG_QUERY_REMOVEDOCSIGNBEFORESIGN (RID_DIGITALSIGNATUREDLG_START + 1)
+#endif
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index d699787ba451..d0fba345588c 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -1,5 +1,5 @@
-/*************************************************************************
- *
+/*************************************************************************
+ *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
@@ -23,380 +23,380 @@
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_xmlsecurity.hxx"
-
-#include <xmlsecurity/documentsignaturehelper.hxx>
-
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/embed/XStorage.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include "com/sun/star/beans/XPropertySet.hpp"
-
-#include "comphelper/documentconstants.hxx"
-#include <tools/debug.hxx>
-#include "rtl/uri.hxx"
-
-using namespace ::com::sun::star::uno;
-//using namespace ::com::sun::star;
-namespace css = ::com::sun::star;
-using rtl::OUString;
-
-
-namespace
-{
-::rtl::OUString getElement(::rtl::OUString const & version, ::sal_Int32 * index)
-{
- while (*index < version.getLength() && version[*index] == '0') {
- ++*index;
- }
- return version.getToken(0, '.', *index);
-}
-
-
-
-// Return 1 if version1 is greater then version 2, 0 if they are equal
-//and -1 if version1 is less version 2
-int compareVersions(
- ::rtl::OUString const & version1, ::rtl::OUString const & version2)
-{
- for (::sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0;) {
- ::rtl::OUString e1(getElement(version1, &i1));
- ::rtl::OUString e2(getElement(version2, &i2));
- if (e1.getLength() < e2.getLength()) {
- return -1;
- } else if (e1.getLength() > e2.getLength()) {
- return 1;
- } else if (e1 < e2) {
- return -1;
- } else if (e1 > e2) {
- return 1;
- }
- }
- return 0;
-}
-}
-//If the OOo 3.0 mode is used then we exclude
-//'mimetype' and all content of 'META-INF'.
-//If the argument 'bSigning' is true then the element list is created for a signing
-//operation in which case we use the latest signing algorithm. That is all elements
-//we find in the zip storage are added to the list. We do not support the old signatures
-//which did not contain all files.
-//If 'bSigning' is false, then we validate. If the user enabled validating according to OOo 3.0
-//then mimetype and all content of META-INF must be excluded.
-void ImplFillElementList(
- std::vector< rtl::OUString >& rList, const Reference < css::embed::XStorage >& rxStore,
- const ::rtl::OUString rRootStorageName, const bool bRecursive,
- const DocumentSignatureAlgorithm mode)
-{
- ::rtl::OUString aMetaInfName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
- ::rtl::OUString sMimeTypeName (RTL_CONSTASCII_USTRINGPARAM("mimetype"));
- ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
-
- Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
- Sequence< ::rtl::OUString > aElements = xElements->getElementNames();
- sal_Int32 nElements = aElements.getLength();
- const ::rtl::OUString* pNames = aElements.getConstArray();
-
- for ( sal_Int32 n = 0; n < nElements; n++ )
- {
- if (mode != OOo3_2Document
- && (pNames[n] == aMetaInfName
- || pNames[n] == sMimeTypeName))
- {
- continue;
- }
- else
- {
- ::rtl::OUString sEncName = ::rtl::Uri::encode(
- pNames[n], rtl_UriCharClassRelSegment,
- rtl_UriEncodeStrict, RTL_TEXTENCODING_UTF8);
- if (sEncName.getLength() == 0 && pNames[n].getLength() != 0)
- throw css::uno::Exception(::rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("Failed to encode element name of XStorage")), 0);
-
- if ( rxStore->isStreamElement( pNames[n] ) )
- {
- //Exclude documentsignatures.xml!
- if (pNames[n].equals(
- DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName()))
- continue;
- ::rtl::OUString aFullName( rRootStorageName + sEncName );
- rList.push_back(aFullName);
- }
- else if ( bRecursive && rxStore->isStorageElement( pNames[n] ) )
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
- rtl::OUString aFullRootName( rRootStorageName + sEncName + aSep );
- ImplFillElementList(rList, xSubStore, aFullRootName, bRecursive, mode);
- }
- }
- }
-}
-
-
-bool DocumentSignatureHelper::isODFPre_1_2(const ::rtl::OUString & sVersion)
-{
- //The property version exists only if the document is at least version 1.2
- //That is, if the document has version 1.1 and sVersion is empty.
- //The constant is defined in comphelper/documentconstants.hxx
- if (compareVersions(sVersion, ODFVER_012_TEXT) == -1)
- return true;
- return false;
-}
-
-bool DocumentSignatureHelper::isOOo3_2_Signature(const SignatureInformation & sigInfo)
-{
- ::rtl::OUString sManifestURI(RTL_CONSTASCII_USTRINGPARAM("META-INF/manifest.xml"));
- bool bOOo3_2 = false;
- typedef ::std::vector< SignatureReferenceInformation >::const_iterator CIT;
- for (CIT i = sigInfo.vSignatureReferenceInfors.begin();
- i < sigInfo.vSignatureReferenceInfors.end(); i++)
- {
- if (i->ouURI.equals(sManifestURI))
- {
- bOOo3_2 = true;
- break;
- }
- }
- return bOOo3_2;
-}
-
-DocumentSignatureAlgorithm
-DocumentSignatureHelper::getDocumentAlgorithm(
- const ::rtl::OUString & sODFVersion, const SignatureInformation & sigInfo)
-{
- OSL_ASSERT(sODFVersion.getLength());
- DocumentSignatureAlgorithm mode = OOo3_2Document;
- if (!isOOo3_2_Signature(sigInfo))
- {
- if (isODFPre_1_2(sODFVersion))
- mode = OOo2Document;
- else
- mode = OOo3_0Document;
- }
- return mode;
-}
-
-//The function creates a list of files which are to be signed or for which
-//the signature is to be validated. The strings are UTF8 encoded URIs which
-//contain '/' as path separators.
-//
-//The algorithm how document signatures are created and validated has
-//changed over time. The change affects only which files within the document
-//are changed. Document signatures created by OOo 2.x only used particular files. Since
-//OOo 3.0 everything except "mimetype" and "META-INF" are signed. As of OOo 3.2 everything
-//except META-INF/documentsignatures.xml is signed.
-//Signatures are validated according to the algorithm which was then used for validation.
-//That is, when validating a signature which was created by OOo 3.0, then mimetype and
-//META-INF are not used.
-//
-//When a signature is created then we always use the latest algorithm. That is, we use
-//that of OOo 3.2
-std::vector< rtl::OUString >
-DocumentSignatureHelper::CreateElementList(
- const Reference < css::embed::XStorage >& rxStore,
- const ::rtl::OUString /*rRootStorageName*/, DocumentSignatureMode eMode,
- const DocumentSignatureAlgorithm mode)
-{
- std::vector< rtl::OUString > aElements;
- ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
-
- switch ( eMode )
- {
- case SignatureModeDocumentContent:
- {
- if (mode == OOo2Document) //that is, ODF 1.0, 1.1
- {
- // 1) Main content
- ImplFillElementList(aElements, rxStore, ::rtl::OUString(), false, mode);
-
- // 2) Pictures...
- rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Pictures" ) );
- try
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
- }
- catch(css::io::IOException& )
- {
- ; // Doesn't have to exist...
- }
- // 3) OLE....
- aSubStorageName = rtl::OUString::createFromAscii( "ObjectReplacements" );
- try
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
- xSubStore.clear();
-
- // Object folders...
- rtl::OUString aMatchStr( rtl::OUString::createFromAscii( "Object " ) );
- Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
- Sequence< ::rtl::OUString > aElementNames = xElements->getElementNames();
- sal_Int32 nElements = aElementNames.getLength();
- const ::rtl::OUString* pNames = aElementNames.getConstArray();
- for ( sal_Int32 n = 0; n < nElements; n++ )
- {
- if ( ( pNames[n].match( aMatchStr ) ) && rxStore->isStorageElement( pNames[n] ) )
- {
- Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xTmpSubStore, pNames[n]+aSep, true, mode);
- }
- }
- }
- catch( com::sun::star::io::IOException& )
- {
- ; // Doesn't have to exist...
- }
- }
- else
- {
- // Everything except META-INF
- ImplFillElementList(aElements, rxStore, ::rtl::OUString(), true, mode);
- }
- }
- break;
- case SignatureModeMacros:
- {
- // 1) Macros
- rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Basic" ) );
- try
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
- }
- catch( com::sun::star::io::IOException& )
- {
- ; // Doesn't have to exist...
- }
-
- // 2) Dialogs
- aSubStorageName = rtl::OUString::createFromAscii( "Dialogs") ;
- try
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
- }
- catch( com::sun::star::io::IOException& )
- {
- ; // Doesn't have to exist...
- }
- // 3) Scripts
- aSubStorageName = rtl::OUString::createFromAscii( "Scripts") ;
- try
- {
- Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
- ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
- }
- catch( css::io::IOException& )
- {
- ; // Doesn't have to exist...
- }
- }
- break;
- case SignatureModePackage:
- {
- // Everything except META-INF
- ImplFillElementList(aElements, rxStore, ::rtl::OUString(), true, mode);
- }
- break;
- }
-
- return aElements;
-}
-
-SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
- const Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode )
-{
- sal_Int32 nSubStorageOpenMode = css::embed::ElementModes::READ;
- if ( nOpenMode & css::embed::ElementModes::WRITE )
- nSubStorageOpenMode = css::embed::ElementModes::WRITE;
-
- SignatureStreamHelper aHelper;
-
- try
- {
- ::rtl::OUString aSIGStoreName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
- aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
- if ( aHelper.xSignatureStorage.is() )
- {
- ::rtl::OUString aSIGStreamName;
- if ( eDocSigMode == SignatureModeDocumentContent )
- aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName();
- else if ( eDocSigMode == SignatureModeMacros )
- aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName();
- else
- aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName();
-
- aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
- }
- }
- catch(css::io::IOException& )
- {
- // Doesn't have to exist...
- DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." );
- }
-
- return aHelper;
-}
-
-//sElementList contains all files which are expected to be signed. Only those files must me signed,
-//no more, no less.
-//The DocumentSignatureAlgorithm indicates if the document was created with OOo 2.x. Then
-//the uri s in the Reference elements in the signature, were not properly encoded.
-// For example: <Reference URI="ObjectReplacements/Object 1">
-bool DocumentSignatureHelper::checkIfAllFilesAreSigned(
- const ::std::vector< ::rtl::OUString > & sElementList,
- const SignatureInformation & sigInfo,
- const DocumentSignatureAlgorithm alg)
-{
- // Can only be valid if ALL streams are signed, which means real stream count == signed stream count
- unsigned int nRealCount = 0;
- for ( int i = sigInfo.vSignatureReferenceInfors.size(); i; )
- {
- const SignatureReferenceInformation& rInf = sigInfo.vSignatureReferenceInfors[--i];
- // There is also an extra entry of type TYPE_SAMEDOCUMENT_REFERENCE because of signature date.
- if ( ( rInf.nType == TYPE_BINARYSTREAM_REFERENCE ) || ( rInf.nType == TYPE_XMLSTREAM_REFERENCE ) )
- {
- ::rtl::OUString sReferenceURI = rInf.ouURI;
- if (alg == OOo2Document)
- {
- //Comparing URIs is a difficult. Therefore we kind of normalize
- //it before comparing. We assume that our URI do not have a leading "./"
- //and fragments at the end (...#...)
- sReferenceURI = ::rtl::Uri::encode(
- sReferenceURI, rtl_UriCharClassPchar,
- rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
- }
-
- //find the file in the element list
- typedef ::std::vector< ::rtl::OUString >::const_iterator CIT;
- for (CIT aIter = sElementList.begin(); aIter < sElementList.end(); aIter++)
- {
- ::rtl::OUString sElementListURI = *aIter;
- if (alg == OOo2Document)
- {
- sElementListURI =
- ::rtl::Uri::encode(
- sElementListURI, rtl_UriCharClassPchar,
- rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
- }
- if (sElementListURI.equals(sReferenceURI))
- {
- nRealCount++;
- break;
- }
- }
- }
- }
- return sElementList.size() == nRealCount;
-}
-
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmlsecurity.hxx"
+
+#include <xmlsecurity/documentsignaturehelper.hxx>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include "com/sun/star/beans/XPropertySet.hpp"
+
+#include "comphelper/documentconstants.hxx"
+#include <tools/debug.hxx>
+#include "rtl/uri.hxx"
+
+using namespace ::com::sun::star::uno;
+//using namespace ::com::sun::star;
+namespace css = ::com::sun::star;
+using rtl::OUString;
+
+
+namespace
+{
+::rtl::OUString getElement(::rtl::OUString const & version, ::sal_Int32 * index)
+{
+ while (*index < version.getLength() && version[*index] == '0') {
+ ++*index;
+ }
+ return version.getToken(0, '.', *index);
+}
+
+
+
+// Return 1 if version1 is greater then version 2, 0 if they are equal
+//and -1 if version1 is less version 2
+int compareVersions(
+ ::rtl::OUString const & version1, ::rtl::OUString const & version2)
+{
+ for (::sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0;) {
+ ::rtl::OUString e1(getElement(version1, &i1));
+ ::rtl::OUString e2(getElement(version2, &i2));
+ if (e1.getLength() < e2.getLength()) {
+ return -1;
+ } else if (e1.getLength() > e2.getLength()) {
+ return 1;
+ } else if (e1 < e2) {
+ return -1;
+ } else if (e1 > e2) {
+ return 1;
+ }
+ }
+ return 0;
+}
+}
+//If the OOo 3.0 mode is used then we exclude
+//'mimetype' and all content of 'META-INF'.
+//If the argument 'bSigning' is true then the element list is created for a signing
+//operation in which case we use the latest signing algorithm. That is all elements
+//we find in the zip storage are added to the list. We do not support the old signatures
+//which did not contain all files.
+//If 'bSigning' is false, then we validate. If the user enabled validating according to OOo 3.0
+//then mimetype and all content of META-INF must be excluded.
+void ImplFillElementList(
+ std::vector< rtl::OUString >& rList, const Reference < css::embed::XStorage >& rxStore,
+ const ::rtl::OUString rRootStorageName, const bool bRecursive,
+ const DocumentSignatureAlgorithm mode)
+{
+ ::rtl::OUString aMetaInfName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
+ ::rtl::OUString sMimeTypeName (RTL_CONSTASCII_USTRINGPARAM("mimetype"));
+ ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+
+ Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
+ Sequence< ::rtl::OUString > aElements = xElements->getElementNames();
+ sal_Int32 nElements = aElements.getLength();
+ const ::rtl::OUString* pNames = aElements.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nElements; n++ )
+ {
+ if (mode != OOo3_2Document
+ && (pNames[n] == aMetaInfName
+ || pNames[n] == sMimeTypeName))
+ {
+ continue;
+ }
+ else
+ {
+ ::rtl::OUString sEncName = ::rtl::Uri::encode(
+ pNames[n], rtl_UriCharClassRelSegment,
+ rtl_UriEncodeStrict, RTL_TEXTENCODING_UTF8);
+ if (sEncName.getLength() == 0 && pNames[n].getLength() != 0)
+ throw css::uno::Exception(::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Failed to encode element name of XStorage")), 0);
+
+ if ( rxStore->isStreamElement( pNames[n] ) )
+ {
+ //Exclude documentsignatures.xml!
+ if (pNames[n].equals(
+ DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName()))
+ continue;
+ ::rtl::OUString aFullName( rRootStorageName + sEncName );
+ rList.push_back(aFullName);
+ }
+ else if ( bRecursive && rxStore->isStorageElement( pNames[n] ) )
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
+ rtl::OUString aFullRootName( rRootStorageName + sEncName + aSep );
+ ImplFillElementList(rList, xSubStore, aFullRootName, bRecursive, mode);
+ }
+ }
+ }
+}
+
+
+bool DocumentSignatureHelper::isODFPre_1_2(const ::rtl::OUString & sVersion)
+{
+ //The property version exists only if the document is at least version 1.2
+ //That is, if the document has version 1.1 and sVersion is empty.
+ //The constant is defined in comphelper/documentconstants.hxx
+ if (compareVersions(sVersion, ODFVER_012_TEXT) == -1)
+ return true;
+ return false;
+}
+
+bool DocumentSignatureHelper::isOOo3_2_Signature(const SignatureInformation & sigInfo)
+{
+ ::rtl::OUString sManifestURI(RTL_CONSTASCII_USTRINGPARAM("META-INF/manifest.xml"));
+ bool bOOo3_2 = false;
+ typedef ::std::vector< SignatureReferenceInformation >::const_iterator CIT;
+ for (CIT i = sigInfo.vSignatureReferenceInfors.begin();
+ i < sigInfo.vSignatureReferenceInfors.end(); i++)
+ {
+ if (i->ouURI.equals(sManifestURI))
+ {
+ bOOo3_2 = true;
+ break;
+ }
+ }
+ return bOOo3_2;
+}
+
+DocumentSignatureAlgorithm
+DocumentSignatureHelper::getDocumentAlgorithm(
+ const ::rtl::OUString & sODFVersion, const SignatureInformation & sigInfo)
+{
+ OSL_ASSERT(sODFVersion.getLength());
+ DocumentSignatureAlgorithm mode = OOo3_2Document;
+ if (!isOOo3_2_Signature(sigInfo))
+ {
+ if (isODFPre_1_2(sODFVersion))
+ mode = OOo2Document;
+ else
+ mode = OOo3_0Document;
+ }
+ return mode;
+}
+
+//The function creates a list of files which are to be signed or for which
+//the signature is to be validated. The strings are UTF8 encoded URIs which
+//contain '/' as path separators.
+//
+//The algorithm how document signatures are created and validated has
+//changed over time. The change affects only which files within the document
+//are changed. Document signatures created by OOo 2.x only used particular files. Since
+//OOo 3.0 everything except "mimetype" and "META-INF" are signed. As of OOo 3.2 everything
+//except META-INF/documentsignatures.xml is signed.
+//Signatures are validated according to the algorithm which was then used for validation.
+//That is, when validating a signature which was created by OOo 3.0, then mimetype and
+//META-INF are not used.
+//
+//When a signature is created then we always use the latest algorithm. That is, we use
+//that of OOo 3.2
+std::vector< rtl::OUString >
+DocumentSignatureHelper::CreateElementList(
+ const Reference < css::embed::XStorage >& rxStore,
+ const ::rtl::OUString /*rRootStorageName*/, DocumentSignatureMode eMode,
+ const DocumentSignatureAlgorithm mode)
+{
+ std::vector< rtl::OUString > aElements;
+ ::rtl::OUString aSep( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+
+ switch ( eMode )
+ {
+ case SignatureModeDocumentContent:
+ {
+ if (mode == OOo2Document) //that is, ODF 1.0, 1.1
+ {
+ // 1) Main content
+ ImplFillElementList(aElements, rxStore, ::rtl::OUString(), false, mode);
+
+ // 2) Pictures...
+ rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Pictures" ) );
+ try
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
+ }
+ catch(css::io::IOException& )
+ {
+ ; // Doesn't have to exist...
+ }
+ // 3) OLE....
+ aSubStorageName = rtl::OUString::createFromAscii( "ObjectReplacements" );
+ try
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
+ xSubStore.clear();
+
+ // Object folders...
+ rtl::OUString aMatchStr( rtl::OUString::createFromAscii( "Object " ) );
+ Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
+ Sequence< ::rtl::OUString > aElementNames = xElements->getElementNames();
+ sal_Int32 nElements = aElementNames.getLength();
+ const ::rtl::OUString* pNames = aElementNames.getConstArray();
+ for ( sal_Int32 n = 0; n < nElements; n++ )
+ {
+ if ( ( pNames[n].match( aMatchStr ) ) && rxStore->isStorageElement( pNames[n] ) )
+ {
+ Reference < css::embed::XStorage > xTmpSubStore = rxStore->openStorageElement( pNames[n], css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xTmpSubStore, pNames[n]+aSep, true, mode);
+ }
+ }
+ }
+ catch( com::sun::star::io::IOException& )
+ {
+ ; // Doesn't have to exist...
+ }
+ }
+ else
+ {
+ // Everything except META-INF
+ ImplFillElementList(aElements, rxStore, ::rtl::OUString(), true, mode);
+ }
+ }
+ break;
+ case SignatureModeMacros:
+ {
+ // 1) Macros
+ rtl::OUString aSubStorageName( rtl::OUString::createFromAscii( "Basic" ) );
+ try
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
+ }
+ catch( com::sun::star::io::IOException& )
+ {
+ ; // Doesn't have to exist...
+ }
+
+ // 2) Dialogs
+ aSubStorageName = rtl::OUString::createFromAscii( "Dialogs") ;
+ try
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
+ }
+ catch( com::sun::star::io::IOException& )
+ {
+ ; // Doesn't have to exist...
+ }
+ // 3) Scripts
+ aSubStorageName = rtl::OUString::createFromAscii( "Scripts") ;
+ try
+ {
+ Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ );
+ ImplFillElementList(aElements, xSubStore, aSubStorageName+aSep, true, mode);
+ }
+ catch( css::io::IOException& )
+ {
+ ; // Doesn't have to exist...
+ }
+ }
+ break;
+ case SignatureModePackage:
+ {
+ // Everything except META-INF
+ ImplFillElementList(aElements, rxStore, ::rtl::OUString(), true, mode);
+ }
+ break;
+ }
+
+ return aElements;
+}
+
+SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
+ const Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, DocumentSignatureMode eDocSigMode )
+{
+ sal_Int32 nSubStorageOpenMode = css::embed::ElementModes::READ;
+ if ( nOpenMode & css::embed::ElementModes::WRITE )
+ nSubStorageOpenMode = css::embed::ElementModes::WRITE;
+
+ SignatureStreamHelper aHelper;
+
+ try
+ {
+ ::rtl::OUString aSIGStoreName( RTL_CONSTASCII_USTRINGPARAM( "META-INF" ) );
+ aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
+ if ( aHelper.xSignatureStorage.is() )
+ {
+ ::rtl::OUString aSIGStreamName;
+ if ( eDocSigMode == SignatureModeDocumentContent )
+ aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName();
+ else if ( eDocSigMode == SignatureModeMacros )
+ aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName();
+ else
+ aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName();
+
+ aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
+ }
+ }
+ catch(css::io::IOException& )
+ {
+ // Doesn't have to exist...
+ DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." );
+ }
+
+ return aHelper;
+}
+
+//sElementList contains all files which are expected to be signed. Only those files must me signed,
+//no more, no less.
+//The DocumentSignatureAlgorithm indicates if the document was created with OOo 2.x. Then
+//the uri s in the Reference elements in the signature, were not properly encoded.
+// For example: <Reference URI="ObjectReplacements/Object 1">
+bool DocumentSignatureHelper::checkIfAllFilesAreSigned(
+ const ::std::vector< ::rtl::OUString > & sElementList,
+ const SignatureInformation & sigInfo,
+ const DocumentSignatureAlgorithm alg)
+{
+ // Can only be valid if ALL streams are signed, which means real stream count == signed stream count
+ unsigned int nRealCount = 0;
+ for ( int i = sigInfo.vSignatureReferenceInfors.size(); i; )
+ {
+ const SignatureReferenceInformation& rInf = sigInfo.vSignatureReferenceInfors[--i];
+ // There is also an extra entry of type TYPE_SAMEDOCUMENT_REFERENCE because of signature date.
+ if ( ( rInf.nType == TYPE_BINARYSTREAM_REFERENCE ) || ( rInf.nType == TYPE_XMLSTREAM_REFERENCE ) )
+ {
+ ::rtl::OUString sReferenceURI = rInf.ouURI;
+ if (alg == OOo2Document)
+ {
+ //Comparing URIs is a difficult. Therefore we kind of normalize
+ //it before comparing. We assume that our URI do not have a leading "./"
+ //and fragments at the end (...#...)
+ sReferenceURI = ::rtl::Uri::encode(
+ sReferenceURI, rtl_UriCharClassPchar,
+ rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
+ }
+
+ //find the file in the element list
+ typedef ::std::vector< ::rtl::OUString >::const_iterator CIT;
+ for (CIT aIter = sElementList.begin(); aIter < sElementList.end(); aIter++)
+ {
+ ::rtl::OUString sElementListURI = *aIter;
+ if (alg == OOo2Document)
+ {
+ sElementListURI =
+ ::rtl::Uri::encode(
+ sElementListURI, rtl_UriCharClassPchar,
+ rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8);
+ }
+ if (sElementListURI.equals(sReferenceURI))
+ {
+ nRealCount++;
+ break;
+ }
+ }
+ }
+ }
+ return sElementList.size() == nRealCount;
+}
+
/*Compares the Uri which are obtained from CreateElementList with
the path obtained from the manifest.xml.
Returns true if both strings are equal.
@@ -405,58 +405,58 @@ bool DocumentSignatureHelper::equalsReferenceUriManifestPath(
const OUString & rUri, const OUString & rPath)
{
bool retVal = false;
- //split up the uri and path into segments. Both are separated by '/'
- std::vector<OUString> vUriSegments;
- sal_Int32 nIndex = 0;
- do
- {
- OUString aToken = rUri.getToken( 0, '/', nIndex );
- vUriSegments.push_back(aToken);
- }
- while (nIndex >= 0);
-
- std::vector<OUString> vPathSegments;
- nIndex = 0;
- do
- {
- OUString aToken = rPath.getToken( 0, '/', nIndex );
- vPathSegments.push_back(aToken);
- }
- while (nIndex >= 0);
-
- //Now compare each segment of the uri with its counterpart from the path
- if (vUriSegments.size() == vPathSegments.size())
- {
- retVal = true;
- typedef std::vector<OUString>::const_iterator CIT;
- for (CIT i = vUriSegments.begin(), j = vPathSegments.begin();
- i != vUriSegments.end(); i++, j++)
- {
- //Decode the uri segment, so that %20 becomes ' ', etc.
- OUString sDecUri = ::rtl::Uri::decode(
- *i, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
- if (!sDecUri.equals(*j))
- {
- retVal = false;
- break;
- }
- }
- }
+ //split up the uri and path into segments. Both are separated by '/'
+ std::vector<OUString> vUriSegments;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ OUString aToken = rUri.getToken( 0, '/', nIndex );
+ vUriSegments.push_back(aToken);
+ }
+ while (nIndex >= 0);
+
+ std::vector<OUString> vPathSegments;
+ nIndex = 0;
+ do
+ {
+ OUString aToken = rPath.getToken( 0, '/', nIndex );
+ vPathSegments.push_back(aToken);
+ }
+ while (nIndex >= 0);
+
+ //Now compare each segment of the uri with its counterpart from the path
+ if (vUriSegments.size() == vPathSegments.size())
+ {
+ retVal = true;
+ typedef std::vector<OUString>::const_iterator CIT;
+ for (CIT i = vUriSegments.begin(), j = vPathSegments.begin();
+ i != vUriSegments.end(); i++, j++)
+ {
+ //Decode the uri segment, so that %20 becomes ' ', etc.
+ OUString sDecUri = ::rtl::Uri::decode(
+ *i, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
+ if (!sDecUri.equals(*j))
+ {
+ retVal = false;
+ break;
+ }
+ }
+ }
return retVal;
}
-
-::rtl::OUString DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName()
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "documentsignatures.xml" ) );
-}
-
-::rtl::OUString DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName()
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "macrosignatures.xml" ) );
-}
-
-::rtl::OUString DocumentSignatureHelper::GetPackageSignatureDefaultStreamName()
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "packagesignatures.xml" ) );
-}
+
+::rtl::OUString DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "documentsignatures.xml" ) );
+}
+
+::rtl::OUString DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "macrosignatures.xml" ) );
+}
+
+::rtl::OUString DocumentSignatureHelper::GetPackageSignatureDefaultStreamName()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "packagesignatures.xml" ) );
+}