2017-10-09 11:31:13 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <editeng/CustomPropertyField.hxx>
|
2018-07-11 21:53:47 +02:00
|
|
|
#include <o3tl/make_unique.hxx>
|
2017-10-09 11:31:13 +02:00
|
|
|
#include <vcl/metaact.hxx>
|
|
|
|
#include <com/sun/star/beans/XPropertyContainer.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
|
|
|
|
using namespace css;
|
|
|
|
|
|
|
|
namespace editeng
|
|
|
|
{
|
|
|
|
|
2017-10-30 12:21:49 +09:00
|
|
|
CustomPropertyField::CustomPropertyField(OUString const & rName, OUString const & rCurrentPresentation)
|
2017-10-09 11:31:13 +02:00
|
|
|
: SvxFieldData()
|
2017-10-30 12:21:49 +09:00
|
|
|
, msName(rName)
|
|
|
|
, msCurrentPresentation(rCurrentPresentation)
|
2017-10-09 11:31:13 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
CustomPropertyField::~CustomPropertyField()
|
|
|
|
{}
|
|
|
|
|
2018-07-11 21:53:47 +02:00
|
|
|
std::unique_ptr<SvxFieldData> CustomPropertyField::Clone() const
|
2017-10-09 11:31:13 +02:00
|
|
|
{
|
2018-07-11 21:53:47 +02:00
|
|
|
return o3tl::make_unique<CustomPropertyField>(msName, msCurrentPresentation);
|
2017-10-09 11:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CustomPropertyField::operator==(const SvxFieldData& rOther) const
|
|
|
|
{
|
|
|
|
if (typeid(rOther) != typeid(*this))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const CustomPropertyField& rOtherField = static_cast<const CustomPropertyField&>(rOther);
|
2017-10-30 12:21:49 +09:00
|
|
|
return (msName == rOtherField.msName &&
|
|
|
|
msCurrentPresentation == rOtherField.msCurrentPresentation);
|
2017-10-09 11:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaAction* CustomPropertyField::createBeginComment() const
|
|
|
|
{
|
|
|
|
return new MetaCommentAction("FIELD_SEQ_BEGIN");
|
|
|
|
}
|
|
|
|
|
2017-10-30 12:21:49 +09:00
|
|
|
OUString CustomPropertyField::GetFormatted(uno::Reference<document::XDocumentProperties> const & xDocumentProperties)
|
2017-10-09 11:31:13 +02:00
|
|
|
{
|
2017-10-30 12:21:49 +09:00
|
|
|
if (msName.isEmpty())
|
|
|
|
return OUString();
|
2017-10-09 11:31:13 +02:00
|
|
|
if (!xDocumentProperties.is())
|
|
|
|
return OUString();
|
|
|
|
uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
|
|
|
|
if (!xPropertyContainer.is())
|
|
|
|
return OUString();
|
|
|
|
uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
|
|
|
|
if (!xPropertySet.is())
|
|
|
|
return OUString();
|
2017-10-30 12:21:49 +09:00
|
|
|
uno::Any aAny = xPropertySet->getPropertyValue(msName);
|
2017-10-09 11:31:13 +02:00
|
|
|
if (!aAny.has<OUString>())
|
|
|
|
return OUString();
|
2017-10-30 12:21:49 +09:00
|
|
|
msCurrentPresentation = aAny.get<OUString>();
|
|
|
|
return msCurrentPresentation;
|
2017-10-09 11:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end editeng namespace
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|