24#include <rtl/ustrbuf.hxx>
51 mnFamily( nFamily ), maStrFamilyName(
std::move( aStrName)), mxMapper(
std::move( xMapper )),
52 mnCount( 0 ), mnName( 0 ), maStrPrefix(
std::move( aStrPrefix )), mbAsFamily( bAsFamily )
56 mnFamily(nFamily),
mnCount(0), mnName(0), mbAsFamily(false) {}
65 const typelib_TypeDescriptionReference *type);
71 assert(
type->eTypeClass == typelib_TypeClass_STRUCT);
73 OUStringBuffer
result(
"{");
75 const typelib_CompoundTypeDescription *compoundType =
76 &
reinterpret_cast<const typelib_StructTypeDescription*
>(
type)->aBase;
78 for (
int i = 0;
i < compoundType->nMembers;
i++)
83 OUString::unacquired(&compoundType->ppMemberNames[
i])
85 +
data2string(
static_cast<char *
>(data)+compoundType->pMemberOffsets[
i],
86 compoundType->ppTypeRefs[
i]));
91 return result.makeStringAndClear();
96 const typelib_TypeDescriptionReference *type)
98 switch (
type->eTypeClass)
100 case typelib_TypeClass_VOID:
102 case typelib_TypeClass_BOOLEAN:
103 return *
static_cast<const sal_Bool*
>(data) ? OUString(
"true") : OUString(
"false");
104 case typelib_TypeClass_BYTE:
105 return OUString::number(*
static_cast<const sal_Int8*
>(data));
106 case typelib_TypeClass_SHORT:
107 return OUString::number(*
static_cast<const sal_Int16*
>(data));
108 case typelib_TypeClass_LONG:
109 return OUString::number(*
static_cast<const sal_Int32*
>(data));
110 case typelib_TypeClass_HYPER:
111 return OUString::number(*
static_cast<const sal_Int64*
>(data));
112 case typelib_TypeClass_UNSIGNED_SHORT:
113 return OUString::number(*
static_cast<const sal_uInt16*
>(data));
114 case typelib_TypeClass_UNSIGNED_LONG:
115 return OUString::number((*
static_cast<const sal_uInt32*
>(data)), 16);
116 case typelib_TypeClass_UNSIGNED_HYPER:
117 return OUString::number((*
static_cast<const sal_uInt64*
>(data)), 16);
118 case typelib_TypeClass_FLOAT:
119 return OUString::number(*
static_cast<const float*
>(data));
120 case typelib_TypeClass_DOUBLE:
121 return OUString::number(*
static_cast<const double*
>(data));
122 case typelib_TypeClass_CHAR:
123 return (
"U+" + OUString::number(*
static_cast<const sal_uInt16*
>(data)));
124 case typelib_TypeClass_STRING:
125 return *
static_cast<OUString*
>(data);
126 case typelib_TypeClass_TYPE:
127 case typelib_TypeClass_SEQUENCE:
128 case typelib_TypeClass_EXCEPTION:
129 case typelib_TypeClass_INTERFACE:
131 case typelib_TypeClass_STRUCT:
133 case typelib_TypeClass_ENUM:
134 return OUString::number(*
static_cast<const sal_Int32*
>(data));
154 static bool bHack = (getenv(
"LIBO_ONEWAY_STABLE_ODF_EXPORT") !=
nullptr);
158 OUStringBuffer aStemBuffer(32);
161 if (!rParentName.isEmpty())
163 aStemBuffer.append(
"-" + rParentName);
169 if (rState.mnIndex == -1)
171 OUString sXMLName(rFamilyData.
mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex));
172 if (sXMLName.isEmpty())
176 + OUString::number(
static_cast<sal_Int32
>(rFamilyData.
mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex)))
186 aStemBuffer.append(
"-z");
187 static sal_Int32 nCounter = 0;
188 aStemBuffer.append(nCounter++));
195 bool bWarned =
false;
203 msName = aStemBuffer +
"-" + OUString::number(
static_cast<sal_Int64
>(rFamilyData.
mnName) );
219#if OSL_DEBUG_LEVEL > 0
220 std::set<sal_Int32> DebugProperties;
223 sal_Int32
const property(rPropState.mnIndex);
225 assert(DebugProperties.find(
property) == DebugProperties.end());
250 bool operator()(
const std::vector< XMLPropertyState >& lhs,
256 const std::vector< XMLPropertyState >& rhs )
const
272 for (
auto it = itBegin; it != itEnd; ++it)
273 if (rFamilyData.
mxMapper->Equals(it->GetProperties(), rProperties))
283 rName = pProperties->GetName();
303 it->SetName( rName );
315 for (
auto it = itBegin; it != itEnd; ++it)
316 if (rFamilyData.
mxMapper->Equals(it->GetProperties(), rProperties))
317 sName = it->GetName();
343 const OUString& rStrName,
345 const OUString& rStrPrefix,
352 OUString aPrefix( rStrPrefix );
355 aPrefix =
"M" + rStrPrefix;
358#if OSL_DEBUG_LEVEL > 0
366 "Adding duplicate family " << rStrName <<
367 " with mismatching mapper ! " <<
368 typeid(iter->mxMapper.get()).name() <<
" " <<
369 typeid(*rMapper).name() );
373 m_FamilySet.emplace(nFamily, rStrName, rMapper, aPrefix, bAsFamily);
409 uno::Sequence<sal_Int32>& rFamilies,
410 uno::Sequence<OUString>& rNames )
413 std::vector<sal_Int32> aFamilies;
414 std::vector<OUString> aNames;
420 for (
const auto& rName : rFamily.maNameSet)
422 aFamilies.push_back(
static_cast<sal_Int32
>(rFamily.mnFamily) );
423 aNames.push_back( rName );
428 assert(aFamilies.size() == aNames.size());
430 rFamilies.realloc( aFamilies.size() );
431 std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
433 rNames.realloc( aNames.size() );
434 std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
444 rFamily.mxMapper->GetEntryAPINames(aNames);
453 OUString& rName,
XmlStyleFamily nFamily,
const OUString& rParentName,
454 ::std::vector< XMLPropertyState >&& rProperties,
bool bDontSeek )
462 auto itPair = rFamily.
m_ParentSet.emplace(rParentName);
466 if (rParent.
Add(rFamily, std::move(rProperties), rName, bDontSeek))
476 const OUString& rName,
XmlStyleFamily nFamily,
const OUString& rParentName,
477 std::vector< XMLPropertyState >&& rProperties )
487 auto itPair = rFamily.
m_ParentSet.emplace(rParentName);
491 if (rParent.
AddNamed(rFamily, std::move(rProperties), rName))
505 const OUString& rParent,
506 const std::vector< XMLPropertyState >& rProperties )
const
519 sName = it2->Find(rFamily, rProperties);
527 std::vector<xmloff::AutoStyleEntry> rReturnVector;
536 rReturnVector.emplace_back();
540 if (rPropertyState.mnIndex >= 0)
542 OUString sXmlName = aPropertyMapper->GetEntryXMLName(rPropertyState.mnIndex);
549 return rReturnVector;
554struct AutoStylePoolExport
559 AutoStylePoolExport() :
mpParent(nullptr), mpProperties(nullptr) {}
562struct StyleComparator
564 bool operator() (
const AutoStylePoolExport& a,
const AutoStylePoolExport& b)
566 return (
a.mpProperties->GetName() < b.mpProperties->GetName() ||
567 (
a.mpProperties->GetName() == b.mpProperties->GetName() && *
a.mpParent < *b.mpParent));
590 std::vector<AutoStylePoolExport> aExpStyles(
nCount);
601 assert(!aExpStyles[
nPos].mpProperties);
607 static bool bHack = (getenv(
"LIBO_ONEWAY_STABLE_ODF_EXPORT") !=
nullptr);
612 std::sort(aExpStyles.begin(), aExpStyles.end(), StyleComparator());
616 OUString oldName = aExpStyles[
i].mpProperties->GetName();
617 sal_Int32 dashIx = oldName.indexOf(
'-');
618 OUString
newName = (dashIx > 0 ? oldName.copy(0, dashIx) : oldName) + OUString::number(
i);
619 aExpStyles[
i].mpProperties->SetName(
newName);
630 assert(aExpStyles[
i].mpProperties);
632 if( aExpStyles[
i].mpProperties )
636 aExpStyles[
i].mpProperties->GetName() );
638 bool bExtensionNamespace =
false;
643 if(aStrFamilyName !=
"graphic" &&
644 aStrFamilyName !=
"drawing-page" &&
645 aStrFamilyName !=
"presentation" &&
646 aStrFamilyName !=
"chart" )
647 bExtensionNamespace =
true;
665 aExpStyles[
i].mpProperties->GetProperties(),
673 sal_Int32 nStart(-1);
680 rFamily.
mxMapper->getPropertySetMapper();
681 sal_Int16 nContextID;
682 while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
684 nContextID = aPropMapper->GetEntryContextId(
nIndex );
695 aExpStyles[
i].mpProperties->GetProperties(),
699 aExpStyles[
i].mpProperties->GetProperties(),
void RegisterDefinedName(XmlStyleFamily nFamily, const OUString &rName)
OUString Find(XmlStyleFamily nFamily, const OUString &rParent, const ::std::vector< XMLPropertyState > &rProperties) const
void exportXML(XmlStyleFamily nFamily, const SvXMLAutoStylePoolP *pAntiImpl) const
void AddFamily(XmlStyleFamily nFamily, const OUString &rStrName, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper, const OUString &rStrPrefix, bool bAsFamily)
FamilySetType m_FamilySet
void SetFamilyPropSetMapper(XmlStyleFamily nFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper)
css::uno::Sequence< OUString > GetPropertyNames()
retrieve the names of the properties used in the styles
~SvXMLAutoStylePoolP_Impl()
bool AddNamed(const OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, std::vector< XMLPropertyState > &&rProperties)
SvXMLExport & GetExport() const
void GetRegisteredNames(css::uno::Sequence< sal_Int32 > &aFamilies, css::uno::Sequence< OUString > &aNames)
SvXMLAutoStylePoolP_Impl(SvXMLExport &rExport)
bool Add(OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, std::vector< XMLPropertyState > &&rProperties, bool bDontSeek=false)
std::vector< xmloff::AutoStyleEntry > GetAutoStyleEntries() const
void RegisterName(XmlStyleFamily nFamily, const OUString &rName)
virtual void exportStyleContent(const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler, XmlStyleFamily nFamily, const ::std::vector< XMLPropertyState > &rProperties, const SvXMLExportPropertyMapper &rPropExp, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const
virtual void exportStyleAttributes(comphelper::AttributeList &rAttrList, XmlStyleFamily nFamily, const ::std::vector< XMLPropertyState > &rProperties, const SvXMLExportPropertyMapper &rPropExp, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvXMLExportFlags getExportFlags() const
bool AddNamed(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, const OUString &rName)
bool Add(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, OUString &rName, bool bDontSeek)
~XMLAutoStylePoolParent()
const PropertiesListType & GetPropertiesList() const
bool operator<(const XMLAutoStylePoolParent &rOther) const
const OUString & GetParent() const
PropertiesListType m_PropertiesList
OUString Find(const XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties) const
const ::std::vector< XMLPropertyState > & GetProperties() const
XMLAutoStylePoolProperties(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, OUString const &rParentname)
::std::vector< XMLPropertyState > maProperties
sal_uInt32 GetPos() const
RegionData_Impl * mpParent
static OUString data2string(void *data, const typelib_TypeDescriptionReference *type)
bool operator<(const XMLAutoStyleFamily &r1, const XMLAutoStyleFamily &r2)
static OUString any2string(const uno::Any &any)
static OUString struct2string(void *data, const typelib_TypeDescription *type)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
struct _typelib_TypeDescription typelib_TypeDescription
SvGenericNameContainerMapImpl maProperties
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
rtl::Reference< SvXMLExportPropertyMapper > mxMapper
std::set< OUString > maReservedNameSet
std::set< OUString > maNameSet
XMLAutoStyleFamily(XmlStyleFamily nFamily, OUString aStrName, rtl::Reference< SvXMLExportPropertyMapper > xMapper, OUString aStrPrefix, bool bAsFamily)
ParentSetType m_ParentSet
Smart struct to transport an Any with an index to the appropriate property-name.
std::vector< std::pair< OUString, css::uno::Any > > m_aXmlProperties
constexpr sal_uInt16 XML_NAMESPACE_STYLE