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();
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 bIsLegal =
false;
88 bool bHasColor =
false;
90 sal_Int32 nSpaceBefore = 0, nMinLabelWidth = 0, nMinLabelDist = 0;
92 sal_Int16 nStartValue = 1, nDisplayLevels = 1, nBullRelSize = 0;
98 rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;
100 uno::Reference<graphic::XGraphic> xGraphic;
102 sal_Int32 nImageWidth = 0, nImageHeight = 0;
103 sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER;
105 sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
106 sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
107 sal_Int32 nListtabStopPosition( 0 );
108 sal_Int32 nFirstLineIndent( 0 );
109 sal_Int32 nIndentAt( 0 );
111 for(
const beans::PropertyValue& rProp : rProps )
113 if( rProp.Name ==
"NumberingType" )
115 rProp.Value >>=
eType;
117 else if( rProp.Name ==
"Prefix" )
121 else if( rProp.Name ==
"Suffix" )
125 else if (rProp.Name ==
"ListFormat")
127 rProp.Value >>= sListFormat;
129 else if (rProp.Name ==
"IsLegal")
131 rProp.Value >>= bIsLegal;
133 else if (rProp.Name ==
"BulletChar")
136 rProp.Value >>= sValue;
137 if( !sValue.isEmpty() )
142 else if( rProp.Name ==
"BulletRelSize" )
144 rProp.Value >>= nBullRelSize;
146 else if( rProp.Name ==
"Adjust" )
152 else if( rProp.Name ==
"BulletFont" )
154 awt::FontDescriptor rFDesc;
155 if( rProp.Value >>= rFDesc )
158 sBulletFontStyleName = rFDesc.StyleName;
159 eBulletFontFamily =
static_cast< FontFamily >( rFDesc.Family );
160 eBulletFontPitch =
static_cast< FontPitch >( rFDesc.Pitch );
161 eBulletFontEncoding =
static_cast<rtl_TextEncoding
>(rFDesc.CharSet);
164 else if( rProp.Name ==
"GraphicBitmap" )
166 uno::Reference<awt::XBitmap> xBitmap;
167 rProp.Value >>= xBitmap;
168 xGraphic.set(xBitmap, uno::UNO_QUERY);
170 else if( rProp.Name ==
"BulletColor" )
172 rProp.Value >>= nColor;
175 else if( rProp.Name ==
"StartWith" )
177 rProp.Value >>= nStartValue;
179 else if( rProp.Name ==
"LeftMargin" )
181 rProp.Value >>= nSpaceBefore;
183 else if( rProp.Name ==
"FirstLineOffset" )
185 rProp.Value >>= nMinLabelWidth;
187 else if( rProp.Name ==
"SymbolTextDistance" )
189 rProp.Value >>= nMinLabelDist;
191 else if( rProp.Name ==
"ParentNumbering" )
193 rProp.Value >>= nDisplayLevels;
194 if( nDisplayLevels > nLevel+1 )
195 nDisplayLevels =
static_cast<sal_Int16
>( nLevel )+1;
197 else if( rProp.Name ==
"CharStyleName" )
199 rProp.Value >>= sTextStyleName;
201 else if( rProp.Name ==
"GraphicSize" )
204 if( rProp.Value >>= aSize )
206 nImageWidth = aSize.Width;
207 nImageHeight = aSize.Height;
210 else if( rProp.Name ==
"VertOrient" )
214 eImageVertOrient =
nValue;
216 else if( rProp.Name ==
"PositionAndSpaceMode" )
220 ePosAndSpaceMode =
nValue;
222 else if( rProp.Name ==
"LabelFollowedBy" )
226 eLabelFollowedBy =
nValue;
228 else if( rProp.Name ==
"ListtabStopPosition" )
230 rProp.Value >>= nListtabStopPosition;
232 else if( rProp.Name ==
"FirstLineIndent" )
234 rProp.Value >>= nFirstLineIndent;
236 else if( rProp.Name ==
"IndentAt" )
238 rProp.Value >>= nIndentAt;
242 if( bOutline && (NumberingType::CHAR_SPECIAL ==
eType ||
243 NumberingType::BITMAP ==
eType) )
246 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
257 if (NumberingType::BITMAP !=
eType)
259 if (!sTextStyleName.isEmpty())
262 GetExport().EncodeStyleName( sTextStyleName ) );
269 if (!sListFormat.isEmpty())
291 if( NumberingType::CHAR_SPECIAL ==
eType )
300 cBullet = 0xF000 + 149;
303 sTmp.append(OUString(&cBullet, 1));
305 sTmp.makeStringAndClear() );
313 else if( NumberingType::BITMAP ==
eType )
321 OUString sUsedMimeType;
323 if (!sInternalURL.isEmpty())
333 SAL_WARN_IF(xGraphic.is(),
"xmloff",
"embedded images are not supported by now");
346 sTmp.makeStringAndClear() );
348 if( !sTmp.isEmpty() )
351 sTmp.makeStringAndClear() );
353 if( nStartValue != 1 )
355 sTmp.append(
static_cast<sal_Int32
>(nStartValue) );
357 sTmp.makeStringAndClear() );
359 if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE !=
eType )
361 sTmp.append(
static_cast<sal_Int32
>(nDisplayLevels) );
363 sTmp.makeStringAndClear() );
371 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
373 nSpaceBefore += nMinLabelWidth;
374 nMinLabelWidth = -nMinLabelWidth;
375 if( nSpaceBefore != 0 )
381 if( nMinLabelWidth != 0 )
386 if( nMinLabelDist > 0 )
396 else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
403 if( HoriOrientation::LEFT != eAdjust )
408 case HoriOrientation::RIGHT: eValue =
XML_END;
break;
409 case HoriOrientation::CENTER: eValue =
XML_CENTER;
break;
415 if( NumberingType::BITMAP ==
eType )
418 switch( eImageVertOrient )
420 case VertOrientation::BOTTOM:
422 case VertOrientation::LINE_TOP:
423 case VertOrientation::CHAR_TOP:
426 case VertOrientation::CENTER:
427 case VertOrientation::LINE_CENTER:
428 case VertOrientation::CHAR_CENTER:
431 case VertOrientation::TOP:
433 case VertOrientation::LINE_BOTTOM:
434 case VertOrientation::CHAR_BOTTOM:
442 switch( eImageVertOrient )
444 case VertOrientation::TOP:
445 case VertOrientation::CENTER:
446 case VertOrientation::BOTTOM:
449 case VertOrientation::LINE_TOP:
450 case VertOrientation::LINE_CENTER:
451 case VertOrientation::LINE_BOTTOM:
454 case VertOrientation::CHAR_TOP:
455 case VertOrientation::CHAR_CENTER:
456 case VertOrientation::CHAR_BOTTOM:
463 if( nImageWidth > 0 )
470 if( nImageHeight > 0 )
485 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
489 if ( eLabelFollowedBy == LabelFollow::SPACE )
493 else if ( eLabelFollowedBy == LabelFollow::NOTHING )
500 if (eLabelFollowedBy == LabelFollow::NEWLINE)
507 if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
508 nListtabStopPosition > 0 )
511 nListtabStopPosition );
517 if ( nFirstLineIndent != 0 )
526 if ( nIndentAt != 0 )
541 if( NumberingType::CHAR_SPECIAL ==
eType )
545 OUString sStyleName =
548 eBulletFontFamily, eBulletFontPitch,
549 eBulletFontEncoding );
551 if( !sStyleName.isEmpty() )
568 if( !sBulletFontStyleName.isEmpty() )
571 sBulletFontStyleName );
574 if( aFamilyHdl.
exportXML( sTemp,
Any(
static_cast<sal_Int16
>(eBulletFontFamily)), rUnitConv ) )
580 if( aPitchHdl.
exportXML( sTemp,
Any(
static_cast<sal_Int16
>(eBulletFontPitch)), rUnitConv ) )
585 if( aEncHdl.
exportXML( sTemp,
Any(
static_cast<sal_Int16
>(eBulletFontEncoding)), rUnitConv ) )
591 if( NumberingType::BITMAP !=
eType )
596 if (0xffffffff ==
static_cast<sal_uInt32
>(nColor))
602 OUStringBuffer sBuffer;
605 sBuffer.makeStringAndClear() );
613 sTmp.makeStringAndClear() );
621 if (xGraphic.is() && NumberingType::BITMAP ==
eType)
637 mbExportPositionAndSpaceModeLabelAlignment( true )
639 switch (
GetExport().getSaneDefaultVersion())
655 const OUString& rName,
bool bIsHidden,
656 const Reference< XIndexReplace >& rNumRule )
658 Reference< XPropertySet > xPropSet( rNumRule, UNO_QUERY );
659 Reference< XPropertySetInfo > xPropSetInfo;
661 xPropSetInfo = xPropSet->getPropertySetInfo();
666 if( !rName.isEmpty() )
668 bool bEncoded =
false;
670 GetExport().EncodeStyleName( rName, &bEncoded ) );
685 bool bContNumbering =
false;
686 if( xPropSetInfo.is() &&
690 bContNumbering = *o3tl::doAccess<bool>(aAny);
705 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
706 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
715 if( !*o3tl::doAccess<bool>(aAny) )
720 Reference<XIndexReplace> xNumRule;
723 OUString
sName = rStyle->getName();
725 bool bHidden =
false;
726 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
728 aAny = xPropSet->getPropertyValue(
"Hidden" );
737 Reference< XChapterNumberingSupplier > xCNSupplier(
GetExport().GetModel(),
739 SAL_WARN_IF( !xCNSupplier.is(),
"xmloff",
"no chapter numbering supplier" );
741 if( !xCNSupplier.is() )
744 Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() );
745 SAL_WARN_IF( !xNumRule.is(),
"xmloff",
"no chapter numbering rules" );
753 OUString sOutlineStyleName;
755 Reference<XPropertySet> xNumRulePropSet(
756 xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
757 if (xNumRulePropSet.is())
759 xNumRulePropSet->getPropertyValue(
"Name" ) >>= sOutlineStyleName;
766 &&
GetExport().writeOutlineStyleAsNormalListStyle())
777 if ( !sOutlineStyleName.isEmpty() )
779 bool bEncoded =
false;
781 GetExport().EncodeStyleName( sOutlineStyleName,
797 if( bExportChapterNumbering )
800 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
GetExport().GetModel(), UNO_QUERY );
801 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"No XStyleFamiliesSupplier from XModel for export!" );
802 if( !xFamiliesSupp.is() )
805 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
806 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"getStyleFamilies() from XModel failed for export!" );
808 if( !xFamilies.is() )
811 static constexpr OUStringLiteral aNumberStyleName(
u"NumberingStyles" );
813 Reference< XIndexAccess > xStyles;
814 if( !xFamilies->hasByName( aNumberStyleName ) )
817 xFamilies->getByName( aNumberStyleName ) >>= xStyles;
819 SAL_WARN_IF( !xStyles.is(),
"xmloff",
"Style not found for export!" );
824 const sal_Int32 nStyles = xStyles->getCount();
826 for( sal_Int32
i=0;
i < nStyles;
i++ )
828 Reference< XStyle > xStyle;
829 xStyles->getByIndex(
i ) >>= xStyle;
831 if( !bUsed || xStyle->isInUse() )
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
rtl::Reference< XMLFontAutoStylePool > const & GetFontAutoStylePool()
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
returns the deterministic version for odf export
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
const SvXMLUnitConverter & GetMM100UnitConverter() const
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
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
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
SvXMLExport & GetExport()
void exportLevelStyles(const css::uno::Reference< css::container::XIndexReplace > &xNumRule, bool bOutline=false)
void exportStyles(bool bUsed, bool bExportChapterNumbering)
SAL_DLLPRIVATE void exportStyle(const css::uno::Reference< css::style::XStyle > &rStyle)
void exportNumberingRule(const OUString &rName, bool bIsHidden, const css::uno::Reference< css::container::XIndexReplace > &xNumRule)
SAL_DLLPRIVATE void exportOutline()
SvxXMLNumRuleExport(SvXMLExport &rExport)
bool mbExportPositionAndSpaceModeLabelAlignment
SAL_DLLPRIVATE void exportLevelStyle(sal_Int32 nLevel, const css::uno::Sequence< css::beans::PropertyValue > &rProps, bool bOutline)
PropertyHandler for the XML-data-type:
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.
PropertyHandler for the XML-data-type:
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.
PropertyHandler for the XML-data-type:
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.
PropertyHandler for the XML-data-type:
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 convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
double getLength(const B2DPolygon &rCandidate)
constexpr T & temporary(T &&x)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
@ XML_LIST_LEVEL_STYLE_IMAGE
@ XML_LIST_LEVEL_PROPERTIES
@ XML_LIST_LEVEL_STYLE_NUMBER
@ XML_LIST_TAB_STOP_POSITION
@ XML_CONSECUTIVE_NUMBERING
@ XML_FONT_FAMILY_GENERIC
@ XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
@ XML_LIST_LEVEL_STYLE_BULLET
@ XML_USE_WINDOW_FONT_COLOR
@ XML_OUTLINE_LEVEL_STYLE
@ XML_LIST_LEVEL_LABEL_ALIGNMENT
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr sal_uInt16 XML_NAMESPACE_FO
constexpr OUStringLiteral gsIsPhysical(u"IsPhysical")
constexpr OUStringLiteral gsNumberingRules(u"NumberingRules")
constexpr OUStringLiteral gsIsContinuousNumbering(u"IsContinuousNumbering")