LibreOffice Module svx (master)  1
rotmodit.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 
20 #include <com/sun/star/table/CellVertJustify2.hpp>
21 
22 #include <svx/dialmgr.hxx>
23 #include <svx/rotmodit.hxx>
24 #include <rotationstrings.hrc>
25 
26 using namespace ::com::sun::star;
27 
28 
30 
31 
32 // SvxRotateModeItem - orientation with turned text
33 
34 
36  : SfxEnumItem( _nWhich, eMode )
37 {
38 }
39 
41  : SfxEnumItem( rItem )
42 {
43 }
44 
46 {
47 }
48 
50 {
51  assert(nVal <= SVX_ROTATE_MODE_BOTTOM && "enum overflow!");
52  return SvxResId(RID_SVXITEMS_ROTATE_MODE[static_cast<size_t>(nVal)]);
53 }
54 
56  SfxItemPresentation ePres,
57  MapUnit /*eCoreUnit*/, MapUnit /*ePresUnit*/,
58  OUString& rText, const IntlWrapper& ) const
59 {
60  rText.clear();
61 
62  switch ( ePres )
63  {
64  case SfxItemPresentation::Complete:
65  rText += GetValueText(GetValue());
66  return true;
67  break;
68 
69  case SfxItemPresentation::Nameless:
70  rText += OUString::number( GetValue() );
71  return true;
72  break;
73  default: ;//prevent warning
74  }
75 
76  return false;
77 }
78 
80 {
81  return 4; // STANDARD, TOP, CENTER, BOTTOM
82 }
83 
85 {
86  return new SvxRotateModeItem( *this );
87 }
88 
89 bool SvxRotateModeItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
90 {
91  sal_Int32 nUno = table::CellVertJustify2::STANDARD;
92  switch ( GetValue() )
93  {
94  case SVX_ROTATE_MODE_STANDARD: nUno = table::CellVertJustify2::STANDARD; break;
95  case SVX_ROTATE_MODE_TOP: nUno = table::CellVertJustify2::TOP; break;
96  case SVX_ROTATE_MODE_CENTER: nUno = table::CellVertJustify2::CENTER; break;
97  case SVX_ROTATE_MODE_BOTTOM: nUno = table::CellVertJustify2::BOTTOM; break;
98  }
99  rVal <<= nUno;
100  return true;
101 }
102 
103 bool SvxRotateModeItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
104 {
105  sal_Int32 nUno(0);
106  if(!(rVal >>= nUno))
107  {
108  nUno = table::CellVertJustify2::STANDARD;
109  }
110 
112  switch (nUno)
113  {
114  case table::CellVertJustify2::STANDARD: eSvx = SVX_ROTATE_MODE_STANDARD; break;
115  case table::CellVertJustify2::TOP: eSvx = SVX_ROTATE_MODE_TOP; break;
116  case table::CellVertJustify2::CENTER: eSvx = SVX_ROTATE_MODE_CENTER; break;
117  case table::CellVertJustify2::BOTTOM: eSvx = SVX_ROTATE_MODE_BOTTOM; break;
118  default: ;//prevent warning
119  }
120  SetValue( eSvx );
121  return true;
122 }
123 
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxRotateMode
Definition: rotmodit.hxx:29
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: rotmodit.cxx:89
SvxRotateModeItem(SvxRotateMode eMode, sal_uInt16 nWhich)
Definition: rotmodit.cxx:35
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: rotmodit.cxx:103
static OUString GetValueText(SvxRotateMode nVal)
Definition: rotmodit.cxx:49
virtual ~SvxRotateModeItem() override
Definition: rotmodit.cxx:45
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
SfxItemPresentation
void SetValue(EnumT nTheValue)
virtual SvxRotateModeItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: rotmodit.cxx:84
unsigned char sal_uInt8
static SfxPoolItem * CreateDefault()
Definition: rotmodit.cxx:29
MapUnit
virtual sal_uInt16 GetValueCount() const override
Definition: rotmodit.cxx:79
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &) const override
Definition: rotmodit.cxx:55