diff options
author | Noel Grandin <noel@peralex.com> | 2015-04-13 13:21:04 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-04-15 11:35:03 +0000 |
commit | d208cf834f4f191558ae27ea7a8c7a31b8e440a6 (patch) | |
tree | 4b318cdb42b9888197247089cb0a7349f122dd99 /sfx2/source/doc | |
parent | 9782438a5887c40246016c1f2b5fe12401d2c68d (diff) |
convert SIGNATURESTATE_ constants to scoped enum
Change-Id: I715e39599464a199a8b78ec274bfe47b90fc4bb7
Reviewed-on: https://gerrit.libreoffice.org/15301
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/docmacromode.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 56 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 4 |
8 files changed, 66 insertions, 66 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 73deeca8877c..cdd18ce638a2 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -232,7 +232,7 @@ public: // the following member is changed and makes sense only during saving // TODO/LATER: in future the signature state should be controlled by the medium not by the document // in this case the member will hold this information - sal_uInt16 m_nSignatureState; + SignatureState m_nSignatureState; util::DateTime m_aDateTime; @@ -275,7 +275,7 @@ SfxMedium_Impl::SfxMedium_Impl( SfxMedium* pAntiImplP ) : aExpireTime( Date( Date::SYSTEM ) + 10, tools::Time( tools::Time::SYSTEM ) ), pTempFile( NULL ), nLastStorageError( 0 ), - m_nSignatureState( SIGNATURESTATE_NOSIGNATURES ) + m_nSignatureState( SignatureState::NOSIGNATURES ) { aDoneLink.CreateMutex(); } @@ -3456,13 +3456,13 @@ bool SfxMedium::SignContents_Impl( bool bScriptingContent, const OUString& aODFV } -sal_uInt16 SfxMedium::GetCachedSignatureState_Impl() +SignatureState SfxMedium::GetCachedSignatureState_Impl() { return pImp->m_nSignatureState; } -void SfxMedium::SetCachedSignatureState_Impl( sal_uInt16 nState ) +void SfxMedium::SetCachedSignatureState_Impl( SignatureState nState ) { pImp->m_nSignatureState = nState; } diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index 54fd58ef51f0..9381651d7f1a 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -246,8 +246,8 @@ namespace sfx2 // the trusted macro check will also retrieve the signature state ( small optimization ) bool bHasTrustedMacroSignature = m_xData->m_rDocumentAccess.hasTrustedScriptingSignature( nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN ); - sal_uInt16 nSignatureState = m_xData->m_rDocumentAccess.getScriptingSignatureState(); - if ( nSignatureState == SIGNATURESTATE_SIGNATURES_BROKEN ) + SignatureState nSignatureState = m_xData->m_rDocumentAccess.getScriptingSignatureState(); + if ( nSignatureState == SignatureState::BROKEN ) { // the signature is broken, no macro execution if ( nMacroExecutionMode != MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN ) @@ -260,8 +260,8 @@ namespace sfx2 // there is trusted macro signature, allow macro execution return allowMacroExecution(); } - else if ( nSignatureState == SIGNATURESTATE_SIGNATURES_OK - || nSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + else if ( nSignatureState == SignatureState::OK + || nSignatureState == SignatureState::NOTVALIDATED ) { // there is valid signature, but it is not from the trusted author return disallowMacroExecution(); diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 3dc833cfbe6a..b335dbf45d0e 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1383,7 +1383,7 @@ bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel, uno::Sequence< beans::PropertyValue >& aArgsSequence, bool bPreselectPassword, const OUString& _aSuggestedName, - sal_uInt16 nDocumentSignatureState ) + SignatureState nDocumentSignatureState ) { OUString aSuggestedName = _aSuggestedName; ModelData_Impl aModelData( *this, xModel, aArgsSequence ); @@ -1459,10 +1459,10 @@ bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel, if ( !( nStoreMode & EXPORT_REQUESTED ) ) { // if it is no export, warn user that the signature will be removed - if ( SIGNATURESTATE_SIGNATURES_OK == nDocumentSignatureState - || SIGNATURESTATE_SIGNATURES_INVALID == nDocumentSignatureState - || SIGNATURESTATE_SIGNATURES_NOTVALIDATED == nDocumentSignatureState - || SIGNATURESTATE_SIGNATURES_PARTIAL_OK == nDocumentSignatureState) + if ( SignatureState::OK == nDocumentSignatureState + || SignatureState::INVALID == nDocumentSignatureState + || SignatureState::NOTVALIDATED == nDocumentSignatureState + || SignatureState::PARTIAL_OK == nDocumentSignatureState) { if (MessageDialog(NULL, SfxResId(RID_SVXSTR_XMLSEC_QUERY_LOSINGSIGNATURE), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO).Execute() != RET_YES) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index f3ac27ce1752..09b5bf13f715 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1127,8 +1127,8 @@ void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteract void SfxObjectShell::CheckForBrokenDocSignatures_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) { - sal_Int16 nSignatureState = GetDocumentSignatureState(); - bool bSignatureBroken = ( nSignatureState == SIGNATURESTATE_SIGNATURES_BROKEN ); + SignatureState nSignatureState = GetDocumentSignatureState(); + bool bSignatureBroken = ( nSignatureState == SignatureState::BROKEN ); if ( !bSignatureBroken ) return; @@ -1921,14 +1921,14 @@ Reference< XEmbeddedScripts > SfxObjectShell_Impl::getEmbeddedDocumentScripts() return Reference< XEmbeddedScripts >( rDocShell.GetModel(), UNO_QUERY ); } -sal_Int16 SfxObjectShell_Impl::getScriptingSignatureState() +SignatureState SfxObjectShell_Impl::getScriptingSignatureState() { - sal_Int16 nSignatureState( rDocShell.GetScriptingSignatureState() ); + SignatureState nSignatureState( rDocShell.GetScriptingSignatureState() ); - if ( nSignatureState != SIGNATURESTATE_NOSIGNATURES && m_bMacroSignBroken ) + if ( nSignatureState != SignatureState::NOSIGNATURES && m_bMacroSignBroken ) { // if there is a macro signature it must be handled as broken - nSignatureState = SIGNATURESTATE_SIGNATURES_BROKEN; + nSignatureState = SignatureState::BROKEN; } return nSignatureState; @@ -1952,19 +1952,19 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor uno::Reference< security::XDocumentDigitalSignatures > xSigner( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) ); - if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN - || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK - || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + if ( nScriptingSignatureState == SignatureState::UNKNOWN + || nScriptingSignatureState == SignatureState::OK + || nScriptingSignatureState == SignatureState::NOTVALIDATED ) { uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.ImplAnalyzeSignature( true, xSigner ); if ( aInfo.getLength() ) { - if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN ) + if ( nScriptingSignatureState == SignatureState::UNKNOWN ) nScriptingSignatureState = rDocShell.ImplCheckSignaturesInformation( aInfo ); - if ( nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK - || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED ) + if ( nScriptingSignatureState == SignatureState::OK + || nScriptingSignatureState == SignatureState::NOTVALIDATED ) { for ( sal_Int32 nInd = 0; !bResult && nInd < aInfo.getLength(); nInd++ ) { diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 119e52f9e6f6..8f10da507570 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1109,14 +1109,14 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } case SID_SIGNATURE: { - rSet.Put( SfxUInt16Item( SID_SIGNATURE, GetDocumentSignatureState() ) ); + rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast<sal_uInt16>(GetDocumentSignatureState()) ) ); break; } case SID_MACRO_SIGNATURE: { // the slot makes sense only if there is a macro in the document if ( pImp->documentStorageHasMacros() || pImp->aMacroMode.hasMacroLibrary() ) - rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, GetScriptingSignatureState() ) ); + rSet.Put( SfxUInt16Item( SID_MACRO_SIGNATURE, static_cast<sal_uInt16>(GetScriptingSignatureState()) ) ); else rSet.DisableItem( nWhich ); break; @@ -1287,36 +1287,36 @@ void SfxObjectShell::StateView_Impl(SfxItemSet& /*rSet*/) { } -sal_uInt16 SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< security::DocumentSignatureInformation >& aInfos ) +SignatureState SfxObjectShell::ImplCheckSignaturesInformation( const uno::Sequence< security::DocumentSignatureInformation >& aInfos ) { bool bCertValid = true; - sal_uInt16 nResult = SIGNATURESTATE_NOSIGNATURES; + SignatureState nResult = SignatureState::NOSIGNATURES; int nInfos = aInfos.getLength(); bool bCompleteSignature = true; if( nInfos ) { - nResult = SIGNATURESTATE_SIGNATURES_OK; + nResult = SignatureState::OK; for ( int n = 0; n < nInfos; n++ ) { if ( bCertValid ) { sal_Int32 nCertStat = aInfos[n].CertificateStatus; - bCertValid = nCertStat == security::CertificateValidity::VALID ? sal_True : sal_False; + bCertValid = nCertStat == security::CertificateValidity::VALID; } if ( !aInfos[n].SignatureIsValid ) { - nResult = SIGNATURESTATE_SIGNATURES_BROKEN; + nResult = SignatureState::BROKEN; break; // we know enough } bCompleteSignature &= !aInfos[n].PartialDocumentSignature; } } - if ( nResult == SIGNATURESTATE_SIGNATURES_OK && !bCertValid ) - nResult = SIGNATURESTATE_SIGNATURES_NOTVALIDATED; - else if ( nResult == SIGNATURESTATE_SIGNATURES_OK && bCertValid && !bCompleteSignature) - nResult = SIGNATURESTATE_SIGNATURES_PARTIAL_OK; + if ( nResult == SignatureState::OK && !bCertValid ) + nResult = SignatureState::NOTVALIDATED; + else if ( nResult == SignatureState::OK && bCertValid && !bCompleteSignature) + nResult = SignatureState::PARTIAL_OK; // this code must not check whether the document is modified // it should only check the provided info @@ -1364,26 +1364,26 @@ uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnal return aResult; } -sal_uInt16 SfxObjectShell::ImplGetSignatureState( bool bScriptingContent ) +SignatureState SfxObjectShell::ImplGetSignatureState( bool bScriptingContent ) { - sal_Int16* pState = bScriptingContent ? &pImp->nScriptingSignatureState : &pImp->nDocumentSignatureState; + SignatureState* pState = bScriptingContent ? &pImp->nScriptingSignatureState : &pImp->nDocumentSignatureState; - if ( *pState == SIGNATURESTATE_UNKNOWN ) + if ( *pState == SignatureState::UNKNOWN ) { - *pState = SIGNATURESTATE_NOSIGNATURES; + *pState = SignatureState::NOSIGNATURES; uno::Sequence< security::DocumentSignatureInformation > aInfos = ImplAnalyzeSignature( bScriptingContent ); *pState = ImplCheckSignaturesInformation( aInfos ); } - if ( *pState == SIGNATURESTATE_SIGNATURES_OK || *pState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED - || *pState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) + if ( *pState == SignatureState::OK || *pState == SignatureState::NOTVALIDATED + || *pState == SignatureState::PARTIAL_OK) { if ( IsModified() ) - *pState = SIGNATURESTATE_SIGNATURES_INVALID; + *pState = SignatureState::INVALID; } - return (sal_uInt16)*pState; + return *pState; } void SfxObjectShell::ImplSign( bool bScriptingContent ) @@ -1405,7 +1405,7 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) // check whether the document is signed ImplGetSignatureState( false ); // document signature ImplGetSignatureState( true ); // script signature - bool bHasSign = ( pImp->nScriptingSignatureState != SIGNATURESTATE_NOSIGNATURES || pImp->nDocumentSignatureState != SIGNATURESTATE_NOSIGNATURES ); + bool bHasSign = ( pImp->nScriptingSignatureState != SignatureState::NOSIGNATURES || pImp->nDocumentSignatureState != SignatureState::NOSIGNATURES ); // the target ODF version on saving SvtSaveOptions aSaveOpt; @@ -1492,9 +1492,9 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) bool bSigned = GetMedium()->SignContents_Impl( bScriptingContent, aODFVersion, - pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_OK - || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED - || pImp->nDocumentSignatureState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK); + pImp->nDocumentSignatureState == SignatureState::OK + || pImp->nDocumentSignatureState == SignatureState::NOTVALIDATED + || pImp->nDocumentSignatureState == SignatureState::PARTIAL_OK); DoSaveCompleted( GetMedium() ); @@ -1502,13 +1502,13 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) { if ( bScriptingContent ) { - pImp->nScriptingSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + pImp->nScriptingSignatureState = SignatureState::UNKNOWN;// Re-Check // adding of scripting signature removes existing document signature - pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + pImp->nDocumentSignatureState = SignatureState::UNKNOWN;// Re-Check } else - pImp->nDocumentSignatureState = SIGNATURESTATE_UNKNOWN;// Re-Check + pImp->nDocumentSignatureState = SignatureState::UNKNOWN;// Re-Check pImp->bSignatureErrorIsShown = false; @@ -1522,7 +1522,7 @@ void SfxObjectShell::ImplSign( bool bScriptingContent ) EnableSetModified( true ); } -sal_uInt16 SfxObjectShell::GetDocumentSignatureState() +SignatureState SfxObjectShell::GetDocumentSignatureState() { return ImplGetSignatureState( false ); } @@ -1532,7 +1532,7 @@ void SfxObjectShell::SignDocumentContent() ImplSign( false ); } -sal_uInt16 SfxObjectShell::GetScriptingSignatureState() +SignatureState SfxObjectShell::GetScriptingSignatureState() { return ImplGetSignatureState( true ); } diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index b1ed9b3d42c7..c609495d1462 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1156,9 +1156,9 @@ bool SfxObjectShell::SaveTo_Impl // no way to detect whether a filter is oasis format, have to wait for saving process bool bNoPreserveForOasis = false; if ( bOwnSource && bOwnTarget - && ( pImp->nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK - || pImp->nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED - || pImp->nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_INVALID ) ) + && ( pImp->nScriptingSignatureState == SignatureState::OK + || pImp->nScriptingSignatureState == SignatureState::NOTVALIDATED + || pImp->nScriptingSignatureState == SignatureState::INVALID ) ) { AddLog( OUString( OSL_LOG_PREFIX "MacroSignaturePreserving" ) ); @@ -1640,9 +1640,9 @@ bool SfxObjectShell::SaveTo_Impl uno::Sequence< security::DocumentSignatureInformation > aInfos = xDDSigns->verifyScriptingContentSignatures( xTarget, uno::Reference< io::XInputStream >() ); - sal_uInt16 nState = ImplCheckSignaturesInformation( aInfos ); - if ( nState == SIGNATURESTATE_SIGNATURES_OK || nState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED - || nState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK) + SignatureState nState = ImplCheckSignaturesInformation( aInfos ); + if ( nState == SignatureState::OK || nState == SignatureState::NOTVALIDATED + || nState == SignatureState::PARTIAL_OK) { rMedium.SetCachedSignatureState_Impl( nState ); @@ -2073,13 +2073,13 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed ) } // before the title regenerated the document must lose the signatures - pImp->nDocumentSignatureState = SIGNATURESTATE_NOSIGNATURES; + pImp->nDocumentSignatureState = SignatureState::NOSIGNATURES; pImp->nScriptingSignatureState = pNewMed->GetCachedSignatureState_Impl(); - OSL_ENSURE( pImp->nScriptingSignatureState != SIGNATURESTATE_SIGNATURES_BROKEN, "The signature must not be broken at this place" ); + OSL_ENSURE( pImp->nScriptingSignatureState != SignatureState::BROKEN, "The signature must not be broken at this place" ); pImp->bSignatureErrorIsShown = false; // TODO/LATER: in future the medium must control own signature state, not the document - pNewMed->SetCachedSignatureState_Impl( SIGNATURESTATE_NOSIGNATURES ); // set the default value back + pNewMed->SetCachedSignatureState_Impl( SignatureState::NOSIGNATURES ); // set the default value back // Set new title if (!pNewMed->GetName().isEmpty() && SfxObjectCreateMode::EMBEDDED != eCreateMode) diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 611441161138..854094b293fd 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -211,8 +211,8 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,pProgress( 0) ,nTime( DateTime::SYSTEM ) ,nVisualDocumentNumber( USHRT_MAX) - ,nDocumentSignatureState( SIGNATURESTATE_UNKNOWN ) - ,nScriptingSignatureState( SIGNATURESTATE_UNKNOWN ) + ,nDocumentSignatureState( SignatureState::UNKNOWN ) + ,nScriptingSignatureState( SignatureState::UNKNOWN ) ,bInList( false) ,bClosing( false) ,bIsSaving( false) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index d3c4eb5c6c86..c24f3eaf5852 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3448,7 +3448,7 @@ bool SfxBaseModel::hasValidSignatures() const { SolarMutexGuard aGuard; if ( m_pData->m_pObjectShell.Is() ) - return ( m_pData->m_pObjectShell->ImplGetSignatureState( false ) == SIGNATURESTATE_SIGNATURES_OK ); + return ( m_pData->m_pObjectShell->ImplGetSignatureState( false ) == SignatureState::OK ); return false; } @@ -4007,7 +4007,7 @@ OUString SAL_CALL SfxBaseModel::getTitle() else if ( m_pData->m_pObjectShell->IsDocShared() ) aResult += SfxResId(STR_SHARED).toString(); - if ( m_pData->m_pObjectShell->GetDocumentSignatureState() == SIGNATURESTATE_SIGNATURES_OK ) + if ( m_pData->m_pObjectShell->GetDocumentSignatureState() == SignatureState::OK ) aResult += SfxResId(RID_XMLSEC_DOCUMENTSIGNED).toString(); } |