27#include <com/sun/star/frame/XModel.hpp>
28#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
30#include <com/sun/star/style/XStyle.hpp>
31#include <com/sun/star/beans/NamedValue.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/beans/XPropertyState.hpp>
34#include <com/sun/star/document/XEventsSupplier.hpp>
35#include <com/sun/star/text/XChapterNumberingSupplier.hpp>
54using ::com::sun::star::document::XEventsSupplier;
66 m_pAutoStylePool( pAutoStyleP )
80 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
81 assert(xPropSet.is());
85 uno::Any aProperty = xPropSet->getPropertyValue(
"ParaStyleConditions" );
86 uno::Sequence< beans::NamedValue >
aSeq;
90 for (beans::NamedValue
const& rNamedCond : std::as_const(
aSeq))
94 if (rNamedCond.Value >>= aStyleName)
96 if (!aStyleName.isEmpty())
100 if (!aExternal.isEmpty())
121 catch(
const beans::UnknownPropertyException& )
129void ExportStyleListlevel(
const uno::Reference<beans::XPropertySetInfo>& xPropSetInfo,
130 const uno::Reference<beans::XPropertyState>& xPropState,
131 const uno::Reference<beans::XPropertySet>& xPropSet,
SvXMLExport& rExport)
133 if (!xPropSetInfo->hasPropertyByName(
"NumberingLevel"))
135 SAL_WARN(
"xmloff",
"ExportStyleListlevel: no NumberingLevel for a Writer paragraph style");
139 if (xPropState->getPropertyState(
"NumberingLevel") != beans::PropertyState_DIRECT_VALUE)
144 sal_Int16 nNumberingLevel{};
145 if (!(xPropSet->getPropertyValue(
"NumberingLevel") >>= nNumberingLevel))
156 const Reference< XStyle >& rStyle,
157 const OUString& rXMLFamily,
159 const Reference< XNameAccess >& xStyles,
160 const OUString* pPrefix )
162 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
166 Reference< XPropertySetInfo > xPropSetInfo =
167 xPropSet->getPropertySetInfo();
175 if( !*o3tl::doAccess<bool>(aAny) )
187 sName += rStyle->getName();
189 bool bEncoded =
false;
190 const OUString sEncodedStyleName(
GetExport().EncodeStyleName(
sName, &bEncoded ));
198 if( !rXMLFamily.isEmpty() )
201 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
203 aAny = xPropSet->getPropertyValue(
"Hidden" );
204 bool bHidden =
false;
205 if ((aAny >>= bHidden) && bHidden
214 OUString sParentString(rStyle->getParentStyle());
217 if(!sParentString.isEmpty())
221 sParent += sParentString;
224 if( !sParent.isEmpty() )
226 GetExport().EncodeStyleName( sParent ) );
234 if(
sName != sNextName )
237 GetExport().EncodeStyleName( sNextName ) );
242 if (xPropSetInfo->hasPropertyByName(
"LinkStyle"))
244 aAny = xPropSet->getPropertyValue(
"LinkStyle");
247 if (!sLinkName.isEmpty()
259 if( *o3tl::doAccess<bool>(aAny) )
265 sal_Int32 nOutlineLevel = 0;
268 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
269 if( PropertyState_DIRECT_VALUE == xPropState->getPropertyState(
gsOutlineLevel ) )
272 aAny >>= nOutlineLevel;
273 if( nOutlineLevel > 0 )
277 OUString::number(nOutlineLevel) );
298 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
299 if( PropertyState_DIRECT_VALUE ==
303 if( aAny.hasValue() )
312 if ( sListName.isEmpty() )
321 bool bSuppressListStyle(
false );
323 if ( !
GetExport().writeOutlineStyleAsNormalListStyle() )
325 Reference< XChapterNumberingSupplier > xCNSupplier
328 if (xCNSupplier.is())
330 Reference< XIndexReplace > xNumRule
331 ( xCNSupplier->getChapterNumberingRules() );
332 assert(xNumRule.is());
334 Reference< XPropertySet > xNumRulePropSet
335 (xNumRule, UNO_QUERY);
336 OUString sOutlineName;
337 xNumRulePropSet->getPropertyValue(
"Name")
339 bSuppressListStyle = sListName == sOutlineName;
344 if ( !sListName.isEmpty() && !bSuppressListStyle )
348 GetExport().EncodeStyleName( sListName ) );
350 ExportStyleListlevel(xPropSetInfo, xPropState, xPropSet,
GetExport());
355 else if( nOutlineLevel > 0 )
358 bool bNoInheritedListStyle(
true );
360 Reference<XStyle> xStyle( xPropState, UNO_QUERY );
361 while ( xStyle.is() )
363 OUString aParentStyle( xStyle->getParentStyle() );
364 if ( aParentStyle.isEmpty() || !xStyles->hasByName( aParentStyle ) )
370 xPropState.set( xStyles->getByName( aParentStyle ), UNO_QUERY );
371 if ( !xPropState.is() )
377 bNoInheritedListStyle =
false;
382 xStyle.set( xPropState, UNO_QUERY );
386 if ( bNoInheritedListStyle )
406 rPropMapper->SetStyleName(
sName );
409 ::std::vector< XMLPropertyState > aPropStates =
410 rPropMapper->Filter(
GetExport(), xPropSet,
true);
411 bool const bUseExtensionNamespaceForGraphicProperties(
412 rXMLFamily !=
"drawing-page" &&
413 rXMLFamily !=
"graphic" &&
414 rXMLFamily !=
"presentation" &&
415 rXMLFamily !=
"chart");
416 rPropMapper->exportXML(
GetExport(), aPropStates,
418 bUseExtensionNamespaceForGraphicProperties );
420 rPropMapper->SetStyleName( OUString() );
425 Reference<XEventsSupplier> xEventsSupp(rStyle, UNO_QUERY);
432 const Reference< XPropertySet >& xPropSet,
433 const OUString& rXMLFamily,
441 if( !rXMLFamily.isEmpty() )
449 ::std::vector< XMLPropertyState > aPropStates =
450 rPropMapper->FilterDefaults(
GetExport(), xPropSet);
451 rPropMapper->exportXML(
GetExport(), aPropStates,
457 const OUString& rFamily,
const OUString& rXMLFamily,
462 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
GetExport().GetModel(), UNO_QUERY );
463 if( !xFamiliesSupp.is() )
466 Reference< XNameAccess > xStyleCont;
468 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
469 if( xFamilies->hasByName( rFamily ) )
470 xFamilies->getByName( rFamily ) >>= xStyleCont;
472 if( !xStyleCont.is() )
478 std::optional<std::set<OUString> > xExportedStyles;
479 bool bFirstStyle =
true;
481 const uno::Sequence< OUString>
aSeq = xStyleCont->getElementNames();
482 for(
const auto& rName :
aSeq)
484 Reference< XStyle > xStyle;
487 xStyleCont->getByName( rName ) >>= xStyle;
489 catch(
const lang::IndexOutOfBoundsException&)
497 catch(css::container::NoSuchElementException&)
503 if (!bUsed || xStyle->isInUse())
505 bool bExported =
exportStyle( xStyle, rXMLFamily, rPropMapper,
506 xStyleCont,pPrefix );
507 if (bUsed && bFirstStyle && bExported)
511 Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
512 Reference< XPropertySetInfo > xPropSetInfo =
513 xPropSet->getPropertySetInfo();
516 xExportedStyles.emplace();
520 if (xExportedStyles && bExported)
523 xExportedStyles->insert( xStyle->getName() );
533 if( !xExportedStyles )
538 for(
const auto& rName :
aSeq)
540 Reference< XStyle > xStyle;
541 xStyleCont->getByName( rName ) >>= xStyle;
545 Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
546 Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
552 if (!*o3tl::doAccess<bool>(aAny))
556 if (!xStyle->isInUse())
566 OUString sTmp( sNextName );
569 if (xStyle->getName() != sNextName &&
570 0 == xExportedStyles->count( sTmp ))
572 xStyleCont->getByName( sNextName ) >>= xStyle;
575 if (
exportStyle(xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix))
576 xExportedStyles->insert( sTmp );
void RegisterName(XmlStyleFamily nFamily, const OUString &rName)
Register a name that must not be used as a generated name.
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
void Export(css::uno::Reference< css::document::XEventsSupplier > const &xAccess, bool bUseWhitespace=true)
export the events (calls EventExport::Export(Reference<XNameAccess>) )
bool exportStyle(const css::uno::Reference< css::style::XStyle > &rStyle, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper, const css::uno::Reference< css::container::XNameAccess > &xStyles, const OUString *pPrefix)
virtual void exportStyleContent(const css::uno::Reference< css::style::XStyle > &rStyle)
SvXMLAutoStylePoolP * m_pAutoStylePool
virtual ~XMLStyleExport() override
virtual void exportStyleAttributes(const css::uno::Reference< css::style::XStyle > &rStyle)
void exportStyleFamily(const OUString &rFamily, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper, bool bUsed, XmlStyleFamily nFamily, const OUString *pPrefix=nullptr)
XMLStyleExport(SvXMLExport &rExp, SvXMLAutoStylePoolP *pAutoStyleP=nullptr)
void exportDefaultStyle(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper)
SvXMLExport & GetExport()
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
Handling of tokens in XML:
@ XML_DEFAULT_OUTLINE_LEVEL
OUString GetParaStyleCondExternal(std::u16string_view internal)
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
constexpr OUStringLiteral gsIsAutoUpdate(u"IsAutoUpdate")
constexpr OUStringLiteral gsNumberingStyleName(u"NumberingStyleName")
constexpr OUStringLiteral gsOutlineLevel(u"OutlineLevel")
constexpr OUStringLiteral gsFollowStyle(u"FollowStyle")
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE