23#include <osl/diagnose.h>
29#include <com/sun/star/frame/XModel.hpp>
30#include <com/sun/star/style/XStyle.hpp>
31#include <com/sun/star/style/XAutoStyleFamily.hpp>
32#include <com/sun/star/container/XNameContainer.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/beans/XPropertyState.hpp>
35#include <com/sun/star/beans/XMultiPropertyStates.hpp>
36#include <com/sun/star/lang/XMultiServiceFactory.hpp>
45#include <com/sun/star/drawing/FillStyle.hpp>
58 const OUString& rValue )
78 aSet.insert(
"BackColorRGB");
79 aSet.insert(
"BackTransparent");
80 aSet.insert(
"BackColorTransparency");
81 aSet.insert(
"BackGraphic");
82 aSet.insert(
"BackGraphicFilter");
83 aSet.insert(
"BackGraphicLocation");
84 aSet.insert(
"BackGraphicTransparency");
94 aSet.insert(
"HeaderBackColorRGB");
95 aSet.insert(
"HeaderBackTransparent");
96 aSet.insert(
"HeaderBackColorTransparency");
97 aSet.insert(
"HeaderBackGraphic");
98 aSet.insert(
"HeaderBackGraphicFilter");
99 aSet.insert(
"HeaderBackGraphicLocation");
100 aSet.insert(
"HeaderBackGraphicTransparency");
110 aSet.insert(
"FooterBackColorRGB");
111 aSet.insert(
"FooterBackTransparent");
112 aSet.insert(
"FooterBackColorTransparency");
113 aSet.insert(
"FooterBackGraphic");
114 aSet.insert(
"FooterBackGraphicFilter");
115 aSet.insert(
"FooterBackGraphicLocation");
116 aSet.insert(
"FooterBackGraphicTransparency");
128 aSet.insert(
"ParaBackColor");
129 aSet.insert(
"ParaBackTransparent");
130 aSet.insert(
"ParaBackGraphicLocation");
131 aSet.insert(
"ParaBackGraphicFilter");
132 aSet.insert(
"ParaBackGraphic");
152, mxStyles( &rStyles )
162 return theStandardSet();
167 return theHeaderSet();
172 return theFooterSet();
177 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
179 sal_uInt32 nFamily = 0;
223 const Reference< XPropertySet > & rPropSet )
227 SAL_WARN_IF( !xImpPrMap.is(),
"xmloff",
"There is the import prop mapper" );
238 Reference < XStyle > xNewStyle;
247 Reference < XInterface > xIfc =
250 xNewStyle.set( xIfc, UNO_QUERY );
261 OSL_ENSURE(xImpPrMap.is(),
"There is no import prop mapper");
266 bool bDrawingLayerFillStylesUsed(
false);
268 if(bTakeCareOfDrawingLayerFillStyle)
271 static OUString s_FillStyle(
"FillStyle");
276 bDrawingLayerFillStylesUsed =
true;
290 if(bDrawingLayerFillStylesUsed)
296 if( !xAutoFamily.is() )
300 Sequence< PropertyValue > aValues;
301 xImpPrMap->FillPropertySequence(
maProperties, aValues );
303 sal_Int32 nLen = aValues.getLength();
308 aValues.realloc( nLen + 2 );
309 PropertyValue *pProps = aValues.getArray() + nLen;
310 pProps->Name =
"ParaStyleName";
312 if( !sParent.isEmpty() )
316 if(xFamilies.is() && xFamilies->hasByName( sParent ) )
318 css::uno::Reference< css::style::XStyle > xStyle;
319 Any aAny = xFamilies->getByName( sParent );
321 sParent = xStyle->getName() ;
325 sParent =
"Standard";
326 pProps->Value <<= sParent;
328 pProps->Name =
"ParaConditionalStyleName";
329 pProps->Value <<= sParent;
332 Reference < XAutoStyle > xAutoStyle = xAutoFamily->insertStyle( aValues );
333 if( xAutoStyle.is() )
338 OUString(
"ParaAutoStyleName"):
339 OUString(
"CharAutoStyleName")
341 Sequence< Any > aAny = xAutoStyle->getPropertyValues(
aPropNames );
342 if( aAny.hasElements() )
357 if( !xFamilies.is() )
359 SAL_WARN(
"xmloff",
"no styles container for family " <<
static_cast<int>(
GetFamily()));
364 if( xFamilies->hasByName( rName ) )
366 Any aAny = xFamilies->getByName( rName );
375 xFamilies->insertByName( rName,
Any(
mxStyle) );
379 Reference < XPropertySet > xPropSet(
mxStyle, UNO_QUERY );
380 Reference< XPropertySetInfo > xPropSetInfo =
381 xPropSet->getPropertySetInfo();
382 if( !bNew && xPropSetInfo->hasPropertyByName(
gsIsPhysical ) )
385 bNew = !*o3tl::doAccess<bool>(aAny);
392 if( bOverwrite || bNew )
396 xPrMap = xImpPrMap->getPropertySetMapper();
399 Reference < XMultiPropertyStates > xMultiStates( xPropSet,
401 if( xMultiStates.is() )
403 xMultiStates->setAllPropertiesToDefault();
407 std::set < OUString > aNameSet;
408 sal_Int32
nCount = xPrMap->GetEntryCount();
412 const OUString& rPrName = xPrMap->GetEntryAPIName(
i );
413 if( xPropSetInfo->hasPropertyByName( rPrName ) )
414 aNameSet.insert( rPrName );
416 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
421 Sequence < PropertyState > aStates( xPropState->getPropertyStates(aNames) );
422 const PropertyState *pStates = aStates.getConstArray();
423 OUString* pNames = aNames.getArray();
427 if( PropertyState_DIRECT_VALUE == *pStates++ )
428 xPropState->setPropertyToDefault( pNames[
i] );
435 mxStyle->setParentStyle(OUString());
452 Reference < XNameContainer > xFamilies =
mxStyles->GetStylesContainer(
GetFamily() );
453 SAL_WARN_IF( !xFamilies.is(),
"xmloff",
"Families lost" );
454 if( !xFamilies.is() )
459 if( !sParent.isEmpty() )
461 if( !sParent.isEmpty() && !xFamilies->hasByName( sParent ) )
464 if( sParent !=
mxStyle->getParentStyle() )
471 mxStyle->setParentStyle( sParent );
473 catch(
const uno::Exception& e)
487 {
mxStyle->getName(), sParent }, e.Message, nullptr );
493 if( !sFollow.isEmpty() )
495 if( sFollow.isEmpty() || !xFamilies->hasByName( sFollow ) )
498 Reference < XPropertySet > xPropSet(
mxStyle, UNO_QUERY );
499 Reference< XPropertySetInfo > xPropSetInfo =
500 xPropSet->getPropertySetInfo();
504 OUString sCurrFollow;
505 aAny >>= sCurrFollow;
506 if( sCurrFollow != sFollow )
514 if (!aLinked.isEmpty())
525 if (!aLinked.isEmpty() && xPropSetInfo->hasPropertyByName(
"LinkStyle"))
527 uno::Any aAny = xPropSet->getPropertyValue(
"LinkStyle");
528 OUString aCurrentLinked;
529 aAny >>= aCurrentLinked;
530 if (aCurrentLinked != aLinked)
532 xPropSet->setPropertyValue(
"LinkStyle",
uno::Any(aLinked));
536 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
544 std::u16string_view rFillStyleTag)
const
557 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
559 if(rPropName == rFillStyleTag)
563 if(
a.maValue >>= eFillStyle)
570 sal_Int32 nFillStyle(0);
572 if(
a.maValue >>= nFillStyle)
574 eFillStyle =
static_cast< FillStyle >(nFillStyle);
579 return FillStyle_NONE != eFillStyle;
604 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
606 if(rHashSetOfTags.find(rPropName) != rHashSetOfTags.end())
625 static constexpr OUStringLiteral s_FillGradientName(
u"FillGradientName");
626 static constexpr OUStringLiteral s_FillHatchName(
u"FillHatchName");
627 static constexpr OUStringLiteral s_FillBitmapName(
u"FillBitmapName");
628 static constexpr OUStringLiteral s_FillTransparenceGradientName(
u"FillTransparenceGradientName");
634 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
637 if(rPropName == s_FillGradientName || rPropName == s_FillTransparenceGradientName)
641 else if(rPropName == s_FillHatchName)
645 else if(rPropName == s_FillBitmapName)
654 a.maValue >>= sStyleName;
655 sStyleName =
GetImport().GetStyleDisplayName( aStyleFamily, sStyleName );
656 a.maValue <<= sStyleName;
constexpr OUStringLiteral sServiceName
SvXMLImport & GetImport()
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue)
const OUString & GetName() const
const OUString & GetFollow() const
const OUString & GetLinked() const
XmlStyleFamily GetFamily() const
const OUString & GetParentName() const
void SetAutoName(const css::uno::Any &rName)
bool IsDefaultStyle() const
const OUString & GetDisplayName() const
static XmlStyleFamily GetFamily(std::u16string_view rFamily)
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
bool IsAutomaticStyle() const
css::uno::Reference< css::style::XAutoStyleFamily > GetAutoStyles(XmlStyleFamily nFamily) const
virtual void SetDefaults() override
bool doNewDrawingLayerFillStyleDefinitionsExist(std::u16string_view rFillStyleTag) const
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
XMLPropStyleContext(XMLPropStyleContext const &)=delete
void translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames()
void deactivateOldFillStyleDefinitions(const OldFillStyleDefinitionSet &rHashSetOfTags)
static const OldFillStyleDefinitionSet & getHeaderSet()
css::uno::Reference< css::style::XStyle > mxStyle
rtl::Reference< SvXMLStylesContext > mxStyles
static const OldFillStyleDefinitionSet & getStandardSet()
static const OldFillStyleDefinitionSet & getFooterSet()
::std::vector< XMLPropertyState > maProperties
virtual void CreateAndInsert(bool bOverwrite) override
virtual css::uno::Reference< css::style::XStyle > Create()
virtual ~XMLPropStyleContext() override
SvXMLStylesContext * GetStyles()
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
virtual void Finish(bool bOverwrite) override
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
enum SAL_DLLPUBLIC_RTTI FillStyle
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Handling of tokens in XML:
@ XML_TABLE_CELL_PROPERTIES
@ XML_DRAWING_PAGE_PROPERTIES
@ XML_TABLE_COLUMN_PROPERTIES
@ XML_PARAGRAPH_PROPERTIES
@ XML_TABLE_ROW_PROPERTIES
const PropertyStruct aPropNames[]
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
constexpr OUStringLiteral gsFollowStyle(u"FollowStyle")
std::unordered_set< OUString > OldFillStyleDefinitionSet
#define XMLERROR_PARENT_STYLE_NOT_ALLOWED
#define XMLERROR_FLAG_ERROR
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XML_ELEMENT(prefix, name)
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
constexpr sal_Int32 TOKEN_MASK
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
#define XML_TYPE_PROP_RUBY
#define XML_TYPE_PROP_SECTION
#define XML_TYPE_PROP_GRAPHIC
#define XML_TYPE_PROP_CHART
#define XML_TYPE_PROP_TABLE_CELL
#define XML_TYPE_PROP_PARAGRAPH
#define XML_TYPE_PROP_TEXT
#define XML_TYPE_PROP_TABLE_COLUMN
#define XML_TYPE_PROP_TABLE
#define XML_TYPE_PROP_DRAWING_PAGE
#define XML_TYPE_PROP_TABLE_ROW