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 #ifndef INCLUDED_GRAPHICIMPORT_HXX
24 #define INCLUDED_GRAPHICIMPORT_HXX
25 
26 //#ifndef INCLUDED_WRITERFILTERDLLAPI_H
27 //#include <WriterFilterDllApi.hxx>
28 //#endif
29 #include <resourcemodel/LoggedResources.hxx>
30 //#include <com/sun/star/lang/XComponent.hpp>
31 namespace com{ namespace sun { namespace star {
32     namespace uno{
33         class XComponentContext;
34     }
35     namespace lang
36     {
37         class XMultiServiceFactory;
38     }
39     namespace text
40     {
41         class XTextContent;
42     }
43     namespace drawing
44     {
45         class XShape;
46     }
47     namespace beans
48     {
49         struct PropertyValue;
50         typedef ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > PropertyValues;
51     }
52 }}}
53 
54 namespace writerfilter {
55 namespace dmapper
56 {
57 class GraphicImport_Impl;
58 class DomainMapper;
59 
60 enum GraphicImportType
61 {
62     IMPORT_AS_GRAPHIC,
63     IMPORT_AS_SHAPE,
64     IMPORT_AS_DETECTED_INLINE,
65     IMPORT_AS_DETECTED_ANCHOR
66 };
67 
68 class WRITERFILTER_DLLPRIVATE GraphicImport : public LoggedProperties, public LoggedTable
69                     ,public BinaryObj, public LoggedStream
70 {
71     GraphicImport_Impl* m_pImpl;
72     ::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext >    m_xComponentContext;
73     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xTextFactory;
74 
75     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > m_xGraphicObject;
76 
77     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> m_xShape;
78     void ProcessShapeOptions(Value & val);
79 
80     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > createGraphicObject(
81             const ::com::sun::star::beans::PropertyValues& aMediaProperties );
82 
83 public:
84     explicit GraphicImport(::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext >    xComponentContext,
85                   ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xTextFactory,
86                   DomainMapper& rDomainMapper,
87                   GraphicImportType eGraphicImportType);
88     virtual ~GraphicImport();
89 
90     // BinaryObj
91     virtual void data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t ref);
92 
93     ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > GetGraphicObject();
94     bool    IsGraphic() const;
95 
96  private:
97     // Properties
98     virtual void lcl_attribute(Id Name, Value & val);
99     virtual void lcl_sprm(Sprm & sprm);
100 
101     // Table
102     virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
103 
104     // Stream
105     virtual void lcl_startSectionGroup();
106     virtual void lcl_endSectionGroup();
107     virtual void lcl_startParagraphGroup();
108     virtual void lcl_endParagraphGroup();
109     virtual void lcl_startCharacterGroup();
110     virtual void lcl_endCharacterGroup();
111     virtual void lcl_text(const sal_uInt8 * data, size_t len);
112     virtual void lcl_utext(const sal_uInt8 * data, size_t len);
113     virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref);
114     virtual void lcl_table(Id name,
115                            writerfilter::Reference<Table>::Pointer_t ref);
116     virtual void lcl_substream(Id name,
117                                ::writerfilter::Reference<Stream>::Pointer_t ref);
118     virtual void lcl_info(const string & info);
119     virtual void lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
120     virtual void lcl_endShape( );
121 
122     void handleWrapTextValue(sal_uInt32 nVal);
123 };
124 
125 typedef boost::shared_ptr< GraphicImport >          GraphicImportPtr;
126 }}
127 
128 #endif //
129