1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/drawing/LineJoint.hpp>
21 #include <com/sun/star/drawing/LineCap.hpp>
22 #include <com/sun/star/uno/Any.hxx>
24 #include <osl/diagnose.h>
25 #include <i18nutil/unicode.hxx>
26 #include <svx/strings.hrc>
27 #include <svx/svxids.hrc>
28 #include <svx/xlinjoit.hxx>
29 #include <svx/xlncapit.hxx>
30 #include <svx/xlntrit.hxx>
31 #include <svx/xfltrit.hxx>
32 #include <xftshtit.hxx>
33 #include <svx/xgrscit.hxx>
34 #include <svx/xflbmtit.hxx>
35 #include <svx/xflbmpit.hxx>
36 #include <svx/xflbmsxy.hxx>
37 #include <svx/xflbmsli.hxx>
38 #include <svx/xflbtoxy.hxx>
39 #include <svx/xflbstit.hxx>
40 #include <svx/xflboxy.hxx>
41 #include <svx/xflbckit.hxx>
42 #include <svx/xfilluseslidebackgrounditem.hxx>
43 #include <svx/dialmgr.hxx>
44 #include <svx/xdef.hxx>
45 #include <AffineMatrixItem.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/settings.hxx>
49 #include <comphelper/lok.hxx>
51 #include <libxml/xmlwriter.h>
53 XLineTransparenceItem::XLineTransparenceItem(sal_uInt16 nLineTransparence
) :
54 SfxUInt16Item(XATTR_LINETRANSPARENCE
, nLineTransparence
)
58 XLineTransparenceItem
* XLineTransparenceItem::Clone(SfxItemPool
* /*pPool*/) const
60 return new XLineTransparenceItem(*this);
63 bool XLineTransparenceItem::GetPresentation
65 SfxItemPresentation ePres
,
66 MapUnit
/*eCoreUnit*/,
67 MapUnit
/*ePresUnit*/,
68 OUString
& rText
, const IntlWrapper
&
75 case SfxItemPresentation::Complete
:
76 rText
= SvxResId(RID_SVXSTR_TRANSPARENCE
) + ": ";
78 case SfxItemPresentation::Nameless
:
79 rText
+= unicode::formatPercent(GetValue(),
80 Application::GetSettings().GetUILanguageTag());
88 SfxPoolItem
* XLineJointItem::CreateDefault() { return new XLineJointItem
; }
90 XLineJointItem::XLineJointItem( css::drawing::LineJoint eLineJoint
) :
91 SfxEnumItem(XATTR_LINEJOINT
, eLineJoint
)
95 XLineJointItem
* XLineJointItem::Clone(SfxItemPool
* /*pPool*/) const
97 return new XLineJointItem( *this );
100 bool XLineJointItem::GetPresentation( SfxItemPresentation
/*ePres*/, MapUnit
/*eCoreUnit*/,
101 MapUnit
/*ePresUnit*/, OUString
& rText
, const IntlWrapper
&) const
109 case css::drawing::LineJoint::LineJoint_MAKE_FIXED_SIZE
:
110 case css::drawing::LineJoint_NONE
:
111 pId
= comphelper::LibreOfficeKit::isActive() ? RID_SVXSTR_INVISIBLE
: RID_SVXSTR_NONE
;
114 case css::drawing::LineJoint_MIDDLE
:
115 pId
= RID_SVXSTR_LINEJOINT_MIDDLE
;
119 case css::drawing::LineJoint_BEVEL
:
120 pId
= RID_SVXSTR_LINEJOINT_BEVEL
;
124 case css::drawing::LineJoint_MITER
:
125 pId
= RID_SVXSTR_LINEJOINT_MITER
;
129 case css::drawing::LineJoint_ROUND
:
130 pId
= RID_SVXSTR_LINEJOINT_ROUND
;
135 rText
= SvxResId(pId
);
140 bool XLineJointItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
142 const css::drawing::LineJoint eJoint
= GetValue();
147 bool XLineJointItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
149 css::drawing::LineJoint eUnoJoint
;
151 if(!(rVal
>>= eUnoJoint
))
153 // also try an int (for Basic)
157 eUnoJoint
= static_cast<css::drawing::LineJoint
>(nLJ
);
160 SetValue( eUnoJoint
);
165 sal_uInt16
XLineJointItem::GetValueCount() const
167 // don't forget to update the api interface also
172 AffineMatrixItem::AffineMatrixItem(const css::geometry::AffineMatrix2D
* pMatrix
)
173 : SfxPoolItem(SID_ATTR_TRANSFORM_MATRIX
)
190 AffineMatrixItem::AffineMatrixItem(const AffineMatrixItem
& rRef
)
193 maMatrix
= rRef
.maMatrix
;
196 AffineMatrixItem::~AffineMatrixItem()
200 bool AffineMatrixItem::operator==(const SfxPoolItem
& rRef
) const
202 if(!SfxPoolItem::operator==(rRef
))
207 const AffineMatrixItem
* pRef
= static_cast< const AffineMatrixItem
* >(&rRef
);
214 return (maMatrix
.m00
== pRef
->maMatrix
.m00
215 && maMatrix
.m01
== pRef
->maMatrix
.m01
216 && maMatrix
.m02
== pRef
->maMatrix
.m02
217 && maMatrix
.m10
== pRef
->maMatrix
.m10
218 && maMatrix
.m11
== pRef
->maMatrix
.m11
219 && maMatrix
.m12
== pRef
->maMatrix
.m12
);
222 AffineMatrixItem
* AffineMatrixItem::Clone( SfxItemPool
* /*pPool*/ ) const
224 return new AffineMatrixItem(*this);
227 bool AffineMatrixItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
233 bool AffineMatrixItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
235 if (rVal
>>= maMatrix
)
240 OSL_ENSURE(false, "AffineMatrixItem::PutValue - Wrong type!");
245 SfxPoolItem
* XLineCapItem::CreateDefault() { return new XLineCapItem
; }
247 XLineCapItem::XLineCapItem(css::drawing::LineCap eLineCap
)
248 : SfxEnumItem(XATTR_LINECAP
, eLineCap
)
252 XLineCapItem
* XLineCapItem::Clone(SfxItemPool
* /*pPool*/) const
254 return new XLineCapItem( *this );
257 bool XLineCapItem::GetPresentation( SfxItemPresentation
/*ePres*/, MapUnit
/*eCoreUnit*/,
258 MapUnit
/*ePresUnit*/, OUString
& rText
, const IntlWrapper
&) const
264 default: /*css::drawing::LineCap_BUTT*/
265 pId
= RID_SVXSTR_LINECAP_BUTT
;
268 case css::drawing::LineCap_ROUND
:
269 pId
= RID_SVXSTR_LINECAP_ROUND
;
272 case css::drawing::LineCap_SQUARE
:
273 pId
= RID_SVXSTR_LINECAP_SQUARE
;
277 rText
= SvxResId(pId
);
282 bool XLineCapItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/) const
284 const css::drawing::LineCap
eCap(GetValue());
289 bool XLineCapItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/)
291 css::drawing::LineCap eUnoCap
;
293 if(!(rVal
>>= eUnoCap
))
295 // also try an int (for Basic)
303 eUnoCap
= static_cast<css::drawing::LineCap
>(nLJ
);
306 OSL_ENSURE(css::drawing::LineCap_BUTT
== eUnoCap
307 || css::drawing::LineCap_ROUND
== eUnoCap
308 || css::drawing::LineCap_SQUARE
== eUnoCap
, "Unknown enum value in XATTR_LINECAP (!)");
315 sal_uInt16
XLineCapItem::GetValueCount() const
317 // don't forget to update the api interface also
321 css::drawing::LineCap
XLineCapItem::GetValue() const
323 const css::drawing::LineCap
eRetval(SfxEnumItem::GetValue());
324 OSL_ENSURE(css::drawing::LineCap_BUTT
== eRetval
325 || css::drawing::LineCap_ROUND
== eRetval
326 || css::drawing::LineCap_SQUARE
== eRetval
, "Unknown enum value in XATTR_LINECAP (!)");
331 XFillTransparenceItem::XFillTransparenceItem(sal_uInt16 nFillTransparence
) :
332 SfxUInt16Item(XATTR_FILLTRANSPARENCE
, nFillTransparence
)
336 XFillTransparenceItem
* XFillTransparenceItem::Clone(SfxItemPool
* /*pPool*/) const
338 return new XFillTransparenceItem(*this);
341 bool XFillTransparenceItem::GetPresentation
343 SfxItemPresentation ePres
,
344 MapUnit
/*eCoreUnit*/,
345 MapUnit
/*ePresUnit*/,
346 OUString
& rText
, const IntlWrapper
&
353 case SfxItemPresentation::Complete
:
354 rText
= SvxResId(RID_SVXSTR_TRANSPARENCE
) + ": ";
356 case SfxItemPresentation::Nameless
:
357 rText
+= unicode::formatPercent(GetValue(),
358 Application::GetSettings().GetUILanguageTag());
365 void XFillTransparenceItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
367 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillTransparenceItem"));
368 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
369 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
370 (void)xmlTextWriterEndElement(pWriter
);
374 XFormTextShadowTranspItem::XFormTextShadowTranspItem(sal_uInt16 nShdwTransparence
) :
375 SfxUInt16Item(XATTR_FORMTXTSHDWTRANSP
, nShdwTransparence
)
379 XFormTextShadowTranspItem
* XFormTextShadowTranspItem::Clone(SfxItemPool
* /*pPool*/) const
381 return new XFormTextShadowTranspItem(*this);
385 XGradientStepCountItem::XGradientStepCountItem( sal_uInt16 nStepCount
) :
386 SfxUInt16Item( XATTR_GRADIENTSTEPCOUNT
, nStepCount
)
390 XGradientStepCountItem
* XGradientStepCountItem::Clone( SfxItemPool
* /*pPool*/) const
392 return new XGradientStepCountItem( *this );
395 bool XGradientStepCountItem::GetPresentation
397 SfxItemPresentation
/*ePres*/,
398 MapUnit
/*eCoreUnit*/,
399 MapUnit
/*ePresUnit*/,
400 OUString
& rText
, const IntlWrapper
&
405 rText
+= OUString::number(GetValue());
410 XFillBmpTileItem::XFillBmpTileItem( bool bTile
) :
411 SfxBoolItem( XATTR_FILLBMP_TILE
, bTile
)
415 XFillBmpTileItem
* XFillBmpTileItem::Clone( SfxItemPool
* /*pPool*/) const
417 return new XFillBmpTileItem( *this );
420 bool XFillBmpTileItem::GetPresentation
422 SfxItemPresentation
/*ePres*/,
423 MapUnit
/*eCoreUnit*/,
424 MapUnit
/*ePresUnit*/,
425 OUString
& rText
, const IntlWrapper
&
432 void XFillBmpTileItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
434 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillBmpTileItem"));
435 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
436 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::boolean(GetValue()).getStr()));
437 (void)xmlTextWriterEndElement(pWriter
);
442 XFillBmpPosItem::XFillBmpPosItem( RectPoint eRP
) :
443 SfxEnumItem( XATTR_FILLBMP_POS
, eRP
)
447 XFillBmpPosItem
* XFillBmpPosItem::Clone( SfxItemPool
* /*pPool*/) const
449 return new XFillBmpPosItem( *this );
452 bool XFillBmpPosItem::GetPresentation
454 SfxItemPresentation
/*ePres*/,
455 MapUnit
/*eCoreUnit*/,
456 MapUnit
/*ePresUnit*/,
457 OUString
& rText
, const IntlWrapper
&
464 sal_uInt16
XFillBmpPosItem::GetValueCount() const
469 void XFillBmpPosItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
471 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillBmpPosItem"));
472 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
473 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::number(static_cast<int>(GetValue())).getStr()));
474 (void)xmlTextWriterEndElement(pWriter
);
478 XFillBmpSizeXItem::XFillBmpSizeXItem( tools::Long nSizeX
) :
479 SfxMetricItem( XATTR_FILLBMP_SIZEX
, nSizeX
)
483 XFillBmpSizeXItem
* XFillBmpSizeXItem::Clone( SfxItemPool
* /*pPool*/) const
485 return new XFillBmpSizeXItem( *this );
488 bool XFillBmpSizeXItem::GetPresentation
490 SfxItemPresentation
/*ePres*/,
491 MapUnit
/*eCoreUnit*/,
492 MapUnit
/*ePresUnit*/,
493 OUString
& rText
, const IntlWrapper
&
500 bool XFillBmpSizeXItem::HasMetrics() const
502 return GetValue() > 0;
507 XFillBmpSizeYItem::XFillBmpSizeYItem( tools::Long nSizeY
) :
508 SfxMetricItem( XATTR_FILLBMP_SIZEY
, nSizeY
)
512 XFillBmpSizeYItem
* XFillBmpSizeYItem::Clone( SfxItemPool
* /*pPool*/) const
514 return new XFillBmpSizeYItem( *this );
517 bool XFillBmpSizeYItem::GetPresentation
519 SfxItemPresentation
/*ePres*/,
520 MapUnit
/*eCoreUnit*/,
521 MapUnit
/*ePresUnit*/,
522 OUString
& rText
, const IntlWrapper
&
529 bool XFillBmpSizeYItem::HasMetrics() const
531 return GetValue() > 0;
535 XFillBmpSizeLogItem::XFillBmpSizeLogItem( bool bLog
) :
536 SfxBoolItem( XATTR_FILLBMP_SIZELOG
, bLog
)
540 XFillBmpSizeLogItem
* XFillBmpSizeLogItem::Clone( SfxItemPool
* /*pPool*/) const
542 return new XFillBmpSizeLogItem( *this );
545 bool XFillBmpSizeLogItem::GetPresentation
547 SfxItemPresentation
/*ePres*/,
548 MapUnit
/*eCoreUnit*/,
549 MapUnit
/*ePresUnit*/,
550 OUString
& rText
, const IntlWrapper
&
559 XFillBmpTileOffsetXItem::XFillBmpTileOffsetXItem( sal_uInt16 nOffX
) :
560 SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETX
, nOffX
)
564 XFillBmpTileOffsetXItem
* XFillBmpTileOffsetXItem::Clone( SfxItemPool
* /*pPool*/) const
566 return new XFillBmpTileOffsetXItem( *this );
569 bool XFillBmpTileOffsetXItem::GetPresentation
571 SfxItemPresentation
/*ePres*/,
572 MapUnit
/*eCoreUnit*/,
573 MapUnit
/*ePresUnit*/,
574 OUString
& rText
, const IntlWrapper
&
582 XFillBmpTileOffsetYItem::XFillBmpTileOffsetYItem( sal_uInt16 nOffY
) :
583 SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETY
, nOffY
)
587 XFillBmpTileOffsetYItem
* XFillBmpTileOffsetYItem::Clone( SfxItemPool
* /*pPool*/) const
589 return new XFillBmpTileOffsetYItem( *this );
592 bool XFillBmpTileOffsetYItem::GetPresentation
594 SfxItemPresentation
/*ePres*/,
595 MapUnit
/*eCoreUnit*/,
596 MapUnit
/*ePresUnit*/,
597 OUString
& rText
, const IntlWrapper
&
604 XFillBmpStretchItem::XFillBmpStretchItem( bool bStretch
) :
605 SfxBoolItem( XATTR_FILLBMP_STRETCH
, bStretch
)
609 XFillBmpStretchItem
* XFillBmpStretchItem::Clone( SfxItemPool
* /*pPool*/) const
611 return new XFillBmpStretchItem( *this );
614 bool XFillBmpStretchItem::GetPresentation
616 SfxItemPresentation
/*ePres*/,
617 MapUnit
/*eCoreUnit*/,
618 MapUnit
/*ePresUnit*/,
619 OUString
& rText
, const IntlWrapper
&
626 void XFillBmpStretchItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
628 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillBmpStretchItem"));
629 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
630 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::boolean(GetValue()).getStr()));
631 (void)xmlTextWriterEndElement(pWriter
);
635 XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem( sal_uInt16 nOffPosX
) :
636 SfxUInt16Item( XATTR_FILLBMP_POSOFFSETX
, nOffPosX
)
640 XFillBmpPosOffsetXItem
* XFillBmpPosOffsetXItem::Clone( SfxItemPool
* /*pPool*/) const
642 return new XFillBmpPosOffsetXItem( *this );
645 bool XFillBmpPosOffsetXItem::GetPresentation
647 SfxItemPresentation
/*ePres*/,
648 MapUnit
/*eCoreUnit*/,
649 MapUnit
/*ePresUnit*/,
650 OUString
& rText
, const IntlWrapper
&
658 XFillBmpPosOffsetYItem::XFillBmpPosOffsetYItem( sal_uInt16 nOffPosY
) :
659 SfxUInt16Item( XATTR_FILLBMP_POSOFFSETY
, nOffPosY
)
663 XFillBmpPosOffsetYItem
* XFillBmpPosOffsetYItem::Clone( SfxItemPool
* /*pPool*/) const
665 return new XFillBmpPosOffsetYItem( *this );
668 bool XFillBmpPosOffsetYItem::GetPresentation
670 SfxItemPresentation
/*ePres*/,
671 MapUnit
/*eCoreUnit*/,
672 MapUnit
/*ePresUnit*/,
673 OUString
& rText
, const IntlWrapper
&
680 XFillBackgroundItem::XFillBackgroundItem( bool bFill
) :
681 SfxBoolItem( XATTR_FILLBACKGROUND
, bFill
)
685 XFillBackgroundItem
* XFillBackgroundItem::Clone( SfxItemPool
* /*pPool*/) const
687 return new XFillBackgroundItem( *this );
690 bool XFillBackgroundItem::GetPresentation( SfxItemPresentation
/*ePres*/, MapUnit
/*eCoreUnit*/,
691 MapUnit
/*ePresUnit*/, OUString
& rText
, const IntlWrapper
&) const
697 void XFillBackgroundItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
699 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillBackgroundItem"));
700 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
701 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::boolean(GetValue()).getStr()));
702 (void)xmlTextWriterEndElement(pWriter
);
705 XFillUseSlideBackgroundItem::XFillUseSlideBackgroundItem( bool bFill
) :
706 SfxBoolItem( XATTR_FILLUSESLIDEBACKGROUND
, bFill
)
710 XFillUseSlideBackgroundItem
* XFillUseSlideBackgroundItem::Clone( SfxItemPool
* /*pPool*/) const
712 return new XFillUseSlideBackgroundItem( *this );
715 bool XFillUseSlideBackgroundItem::GetPresentation( SfxItemPresentation
/*ePres*/, MapUnit
/*eCoreUnit*/,
716 MapUnit
/*ePresUnit*/, OUString
& rText
, const IntlWrapper
&) const
722 void XFillUseSlideBackgroundItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
724 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("XFillUseSlideBackgroundItem"));
725 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
726 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("value"), BAD_CAST(OString::boolean(GetValue()).getStr()));
727 (void)xmlTextWriterEndElement(pWriter
);
731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */