23#include <rtl/ustrbuf.hxx>
50 mnFamily( nFamily ), maStrFamilyName(
std::move( aStrName)), mxMapper(
std::move( xMapper )),
51 mnCount( 0 ), mnName( 0 ), maStrPrefix(
std::move( aStrPrefix )), mbAsFamily( bAsFamily )
55 mnFamily(nFamily),
mnCount(0), mnName(0), mbAsFamily(false) {}
64 const typelib_TypeDescriptionReference *type);
70 assert(
type->eTypeClass == typelib_TypeClass_STRUCT);
72 OUStringBuffer
result(
"{");
74 const typelib_CompoundTypeDescription *compoundType =
75 &
reinterpret_cast<const typelib_StructTypeDescription*
>(
type)->aBase;
77 for (
int i = 0;
i < compoundType->nMembers;
i++)
82 OUString::unacquired(&compoundType->ppMemberNames[
i])
84 +
data2string(
static_cast<char *
>(data)+compoundType->pMemberOffsets[
i],
85 compoundType->ppTypeRefs[
i]));
90 return result.makeStringAndClear();
95 const typelib_TypeDescriptionReference *type)
97 switch (
type->eTypeClass)
99 case typelib_TypeClass_VOID:
101 case typelib_TypeClass_BOOLEAN:
102 return *
static_cast<const sal_Bool*
>(data) ? OUString(
"true") : OUString(
"false");
103 case typelib_TypeClass_BYTE:
104 return OUString::number(*
static_cast<const sal_Int8*
>(data));
105 case typelib_TypeClass_SHORT:
106 return OUString::number(*
static_cast<const sal_Int16*
>(data));
107 case typelib_TypeClass_LONG:
108 return OUString::number(*
static_cast<const sal_Int32*
>(data));
109 case typelib_TypeClass_HYPER:
110 return OUString::number(*
static_cast<const sal_Int64*
>(data));
111 case typelib_TypeClass_UNSIGNED_SHORT:
112 return OUString::number(*
static_cast<const sal_uInt16*
>(data));
113 case typelib_TypeClass_UNSIGNED_LONG:
114 return OUString::number((*
static_cast<const sal_uInt32*
>(data)), 16);
115 case typelib_TypeClass_UNSIGNED_HYPER:
116 return OUString::number((*
static_cast<const sal_uInt64*
>(data)), 16);
117 case typelib_TypeClass_FLOAT:
118 return OUString::number(*
static_cast<const float*
>(data));
119 case typelib_TypeClass_DOUBLE:
120 return OUString::number(*
static_cast<const double*
>(data));
121 case typelib_TypeClass_CHAR:
122 return (
"U+" + OUString::number(*
static_cast<const sal_uInt16*
>(data)));
123 case typelib_TypeClass_STRING:
124 return *
static_cast<OUString*
>(data);
125 case typelib_TypeClass_TYPE:
126 case typelib_TypeClass_SEQUENCE:
127 case typelib_TypeClass_EXCEPTION:
128 case typelib_TypeClass_INTERFACE:
130 case typelib_TypeClass_STRUCT:
132 case typelib_TypeClass_ENUM:
133 return OUString::number(*
static_cast<const sal_Int32*
>(data));
153 static bool bHack = (getenv(
"LIBO_ONEWAY_STABLE_ODF_EXPORT") !=
nullptr);
157 OUStringBuffer aStemBuffer(32);
160 if (!rParentName.isEmpty())
162 aStemBuffer.append(
"-" + rParentName);
168 if (rState.mnIndex == -1)
170 OUString sXMLName(rFamilyData.
mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex));
171 if (sXMLName.isEmpty())
175 + OUString::number(
static_cast<sal_Int32
>(rFamilyData.
mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex)))
185 aStemBuffer.append(
"-z");
186 static sal_Int32 nCounter = 0;
187 aStemBuffer.append(nCounter++));
194 bool bWarned =
false;
202 msName = aStemBuffer +
"-" + OUString::number(
static_cast<sal_Int64
>(rFamilyData.
mnName) );
218#if OSL_DEBUG_LEVEL > 0
219 std::set<sal_Int32> DebugProperties;
222 sal_Int32
const property(rPropState.mnIndex);
224 assert(DebugProperties.find(
property) == DebugProperties.end());
249 bool operator()(
const std::vector< XMLPropertyState >& lhs,
255 const std::vector< XMLPropertyState >& rhs )
const
271 for (
auto it = itBegin; it != itEnd; ++it)
272 if (rFamilyData.
mxMapper->Equals(it->GetProperties(), rProperties))
282 rName = pProperties->GetName();
302 it->SetName( rName );
314 for (
auto it = itBegin; it != itEnd; ++it)
315 if (rFamilyData.
mxMapper->Equals(it->GetProperties(), rProperties))
316 sName = it->GetName();
342 const OUString& rStrName,
344 const OUString& rStrPrefix,
351 OUString aPrefix( rStrPrefix );
354 aPrefix =
"M" + rStrPrefix;
357#if OSL_DEBUG_LEVEL > 0
365 "Adding duplicate family " << rStrName <<
366 " with mismatching mapper ! " <<
367 typeid(iter->mxMapper.get()).name() <<
" " <<
368 typeid(*rMapper).name() );
372 m_FamilySet.emplace(nFamily, rStrName, rMapper, aPrefix, bAsFamily);
408 uno::Sequence<sal_Int32>& rFamilies,
409 uno::Sequence<OUString>& rNames )
412 std::vector<sal_Int32> aFamilies;
413 std::vector<OUString> aNames;
419 for (
const auto& rName : rFamily.maNameSet)
421 aFamilies.push_back(
static_cast<sal_Int32
>(rFamily.mnFamily) );
422 aNames.push_back( rName );
427 assert(aFamilies.size() == aNames.size());
429 rFamilies.realloc( aFamilies.size() );
430 std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
432 rNames.realloc( aNames.size() );
433 std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
440 OUString& rName,
XmlStyleFamily nFamily,
const OUString& rParentName,
441 ::std::vector< XMLPropertyState >&& rProperties,
bool bDontSeek )
449 auto itPair = rFamily.
m_ParentSet.emplace(rParentName);
453 if (rParent.
Add(rFamily, std::move(rProperties), rName, bDontSeek))
463 const OUString& rName,
XmlStyleFamily nFamily,
const OUString& rParentName,
464 std::vector< XMLPropertyState >&& rProperties )
474 auto itPair = rFamily.
m_ParentSet.emplace(rParentName);
478 if (rParent.
AddNamed(rFamily, std::move(rProperties), rName))
492 const OUString& rParent,
493 const std::vector< XMLPropertyState >& rProperties )
const
506 sName = it2->Find(rFamily, rProperties);
514 std::vector<xmloff::AutoStyleEntry> rReturnVector;
523 rReturnVector.emplace_back();
527 if (rPropertyState.mnIndex >= 0)
529 OUString sXmlName = aPropertyMapper->GetEntryXMLName(rPropertyState.mnIndex);
536 return rReturnVector;
541struct AutoStylePoolExport
546 AutoStylePoolExport() :
mpParent(nullptr), mpProperties(nullptr) {}
549struct StyleComparator
551 bool operator() (
const AutoStylePoolExport& a,
const AutoStylePoolExport& b)
553 return (
a.mpProperties->GetName() < b.mpProperties->GetName() ||
554 (
a.mpProperties->GetName() == b.mpProperties->GetName() && *
a.mpParent < *b.mpParent));
577 std::vector<AutoStylePoolExport> aExpStyles(
nCount);
588 assert(!aExpStyles[
nPos].mpProperties);
594 static bool bHack = (getenv(
"LIBO_ONEWAY_STABLE_ODF_EXPORT") !=
nullptr);
599 std::sort(aExpStyles.begin(), aExpStyles.end(), StyleComparator());
603 OUString oldName = aExpStyles[
i].mpProperties->GetName();
604 sal_Int32 dashIx = oldName.indexOf(
'-');
605 OUString
newName = (dashIx > 0 ? oldName.copy(0, dashIx) : oldName) + OUString::number(
i);
606 aExpStyles[
i].mpProperties->SetName(
newName);
617 assert(aExpStyles[
i].mpProperties);
619 if( aExpStyles[
i].mpProperties )
623 aExpStyles[
i].mpProperties->GetName() );
625 bool bExtensionNamespace =
false;
630 if(aStrFamilyName !=
"graphic" &&
631 aStrFamilyName !=
"drawing-page" &&
632 aStrFamilyName !=
"presentation" &&
633 aStrFamilyName !=
"chart" )
634 bExtensionNamespace =
true;
652 aExpStyles[
i].mpProperties->GetProperties(),
660 sal_Int32 nStart(-1);
667 rFamily.
mxMapper->getPropertySetMapper();
668 sal_Int16 nContextID;
669 while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
671 nContextID = aPropMapper->GetEntryContextId(
nIndex );
682 aExpStyles[
i].mpProperties->GetProperties(),
686 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)
~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
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