22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
24 #include <com/sun/star/style/NumberingType.hpp>
25 #include <com/sun/star/style/XStyle.hpp>
26 #include <com/sun/star/container/XIndexReplace.hpp>
27 #include <com/sun/star/awt/XBitmap.hpp>
28 #include <com/sun/star/graphic/XGraphic.hpp>
29 #include <com/sun/star/awt/FontDescriptor.hpp>
30 #include <com/sun/star/text/HoriOrientation.hpp>
31 #include <com/sun/star/text/VertOrientation.hpp>
32 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
33 #include <com/sun/star/text/PositionAndSpaceMode.hpp>
34 #include <com/sun/star/text/LabelFollow.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <rtl/ustrbuf.hxx>
66 sal_Int32
nCount = xNumRule ->getCount();
67 for( sal_Int32
i=0;
i<nCount;
i++ )
69 uno::Any aEntry( xNumRule->getByIndex(
i ) );
70 uno::Sequence<beans::PropertyValue>
aSeq;
79 const uno::Sequence<beans::PropertyValue>& rProps,
82 sal_Int16
eType = NumberingType::CHAR_SPECIAL;
84 sal_Int16 eAdjust = HoriOrientation::LEFT;
86 OUString sTextStyleName;
87 bool bHasColor =
false;
89 sal_Int32 nSpaceBefore = 0, nMinLabelWidth = 0, nMinLabelDist = 0;
91 sal_Int16 nStartValue = 1, nDisplayLevels = 1, nBullRelSize = 0;
97 rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;
99 uno::Reference<graphic::XGraphic> xGraphic;
101 sal_Int32 nImageWidth = 0, nImageHeight = 0;
102 sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER;
104 sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
105 sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
106 sal_Int32 nListtabStopPosition( 0 );
107 sal_Int32 nFirstLineIndent( 0 );
108 sal_Int32 nIndentAt( 0 );
110 for(
const beans::PropertyValue& rProp : rProps )
112 if( rProp.Name ==
"NumberingType" )
114 rProp.Value >>= eType;
116 else if( rProp.Name ==
"Prefix" )
120 else if( rProp.Name ==
"Suffix" )
122 rProp.Value >>= sSuffix;
124 else if (rProp.Name ==
"ListFormat")
126 rProp.Value >>= sListFormat;
128 else if (rProp.Name ==
"BulletChar")
131 rProp.Value >>= sValue;
132 if( !sValue.isEmpty() )
137 else if( rProp.Name ==
"BulletRelSize" )
139 rProp.Value >>= nBullRelSize;
141 else if( rProp.Name ==
"Adjust" )
144 rProp.Value >>= nValue;
147 else if( rProp.Name ==
"BulletFont" )
149 awt::FontDescriptor rFDesc;
150 if( rProp.Value >>= rFDesc )
152 sBulletFontName = rFDesc.Name;
153 sBulletFontStyleName = rFDesc.StyleName;
154 eBulletFontFamily =
static_cast< FontFamily >( rFDesc.Family );
155 eBulletFontPitch =
static_cast< FontPitch >( rFDesc.Pitch );
156 eBulletFontEncoding =
static_cast<rtl_TextEncoding
>(rFDesc.CharSet);
159 else if( rProp.Name ==
"GraphicBitmap" )
161 uno::Reference<awt::XBitmap> xBitmap;
162 rProp.Value >>= xBitmap;
163 xGraphic.set(xBitmap, uno::UNO_QUERY);
165 else if( rProp.Name ==
"BulletColor" )
167 rProp.Value >>= nColor;
170 else if( rProp.Name ==
"StartWith" )
172 rProp.Value >>= nStartValue;
174 else if( rProp.Name ==
"LeftMargin" )
176 rProp.Value >>= nSpaceBefore;
178 else if( rProp.Name ==
"FirstLineOffset" )
180 rProp.Value >>= nMinLabelWidth;
182 else if( rProp.Name ==
"SymbolTextDistance" )
184 rProp.Value >>= nMinLabelDist;
186 else if( rProp.Name ==
"ParentNumbering" )
188 rProp.Value >>= nDisplayLevels;
189 if( nDisplayLevels > nLevel+1 )
190 nDisplayLevels =
static_cast<sal_Int16
>( nLevel )+1;
192 else if( rProp.Name ==
"CharStyleName" )
194 rProp.Value >>= sTextStyleName;
196 else if( rProp.Name ==
"GraphicSize" )
199 if( rProp.Value >>= aSize )
201 nImageWidth = aSize.Width;
202 nImageHeight = aSize.Height;
205 else if( rProp.Name ==
"VertOrient" )
208 rProp.Value >>= nValue;
209 eImageVertOrient = nValue;
211 else if( rProp.Name ==
"PositionAndSpaceMode" )
214 rProp.Value >>= nValue;
215 ePosAndSpaceMode = nValue;
217 else if( rProp.Name ==
"LabelFollowedBy" )
220 rProp.Value >>= nValue;
221 eLabelFollowedBy = nValue;
223 else if( rProp.Name ==
"ListtabStopPosition" )
225 rProp.Value >>= nListtabStopPosition;
227 else if( rProp.Name ==
"FirstLineIndent" )
229 rProp.Value >>= nFirstLineIndent;
231 else if( rProp.Name ==
"IndentAt" )
233 rProp.Value >>= nIndentAt;
237 if( bOutline && (NumberingType::CHAR_SPECIAL == eType ||
238 NumberingType::BITMAP == eType) )
241 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
252 if (NumberingType::BITMAP != eType)
254 if (!sTextStyleName.isEmpty())
257 GetExport().EncodeStyleName( sTextStyleName ) );
259 if (!sListFormat.isEmpty())
268 if (!sPrefix.isEmpty())
273 if (!sSuffix.isEmpty())
281 if( NumberingType::CHAR_SPECIAL == eType )
290 cBullet = 0xF000 + 149;
293 sTmp.append(OUString(&cBullet, 1));
295 sTmp.makeStringAndClear() );
303 else if( NumberingType::BITMAP == eType )
311 OUString sUsedMimeType;
313 if (!sInternalURL.isEmpty())
323 SAL_WARN_IF(xGraphic.is(),
"xmloff",
"embedded images are not supported by now");
336 sTmp.makeStringAndClear() );
338 if( !sTmp.isEmpty() )
341 sTmp.makeStringAndClear() );
343 if( nStartValue != 1 )
345 sTmp.append( static_cast<sal_Int32>(nStartValue) );
347 sTmp.makeStringAndClear() );
349 if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE != eType )
351 sTmp.append( static_cast<sal_Int32>(nDisplayLevels) );
353 sTmp.makeStringAndClear() );
361 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
363 nSpaceBefore += nMinLabelWidth;
364 nMinLabelWidth = -nMinLabelWidth;
365 if( nSpaceBefore != 0 )
371 if( nMinLabelWidth != 0 )
376 if( nMinLabelDist > 0 )
386 else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
393 if( HoriOrientation::LEFT != eAdjust )
398 case HoriOrientation::RIGHT: eValue =
XML_END;
break;
399 case HoriOrientation::CENTER: eValue =
XML_CENTER;
break;
405 if( NumberingType::BITMAP == eType )
408 switch( eImageVertOrient )
410 case VertOrientation::BOTTOM:
412 case VertOrientation::LINE_TOP:
413 case VertOrientation::CHAR_TOP:
416 case VertOrientation::CENTER:
417 case VertOrientation::LINE_CENTER:
418 case VertOrientation::CHAR_CENTER:
421 case VertOrientation::TOP:
423 case VertOrientation::LINE_BOTTOM:
424 case VertOrientation::CHAR_BOTTOM:
432 switch( eImageVertOrient )
434 case VertOrientation::TOP:
435 case VertOrientation::CENTER:
436 case VertOrientation::BOTTOM:
439 case VertOrientation::LINE_TOP:
440 case VertOrientation::LINE_CENTER:
441 case VertOrientation::LINE_BOTTOM:
444 case VertOrientation::CHAR_TOP:
445 case VertOrientation::CHAR_CENTER:
446 case VertOrientation::CHAR_BOTTOM:
453 if( nImageWidth > 0 )
460 if( nImageHeight > 0 )
475 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
479 if ( eLabelFollowedBy == LabelFollow::SPACE )
483 else if ( eLabelFollowedBy == LabelFollow::NOTHING )
490 if (eLabelFollowedBy == LabelFollow::NEWLINE)
497 if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
498 nListtabStopPosition > 0 )
501 nListtabStopPosition );
507 if ( nFirstLineIndent != 0 )
516 if ( nIndentAt != 0 )
531 if( NumberingType::CHAR_SPECIAL == eType )
533 if( !sBulletFontName.isEmpty() )
535 OUString sStyleName =
537 sBulletFontName, sBulletFontStyleName,
538 eBulletFontFamily, eBulletFontPitch,
539 eBulletFontEncoding );
541 if( !sStyleName.isEmpty() )
554 if( aFamilyNameHdl.
exportXML( sTemp,
Any(sBulletFontName), rUnitConv ) )
558 if( !sBulletFontStyleName.isEmpty() )
561 sBulletFontStyleName );
564 if( aFamilyHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontFamily)), rUnitConv ) )
570 if( aPitchHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontPitch)), rUnitConv ) )
575 if( aEncHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontEncoding)), rUnitConv ) )
581 if( NumberingType::BITMAP != eType )
586 if (0xffffffff == static_cast<sal_uInt32>(nColor))
592 OUStringBuffer sBuffer;
595 sBuffer.makeStringAndClear() );
603 sTmp.makeStringAndClear() );
611 if (xGraphic.is() && NumberingType::BITMAP == eType)
621 constexpr OUStringLiteral
gsIsPhysical( u
"IsPhysical" );
627 mbExportPositionAndSpaceModeLabelAlignment( true )
629 switch (
GetExport().getSaneDefaultVersion())
645 const OUString& rName,
bool bIsHidden,
646 const Reference< XIndexReplace >& rNumRule )
649 Reference< XPropertySetInfo > xPropSetInfo;
651 xPropSetInfo = xPropSet->getPropertySetInfo();
656 if( !rName.isEmpty() )
658 bool bEncoded =
false;
660 GetExport().EncodeStyleName( rName, &bEncoded ) );
675 bool bContNumbering =
false;
676 if( xPropSetInfo.is() &&
680 bContNumbering = *o3tl::doAccess<bool>(aAny);
696 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
705 if( !*o3tl::doAccess<bool>(aAny) )
710 Reference<XIndexReplace> xNumRule;
713 OUString
sName = rStyle->getName();
715 bool bHidden =
false;
716 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
718 aAny = xPropSet->getPropertyValue(
"Hidden" );
727 Reference< XChapterNumberingSupplier > xCNSupplier(
GetExport().GetModel(),
729 SAL_WARN_IF( !xCNSupplier.is(),
"xmloff",
"no chapter numbering supplier" );
731 if( !xCNSupplier.is() )
734 Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() );
735 SAL_WARN_IF( !xNumRule.is(),
"xmloff",
"no chapter numbering rules" );
743 OUString sOutlineStyleName;
746 xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
747 if (xNumRulePropSet.is())
749 xNumRulePropSet->getPropertyValue(
"Name" ) >>= sOutlineStyleName;
756 &&
GetExport().writeOutlineStyleAsNormalListStyle())
767 if ( !sOutlineStyleName.isEmpty() )
769 bool bEncoded =
false;
771 GetExport().EncodeStyleName( sOutlineStyleName,
787 bool bExportChapterNumbering )
789 if( bExportChapterNumbering )
792 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
GetExport().GetModel(), UNO_QUERY );
793 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"No XStyleFamiliesSupplier from XModel for export!" );
794 if( !xFamiliesSupp.is() )
798 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"getStyleFamilies() from XModel failed for export!" );
800 if( !xFamilies.is() )
803 static const OUStringLiteral aNumberStyleName(
u"NumberingStyles" );
805 Reference< XIndexAccess > xStyles;
806 if( !xFamilies->hasByName( aNumberStyleName ) )
809 xFamilies->getByName( aNumberStyleName ) >>= xStyles;
811 SAL_WARN_IF( !xStyles.is(),
"xmloff",
"Style not found for export!" );
816 const sal_Int32 nStyles = xStyles->getCount();
818 for( sal_Int32
i=0;
i < nStyles;
i++ )
820 Reference< XStyle > xStyle;
821 xStyles->getByIndex(
i ) >>= xStyle;
823 if( !bUsed || xStyle->isInUse() )
SvxXMLNumRuleExport(SvXMLExport &rExport)
SvXMLExport & GetExport()
PropertyHandler for the XML-data-type:
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
SAL_DLLPRIVATE void exportOutline()
SAL_DLLPRIVATE void exportStyle(const css::uno::Reference< css::style::XStyle > &rStyle)
constexpr OUStringLiteral gsNumberingRules(u"NumberingRules")
const SvXMLUnitConverter & GetMM100UnitConverter() const
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
SvXMLAttributeList & GetAttrList()
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, std::u16string_view rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
PropertyHandler for the XML-data-type:
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
PropertyHandler for the XML-data-type:
constexpr sal_uInt16 XML_NAMESPACE_FO
void RegisterName(const OUString &rName)
constexpr sal_uInt16 XML_NAMESPACE_TEXT
void exportStyles(bool bUsed, XMLTextListAutoStylePool *pPool, bool bExportChapterNumbering)
virtual sal_Int16 SAL_CALL getLength() override
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
constexpr T & temporary(T &&x)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
bool mbExportPositionAndSpaceModeLabelAlignment
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
#define SAL_WARN_IF(condition, area, stream)
rtl::Reference< XMLFontAutoStylePool > const & GetFontAutoStylePool()
void exportLevelStyles(const css::uno::Reference< css::container::XIndexReplace > &xNumRule, bool bOutline=false)
Handling of tokens in XML:
void exportNumberingRule(const OUString &rName, bool bIsHidden, const css::uno::Reference< css::container::XIndexReplace > &xNumRule)
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
XMLTokenEnum
The enumeration of all XML tokens.
Sequence< sal_Int8 > aSeq
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
PropertyHandler for the XML-data-type:
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr OUStringLiteral gsIsContinuousNumbering(u"IsContinuousNumbering")
SAL_DLLPRIVATE void exportLevelStyle(sal_Int32 nLevel, const css::uno::Sequence< css::beans::PropertyValue > &rProps, bool bOutline)