summaryrefslogtreecommitdiffstats
path: root/lib/kotext/KoOasisContext.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /lib/kotext/KoOasisContext.cpp
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kotext/KoOasisContext.cpp')
-rw-r--r--lib/kotext/KoOasisContext.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/lib/kotext/KoOasisContext.cpp b/lib/kotext/KoOasisContext.cpp
new file mode 100644
index 00000000..87f4be66
--- /dev/null
+++ b/lib/kotext/KoOasisContext.cpp
@@ -0,0 +1,135 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004-2006 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "KoOasisContext.h"
+#include <KoOasisStyles.h>
+#include <KoOasisStore.h>
+#include <KoXmlNS.h>
+#include <KoXmlWriter.h>
+#include <kdebug.h>
+#include <KoDom.h>
+
+KoOasisContext::KoOasisContext( KoDocument* doc, KoVariableCollection& varColl,
+ KoOasisStyles& styles, KoStore* store )
+ : KoOasisLoadingContext( doc, styles, store ),
+ m_varColl( varColl ),
+ m_cursorTextParagraph( 0 )
+{
+}
+
+static QDomElement findListLevelStyle( const QDomElement& fullListStyle, int level )
+{
+ for ( QDomNode n = fullListStyle.firstChild(); !n.isNull(); n = n.nextSibling() )
+ {
+ const QDomElement listLevelItem = n.toElement();
+ if ( listLevelItem.attributeNS( KoXmlNS::text, "level", QString::null ).toInt() == level )
+ return listLevelItem;
+ }
+ return QDomElement();
+}
+
+bool KoOasisContext::pushListLevelStyle( const QString& listStyleName, int level )
+{
+ QDomElement* fullListStyle = oasisStyles().listStyles()[listStyleName];
+ if ( !fullListStyle ) {
+ kdWarning(32500) << "List style " << listStyleName << " not found!" << endl;
+ return false;
+ }
+ else
+ return pushListLevelStyle( listStyleName, *fullListStyle, level );
+}
+
+bool KoOasisContext::pushOutlineListLevelStyle( int level )
+{
+ QDomElement outlineStyle = KoDom::namedItemNS( oasisStyles().officeStyle(), KoXmlNS::text, "outline-style" );
+ return pushListLevelStyle( "<outline-style>", outlineStyle, level );
+}
+
+bool KoOasisContext::pushListLevelStyle( const QString& listStyleName, // for debug only
+ const QDomElement& fullListStyle, int level )
+{
+ // Find applicable list-level-style for level
+ int i = level;
+ QDomElement listLevelStyle;
+ while ( i > 0 && listLevelStyle.isNull() ) {
+ listLevelStyle = findListLevelStyle( fullListStyle, i );
+ --i;
+ }
+ if ( listLevelStyle.isNull() ) {
+ kdWarning(32500) << "List level style for level " << level << " in list style " << listStyleName << " not found!" << endl;
+ return false;
+ }
+ //kdDebug(32500) << "Pushing list-level-style from list-style " << listStyleName << " level " << level << endl;
+ m_listStyleStack.push( listLevelStyle );
+ return true;
+}
+
+void KoOasisContext::setCursorPosition( KoTextParag* cursorTextParagraph,
+ int cursorTextIndex )
+{
+ m_cursorTextParagraph = cursorTextParagraph;
+ m_cursorTextIndex = cursorTextIndex;
+}
+
+KoOasisContext::~KoOasisContext()
+{
+}
+
+////
+
+KoSavingContext::KoSavingContext( KoGenStyles& mainStyles, KoVariableSettings* settings, bool hasColumns, SavingMode savingMode )
+ : m_mainStyles( mainStyles ),
+ m_savingMode( savingMode ),
+ m_cursorTextParagraph( 0 ),
+ m_variableSettings( settings ),
+ m_hasColumns( hasColumns )
+{
+}
+
+
+KoSavingContext::~KoSavingContext()
+{
+}
+
+void KoSavingContext::setCursorPosition( KoTextParag* cursorTextParagraph,
+ int cursorTextIndex )
+{
+ m_cursorTextParagraph = cursorTextParagraph;
+ m_cursorTextIndex = cursorTextIndex;
+}
+
+void KoSavingContext::addFontFace( const QString& fontName )
+{
+ m_fontFaces[fontName] = true;
+}
+
+void KoSavingContext::writeFontFaces( KoXmlWriter& writer )
+{
+ writer.startElement( "office:font-face-decls" );
+ const QStringList fontFaces = m_fontFaces.keys();
+ for ( QStringList::const_iterator ffit = fontFaces.begin(), ffend = fontFaces.end() ; ffit != ffend ; ++ffit ) {
+ writer.startElement( "style:font-face" );
+ writer.addAttribute( "style:name", *ffit );
+ writer.addAttribute( "svg:font-family", *ffit );
+ // TODO style:font-family-generic
+ // TODO style:font-pitch
+ writer.endElement(); // style:font-face
+ }
+ writer.endElement(); // office:font-face-decls
+}