vcl: support rendering multiple PDF pages to bitmap
[LibreOffice.git] / idlc / source / astconstant.cxx
blob54d235fa32ed90410f36df7cd75ea849a6d50a6d
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 <astconstant.hxx>
21 #include <astscope.hxx>
23 #include <registry/writer.hxx>
25 AstConstant::AstConstant(const ExprType type,
26 const NodeType nodeType,
27 AstExpression* pExpr,
28 const OString& name,
29 AstScope* pScope)
30 : AstDeclaration(nodeType, name, pScope)
31 , m_pConstValue(pExpr)
32 , m_constValueType(type)
36 AstConstant::AstConstant(const ExprType type,
37 AstExpression* pExpr,
38 const OString& name,
39 AstScope* pScope)
40 : AstDeclaration(NT_const, name, pScope)
41 , m_pConstValue(pExpr)
42 , m_constValueType(type)
46 AstConstant::~AstConstant()
51 bool AstConstant::dumpBlob(
52 typereg::Writer & rBlob, sal_uInt16 index, bool published)
54 RTConstValue aConst;
56 AstExprValue *exprVal = getConstValue()->getExprValue();
57 switch (getConstValueType())
59 case ET_short:
60 aConst.m_type = RT_TYPE_INT16;
61 aConst.m_value.aShort = exprVal->u.sval;
62 break;
63 case ET_ushort:
64 aConst.m_type = RT_TYPE_UINT16;
65 aConst.m_value.aUShort = exprVal->u.usval;
66 break;
67 case ET_long:
68 aConst.m_type = RT_TYPE_INT32;
69 aConst.m_value.aLong = exprVal->u.lval;
70 break;
71 case ET_ulong:
72 aConst.m_type = RT_TYPE_UINT32;
73 aConst.m_value.aULong = exprVal->u.ulval;
74 break;
75 case ET_hyper:
76 aConst.m_type = RT_TYPE_INT64;
77 aConst.m_value.aHyper = exprVal->u.hval;
78 break;
79 case ET_uhyper:
80 aConst.m_type = RT_TYPE_UINT64;
81 aConst.m_value.aUHyper = exprVal->u.uhval;
82 break;
83 case ET_float:
84 aConst.m_type = RT_TYPE_FLOAT;
85 aConst.m_value.aFloat = exprVal->u.fval;
86 break;
87 case ET_double:
88 aConst.m_type = RT_TYPE_DOUBLE;
89 aConst.m_value.aDouble = exprVal->u.dval;
90 break;
91 case ET_byte:
92 aConst.m_type = RT_TYPE_BYTE;
93 aConst.m_value.aByte = exprVal->u.byval;
94 break;
95 case ET_boolean:
96 aConst.m_type = RT_TYPE_BOOL;
97 aConst.m_value.aBool = exprVal->u.bval;
98 break;
99 default:
101 fprintf(stderr, "%s: exprtype to const type: cannot convert ExprType\n",
102 idlc()->getOptions()->getProgramName().getStr());
103 return false;
107 OString name = getLocalName();
109 OUString type;
110 if ( getNodeType() != NT_enum_val )
112 type = OStringToOUString(exprTypeToString(getConstValueType()), RTL_TEXTENCODING_UTF8);
115 rBlob.setFieldData(
116 index, getDocumentation(), OUString(),
117 RTFieldAccess::CONST | (published ? RTFieldAccess::PUBLISHED : RTFieldAccess::NONE),
118 OStringToOUString(name, RTL_TEXTENCODING_UTF8), type, aConst);
120 return true;
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */