android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / attr / fmtwrapinfluenceonobjpos.cxx
blob8f9abd96c775634f945baae2d580628f0ee24590
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 <fmtwrapinfluenceonobjpos.hxx>
21 #include <unomid.h>
22 #include <osl/diagnose.h>
23 #include <libxml/xmlwriter.h>
24 #include <sal/log.hxx>
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::uno;
30 SwFormatWrapInfluenceOnObjPos::SwFormatWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
31 : SfxPoolItem( RES_WRAP_INFLUENCE_ON_OBJPOS ),
32 mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
36 SwFormatWrapInfluenceOnObjPos::~SwFormatWrapInfluenceOnObjPos()
40 bool SwFormatWrapInfluenceOnObjPos::operator==( const SfxPoolItem& rAttr ) const
42 assert(SfxPoolItem::operator==(rAttr));
43 const SwFormatWrapInfluenceOnObjPos& rAttribute
44 = static_cast<const SwFormatWrapInfluenceOnObjPos&>(rAttr);
45 return (mnWrapInfluenceOnPosition == rAttribute.GetWrapInfluenceOnObjPos()
46 && mbAllowOverlap == rAttribute.mbAllowOverlap
47 && mnOverlapVertOffset == rAttribute.mnOverlapVertOffset);
50 SwFormatWrapInfluenceOnObjPos* SwFormatWrapInfluenceOnObjPos::Clone( SfxItemPool * ) const
52 return new SwFormatWrapInfluenceOnObjPos(*this);
55 bool SwFormatWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
57 nMemberId &= ~CONVERT_TWIPS;
58 bool bRet = true;
59 if( nMemberId == MID_WRAP_INFLUENCE )
61 rVal <<= GetWrapInfluenceOnObjPos();
63 else if( nMemberId == MID_ALLOW_OVERLAP )
65 rVal <<= GetAllowOverlap();
67 else
69 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
70 bRet = false;
72 return bRet;
75 bool SwFormatWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
77 nMemberId &= ~CONVERT_TWIPS;
78 bool bRet = false;
80 if( nMemberId == MID_WRAP_INFLUENCE )
82 sal_Int16 nNewWrapInfluence = 0;
83 rVal >>= nNewWrapInfluence;
84 // #i35017# - constant names have changed and <ITERATIVE> has been added
85 if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
86 nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
87 nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
89 SetWrapInfluenceOnObjPos( nNewWrapInfluence );
90 bRet = true;
92 else
94 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
97 else if( nMemberId == MID_ALLOW_OVERLAP )
99 bool bAllowOverlap = true;
100 if (rVal >>= bAllowOverlap)
102 SetAllowOverlap(bAllowOverlap);
103 bRet = true;
105 else
107 SAL_WARN("sw.core", "SwFormatWrapInfluenceOnObjPos::PutValue: invalid AllowOverlap type");
110 else
112 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - unknown MemberId" );
114 return bRet;
117 void SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
119 // #i35017# - constant names have changed and consider new value <ITERATIVE>
120 if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
121 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
122 _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
124 mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
126 else
128 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
132 // #i35017# - add parameter <_bIterativeAsOnceConcurrent> to control, if
133 // value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
134 sal_Int16 SwFormatWrapInfluenceOnObjPos::GetWrapInfluenceOnObjPos(
135 const bool _bIterativeAsOnceConcurrent ) const
137 sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
139 if ( _bIterativeAsOnceConcurrent &&
140 nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
142 nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
145 return nWrapInfluenceOnPosition;
148 void SwFormatWrapInfluenceOnObjPos::SetAllowOverlap(bool bAllowOverlap)
150 mbAllowOverlap = bAllowOverlap;
153 bool SwFormatWrapInfluenceOnObjPos::GetAllowOverlap() const
155 return mbAllowOverlap;
158 void SwFormatWrapInfluenceOnObjPos::SetOverlapVertOffset(SwTwips nOverlapVertOffset)
160 mnOverlapVertOffset = nOverlapVertOffset;
163 SwTwips SwFormatWrapInfluenceOnObjPos::GetOverlapVertOffset() const { return mnOverlapVertOffset; }
165 void SwFormatWrapInfluenceOnObjPos::dumpAsXml(xmlTextWriterPtr pWriter) const
167 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatWrapInfluenceOnObjPos"));
168 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
169 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nWrapInfluenceOnPosition"), BAD_CAST(OString::number(mnWrapInfluenceOnPosition).getStr()));
170 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mbAllowOverlap"), BAD_CAST(OString::boolean(mbAllowOverlap).getStr()));
171 (void)xmlTextWriterEndElement(pWriter);
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */