ITEM: Refactor ItemType
[LibreOffice.git] / sw / source / core / fields / scrptfld.cxx
blob302845281d36435a18d1a8b28abc5c584db9e99c
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 <docufld.hxx>
21 #include <unofldmid.h>
22 #include <strings.hrc>
23 #include <o3tl/any.hxx>
24 #include <swtypes.hxx>
25 #include <utility>
27 using namespace ::com::sun::star;
29 SwScriptFieldType::SwScriptFieldType( SwDoc& rD )
30 : SwFieldType( SwFieldIds::Script ), m_rDoc( rD )
33 std::unique_ptr<SwFieldType> SwScriptFieldType::Copy() const
35 return std::make_unique<SwScriptFieldType>( m_rDoc );
38 SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
39 OUString aType, OUString aCode,
40 bool bURL )
41 : SwField( pInitType ), m_sType( std::move(aType) ), m_sCode( std::move(aCode) ), m_bCodeURL( bURL )
45 OUString SwScriptField::GetDescription() const
47 return SwResId(STR_SCRIPT);
50 OUString SwScriptField::ExpandImpl(SwRootFrame const*const) const
52 return OUString();
55 std::unique_ptr<SwField> SwScriptField::Copy() const
57 return std::make_unique<SwScriptField>( static_cast<SwScriptFieldType*>(GetTyp()), m_sType, m_sCode, m_bCodeURL );
60 /// set type
61 void SwScriptField::SetPar1( const OUString& rStr )
63 m_sType = rStr;
66 OUString SwScriptField::GetPar1() const
68 return m_sType;
71 /// set code
72 void SwScriptField::SetPar2( const OUString& rStr )
74 m_sCode = rStr;
77 OUString SwScriptField::GetPar2() const
79 return m_sCode;
82 bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
84 switch( nWhichId )
86 case FIELD_PROP_PAR1:
87 rAny <<= m_sType;
88 break;
89 case FIELD_PROP_PAR2:
90 rAny <<= m_sCode;
91 break;
92 case FIELD_PROP_BOOL1:
93 rAny <<= m_bCodeURL;
94 break;
95 default:
96 assert(false);
98 return true;
101 bool SwScriptField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
103 switch( nWhichId )
105 case FIELD_PROP_PAR1:
106 rAny >>= m_sType;
107 break;
108 case FIELD_PROP_PAR2:
109 rAny >>= m_sCode;
110 break;
111 case FIELD_PROP_BOOL1:
112 m_bCodeURL = *o3tl::doAccess<bool>(rAny);
113 break;
114 default:
115 assert(false);
117 return true;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */