22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
26 #include <com/sun/star/style/XAutoStylesSupplier.hpp>
27 #include <com/sun/star/style/XAutoStyleFamily.hpp>
54 #include <string_view>
109 mbDefaultStyle( bDefault )
119 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
148 class SvXMLStyleIndex_Impl
157 SvXMLStyleIndex_Impl(
XmlStyleFamily nFam,
const OUString& rName ) :
165 sName( rStl->GetName() ),
166 nFamily( rStl->GetFamily() ),
167 mpStyle ( rStl.
get() )
171 const OUString& GetName()
const {
return sName; }
176 struct SvXMLStyleIndexCmp_Impl
178 bool operator()(
const SvXMLStyleIndex_Impl& r1,
const SvXMLStyleIndex_Impl& r2)
const
182 if( r1.GetFamily() < r2.GetFamily() )
184 else if( r1.GetFamily() > r2.GetFamily() )
187 nRet = r1.GetName().compareTo( r2.GetName() );
197 typedef std::set<SvXMLStyleIndex_Impl, SvXMLStyleIndexCmp_Impl>
IndicesType;
199 std::vector<rtl::Reference<SvXMLStyleContext>>
aStyles;
203 #if OSL_DEBUG_LEVEL > 0
216 return i < aStyles.size() ? aStyles[ i ].get() :
nullptr;
223 const OUString& rName,
224 bool bCreateIndex )
const;
229 bAutomaticStyle( bAuto )
230 #
if OSL_DEBUG_LEVEL > 0
231 , m_nIndexCreated( 0 )
237 #if OSL_DEBUG_LEVEL > 0
254 const OUString& rName,
255 bool bCreateIndex )
const
263 #if OSL_DEBUG_LEVEL > 0
265 "Performance warning: sdbcx::Index created multiple times");
272 SvXMLStyleIndex_Impl
aIndex( nFamily, rName );
273 IndicesType::iterator aFind =
pIndices->find(aIndex);
275 pStyle = aFind->GetStyle();
279 for(
size_t i = 0; !pStyle &&
i <
aStyles.size();
i++ )
293 return mpImpl->GetStyleCount();
298 return mpImpl->GetStyle( i );
303 return mpImpl->GetStyle( i );
308 return mpImpl->IsAutomaticStyle();
313 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList)
411 const uno::Reference< xml::sax::XFastAttributeList > & )
443 const uno::Reference< xml::sax::XFastAttributeList > & )
523 ->GetParaImportPropertySetMapper();
533 ->GetTextImportPropertySetMapper();
543 GetSectionImportPropertySetMapper();
551 GetRubyImportPropertySetMapper();
561 aImpHelper->GetPropertySetMapper();
580 const_cast<SvXMLStylesContext*>(
this)->
GetImport() );
592 Reference < XAutoStyleFamily > xAutoStyles;
602 OUString
sName(bPara ? std::u16string_view(
u"ParagraphStyles" ): std::u16string_view(
u"CharacterStyles" ));
603 Reference< XAutoStylesSupplier > xAutoStylesSupp(
GetImport().GetModel(), UNO_QUERY );
604 Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles();
605 if (xAutoStyleFamilies->hasByName(sName))
607 Any aAny = xAutoStyleFamilies->getByName( sName );
608 aAny >>= xAutoStyles;
622 Reference < XNameContainer > xStyles;
630 sName =
"ParagraphStyles";
637 sName =
"CharacterStyles";
641 if( !xStyles.is() && !sName.isEmpty() )
643 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
645 if ( xFamiliesSupp.is() )
648 if (xFamilies->hasByName(sName))
650 xStyles.set(xFamilies->getByName( sName ),uno::UNO_QUERY);
698 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
705 mpImpl->AddStyle( pStyle );
714 mpImpl->AddStyle( &rNew );
726 for( i = 0; i < nCount; i++ )
744 for( i = 0; i < nCount; i++ )
759 for( i=0; i<nCount; i++ )
777 for( sal_uInt32
i=0;
i<nCount;
i++ )
784 pStyle->
Finish( bOverwrite );
790 const OUString& rName,
791 bool bCreateIndex )
const
793 return mpImpl->FindStyleChildContext( nFamily, rName, bCreateIndex );
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
virtual SvXMLStyleContext * CreateStyleChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XmlStyleFamily GetFamily() const
std::set< SvXMLStyleIndex_Impl, SvXMLStyleIndexCmp_Impl > IndicesType
bool IsAutomaticStyle() const
void CopyAutoStylesToDoc()
std::vector< rtl::Reference< SvXMLStyleContext > > aStyles
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex) const
size_t GetStyleCount() const
css::uno::Reference< css::container::XNameContainer > mxParaStyles
SvXMLImport & GetImport()
SvXMLStyleContext * GetStyle(sal_uInt32 i)
css::uno::Reference< css::style::XAutoStyleFamily > GetAutoStyles(XmlStyleFamily nFamily) const
bool IsDefaultStyle() const
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
SvXMLNumFmtHelper * GetDataStylesImport()
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
SvXMLStyleContext * CreateChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, SvXMLStylesContext &rStyles)
virtual ~SvXMLStyleContext() override
void AddStyle(SvXMLStyleContext *pStyle)
virtual ~SvXMLStylesContext() override
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
#define XML_STYLE_FAMILY_SCH_CHART_NAME
virtual void Finish(bool bOverwrite)
static XmlStyleFamily GetFamily(std::u16string_view rFamily)
SvXMLStyleContext * GetStyle(size_t i)
#define XML_STYLE_FAMILY_SD_PRESENTATION_NAME
bool IsAutomaticStyle() const
css::uno::Any const & rValue
sal_uInt32 m_nIndexCreated
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
constexpr OUStringLiteral sServiceName
static OUString getPrefixAndNameFromToken(sal_Int32 nToken)
#define XML_STYLE_FAMILY_SD_GRAPHICS_NAME
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
#define XML_STYLE_FAMILY_SD_POOL_NAME
SvXMLStylesContext_Impl(bool bAuto)
void CopyStylesToDoc(bool bOverwrite, bool bFinish=true)
std::unique_ptr< IndicesType > pIndices
virtual SvXMLStyleContext * CreateDefaultStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue)
virtual bool IsTransient() const
if this method returns true, its parent styles context should not add it to its container.
constexpr OUStringLiteral gsParaStyleServiceName(u"com.sun.star.style.ParagraphStyle")
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
virtual void SetDefaults()
constexpr OUStringLiteral gsTextStyleServiceName(u"com.sun.star.style.CharacterStyle")
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
virtual bool InsertStyleFamily(XmlStyleFamily nFamily) const
#define XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME
virtual OUString GetServiceName(XmlStyleFamily nFamily) const
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
This class deliberately does not support XWeak, to improve performance when loading large documents...
SvXMLStyleContext(SvXMLImport &rImport, XmlStyleFamily nFamily=XmlStyleFamily::DATA_STYLE, bool bDefaultStyle=false)
virtual void CreateAndInsert(bool bOverwrite)
std::deque< AttacherIndex_Impl > aIndex
SvXMLStylesContext(SvXMLStylesContext const &)=delete
#define SAL_WARN_IF(condition, area, stream)
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
const OUString & GetName() const
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
virtual SvXMLStyleContext * CreateStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void AddStyle(SvXMLStyleContext &rNew)
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
#define SAL_WARN(area, stream)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
css::uno::Reference< css::container::XNameContainer > mxTextStyles
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const
sal_uInt32 GetStyleCount() const
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
void FinishStyles(bool bOverwrite)
virtual void CreateAndInsertLate(bool bOverwrite)
Import bibliography configuration.