bump product version to 4.1.6.2
[LibreOffice.git] / basctl / source / basicide / docsignature.cxx
blob0060ca6f19e92c612ae71e72ce3fbffb3a171eda
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "docsignature.hxx"
21 #include "scriptdocument.hxx"
23 #include <sfx2/objsh.hxx>
24 #include <sfx2/signaturestate.hxx>
26 //........................................................................
27 namespace basctl
29 //........................................................................
31 using ::com::sun::star::uno::Reference;
32 using ::com::sun::star::uno::UNO_QUERY;
33 using ::com::sun::star::uno::UNO_QUERY_THROW;
34 using ::com::sun::star::uno::Exception;
35 using ::com::sun::star::uno::RuntimeException;
36 using ::com::sun::star::frame::XModel;
38 //====================================================================
39 //= DocumentSignature::Impl
40 //====================================================================
41 struct DocumentSignature::Impl
43 SfxObjectShell* pShell;
45 Impl () : pShell(0) { }
48 //====================================================================
49 //= DocumentSignature
50 //====================================================================
51 //--------------------------------------------------------------------
52 DocumentSignature::DocumentSignature (ScriptDocument const& rDocument) :
53 m_pImpl(new Impl)
55 if (rDocument.isDocument())
57 Reference<XModel> xDocument(rDocument.getDocument());
58 // find object shell for document
59 SfxObjectShell* pShell = SfxObjectShell::GetFirst();
60 while ( pShell )
62 if ( pShell->GetModel() == xDocument )
63 break;
64 pShell = SfxObjectShell::GetNext( *pShell );
66 m_pImpl->pShell = pShell;
70 //--------------------------------------------------------------------
71 DocumentSignature::~DocumentSignature()
75 //--------------------------------------------------------------------
76 bool DocumentSignature::supportsSignatures() const
78 return ( m_pImpl->pShell != NULL );
81 //--------------------------------------------------------------------
82 void DocumentSignature::signScriptingContent() const
84 OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" );
85 if ( m_pImpl->pShell )
86 m_pImpl->pShell->SignScriptingContent();
89 //--------------------------------------------------------------------
90 sal_uInt16 DocumentSignature::getScriptingSignatureState() const
92 if ( m_pImpl->pShell )
93 return m_pImpl->pShell->GetScriptingSignatureState();
94 return SIGNATURESTATE_NOSIGNATURES;
97 //........................................................................
98 } // namespace basctl
99 //........................................................................
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */