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#include <utility>
26
27using namespace ::com::sun::star;
28
31{}
32
33std::unique_ptr<SwFieldType> SwScriptFieldType::Copy() const
34{
35 return std::make_unique<SwScriptFieldType>( m_rDoc );
36}
37
39 OUString aType, OUString aCode,
40 bool bURL )
41 : SwField( pInitType ), m_sType( std::move(aType) ), m_sCode( std::move(aCode) ), m_bCodeURL( bURL )
42{
43}
44
46{
47 return SwResId(STR_SCRIPT);
48}
49
50OUString SwScriptField::ExpandImpl(SwRootFrame const*const) const
51{
52 return OUString();
53}
54
55std::unique_ptr<SwField> SwScriptField::Copy() const
56{
57 return std::make_unique<SwScriptField>( static_cast<SwScriptFieldType*>(GetTyp()), m_sType, m_sCode, m_bCodeURL );
58}
59
61void SwScriptField::SetPar1( const OUString& rStr )
62{
63 m_sType = rStr;
64}
65
66OUString SwScriptField::GetPar1() const
67{
68 return m_sType;
69}
70
72void SwScriptField::SetPar2( const OUString& rStr )
73{
74 m_sCode = rStr;
75}
76
77OUString SwScriptField::GetPar2() const
78{
79 return m_sCode;
80}
81
82bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
83{
84 switch( nWhichId )
85 {
86 case FIELD_PROP_PAR1:
87 rAny <<= m_sType;
88 break;
89 case FIELD_PROP_PAR2:
90 rAny <<= m_sCode;
91 break;
93 rAny <<= m_bCodeURL;
94 break;
95 default:
96 assert(false);
97 }
98 return true;
99}
100
101bool SwScriptField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
102{
103 switch( nWhichId )
104 {
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);
116 }
117 return true;
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:197
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:247
Base class of all fields.
Definition: fldbas.hxx:296
SwFieldType * GetTyp() const
Definition: fldbas.hxx:402
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
virtual std::unique_ptr< SwFieldType > Copy() const override
Definition: scrptfld.cxx:33
SwScriptFieldType(SwDoc &rDoc)
Definition: scrptfld.cxx:29
bool m_bCodeURL
Code contains URL of a script.
Definition: docufld.hxx:713
virtual OUString GetDescription() const override
Definition: scrptfld.cxx:45
virtual OUString ExpandImpl(SwRootFrame const *pLayout) const override
Definition: scrptfld.cxx:50
virtual std::unique_ptr< SwField > Copy() const override
Definition: scrptfld.cxx:55
virtual OUString GetPar1() const override
Type.
Definition: scrptfld.cxx:66
virtual void SetPar1(const OUString &rStr) override
set type
Definition: scrptfld.cxx:61
virtual OUString GetPar2() const override
Text.
Definition: scrptfld.cxx:77
OUString m_sCode
Code as text.
Definition: docufld.hxx:710
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt16 nWhich) override
Definition: scrptfld.cxx:101
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt16 nWhich) const override
Definition: scrptfld.cxx:82
OUString m_sType
Type of Code (Java/VBScript/...)
Definition: docufld.hxx:709
virtual void SetPar2(const OUString &rStr) override
set code
Definition: scrptfld.cxx:72
SwScriptField(SwScriptFieldType *, OUString aType, OUString aCode, bool bURL)
Definition: scrptfld.cxx:38
SwDoc & m_rDoc
Definition: docbm.cxx:1228
SwFieldIds
Definition: fldbas.hxx:49
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
#define FIELD_PROP_BOOL1
Definition: unofldmid.h:28
#define FIELD_PROP_PAR1
Definition: unofldmid.h:23
#define FIELD_PROP_PAR2
Definition: unofldmid.h:24