LibreOffice Module sw (master) 1
fmtwrapinfluenceonobjpos.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include <unomid.h>
22#include <osl/diagnose.h>
23#include <libxml/xmlwriter.h>
24#include <sal/log.hxx>
25
26using namespace ::com::sun::star;
27using namespace ::com::sun::star::uno;
28
29
32 mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
33{
34}
35
37{
38}
39
41{
42 assert(SfxPoolItem::operator==(rAttr));
43 const SwFormatWrapInfluenceOnObjPos& rAttribute
44 = static_cast<const SwFormatWrapInfluenceOnObjPos&>(rAttr);
46 && mbAllowOverlap == rAttribute.mbAllowOverlap
48}
49
51{
52 return new SwFormatWrapInfluenceOnObjPos(*this);
53}
54
55bool SwFormatWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
56{
57 nMemberId &= ~CONVERT_TWIPS;
58 bool bRet = true;
59 if( nMemberId == MID_WRAP_INFLUENCE )
60 {
61 rVal <<= GetWrapInfluenceOnObjPos();
62 }
63 else if( nMemberId == MID_ALLOW_OVERLAP )
64 {
65 rVal <<= GetAllowOverlap();
66 }
67 else
68 {
69 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
70 bRet = false;
71 }
72 return bRet;
73}
74
75bool SwFormatWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
76{
77 nMemberId &= ~CONVERT_TWIPS;
78 bool bRet = false;
79
80 if( nMemberId == MID_WRAP_INFLUENCE )
81 {
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 )
88 {
89 SetWrapInfluenceOnObjPos( nNewWrapInfluence );
90 bRet = true;
91 }
92 else
93 {
94 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
95 }
96 }
97 else if( nMemberId == MID_ALLOW_OVERLAP )
98 {
99 bool bAllowOverlap = true;
100 if (rVal >>= bAllowOverlap)
101 {
102 SetAllowOverlap(bAllowOverlap);
103 bRet = true;
104 }
105 else
106 {
107 SAL_WARN("sw.core", "SwFormatWrapInfluenceOnObjPos::PutValue: invalid AllowOverlap type");
108 }
109 }
110 else
111 {
112 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - unknown MemberId" );
113 }
114 return bRet;
115}
116
117void SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
118{
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 )
123 {
124 mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
125 }
126 else
127 {
128 OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
129 }
130}
131
132// #i35017# - add parameter <_bIterativeAsOnceConcurrent> to control, if
133// value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
135 const bool _bIterativeAsOnceConcurrent ) const
136{
137 sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
138
139 if ( _bIterativeAsOnceConcurrent &&
140 nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
141 {
142 nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
143 }
144
145 return nWrapInfluenceOnPosition;
146}
147
149{
150 mbAllowOverlap = bAllowOverlap;
151}
152
154{
155 return mbAllowOverlap;
156}
157
159{
160 mnOverlapVertOffset = nOverlapVertOffset;
161}
162
164
166{
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);
172}
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 Which() const
Allows positioning of floating screen objects without considering their own wrapping type and the wra...
SwTwips mnOverlapVertOffset
Vertical offset added during positioning to avoid an overlap.
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
void SetOverlapVertOffset(SwTwips nOverlapVertOffset)
void dumpAsXml(xmlTextWriterPtr pWriter) const override
SwFormatWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition=css::text::WrapInfluenceOnPosition::ONCE_CONCURRENT)
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
virtual SwFormatWrapInfluenceOnObjPos * Clone(SfxItemPool *pPool=nullptr) const override
sal_Int16 GetWrapInfluenceOnObjPos(const bool _bIterativeAsOnceConcurrent=false) const
to control, if value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
void SetWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition)
direct accessors to data
bool mbAllowOverlap
Allow objects to overlap, permitted by default.
virtual bool operator==(const SfxPoolItem &_rAttr) const override
pure virtual methods of class <SfxPoolItem>
void SetAllowOverlap(bool bAllowOverlap)
struct _xmlTextWriter * xmlTextWriterPtr
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(132)
#define SAL_WARN(area, stream)
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8
#define MID_WRAP_INFLUENCE
Definition: unomid.h:148
#define MID_ALLOW_OVERLAP
Definition: unomid.h:149