File indexing completed on 2024-12-08 12:56:11
0001 /* 0002 * Copyright (c) 2010 Carlos Licea <carlos@kdab.com> 0003 * 0004 * This library is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published 0006 * by the Free Software Foundation; either version 2.1 of the License, or 0007 * (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 0012 * GNU Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "KoStyle.h" 0020 0021 #include <KoGenStyles.h> 0022 0023 0024 KoStyle::KoStyle() 0025 : m_autoStyle(false), m_autoStyleInStylesDotXml(false) 0026 { 0027 } 0028 0029 KoStyle::~KoStyle() 0030 { 0031 } 0032 0033 void KoStyle::setName(const QString &name) 0034 { 0035 m_name = name; 0036 } 0037 0038 QString KoStyle::name() const 0039 { 0040 return m_name; 0041 } 0042 0043 void KoStyle::setAutoStyleInStylesDotXml(bool b) 0044 { 0045 m_autoStyleInStylesDotXml = b; 0046 } 0047 0048 bool KoStyle::autoStyleInStylesDotXml() const 0049 { 0050 return m_autoStyleInStylesDotXml; 0051 } 0052 0053 KoGenStyles::InsertionFlags KoStyle::insertionFlags() const 0054 { 0055 if(m_name.isEmpty()) { 0056 return KoGenStyles::NoFlag; 0057 } 0058 else { 0059 return KoGenStyles::DontAddNumberToName | KoGenStyles::AllowDuplicates; 0060 } 0061 } 0062 0063 QString KoStyle::saveOdf(KoGenStyles& styles) const 0064 { 0065 KoGenStyle::Type type; 0066 if(m_name.isEmpty()) { 0067 type = automaticstyleType(); 0068 } 0069 else { 0070 type = styleType(); 0071 } 0072 KoGenStyle style(type, styleFamilyName()); 0073 prepareStyle(style); 0074 style.setAutoStyleInStylesDotXml(m_autoStyleInStylesDotXml); 0075 0076 QString styleName = m_name; 0077 if(styleName.isEmpty()) { 0078 styleName = defaultPrefix(); 0079 } 0080 0081 return styles.insert(style, styleName, insertionFlags()); 0082 }