Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_GRAPHICIMPORT_HXX
20 : #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_GRAPHICIMPORT_HXX
21 :
22 : #include <queue>
23 : #include <boost/scoped_ptr.hpp>
24 :
25 : #include "LoggedResources.hxx"
26 :
27 : namespace com { namespace sun { namespace star {
28 : namespace uno
29 : {
30 : class XComponentContext;
31 : }
32 : namespace lang
33 : {
34 : class XMultiServiceFactory;
35 : }
36 : namespace text
37 : {
38 : class XTextContent;
39 : }
40 : namespace drawing
41 : {
42 : class XShape;
43 : }
44 : namespace beans
45 : {
46 : struct PropertyValue;
47 : typedef css::uno::Sequence< css::beans::PropertyValue > PropertyValues;
48 : }
49 : }}}
50 :
51 : namespace writerfilter
52 : {
53 : namespace dmapper
54 : {
55 : class GraphicImport_Impl;
56 : class DomainMapper;
57 :
58 : enum GraphicImportType
59 : {
60 : IMPORT_AS_DETECTED_INLINE,
61 : IMPORT_AS_DETECTED_ANCHOR
62 : };
63 :
64 : class GraphicImport : public LoggedProperties, public LoggedTable
65 : ,public BinaryObj, public LoggedStream
66 : {
67 : boost::scoped_ptr<GraphicImport_Impl> m_pImpl;
68 :
69 : css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
70 : css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory;
71 :
72 : css::uno::Reference<css::text::XTextContent> m_xGraphicObject;
73 :
74 : css::uno::Reference<css::drawing::XShape> m_xShape;
75 : void ProcessShapeOptions(Value & val);
76 :
77 : css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties, const css::uno::Reference<css::beans::XPropertySet>& xShapeProps);
78 :
79 : void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
80 :
81 : public:
82 : explicit GraphicImport( css::uno::Reference<css::uno::XComponentContext> const& xComponentContext,
83 : css::uno::Reference<css::lang::XMultiServiceFactory> const& xTextFactory,
84 : DomainMapper& rDomainMapper,
85 : GraphicImportType eGraphicImportType,
86 : std::pair<OUString, OUString>& rPositionOffsets,
87 : std::pair<OUString, OUString>& rAligns,
88 : std::queue<OUString>& rPositivePercentages);
89 : virtual ~GraphicImport();
90 :
91 : // BinaryObj
92 : virtual void data(const sal_uInt8* buffer, size_t len, writerfilter::Reference<Properties>::Pointer_t ref) SAL_OVERRIDE;
93 :
94 : css::uno::Reference<css::text::XTextContent> GetGraphicObject();
95 86 : css::uno::Reference<css::drawing::XShape> GetXShapeObject() { return m_xShape;}
96 : bool IsGraphic() const;
97 :
98 : private:
99 : // Properties
100 : virtual void lcl_attribute(Id Name, Value & val) SAL_OVERRIDE;
101 : virtual void lcl_sprm(Sprm & sprm) SAL_OVERRIDE;
102 :
103 : // Table
104 : virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) SAL_OVERRIDE;
105 :
106 : // Stream
107 : virtual void lcl_startSectionGroup() SAL_OVERRIDE;
108 : virtual void lcl_endSectionGroup() SAL_OVERRIDE;
109 : virtual void lcl_startParagraphGroup() SAL_OVERRIDE;
110 : virtual void lcl_endParagraphGroup() SAL_OVERRIDE;
111 : virtual void lcl_startCharacterGroup() SAL_OVERRIDE;
112 : virtual void lcl_endCharacterGroup() SAL_OVERRIDE;
113 : virtual void lcl_text(const sal_uInt8 * data, size_t len) SAL_OVERRIDE;
114 : virtual void lcl_utext(const sal_uInt8 * data, size_t len) SAL_OVERRIDE;
115 : virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref) SAL_OVERRIDE;
116 : virtual void lcl_table(Id name,
117 : writerfilter::Reference<Table>::Pointer_t ref) SAL_OVERRIDE;
118 : virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) SAL_OVERRIDE;
119 : virtual void lcl_info(const std::string & info) SAL_OVERRIDE;
120 : virtual void lcl_startShape(css::uno::Reference<css::drawing::XShape> const& xShape) SAL_OVERRIDE;
121 : virtual void lcl_endShape() SAL_OVERRIDE;
122 :
123 : void handleWrapTextValue(sal_uInt32 nVal);
124 : };
125 :
126 : typedef std::shared_ptr<GraphicImport> GraphicImportPtr;
127 :
128 : }}
129 :
130 : #endif
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|