24 #include <rtl/ustrbuf.hxx>
27 #include <string_view>
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) );
171 aRet.append( nStyle );
176 aRet.append(
"invalid style id " );
177 aRet.append( nStyle );
180 return aRet.makeStringAndClear();
187 std::unordered_map< sal_Int32, RefCountedHashedStyle >::const_iterator it =
m_aIdToStyle.find( nStyleId );
195 if (rStyle.
Name ==
"draw:stroke-dash")
196 aProps[
"draw:name" ] = aProps[
"style:name" ];
199 for(sal_Int32 nSubStyle : rStyle.
SubStyles)
205 std::list<std::unique_ptr<Element>>::iterator() );
212 std::vector< sal_Int32 > aMasterPageSection, aAutomaticStyleSection, aOfficeStyleSection;
215 if( ! rEntry.second.style.IsSubStyle )
217 if( rEntry.second.style.Name ==
"style:master-page" )
218 aMasterPageSection.push_back( rEntry.first );
220 aOfficeStyleSection.push_back( rEntry.first );
222 aAutomaticStyleSection.push_back( rEntry.first );
226 if( ! aMasterPageSection.empty() )
227 std::stable_sort( aMasterPageSection.begin(), aMasterPageSection.end(),
StyleIdNameSort(&m_aIdToStyle) );
228 if( ! aAutomaticStyleSection.empty() )
229 std::stable_sort( aAutomaticStyleSection.begin(), aAutomaticStyleSection.end(),
StyleIdNameSort(&m_aIdToStyle) );
230 if( ! aOfficeStyleSection.empty() )
231 std::stable_sort( aOfficeStyleSection.begin(), aOfficeStyleSection.end(),
StyleIdNameSort(&m_aIdToStyle) );
236 impl_emitStyle( aOfficeStyleSection[n], rContext, rContainedElemVisitor );
239 for( n = 0, nElements = aAutomaticStyleSection.size(); n < nElements; n++ )
240 impl_emitStyle( aAutomaticStyleSection[n], rContext, rContainedElemVisitor );
243 for( n = 0, nElements = aMasterPageSection.size(); n < nElements; n++ )
244 impl_emitStyle( aMasterPageSection[n], rContext, rContainedElemVisitor );
std::unordered_map< OUString, OUString > PropertyMap
std::vector< Style * > SubStyles
std::unordered_map< HashedStyle, sal_Int32, StyleHash > m_aStyleToId
virtual void beginTag(const char *pTag, const PropertyMap &rProperties)=0
Open up a tag with the given properties.
sal_Int32 impl_getStyleId(const Style &rStyle, bool bSubStyle)
Element * ContainedElement
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
To be visited by all tree element types.
const PropertyMap * getProperties(sal_Int32 nStyleId) const
friend struct StyleIdNameSort
OUString getStyleName(sal_Int32 nStyle) const
sal_Int32 setProperties(sal_Int32 nStyleId, PropertyMap &&rNewProps)
sal_Int32 getStandardStyleId(std::string_view rFamily)
void impl_emitStyle(sal_Int32 nStyleId, EmitContext &rContext, ElementTreeVisitor &rContainedElemVisitor)
sal_Int32 getStyleId(const Style &rStyle)
void emit(EmitContext &rContext, ElementTreeVisitor &rContainedElemVisitor)
std::unordered_map< sal_Int32, RefCountedHashedStyle > m_aIdToStyle
virtual void write(const OUString &rString)=0
Write PCTEXT as-is to output.
virtual void endTag(const char *pTag)=0
Close previously opened tag.