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>
54 using ::com::sun::star::document::XEventsSupplier;
66 pAutoStylePool( pAutoStyleP )
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& )
129 void 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,
160 const OUString* pPrefix )
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())
258 if( *o3tl::doAccess<bool>(aAny) )
264 sal_Int32 nOutlineLevel = 0;
267 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
268 if( PropertyState_DIRECT_VALUE == xPropState->getPropertyState(
gsOutlineLevel ) )
271 aAny >>= nOutlineLevel;
272 if( nOutlineLevel > 0 )
276 OUString::number(nOutlineLevel) );
297 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
298 if( PropertyState_DIRECT_VALUE ==
302 if( aAny.hasValue() )
311 if ( sListName.isEmpty() )
320 bool bSuppressListStyle(
false );
322 if ( !
GetExport().writeOutlineStyleAsNormalListStyle() )
324 Reference< XChapterNumberingSupplier > xCNSupplier
327 if (xCNSupplier.is())
329 Reference< XIndexReplace > xNumRule
330 ( xCNSupplier->getChapterNumberingRules() );
331 assert(xNumRule.is());
334 (xNumRule, UNO_QUERY);
335 OUString sOutlineName;
336 xNumRulePropSet->getPropertyValue(
"Name")
338 bSuppressListStyle = sListName == sOutlineName;
343 if ( !sListName.isEmpty() && !bSuppressListStyle )
347 GetExport().EncodeStyleName( sListName ) );
349 ExportStyleListlevel(xPropSetInfo, xPropState, xPropSet,
GetExport());
354 else if( nOutlineLevel > 0 )
357 bool bNoInheritedListStyle(
true );
359 Reference<XStyle> xStyle( xPropState, UNO_QUERY );
360 while ( xStyle.is() )
362 OUString aParentStyle( xStyle->getParentStyle() );
363 if ( aParentStyle.isEmpty() || !xStyles->hasByName( aParentStyle ) )
369 xPropState.set( xStyles->getByName( aParentStyle ), UNO_QUERY );
370 if ( !xPropState.is() )
376 bNoInheritedListStyle =
false;
381 xStyle.set( xPropState, UNO_QUERY );
385 if ( bNoInheritedListStyle )
405 rPropMapper->SetStyleName( sName );
408 ::std::vector< XMLPropertyState > aPropStates =
409 rPropMapper->Filter(
GetExport(), xPropSet,
true);
410 bool const bUseExtensionNamespaceForGraphicProperties(
411 rXMLFamily !=
"drawing-page" &&
412 rXMLFamily !=
"graphic" &&
413 rXMLFamily !=
"presentation" &&
414 rXMLFamily !=
"chart");
415 rPropMapper->exportXML(
GetExport(), aPropStates,
417 bUseExtensionNamespaceForGraphicProperties );
419 rPropMapper->SetStyleName( OUString() );
424 Reference<XEventsSupplier> xEventsSupp(rStyle, UNO_QUERY);
432 const OUString& rXMLFamily,
440 if( !rXMLFamily.isEmpty() )
448 ::std::vector< XMLPropertyState > aPropStates =
449 rPropMapper->FilterDefaults(
GetExport(), xPropSet);
450 rPropMapper->exportXML(
GetExport(), aPropStates,
457 const OUString& rXMLFamily,
461 const OUString sFamily(OUString::createFromAscii(pFamily ));
467 const OUString& rFamily,
const OUString& rXMLFamily,
472 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
GetExport().GetModel(), UNO_QUERY );
473 if( !xFamiliesSupp.is() )
479 if( xFamilies->hasByName( rFamily ) )
480 xFamilies->getByName( rFamily ) >>= xStyleCont;
482 if( !xStyleCont.is() )
488 std::optional<std::set<OUString> > xExportedStyles;
489 bool bFirstStyle =
true;
491 const uno::Sequence< OUString>
aSeq = xStyleCont->getElementNames();
492 for(
const auto& rName : aSeq)
494 Reference< XStyle > xStyle;
497 xStyleCont->getByName( rName ) >>= xStyle;
499 catch(
const lang::IndexOutOfBoundsException&)
507 catch(css::container::NoSuchElementException&)
513 if (!bUsed || xStyle->isInUse())
515 bool bExported =
exportStyle( xStyle, rXMLFamily, rPropMapper,
516 xStyleCont,pPrefix );
517 if (bUsed && bFirstStyle && bExported)
522 Reference< XPropertySetInfo > xPropSetInfo =
523 xPropSet->getPropertySetInfo();
526 xExportedStyles.emplace();
530 if (xExportedStyles && bExported)
533 xExportedStyles->insert( xStyle->getName() );
543 if( !xExportedStyles )
548 for(
const auto& rName : aSeq)
550 Reference< XStyle > xStyle;
551 xStyleCont->getByName( rName ) >>= xStyle;
556 Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
562 if (!*o3tl::doAccess<bool>(aAny))
566 if (!xStyle->isInUse())
576 OUString sTmp( sNextName );
579 if (xStyle->getName() != sNextName &&
580 0 == xExportedStyles->count( sTmp ))
582 xStyleCont->getByName( sNextName ) >>= xStyle;
585 if (
exportStyle(xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix))
586 xExportedStyles->insert( sTmp );
constexpr OUStringLiteral gsOutlineLevel(u"OutlineLevel")
constexpr OUStringLiteral gsNumberingStyleName(u"NumberingStyleName")
void exportDefaultStyle(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper)
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
void RegisterName(XmlStyleFamily nFamily, const OUString &rName)
Register a name that must not be used as a generated name.
OUString GetParaStyleCondExternal(OUString const &internal)
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr OUStringLiteral gsFollowStyle(u"FollowStyle")
SvXMLAutoStylePoolP * pAutoStylePool
SvXMLExport & GetExport()
void exportStyleFamily(const OUString &rFamily, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper, bool bUsed, XmlStyleFamily nFamily, const OUString *pPrefix=nullptr)
constexpr OUStringLiteral gsIsAutoUpdate(u"IsAutoUpdate")
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
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 exportStyleAttributes(const css::uno::Reference< css::style::XStyle > &rStyle)
XMLEventExport & GetEventExport()
get Event export, with handlers for script types "None" and "StarBasic" already registered; other han...
virtual void exportStyleContent(const css::uno::Reference< css::style::XStyle > &rStyle)
XMLStyleExport(SvXMLExport &rExp, SvXMLAutoStylePoolP *pAutoStyleP=nullptr)
Handling of tokens in XML:
Sequence< sal_Int8 > aSeq
virtual ~XMLStyleExport() override
#define SAL_WARN(area, stream)
constexpr sal_uInt16 XML_NAMESPACE_STYLE
void Export(css::uno::Reference< css::document::XEventsSupplier > const &xAccess, bool bUseWhitespace=true)
export the events (calls EventExport::Export(Reference) )