/src/libreoffice/editeng/source/items/rubyitem.cxx
Line | Count | Source |
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 <editeng/memberids.h> |
21 | | #include <editeng/rubyitem.hxx> |
22 | | |
23 | | using namespace ::com::sun::star; |
24 | | |
25 | | SvxRubyItem::SvxRubyItem(const sal_uInt16 nId) |
26 | 24 | : SfxPoolItem(nId) |
27 | 24 | { |
28 | 24 | } |
29 | | |
30 | 65.0k | const OUString& SvxRubyItem::GetText() const { return m_aText; } |
31 | | |
32 | | void SvxRubyItem::SetText(OUString aValue) |
33 | 881 | { |
34 | 881 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
35 | 881 | m_aText = std::move(aValue); |
36 | 881 | } |
37 | | |
38 | 0 | css::text::RubyAdjust SvxRubyItem::GetAdjustment() const { return m_eAdjustment; } |
39 | | |
40 | | void SvxRubyItem::SetAdjustment(css::text::RubyAdjust eValue) |
41 | 0 | { |
42 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
43 | 0 | m_eAdjustment = eValue; |
44 | 0 | } |
45 | | |
46 | 0 | sal_Int16 SvxRubyItem::GetPosition() const { return m_ePosition; } |
47 | | |
48 | | void SvxRubyItem::SetPosition(sal_Int16 eValue) |
49 | 0 | { |
50 | 0 | ASSERT_CHANGE_REFCOUNTED_ITEM; |
51 | 0 | m_ePosition = eValue; |
52 | 0 | } |
53 | | |
54 | | bool SvxRubyItem::operator==(const SfxPoolItem& rItem) const |
55 | 158k | { |
56 | 158k | assert(SfxPoolItem::operator==(rItem)); |
57 | 158k | const auto& rCastItem = static_cast<const SvxRubyItem&>(rItem); |
58 | | |
59 | 158k | return std::tie(m_aText, m_eAdjustment, m_ePosition) |
60 | 158k | == std::tie(rCastItem.m_aText, rCastItem.m_eAdjustment, rCastItem.m_ePosition); |
61 | 158k | } |
62 | | |
63 | 881 | SvxRubyItem* SvxRubyItem::Clone(SfxItemPool*) const { return new SvxRubyItem(*this); } |
64 | | |
65 | | bool SvxRubyItem::GetPresentation(SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/, |
66 | | MapUnit /*ePresUnit*/, OUString& rText, |
67 | | const IntlWrapper& /*rIntl*/ |
68 | | ) const |
69 | 0 | { |
70 | 0 | rText = m_aText; |
71 | 0 | return true; |
72 | 0 | } |
73 | | |
74 | | bool SvxRubyItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const |
75 | 0 | { |
76 | 0 | nMemberId &= ~CONVERT_TWIPS; |
77 | 0 | switch (nMemberId) |
78 | 0 | { |
79 | 0 | case MID_RUBY_TEXT: |
80 | 0 | rVal <<= m_aText; |
81 | 0 | return true; |
82 | | |
83 | 0 | case MID_RUBY_ADJUST: |
84 | 0 | rVal <<= static_cast<sal_Int16>(m_eAdjustment); |
85 | 0 | return true; |
86 | | |
87 | 0 | case MID_RUBY_POSITION: |
88 | 0 | rVal <<= m_ePosition; |
89 | 0 | return true; |
90 | 0 | } |
91 | | |
92 | 0 | return false; |
93 | 0 | } |
94 | | |
95 | | bool SvxRubyItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) |
96 | 881 | { |
97 | 881 | nMemberId &= ~CONVERT_TWIPS; |
98 | 881 | switch (nMemberId) |
99 | 881 | { |
100 | 881 | case MID_RUBY_TEXT: |
101 | 881 | if (OUString aValue; rVal >>= aValue) |
102 | 881 | { |
103 | 881 | SetText(std::move(aValue)); |
104 | 881 | return true; |
105 | 881 | } |
106 | 0 | break; |
107 | | |
108 | 0 | case MID_RUBY_ADJUST: |
109 | 0 | if (sal_Int16 eValue; rVal >>= eValue) |
110 | 0 | { |
111 | 0 | if (eValue >= sal_Int16(css::text::RubyAdjust_LEFT) |
112 | 0 | && eValue <= sal_Int16(css::text::RubyAdjust_INDENT_BLOCK)) |
113 | 0 | { |
114 | 0 | SetAdjustment(css::text::RubyAdjust{ eValue }); |
115 | 0 | return true; |
116 | 0 | } |
117 | 0 | } |
118 | 0 | break; |
119 | | |
120 | 0 | case MID_RUBY_POSITION: |
121 | 0 | if (sal_Int16 eValue; rVal >>= eValue) |
122 | 0 | { |
123 | 0 | SetPosition(eValue); |
124 | 0 | return true; |
125 | 0 | } |
126 | 0 | break; |
127 | 881 | } |
128 | | |
129 | 0 | return false; |
130 | 881 | } |
131 | | |
132 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |