2004-03-18 09:38:44 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* $RCSfile: CanvasFont.java,v $
|
|
|
|
* $Revision: 1.7 $
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* OpenOffice.org 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 Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
2008-04-11 08:21:44 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-03-18 09:38:44 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// UNO
|
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XComponentContext;
|
|
|
|
import com.sun.star.uno.AnyConverter;
|
|
|
|
import com.sun.star.lib.uno.helper.WeakBase;
|
|
|
|
|
|
|
|
// OOo AWT
|
|
|
|
import com.sun.star.awt.*;
|
|
|
|
|
|
|
|
// Canvas
|
2005-03-10 10:52:42 +00:00
|
|
|
import com.sun.star.rendering.*;
|
|
|
|
import com.sun.star.geometry.*;
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
public class CanvasFont
|
|
|
|
extends com.sun.star.lib.uno.helper.ComponentBase
|
|
|
|
implements com.sun.star.lang.XServiceInfo,
|
2005-03-10 10:52:42 +00:00
|
|
|
com.sun.star.rendering.XCanvasFont
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
|
|
|
private CanvasBase associatedCanvas;
|
2005-03-10 10:52:42 +00:00
|
|
|
private com.sun.star.rendering.FontRequest fontRequest;
|
2004-03-18 09:38:44 +00:00
|
|
|
private java.awt.Font font;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
2005-03-10 10:52:42 +00:00
|
|
|
public CanvasFont( com.sun.star.rendering.FontRequest _fontRequest,
|
2004-03-18 09:38:44 +00:00
|
|
|
CanvasBase _canvas )
|
|
|
|
{
|
|
|
|
associatedCanvas = _canvas;
|
|
|
|
fontRequest = _fontRequest;
|
|
|
|
|
|
|
|
// TODO: Use proper attributes here, first of all, use fractional point font size
|
2004-11-26 16:05:43 +00:00
|
|
|
font = new java.awt.Font( fontRequest.FontDescription.FamilyName, java.awt.Font.PLAIN, (int)(fontRequest.CellSize + .5) );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public java.awt.Font getFont()
|
|
|
|
{
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
// XCanvasFont implementation
|
|
|
|
// ===========================
|
|
|
|
//
|
|
|
|
|
2004-11-26 16:05:43 +00:00
|
|
|
public XTextLayout createTextLayout( StringContext aText, byte nDirection, long nRandomSeed )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2004-11-26 16:05:43 +00:00
|
|
|
return new TextLayout( aText, nDirection, nRandomSeed, this, associatedCanvas );
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2004-11-26 16:05:43 +00:00
|
|
|
public FontRequest getFontRequest( )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2004-11-26 16:05:43 +00:00
|
|
|
return fontRequest;
|
2004-03-18 09:38:44 +00:00
|
|
|
}
|
|
|
|
|
2004-11-26 16:05:43 +00:00
|
|
|
public FontMetrics getFontMetrics( )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2004-11-26 16:05:43 +00:00
|
|
|
// TODO
|
2004-03-18 09:38:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2004-11-26 16:05:43 +00:00
|
|
|
public double[] getAvailableSizes( )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2004-11-26 16:05:43 +00:00
|
|
|
// TODO
|
2004-03-18 09:38:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2004-11-26 16:05:43 +00:00
|
|
|
public com.sun.star.beans.PropertyValue[] getExtraFontProperties( )
|
2004-03-18 09:38:44 +00:00
|
|
|
{
|
2004-11-26 16:05:43 +00:00
|
|
|
// TODO
|
2004-03-18 09:38:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
// XServiceInfo impl
|
|
|
|
// =================
|
|
|
|
//
|
|
|
|
|
|
|
|
private static final String s_implName = "CanvasFont.java.impl";
|
2005-03-10 10:52:42 +00:00
|
|
|
private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont";
|
2004-03-18 09:38:44 +00:00
|
|
|
|
|
|
|
public String getImplementationName()
|
|
|
|
{
|
|
|
|
return s_implName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String [] getSupportedServiceNames()
|
|
|
|
{
|
|
|
|
return new String [] { s_serviceName };
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean supportsService( String serviceName )
|
|
|
|
{
|
|
|
|
return serviceName.equals( s_serviceName );
|
|
|
|
}
|
|
|
|
}
|