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>
73 struct theStandardSet :
74 public rtl::StaticWithInit<OldFillStyleDefinitionSet, theStandardSet>
79 aSet.insert(
"BackColorRGB");
80 aSet.insert(
"BackTransparent");
81 aSet.insert(
"BackColorTransparency");
82 aSet.insert(
"BackGraphic");
83 aSet.insert(
"BackGraphicFilter");
84 aSet.insert(
"BackGraphicLocation");
85 aSet.insert(
"BackGraphicTransparency");
90 public rtl::StaticWithInit<OldFillStyleDefinitionSet, theHeaderSet>
95 aSet.insert(
"HeaderBackColorRGB");
96 aSet.insert(
"HeaderBackTransparent");
97 aSet.insert(
"HeaderBackColorTransparency");
98 aSet.insert(
"HeaderBackGraphic");
99 aSet.insert(
"HeaderBackGraphicFilter");
100 aSet.insert(
"HeaderBackGraphicLocation");
101 aSet.insert(
"HeaderBackGraphicTransparency");
105 struct theFooterSet :
106 public rtl::StaticWithInit<OldFillStyleDefinitionSet, theFooterSet>
111 aSet.insert(
"FooterBackColorRGB");
112 aSet.insert(
"FooterBackTransparent");
113 aSet.insert(
"FooterBackColorTransparency");
114 aSet.insert(
"FooterBackGraphic");
115 aSet.insert(
"FooterBackGraphicFilter");
116 aSet.insert(
"FooterBackGraphicLocation");
117 aSet.insert(
"FooterBackGraphicTransparency");
122 public rtl::StaticWithInit<OldFillStyleDefinitionSet, theParaSet>
129 aSet.insert(
"ParaBackColor");
130 aSet.insert(
"ParaBackTransparent");
131 aSet.insert(
"ParaBackGraphicLocation");
132 aSet.insert(
"ParaBackGraphicFilter");
133 aSet.insert(
"ParaBackGraphic");
145 constexpr OUStringLiteral
gsIsPhysical( u
"IsPhysical" );
152 , mxStyles( &rStyles )
162 return theStandardSet::get();
167 return theHeaderSet::get();
172 return theFooterSet::get();
177 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
179 sal_uInt32 nFamily = 0;
227 SAL_WARN_IF( !xImpPrMap.is(),
"xmloff",
"There is the import prop mapper" );
238 Reference < XStyle > xNewStyle;
241 if( !sServiceName.isEmpty() )
247 Reference < XInterface > xIfc =
248 xFactory->createInstance( sServiceName );
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() )
337 OUStringLiteral(
u"ParaAutoStyleName") :
338 OUStringLiteral(
u"CharAutoStyleName");
339 Sequence< Any > aAny = xAutoStyle->getPropertyValues( aPropNames );
340 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) );
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();
410 for( i = 0; i < nCount; i++ )
412 const OUString& rPrName = xPrMap->GetEntryAPIName( i );
413 if( xPropSetInfo->hasPropertyByName( rPrName ) )
414 aNameSet.insert( rPrName );
416 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
419 nCount = aNameSet.size();
421 Sequence < PropertyState > aStates( xPropState->getPropertyStates(aNames) );
422 const PropertyState *pStates = aStates.getConstArray();
423 OUString* pNames = aNames.getArray();
425 for( i = 0; i < nCount; i++ )
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)
486 aSequence[0] =
mxStyle->getName();
487 aSequence[1] = sParent;
491 aSequence, e.Message,
nullptr );
497 if( !sFollow.isEmpty() )
499 if( sFollow.isEmpty() || !xFamilies->hasByName( sFollow ) )
503 Reference< XPropertySetInfo > xPropSetInfo =
504 xPropSet->getPropertySetInfo();
508 OUString sCurrFollow;
509 aAny >>= sCurrFollow;
510 if( sCurrFollow != sFollow )
516 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
518 xPropSet->setPropertyValue(
"Hidden", uno::makeAny(
IsHidden( ) ) );
524 const OUString& rFillStyleTag)
const
537 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
539 if(rPropName == rFillStyleTag)
543 if(
a.maValue >>= eFillStyle)
550 sal_Int32 nFillStyle(0);
552 if(
a.maValue >>= nFillStyle)
554 eFillStyle =
static_cast< FillStyle >(nFillStyle);
559 return FillStyle_NONE != eFillStyle;
584 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
586 if(rHashSetOfTags.find(rPropName) != rHashSetOfTags.end())
605 static OUString s_FillGradientName(
"FillGradientName");
606 static OUString s_FillHatchName(
"FillHatchName");
607 static OUString s_FillBitmapName(
"FillBitmapName");
608 static OUString s_FillTransparenceGradientName(
"FillTransparenceGradientName");
614 const OUString& rPropName = rMapper->GetEntryAPIName(
a.mnIndex);
617 if(rPropName == s_FillGradientName || rPropName == s_FillTransparenceGradientName)
621 else if(rPropName == s_FillHatchName)
625 else if(rPropName == s_FillBitmapName)
634 a.maValue >>= sStyleName;
636 a.maValue <<= sStyleName;
XmlStyleFamily GetFamily() const
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
std::unordered_set< OUString > OldFillStyleDefinitionSet
static const OldFillStyleDefinitionSet & getStandardSet()
#define XML_TYPE_PROP_RUBY
SvXMLImport & GetImport()
css::uno::Reference< css::style::XAutoStyleFamily > GetAutoStyles(XmlStyleFamily nFamily) const
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
bool IsDefaultStyle() const
#define XML_TYPE_PROP_TABLE_ROW
static XmlStyleFamily GetFamily(std::u16string_view rFamily)
bool IsAutomaticStyle() const
#define XML_TYPE_PROP_TABLE_COLUMN
css::uno::Any const & rValue
#define XML_TYPE_PROP_PARAGRAPH
constexpr OUStringLiteral sServiceName
virtual css::uno::Reference< css::style::XStyle > Create()
virtual ~XMLPropStyleContext() override
bool doNewDrawingLayerFillStyleDefinitionsExist(const OUString &rFillStyleTag) const
XMLPropStyleContext(XMLPropStyleContext const &)=delete
void deactivateOldFillStyleDefinitions(const OldFillStyleDefinitionSet &rHashSetOfTags)
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
const OUString & GetDisplayName() const
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue)
virtual void CreateAndInsert(bool bOverwrite) override
const PropertyStruct aPropNames[]
css::uno::Reference< css::style::XStyle > mxStyle
#define XML_TYPE_PROP_TEXT
rtl::Reference< SvXMLStylesContext > mxStyles
constexpr OUStringLiteral gsFollowStyle(u"FollowStyle")
#define XML_TYPE_PROP_CHART
#define XML_TYPE_PROP_TABLE
virtual void SetDefaults() override
virtual void Finish(bool bOverwrite) override
static const OldFillStyleDefinitionSet & getHeaderSet()
static const OldFillStyleDefinitionSet & getFooterSet()
const OUString & GetParentName() const
#define XML_TYPE_PROP_TABLE_CELL
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetName() const
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
::std::vector< XMLPropertyState > maProperties
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Handling of tokens in XML:
#define XML_TYPE_PROP_GRAPHIC
#define XMLERROR_FLAG_ERROR
#define XML_ELEMENT(prefix, name)
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Record an error condition that occurred during import.
void SetAutoName(const OUString &rName)
SvXMLStylesContext * GetStyles()
#define XML_TYPE_PROP_DRAWING_PAGE
void translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames()
const OUString & GetFollow() const
void AddStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName, const OUString &rDisplayName)
#define SAL_WARN(area, stream)
Reference< XSingleServiceFactory > xFactory
constexpr sal_Int32 TOKEN_MASK
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
#define XMLERROR_PARENT_STYLE_NOT_ALLOWED
#define XML_TYPE_PROP_SECTION
constexpr sal_uInt16 XML_NAMESPACE_STYLE