loplugin:virtualdead dead propertygroup functionality

ever since it was introduced in

    commit d09dd89864
    Date:   Wed Sep 15 13:55:34 2010 +0200
dba34a: export/import min-/max-/default-/value for date/time as
XML-Schema conformant strings

looks like classic over-engineering

Change-Id: Ia4e4b65cfe92f522dee238a54a37db01f691750e
Reviewed-on: https://gerrit.libreoffice.org/80951
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-10-17 12:10:56 +02:00
parent e8475b6343
commit 18d8ba49dc
11 changed files with 19 additions and 202 deletions

View File

@@ -445,6 +445,3 @@ writerfilter/source/dmapper/LoggedResources.hxx:93
writerfilter/source/dmapper/LoggedResources.hxx:129
void writerfilter::LoggedTable::lcl_entry(int,class tools::SvRef<class writerfilter::Reference<class writerfilter::Properties> >,)
01
xmloff/inc/forms/property_handler.hxx:44
class rtl::OUString xmloff::PropertyHandlerBase::getAttributeValue(const class std::__debug::map<enum xmloff::PropertyId, class com::sun::star::uno::Any, struct std::less<enum xmloff::PropertyId>, class std::allocator<struct std::pair<const enum xmloff::PropertyId, class com::sun::star::uno::Any> > > &,)const
0

View File

@@ -38,11 +38,6 @@ namespace xmloff
class PropertyHandlerBase : public ::salhelper::SimpleReferenceObject
{
public:
/** retrieves the XML attribute value for the given property values
*/
virtual OUString
getAttributeValue( const PropertyValues& i_propertyValues ) const = 0;
/** is a convenience method for XML attributes whose value comprises of only one UNO API property
*/
virtual OUString

View File

@@ -456,42 +456,17 @@ namespace xmloff
continue;
}
OUString attributeValue;
if ( propDescription->propertyGroup == NO_GROUP )
// that's a property which has a direct mapping to an attribute
if ( !shouldExportProperty( prop.Name ) )
// TODO: in the future, we surely need a more sophisticated approach to this, involving the property
// handler, or the property description
{
// that's a property which has a direct mapping to an attribute
if ( !shouldExportProperty( prop.Name ) )
// TODO: in the future, we surely need a more sophisticated approach to this, involving the property
// handler, or the property description
{
exportedProperty( prop.Name );
continue;
}
const Any propValue = m_xProps->getPropertyValue( prop.Name );
attributeValue = handler->getAttributeValue( propValue );
exportedProperty( prop.Name );
continue;
}
else
{
// that's a property which is part of a group of properties, whose values, in their entity, comprise
// a single attribute value
// retrieve the descriptions of all other properties which add to the attribute value
PropertyDescriptionList descriptions;
metadata::getPropertyGroup( propDescription->propertyGroup, descriptions );
// retrieve the values for all those properties
PropertyValues aValues;
for ( const auto& desc : descriptions )
{
// TODO: XMultiPropertySet?
const Any propValue = m_xProps->getPropertyValue( desc->propertyName );
aValues[ desc->propertyId ] = propValue;
}
// let the handler translate into an XML attribute value
attributeValue = handler->getAttributeValue( aValues );
}
const Any propValue = m_xProps->getPropertyValue( prop.Name );
OUString attributeValue = handler->getAttributeValue( propValue );
AddAttribute(
propDescription->attribute.namespacePrefix,

View File

@@ -42,12 +42,6 @@ namespace xmloff
{
}
OUString VCLDateHandler::getAttributeValue( const PropertyValues& /*i_propertyValues*/ ) const
{
OSL_ENSURE( false, "VCLDateHandler::getAttributeValue: unexpected call!" );
return OUString();
}
OUString VCLDateHandler::getAttributeValue( const Any& i_propertyValue ) const
{
Date aDate;

View File

@@ -32,7 +32,6 @@ namespace xmloff
VCLDateHandler();
// IPropertyHandler
virtual OUString getAttributeValue( const PropertyValues& i_propertyValues ) const override;
virtual OUString getAttributeValue( const css::uno::Any& i_propertyValue ) const override;
virtual bool getPropertyValues( const OUString& i_attributeValue, PropertyValues& o_propertyValues ) const override;
};

View File

@@ -42,12 +42,6 @@ namespace xmloff
{
}
OUString VCLTimeHandler::getAttributeValue( const PropertyValues& /*i_propertyValues*/ ) const
{
OSL_ENSURE( false, "VCLTimeHandler::getAttributeValue: unexpected call!" );
return OUString();
}
OUString VCLTimeHandler::getAttributeValue( const Any& i_propertyValue ) const
{
css::util::Time aTime;

View File

@@ -32,7 +32,6 @@ namespace xmloff
VCLTimeHandler();
// IPropertyHandler
virtual OUString getAttributeValue( const PropertyValues& i_propertyValues ) const override;
virtual OUString getAttributeValue( const css::uno::Any& i_propertyValue ) const override;
virtual bool getPropertyValues( const OUString& i_attributeValue, PropertyValues& o_propertyValues ) const override;
};

View File

@@ -21,8 +21,6 @@
#define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
#include <forms/property_handler.hxx>
#include "property_group.hxx"
#include <xmloff/xmltoken.hxx>
#include <vector>
@@ -71,23 +69,12 @@ namespace xmloff
const PropertyHandlerFactory factory;
/// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
const PropertyId propertyId;
/** the group which the property belongs to. Multiple properties belonging to the same group will, all together,
define the attribute value to be written into the ODF file.
Consequently, properties which have the same |propertyGroup| value must also have the same |attribute|
and the same |factory| value, with the only exception being NO_GROUP properties.
Note that the other direction is not given: It is perfectly legitimate to map the same attribute to different
(disjunct) property groups.
*/
const PropertyGroup propertyGroup;
PropertyDescription()
:propertyName()
,attribute()
,factory( nullptr )
,propertyId( PID_INVALID )
,propertyGroup( NO_GROUP )
{
}
@@ -96,14 +83,12 @@ namespace xmloff
const sal_uInt16 i_namespacePrefix,
const ::xmloff::token::XMLTokenEnum i_attributeToken,
const PropertyHandlerFactory i_factory,
const PropertyId i_propertyId,
const PropertyGroup i_propertyGroup
const PropertyId i_propertyId
)
:propertyName( i_propertyName )
,attribute( i_namespacePrefix, i_attributeToken )
,factory( i_factory )
,propertyId( i_propertyId )
,propertyGroup( i_propertyGroup )
{
}
};

View File

@@ -1,36 +0,0 @@
/* -*- 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/.
*
* 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 .
*/
#ifndef INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_GROUP_HXX
#define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_GROUP_HXX
namespace xmloff
{
//= PropertyGroup
enum PropertyGroup
{
NO_GROUP
};
} // namespace xmloff
#endif // INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_GROUP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -37,7 +37,7 @@ namespace xmloff { namespace metadata
using namespace ::xmloff::token;
#define FORM_SINGLE_PROPERTY( id, att ) \
PropertyDescription( PROPERTY_##id, XML_NAMESPACE_FORM, att, &FormHandlerFactory::getFormPropertyHandler, PID_##id, NO_GROUP )
PropertyDescription( PROPERTY_##id, XML_NAMESPACE_FORM, att, &FormHandlerFactory::getFormPropertyHandler, PID_##id )
//= property meta data
namespace
@@ -88,25 +88,6 @@ namespace xmloff { namespace metadata
return s_propertyDescriptionsByName;
}
typedef ::std::map< PropertyGroup, PropertyDescriptionList > IndexedPropertyGroups;
const IndexedPropertyGroups& lcl_getIndexedPropertyGroups()
{
DBG_TESTSOLARMUTEX();
static IndexedPropertyGroups s_indexedPropertyGroups;
if ( s_indexedPropertyGroups.empty() )
{
const PropertyDescription* desc = lcl_getPropertyMetaData();
while ( !desc->propertyName.isEmpty() )
{
if ( desc->propertyGroup != NO_GROUP )
s_indexedPropertyGroups[ desc->propertyGroup ].push_back( desc );
++desc;
}
}
return s_indexedPropertyGroups;
}
typedef std::unordered_map< OUString, XMLTokenEnum > ReverseTokenLookup;
const ReverseTokenLookup& getReverseTokenLookup()
@@ -136,25 +117,6 @@ namespace xmloff { namespace metadata
}
};
typedef std::unordered_multimap< AttributeDescription, PropertyGroup, AttributeHash > AttributeGroups;
const AttributeGroups& lcl_getAttributeGroups()
{
DBG_TESTSOLARMUTEX();
static AttributeGroups s_attributeGroups;
if ( s_attributeGroups.empty() )
{
const PropertyDescription* desc = lcl_getPropertyMetaData();
while ( !desc->propertyName.isEmpty() )
{
if ( desc->propertyGroup != NO_GROUP )
s_attributeGroups.emplace( desc->attribute, desc->propertyGroup );
++desc;
}
}
return s_attributeGroups;
}
typedef std::unordered_map< AttributeDescription, PropertyGroups, AttributeHash > AttributesWithoutGroup;
const AttributesWithoutGroup& lcl_getAttributesWithoutGroups()
@@ -166,13 +128,10 @@ namespace xmloff { namespace metadata
const PropertyDescription* desc = lcl_getPropertyMetaData();
while ( !desc->propertyName.isEmpty() )
{
if ( desc->propertyGroup == NO_GROUP )
{
PropertyDescriptionList singleElementList;
singleElementList.push_back( desc );
PropertyDescriptionList singleElementList;
singleElementList.push_back( desc );
s_attributesWithoutGroup[ desc->attribute ].push_back( singleElementList );
}
s_attributesWithoutGroup[ desc->attribute ].push_back( singleElementList );
++desc;
}
}
@@ -189,48 +148,14 @@ namespace xmloff { namespace metadata
return nullptr;
}
void getPropertyGroup( const PropertyGroup i_propertyGroup, PropertyDescriptionList& o_propertyDescriptions )
{
OSL_ENSURE( i_propertyGroup != NO_GROUP, "xmloff::metadata::getPropertyGroup: illegal group!" );
const IndexedPropertyGroups& rPropertyGroups( lcl_getIndexedPropertyGroups() );
const IndexedPropertyGroups::const_iterator pos = rPropertyGroups.find( i_propertyGroup );
if ( pos != rPropertyGroups.end() )
o_propertyDescriptions = pos->second;
}
void getPropertyGroupList( const AttributeDescription& i_attribute, PropertyGroups& o_propertyGroups )
{
const AttributeGroups& rAttributeGroups = lcl_getAttributeGroups();
::std::pair< AttributeGroups::const_iterator, AttributeGroups::const_iterator >
range = rAttributeGroups.equal_range( i_attribute );
if ( range.first == range.second )
{
// the attribute is not used for any non-trivial group, which means it is mapped directly to
// a single property
const AttributesWithoutGroup& attributesWithoutGroups( lcl_getAttributesWithoutGroups() );
const AttributesWithoutGroup::const_iterator pos = attributesWithoutGroups.find( i_attribute );
if ( pos != attributesWithoutGroups.end() )
o_propertyGroups = pos->second;
}
else
{
const IndexedPropertyGroups& rPropertyGroups = lcl_getIndexedPropertyGroups();
for ( AttributeGroups::const_iterator group = range.first; group != range.second; ++group )
{
const PropertyGroup propGroup = group->second;
const IndexedPropertyGroups::const_iterator groupPos = rPropertyGroups.find( propGroup );
if( groupPos == rPropertyGroups.end() )
{
SAL_WARN( "xmloff.forms", "getPropertyGroupList: inconsistency!" );
continue;
}
o_propertyGroups.push_back( groupPos->second );
}
}
// the attribute is not used for any non-trivial group, which means it is mapped directly to
// a single property
const AttributesWithoutGroup& attributesWithoutGroups( lcl_getAttributesWithoutGroups() );
const AttributesWithoutGroup::const_iterator pos = attributesWithoutGroups.find( i_attribute );
if ( pos != attributesWithoutGroups.end() )
o_propertyGroups = pos->second;
}
AttributeDescription getAttributeDescription( const sal_uInt16 i_namespacePrefix, const OUString& i_attributeName )

View File

@@ -27,16 +27,6 @@ namespace xmloff { namespace metadata
const PropertyDescription* getPropertyDescription( const OUString& i_propertyName );
/** retries the descriptions of all properties which add to the given XML attribute
<p>Effectively, the complete property map is search for all entries which have the given
namespace/attribute values.</p>
*/
void getPropertyGroup(
const PropertyGroup i_propertyGroup,
PropertyDescriptionList& o_propertyDescriptions
);
/** retrieves all known property groups which are mapped to the given attribute
*/
void getPropertyGroupList(