22#include <com/sun/star/awt/FontDescriptor.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26#include <com/sun/star/text/HoriOrientation.hpp>
27#include <com/sun/star/awt/XBitmap.hpp>
28#include <com/sun/star/graphic/XGraphic.hpp>
32#include <vcl/font.hxx>
44#include <editeng/editids.hrc>
49using ::com::sun::star::util::XCloneable;
50using ::com::sun::star::ucb::XAnyCompare;
71 text::HoriOrientation::LEFT,
72 text::HoriOrientation::RIGHT,
73 text::HoriOrientation::FULL,
74 text::HoriOrientation::CENTER,
75 text::HoriOrientation::FULL,
76 text::HoriOrientation::LEFT
87 DBG_ASSERT(
static_cast<int>(eAdjust) <= 6,
"Enum has changed! [CL]" );
92: maRule(
std::move( aRule ))
106 throw IndexOutOfBoundsException();
108 Sequence< beans::PropertyValue >
aSeq;
110 if( !( Element >>=
aSeq) )
111 throw IllegalArgumentException();
128 throw IndexOutOfBoundsException();
158 return "SvxUnoNumberingRules";
168 return {
"com.sun.star.text.NumberingRules" };
177 const int nProps = 15;
178 std::unique_ptr<beans::PropertyValue[]> pArray(
new beans::PropertyValue[nProps]);
184 pArray[nIdx++] = aAlignProp;
190 pArray[nIdx++] = beans::PropertyValue(
UNO_NAME_NRULE_ADJUST, -1, aVal, beans::PropertyState_DIRECT_VALUE);
195 beans::PropertyValue aPrefixProp(
UNO_NAME_NRULE_PREFIX, -1, aVal, beans::PropertyState_DIRECT_VALUE);
196 pArray[nIdx++] = aPrefixProp;
201 beans::PropertyValue aSuffixProp(
UNO_NAME_NRULE_SUFFIX, -1, aVal, beans::PropertyState_DIRECT_VALUE);
202 pArray[nIdx++] = aSuffixProp;
208 OUString
aStr( &nCode, 1 );
210 beans::PropertyValue aBulletProp(
"BulletChar", -1, aVal, beans::PropertyState_DIRECT_VALUE);
211 pArray[nIdx++] = aBulletProp;
216 awt::FontDescriptor aDesc;
224 const Graphic* pGraphic =
nullptr;
229 uno::Reference<awt::XBitmap> xBitmap(pGraphic->
GetXGraphic(), uno::UNO_QUERY);
232 const beans::PropertyValue aGraphicProp(
"GraphicBitmap", -1, aVal, beans::PropertyState_DIRECT_VALUE);
233 pArray[nIdx++] = aGraphicProp;
239 const awt::Size aUnoSize( aSize.
Width(), aSize.
Height() );
241 const beans::PropertyValue aGraphicSizeProp(
"GraphicSize", -1, aVal, beans::PropertyState_DIRECT_VALUE );
242 pArray[nIdx++] = aGraphicSizeProp;
245 aVal <<= static_cast<sal_Int16>(rFmt.
GetStart());
254 pArray[nIdx++] = beans::PropertyValue(
"SymbolTextDistance", -1, aVal, beans::PropertyState_DIRECT_VALUE);
262 DBG_ASSERT( nIdx <= nProps,
"FixMe: overflow in Array!!! [CL]" );
263 Sequence< beans::PropertyValue>
aSeq(pArray.get(), nIdx);
271 for(
const beans::PropertyValue& rProp : rProperties)
273 const OUString& rPropName = rProp.Name;
274 const Any& aVal = rProp.Value;
278 sal_Int16 nSet = sal_Int16();
291 if( aVal >>= aPrefix )
300 if( aVal >>= aSuffix )
308 sal_Int16 nSet = sal_Int16();
318 else if ( rPropName ==
"BulletChar" )
336 sal_Int16
nAdjust = sal_Int16();
345 awt::FontDescriptor aDesc;
354 else if ( rPropName ==
"GraphicURL" )
368 else if ( rPropName ==
"GraphicBitmap" )
370 uno::Reference<awt::XBitmap> xBitmap;
371 if (aVal >>= xBitmap)
373 uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
380 else if ( rPropName ==
"GraphicSize" )
383 if( aVal >>= aUnoSize )
391 sal_Int16 nStart = sal_Int16();
392 if( aVal >>= nStart )
400 sal_Int32 nMargin = 0;
401 if( aVal >>= nMargin )
409 sal_Int32 nMargin = 0;
410 if( aVal >>= nMargin )
416 else if ( rPropName ==
"SymbolTextDistance" )
418 sal_Int32 nTextDistance = 0;
419 if( aVal >>= nTextDistance )
428 if( aVal >>= aColor )
436 sal_Int16 nSize = sal_Int16();
442 if ((nSize>400)||(nSize<=0))
456 throw IllegalArgumentException();
475 if( pRule ==
nullptr )
476 throw IllegalArgumentException();
491 virtual sal_Int16 SAL_CALL
compare(
const Any& Any1,
const Any& Any2 )
override;
496sal_Int16 SAL_CALL SvxUnoNumberingRulesCompare::compare(
const Any& Any1,
const Any& Any2 )
503 Reference< XIndexReplace > x1( Any1, UNO_QUERY ), x2( Any2, UNO_QUERY );
507 if( x1.get() == x2.get() )
523 if( nLevelCount1 == 0 || nLevelCount2 == 0 )
526 for( sal_uInt16
i = 0; (
i < nLevelCount1) && (
i < nLevelCount2);
i++ )
536 return new SvxUnoNumberingRulesCompare;
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Graphic * GetGraphic(OUString const &referer=OUString()) const
sal_uInt16 GetLevelCount() const
const SvxNumberFormat & GetLevel(sal_uInt16 nLevel) const
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
void SetNumberingType(SvxNumType nSet)
SvxNumType GetNumberingType() const
static void ConvertFromFont(const vcl::Font &rFont, css::awt::FontDescriptor &rDesc)
static void ConvertToFont(const css::awt::FontDescriptor &rDesc, vcl::Font &rFont)
virtual ~SvxUnoNumberingRules() noexcept override
SvxUnoNumberingRules(SvxNumRule aRule)
virtual sal_Int16 SAL_CALL compare(const css::uno::Any &Any1, const css::uno::Any &Any2) override
static sal_Int16 Compare(const css::uno::Any &rAny1, const css::uno::Any &rAny2)
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
css::uno::Sequence< css::beans::PropertyValue > getNumberingRuleByIndex(sal_Int32 nIndex) const
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const css::uno::Any &Element) override
virtual sal_Int32 SAL_CALL getCount() override
const SvxNumRule & getNumRule() const
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
void setNumberingRuleByIndex(const css::uno::Sequence< css::beans::PropertyValue > &rProperties, sal_Int32 nIndex)
virtual OUString SAL_CALL getImplementationName() override
#define DBG_ASSERT(sCon, aError)
Sequence< sal_Int8 > aSeq
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr T & temporary(T &&x)
Graphic loadFromURL(OUString const &rURL, weld::Window *pParentWin)
SbxDecimal::CmpResult compare(SAL_UNUSED_PARAMETER const SbxDecimal &, SAL_UNUSED_PARAMETER const SbxDecimal &)
SvxNumType
these must match the values in css::style::NumberingType
const SvxAdjust aUnoToSvxAdjust[]
static SvxAdjust ConvertUnoAdjust(unsigned short nAdjust)
css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule &rRule)
Reference< XAnyCompare > SvxCreateNumRuleCompare() noexcept
const o3tl::enumarray< SvxAdjust, sal_Int16 > aSvxToUnoAdjust
const SvxNumRule & SvxGetNumRule(Reference< XIndexReplace > const &xRule)
constexpr OUStringLiteral UNO_NAME_NRULE_BULLET_COLOR
constexpr OUStringLiteral UNO_NAME_NRULE_START_WITH
constexpr OUStringLiteral UNO_NAME_NRULE_FIRST_LINE_OFFSET
constexpr OUStringLiteral UNO_NAME_NRULE_BULLET_FONT
constexpr OUStringLiteral UNO_NAME_NRULE_NUMBERINGTYPE
constexpr OUStringLiteral UNO_NAME_NRULE_BULLET_RELSIZE
constexpr OUStringLiteral UNO_NAME_NRULE_PREFIX
constexpr OUStringLiteral UNO_NAME_NRULE_SUFFIX
constexpr OUStringLiteral UNO_NAME_NRULE_ADJUST
#define UNO_NAME_NRULE_BULLETID
constexpr OUStringLiteral UNO_NAME_NRULE_LEFT_MARGIN