File indexing completed on 2024-05-12 16:35:03

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Pierre Ducroquet <pinaraf@gmail.com>
0003  * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #include "PageVariableFactory.h"
0022 
0023 #include "PageVariable.h"
0024 #include "VariablesDebug.h"
0025 
0026 #include <KoProperties.h>
0027 #include <KoXmlNS.h>
0028 
0029 #include <klocalizedstring.h>
0030 
0031 PageVariableFactory::PageVariableFactory()
0032     : KoInlineObjectFactoryBase("page", TextVariable)
0033 {
0034     KoInlineObjectTemplate var1;
0035     var1.id = "pagecount";
0036     var1.name = i18n("Page Count");
0037     KoProperties *props = new KoProperties();
0038     props->setProperty("vartype", 1);
0039     var1.properties = props;
0040     addTemplate(var1);
0041 
0042     KoInlineObjectTemplate var2;
0043     var2.id = "pagenumber";
0044     var2.name = i18n("Page Number");
0045     props = new KoProperties();
0046     props->setProperty("vartype", 2);
0047     var2.properties = props;
0048     addTemplate(var2);
0049 
0050     //KoInlineObjectTemplate var3;
0051     //var3.id = "pagecontinuation";
0052     //var3.name = i18n("Page Continuation");
0053     //props = new KoProperties();
0054     //props->setProperty("vartype", 3);
0055     //var3.properties = props;
0056     //addTemplate(var3);
0057 
0058     QStringList elementNames;
0059     elementNames << "page-count" << "page-number" << "page-continuation-string";
0060     setOdfElementNames(KoXmlNS::text, elementNames);
0061 }
0062 
0063 KoInlineObject *PageVariableFactory::createInlineObject(const KoProperties *properties) const
0064 {
0065     PageVariable *var = new PageVariable();
0066     if (properties)
0067         var->readProperties(properties);
0068     return var;
0069 }