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 ==
"BulletChar" )
127 rProp.Value >>= sValue;
128 if( !sValue.isEmpty() )
133 else if( rProp.Name ==
"BulletRelSize" )
135 rProp.Value >>= nBullRelSize;
137 else if( rProp.Name ==
"Adjust" )
140 rProp.Value >>= nValue;
143 else if( rProp.Name ==
"BulletFont" )
145 awt::FontDescriptor rFDesc;
146 if( rProp.Value >>= rFDesc )
148 sBulletFontName = rFDesc.Name;
149 sBulletFontStyleName = rFDesc.StyleName;
150 eBulletFontFamily =
static_cast< FontFamily >( rFDesc.Family );
151 eBulletFontPitch =
static_cast< FontPitch >( rFDesc.Pitch );
152 eBulletFontEncoding =
static_cast<rtl_TextEncoding
>(rFDesc.CharSet);
155 else if( rProp.Name ==
"GraphicBitmap" )
157 uno::Reference<awt::XBitmap> xBitmap;
158 rProp.Value >>= xBitmap;
159 xGraphic.set(xBitmap, uno::UNO_QUERY);
161 else if( rProp.Name ==
"BulletColor" )
163 rProp.Value >>= nColor;
166 else if( rProp.Name ==
"StartWith" )
168 rProp.Value >>= nStartValue;
170 else if( rProp.Name ==
"LeftMargin" )
172 rProp.Value >>= nSpaceBefore;
174 else if( rProp.Name ==
"FirstLineOffset" )
176 rProp.Value >>= nMinLabelWidth;
178 else if( rProp.Name ==
"SymbolTextDistance" )
180 rProp.Value >>= nMinLabelDist;
182 else if( rProp.Name ==
"ParentNumbering" )
184 rProp.Value >>= nDisplayLevels;
185 if( nDisplayLevels > nLevel+1 )
186 nDisplayLevels =
static_cast<sal_Int16
>( nLevel )+1;
188 else if( rProp.Name ==
"CharStyleName" )
190 rProp.Value >>= sTextStyleName;
192 else if( rProp.Name ==
"GraphicSize" )
195 if( rProp.Value >>= aSize )
197 nImageWidth = aSize.Width;
198 nImageHeight = aSize.Height;
201 else if( rProp.Name ==
"VertOrient" )
204 rProp.Value >>= nValue;
205 eImageVertOrient = nValue;
207 else if( rProp.Name ==
"PositionAndSpaceMode" )
210 rProp.Value >>= nValue;
211 ePosAndSpaceMode = nValue;
213 else if( rProp.Name ==
"LabelFollowedBy" )
216 rProp.Value >>= nValue;
217 eLabelFollowedBy = nValue;
219 else if( rProp.Name ==
"ListtabStopPosition" )
221 rProp.Value >>= nListtabStopPosition;
223 else if( rProp.Name ==
"FirstLineIndent" )
225 rProp.Value >>= nFirstLineIndent;
227 else if( rProp.Name ==
"IndentAt" )
229 rProp.Value >>= nIndentAt;
233 if( bOutline && (NumberingType::CHAR_SPECIAL == eType ||
234 NumberingType::BITMAP == eType) )
237 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" );
245 sTmp.append( nLevel + 1 );
249 if (NumberingType::BITMAP != eType)
251 if (!sTextStyleName.isEmpty())
254 GetExport().EncodeStyleName( sTextStyleName ) );
256 if (!sPrefix.isEmpty())
261 if (!sSuffix.isEmpty())
269 if( NumberingType::CHAR_SPECIAL == eType )
278 cBullet = 0xF000 + 149;
281 sTmp.append(OUString(&cBullet, 1));
283 sTmp.makeStringAndClear() );
291 else if( NumberingType::BITMAP == eType )
299 OUString sUsedMimeType;
301 if (!sInternalURL.isEmpty())
311 SAL_WARN_IF(xGraphic.is(),
"xmloff",
"embedded images are not supported by now");
324 sTmp.makeStringAndClear() );
326 if( !sTmp.isEmpty() )
329 sTmp.makeStringAndClear() );
331 if( nStartValue != 1 )
333 sTmp.append( static_cast<sal_Int32>(nStartValue) );
335 sTmp.makeStringAndClear() );
337 if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE != eType )
339 sTmp.append( static_cast<sal_Int32>(nDisplayLevels) );
341 sTmp.makeStringAndClear() );
349 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
351 nSpaceBefore += nMinLabelWidth;
352 nMinLabelWidth = -nMinLabelWidth;
353 if( nSpaceBefore != 0 )
359 if( nMinLabelWidth != 0 )
364 if( nMinLabelDist > 0 )
374 else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
381 if( HoriOrientation::LEFT != eAdjust )
386 case HoriOrientation::RIGHT: eValue =
XML_END;
break;
387 case HoriOrientation::CENTER: eValue =
XML_CENTER;
break;
393 if( NumberingType::BITMAP == eType )
396 switch( eImageVertOrient )
398 case VertOrientation::BOTTOM:
400 case VertOrientation::LINE_TOP:
401 case VertOrientation::CHAR_TOP:
404 case VertOrientation::CENTER:
405 case VertOrientation::LINE_CENTER:
406 case VertOrientation::CHAR_CENTER:
409 case VertOrientation::TOP:
411 case VertOrientation::LINE_BOTTOM:
412 case VertOrientation::CHAR_BOTTOM:
420 switch( eImageVertOrient )
422 case VertOrientation::TOP:
423 case VertOrientation::CENTER:
424 case VertOrientation::BOTTOM:
427 case VertOrientation::LINE_TOP:
428 case VertOrientation::LINE_CENTER:
429 case VertOrientation::LINE_BOTTOM:
432 case VertOrientation::CHAR_TOP:
433 case VertOrientation::CHAR_CENTER:
434 case VertOrientation::CHAR_BOTTOM:
441 if( nImageWidth > 0 )
448 if( nImageHeight > 0 )
463 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT &&
467 if ( eLabelFollowedBy == LabelFollow::SPACE )
471 else if ( eLabelFollowedBy == LabelFollow::NOTHING )
478 if (eLabelFollowedBy == LabelFollow::NEWLINE)
485 if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
486 nListtabStopPosition > 0 )
489 nListtabStopPosition );
495 if ( nFirstLineIndent != 0 )
504 if ( nIndentAt != 0 )
519 if( NumberingType::CHAR_SPECIAL == eType )
521 if( !sBulletFontName.isEmpty() )
523 OUString sStyleName =
525 sBulletFontName, sBulletFontStyleName,
526 eBulletFontFamily, eBulletFontPitch,
527 eBulletFontEncoding );
529 if( !sStyleName.isEmpty() )
542 if( aFamilyNameHdl.
exportXML( sTemp,
Any(sBulletFontName), rUnitConv ) )
546 if( !sBulletFontStyleName.isEmpty() )
549 sBulletFontStyleName );
552 if( aFamilyHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontFamily)), rUnitConv ) )
558 if( aPitchHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontPitch)), rUnitConv ) )
563 if( aEncHdl.
exportXML( sTemp,
Any(static_cast<sal_Int16>(eBulletFontEncoding)), rUnitConv ) )
569 if( NumberingType::BITMAP != eType )
574 if (0xffffffff == static_cast<sal_uInt32>(nColor))
580 OUStringBuffer sBuffer;
583 sBuffer.makeStringAndClear() );
591 sTmp.makeStringAndClear() );
599 if (xGraphic.is() && NumberingType::BITMAP == eType)
609 constexpr OUStringLiteral
gsIsPhysical( u
"IsPhysical" );
615 mbExportPositionAndSpaceModeLabelAlignment( true )
617 switch (
GetExport().getSaneDefaultVersion())
637 const OUString& rName,
bool bIsHidden,
638 const Reference< XIndexReplace >& rNumRule )
641 Reference< XPropertySetInfo > xPropSetInfo;
643 xPropSetInfo = xPropSet->getPropertySetInfo();
648 if( !rName.isEmpty() )
650 bool bEncoded =
false;
652 GetExport().EncodeStyleName( rName, &bEncoded ) );
667 bool bContNumbering =
false;
668 if( xPropSetInfo.is() &&
672 bContNumbering = *o3tl::doAccess<bool>(aAny);
688 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
697 if( !*o3tl::doAccess<bool>(aAny) )
702 Reference<XIndexReplace> xNumRule;
705 OUString
sName = rStyle->getName();
707 bool bHidden =
false;
708 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
710 aAny = xPropSet->getPropertyValue(
"Hidden" );
719 Reference< XChapterNumberingSupplier > xCNSupplier(
GetExport().GetModel(),
721 SAL_WARN_IF( !xCNSupplier.is(),
"xmloff",
"no chapter numbering supplier" );
723 if( !xCNSupplier.is() )
726 Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() );
727 SAL_WARN_IF( !xNumRule.is(),
"xmloff",
"no chapter numbering rules" );
735 OUString sOutlineStyleName;
738 xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
739 if (xNumRulePropSet.is())
741 xNumRulePropSet->getPropertyValue(
"Name" ) >>= sOutlineStyleName;
748 &&
GetExport().writeOutlineStyleAsNormalListStyle())
759 if ( !sOutlineStyleName.isEmpty() )
761 bool bEncoded =
false;
763 GetExport().EncodeStyleName( sOutlineStyleName,
779 bool bExportChapterNumbering )
781 if( bExportChapterNumbering )
784 Reference< XStyleFamiliesSupplier > xFamiliesSupp(
GetExport().GetModel(), UNO_QUERY );
785 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"No XStyleFamiliesSupplier from XModel for export!" );
786 if( !xFamiliesSupp.is() )
790 SAL_WARN_IF( !xFamiliesSupp.is(),
"xmloff",
"getStyleFamilies() from XModel failed for export!" );
792 if( !xFamilies.is() )
795 const OUString aNumberStyleName(
"NumberingStyles" );
797 Reference< XIndexAccess > xStyles;
798 if( !xFamilies->hasByName( aNumberStyleName ) )
801 xFamilies->getByName( aNumberStyleName ) >>= xStyles;
803 SAL_WARN_IF( !xStyles.is(),
"xmloff",
"Style not found for export!" );
808 const sal_Int32 nStyles = xStyles->getCount();
810 for( sal_Int32
i=0;
i < nStyles;
i++ )
812 Reference< XStyle > xStyle;
813 xStyles->getByIndex(
i ) >>= xStyle;
815 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 char *pName, const OUString &rValue)
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
XMLTokenEnum
The enumeration of all XML tokens.
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...
Sequence< sal_Int8 > aSeq
bool AddEmbeddedXGraphicAsBase64(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic)
PropertyHandler for the XML-data-type:
css::uno::Any const SvXMLExport & rExport
Reference< XGraphic > xGraphic
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)