~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to lib/kformula/cmstyle.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
   You should have received a copy of the GNU Library General Public License
15
15
   along with this library; see the file COPYING.LIB.  If not, write to
16
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
   Boston, MA 02111-1307, USA.
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
18
18
*/
19
19
 
20
20
#include <qpainter.h>
21
21
#include <qpen.h>
 
22
#include <qapplication.h>
22
23
 
23
24
#include <kdebug.h>
24
25
#include <klocale.h>
 
26
#include <kstandarddirs.h>
 
27
#include <kio/netaccess.h>
 
28
#include <kio/job.h>
 
29
#include <kmessagebox.h>
25
30
 
26
31
#include "kformuladefs.h"
27
32
#include "cmstyle.h"
31
36
 
32
37
#include "cmmapping.cc"
33
38
 
34
 
bool CMStyle::init( ContextStyle* context )
 
39
bool CMStyle::m_installed = false;
 
40
 
 
41
bool CMStyle::init( ContextStyle* context, bool install )
35
42
{
 
43
    if (!m_installed && install)
 
44
        installFonts();
36
45
    SymbolTable* st = symbolTable();
37
46
    st->init( context );
38
47
 
62
71
    return new CMArtwork( type );
63
72
}
64
73
 
65
 
QStringList CMStyle::missingFonts()
 
74
QStringList CMStyle::missingFonts( bool install )
 
75
{
 
76
    if (!m_installed && install)
 
77
        installFonts();
 
78
 
 
79
    QStringList missing = missingFontsInternal();
 
80
    return missing;
 
81
}
 
82
 
 
83
QStringList CMStyle::missingFontsInternal()
66
84
{
67
85
    QStringList missing;
68
86
 
77
95
    return missing;
78
96
}
79
97
 
 
98
void CMStyle::installFonts()
 
99
{
 
100
    if (m_installed)
 
101
        return;
 
102
    QStringList missing = missingFontsInternal();
 
103
    if (!missing.isEmpty())
 
104
    {
 
105
        QStringList urlList;
 
106
        for (QStringList::iterator it = missing.begin(); it != missing.end(); ++it)
 
107
        {
 
108
            if (!KIO::NetAccess::exists("fonts:/Personal/" + *it + ".ttf", true, NULL))
 
109
                urlList.append(locate("data", "kformula/fonts/" + *it + ".ttf"));
 
110
        }
 
111
        KIO::copy(urlList, "fonts:/Personal/", false);
 
112
        KMessageBox::information(qApp->mainWidget(), 
 
113
                                 i18n("Some fonts have been installed to assure that symbols in formulas are properly visualized. You must restart the application in order so that changes take effect"));
 
114
    }
 
115
    m_installed = true;
 
116
}
80
117
 
81
118
CMAlphaTable::CMAlphaTable()
82
119
{
342
379
    luPt mySize = style.getAdjustedSize( tstyle );
343
380
    luPixel myX = parentOrigin.x() + getX();
344
381
    luPixel myY = parentOrigin.y() + getY();
 
382
    /*
345
383
    if ( !LuPixelRect( myX, myY, getWidth(), getHeight() ).intersects( r ) )
346
384
        return;
 
385
    */
347
386
 
348
387
    painter.setPen(style.getDefaultColor());
349
388
 
359
398
}
360
399
 
361
400
 
362
 
void CMArtwork::draw(QPainter& painter, const LuPixelRect& r,
 
401
void CMArtwork::draw(QPainter& painter, const LuPixelRect& /*r*/,
363
402
                     const ContextStyle& style, ContextStyle::TextStyle tstyle,
364
403
                     luPt /*parentSize*/, const LuPixelPoint& origin)
365
404
{
366
405
    luPt mySize = style.getAdjustedSize( tstyle );
367
406
    luPixel myX = origin.x() + getX();
368
407
    luPixel myY = origin.y() + getY();
 
408
    /*
369
409
    if ( !LuPixelRect( myX, myY, getWidth(), getHeight() ).intersects( r ) )
370
410
        return;
 
411
    */
371
412
 
372
413
    painter.setPen(style.getDefaultColor());
373
414