File indexing completed on 2024-05-12 16:35:03
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2011 Sebastian Sauer <mail@dipe.org> 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 #ifndef USERVARIABLE_H 0021 #define USERVARIABLE_H 0022 0023 #include <QObject> 0024 #include <KoVariable.h> 0025 #include <KoOdfNumberStyles.h> 0026 0027 class KoShapeSavingContext; 0028 class KoVariableManager; 0029 0030 /** 0031 * This is a KoVariable for user defined variables. 0032 * 0033 * This implements the ODF attributes text:user-field-get and 0034 * text:user-field-input which are fetching variables defined 0035 * via text:user-field-decls and text:user-field-decl. 0036 */ 0037 class UserVariable : public KoVariable 0038 { 0039 Q_OBJECT 0040 public: 0041 UserVariable(); 0042 0043 QWidget* createOptionsWidget() override; 0044 0045 void readProperties(const KoProperties *props); 0046 void propertyChanged(Property property, const QVariant &value) override; 0047 0048 void saveOdf(KoShapeSavingContext &context) override; 0049 bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext & context) override; 0050 0051 KoVariableManager *variableManager(); 0052 0053 int property() const; 0054 0055 const QString& name() const; 0056 void setName(const QString &name); 0057 0058 KoOdfNumberStyles::NumericStyleFormat numberstyle() const; 0059 void setNumberStyle(KoOdfNumberStyles::NumericStyleFormat numberstyle); 0060 0061 private Q_SLOTS: 0062 void valueChanged(); 0063 0064 private: 0065 void resize(const QTextDocument *document, QTextInlineObject &object, int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) override; 0066 0067 KoVariableManager *m_variableManager; 0068 int m_property; 0069 QString m_name; 0070 KoOdfNumberStyles::NumericStyleFormat m_numberstyle; 0071 }; 0072 0073 #endif