• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

documentRenderer.cpp

Go to the documentation of this file.
00001 //
00002 // Class: documentRenderer
00003 //
00004 // Abstract Widget for displaying document types
00005 // Needs to be implemented from the actual parts
00006 // using kviewshell 
00007 // Part of KViewshell - A generic interface for document viewers.
00008 //
00009 // (C) 2004-2005 Wilfried Huss, Stefan Kebekus. Distributed under the GPL.
00010 
00011 #include <config.h>
00012 
00013 #include <kdebug.h>
00014 
00015 #include "documentRenderer.h"
00016 #include "renderedDocumentPage.h"
00017 
00018 
00019 DocumentRenderer::DocumentRenderer(QWidget* par)
00020   : mutex(true), parentWidget(par), accessibilityBackground(false),
00021     accessibilityBackgroundColor(QColor(255,255,255))
00022 {
00023   numPages = 0;
00024   _isModified = false;
00025 }
00026 
00027 
00028 DocumentRenderer::~DocumentRenderer()
00029 {
00030   // Wait for all access to this DocumentRenderer to finish
00031   QMutexLocker lock(&mutex);
00032   
00033   clear();
00034 }
00035 
00036 
00037 void DocumentRenderer::clear()
00038 {
00039   // Wait for all access to this DocumentRenderer to finish
00040   QMutexLocker lock(&mutex);
00041 
00042   numPages = 0;
00043   pageSizes.clear();
00044   anchorList.clear();
00045   bookmarks.clear();
00046   _isModified = false;
00047 }
00048 
00049 void DocumentRenderer::setAccessibleBackground(bool accessibleMode, const QColor& background)
00050 {
00051   // Wait for all access to this DocumentRenderer to finish
00052   QMutexLocker lock(&mutex);
00053   
00054   accessibilityBackground = accessibleMode;
00055   accessibilityBackgroundColor = background;
00056 }
00057 
00058 SimplePageSize DocumentRenderer::sizeOfPage(const PageNumber& page)
00059 {
00060   // Wait for all access to this DocumentRenderer to finish
00061   QMutexLocker locker(&mutex);
00062   
00063   if (!page.isValid())
00064     return SimplePageSize();
00065   if (page > totalPages()) 
00066     return SimplePageSize();
00067   if (page > pageSizes.size())
00068     return SimplePageSize();
00069   
00070   return pageSizes[page-1];
00071 }
00072 
00073 
00074 void DocumentRenderer::drawThumbnail(double resolution, RenderedDocumentPage* page)
00075 {
00076   // Wait for all access to this DocumentRenderer to finish
00077   QMutexLocker locker(&mutex);
00078 
00079   drawPage(resolution, page);
00080 }
00081 
00082 void DocumentRenderer::getText(RenderedDocumentPage* page)
00083 {
00084   // We are only interrested in the textual data, so we can use a dummy value for the resolution.
00085   drawPage(100.0, page);
00086 }
00087 
00088 bool DocumentRenderer::isValidFile(const QString&) const
00089 {
00090   return true;
00091 }
00092 
00093 
00094 Anchor DocumentRenderer::parseReference(const QString &reference)
00095 {
00096   // Wait for all access to this documentRenderer to finish
00097   QMutexLocker locker(&mutex);
00098 
00099   if (isEmpty())
00100     return Anchor();
00101 
00102   // If the reference is a number, which we'll interpret as a
00103   // page number.
00104   bool ok;
00105   int page = reference.toInt(&ok);
00106   if (ok == true)
00107   {
00108     if (page < 1)
00109       page = 1;
00110     if (page > totalPages())
00111       page = totalPages();
00112 
00113     return Anchor(page, Length());
00114   }
00115 
00116   // If the reference is not a number, return an empty anchor.
00117   return Anchor();
00118 }
00119 
00120 Anchor DocumentRenderer::findAnchor(const QString &locallink)
00121 {
00122   // Wait for all access to this DocumentRenderer to finish
00123   QMutexLocker locker(&mutex);
00124 
00125   QMap<QString,Anchor>::Iterator it = anchorList.find(locallink);
00126   if (it != anchorList.end()) 
00127     return *it;
00128   else 
00129     return Anchor();
00130 }
00131 
00132 
00133 #include "documentRenderer.moc"

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal