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 
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::uno;
27 
28 
31  mnWrapInfluenceOnPosition( _nWrapInfluenceOnPosition )
32 {
33 }
34 
36 {
37 }
38 
40 {
41  assert(SfxPoolItem::operator==(rAttr));
42  return ( mnWrapInfluenceOnPosition ==
43  static_cast<const SwFormatWrapInfluenceOnObjPos&>(rAttr).
45 }
46 
48 {
49  return new SwFormatWrapInfluenceOnObjPos(*this);
50 }
51 
52 bool SwFormatWrapInfluenceOnObjPos::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
53 {
54  nMemberId &= ~CONVERT_TWIPS;
55  bool bRet = true;
56  if( nMemberId == MID_WRAP_INFLUENCE )
57  {
58  rVal <<= GetWrapInfluenceOnObjPos();
59  }
60  else
61  {
62  OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::QueryValue()> - unknown MemberId" );
63  bRet = false;
64  }
65  return bRet;
66 }
67 
68 bool SwFormatWrapInfluenceOnObjPos::PutValue( const Any& rVal, sal_uInt8 nMemberId )
69 {
70  nMemberId &= ~CONVERT_TWIPS;
71  bool bRet = false;
72 
73  if( nMemberId == MID_WRAP_INFLUENCE )
74  {
75  sal_Int16 nNewWrapInfluence = 0;
76  rVal >>= nNewWrapInfluence;
77  // #i35017# - constant names have changed and <ITERATIVE> has been added
78  if ( nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
79  nNewWrapInfluence == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
80  nNewWrapInfluence == text::WrapInfluenceOnPosition::ITERATIVE )
81  {
82  SetWrapInfluenceOnObjPos( nNewWrapInfluence );
83  bRet = true;
84  }
85  else
86  {
87  OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - invalid attribute value" );
88  }
89  }
90  else
91  {
92  OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::PutValue(..)> - unknown MemberId" );
93  }
94  return bRet;
95 }
96 
97 void SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos( sal_Int16 _nWrapInfluenceOnPosition )
98 {
99  // #i35017# - constant names have changed and consider new value <ITERATIVE>
100  if ( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
101  _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT ||
102  _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
103  {
104  mnWrapInfluenceOnPosition = _nWrapInfluenceOnPosition;
105  }
106  else
107  {
108  OSL_FAIL( "<SwFormatWrapInfluenceOnObjPos::SetWrapInfluenceOnObjPos(..)> - invalid attribute value" );
109  }
110 }
111 
112 // #i35017# - add parameter <_bIterativeAsOnceConcurrent> to control, if
113 // value <ITERATIVE> has to be treated as <ONCE_CONCURRENT>
115  const bool _bIterativeAsOnceConcurrent ) const
116 {
117  sal_Int16 nWrapInfluenceOnPosition( mnWrapInfluenceOnPosition );
118 
119  if ( _bIterativeAsOnceConcurrent &&
120  nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ITERATIVE )
121  {
122  nWrapInfluenceOnPosition = text::WrapInfluenceOnPosition::ONCE_CONCURRENT;
123  }
124 
125  return nWrapInfluenceOnPosition;
126 }
127 
129 {
130  xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatWrapInfluenceOnObjPos"));
131  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
132  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nWrapInfluenceOnPosition"), BAD_CAST(OString::number(mnWrapInfluenceOnPosition).getStr()));
133  xmlTextWriterEndElement(pWriter);
134 }
135 
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void dumpAsXml(xmlTextWriterPtr pWriter) const override
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
#define RES_WRAP_INFLUENCE_ON_OBJPOS
Definition: hintids.hxx:230
void SetWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition)
direct accessors to data
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
struct _xmlTextWriter * xmlTextWriterPtr
#define MID_WRAP_INFLUENCE
Definition: unomid.h:148
unsigned char sal_uInt8
virtual bool operator==(const SfxPoolItem &_rAttr) const override
pure virtual methods of class
sal_Int16 GetWrapInfluenceOnObjPos(const bool _bIterativeAsOnceConcurrent=false) const
to control, if value has to be treated as
SwFormatWrapInfluenceOnObjPos(sal_Int16 _nWrapInfluenceOnPosition=css::text::WrapInfluenceOnPosition::ONCE_CONCURRENT)
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
sal_uInt16 Which() const
#define CONVERT_TWIPS