Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / xoutdev / xattr2.cxx
blobad1b3b2959e51ce6e3bfcc49c9b0c4383bab71c7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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&
69 ) const
71 rText.clear();
73 switch ( ePres )
75 case SfxItemPresentation::Complete:
76 rText = SvxResId(RID_SVXSTR_TRANSPARENCE) + ": ";
77 [[fallthrough]];
78 case SfxItemPresentation::Nameless:
79 rText += unicode::formatPercent(GetValue(),
80 Application::GetSettings().GetUILanguageTag());
81 return true;
82 default:
83 return false;
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
103 rText.clear();
105 TranslateId pId;
107 switch( GetValue() )
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;
112 break;
114 case css::drawing::LineJoint_MIDDLE:
115 pId = RID_SVXSTR_LINEJOINT_MIDDLE;
116 break;
119 case css::drawing::LineJoint_BEVEL:
120 pId = RID_SVXSTR_LINEJOINT_BEVEL;
121 break;
124 case css::drawing::LineJoint_MITER:
125 pId = RID_SVXSTR_LINEJOINT_MITER;
126 break;
129 case css::drawing::LineJoint_ROUND:
130 pId = RID_SVXSTR_LINEJOINT_ROUND;
131 break;
134 if (pId)
135 rText = SvxResId(pId);
137 return true;
140 bool XLineJointItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
142 const css::drawing::LineJoint eJoint = GetValue();
143 rVal <<= eJoint;
144 return true;
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)
154 sal_Int32 nLJ = 0;
155 if(!(rVal >>= nLJ))
156 return false;
157 eUnoJoint = static_cast<css::drawing::LineJoint>(nLJ);
160 SetValue( eUnoJoint );
162 return true;
165 sal_uInt16 XLineJointItem::GetValueCount() const
167 // don't forget to update the api interface also
168 return 5;
172 AffineMatrixItem::AffineMatrixItem(const css::geometry::AffineMatrix2D* pMatrix)
173 : SfxPoolItem(SID_ATTR_TRANSFORM_MATRIX)
175 if(pMatrix)
177 maMatrix = *pMatrix;
179 else
181 maMatrix.m00 = 1.0;
182 maMatrix.m01 = 0.0;
183 maMatrix.m02 = 0.0;
184 maMatrix.m10 = 0.0;
185 maMatrix.m11 = 1.0;
186 maMatrix.m12 = 0.0;
190 AffineMatrixItem::AffineMatrixItem(const AffineMatrixItem& rRef)
191 : SfxPoolItem(rRef)
193 maMatrix = rRef.maMatrix;
196 AffineMatrixItem::~AffineMatrixItem()
200 bool AffineMatrixItem::operator==(const SfxPoolItem& rRef) const
202 if(!SfxPoolItem::operator==(rRef))
204 return false;
207 const AffineMatrixItem* pRef = static_cast< const AffineMatrixItem* >(&rRef);
209 if(!pRef)
211 return false;
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
229 rVal <<= maMatrix;
230 return true;
233 bool AffineMatrixItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
235 if (rVal >>= maMatrix)
237 return true;
240 OSL_ENSURE(false, "AffineMatrixItem::PutValue - Wrong type!");
241 return false;
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
260 TranslateId pId;
262 switch( GetValue() )
264 default: /*css::drawing::LineCap_BUTT*/
265 pId = RID_SVXSTR_LINECAP_BUTT;
266 break;
268 case css::drawing::LineCap_ROUND:
269 pId = RID_SVXSTR_LINECAP_ROUND;
270 break;
272 case css::drawing::LineCap_SQUARE:
273 pId = RID_SVXSTR_LINECAP_SQUARE;
274 break;
277 rText = SvxResId(pId);
279 return true;
282 bool XLineCapItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
284 const css::drawing::LineCap eCap(GetValue());
285 rVal <<= eCap;
286 return true;
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)
296 sal_Int32 nLJ(0);
298 if(!(rVal >>= nLJ))
300 return false;
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 (!)");
310 SetValue(eUnoCap);
312 return true;
315 sal_uInt16 XLineCapItem::GetValueCount() const
317 // don't forget to update the api interface also
318 return 3;
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 (!)");
328 return eRetval;
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&
347 ) const
349 rText.clear();
351 switch ( ePres )
353 case SfxItemPresentation::Complete:
354 rText = SvxResId(RID_SVXSTR_TRANSPARENCE) + ": ";
355 [[fallthrough]];
356 case SfxItemPresentation::Nameless:
357 rText += unicode::formatPercent(GetValue(),
358 Application::GetSettings().GetUILanguageTag());
359 return true;
360 default:
361 return false;
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&
401 ) const
403 rText.clear();
405 rText += OUString::number(GetValue());
406 return true;
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&
426 ) const
428 rText.clear();
429 return true;
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&
458 ) const
460 rText.clear();
461 return true;
464 sal_uInt16 XFillBmpPosItem::GetValueCount() const
466 return 9;
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&
494 ) const
496 rText.clear();
497 return true;
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&
523 ) const
525 rText.clear();
526 return true;
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&
551 ) const
553 rText.clear();
554 return true;
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&
575 ) const
577 rText.clear();
578 return true;
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&
598 ) const
600 rText.clear();
601 return true;
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&
620 ) const
622 rText.clear();
623 return true;
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&
651 ) const
653 rText.clear();
654 return true;
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&
674 ) const
676 rText.clear();
677 return true;
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
693 rText.clear();
694 return true;
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
718 rText.clear();
719 return true;
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: */