1*31598a22SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*31598a22SAndrew Rist * distributed with this work for additional information 6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance 9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at 10*31598a22SAndrew Rist * 11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*31598a22SAndrew Rist * 13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*31598a22SAndrew Rist * software distributed under the License is distributed on an 15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the 17*31598a22SAndrew Rist * specific language governing permissions and limitations 18*31598a22SAndrew Rist * under the License. 19*31598a22SAndrew Rist * 20*31598a22SAndrew Rist *************************************************************/ 21*31598a22SAndrew Rist 22*31598a22SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_basctl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "docsignature.hxx" 28cdf0e10cSrcweir #include "scriptdocument.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** === begin UNO includes === **/ 31cdf0e10cSrcweir /** === end UNO includes === **/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <sfx2/objsh.hxx> 34cdf0e10cSrcweir #include <sfx2/signaturestate.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir //........................................................................ 37cdf0e10cSrcweir namespace basctl 38cdf0e10cSrcweir { 39cdf0e10cSrcweir //........................................................................ 40cdf0e10cSrcweir 41cdf0e10cSrcweir /** === begin UNO using === **/ 42cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 43cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 44cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 45cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 46cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 47cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 48cdf0e10cSrcweir /** === end UNO using === **/ 49cdf0e10cSrcweir 50cdf0e10cSrcweir //==================================================================== 51cdf0e10cSrcweir //= DocumentSignature_Data 52cdf0e10cSrcweir //==================================================================== 53cdf0e10cSrcweir struct DocumentSignature_Data 54cdf0e10cSrcweir { 55cdf0e10cSrcweir SfxObjectShell* pShell; 56cdf0e10cSrcweir DocumentSignature_Databasctl::DocumentSignature_Data57cdf0e10cSrcweir DocumentSignature_Data() : pShell( NULL ) { } 58cdf0e10cSrcweir }; 59cdf0e10cSrcweir 60cdf0e10cSrcweir //==================================================================== 61cdf0e10cSrcweir //= DocumentSignature 62cdf0e10cSrcweir //==================================================================== 63cdf0e10cSrcweir //-------------------------------------------------------------------- DocumentSignature(const ScriptDocument & _rDocument)64cdf0e10cSrcweir DocumentSignature::DocumentSignature( const ScriptDocument& _rDocument ) 65cdf0e10cSrcweir :m_pData( new DocumentSignature_Data ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir if ( _rDocument.isDocument() ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir Reference< XModel > xDocument( _rDocument.getDocument() ); 70cdf0e10cSrcweir // find object shell for document 71cdf0e10cSrcweir SfxObjectShell* pShell = SfxObjectShell::GetFirst(); 72cdf0e10cSrcweir while ( pShell ) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir if ( pShell->GetModel() == xDocument ) 75cdf0e10cSrcweir break; 76cdf0e10cSrcweir pShell = SfxObjectShell::GetNext( *pShell ); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir m_pData->pShell = pShell; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir //-------------------------------------------------------------------- ~DocumentSignature()83cdf0e10cSrcweir DocumentSignature::~DocumentSignature() 84cdf0e10cSrcweir { 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir //-------------------------------------------------------------------- supportsSignatures() const88cdf0e10cSrcweir bool DocumentSignature::supportsSignatures() const 89cdf0e10cSrcweir { 90cdf0e10cSrcweir return ( m_pData->pShell != NULL ); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir //-------------------------------------------------------------------- signScriptingContent() const94cdf0e10cSrcweir void DocumentSignature::signScriptingContent() const 95cdf0e10cSrcweir { 96cdf0e10cSrcweir OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" ); 97cdf0e10cSrcweir if ( m_pData->pShell ) 98cdf0e10cSrcweir m_pData->pShell->SignScriptingContent(); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir //-------------------------------------------------------------------- getScriptingSignatureState() const102cdf0e10cSrcweir sal_uInt16 DocumentSignature::getScriptingSignatureState() const 103cdf0e10cSrcweir { 104cdf0e10cSrcweir if ( m_pData->pShell ) 105cdf0e10cSrcweir return m_pData->pShell->GetScriptingSignatureState(); 106cdf0e10cSrcweir return SIGNATURESTATE_NOSIGNATURES; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir //........................................................................ 110cdf0e10cSrcweir } // namespace basctl 111cdf0e10cSrcweir //........................................................................ 112