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_SLIDESHOW_SHAPEIMPORTER_HXX
20 : #define INCLUDED_SLIDESHOW_SHAPEIMPORTER_HXX
21 :
22 : #include <com/sun/star/drawing/XDrawPage.hpp>
23 : #include <com/sun/star/drawing/XShapes.hpp>
24 : #include <com/sun/star/beans/XPropertySet.hpp>
25 : #include <com/sun/star/drawing/XLayer.hpp>
26 : #include "unoviewcontainer.hxx"
27 : #include "unoview.hxx"
28 :
29 : #include "shape.hxx"
30 :
31 : #include <stack>
32 :
33 : namespace slideshow {
34 : namespace internal {
35 :
36 : struct SlideShowContext;
37 :
38 : typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector;
39 : typedef ::boost::shared_ptr< UnoView > UnoViewSharedPtr;
40 : typedef ::std::vector< UnoViewSharedPtr > UnoViewVector;
41 :
42 : /** This class imports all shapes from a given XShapes object
43 : */
44 0 : class ShapeImporter
45 : {
46 : public:
47 : /** Create shape importer.
48 :
49 : @param xPage
50 : Page containing the shapes
51 :
52 : @param xActualPage
53 : Actual page that's imported - if xPage is a master
54 : page, this argument must refer to the using, i.e the
55 : page that embeds this specific masterpage. Otherwise,
56 : this argument is probably equal to xPage.
57 :
58 : @param nOrdNumStart
59 : Each shape receives a z order number, in order of
60 : import (which relies on the fact that the API returns
61 : the shapes in draw order - which it does,
62 : currently). Since we might mix several pages on screen
63 : (e.g. master page and foreground page), this value can
64 : be used as an offset to distinguish those pages.
65 :
66 : @param bConvertingMasterPage
67 : When true, then the master page is imported. Otherwise, this
68 : object imports the draw page.
69 : */
70 : ShapeImporter( const ::com::sun::star::uno::Reference<
71 : ::com::sun::star::drawing::XDrawPage >& xPage,
72 : const ::com::sun::star::uno::Reference<
73 : ::com::sun::star::drawing::XDrawPage >& xActualPage,
74 : const ::com::sun::star::uno::Reference<
75 : ::com::sun::star::drawing::XDrawPagesSupplier>& xPagesSupplier,
76 : const SlideShowContext& rContext,
77 : sal_Int32 nOrdNumStart,
78 : bool bConvertingMasterPage );
79 :
80 : /** This method imports the presentation background shape
81 : */
82 : ShapeSharedPtr importBackgroundShape(); // throw (ShapeLoadFailedException)
83 :
84 : /** This method imports presentation-visible shapes (and skips all others).
85 :
86 : @return the generated Shape, or NULL for no more shapes.
87 : */
88 : ShapeSharedPtr importShape(); // throw (ConversionFailedException)
89 :
90 : /** Test whether import is done.
91 :
92 : @return true, if all shapes are imported via the
93 : importShape() call.
94 : */
95 : bool isImportDone() const;
96 : PolyPolygonVector getPolygons();
97 :
98 0 : double getImportedShapesCount() { return mnAscendingPrio; }
99 : private:
100 : bool isSkip( ::com::sun::star::uno::Reference<
101 : ::com::sun::star::beans::XPropertySet> const& xPropSet,
102 : OUString const& shapeType,
103 : ::com::sun::star::uno::Reference<
104 : ::com::sun::star::drawing::XLayer> const& xLayer);
105 :
106 : ShapeSharedPtr createShape(
107 : ::com::sun::star::uno::Reference<
108 : ::com::sun::star::drawing::XShape> const& xCurrShape,
109 : ::com::sun::star::uno::Reference<
110 : ::com::sun::star::beans::XPropertySet> const& xPropSet,
111 : OUString const& shapeType ) const;
112 :
113 : void importPolygons(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > const& xPropSet) ;
114 :
115 0 : struct XShapesEntry
116 : {
117 : ShapeSharedPtr const mpGroupShape;
118 : ::com::sun::star::uno::Reference<
119 : ::com::sun::star::drawing::XShapes> const mxShapes;
120 : sal_Int32 const mnCount;
121 : sal_Int32 mnPos;
122 :
123 0 : explicit XShapesEntry( ShapeSharedPtr const& pGroupShape )
124 : : mpGroupShape(pGroupShape),
125 0 : mxShapes( pGroupShape->getXShape(),
126 : ::com::sun::star::uno::UNO_QUERY_THROW ),
127 0 : mnCount(mxShapes->getCount()), mnPos(0) {}
128 0 : explicit XShapesEntry( ::com::sun::star::uno::Reference<
129 : ::com::sun::star::drawing::XShapes> const& xShapes )
130 : : mpGroupShape(), mxShapes(xShapes),
131 0 : mnCount(xShapes->getCount()), mnPos(0) {}
132 : };
133 : typedef ::std::stack<XShapesEntry> XShapesStack;
134 :
135 : ::com::sun::star::uno::Reference<
136 : ::com::sun::star::drawing::XDrawPage> mxPage;
137 : ::com::sun::star::uno::Reference<
138 : ::com::sun::star::drawing::XDrawPagesSupplier> mxPagesSupplier;
139 : const SlideShowContext& mrContext;
140 : PolyPolygonVector maPolygons;
141 : XShapesStack maShapesStack;
142 : double mnAscendingPrio;
143 : bool mbConvertingMasterPage;
144 : };
145 :
146 : } // namespace internal
147 : } // namespace presentation
148 :
149 : #endif
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|