Warning, file /office/calligra/libs/flake/KoShapeLayer.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006-2007 Jan Hambrecht <jaham@gmx.net> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "KoShapeLayer.h" 0021 #include "SimpleShapeContainerModel.h" 0022 #include "KoShapeSavingContext.h" 0023 #include "KoShapeLoadingContext.h" 0024 #include <KoXmlReader.h> 0025 #include <KoXmlWriter.h> 0026 #include <KoXmlNS.h> 0027 0028 #include <algorithm> 0029 0030 KoShapeLayer::KoShapeLayer() 0031 : KoShapeContainer(new SimpleShapeContainerModel()) 0032 { 0033 setSelectable(false); 0034 } 0035 0036 KoShapeLayer::KoShapeLayer(KoShapeContainerModel *model) 0037 : KoShapeContainer(model) 0038 { 0039 setSelectable(false); 0040 } 0041 0042 bool KoShapeLayer::hitTest(const QPointF &position) const 0043 { 0044 Q_UNUSED(position); 0045 return false; 0046 } 0047 0048 QRectF KoShapeLayer::boundingRect() const 0049 { 0050 QRectF bb; 0051 0052 foreach(KoShape* shape, shapes()) { 0053 if (bb.isEmpty()) 0054 bb = shape->boundingRect(); 0055 else 0056 bb = bb.united(shape->boundingRect()); 0057 } 0058 0059 return bb; 0060 } 0061 0062 void KoShapeLayer::saveOdf(KoShapeSavingContext & context) const 0063 { 0064 QList<KoShape*> shapes = this->shapes(); 0065 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); 0066 0067 foreach(KoShape* shape, shapes) { 0068 shape->saveOdf(context); 0069 } 0070 } 0071 0072 bool KoShapeLayer::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context) 0073 { 0074 // set layer name 0075 setName(element.attributeNS(KoXmlNS::draw, "name")); 0076 // layer locking 0077 setGeometryProtected(element.attributeNS(KoXmlNS::draw, "protected", "false") == "true"); 0078 // layer visibility 0079 setVisible(element.attributeNS(KoXmlNS::draw, "display", "false") != "none"); 0080 0081 // add layer by name into shape context 0082 context.addLayer(this, name()); 0083 0084 return true; 0085 } 0086 0087 void KoShapeLayer::paintComponent(QPainter &, const KoViewConverter &, KoShapePaintingContext &) 0088 { 0089 }