24#include <rtl/ustrbuf.hxx>
32StyleContainer::StyleContainer() :
50 std::unordered_map< HashedStyle, sal_Int32, StyleHash >::iterator it =
67 rNew.
style = aSearchStyle;
79 aProps[
"style:family" ] = OStringToOUString( rName, RTL_TEXTENCODING_UTF8 );
80 aProps[
"style:name" ] =
"standard";
82 Style aStyle(
"style:style", std::move(aProps) );
88 std::unordered_map< sal_Int32, RefCountedHashedStyle >::const_iterator it =
90 return it !=
m_aIdToStyle.end() ? &(it->second.style.Properties) :
nullptr;
96 std::unordered_map< sal_Int32, RefCountedHashedStyle >::iterator it =
100 if( it->second.RefCount == 1 )
106 it->second.style.Properties = std::move(rNewProps);
113 it->second.RefCount--;
116 aSearchStyle.
Name = it->second.style.Name;
117 aSearchStyle.
Properties = std::move(rNewProps);
118 aSearchStyle.
Contents = it->second.style.Contents;
120 aSearchStyle.
SubStyles = it->second.style.SubStyles;
121 aSearchStyle.
IsSubStyle = it->second.style.IsSubStyle;
124 std::unordered_map< HashedStyle, sal_Int32, StyleHash >::iterator new_it =
128 nRet = new_it->second;
136 rNew.
style = aSearchStyle;
148 OUStringBuffer aRet( 64 );
150 std::unordered_map< sal_Int32, RefCountedHashedStyle >::const_iterator style_it =
154 const HashedStyle& rStyle = style_it->second.style;
156 PropertyMap::const_iterator name_it = rStyle.
Properties.find(
"style:name" );
158 aRet.append( name_it->second );
161 PropertyMap::const_iterator fam_it = rStyle.
Properties.find(
"style:family" );
165 aStyleName = fam_it->second;
168 aStyleName = OStringToOUString( rStyle.
Name, RTL_TEXTENCODING_ASCII_US );
169 sal_Int32
nIndex = aStyleName.lastIndexOf(
':' );
170 aRet.append( aStyleName.subView(
nIndex+1) + OUString::number( nStyle ) );
175 aRet.append(
"invalid style id " + OUString::number(nStyle) );
178 return aRet.makeStringAndClear();
185 std::unordered_map< sal_Int32, RefCountedHashedStyle >::const_iterator it =
m_aIdToStyle.find( nStyleId );
193 if (rStyle.
Name ==
"draw:stroke-dash")
194 aProps[
"draw:name" ] = aProps[
"style:name" ];
197 for(sal_Int32 nSubStyle : rStyle.
SubStyles)
203 std::list<std::unique_ptr<Element>>::iterator() );
210 std::vector< sal_Int32 > aMasterPageSection, aAutomaticStyleSection, aOfficeStyleSection;
213 if( ! rEntry.second.style.IsSubStyle )
215 if( rEntry.second.style.Name ==
"style:master-page" )
216 aMasterPageSection.push_back( rEntry.first );
218 aOfficeStyleSection.push_back( rEntry.first );
220 aAutomaticStyleSection.push_back( rEntry.first );
224 if( ! aMasterPageSection.empty() )
226 if( ! aAutomaticStyleSection.empty() )
228 if( ! aOfficeStyleSection.empty() )
234 impl_emitStyle( aOfficeStyleSection[
n], rContext, rContainedElemVisitor );
238 impl_emitStyle( aAutomaticStyleSection[
n], rContext, rContainedElemVisitor );
242 impl_emitStyle( aMasterPageSection[
n], rContext, rContainedElemVisitor );
void emit(EmitContext &rContext, ElementTreeVisitor &rContainedElemVisitor)
sal_Int32 setProperties(sal_Int32 nStyleId, PropertyMap &&rNewProps)
OUString getStyleName(sal_Int32 nStyle) const
sal_Int32 impl_getStyleId(const Style &rStyle, bool bSubStyle)
const PropertyMap * getProperties(sal_Int32 nStyleId) const
sal_Int32 getStandardStyleId(std::string_view rFamily)
std::unordered_map< HashedStyle, sal_Int32, StyleHash > m_aStyleToId
std::unordered_map< sal_Int32, RefCountedHashedStyle > m_aIdToStyle
void impl_emitStyle(sal_Int32 nStyleId, EmitContext &rContext, ElementTreeVisitor &rContainedElemVisitor)
sal_Int32 getStyleId(const Style &rStyle)
virtual void write(const OUString &rString)=0
Write PCTEXT as-is to output.
virtual void endTag(const char *pTag)=0
Close previously opened tag.
virtual void beginTag(const char *pTag, const PropertyMap &rProperties)=0
Open up a tag with the given properties.
std::unordered_map< OUString, OUString > PropertyMap
To be visited by all tree element types.
virtual void visitedBy(ElementTreeVisitor &, const std::list< std::unique_ptr< Element > >::const_iterator &rParentIt)=0
To be implemented by every tree node that needs to be visitable.
Element * ContainedElement
std::vector< sal_Int32 > SubStyles
std::vector< Style * > SubStyles
Element * ContainedElement