File indexing completed on 2024-05-12 16:37:15
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2001 David Faure <faure@kde.org> 0003 * Copyright (C) 2005-2006 Thomas Zander <zander@kde.org> 0004 * Copyright (C) 2010-2011 Boudewijn Rempt <boud@kogmbh.com> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include "KWViewMode.h" 0023 0024 #include <KoViewConverter.h> 0025 0026 #include "KWDocument.h" 0027 #include "KWViewModeNormal.h" 0028 #include "KWViewModePreview.h" 0029 0030 KWViewMode::KWViewMode() 0031 : m_pageManager(0) 0032 { 0033 } 0034 0035 QRectF KWViewMode::documentToView(const QRectF &rect, KoViewConverter *viewConverter) const 0036 { 0037 QRectF r; 0038 QPointF topLeft(documentToView(rect.topLeft(), viewConverter)); 0039 QPointF bottomRight(documentToView(rect.bottomRight(), viewConverter)); 0040 0041 r.setCoords(topLeft.x(), topLeft.y(), bottomRight.x(), bottomRight.y()); 0042 return r; 0043 } 0044 0045 QRectF KWViewMode::viewToDocument(const QRectF &rect, KoViewConverter *viewConverter) const 0046 { 0047 QRectF r; 0048 QPointF topLeft(viewToDocument(rect.topLeft(), viewConverter)); 0049 QPointF bottomRight(viewToDocument(rect.bottomRight(), viewConverter)); 0050 0051 r.setCoords(topLeft.x(), topLeft.y(), bottomRight.x(), bottomRight.y()); 0052 return r; 0053 } 0054 0055 void KWViewMode::pageSetupChanged() 0056 { 0057 updatePageCache(); 0058 } 0059 0060 // static 0061 KWViewMode *KWViewMode::create(const QString &viewModeType, KWDocument *document) 0062 { 0063 KWViewMode * vm = 0; 0064 if (viewModeType == KWViewModePreview::viewMode()) 0065 vm = new KWViewModePreview(); 0066 if (vm == 0) 0067 vm = new KWViewModeNormal(); 0068 0069 vm->setPageManager(document->pageManager()); 0070 return vm; 0071 } 0072