1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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,
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
58 * For LWP filter architecture prototype - OLE object
60 /*************************************************************************
63 ************************************************************************/
65 #include <tools/stream.hxx>
66 #include "lwpglobalmgr.hxx"
67 #include "lwpoleobject.hxx"
68 #include "lwpobjfactory.hxx"
69 #include "lwpidxmgr.hxx"
70 #include "lwp9reader.hxx"
71 #include "xfilter/xfparagraph.hxx"
72 #include "lwpframelayout.hxx"
73 #include "xfilter/xfstylemanager.hxx"
77 * @descr: construction function
78 * @param: objHdr - object header, read before entering this function
79 * @param: pStrm - file stream
83 LwpGraphicOleObject::LwpGraphicOleObject(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
84 : LwpContent(objHdr
, pStrm
)
87 * @descr: Read GraphicOleObject part
92 void LwpGraphicOleObject::Read()
96 if (LwpFileHeader::m_nFileRevision
>= 0x000b)
98 // I'm not sure about the read method
99 m_pNextObj
.ReadIndexed(m_pObjStrm
);
100 m_pPrevObj
.ReadIndexed(m_pObjStrm
);
102 m_pObjStrm
->SkipExtra();
106 void LwpGraphicOleObject::GetGrafOrgSize(double & rWidth
, double & rHeight
)
112 void LwpGraphicOleObject::GetGrafScaledSize(double & fWidth
, double & fHeight
)
114 GetGrafOrgSize(fWidth
, fHeight
);
116 double fSclGrafWidth
= fWidth
;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
117 double fSclGrafHeight
= fHeight
;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
119 LwpVirtualLayout
* pLayout
= GetLayout(NULL
);
120 if (pLayout
&& pLayout
->IsFrame())
122 LwpFrameLayout
* pMyFrameLayout
= static_cast<LwpFrameLayout
*>(pLayout
);
123 LwpLayoutScale
* pMyScale
= pMyFrameLayout
->GetLayoutScale();
124 LwpLayoutGeometry
* pFrameGeo
= pMyFrameLayout
->GetGeometry();
126 // original image size
127 //double fOrgGrafWidth = (double)m_Cache.Width/TWIPS_PER_CM;
128 //double fOrgGrafHeight = (double)m_Cache.Height/TWIPS_PER_CM;
131 double fLeftMargin
= pMyFrameLayout
->GetMarginsValue(MARGIN_LEFT
);
132 double fRightMargin
= pMyFrameLayout
->GetMarginsValue(MARGIN_RIGHT
);
133 double fTopMargin
= pMyFrameLayout
->GetMarginsValue(MARGIN_TOP
);
134 double fBottomMargin
= pMyFrameLayout
->GetMarginsValue(MARGIN_BOTTOM
);
136 if (pMyScale
&& pFrameGeo
)
139 double fFrameWidth
= LwpTools::ConvertFromUnitsToMetric(pFrameGeo
->GetWidth());
140 double fFrameHeight
= LwpTools::ConvertFromUnitsToMetric(pFrameGeo
->GetHeight());
142 // calculate the displayed size of the frame
143 double fDisFrameWidth
= fFrameWidth
- (fLeftMargin
+fRightMargin
);
144 double fDisFrameHeight
= fFrameHeight
- (fTopMargin
+fBottomMargin
);
147 sal_uInt16 nScalemode
= pMyScale
->GetScaleMode();
148 if (nScalemode
& LwpLayoutScale::CUSTOM
)
150 fSclGrafWidth
= LwpTools::ConvertFromUnitsToMetric(pMyScale
->GetScaleWidth());
151 fSclGrafHeight
= LwpTools::ConvertFromUnitsToMetric(pMyScale
->GetScaleHeight());
153 else if (nScalemode
& LwpLayoutScale::PERCENTAGE
)
155 double fScalePercentage
= (double)pMyScale
->GetScalePercentage() / 1000;
156 fSclGrafWidth
= fScalePercentage
* fWidth
;
157 fSclGrafHeight
= fScalePercentage
* fHeight
;
159 else if (nScalemode
& LwpLayoutScale::FIT_IN_FRAME
)
161 if (pMyFrameLayout
->IsFitGraphic())
163 fSclGrafWidth
= fWidth
;
164 fSclGrafHeight
= fHeight
;
166 else if (nScalemode
& LwpLayoutScale::MAINTAIN_ASPECT_RATIO
)
168 if (fWidth
/fHeight
>= fDisFrameWidth
/fDisFrameHeight
)
170 fSclGrafWidth
= fDisFrameWidth
;
171 fSclGrafHeight
= (fDisFrameWidth
/fWidth
) * fHeight
;
175 fSclGrafHeight
= fDisFrameHeight
;
176 fSclGrafWidth
= (fDisFrameHeight
/fHeight
) * fWidth
;
181 fSclGrafWidth
= fDisFrameWidth
;
182 fSclGrafHeight
= fDisFrameHeight
;
187 fWidth
= fSclGrafWidth
;
188 fHeight
= fSclGrafHeight
;
193 * @descr: construction function
194 * @param: objHdr - object header, read before entering this function
195 * @param: pStrm - file stream
199 LwpOleObject::LwpOleObject(LwpObjectHeader
&objHdr
, LwpSvStream
* pStrm
)
200 : LwpGraphicOleObject(objHdr
, pStrm
)
201 , cPersistentFlags(0)
202 , m_SizeRect(0,0,5,5)
206 * @descr: Read VO_OLEOBJECT record
211 void LwpOleObject::Read()
213 LwpGraphicOleObject::Read();
215 cPersistentFlags
= m_pObjStrm
->QuickReaduInt16();
220 if (LwpFileHeader::m_nFileRevision
>= 0x0004)
222 m_pObjStrm
->QuickReaduInt16();
224 m_pObjStrm
->QuickReadStringPtr();
226 if (LwpFileHeader::m_nFileRevision
< 0x000B)
228 // null pointers have a VO_INVALID type
229 //if (VO_INVALID == m_pObjStrm->QuickReaduInt16())
233 //return m_pObjStrm->Locate(ID);
237 ID
.ReadIndexed(m_pObjStrm
);
241 //return m_pObjStrm->Locate(ID);
245 if (m_pObjStrm
->CheckExtra())
247 m_pObjStrm
->QuickReaduInt16();
248 m_pObjStrm
->SkipExtra();
254 * @descr: Parse VO_OLEOBJECT and dump to XML stream only on WIN32 platform
255 * @param: pOutputStream - stream to dump OLE object
256 * @param: pFrameLayout - framlayout object used to dump OLE object
260 void LwpOleObject::Parse(IXFStream
* /*pOutputStream*/)
264 void LwpOleObject::XFConvert(XFContentContainer
* /*pCont*/)
268 void LwpOleObject::GetGrafOrgSize(double & rWidth
, double & rHeight
)
270 rWidth
= (double)m_SizeRect
.GetWidth()/1000;//cm unit
271 rHeight
= (double)m_SizeRect
.GetHeight()/1000;//cm unit
274 void LwpOleObject::RegisterStyle()
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */