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:
@@ -445,6 +445,3 @@ writerfilter/source/dmapper/LoggedResources.hxx:93
|
|||||||
writerfilter/source/dmapper/LoggedResources.hxx:129
|
writerfilter/source/dmapper/LoggedResources.hxx:129
|
||||||
void writerfilter::LoggedTable::lcl_entry(int,class tools::SvRef<class writerfilter::Reference<class writerfilter::Properties> >,)
|
void writerfilter::LoggedTable::lcl_entry(int,class tools::SvRef<class writerfilter::Reference<class writerfilter::Properties> >,)
|
||||||
01
|
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
|
|
||||||
|
@@ -38,11 +38,6 @@ namespace xmloff
|
|||||||
class PropertyHandlerBase : public ::salhelper::SimpleReferenceObject
|
class PropertyHandlerBase : public ::salhelper::SimpleReferenceObject
|
||||||
{
|
{
|
||||||
public:
|
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
|
/** is a convenience method for XML attributes whose value comprises of only one UNO API property
|
||||||
*/
|
*/
|
||||||
virtual OUString
|
virtual OUString
|
||||||
|
@@ -456,42 +456,17 @@ namespace xmloff
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString attributeValue;
|
// that's a property which has a direct mapping to an attribute
|
||||||
if ( propDescription->propertyGroup == NO_GROUP )
|
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
|
exportedProperty( prop.Name );
|
||||||
if ( !shouldExportProperty( prop.Name ) )
|
continue;
|
||||||
// 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 );
|
|
||||||
}
|
}
|
||||||
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
|
const Any propValue = m_xProps->getPropertyValue( prop.Name );
|
||||||
PropertyDescriptionList descriptions;
|
OUString attributeValue = handler->getAttributeValue( propValue );
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
AddAttribute(
|
AddAttribute(
|
||||||
propDescription->attribute.namespacePrefix,
|
propDescription->attribute.namespacePrefix,
|
||||||
|
@@ -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
|
OUString VCLDateHandler::getAttributeValue( const Any& i_propertyValue ) const
|
||||||
{
|
{
|
||||||
Date aDate;
|
Date aDate;
|
||||||
|
@@ -32,7 +32,6 @@ namespace xmloff
|
|||||||
VCLDateHandler();
|
VCLDateHandler();
|
||||||
|
|
||||||
// IPropertyHandler
|
// IPropertyHandler
|
||||||
virtual OUString getAttributeValue( const PropertyValues& i_propertyValues ) const override;
|
|
||||||
virtual OUString getAttributeValue( const css::uno::Any& i_propertyValue ) 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;
|
virtual bool getPropertyValues( const OUString& i_attributeValue, PropertyValues& o_propertyValues ) const override;
|
||||||
};
|
};
|
||||||
|
@@ -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
|
OUString VCLTimeHandler::getAttributeValue( const Any& i_propertyValue ) const
|
||||||
{
|
{
|
||||||
css::util::Time aTime;
|
css::util::Time aTime;
|
||||||
|
@@ -32,7 +32,6 @@ namespace xmloff
|
|||||||
VCLTimeHandler();
|
VCLTimeHandler();
|
||||||
|
|
||||||
// IPropertyHandler
|
// IPropertyHandler
|
||||||
virtual OUString getAttributeValue( const PropertyValues& i_propertyValues ) const override;
|
|
||||||
virtual OUString getAttributeValue( const css::uno::Any& i_propertyValue ) 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;
|
virtual bool getPropertyValues( const OUString& i_attributeValue, PropertyValues& o_propertyValues ) const override;
|
||||||
};
|
};
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
|
#define INCLUDED_XMLOFF_SOURCE_FORMS_PROPERTY_DESCRIPTION_HXX
|
||||||
|
|
||||||
#include <forms/property_handler.hxx>
|
#include <forms/property_handler.hxx>
|
||||||
#include "property_group.hxx"
|
|
||||||
|
|
||||||
#include <xmloff/xmltoken.hxx>
|
#include <xmloff/xmltoken.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -71,23 +69,12 @@ namespace xmloff
|
|||||||
const PropertyHandlerFactory factory;
|
const PropertyHandlerFactory factory;
|
||||||
/// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
|
/// the unique ID of the property. The property meta data table must not contain two entries with the same property ID
|
||||||
const PropertyId propertyId;
|
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()
|
PropertyDescription()
|
||||||
:propertyName()
|
:propertyName()
|
||||||
,attribute()
|
,attribute()
|
||||||
,factory( nullptr )
|
,factory( nullptr )
|
||||||
,propertyId( PID_INVALID )
|
,propertyId( PID_INVALID )
|
||||||
,propertyGroup( NO_GROUP )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,14 +83,12 @@ namespace xmloff
|
|||||||
const sal_uInt16 i_namespacePrefix,
|
const sal_uInt16 i_namespacePrefix,
|
||||||
const ::xmloff::token::XMLTokenEnum i_attributeToken,
|
const ::xmloff::token::XMLTokenEnum i_attributeToken,
|
||||||
const PropertyHandlerFactory i_factory,
|
const PropertyHandlerFactory i_factory,
|
||||||
const PropertyId i_propertyId,
|
const PropertyId i_propertyId
|
||||||
const PropertyGroup i_propertyGroup
|
|
||||||
)
|
)
|
||||||
:propertyName( i_propertyName )
|
:propertyName( i_propertyName )
|
||||||
,attribute( i_namespacePrefix, i_attributeToken )
|
,attribute( i_namespacePrefix, i_attributeToken )
|
||||||
,factory( i_factory )
|
,factory( i_factory )
|
||||||
,propertyId( i_propertyId )
|
,propertyId( i_propertyId )
|
||||||
,propertyGroup( i_propertyGroup )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -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: */
|
|
@@ -37,7 +37,7 @@ namespace xmloff { namespace metadata
|
|||||||
using namespace ::xmloff::token;
|
using namespace ::xmloff::token;
|
||||||
|
|
||||||
#define FORM_SINGLE_PROPERTY( id, att ) \
|
#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
|
//= property meta data
|
||||||
namespace
|
namespace
|
||||||
@@ -88,25 +88,6 @@ namespace xmloff { namespace metadata
|
|||||||
return s_propertyDescriptionsByName;
|
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;
|
typedef std::unordered_map< OUString, XMLTokenEnum > ReverseTokenLookup;
|
||||||
|
|
||||||
const ReverseTokenLookup& getReverseTokenLookup()
|
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;
|
typedef std::unordered_map< AttributeDescription, PropertyGroups, AttributeHash > AttributesWithoutGroup;
|
||||||
|
|
||||||
const AttributesWithoutGroup& lcl_getAttributesWithoutGroups()
|
const AttributesWithoutGroup& lcl_getAttributesWithoutGroups()
|
||||||
@@ -166,13 +128,10 @@ namespace xmloff { namespace metadata
|
|||||||
const PropertyDescription* desc = lcl_getPropertyMetaData();
|
const PropertyDescription* desc = lcl_getPropertyMetaData();
|
||||||
while ( !desc->propertyName.isEmpty() )
|
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;
|
++desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,48 +148,14 @@ namespace xmloff { namespace metadata
|
|||||||
return nullptr;
|
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 )
|
void getPropertyGroupList( const AttributeDescription& i_attribute, PropertyGroups& o_propertyGroups )
|
||||||
{
|
{
|
||||||
const AttributeGroups& rAttributeGroups = lcl_getAttributeGroups();
|
// the attribute is not used for any non-trivial group, which means it is mapped directly to
|
||||||
|
// a single property
|
||||||
::std::pair< AttributeGroups::const_iterator, AttributeGroups::const_iterator >
|
const AttributesWithoutGroup& attributesWithoutGroups( lcl_getAttributesWithoutGroups() );
|
||||||
range = rAttributeGroups.equal_range( i_attribute );
|
const AttributesWithoutGroup::const_iterator pos = attributesWithoutGroups.find( i_attribute );
|
||||||
|
if ( pos != attributesWithoutGroups.end() )
|
||||||
if ( range.first == range.second )
|
o_propertyGroups = pos->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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeDescription getAttributeDescription( const sal_uInt16 i_namespacePrefix, const OUString& i_attributeName )
|
AttributeDescription getAttributeDescription( const sal_uInt16 i_namespacePrefix, const OUString& i_attributeName )
|
||||||
|
@@ -27,16 +27,6 @@ namespace xmloff { namespace metadata
|
|||||||
|
|
||||||
const PropertyDescription* getPropertyDescription( const OUString& i_propertyName );
|
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
|
/** retrieves all known property groups which are mapped to the given attribute
|
||||||
*/
|
*/
|
||||||
void getPropertyGroupList(
|
void getPropertyGroupList(
|
||||||
|
Reference in New Issue
Block a user