LibreOffice Module sw (master) 1
scrptfld.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 <docufld.hxx>
21#include <unofldmid.h>
22#include <strings.hrc>
23#include <o3tl/any.hxx>
24#include <swtypes.hxx>
25
26using namespace ::com::sun::star;
27
30{}
31
32std::unique_ptr<SwFieldType> SwScriptFieldType::Copy() const
33{
34 return std::make_unique<SwScriptFieldType>( m_rDoc );
35}
36
38 const OUString& rType, const OUString& rCode,
39 bool bURL )
40 : SwField( pInitType ), m_sType( rType ), m_sCode( rCode ), m_bCodeURL( bURL )
41{
42}
43
45{
46 return SwResId(STR_SCRIPT);
47}
48
49OUString SwScriptField::ExpandImpl(SwRootFrame const*const) const
50{
51 return OUString();
52}
53
54std::unique_ptr<SwField> SwScriptField::Copy() const
55{
56 return std::make_unique<SwScriptField>( static_cast<SwScriptFieldType*>(GetTyp()), m_sType, m_sCode, m_bCodeURL );
57}
58
60void SwScriptField::SetPar1( const OUString& rStr )
61{
62 m_sType = rStr;
63}
64
65OUString SwScriptField::GetPar1() const
66{
67 return m_sType;
68}
69
71void SwScriptField::SetPar2( const OUString& rStr )
72{
73 m_sCode = rStr;
74}
75
76OUString SwScriptField::GetPar2() const
77{
78 return m_sCode;
79}
80
81bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
82{
83 switch( nWhichId )
84 {
85 case FIELD_PROP_PAR1:
86 rAny <<= m_sType;
87 break;
88 case FIELD_PROP_PAR2:
89 rAny <<= m_sCode;
90 break;
92 rAny <<= m_bCodeURL;
93 break;
94 default:
95 assert(false);
96 }
97 return true;
98}
99
100bool SwScriptField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
101{
102 switch( nWhichId )
103 {
104 case FIELD_PROP_PAR1:
105 rAny >>= m_sType;
106 break;
107 case FIELD_PROP_PAR2:
108 rAny >>= m_sCode;
109 break;
110 case FIELD_PROP_BOOL1:
111 m_bCodeURL = *o3tl::doAccess<bool>(rAny);
112 break;
113 default:
114 assert(false);
115 }
116 return true;
117}
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:188
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:242
Base class of all fields.
Definition: fldbas.hxx:292
SwFieldType * GetTyp() const
Definition: fldbas.hxx:398
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: scrptfld.cxx:32
SwScriptFieldType(SwDoc &rDoc)
Definition: scrptfld.cxx:28
bool m_bCodeURL
Code contains URL of a script.
Definition: docufld.hxx:704
virtual OUString GetDescription() const override
Definition: scrptfld.cxx:44
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: scrptfld.cxx:49
virtual std::unique_ptr< SwField > Copy() const override
Definition: scrptfld.cxx:54
virtual OUString GetPar1() const override
Type.
Definition: scrptfld.cxx:65
virtual void SetPar1(const OUString &rStr) override
set type
Definition: scrptfld.cxx:60
virtual OUString GetPar2() const override
Text.
Definition: scrptfld.cxx:76
OUString m_sCode
Code as text.
Definition: docufld.hxx:701
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: scrptfld.cxx:100
SwScriptField(SwScriptFieldType *, const OUString &rType, const OUString &rCode, bool bURL)
Definition: scrptfld.cxx:37
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: scrptfld.cxx:81
OUString m_sType
Type of Code (Java/VBScript/...)
Definition: docufld.hxx:700
virtual void SetPar2(const OUString &rStr) override
set code
Definition: scrptfld.cxx:71
SwDoc & m_rDoc
Definition: docbm.cxx:1201
SwFieldIds
Definition: fldbas.hxx:45
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24