Updated core
[LibreOffice.git] / writerfilter / source / doctok / WW8Picture.cxx
blobf6d7ddc41f388c58c83d1d6b5597e5d2c17fad78
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 <doctok/resources.hxx>
21 #include <WW8DocumentImpl.hxx>
23 namespace writerfilter {
24 namespace doctok
27 void WW8PICF::resolveNoAuto(Properties & rHandler)
29 WW8Stream::Pointer_t pStream = getDocument()->getDataStream();
32 writerfilter::Reference<Properties>::Pointer_t pContent;
33 if (getDocument()->isPicData())
35 WW8Value::Pointer_t pValue = createValue(get_ffdata());
36 rHandler.attribute(NS_rtf::LN_ffdata, *pValue);
38 else
40 WW8Value::Pointer_t pValue = createValue(get_DffRecord());
41 rHandler.attribute(NS_rtf::LN_DffRecord, *pValue);
46 writerfilter::Reference<Properties>::Pointer_t
47 WW8PICF::get_DffRecord()
49 writerfilter::Reference<Properties>::Pointer_t
50 pRet(new DffBlock(this, get_cbHeader(), getCount() - get_cbHeader(),
51 0));
52 return pRet;
55 writerfilter::Reference<Properties>::Pointer_t
56 WW8PICF::get_ffdata()
58 writerfilter::Reference<Properties>::Pointer_t
59 pRet(new WW8FFDATA(this, get_cbHeader(), getCount() - get_cbHeader()));
61 WW8StructBase::Pointer_t pStruct
62 (new WW8StructBase(this, get_cbHeader(),
63 getCount() - get_cbHeader()));
65 pStruct->dump(output);
67 return pRet;
70 writerfilter::Reference<Properties>::Pointer_t
71 WW8FSPA::get_shape()
73 return getDocument()->getShape(get_spid());
76 void WW8FFDATA::resolveNoAuto(Properties & rHandler)
78 WW8DocumentImpl * pDocument = getDocument();
80 if (pDocument != NULL)
82 WW8FLD::Pointer_t pFLD = pDocument->getCurrentFLD();
83 WW8Value::Pointer_t pValue = createValue(pFLD->get_flt());
85 rHandler.attribute(NS_rtf::LN_FLT, *pValue);
90 sal_uInt32 WW8FFDATA::get_FLT()
92 sal_uInt32 nResult = 0;
94 WW8DocumentImpl * pDocument = getDocument();
96 if (pDocument != NULL)
98 WW8FLD::Pointer_t pFLD = pDocument->getCurrentFLD();
100 if (pFLD.get() != NULL)
101 nResult = pFLD->get_flt();
104 return nResult;
107 static sal_uInt32 lcl_FFDATA_default_offset(WW8FFDATA & rRef)
109 return 0xa + (rRef.getU16(0xa) + 2) * 2;
112 static sal_uInt32 lcl_FFDATA_formatting_offset(WW8FFDATA & rRef)
114 sal_uInt32 nResult = lcl_FFDATA_default_offset(rRef);
116 switch (rRef.get_FLT())
118 case 71: // forms checkbox
119 case 83: // forms listbox
120 nResult += 2;
121 break;
122 default:
123 nResult += (rRef.getU16(nResult) + 2) * 2;
124 break;
127 return nResult;
130 static sal_uInt32 lcl_FFDATA_help_offset(WW8FFDATA & rRef)
132 sal_uInt32 nResult = lcl_FFDATA_formatting_offset(rRef);
134 nResult += (rRef.getU16(nResult) + 2) * 2;
136 return nResult;
139 static sal_uInt32 lcl_FFDATA_tooltip_offset(WW8FFDATA & rRef)
141 sal_uInt32 nResult = lcl_FFDATA_help_offset(rRef);
143 nResult += (rRef.getU16(nResult) + 2) * 2;
145 return nResult;
148 OUString WW8FFDATA::get_default()
150 OUString sResult;
152 sal_uInt32 nOffset = lcl_FFDATA_default_offset(*this);
153 switch (get_FLT())
155 case 70:
156 sResult = getString(nOffset);
158 break;
159 default:
160 break;
163 return sResult;
166 OUString WW8FFDATA::get_formatting()
168 return getString(lcl_FFDATA_formatting_offset(*this));
171 OUString WW8FFDATA::get_help()
173 return getString(lcl_FFDATA_help_offset(*this));
176 OUString WW8FFDATA::get_tooltip()
178 OUString sResult;
180 sResult = getString(lcl_FFDATA_tooltip_offset(*this));
182 return sResult;
185 sal_uInt16 WW8FFDATA::get_checked()
187 sal_uInt16 nResult = 0;
189 switch (get_FLT())
191 case 71:
192 nResult = getU16(lcl_FFDATA_default_offset(*this));
193 break;
194 default:
195 break;
198 return nResult;
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */