Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /**
57 : * @file
58 : * For LWP filter architecture prototype - OLE object
59 : */
60 : /*************************************************************************
61 : * Change History
62 : Feb 2005 Created
63 : ************************************************************************/
64 : #include <tools/stream.hxx>
65 : #include "lwpglobalmgr.hxx"
66 : #include "lwpoleobject.hxx"
67 : #include "lwpobjfactory.hxx"
68 : #include "lwpidxmgr.hxx"
69 : #include "lwp9reader.hxx"
70 : #include "xfilter/xfparagraph.hxx"
71 : #include "lwpframelayout.hxx"
72 : #include "xfilter/xfstylemanager.hxx"
73 : #include "bento.hxx"
74 :
75 : /**
76 : * @descr: construction function
77 : * @param: objHdr - object header, read before entering this function
78 : * @param: pStrm - file stream
79 : * @return: None
80 : * @date: 2/22/2005
81 : */
82 25 : LwpGraphicOleObject::LwpGraphicOleObject(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
83 25 : : LwpContent(objHdr, pStrm)
84 25 : {}
85 : /**
86 : * @descr: Read GraphicOleObject part
87 : * @param: None
88 : * @return: None
89 : * @date: 2/22/2005
90 : */
91 25 : void LwpGraphicOleObject::Read()
92 : {
93 25 : LwpContent::Read();
94 :
95 24 : if (LwpFileHeader::m_nFileRevision >= 0x000b)
96 : {
97 : // I'm not sure about the read method
98 24 : m_pNextObj.ReadIndexed(m_pObjStrm);
99 24 : m_pPrevObj.ReadIndexed(m_pObjStrm);
100 : }
101 24 : m_pObjStrm->SkipExtra();
102 :
103 24 : }
104 :
105 0 : void LwpGraphicOleObject::GetGrafOrgSize(double & rWidth, double & rHeight)
106 : {
107 0 : rWidth = 0;
108 0 : rHeight = 0;
109 0 : }
110 :
111 13 : void LwpGraphicOleObject::GetGrafScaledSize(double & fWidth, double & fHeight)
112 : {
113 13 : GetGrafOrgSize(fWidth, fHeight);
114 : // scaled image size
115 13 : double fSclGrafWidth = fWidth;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
116 13 : double fSclGrafHeight = fHeight;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
117 :
118 13 : LwpVirtualLayout* pLayout = GetLayout(NULL);
119 13 : if (pLayout && pLayout->IsFrame())
120 : {
121 13 : LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(pLayout);
122 13 : LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
123 13 : LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
124 :
125 : // original image size
126 : //double fOrgGrafWidth = (double)m_Cache.Width/TWIPS_PER_CM;
127 : //double fOrgGrafHeight = (double)m_Cache.Height/TWIPS_PER_CM;
128 :
129 : // get margin values
130 13 : double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
131 13 : double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT);
132 13 : double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
133 13 : double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
134 :
135 13 : if (pMyScale && pFrameGeo)
136 : {
137 : // frame size
138 13 : double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
139 13 : double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
140 :
141 : // calculate the displayed size of the frame
142 13 : double fDisFrameWidth = fFrameWidth - (fLeftMargin+fRightMargin);
143 13 : double fDisFrameHeight = fFrameHeight - (fTopMargin+fBottomMargin);
144 :
145 : // get scale mode
146 13 : sal_uInt16 nScalemode = pMyScale->GetScaleMode();
147 13 : if (nScalemode & LwpLayoutScale::CUSTOM)
148 : {
149 2 : fSclGrafWidth = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
150 2 : fSclGrafHeight = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
151 : }
152 11 : else if (nScalemode & LwpLayoutScale::PERCENTAGE)
153 : {
154 5 : double fScalePercentage = (double)pMyScale->GetScalePercentage() / 1000;
155 5 : fSclGrafWidth = fScalePercentage * fWidth;
156 5 : fSclGrafHeight = fScalePercentage * fHeight;
157 : }
158 6 : else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
159 : {
160 6 : if (pMyFrameLayout->IsFitGraphic())
161 : {
162 0 : fSclGrafWidth = fWidth;
163 0 : fSclGrafHeight = fHeight;
164 : }
165 6 : else if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
166 : {
167 4 : if (fWidth/fHeight >= fDisFrameWidth/fDisFrameHeight)
168 : {
169 1 : fSclGrafWidth = fDisFrameWidth;
170 1 : fSclGrafHeight = (fDisFrameWidth/fWidth) * fHeight;
171 : }
172 : else
173 : {
174 3 : fSclGrafHeight = fDisFrameHeight;
175 3 : fSclGrafWidth = (fDisFrameHeight/fHeight) * fWidth;
176 : }
177 : }
178 : else
179 : {
180 2 : fSclGrafWidth = fDisFrameWidth;
181 2 : fSclGrafHeight = fDisFrameHeight;
182 : }
183 : }
184 : }
185 : }
186 13 : fWidth = fSclGrafWidth ;
187 13 : fHeight = fSclGrafHeight ;
188 :
189 13 : }
190 :
191 : /**
192 : * @descr: construction function
193 : * @param: objHdr - object header, read before entering this function
194 : * @param: pStrm - file stream
195 : * @return: None
196 : * @date: 2/22/2005
197 : */
198 18 : LwpOleObject::LwpOleObject(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
199 : : LwpGraphicOleObject(objHdr, pStrm)
200 : , cPersistentFlags(0)
201 18 : , m_SizeRect(0,0,5,5)
202 : {
203 18 : }
204 : /**
205 : * @descr: Read VO_OLEOBJECT record
206 : * @param: None
207 : * @return: None
208 : * @date: 2/22/2005
209 : */
210 18 : void LwpOleObject::Read()
211 : {
212 18 : LwpGraphicOleObject::Read();
213 :
214 18 : cPersistentFlags = m_pObjStrm->QuickReaduInt16();
215 :
216 : // qCMarker read
217 18 : LwpObjectID ID;
218 :
219 18 : if (LwpFileHeader::m_nFileRevision >= 0x0004)
220 : {
221 18 : m_pObjStrm->QuickReaduInt16();
222 :
223 18 : m_pObjStrm->QuickReadStringPtr();
224 :
225 18 : if (LwpFileHeader::m_nFileRevision < 0x000B)
226 : {
227 : // null pointers have a VO_INVALID type
228 : //if (VO_INVALID == m_pObjStrm->QuickReaduInt16())
229 : // return;
230 :
231 0 : ID.Read(m_pObjStrm);
232 : //return m_pObjStrm->Locate(ID);
233 : }
234 : else
235 : {
236 18 : ID.ReadIndexed(m_pObjStrm);
237 : //if (ID.IsNull())
238 : // return;
239 :
240 : //return m_pObjStrm->Locate(ID);
241 : }
242 : }
243 :
244 18 : if (m_pObjStrm->CheckExtra())
245 : {
246 18 : m_pObjStrm->QuickReaduInt16();
247 18 : m_pObjStrm->SkipExtra();
248 : }
249 :
250 18 : }
251 :
252 : /**
253 : * @descr: Parse VO_OLEOBJECT and dump to XML stream only on WIN32 platform
254 : * @param: pOutputStream - stream to dump OLE object
255 : * @param: pFrameLayout - framlayout object used to dump OLE object
256 : * @return: None
257 : * @date: 2/22/2005
258 : */
259 0 : void LwpOleObject::Parse(IXFStream* /*pOutputStream*/)
260 : {
261 0 : }
262 :
263 9 : void LwpOleObject::XFConvert(XFContentContainer * /*pCont*/)
264 : {
265 9 : }
266 :
267 9 : void LwpOleObject::GetGrafOrgSize(double & rWidth, double & rHeight)
268 : {
269 9 : rWidth = (double)m_SizeRect.GetWidth()/1000;//cm unit
270 9 : rHeight = (double)m_SizeRect.GetHeight()/1000;//cm unit
271 9 : }
272 :
273 18 : void LwpOleObject::RegisterStyle()
274 : {
275 30 : }
276 :
277 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|