/* -*- 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 .
*/
for (int i = 0; i < compoundType->nMembers; i++)
{ if (i > 0)
result.append(":");
result.append(
OUString::unacquired(&compoundType->ppMemberNames[i])
+ "="
+ data2string(static_cast<char *>(data)+compoundType->pMemberOffsets[i],
compoundType->ppTypeRefs[i]));
}
result.append("}");
return result.makeStringAndClear();
}
static OUString
data2string(void *data, const typelib_TypeDescriptionReference *type)
{ switch (type->eTypeClass)
{ case typelib_TypeClass_VOID: return u""_ustr; case typelib_TypeClass_BOOLEAN: return *static_cast<const sal_Bool*>(data) ? u"true"_ustr : u"false"_ustr; case typelib_TypeClass_BYTE: return OUString::number(*static_cast<const sal_Int8*>(data)); case typelib_TypeClass_SHORT: return OUString::number(*static_cast<const sal_Int16*>(data)); case typelib_TypeClass_LONG: return OUString::number(*static_cast<const sal_Int32*>(data)); case typelib_TypeClass_HYPER: return OUString::number(*static_cast<const sal_Int64*>(data)); case typelib_TypeClass_UNSIGNED_SHORT: return OUString::number(*static_cast<const sal_uInt16*>(data)); case typelib_TypeClass_UNSIGNED_LONG: return OUString::number((*static_cast<const sal_uInt32*>(data)), 16); case typelib_TypeClass_UNSIGNED_HYPER: return OUString::number((*static_cast<const sal_uInt64*>(data)), 16); case typelib_TypeClass_FLOAT: return OUString::number(*static_cast<constfloat*>(data)); case typelib_TypeClass_DOUBLE: return OUString::number(*static_cast<constdouble*>(data)); case typelib_TypeClass_CHAR: return ("U+" + OUString::number(*static_cast<const sal_uInt16*>(data))); case typelib_TypeClass_STRING: return *static_cast<OUString*>(data); case typelib_TypeClass_TYPE: case typelib_TypeClass_SEQUENCE: case typelib_TypeClass_EXCEPTION: case typelib_TypeClass_INTERFACE: return u"wtf"_ustr; case typelib_TypeClass_STRUCT: return struct2string(data, type->pType); case typelib_TypeClass_ENUM: return OUString::number(*static_cast<const sal_Int32*>(data)); default:
assert(false); // this cannot happen I hope break;
} return u""_ustr;
}
if (bHack)
{
OUStringBuffer aStemBuffer(32);
aStemBuffer.append( rFamilyData.maStrPrefix );
if (!rParentName.isEmpty())
{
aStemBuffer.append("-" + rParentName);
}
// Create a name based on the properties used for(XMLPropertyState const & rState : maProperties)
{ if (rState.mnIndex == -1) continue;
OUString sXMLName(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex)); if (sXMLName.isEmpty()) continue;
aStemBuffer.append( "-"
+ OUString::number(static_cast<sal_Int32>(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex)))
+ ":"
+ sXMLName
+ "="
+ any2string(rState.maValue));
}
#if 0 // Finally append an incremental counter in an attempt to make identical // styles always come out in the same order. Will see if this works.
aStemBuffer.append("-z"); static sal_Int32 nCounter = 0;
aStemBuffer.append(nCounter++)); #endif
// create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again
msName = aStemBuffer; bool bWarned = false; while (rFamilyData.maNameSet.find(msName) !=
rFamilyData.maNameSet.end())
{ if (!bWarned)
SAL_WARN("xmloff", "Overlapping style name for " << msName);
bWarned = true;
rFamilyData.mnName++;
msName = aStemBuffer + "-" + OUString::number( static_cast<sal_Int64>(rFamilyData.mnName) );
}
rFamilyData.maNameSet.insert(msName);
} else
{ // create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again do
{
rFamilyData.mnName++;
msName = rFamilyData.maStrPrefix + OUString::number( static_cast<sal_Int64>(rFamilyData.mnName) );
} while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end() || rFamilyData.maReservedNameSet.find(msName) != rFamilyData.maReservedNameSet.end());
}
#if OSL_DEBUG_LEVEL > 0
std::set<sal_Int32> DebugProperties; for (XMLPropertyState const & rPropState : maProperties)
{
sal_Int32 const property(rPropState.mnIndex); // serious bug: will cause duplicate attributes to be exported
assert(DebugProperties.find(property) == DebugProperties.end()); if (-1 != property)
{
DebugProperties.insert(property);
}
} #endif
}
// Adds an array of XMLPropertyState ( std::vector< XMLPropertyState > ) with a given name. // If the name exists already, nothing is done. If a style with a different name and // the same properties exists, a new one is added (like with bDontSeek).
// Adds a name to list void SvXMLAutoStylePoolP_Impl::RegisterName( XmlStyleFamily nFamily, const OUString& rName )
{
XMLAutoStyleFamily aTemp(nFamily); autoconst iter = m_FamilySet.find(aTemp);
assert(iter != m_FamilySet.end()); // family must be known const_cast<XMLAutoStyleFamily&>(*iter).maNameSet.insert(rName);
}
// Adds a name to list void SvXMLAutoStylePoolP_Impl::RegisterDefinedName( XmlStyleFamily nFamily, const OUString& rName )
{
XMLAutoStyleFamily aTemp(nFamily); autoconst iter = m_FamilySet.find(aTemp);
assert(iter != m_FamilySet.end()); // family must be known const_cast<XMLAutoStyleFamily&>(*iter).maReservedNameSet.insert(rName);
}
bool SvXMLAutoStylePoolP_Impl::AddNamed( const OUString& rName, XmlStyleFamily nFamily, const OUString& rParentName,
std::vector< XMLPropertyState >&& rProperties )
{ // get family and parent the same way as in Add()
XMLAutoStyleFamily aTemp(nFamily); autoconst iter = m_FamilySet.find(aTemp);
assert(iter != m_FamilySet.end()); // family must be known
void SvXMLAutoStylePoolP_Impl::exportXML(
XmlStyleFamily nFamily, const SvXMLAutoStylePoolP *pAntiImpl) const
{ // Get list of parents for current family (nFamily)
XMLAutoStyleFamily aTemp(nFamily); autoconst iter = m_FamilySet.find(aTemp);
assert(iter != m_FamilySet.end()); // family must be known
// create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl) // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
std::vector<AutoStylePoolExport> aExpStyles(nCount);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.