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 #ifndef _RTFSdrEXPORT_HXX_
25 #define _RTFSdrEXPORT_HXX_
26 
27 #include <filter/msfilter/escherex.hxx>
28 #include <editeng/outlobj.hxx>
29 #include <rtl/strbuf.hxx>
30 
31 #include <map>
32 
33 class RtfExport;
34 class RtfAttributeOutput;
35 
36 class RtfSdrExport : public EscherEx
37 {
38     RtfExport &m_rExport;
39 
40     RtfAttributeOutput &m_rAttrOutput;
41 
42     const SdrObject* m_pSdrObject;
43 
44     /// Remember the shape type.
45     sal_uInt32 m_nShapeType;
46 
47     /// Remember the shape flags.
48     sal_uInt32 m_nShapeFlags;
49 
50     /// Remember style, the most important shape attribute ;-)
51     rtl::OStringBuffer *m_pShapeStyle;
52 
53     std::map<rtl::OString,rtl::OString> m_aShapeProps;
54 
55     /// Remember which shape types we had already written.
56     bool *m_pShapeTypeWritten;
57 
58 public:
59                         RtfSdrExport( RtfExport &rExport );
60     virtual             ~RtfSdrExport();
61 
62     /// Export the sdr object as Sdr.
63     ///
64     /// Call this when you need to export the object as Sdr in RTF.
65     sal_uInt32 AddSdrObject( const SdrObject& rObj );
66 
67 protected:
68     /// Add an attribute to the generated shape element.
69     ///
70     /// This should be called from within StartShape() to ensure that the
71     /// added attribute is preserved.
72     void                AddShapeAttribute( sal_Int32 nAttribute, const rtl::OString& sValue );
73 
74     /// Start the shape for which we just collected the information.
75     ///
76     /// Returns the element's tag number, -1 means we wrote nothing.
77     using EscherEx::StartShape;
78     virtual sal_Int32   StartShape();
79 
80     /// End the shape.
81     ///
82     /// The parameter is just what we got from StartShape().
83     using EscherEx::EndShape;
84     virtual void        EndShape( sal_Int32 nShapeElement );
85 
86     virtual void        Commit( EscherPropertyContainer& rProps, const Rectangle& rRect );
87 
88 private:
89 
90     virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 );
91     virtual void CloseContainer();
92 
93     using EscherEx::EnterGroup;
94     virtual sal_uInt32 EnterGroup( const String& rShapeName, const Rectangle* pBoundRect = 0 );
95     virtual void LeaveGroup();
96 
97     virtual void AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId = 0 );
98 
99 private:
100     /// Add starting and ending point of a line to the m_pShapeAttrList.
101     void AddLineDimensions( const Rectangle& rRectangle );
102 
103     /// Add position and size to the OStringBuffer.
104     void AddRectangleDimensions( rtl::OStringBuffer& rBuffer, const Rectangle& rRectangle );
105 
106     void WriteOutliner(const OutlinerParaObject& rParaObj);
107 };
108 
109 #endif // _RTFSdrEXPORT_HXX_
110 /* vi:set shiftwidth=4 expandtab: */
111