Files
libreoffice/xmloff/source/core/SvXMLAttrCollection.cxx
Gabor Kelemen 0132f27d4e Add missing sal/log.hxx headers
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it.
This is a continuation of commit 6ff2d84ade to be able to remove those unneeded includes.

This commit adds missing headers to every file found by:
grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG')
to directories w* x*

Change-Id: I27bff44da3d34d24262031c7489e755311599bc5
Reviewed-on: https://gerrit.libreoffice.org/57307
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-07-12 10:40:25 +02:00

182 lines
5.1 KiB
C++

/* -*- 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 "SvXMLAttrCollection.hxx"
#include <limits.h>
#include <osl/diagnose.h>
#include <sal/log.hxx>
bool SvXMLAttrCollection::operator ==( const SvXMLAttrCollection& rCmp ) const
{
return (rCmp.aNamespaceMap == aNamespaceMap) &&
(rCmp.aAttrs == aAttrs);
}
bool SvXMLAttrCollection::AddAttr( const OUString& rLName,
const OUString& rValue )
{
assert(!rLName.isEmpty());
aAttrs.emplace_back(rLName, rValue );
return true;
}
bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rNamespace,
const OUString& rLName,
const OUString& rValue )
{
assert(!rPrefix.isEmpty());
assert(!rNamespace.isEmpty());
assert(!rLName.isEmpty());
sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
aAttrs.emplace_back(nPos, rLName, rValue );
return true;
}
bool SvXMLAttrCollection::AddAttr( const OUString& rPrefix,
const OUString& rLName,
const OUString& rValue )
{
assert(!rPrefix.isEmpty());
assert(!rLName.isEmpty());
sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
if( USHRT_MAX == nPos )
return false;
aAttrs.emplace_back(nPos, rLName, rValue );
return true;
}
bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rLName,
const OUString& rValue )
{
assert(!rLName.isEmpty());
if( i >= GetAttrCount() )
return false;
aAttrs[i] = SvXMLAttr(rLName, rValue);
return true;
}
bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rPrefix,
const OUString& rNamespace,
const OUString& rLName,
const OUString& rValue )
{
assert(!rPrefix.isEmpty());
assert(!rNamespace.isEmpty());
assert(!rLName.isEmpty());
if( i >= GetAttrCount() )
return false;
sal_uInt16 nPos = aNamespaceMap.Add( rPrefix, rNamespace );
if( USHRT_MAX == nPos )
return false;
aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
return true;
}
bool SvXMLAttrCollection::SetAt( size_t i,
const OUString& rPrefix,
const OUString& rLName,
const OUString& rValue )
{
assert(!rPrefix.isEmpty());
assert(!rLName.isEmpty());
if( i >= GetAttrCount() )
return false;
sal_uInt16 nPos = aNamespaceMap.GetIndexByPrefix( rPrefix );
if( USHRT_MAX == nPos )
return false;
aAttrs[i] = SvXMLAttr(nPos, rLName, rValue);
return true;
}
void SvXMLAttrCollection::Remove( size_t i )
{
if( i < GetAttrCount() )
{
aAttrs.erase( aAttrs.begin() + i );
}
else
{
OSL_FAIL( "illegal index" );
}
}
size_t SvXMLAttrCollection::GetAttrCount() const
{
return aAttrs.size();
}
const OUString& SvXMLAttrCollection::GetAttrLName(size_t i) const
{
OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetLName: illegal index" );
return aAttrs[i].getLName();
}
const OUString& SvXMLAttrCollection::GetAttrValue(size_t i) const
{
OSL_ENSURE( i < aAttrs.size(), "SvXMLAttrContainerData::GetValue: illegal index" );
return aAttrs[i].getValue();
}
const OUString SvXMLAttrCollection::GetAttrNamespace( size_t i ) const
{
OUString sRet;
sal_uInt16 nPos = GetPrefixPos( i );
//Does this point to a valid namespace entry?
if( USHRT_MAX != nPos )
sRet = aNamespaceMap.GetNameByIndex( nPos );
return sRet;
}
const OUString SvXMLAttrCollection::GetAttrPrefix( size_t i ) const
{
OUString sRet;
sal_uInt16 nPos = GetPrefixPos( i );
//Does this point to a valid namespace entry?
if( USHRT_MAX != nPos )
sRet = aNamespaceMap.GetPrefixByIndex( nPos );
return sRet;
}
const OUString& SvXMLAttrCollection::GetNamespace( sal_uInt16 i ) const
{
return aNamespaceMap.GetNameByIndex( i );
}
const OUString& SvXMLAttrCollection::GetPrefix( sal_uInt16 i ) const
{
return aNamespaceMap.GetPrefixByIndex( i );
}
sal_uInt16 SvXMLAttrCollection::GetFirstNamespaceIndex() const
{
return aNamespaceMap.GetFirstIndex();
}
sal_uInt16 SvXMLAttrCollection::GetNextNamespaceIndex( sal_uInt16 nIdx ) const
{
return aNamespaceMap.GetNextIndex( nIdx );
}
sal_uInt16 SvXMLAttrCollection::GetPrefixPos( size_t i ) const
{
// SAL_WARN_IF( i < 0 || i >= aAttrs.size()), "xmloff",
// "SvXMLAttrCollection::GetPrefixPos: illegal index" );
return aAttrs[i].getPrefixPos();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */