xref: /aoo4110/main/sw/source/filter/ww8/escher.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
25 
26 #ifndef _ESCHER_HXX
27 #define _ESCHER_HXX
28 
29 #ifndef _ESCHEREX_HXX
30 #include <filter/msfilter/escherex.hxx>
31 #endif
32 
33 const sal_uInt32 nInlineHack = 0x00010001;
34 class SwFrmFmt;
35 // --> OD 2005-01-06 #i30669#
36 class SwFmtHoriOrient;
37 class SwFmtVertOrient;
38 // <--
39 
40 class WinwordAnchoring : public EscherExClientRecord_Base
41 {
42 public:
43     void WriteData(EscherEx& rEx) const;
44     void SetAnchoring(const SwFrmFmt& rFmt);
45 
46     /** method to perform conversion of positioning attributes with the help
47         of corresponding layout information
48 
49         OD 2005-01-06 #i30669#
50         Because most of the Writer object positions doesn't correspond to the
51         object positions in WW8, this method converts the positioning
52         attributes. For this conversion the corresponding layout information
53         is needed. If no layout information exists - e.g. no layout exists - no
54         conversion is performed.
55         No conversion is performed for as-character anchored objects. Whose
56         object positions are already treated special in method <WriteData(..)>.
57         Usage of method: Used by method <SetAnchoring(..)>, nothing else
58 
59         @author OD
60 
61         @param _iorHoriOri
62         input/output parameter - containing the current horizontal position
63         attributes, which are converted by this method.
64 
65         @param _iorVertOri
66         input/output parameter - containing the current vertical position
67         attributes, which are converted by this method.
68 
69         @param _rFrmFmt
70         input parameter - frame format of the anchored object
71 
72         @return boolean, indicating, if a conversion has been performed.
73     */
74     static bool ConvertPosition( SwFmtHoriOrient& _iorHoriOri,
75                                  SwFmtVertOrient& _iorVertOri,
76                                  const SwFrmFmt& _rFrmFmt );
77 
78 private:
79     bool mbInline;
80     sal_uInt32 mnXAlign;
81     sal_uInt32 mnYAlign;
82     sal_uInt32 mnXRelTo;
83     sal_uInt32 mnYRelTo;
84 
85 };
86 
87 class SwEscherExGlobal : public EscherExGlobal
88 {
89 public:
90     explicit            SwEscherExGlobal();
91     virtual             ~SwEscherExGlobal();
92 
93 private:
94     /** Overloaded to create a new memory stream for picture data. */
95     virtual SvStream*   ImplQueryPictureStream();
96 
97 private:
98     ::std::auto_ptr< SvStream > mxPicStrm;
99 };
100 
101 class SwBasicEscherEx : public EscherEx
102 {
103 private:
104     void Init();
105 protected:
106     WW8Export& rWrt;
107     SvStream* pEscherStrm;
108     long mnEmuMul, mnEmuDiv;
109 
110     virtual sal_Int32 WriteFlyFrameAttr(const SwFrmFmt& rFmt, MSO_SPT eShapeType,
111         EscherPropertyContainer& rPropOpt);
112     void WriteBrushAttr(const SvxBrushItem &rBrush,
113         EscherPropertyContainer& rPropOpt);
114     void WriteOLEPicture(EscherPropertyContainer &rPropOpt,
115         sal_uInt32 nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj,
116         sal_uInt32 nShapeId, const com::sun::star::awt::Rectangle* pVisArea );
117     void WriteGrfAttr(const SwNoTxtNode& rNd,EscherPropertyContainer& rPropOpt);
118 
DrawModelToEmu(sal_Int32 nVal) const119     sal_Int32 DrawModelToEmu(sal_Int32 nVal) const
120         { return BigMulDiv(nVal, mnEmuMul, mnEmuDiv); }
121 
122     sal_Int32 ToFract16(sal_Int32 nVal, sal_uInt32 nMax) const;
123 
124     virtual void SetPicId(const SdrObject &, sal_uInt32, EscherPropertyContainer &);
125     SdrLayerID GetInvisibleHellId() const;
126 
127 public:
128     SwBasicEscherEx(SvStream* pStrm, WW8Export& rWrt);
129     sal_Int32 WriteGrfFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId);
130 	//For i120928,to export graphic of bullet
131 	sal_Int32 WriteGrfBullet(const Graphic&);
132     sal_Int32 WriteOLEFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId);
133     void WriteEmptyFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nShapeId);
134     virtual void WriteFrmExtraData(const SwFrmFmt&);
135     virtual void WritePictures();
136     virtual ~SwBasicEscherEx();
137     //i120927,this function is added to export hyperlink info,such as graphic/frame/OLE
138     bool IsRelUrl();
139     String GetBasePath();
140     String BuildFileName(sal_uInt16& rnLevel, bool& rbRel, const String& rUrl );
141     void WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFmtURL* pINetFmtArg);
142     void PreWriteHyperlinkWithinFly(const SwFrmFmt& rFmt,EscherPropertyContainer& rPropOpt);
143 
144 private:
145     //No copying
146     SwBasicEscherEx(const SwBasicEscherEx&);
147     SwBasicEscherEx& operator=(const SwBasicEscherEx&);
148 };
149 
150 class SwEscherEx : public SwBasicEscherEx
151 {
152 private:
153     SvULongs aFollowShpIds;
154     EscherExHostAppData aHostData;
155     WinwordAnchoring aWinwordAnchoring;
156     WW8_WrPlcTxtBoxes *pTxtBxs;
157 
158     sal_uInt32 GetFlyShapeId(const SwFrmFmt& rFmt,
159         unsigned int nHdFtIndex, DrawObjPointerVector &rPVec);
160     void MakeZOrderArrAndFollowIds(std::vector<DrawObj>& rSrcArr,
161         DrawObjPointerVector& rDstArr);
162 
163     sal_Int32 WriteFlyFrm(const DrawObj &rObj, sal_uInt32 &rShapeId,
164         DrawObjPointerVector &rPVec);
165     sal_Int32 WriteTxtFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId,
166         sal_uInt32 nTxtBox, DrawObjPointerVector &rPVec);
167     void WriteOCXControl(const SwFrmFmt& rFmt,sal_uInt32 nShapeId);
168     virtual sal_Int32 WriteFlyFrameAttr(const SwFrmFmt& rFmt, MSO_SPT eShapeType,
169         EscherPropertyContainer& rPropOpt);
170 
171     virtual sal_uInt32 QueryTextID(
172         const com::sun::star::uno::Reference<
173         com::sun::star::drawing::XShape > &,sal_uInt32);
174     virtual void SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId,
175         EscherPropertyContainer &rPropOpt);
176 public:
177     SwEscherEx( SvStream* pStrm, WW8Export& rWW8Wrt );
178     virtual ~SwEscherEx();
179     void FinishEscher();
180     virtual void WritePictures();
181 
182     virtual void WriteFrmExtraData(const SwFrmFmt& rFmt);
183 
StartShape(const com::sun::star::uno::Reference<com::sun::star::drawing::XShape> &,const Rectangle *)184     EscherExHostAppData* StartShape(const com::sun::star::uno::Reference<
185         com::sun::star::drawing::XShape > &, const Rectangle*) {return &aHostData;}
186 private:
187     //No copying
188     SwEscherEx(const SwEscherEx&);
189     SwEscherEx &operator=(const SwEscherEx&);
190 };
191 
192 #endif
193 
194 /* vi:set tabstop=4 shiftwidth=4 expandtab: */
195