summaryrefslogtreecommitdiff
path: root/comphelper/inc/comphelper/docpasswordhelper.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/inc/comphelper/docpasswordhelper.hxx')
-rw-r--r--comphelper/inc/comphelper/docpasswordhelper.hxx111
1 files changed, 111 insertions, 0 deletions
diff --git a/comphelper/inc/comphelper/docpasswordhelper.hxx b/comphelper/inc/comphelper/docpasswordhelper.hxx
index 0a60c4b53ce9..dbbb68372a07 100644
--- a/comphelper/inc/comphelper/docpasswordhelper.hxx
+++ b/comphelper/inc/comphelper/docpasswordhelper.hxx
@@ -33,6 +33,7 @@
#include "comphelper/docpasswordrequest.hxx"
namespace com { namespace sun { namespace star { namespace task { class XInteractionHandler; } } } }
+namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }
namespace comphelper {
@@ -84,6 +85,116 @@ class COMPHELPER_DLLPUBLIC DocPasswordHelper
public:
// ------------------------------------------------------------------------
+ /** This helper function generates the information related
+ to "Password to modify" provided by user. The result
+ sequence contains the hash and the algorithm-related
+ info.
+
+ @param aString
+ The string for which the info should be generated
+
+ @return
+ The sequence containing the hash and the algorithm-related info
+ */
+
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ GenerateNewModifyPasswordInfo( const ::rtl::OUString& aPassword );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function allows to check whether
+ the "Password to modify" provided by user is the correct one.
+
+ @param aString
+ The string containing the provided password
+
+ @param aInfo
+ The sequence containing the hash and the algorithm-info
+
+ @return
+ <TRUE/> if the password is correct one
+ <FALSE/> otherwise
+ */
+
+ static sal_Bool IsModifyPasswordCorrect(
+ const ::rtl::OUString& aPassword,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aInfo );
+
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" feature of Word.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @return
+ The hash represented by sal_uInt32
+ */
+
+ static sal_uInt32 GetWordHashAsUINT32(
+ const ::rtl::OUString& aString );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" feature of Word.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @return
+ The hash represented by sequence of bytes in BigEndian form
+ */
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > GetWordHashAsSequence(
+ const ::rtl::OUString& aString );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" and passwords related to
+ table protection of Excel.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @param nEnc
+ The encoding that should be used to generate the 8-bit string
+ before the hash is generated
+
+ @return
+ The hash represented by sal_uInt16
+ */
+
+ static sal_uInt16 GetXLHashAsUINT16(
+ const ::rtl::OUString& aString,
+ rtl_TextEncoding nEnc = RTL_TEXTENCODING_UTF8 );
+
+ // ------------------------------------------------------------------------
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" and passwords related to
+ table protection.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @param nEnc
+ The encoding that should be used to generate the 8-bit string
+ before the hash is generated
+
+ @return
+ The hash represented by sequence of bytes in BigEndian form
+ */
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > GetXLHashAsSequence(
+ const ::rtl::OUString& aString,
+ rtl_TextEncoding nEnc = RTL_TEXTENCODING_UTF8 );
+
+ // ------------------------------------------------------------------------
+
/** This helper function tries to request and verify a password to load a
protected document.