fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / engine / shapesubset.cxx
blob50e1b2522243640127193aacb8bf76e701418140
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <canvas/debug.hxx>
22 #include <tools/diagnose_ex.h>
24 #include <comphelper/anytostring.hxx>
25 #include <cppuhelper/exc_hlp.hxx>
27 #include "shapesubset.hxx"
30 using namespace ::com::sun::star;
32 namespace slideshow
34 namespace internal
36 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
37 const DocTreeNode& rTreeNode,
38 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
39 mpOriginalShape( rOriginalShape ),
40 mpSubsetShape(),
41 maTreeNode( rTreeNode ),
42 mpShapeManager( rShapeManager )
44 ENSURE_OR_THROW( mpShapeManager,
45 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
48 ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
49 const DocTreeNode& rTreeNode ) :
50 mpOriginalShape( rOriginalSubset->mpSubsetShape ?
51 rOriginalSubset->mpSubsetShape :
52 rOriginalSubset->mpOriginalShape ),
53 mpSubsetShape(),
54 maTreeNode( rTreeNode ),
55 mpShapeManager( rOriginalSubset->mpShapeManager )
57 ENSURE_OR_THROW( mpShapeManager,
58 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
59 ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
60 (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
61 rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
62 "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
65 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
66 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
67 mpOriginalShape( rOriginalShape ),
68 mpSubsetShape(),
69 maTreeNode(),
70 mpShapeManager( rShapeManager )
72 ENSURE_OR_THROW( mpShapeManager,
73 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
76 ShapeSubset::~ShapeSubset()
78 try
80 // if not done yet: revoke subset from original
81 disableSubsetShape();
83 catch (uno::Exception &)
85 OSL_FAIL( OUStringToOString(
86 comphelper::anyToString(
87 cppu::getCaughtException() ),
88 RTL_TEXTENCODING_UTF8 ).getStr() );
92 AttributableShapeSharedPtr ShapeSubset::getSubsetShape() const
94 return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
97 bool ShapeSubset::enableSubsetShape()
99 if( !mpSubsetShape &&
100 !maTreeNode.isEmpty() )
102 mpSubsetShape = mpShapeManager->getSubsetShape(
103 mpOriginalShape,
104 maTreeNode );
107 return static_cast< bool >(mpSubsetShape);
110 void ShapeSubset::disableSubsetShape()
112 if( mpSubsetShape )
114 mpShapeManager->revokeSubset( mpOriginalShape,
115 mpSubsetShape );
116 mpSubsetShape.reset();
120 bool ShapeSubset::isFullSet() const
122 return maTreeNode.isEmpty();
125 DocTreeNode ShapeSubset::getSubset() const
127 return maTreeNode;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */