1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docsignature.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basctl.hxx"
34 #include "docsignature.hxx"
35 #include "scriptdocument.hxx"
37 /** === begin UNO includes === **/
38 /** === end UNO includes === **/
40 #include <sfx2/objsh.hxx>
41 #include <sfx2/signaturestate.hxx>
43 //........................................................................
46 //........................................................................
48 /** === begin UNO using === **/
49 using ::com::sun::star::uno::Reference
;
50 using ::com::sun::star::uno::UNO_QUERY
;
51 using ::com::sun::star::uno::UNO_QUERY_THROW
;
52 using ::com::sun::star::uno::Exception
;
53 using ::com::sun::star::uno::RuntimeException
;
54 using ::com::sun::star::frame::XModel
;
55 /** === end UNO using === **/
57 //====================================================================
58 //= DocumentSignature_Data
59 //====================================================================
60 struct DocumentSignature_Data
62 SfxObjectShell
* pShell
;
64 DocumentSignature_Data() : pShell( NULL
) { }
67 //====================================================================
69 //====================================================================
70 //--------------------------------------------------------------------
71 DocumentSignature::DocumentSignature( const ScriptDocument
& _rDocument
)
72 :m_pData( new DocumentSignature_Data
)
74 if ( _rDocument
.isDocument() )
76 Reference
< XModel
> xDocument( _rDocument
.getDocument() );
77 // find object shell for document
78 SfxObjectShell
* pShell
= SfxObjectShell::GetFirst();
81 if ( pShell
->GetModel() == xDocument
)
83 pShell
= SfxObjectShell::GetNext( *pShell
);
85 m_pData
->pShell
= pShell
;
89 //--------------------------------------------------------------------
90 DocumentSignature::~DocumentSignature()
94 //--------------------------------------------------------------------
95 bool DocumentSignature::supportsSignatures() const
97 return ( m_pData
->pShell
!= NULL
);
100 //--------------------------------------------------------------------
101 void DocumentSignature::signScriptingContent() const
103 OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" );
104 if ( m_pData
->pShell
)
105 m_pData
->pShell
->SignScriptingContent();
108 //--------------------------------------------------------------------
109 sal_uInt16
DocumentSignature::getScriptingSignatureState() const
111 if ( m_pData
->pShell
)
112 return m_pData
->pShell
->GetScriptingSignatureState();
113 return SIGNATURESTATE_NOSIGNATURES
;
116 //........................................................................
117 } // namespace basctl
118 //........................................................................