home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoOasisLoadingContext.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  4.4 KB  |  123 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 2005 David Faure <faure@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18.  
  19. #ifndef KOOASISLOADINGCONTEXT_H
  20. #define KOOASISLOADINGCONTEXT_H
  21.  
  22. class KoXmlWriter;
  23. class QDomElement;
  24. class KoDocument;
  25. class KoOasisStyles;
  26. class KoPictureCollection;
  27. class KoStore;
  28.  
  29. #include <qmap.h>
  30. #include <koffice_export.h>
  31. #include <qstringlist.h>
  32. #include <KoStyleStack.h>
  33.  
  34. /**
  35.  * Used during loading of Oasis format (and discarded at the end of the loading).
  36.  *
  37.  * @author David Faure <faure@kde.org>
  38.  */
  39. class KOFFICECORE_EXPORT KoOasisLoadingContext
  40. {
  41. public:
  42.     /**
  43.      * Stores reference to the KoOasisStyles and stored passed by KoDocument.
  44.      * Make sure that the KoOasisStyles instance outlives this KoOasisLoadingContext instance.
  45.      * (This is the case during loading, when using the KoOasisStyles given by KoDocument)
  46.      *
  47.      * @param doc the KoDocument being loaded
  48.      * @param styles reference to the KoOasisStyles parsed by KoDocument
  49.      * @param store pointer to store, if available, for e.g. loading images.
  50.      */
  51.     KoOasisLoadingContext( KoDocument* doc, KoOasisStyles& styles, KoStore* store );
  52.     ~KoOasisLoadingContext();
  53.  
  54.     KoDocument* koDocument() { return m_doc; }
  55.     KoStore* store() { return m_store; }
  56.  
  57.     KoOasisStyles& oasisStyles() { return m_styles; }
  58.     KoStyleStack& styleStack() { return m_styleStack; }
  59.  
  60.     const QDomDocument& manifestDocument() const { return m_manifestDoc; }
  61.  
  62.     /// Return the <meta:generator> of the document, e.g. "KOffice/1.4.0a"
  63.     QString generator() const;
  64.  
  65.     /**
  66.      * Convenience method for loading the style of an object
  67.      * before loading that object.
  68.      *
  69.      * Read attribute (nsURI,attrName) from the given dom element,
  70.      * treat that attribute as a style name, and load that style
  71.      * including all its parent styles.
  72.      * @param element the dom element to read the attribute from
  73.      * @param nsURI the namespace URI of the attribute to read
  74.      * @param attrName the name of the attribute to read
  75.      * @param family the style family used for this object
  76.      */
  77.     void fillStyleStack( const QDomElement& element, const char* nsURI, const char* attrName, const char* family );
  78.  
  79.     /**
  80.      * Add @p style to the stack, as well as all its parent styles
  81.      * and the default style for this style family.
  82.      *
  83.      * @param style the dom element containing the style to add to the stack
  84.      * @param family the family to use when looking up parent styles
  85.      * @param usingStylesAutoStyles if true, the parent styles are looked up
  86.      *   in the automatic styles from styles.xml, instead of looking up
  87.      *   in the automatic styles from content.xml as we usually do.
  88.      *   This is useful for loading headers and footers for instance.
  89.      *   See setUseStylesAutoStyles(), which makes fillStyleStack() set this bool.
  90.      *
  91.      * Usually you would call fillStyleStack() instead.
  92.      */
  93.     void addStyles( const QDomElement* style, const char* family, bool usingStylesAutoStyles = false );
  94.  
  95.     /// Set to true while loading headers and footers, to remember to use auto styles
  96.     /// from styles.xml
  97.     void setUseStylesAutoStyles( bool useStylesAutoStyles ) { m_useStylesAutoStyles = useStylesAutoStyles; }
  98.     //bool useStylesAutoStyles() const { return m_useStylesAutoStyles; }
  99.  
  100. private:
  101.     void parseMeta() const;
  102.  
  103. private:
  104.     KoDocument* m_doc;
  105.     KoStore* m_store;
  106.     KoOasisStyles& m_styles;
  107.     KoStyleStack m_styleStack;
  108.  
  109.     mutable QString m_generator;
  110.     mutable bool m_metaXmlParsed;
  111.     bool m_useStylesAutoStyles;
  112.     bool m_unused1; // padding, can be used later
  113.     bool m_unused2; // padding, can be used later
  114.  
  115.     QDomDocument m_manifestDoc;
  116.  
  117.     class Private;
  118.     Private *d;
  119. };
  120.  
  121. #endif /* KOOASISLOADINGCONTEXT_H */
  122.  
  123.