2010-10-12 08:57:08 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 11:02:47 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-10-09 09:23:14 -05:00
|
|
|
|
|
|
|
#include "docsignature.hxx"
|
|
|
|
#include "scriptdocument.hxx"
|
|
|
|
|
|
|
|
#include <sfx2/objsh.hxx>
|
2007-11-21 09:37:39 -06:00
|
|
|
#include <sfx2/signaturestate.hxx>
|
2007-10-09 09:23:14 -05:00
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
namespace basctl
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
|
|
|
/** === begin UNO using === **/
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
using ::com::sun::star::uno::RuntimeException;
|
|
|
|
using ::com::sun::star::frame::XModel;
|
|
|
|
/** === end UNO using === **/
|
|
|
|
|
|
|
|
//====================================================================
|
2012-09-02 09:21:08 -05:00
|
|
|
//= DocumentSignature::Impl
|
2007-10-09 09:23:14 -05:00
|
|
|
//====================================================================
|
2012-09-02 09:21:08 -05:00
|
|
|
struct DocumentSignature::Impl
|
2007-10-09 09:23:14 -05:00
|
|
|
{
|
2012-09-02 09:21:08 -05:00
|
|
|
SfxObjectShell* pShell;
|
2007-10-09 09:23:14 -05:00
|
|
|
|
2012-09-02 09:21:08 -05:00
|
|
|
Impl () : pShell(0) { }
|
2007-10-09 09:23:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
//= DocumentSignature
|
|
|
|
//====================================================================
|
|
|
|
//--------------------------------------------------------------------
|
2012-09-02 09:21:08 -05:00
|
|
|
DocumentSignature::DocumentSignature (ScriptDocument const& rDocument) :
|
|
|
|
m_pImpl(new Impl)
|
2007-10-09 09:23:14 -05:00
|
|
|
{
|
2012-09-02 09:21:08 -05:00
|
|
|
if (rDocument.isDocument())
|
2007-10-09 09:23:14 -05:00
|
|
|
{
|
2012-09-02 09:21:08 -05:00
|
|
|
Reference<XModel> xDocument(rDocument.getDocument());
|
2007-10-09 09:23:14 -05:00
|
|
|
// find object shell for document
|
|
|
|
SfxObjectShell* pShell = SfxObjectShell::GetFirst();
|
|
|
|
while ( pShell )
|
|
|
|
{
|
|
|
|
if ( pShell->GetModel() == xDocument )
|
|
|
|
break;
|
|
|
|
pShell = SfxObjectShell::GetNext( *pShell );
|
|
|
|
}
|
2012-09-02 09:21:08 -05:00
|
|
|
m_pImpl->pShell = pShell;
|
2007-10-09 09:23:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
DocumentSignature::~DocumentSignature()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
bool DocumentSignature::supportsSignatures() const
|
|
|
|
{
|
2012-09-02 09:21:08 -05:00
|
|
|
return ( m_pImpl->pShell != NULL );
|
2007-10-09 09:23:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void DocumentSignature::signScriptingContent() const
|
|
|
|
{
|
|
|
|
OSL_PRECOND( supportsSignatures(), "DocumentSignature::signScriptingContent: signatures not supported by this document!" );
|
2012-09-02 09:21:08 -05:00
|
|
|
if ( m_pImpl->pShell )
|
|
|
|
m_pImpl->pShell->SignScriptingContent();
|
2007-10-09 09:23:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_uInt16 DocumentSignature::getScriptingSignatureState() const
|
|
|
|
{
|
2012-09-02 09:21:08 -05:00
|
|
|
if ( m_pImpl->pShell )
|
|
|
|
return m_pImpl->pShell->GetScriptingSignatureState();
|
2007-10-09 09:23:14 -05:00
|
|
|
return SIGNATURESTATE_NOSIGNATURES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
} // namespace basctl
|
|
|
|
//........................................................................
|
2010-10-12 08:57:08 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|