23#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
24#include <com/sun/star/drawing/LineDash.hpp>
25#include <com/sun/star/awt/Gradient.hpp>
26#include <com/sun/star/awt/XBitmap.hpp>
27#include <com/sun/star/graphic/XGraphic.hpp>
28#include <com/sun/star/drawing/Hatch.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/container/XNameContainer.hpp>
42using namespace ::
cppu;
46class SvxUnoXPropertyTable :
public WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
55 SvxUnoXPropertyTable( sal_Int16 nWhich,
XPropertyList& rList )
noexcept;
61 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const = 0;
67 virtual void SAL_CALL insertByName(
const OUString& aName,
const uno::Any& aElement )
override;
68 virtual void SAL_CALL removeByName(
const OUString& Name )
override;
71 virtual void SAL_CALL replaceByName(
const OUString& aName,
const uno::Any& aElement )
override;
74 virtual uno::Any SAL_CALL getByName(
const OUString& aName )
override;
75 virtual uno::Sequence< OUString > SAL_CALL getElementNames( )
override;
76 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override;
79 virtual sal_Bool SAL_CALL hasElements( )
override;
84SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich,
XPropertyList& rList ) noexcept
85: mrList( rList ), mnWhich( nWhich )
91 return mrList.Get(index);
95sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService(
const OUString& ServiceName )
101void SAL_CALL SvxUnoXPropertyTable::insertByName(
const OUString& aName,
const uno::Any& aElement )
105 if( hasByName( aName ) )
106 throw container::ElementExistException();
110 std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
112 throw lang::IllegalArgumentException();
114 mrList.Insert(std::move(pNewEntry));
117void SAL_CALL SvxUnoXPropertyTable::removeByName(
const OUString& Name )
128 if (pEntry && aInternalName == pEntry->
GetName())
135 throw container::NoSuchElementException();
139void SAL_CALL SvxUnoXPropertyTable::replaceByName(
const OUString& aName,
const uno::Any& aElement )
150 if (pEntry && aInternalName == pEntry->
GetName())
152 std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
154 throw lang::IllegalArgumentException();
156 mrList.Replace(std::move(pNewEntry), i);
161 throw container::NoSuchElementException();
165uno::Any SAL_CALL SvxUnoXPropertyTable::getByName(
const OUString& aName )
177 if (pEntry && aInternalName == pEntry->
GetName())
178 return getAny( pEntry );
181 throw container::NoSuchElementException();
184uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
189 uno::Sequence< OUString > aNames( nCount );
190 OUString* pNames = aNames.getArray();
203sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName(
const OUString& aName )
214 if (pEntry && aInternalName == pEntry->
GetName())
222sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
226 return getCount() != 0;
231class SvxUnoXColorTable :
public SvxUnoXPropertyTable
238 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
241 virtual uno::Type SAL_CALL getElementType()
override;
252 return new SvxUnoXColorTable( rList );
258 return uno::Any(
static_cast<sal_Int32
>(
static_cast<const XColorEntry*
>(pEntry)->GetColor()) );
261std::unique_ptr<XPropertyEntry> SvxUnoXColorTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
264 if( !(rAny >>= aColor) )
265 return std::unique_ptr<XPropertyEntry>();
267 return std::make_unique<XColorEntry>(aColor, rName);
271uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
273 return ::cppu::UnoType<sal_Int32>::get();
277OUString SAL_CALL SvxUnoXColorTable::getImplementationName( )
279 return "SvxUnoXColorTable";
282uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( )
284 return {
"com.sun.star.drawing.ColorTable" };
289class SvxUnoXLineEndTable :
public SvxUnoXPropertyTable
296 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
299 virtual uno::Type SAL_CALL getElementType()
override;
310 return new SvxUnoXLineEndTable( rTable );
316 drawing::PolyPolygonBezierCoords aBezier;
322std::unique_ptr<XPropertyEntry> SvxUnoXLineEndTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
324 auto pCoords = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rAny);
326 return std::unique_ptr<XLineEndEntry>();
329 if( pCoords->Coordinates.getLength() > 0 )
335 return std::make_unique<XLineEndEntry>(aPolyPolygon, rName);
339uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
345OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( )
347 return "SvxUnoXLineEndTable";
350uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( )
352 return {
"com.sun.star.drawing.LineEndTable" };
357class SvxUnoXDashTable :
public SvxUnoXPropertyTable
364 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
367 virtual uno::Type SAL_CALL getElementType()
override;
378 return new SvxUnoXDashTable( rTable );
386 drawing::LineDash aLineDash;
388 aLineDash.Style =
static_cast<css::drawing::DashStyle
>(
static_cast<sal_uInt16
>(rXD.
GetDashStyle()));
389 aLineDash.Dots = rXD.
GetDots();
398std::unique_ptr<XPropertyEntry> SvxUnoXDashTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
400 drawing::LineDash aLineDash;
401 if(!(rAny >>= aLineDash))
402 return std::unique_ptr<XDashEntry>();
406 aXDash.
SetDashStyle(
static_cast<css::drawing::DashStyle
>(
static_cast<sal_uInt16
>(aLineDash.Style)));
407 aXDash.
SetDots(aLineDash.Dots);
413 return std::make_unique<XDashEntry>(aXDash, rName);
417uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
423OUString SAL_CALL SvxUnoXDashTable::getImplementationName( )
425 return "SvxUnoXDashTable";
428uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( )
430 return {
"com.sun.star.drawing.DashTable" };
435class SvxUnoXHatchTable :
public SvxUnoXPropertyTable
442 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
445 virtual uno::Type SAL_CALL getElementType()
override;
456 return new SvxUnoXHatchTable( rTable );
464 drawing::Hatch aUnoHatch;
467 aUnoHatch.Color = sal_Int32(aHatch.
GetColor());
474std::unique_ptr<XPropertyEntry> SvxUnoXHatchTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
476 drawing::Hatch aUnoHatch;
477 if(!(rAny >>= aUnoHatch))
478 return std::unique_ptr<XHatchEntry>();
482 aXHatch.
SetColor(
Color(ColorTransparency, aUnoHatch.Color) );
486 return std::make_unique<XHatchEntry>(aXHatch, rName);
490uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
496OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( )
498 return "SvxUnoXHatchTable";
501uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( )
503 return {
"com.sun.star.drawing.HatchTable" };
508class SvxUnoXGradientTable :
public SvxUnoXPropertyTable
515 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
518 virtual uno::Type SAL_CALL getElementType()
override;
529 return new SvxUnoXGradientTable( rTable );
536 awt::Gradient aGradient;
539 aGradient.StartColor =
static_cast<sal_Int32
>(aXGradient.
GetStartColor());
540 aGradient.EndColor =
static_cast<sal_Int32
>(aXGradient.
GetEndColor());
541 aGradient.Angle =
static_cast<short>(aXGradient.
GetAngle());
542 aGradient.Border = aXGradient.
GetBorder();
547 aGradient.StepCount = aXGradient.
GetSteps();
552std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
554 awt::Gradient aGradient;
555 if(!(rAny >>= aGradient))
556 return std::unique_ptr<XPropertyEntry>();
564 aXGradient.
SetBorder( aGradient.Border );
569 aXGradient.
SetSteps( aGradient.StepCount );
571 return std::make_unique<XGradientEntry>(aXGradient, rName);
575uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
581OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( )
583 return "SvxUnoXGradientTable";
586uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( )
588 return {
"com.sun.star.drawing.GradientTable" };
593class SvxUnoXBitmapTable :
public SvxUnoXPropertyTable
600 virtual std::unique_ptr<XPropertyEntry> createEntry(
const OUString& rName,
const uno::Any& rAny)
const override;
603 virtual uno::Type SAL_CALL getElementType()
override;
614 return new SvxUnoXBitmapTable( rTable );
620 auto xBitmapEntry =
static_cast<const XBitmapEntry*
>(pEntry);
621 css::uno::Reference<css::awt::XBitmap> xBitmap(xBitmapEntry->GetGraphicObject().GetGraphic().GetXGraphic(), uno::UNO_QUERY);
625std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(
const OUString& rName,
const uno::Any& rAny)
const
627 if (!rAny.has<uno::Reference<awt::XBitmap>>())
628 return std::unique_ptr<XPropertyEntry>();
630 auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>();
634 uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
639 if (aGraphic.IsNone())
643 return std::make_unique<XBitmapEntry>(aGraphicObject, rName);
647uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
649 return ::cppu::UnoType<awt::XBitmap>::get();
653OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( )
655 return "SvxUnoXBitmapTable";
658uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( )
660 return {
"com.sun.star.drawing.BitmapTable" };
uno::Reference< container::XNameContainer > SvxUnoXColorTable_createInstance(XPropertyList &rList) noexcept
uno::Reference< container::XNameContainer > SvxUnoXHatchTable_createInstance(XPropertyList &rTable) noexcept
uno::Reference< container::XNameContainer > SvxUnoXLineEndTable_createInstance(XPropertyList &rTable) noexcept
uno::Reference< container::XNameContainer > SvxUnoXBitmapTable_createInstance(XPropertyList &rTable) noexcept
uno::Reference< container::XNameContainer > SvxUnoXGradientTable_createInstance(XPropertyList &rTable) noexcept
uno::Reference< container::XNameContainer > SvxUnoXDashTable_createInstance(XPropertyList &rTable) noexcept
void SetDashLen(double nNewDashLen)
void SetDots(sal_uInt16 nNewDots)
css::drawing::DashStyle GetDashStyle() const
void SetDotLen(double nNewDotLen)
double GetDashLen() const
void SetDistance(double nNewDistance)
void SetDashes(sal_uInt16 nNewDashes)
double GetDistance() const
void SetDashStyle(css::drawing::DashStyle eNewStyle)
sal_uInt16 GetDots() const
sal_uInt16 GetDashes() const
const Color & GetEndColor() const
sal_uInt16 GetYOffset() const
void SetEndIntens(sal_uInt16 nNewIntens)
sal_uInt16 GetStartIntens() const
css::awt::GradientStyle GetGradientStyle() const
void SetBorder(sal_uInt16 nNewBorder)
const Color & GetStartColor() const
sal_uInt16 GetBorder() const
sal_uInt16 GetEndIntens() const
Degree10 GetAngle() const
void SetStartColor(const Color &rColor)
sal_uInt16 GetSteps() const
void SetGradientStyle(css::awt::GradientStyle eNewStyle)
void SetXOffset(sal_uInt16 nNewOffset)
void SetEndColor(const Color &rColor)
void SetAngle(Degree10 nNewAngle)
void SetStartIntens(sal_uInt16 nNewIntens)
sal_uInt16 GetXOffset() const
void SetYOffset(sal_uInt16 nNewOffset)
void SetSteps(sal_uInt16 nSteps)
const Color & GetColor() const
tools::Long GetDistance() const
void SetDistance(tools::Long nNewDistance)
void SetHatchStyle(css::drawing::HatchStyle eNewStyle)
css::drawing::HatchStyle GetHatchStyle() const
void SetColor(const Color &rColor)
Degree10 GetAngle() const
void SetAngle(Degree10 nNewAngle)
const OUString & GetName() const
tools::Long Count() const
void setClosed(bool bNew)
css::uno::Type const & get()
void B2DPolyPolygonToUnoPolyPolygonBezierCoords(const B2DPolyPolygon &rPolyPolygon, css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsRetval)
B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(const css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsSource)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
UNDERLYING_TYPE get() const
OUString SvxUnogetApiNameForItem(const sal_uInt16 nWhich, const OUString &rInternalName)
if the given name is a predefined name for the current language it is replaced by the corresponding a...
OUString SvxUnogetInternalNameForItem(const sal_uInt16 nWhich, const OUString &rApiName)
if the given name is a predefined api name it is replaced by the predefined name for the current lang...
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)