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 "InfoVariableFactory.h"
0022 
0023 #include "VariablesDebug.h"
0024 #include "InfoVariable.h"
0025 
0026 #include <KoProperties.h>
0027 #include <KoXmlNS.h>
0028 #include <klocalizedstring.h>
0029 
0030 #include <QStringList>
0031 
0032 
0033 InfoVariableFactory::InfoVariableFactory()
0034         : KoInlineObjectFactoryBase("info", TextVariable)
0035 {
0036     KoInlineObjectTemplate var1;
0037     var1.id = "author";
0038     var1.name = i18n("Author Name");
0039     KoProperties *props = new KoProperties();
0040     props->setProperty("vartype", KoInlineObject::AuthorName);
0041     var1.properties = props;
0042     addTemplate(var1);
0043 
0044     KoInlineObjectTemplate var2;
0045     var2.id = "title";
0046     var2.name = i18n("Title");
0047     props = new KoProperties();
0048     props->setProperty("vartype", KoInlineObject::Title);
0049     var2.properties = props;
0050     addTemplate(var2);
0051 
0052     KoInlineObjectTemplate var3;
0053     var3.id = "subject";
0054     var3.name = i18n("Subject");
0055     props = new KoProperties();
0056     props->setProperty("vartype", KoInlineObject::Subject);
0057     var3.properties = props;
0058     addTemplate(var3);
0059 
0060     KoInlineObjectTemplate var4;
0061     var4.id = "file-name";
0062     var4.name = i18n("File Name");
0063     props = new KoProperties();
0064     props->setProperty("vartype", KoInlineObject::DocumentURL);
0065     var4.properties = props;
0066     addTemplate(var4);
0067 
0068     KoInlineObjectTemplate var5;
0069     var5.id = "keywords";
0070     var5.name = i18n("Keywords");
0071     props = new KoProperties();
0072     props->setProperty("vartype", KoInlineObject::Keywords);
0073     var5.properties = props;
0074     addTemplate(var5);
0075 
0076     KoInlineObjectTemplate var6;
0077     var6.id = "comments";
0078     var6.name = i18n("Comments");
0079     props = new KoProperties();
0080     props->setProperty("vartype", KoInlineObject::Comments);
0081     var6.properties = props;
0082     addTemplate(var6);
0083 
0084     QStringList elementNames(InfoVariable::tags());
0085     setOdfElementNames(KoXmlNS::text, elementNames);
0086 }
0087 
0088 KoInlineObject *InfoVariableFactory::createInlineObject(const KoProperties *properties) const
0089 {
0090     InfoVariable *var = new InfoVariable();
0091     if (properties)
0092         var->readProperties(properties);
0093     return var;
0094 }