26#include <ooxml/resourceids.hxx>
30#include <com/sun/star/beans/XMultiPropertySet.hpp>
31#include <com/sun/star/beans/XPropertyState.hpp>
32#include <com/sun/star/beans/PropertyValue.hpp>
33#include <com/sun/star/container/XEnumerationAccess.hpp>
34#include <com/sun/star/container/XNameContainer.hpp>
35#include <com/sun/star/container/XIndexReplace.hpp>
36#include <com/sun/star/lang/XServiceInfo.hpp>
37#include <com/sun/star/text/XTextDocument.hpp>
38#include <com/sun/star/text/XTextFramesSupplier.hpp>
39#include <com/sun/star/text/XTextTable.hpp>
40#include <com/sun/star/style/NumberingType.hpp>
41#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
42#include <com/sun/star/style/XStyle.hpp>
43#include <com/sun/star/style/ParagraphAdjust.hpp>
44#include <com/sun/star/text/WritingMode.hpp>
45#include <com/sun/star/lang/XMultiServiceFactory.hpp>
47#include <osl/diagnose.h>
48#include <rtl/ustrbuf.hxx>
62 m_bIsDefaultStyle(false)
63 ,m_bAssignedAsChapterNumbering(false)
64 ,m_bInvalidHeight(false)
68 ,m_bAutoRedefine(false)
95 static const int nTypesProps = 4;
104 static const PropertyIds pPropsToCheck[nTypesProps] =
112 for (
int i=0;
i < nTypesProps; ++
i )
114 if (
nType == pTypesToFix[
i] )
117 std::optional<PropertyMap::Property> pChecked = pProps->getProperty(nChecked);
120 std::optional<PropertyMap::Property> pInside = pProps->getProperty(nInsideProp);
122 if ( pChecked && pInside )
125 pProps->Erase( nInsideProp );
153 beans::PropertyValue aRet;
172 if ( pParentStyleSheet )
173 pRet = pParentStyleSheet->GetMergedInheritedProperties(pStyleSheetTable);
194 bool pRemoveInside[] =
205 std::optional<PropertyMap::Property> pProp = pToAdd->getProperty(
nId);
209 if ( pRemoveInside[
i] )
213 pToFill->Erase(nInsideProp);
218 pToFill->InsertProps(pToAdd);
224 struct TblStyleTypeAndMask {
229 static const TblStyleTypeAndMask aOrderedStyleTable[] =
247 for (
const TblStyleTypeAndMask &
i : aOrderedStyleTable)
249 TblStylePrs::iterator pIt =
m_aStyles.find(
i.type );
250 if ( ( nMask &
i.mask ) && ( pIt !=
m_aStyles.end( ) ) )
258struct ListCharStylePropertyMap_t
300 bool const bIsNewDoc)
301 : m_rDMapper( rDMapper ),
302 m_xTextDocument(
std::move( xTextDocument )),
305 m_sDefaultParaStyleName(
"Normal"),
306 m_bHasImportedDefaultParaProps(false),
307 m_bIsNewDoc(bIsNewDoc)
325 const auto& rPropertyValues = rListVector.aPropertyValues;
327 if( rPropertyValues.size() == rPropValues.size() )
331 for(
const auto& rPropVal1 : rPropValues)
334 auto aListIter = std::find_if(rPropertyValues.begin(), rPropertyValues.end(),
335 [&rPropVal1](
const css::beans::PropertyValue& rPropVal2) { return rPropVal2.Name == rPropVal1.Name; });
337 bBreak = (aListIter == rPropertyValues.end()) || (aListIter->Value != rPropVal1.Value);
342 return rListVector.sCharStyleName;
350 beans::PropertyValue aValue;
362 std::vector<OUString> aPropertyNames;
365 [](
const beans::Property& rProp) { return rProp.Name; });
369 for (sal_Int32
i = 0;
i < aStates.getLength(); ++
i)
371 if (aStates[
i] == beans::PropertyState_DIRECT_VALUE)
375 xPropertyState->setPropertyToDefault(aPropertyNames[
i]);
377 catch(
const uno::Exception&)
387 bool const bIsNewDoc)
406 return m_pImpl->m_pDefaultParaProps;
411 return m_pImpl->m_pDefaultCharProps;
416 OSL_ENSURE(
m_pImpl->m_pCurrentEntry,
"current entry has to be set here");
419 int nIntValue = val.
getInt();
427 if(
Name != NS_ooxml::LN_CT_Style_type )
432 case NS_ooxml::LN_CT_Style_type:
435 "writerfilter",
"Style type needs to be processed first" );
439 case NS_ooxml::LN_Value_ST_StyleType_paragraph:
442 case NS_ooxml::LN_Value_ST_StyleType_character:
445 case NS_ooxml::LN_Value_ST_StyleType_table:
448 case NS_ooxml::LN_Value_ST_StyleType_numbering:
452 SAL_WARN(
"writerfilter",
"unknown LN_CT_Style_type " <<
nType);
468 case NS_ooxml::LN_CT_Style_default:
469 m_pImpl->m_pCurrentEntry->m_bIsDefaultStyle = (nIntValue != 0);
474 if (
m_pImpl->m_pCurrentEntry->m_bIsDefaultStyle
476 && !
m_pImpl->m_pCurrentEntry->m_sStyleIdentifierD.isEmpty())
478 m_pImpl->m_sDefaultParaStyleName =
m_pImpl->m_pCurrentEntry->m_sStyleIdentifierD;
481 beans::PropertyValue aValue;
482 aValue.Name =
"default";
483 aValue.Value <<=
m_pImpl->m_pCurrentEntry->m_bIsDefaultStyle;
484 m_pImpl->m_pCurrentEntry->AppendInteropGrabBag(aValue);
487 case NS_ooxml::LN_CT_Style_customStyle:
490 beans::PropertyValue aValue;
491 aValue.Name =
"customStyle";
492 aValue.Value <<= (nIntValue != 0);
493 m_pImpl->m_pCurrentEntry->AppendInteropGrabBag(aValue);
496 case NS_ooxml::LN_CT_Style_styleId:
497 m_pImpl->m_pCurrentEntry->m_sStyleIdentifierD = sValue;
501 beans::PropertyValue aValue;
502 aValue.Name =
"styleId";
503 aValue.Value <<= sValue;
507 case NS_ooxml::LN_CT_TblWidth_w:
509 case NS_ooxml::LN_CT_TblWidth_type:
511 case NS_ooxml::LN_CT_LatentStyles_defQFormat:
512 m_pImpl->AppendLatentStyleProperty(
"defQFormat", val);
514 case NS_ooxml::LN_CT_LatentStyles_defUnhideWhenUsed:
515 m_pImpl->AppendLatentStyleProperty(
"defUnhideWhenUsed", val);
517 case NS_ooxml::LN_CT_LatentStyles_defSemiHidden:
518 m_pImpl->AppendLatentStyleProperty(
"defSemiHidden", val);
520 case NS_ooxml::LN_CT_LatentStyles_count:
521 m_pImpl->AppendLatentStyleProperty(
"count", val);
523 case NS_ooxml::LN_CT_LatentStyles_defUIPriority:
524 m_pImpl->AppendLatentStyleProperty(
"defUIPriority", val);
526 case NS_ooxml::LN_CT_LatentStyles_defLockedState:
527 m_pImpl->AppendLatentStyleProperty(
"defLockedState", val);
542 sal_uInt32 nSprmId = rSprm.
getId();
544 sal_Int32 nIntValue = pValue ? pValue->getInt() : 0;
545 OUString sStringValue = pValue ? pValue->getString() : OUString();
549 case NS_ooxml::LN_CT_Style_name:
551 m_pImpl->m_pCurrentEntry->m_sStyleName = sStringValue;
555 beans::PropertyValue aValue;
556 aValue.Name =
"name";
557 aValue.Value <<= sStringValue;
561 case NS_ooxml::LN_CT_Style_basedOn:
562 m_pImpl->m_pCurrentEntry->m_sBaseStyleIdentifier = sStringValue;
566 beans::PropertyValue aValue;
567 aValue.Name =
"basedOn";
568 aValue.Value <<= sStringValue;
572 case NS_ooxml::LN_CT_Style_link:
573 m_pImpl->m_pCurrentEntry->m_sLinkStyleIdentifier = sStringValue;
575 case NS_ooxml::LN_CT_Style_next:
576 m_pImpl->m_pCurrentEntry->m_sNextStyleIdentifier = sStringValue;
578 case NS_ooxml::LN_CT_Style_aliases:
579 case NS_ooxml::LN_CT_Style_hidden:
580 case NS_ooxml::LN_CT_Style_personal:
581 case NS_ooxml::LN_CT_Style_personalCompose:
582 case NS_ooxml::LN_CT_Style_personalReply:
584 case NS_ooxml::LN_CT_Style_autoRedefine:
585 m_pImpl->m_pCurrentEntry->m_bAutoRedefine = nIntValue;
587 case NS_ooxml::LN_CT_Style_tcPr:
592 auto pTblStylePrHandler = std::make_shared<TblStylePrHandler>(
m_pImpl->m_rDMapper);
593 pProperties->resolve(*pTblStylePrHandler);
599 rTableEntry.
m_pProperties->InsertProps(pTblStylePrHandler->getProperties());
603 case NS_ooxml::LN_CT_Style_trPr:
605 case NS_ooxml::LN_CT_Style_rsid:
606 case NS_ooxml::LN_CT_Style_qFormat:
607 case NS_ooxml::LN_CT_Style_semiHidden:
608 case NS_ooxml::LN_CT_Style_unhideWhenUsed:
609 case NS_ooxml::LN_CT_Style_uiPriority:
610 case NS_ooxml::LN_CT_Style_locked:
614 beans::PropertyValue aValue;
617 case NS_ooxml::LN_CT_Style_rsid:
620 OUStringBuffer
aBuf = OUString::number(nIntValue, 16);
625 aValue.Name =
"rsid";
626 aValue.Value <<=
aStr.makeStringAndClear();
629 case NS_ooxml::LN_CT_Style_qFormat:
630 aValue.Name =
"qFormat";
632 case NS_ooxml::LN_CT_Style_semiHidden:
633 aValue.Name =
"semiHidden";
635 case NS_ooxml::LN_CT_Style_unhideWhenUsed:
636 aValue.Name =
"unhideWhenUsed";
638 case NS_ooxml::LN_CT_Style_uiPriority:
640 aValue.Name =
"uiPriority";
641 aValue.Value <<= OUString::number(nIntValue);
644 case NS_ooxml::LN_CT_Style_locked:
645 aValue.Name =
"locked";
648 pEntry->AppendInteropGrabBag(aValue);
651 case NS_ooxml::LN_CT_Style_tblPr:
652 case NS_ooxml::LN_CT_Style_tblStylePr:
653 case NS_ooxml::LN_CT_TblPrBase_tblInd:
654 case NS_ooxml::LN_EG_RPrBase_rFonts:
659 auto pTblStylePrHandler = std::make_shared<TblStylePrHandler>(
m_pImpl->m_rDMapper );
660 pProperties->resolve( *pTblStylePrHandler );
674 if (pTableEntry !=
nullptr)
678 if (nSprmId == NS_ooxml::LN_CT_Style_tblPr)
680 if (pTableEntry !=
nullptr)
683 else if (nSprmId == NS_ooxml::LN_CT_Style_tblStylePr)
685 pTblStylePrHandler->appendInteropGrabBag(
"type", pTblStylePrHandler->getTypeString());
686 if (pTableEntry !=
nullptr)
692 case NS_ooxml::LN_CT_PPrDefault_pPr:
693 case NS_ooxml::LN_CT_DocDefaults_pPrDefault:
694 if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
695 m_pImpl->m_rDMapper.SetDocDefaultsImport(
true);
697 m_pImpl->m_rDMapper.PushStyleSheetProperties(
m_pImpl->m_pDefaultParaProps );
699 if ( nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault &&
m_pImpl->m_pDefaultParaProps &&
704 m_pImpl->m_rDMapper.PopStyleSheetProperties();
706 m_pImpl->m_bHasImportedDefaultParaProps =
true;
707 if (nSprmId == NS_ooxml::LN_CT_DocDefaults_pPrDefault)
708 m_pImpl->m_rDMapper.SetDocDefaultsImport(
false);
710 case NS_ooxml::LN_CT_RPrDefault_rPr:
711 case NS_ooxml::LN_CT_DocDefaults_rPrDefault:
712 if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
713 m_pImpl->m_rDMapper.SetDocDefaultsImport(
true);
715 m_pImpl->m_rDMapper.PushStyleSheetProperties(
m_pImpl->m_pDefaultCharProps );
717 m_pImpl->m_rDMapper.PopStyleSheetProperties();
719 if (nSprmId == NS_ooxml::LN_CT_DocDefaults_rPrDefault)
720 m_pImpl->m_rDMapper.SetDocDefaultsImport(
false);
722 case NS_ooxml::LN_CT_TblPrBase_jc:
726 case NS_ooxml::LN_CT_TrPrBase_jc:
728 case NS_ooxml::LN_CT_TblPrBase_tblBorders:
733 auto pBorderHandler = std::make_shared<BorderHandler>(
m_pImpl->m_rDMapper.IsOOXMLImport());
734 pProperties->resolve(*pBorderHandler);
735 m_pImpl->m_pCurrentEntry->m_pProperties->InsertProps(
736 pBorderHandler->getProperties());
740 case NS_ooxml::LN_CT_TblPrBase_tblStyleRowBandSize:
741 case NS_ooxml::LN_CT_TblPrBase_tblStyleColBandSize:
743 case NS_ooxml::LN_CT_TblPrBase_tblCellMar:
746 case NS_ooxml::LN_CT_LatentStyles_lsdException:
752 pProperties->resolve(*pLatentStyleHandler);
753 beans::PropertyValue aValue;
754 aValue.Name =
"lsdException";
756 m_pImpl->m_pCurrentEntry->m_aLsdExceptions.push_back(aValue);
760 case NS_ooxml::LN_CT_Style_pPr:
762 case NS_ooxml::LN_CT_Style_rPr:
770 pTblHandler->SetProperties(
m_pImpl->m_pCurrentEntry->m_pProperties.get() );
771 if ( !pTblHandler->sprm( rSprm ) )
773 m_pImpl->m_rDMapper.PushStyleSheetProperties(
m_pImpl->m_pCurrentEntry->m_pProperties.get() );
778 if (nSprmId == NS_ooxml::LN_CT_Style_pPr)
779 m_pImpl->m_rDMapper.enableInteropGrabBag(
"pPr");
780 else if (nSprmId == NS_ooxml::LN_CT_Style_rPr)
781 m_pImpl->m_rDMapper.enableInteropGrabBag(
"rPr");
783 m_pImpl->m_rDMapper.sprmWithProps( rSprm, pProps );
786 if (nSprmId == NS_ooxml::LN_CT_Style_pPr || nSprmId == NS_ooxml::LN_CT_Style_rPr)
793 m_pImpl->m_pCurrentEntry->m_pProperties->InsertProps(pProps);
795 m_pImpl->m_rDMapper.PopStyleSheetProperties( );
806 OSL_ENSURE( !
m_pImpl->m_pCurrentEntry,
"current entry has to be NULL here");
808 m_pImpl->m_pCurrentEntry = pNewEntry;
809 m_pImpl->m_rDMapper.PushStyleSheetProperties(
m_pImpl->m_pCurrentEntry->m_pProperties.get() );
811 m_pImpl->m_rDMapper.ProcessDeferredStyleCharacterProperties();
813 m_pImpl->m_rDMapper.PopStyleSheetProperties();
814 if( !
m_pImpl->m_rDMapper.IsOOXMLImport() || !
m_pImpl->m_pCurrentEntry->m_sStyleName.isEmpty())
817 m_pImpl->m_aStyleSheetEntries.push_back(
m_pImpl->m_pCurrentEntry );
818 m_pImpl->m_aStyleSheetEntriesMap.emplace(
m_pImpl->m_pCurrentEntry->m_sStyleIdentifierD,
m_pImpl->m_pCurrentEntry );
825 if (!
m_pImpl->m_pCurrentEntry->m_aLatentStyles.empty())
828 std::vector<beans::PropertyValue>& rLatentStyles =
m_pImpl->m_pCurrentEntry->m_aLatentStyles;
830 if (!
m_pImpl->m_pCurrentEntry->m_aLsdExceptions.empty())
832 std::vector<beans::PropertyValue>& rLsdExceptions =
m_pImpl->m_pCurrentEntry->m_aLsdExceptions;
833 beans::PropertyValue aValue;
834 aValue.Name =
"lsdExceptions";
836 rLatentStyles.push_back(aValue);
845 auto aGrabBag = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(xPropertySet->getPropertyValue(
"InteropGrabBag").get<
uno::Sequence<beans::PropertyValue> >());
846 beans::PropertyValue aValue;
847 aValue.Name =
"latentStyles";
848 aValue.Value <<= aLatentStyles;
849 aGrabBag.push_back(aValue);
854 m_pImpl->m_pCurrentEntry = pEmptyEntry;
867 void Insert(
const beans::PropertyValue& rVal);
868 uno::Sequence< uno::Any > getValues();
869 uno::Sequence< OUString > getNames();
870 const std::vector<beans::PropertyValue>& getProperties()
const {
return m_aValues; };
875void PropValVector::Insert(
const beans::PropertyValue& rVal)
878 [&rVal](beans::PropertyValue& rPropVal) { return rPropVal.Name > rVal.Name; });
887uno::Sequence< uno::Any > PropValVector::getValues()
889 std::vector<uno::Any> aRet;
890 std::transform(
m_aValues.begin(),
m_aValues.end(), std::back_inserter(aRet), [](
const beans::PropertyValue& rValue) { return rValue.Value; });
894uno::Sequence< OUString > PropValVector::getNames()
896 std::vector<OUString> aRet;
897 std::transform(
m_aValues.begin(),
m_aValues.end(), std::back_inserter(aRet), [](
const beans::PropertyValue& rValue) { return rValue.Name; });
911 if ( !xParaStyles.is() )
914 for (
const auto& pEntry :
m_pImpl->m_aStyleSheetEntries )
917 if ( pEntry->m_nStyleTypeCode ==
STYLE_TYPE_PARA && (pStyleSheetProperties = pEntry->m_pProperties.get()) )
923 xParaStyles->getByName(
ConvertStyleName(pEntry->m_sStyleName) ) >>= xStyle;
929 const OUString sNumberingStyleName =
m_pImpl->m_rDMapper.GetListStyleName( pStyleSheetProperties->
props().
GetListId() );
930 if ( !sNumberingStyleName.isEmpty()
938 m_pImpl->m_rDMapper.ValidateListLevel(pEntry->m_sStyleIdentifierD);
943 catch(
const uno::Exception& )
965 if (!xParaStyles.is())
968 for (
const auto& pEntry :
m_pImpl->m_aStyleSheetEntries)
970 if (pEntry->m_nStyleTypeCode !=
STYLE_TYPE_PARA || pEntry->m_sBaseStyleIdentifier.isEmpty())
974 if (!pParent || !pParent->m_bAssignedAsChapterNumbering)
978 xParaStyles->getByName(pEntry->m_sConvertedStyleName) >>= xStyle;
983 const sal_Int16 nListId = pEntry->m_pProperties->props().GetListId();
984 const OUString& sParentNumberingStyleName
985 =
m_pImpl->m_rDMapper.GetListStyleName(pParent->m_pProperties->props().GetListId());
986 if (nListId == -1 && !sParentNumberingStyleName.isEmpty())
989 uno::Any(sParentNumberingStyleName));
992 sal_Int16 nOutlineLevel = pEntry->m_pProperties->GetOutlineLevel();
993 if (nOutlineLevel != -1)
996 nOutlineLevel = pParent->m_pProperties->GetOutlineLevel();
1005 catch(
const uno::Exception& )
1016 while (xParaEnum->hasMoreElements())
1019 if (xElem->supportsService(
u"com.sun.star.text.Paragraph"))
1023 if (xPara->getPropertyValue(
u"ParaStyleName") >>= styleName)
1028 xPara->setPropertyValue(
u"ParaStyleName",
uno::Any(it->second));
1032 else if (xElem->supportsService(
u"com.sun.star.text.TextTable"))
1036 for (OUString
const& rCell : cells)
1054 if (
m_pImpl->m_ClonedTOCStylesMap.empty()
1059 SAL_INFO(
"writerfilter.dmapper",
"Applying cloned styles to make TOC work");
1065 while (xFramesEnum->hasMoreElements())
1072 m_pImpl->ApplyClonedTOCStylesToXText(xBody);
1078 pClone->m_sStyleIdentifierD = rNewName;
1079 pClone->m_sStyleName = rNewName;
1081 m_pImpl->m_aStyleSheetEntries.push_back(pClone);
1083 m_pImpl->m_aStyleSheetEntriesMap.emplace(rNewName, pClone);
1084 m_pImpl->m_ClonedTOCStylesMap.emplace(pStyle->m_sStyleName, pClone->m_sConvertedStyleName);
1085 std::vector<StyleSheetEntryPtr>
const styles{ pClone };
1087 return pClone->m_sConvertedStyleName;
1108 xStyleFamilies->getByName(
"NumberingStyles") >>= xNumberingStyles;
1109 if(xCharStyles.is() && xParaStyles.is())
1111 std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingParent;
1112 std::vector< ::std::pair<OUString, uno::Reference<style::XStyle>> > aMissingFollow;
1113 std::vector<std::pair<OUString, uno::Reference<style::XStyle>>> aMissingLink;
1114 std::vector<beans::PropertyValue> aTableStylesVec;
1115 for (
auto& pEntry : rEntries)
1117 if( pEntry->m_nStyleTypeCode ==
STYLE_TYPE_UNKNOWN && !pEntry->m_sStyleName.isEmpty() )
1125 bool bInsert =
false;
1128 const OUString sConvertedStyleName =
ConvertStyleName( pEntry->m_sStyleName );
1130 if(xStyles->hasByName( sConvertedStyleName ))
1137 xStyles->getByName( sConvertedStyleName ) >>= xStyle;
1143 if (
m_pImpl->m_bHasImportedDefaultParaProps
1144 && pEntry->m_sBaseStyleIdentifier.isEmpty()
1145 && !xStyle->getParentStyle().isEmpty() )
1147 xStyle->setParentStyle(
"" );
1154 xStyle.set(xDocFactory->createInstance(
1158 uno::UNO_QUERY_THROW);
1163 xStyles->insertByName( sConvertedStyleName,
uno::Any( xStyle ) );
1164 xStyle.set(xStyles->getByName(sConvertedStyleName), uno::UNO_QUERY_THROW);
1172 xPropertySet->getPropertyValue(
"NumberingRules") >>= xNumberingRules;
1174 for (sal_Int32
i = 0;
i < xIndexAccess->getCount(); ++
i)
1178 "NumberingType", style::NumberingType::NUMBER_NONE)
1180 xNumberingRules->replaceByIndex(
i,
uno::Any(aLvlProps));
1181 xPropertySet->setPropertyValue(
"NumberingRules",
uno::Any(xNumberingRules));
1186 if( !pEntry->m_sBaseStyleIdentifier.isEmpty() )
1193 if (pParent && !bListStyle)
1195 const OUString sParentStyleName =
ConvertStyleName( pParent->m_sStyleName );
1196 if ( !sParentStyleName.isEmpty() && !xStyles->hasByName( sParentStyleName ) )
1197 aMissingParent.emplace_back( sParentStyleName, xStyle );
1199 xStyle->setParentStyle( sParentStyleName );
1202 catch(
const uno::RuntimeException& )
1204 OSL_FAIL(
"Styles parent could not be set");
1207 else if( bParaStyle )
1210 pEntry->m_pProperties->InsertProps(
m_pImpl->m_pDefaultParaProps,
false );
1217 sal_uInt32 nFontCount = rFontTable->size();
1218 if( !
m_pImpl->m_rDMapper.IsOOXMLImport() && nFontCount > 2 )
1220 uno::Any aTwoHundredFortyTwip(12.);
1223 pEntry->m_pProperties->Insert(
PROP_CHAR_HEIGHT, aTwoHundredFortyTwip,
false);
1227 OUString sWesternFontName = pWesternFontEntry->sFontName;
1236 if( nFontCount > 3 )
1245 auto aPropValues = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pEntry->m_pProperties->GetPropertyValues());
1247 if (bParaStyle || bCharStyle)
1250 if (!pEntry->m_sLinkStyleIdentifier.isEmpty())
1254 if (pLinkStyle && !pLinkStyle->m_sStyleName.isEmpty())
1263 if ( !pEntry->m_sNextStyleIdentifier.isEmpty() )
1266 if ( pFollowStyle && !pFollowStyle->m_sStyleName.isEmpty() )
1267 aMissingFollow.emplace_back(
ConvertStyleName( pFollowStyle->m_sStyleName ), xStyle );
1273 if ( pStyleSheetProperties )
1286 beans::PropertyState_DIRECT_VALUE);
1287 aPropValues.push_back(aLvlVal);
1292 if( sConvertedStyleName ==
"Contents Heading" ||
1293 sConvertedStyleName ==
"User Index Heading" ||
1294 sConvertedStyleName ==
"Index Heading" )
1300 else if ( sConvertedStyleName ==
"Text body" )
1302 else if ( sConvertedStyleName ==
"Heading 1" ||
1303 sConvertedStyleName ==
"Heading 2" ||
1304 sConvertedStyleName ==
"Heading 3" ||
1305 sConvertedStyleName ==
"Heading 4" ||
1306 sConvertedStyleName ==
"Heading 5" ||
1307 sConvertedStyleName ==
"Heading 6" ||
1308 sConvertedStyleName ==
"Heading 7" ||
1309 sConvertedStyleName ==
"Heading 8" ||
1310 sConvertedStyleName ==
"Heading 9" )
1325 if ( !aPropValues.empty() )
1327 PropValVector aSortedPropVals;
1328 for (
const beans::PropertyValue& rValue : aPropValues)
1331 bool bIsParaStyleName = rValue.Name ==
"ParaStyleName";
1332 bool bIsCharStyleName = rValue.Name ==
"CharStyleName";
1333 if ( !bIsParaStyleName && !bIsCharStyleName )
1335 aSortedPropVals.Insert(rValue);
1344 xMultiPropertySet->setPropertyValues( aSortedPropVals.getNames(), aSortedPropVals.getValues() );
1346 catch (
const uno::Exception& )
1349 for (
const beans::PropertyValue& rValue : aSortedPropVals.getProperties() )
1353 xPropertySet->setPropertyValue( rValue.Name, rValue.Value );
1355 catch (
const uno::Exception& )
1357 SAL_WARN(
"writerfilter",
"StyleSheetTable::ApplyStyleSheets could not set property " << rValue.Name );
1362 if( pEntry->m_sStyleName.equalsIgnoreAsciiCase(
"footnote reference")
1363 || pEntry->m_sStyleName.equalsIgnoreAsciiCase(
"endnote reference") )
1366 if( pEntry->m_sStyleName.equalsIgnoreAsciiCase(
"footnote reference") )
1367 xStyles->getByName(
"Footnote anchor" ) >>= xCopyStyle;
1369 xStyles->getByName(
"Endnote anchor" ) >>= xCopyStyle;
1371 xMultiPropertySet.set( xCopyStyle, uno::UNO_QUERY_THROW);
1372 xMultiPropertySet->setPropertyValues( aSortedPropVals.getNames(), aSortedPropVals.getValues() );
1375 catch(
const lang::WrappedTargetException& rWrapped)
1378 OUString aMessage(
"StyleSheetTable::ApplyStyleSheets: Some style properties could not be set");
1379 beans::UnknownPropertyException aUnknownPropertyException;
1381 if (rWrapped.TargetException >>= aUnknownPropertyException)
1382 aMessage +=
": " + aUnknownPropertyException.Message;
1384 SAL_WARN(
"writerfilter", aMessage);
1389 catch(
const uno::Exception& )
1391 OSL_FAIL(
"Some style properties could not be set");
1395 if(bInsert && !bListStyle)
1397 const OUString sParentStyle = xStyle->getParentStyle();
1398 if( !sParentStyle.isEmpty() && !xStyles->hasByName( sParentStyle ) )
1399 aMissingParent.emplace_back( sParentStyle, xStyle );
1401 xStyles->insertByName( sConvertedStyleName,
uno::Any( xStyle) );
1404 beans::PropertyValues aGrabBag = pEntry->GetInteropGrabBagSeq();
1406 if (aGrabBag.hasElements())
1408 xPropertySet->setPropertyValue(
"StyleInteropGrabBag",
uno::Any(aGrabBag));
1412 if (pEntry->m_bAutoRedefine && bParaStyle)
1413 xPropertySet->setPropertyValue(
"IsAutoUpdate",
uno::Any(
true));
1423 pEntry->m_pProperties->InsertProps(
m_pImpl->m_pDefaultParaProps,
false );
1428 for(
auto const & iter : aMissingParent )
1430 iter.second->setParentStyle( iter.first );
1433 for(
auto const & iter : aMissingFollow )
1438 xPropertySet->setPropertyValue(
"FollowStyle",
uno::Any(iter.first) );
1440 catch( uno::Exception & ) {}
1444 for (
auto const& rLinked : aMissingLink)
1450 xPropertySet->setPropertyValue(
"LinkStyle",
uno::Any(rLinked.first));
1452 catch (uno::Exception&)
1456 "StyleSheetTable::ApplyStyleSheets: failed to set LinkStyle");
1460 if (!aTableStylesVec.empty())
1464 uno::Any aAny = xPropertySet->getPropertyValue(
"InteropGrabBag");
1466 beans::PropertyValue aValue;
1467 aValue.Name =
"tableStyles";
1469 aGrabBag.push_back(aValue);
1474 catch(
const uno::Exception& )
1483 auto findIt =
m_pImpl->m_aStyleSheetEntriesMap.find(sIndex);
1484 if (findIt !=
m_pImpl->m_aStyleSheetEntriesMap.end())
1485 return findIt->second;
1495 if( rpEntry->m_sConvertedStyleName == sIndex)
1512 return m_pImpl->m_pCurrentEntry;
1517 OUString sRet( rWWName );
1518 if( bExtendedSearch )
1521 auto findIt =
m_pImpl->m_aStyleSheetEntriesMap.find(rWWName);
1522 if (findIt !=
m_pImpl->m_aStyleSheetEntriesMap.end())
1524 if (!findIt->second->m_sConvertedStyleName.isEmpty())
1525 return findIt->second->m_sConvertedStyleName;
1526 sRet = findIt->second->m_sStyleName;
1539 static const std::map< OUString, OUString> StyleNameMap {
1540 {
"Normal",
"Standard" },
1541 {
"heading 1",
"Heading 1" },
1542 {
"heading 2",
"Heading 2" },
1543 {
"heading 3",
"Heading 3" },
1544 {
"heading 4",
"Heading 4" },
1545 {
"heading 5",
"Heading 5" },
1546 {
"heading 6",
"Heading 6" },
1547 {
"heading 7",
"Heading 7" },
1548 {
"heading 8",
"Heading 8" },
1549 {
"heading 9",
"Heading 9" },
1550 {
"Heading 1",
"Heading 1" },
1551 {
"Heading 2",
"Heading 2" },
1552 {
"Heading 3",
"Heading 3" },
1553 {
"Heading 4",
"Heading 4" },
1554 {
"Heading 5",
"Heading 5" },
1555 {
"Heading 6",
"Heading 6" },
1556 {
"Heading 7",
"Heading 7" },
1557 {
"Heading 8",
"Heading 8" },
1558 {
"Heading 9",
"Heading 9" },
1559 {
"Index 1",
"Index 1" },
1560 {
"Index 2",
"Index 2" },
1561 {
"Index 3",
"Index 3" },
1568 {
"TOC 1",
"Contents 1" },
1569 {
"TOC 2",
"Contents 2" },
1570 {
"TOC 3",
"Contents 3" },
1571 {
"TOC 4",
"Contents 4" },
1572 {
"TOC 5",
"Contents 5" },
1573 {
"TOC 6",
"Contents 6" },
1574 {
"TOC 7",
"Contents 7" },
1575 {
"TOC 8",
"Contents 8" },
1576 {
"TOC 9",
"Contents 9" },
1577 {
"TOC Heading",
"Contents Heading" },
1578 {
"TOCHeading",
"Contents Heading" },
1579 {
"toc 1",
"Contents 1" },
1580 {
"toc 2",
"Contents 2" },
1581 {
"toc 3",
"Contents 3" },
1582 {
"toc 4",
"Contents 4" },
1583 {
"toc 5",
"Contents 5" },
1584 {
"toc 6",
"Contents 6" },
1585 {
"toc 7",
"Contents 7" },
1586 {
"toc 8",
"Contents 8" },
1587 {
"toc 9",
"Contents 9" },
1588 {
"TOC1",
"Contents 1" },
1589 {
"TOC2",
"Contents 2" },
1590 {
"TOC3",
"Contents 3" },
1591 {
"TOC4",
"Contents 4" },
1592 {
"TOC5",
"Contents 5" },
1593 {
"TOC6",
"Contents 6" },
1594 {
"TOC7",
"Contents 7" },
1595 {
"TOC8",
"Contents 8" },
1596 {
"TOC9",
"Contents 9" },
1598 {
"footnote text",
"Footnote" },
1599 {
"Footnote Text",
"Footnote" },
1600 {
"Annotation Text",
"Marginalia" },
1601 {
"Header",
"Header" },
1602 {
"header",
"Header" },
1603 {
"Footer",
"Footer" },
1604 {
"footer",
"Footer" },
1605 {
"Index Heading",
"Index Heading" },
1606 {
"Caption",
"Caption" },
1607 {
"table of figures",
"Figure Index 1" },
1608 {
"Table of Figures",
"Figure Index 1" },
1609 {
"Envelope Address",
"Addressee" },
1610 {
"Envelope Return",
"Sender" },
1611 {
"footnote reference",
"Footnote Symbol" },
1612 {
"Footnote Reference",
"Footnote Symbol" },
1614 {
"Line Number",
"Line numbering" },
1615 {
"Page Number",
"Page Number" },
1616 {
"endnote reference",
"Endnote Symbol" },
1617 {
"Endnote Reference",
"Endnote Symbol" },
1618 {
"endnote text",
"Endnote" },
1619 {
"Endnote Text",
"Endnote" },
1620 {
"Table of Authorities",
"Bibliography Heading" },
1628 {
"List Bullet",
"List 1" },
1629 {
"List Bullet 2",
"List 2" },
1630 {
"List Bullet 3",
"List 3" },
1631 {
"List Bullet 4",
"List 4" },
1632 {
"List Bullet 5",
"List 5" },
1633 {
"List Number",
"Numbering 1" },
1634 {
"List Number 2",
"Numbering 2" },
1635 {
"List Number 3",
"Numbering 3" },
1636 {
"List Number 4",
"Numbering 4" },
1637 {
"List Number 5",
"Numbering 5" },
1638 {
"Title",
"Title" },
1639 {
"Closing",
"Appendix" },
1640 {
"Signature",
"Signature" },
1642 {
"DefaultParagraphFont",
"Default Paragraph Font" },
1643 {
"Body Text",
"Text body" },
1644 {
"BodyText",
"Text body" },
1645 {
"BodyTextIndentItalic",
"Text body indent italic" },
1646 {
"Body Text Indent",
"Text body indent" },
1647 {
"BodyTextIndent",
"Text body indent" },
1648 {
"BodyTextIndent2",
"Text body indent2" },
1649 {
"List Continue",
"List 1 Cont." },
1650 {
"List Continue 2",
"List 2 Cont." },
1651 {
"List Continue 3",
"List 3 Cont." },
1652 {
"List Continue 4",
"List 4 Cont." },
1653 {
"List Continue 5",
"List 5 Cont." },
1655 {
"Subtitle",
"Subtitle" },
1656 {
"Salutation",
"Salutation" },
1658 {
"Body Text First Indent",
"First line indent" },
1666 {
"Hyperlink",
"Internet link" },
1667 {
"FollowedHyperlink",
"Visited Internet Link" },
1668 {
"Strong",
"Strong Emphasis" },
1669 {
"Emphasis",
"Emphasis" },
1672 {
"NoList",
"No List" },
1673 {
"AbstractHeading",
"Abstract Heading" },
1674 {
"AbstractBody",
"Abstract Body" },
1675 {
"PageNumber",
"Page Number" },
1676 {
"TableNormal",
"Normal Table" },
1677 {
"DocumentMap",
"Document Map" },
1681 if (
const auto aIt = StyleNameMap.find(sRet); aIt != StyleNameMap.end())
1690 for (
const auto& pair : StyleNameMap)
1691 set.insert(pair.second);
1703 if (ReservedStyleNames.
find(sRet) != ReservedStyleNames.
end() || sRet.endsWith(
" (WW)"))
1721 if(!
m_pImpl->m_xTextDefaults.is())
1724 m_pImpl->m_rDMapper.GetTextFactory()->createInstance(
"com.sun.star.text.Defaults"),
1725 uno::UNO_QUERY_THROW );
1729 if( bParaProperties &&
m_pImpl->m_pDefaultParaProps)
1743 xStyleFamilies->getByName(
"ParagraphStyles") >>= xParagraphStyles;
1746 xParagraphStyles->getByName(
"Paragraph style") >>= xDefault;
1749 for(
const auto& rPropValue : aPropValues )
1753 xDefault->setPropertyValue(rPropValue.Name, rPropValue.Value);
1755 catch(
const uno::Exception& )
1761 if( !bParaProperties &&
m_pImpl->m_pDefaultCharProps )
1766 if (
m_pImpl->m_rDMapper.IsOOXMLImport() )
1770 for(
const auto& rPropValue : aPropValues )
1774 m_pImpl->m_xTextDefaults->setPropertyValue( rPropValue.Name, rPropValue.Value );
1776 catch(
const uno::Exception& )
1783 catch(
const uno::Exception& )
1792 OUString sListLabel =
m_pImpl->HasListCharStyle(rCharProperties);
1794 if( !sListLabel.isEmpty() && !bAlwaysCreate)
1799 sListLabel =
m_pImpl->m_rDMapper.GetUnusedCharacterStyleName();
1806 for(
const auto& rCharProp : rCharProperties)
1810 xStyleProps->setPropertyValue( rCharProp.Name, rCharProp.Value );
1812 catch(
const uno::Exception& )
1814 TOOLS_WARN_EXCEPTION(
"writerfilter",
"StyleSheetTable::getOrCreateCharStyle - Style::setPropertyValue");
1817 xCharStyles->insertByName( sListLabel,
uno::Any( xStyle) );
1818 m_pImpl->m_aListCharStylePropertyVector.emplace_back( sListLabel, std::vector(rCharProperties) );
1820 catch(
const uno::Exception& )
std::vector< css::beans::PropertyValue > PropertyValueVector_t
PropertyValueVector_t aPropertyValues
std::vector< beans::PropertyValue > m_aValues
PropertiesInfo aProperties
const_iterator find(const Value &x) const
const_iterator end() const
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
virtual Value::Pointer_t getValue()=0
Returns value of the SPRM.
static TagLogger & getInstance()
void element(const std::string &name)
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
Handler for a latent style (w:lsdException element)
ParagraphProperties & props()
sal_Int32 GetListId() const
OUString m_sLinkStyleIdentifier
OUString m_sNextStyleIdentifier
virtual ~StyleSheetEntry() override
OUString m_sBaseStyleIdentifier
css::beans::PropertyValue GetInteropGrabBag()
Used for table styles, has a name.
css::beans::PropertyValues GetInteropGrabBagSeq() const
Used for existing styles, just a list of properties.
const tools::SvRef< StyleSheetPropertyMap > m_pProperties
StyleType m_nStyleTypeCode
std::vector< css::beans::PropertyValue > m_aInteropGrabBag
PropertyMapPtr GetMergedInheritedProperties(const StyleSheetTablePtr &pStyleSheetTable)
OUString m_sStyleIdentifierD
void AppendInteropGrabBag(const css::beans::PropertyValue &rValue)
sal_Int16 GetOutlineLevel() const
void ApplyStyleSheetsImpl(const FontTablePtr &rFontTable, std::vector< StyleSheetEntryPtr > const &rEntries)
void ApplyClonedTOCStyles()
Replace the applied en-US Word built-in styles that were referenced from TOC fields (also STYLEREF an...
void ReApplyInheritedOutlineLevelFromChapterNumbering()
OUString CloneTOCStyle(FontTablePtr const &rFontTable, StyleSheetEntryPtr const pStyle, OUString const &rName)
virtual void lcl_sprm(Sprm &sprm) override
StyleSheetEntryPtr FindStyleSheetByConvertedStyleName(std::u16string_view rIndex)
StyleSheetEntryPtr FindDefaultParaStyle()
void SetDefaultParaProps(PropertyIds eId, const css::uno::Any &rAny)
virtual void lcl_entry(writerfilter::Reference< Properties >::Pointer_t ref) override
OUString ConvertStyleName(const OUString &rWWName, bool bExtendedSearch=false)
void ApplyNumberingStyleNameToParaStyles()
PropertyMapPtr const & GetDefaultParaProps() const
OUString getOrCreateCharStyle(PropertyValueVector_t &rCharProperties, bool bAlwaysCreate)
const StyleSheetEntryPtr & GetCurrentEntry() const
StyleSheetEntryPtr FindStyleSheetByISTD(const OUString &sIndex)
std::unique_ptr< StyleSheetTable_Impl > m_pImpl
void applyDefaults(bool bParaProperties)
virtual ~StyleSheetTable() override
PropertyMapPtr const & GetDefaultCharProps() const
Returns the default character properties.
StyleSheetTable(DomainMapper &rDMapper, css::uno::Reference< css::text::XTextDocument > const &xTextDocument, bool bIsNewDoc)
void ApplyStyleSheets(const FontTablePtr &rFontTable)
virtual void lcl_attribute(Id Name, Value &val) override
TableStyleSheetEntry(StyleSheetEntry const &aEntry)
PropertyMapPtr GetLocalPropertiesFromMask(sal_Int32 nMask)
void AddTblStylePr(TblStyleType nType, const PropertyMapPtr &pProps)
virtual ~TableStyleSheetEntry() override
PropertyMapPtr GetProperties(sal_Int32 nMask)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
void set(css::uno::UnoInterfaceReference const &value)
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
sal_Int16 convertTableJustification(sal_Int32 nIntValue)
OUString getPropertyName(PropertyIds eId)
tools::SvRef< StyleSheetEntry > StyleSheetEntryPtr
static void lcl_mergeProps(const PropertyMapPtr &pToFill, const PropertyMapPtr &pToAdd, TblStyleType nStyleId)
@ PROP_SERVICE_PARA_STYLE
@ PROP_CHAR_HEIGHT_COMPLEX
@ PROP_CHAR_PROP_HEIGHT_COMPLEX
@ PROP_CHAR_PROP_HEIGHT_ASIAN
@ PROP_CHAR_POSTURE_ASIAN
@ PROP_CHAR_FONT_NAME_ASIAN
@ META_PROP_HORIZONTAL_BORDER
@ META_PROP_VERTICAL_BORDER
@ PROP_CHAR_POSTURE_COMPLEX
@ PROP_CHAR_WEIGHT_COMPLEX
@ PROP_NUMBERING_STYLE_NAME
@ PROP_PARA_BOTTOM_MARGIN
@ PROP_SERVICE_CHAR_STYLE
@ PROP_CHAR_FONT_NAME_COMPLEX
void resolveSprmProps(Properties &rHandler, Sprm &rSprm)
bool m_bHasImportedDefaultParaProps
void AppendLatentStyleProperty(const OUString &aName, Value const &rValue)
Appends the given key-value pair to the list of latent style properties of the current entry.
PropertyMapPtr m_pDefaultCharProps
static void SetPropertiesToDefault(const uno::Reference< style::XStyle > &xStyle)
Sets all properties of xStyle back to default.
uno::Reference< beans::XPropertySet > m_xTextDefaults
OUString m_sDefaultParaStyleName
uno::Reference< text::XTextDocument > m_xTextDocument
StyleSheetTable_Impl(DomainMapper &rDMapper, uno::Reference< text::XTextDocument > xTextDocument, bool bIsNewDoc)
std::map< OUString, StyleSheetEntryPtr > m_aStyleSheetEntriesMap
DomainMapper & m_rDMapper
OUString HasListCharStyle(const PropertyValueVector_t &rCharProperties)
std::vector< ListCharStylePropertyMap_t > m_aListCharStylePropertyVector
std::map< OUString, OUString > m_ClonedTOCStylesMap
void ApplyClonedTOCStylesToXText(uno::Reference< text::XText > const &xText)
std::vector< StyleSheetEntryPtr > m_aStyleSheetEntries
StyleSheetEntryPtr m_pCurrentEntry
PropertyMapPtr m_pDefaultParaProps
Reference< XFrame > xFrame
PointerStyles const styles[]