summaryrefslogtreecommitdiff
path: root/canvas/source/vcl/canvasfont.cxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2004-11-26 16:11:39 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2004-11-26 16:11:39 +0000
commitd71df5c1bdc478aec948995697ae5d98731731d1 (patch)
tree9519e71dff9c59878c7b40c4c31e14b2a160bebc /canvas/source/vcl/canvasfont.cxx
parent277434aa158bef97ea63ff92dc73b770c418f292 (diff)
INTEGRATION: CWS presentationengine01 (1.2.2); FILE MERGED
2004/11/17 17:00:29 thb 1.2.2.12: #118514# Canvas module reorg 2004/08/02 17:50:59 thb 1.2.2.11: #110496# Adapted to recent XCanvas API changes, streamlined and factored out common code with directxcanvas 2004/07/20 19:23:55 thb 1.2.2.10: #110496# Removed self-references to various interface implementations, along the lines, factored out common base implementation for all c++ canvases 2004/07/09 11:51:52 hdu 1.2.2.9: #116716# fix typo 2004/07/09 11:48:42 hdu 1.2.2.8: #116716# more text effects and text lines 2004/07/09 11:48:31 hdu 1.2.2.7: #116716# more text effects and text lines 2004/07/09 09:53:29 hdu 1.2.2.6: #116716# more text effects and text lines 2004/06/17 10:33:26 thb 1.2.2.5: #110496# Handle huge shrinks correctly for font scaling; added some more debug code 2004/05/27 20:51:24 thb 1.2.2.4: #110496# Added classification code to all TODO/HACK/FIXME comments. There are four categories: - code quality (C) - performance (P) - missing functionality (F) - and missing/incomplete error handling (E) Furthermore, every category has a severity number between 1 and 3 associated, where 1 is lowest and 3 highest severity 2004/05/10 09:36:02 hdu 1.2.2.3: #116716# improve text handling for VCL canvas 2004/04/12 15:12:25 thb 1.2.2.2: #110496# Adaptions after canvas01 merge 2004/04/05 15:57:58 thb 1.2.2.1: Resync with canvas01 changes
Diffstat (limited to 'canvas/source/vcl/canvasfont.cxx')
-rw-r--r--canvas/source/vcl/canvasfont.cxx133
1 files changed, 80 insertions, 53 deletions
diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx
index 3f4d88efcd2b..1a998a99e0a4 100644
--- a/canvas/source/vcl/canvasfont.cxx
+++ b/canvas/source/vcl/canvasfont.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: canvasfont.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: thb $ $Date: 2004-03-18 10:38:40 $
+ * last change: $Author: rt $ $Date: 2004-11-26 17:11:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,92 +59,119 @@
*
************************************************************************/
-#include "canvasfont.hxx"
-#include "spritecanvas.hxx"
+#include <canvas/debug.hxx>
+
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+#ifndef _BGFX_NUMERIC_FTOOLS_HXX
+#include <basegfx/numeric/ftools.hxx>
+#endif
-#ifndef _DRAFTS_COM_SUN_STAR_RENDERING_XSPRITECANVAS_HPP_
-#include <drafts/com/sun/star/rendering/XSpriteCanvas.hpp>
+#ifndef _SV_METRIC_HXX
+#include <vcl/metric.hxx>
#endif
+#include "outdevprovider.hxx"
+#include "canvasfont.hxx"
+#include "textlayout.hxx"
+
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star;
+
namespace vclcanvas
{
- CanvasFont::CanvasFont( const rendering::FontRequest& rFontRequest,
- const OutDevProvider::ImplRef& rCanvas ) :
- maFont( Font( rFontRequest.FamilyName, rFontRequest.StyleName, ::Size( 0,
- static_cast<long>(rFontRequest.CellSize + .5)) ) ),
+ CanvasFont::CanvasFont( const rendering::FontRequest& rFontRequest,
+ const uno::Sequence< beans::PropertyValue >& rExtraFontProperties,
+ const geometry::Matrix2D& rFontMatrix,
+ const OutDevProviderSharedPtr& rDevice ) :
+ CanvasFont_Base( m_aMutex ),
+ maFont( Font( rFontRequest.FontDescription.FamilyName,
+ rFontRequest.FontDescription.StyleName,
+ Size( 0, ::basegfx::fround(rFontRequest.CellSize) ) ) ),
maFontRequest( rFontRequest ),
- mpCanvas( rCanvas )
+ mpRefDevice( rDevice )
{
+ CHECK_AND_THROW( mpRefDevice.get(),
+ "CanvasFont::CanvasFont(): Invalid ref device" );
+
maFont->SetAlign( ALIGN_BASELINE );
- maFont->SetHeight( static_cast<long>(rFontRequest.CellSize + .5) );
+ maFont->SetCharSet( (rFontRequest.FontDescription.IsSymbolFont==com::sun::star::util::TriState_YES) ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE );
+ maFont->SetVertical( (rFontRequest.FontDescription.IsVertical==com::sun::star::util::TriState_YES) ? TRUE : FALSE );
+
+ // TODO(F2): improve panose->vclenum conversion
+ maFont->SetWeight( static_cast<FontWeight>(rFontRequest.FontDescription.FontDescription.Weight) );
+ maFont->SetItalic( (rFontRequest.FontDescription.FontDescription.Letterform<=8) ? ITALIC_NONE : ITALIC_NORMAL );
+
+ // adjust to stretched font
+ if( !::rtl::math::approxEqual( rFontMatrix.m00, rFontMatrix.m11) )
+ {
+ const OutputDevice& rOutDev( mpRefDevice->getOutDev() );
+ const Size aSize = rOutDev.GetFontMetric( *maFont ).GetSize();
+
+ const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 );
+ double fStretch = (rFontMatrix.m00 + rFontMatrix.m01);
+
+ if( !::basegfx::fTools::equalZero( fDividend) )
+ fStretch /= fDividend;
+
+ const long nNewWidth = ::basegfx::fround( aSize.Width() * fStretch );
+
+ maFont->SetWidth( nNewWidth );
+ }
}
CanvasFont::~CanvasFont()
{
}
- uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL CanvasFont::queryTextShapes( const rendering::StringContext& text,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 direction ) throw (uno::RuntimeException)
+ void SAL_CALL CanvasFont::disposing()
{
- // TODO
- return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
- }
+ tools::LocalGuard aGuard;
- uno::Sequence< geometry::RealRectangle2D > SAL_CALL CanvasFont::queryTightMeasures( const rendering::StringContext& text,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 direction ) throw (uno::RuntimeException)
- {
- // TODO
- return uno::Sequence< geometry::RealRectangle2D >();
+ mpRefDevice.reset();
}
- uno::Sequence< geometry::RealRectangle2D > SAL_CALL CanvasFont::queryTextMeasures( const rendering::StringContext& text,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 direction ) throw (uno::RuntimeException)
+ uno::Reference< rendering::XTextLayout > SAL_CALL CanvasFont::createTextLayout( const rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) throw (uno::RuntimeException)
{
- // TODO
- return uno::Sequence< geometry::RealRectangle2D >();
- }
+ tools::LocalGuard aGuard;
- uno::Sequence< double > SAL_CALL CanvasFont::queryTextOffsets( const rendering::StringContext& text,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 direction ) throw (uno::RuntimeException)
- {
- // TODO
- return uno::Sequence< double >();
- }
+ if( !mpRefDevice.get() )
+ return uno::Reference< rendering::XTextLayout >(); // we're disposed
- geometry::RealRectangle2D SAL_CALL CanvasFont::queryTextBounds( const rendering::StringContext& text,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState,
- sal_Int8 direction ) throw (uno::RuntimeException)
- {
- // TODO
- return geometry::RealRectangle2D();
+ return new TextLayout( aText, nDirection, nRandomSeed, ImplRef( this ), mpRefDevice );
}
- rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( ) throw (uno::RuntimeException)
+ rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( ) throw (uno::RuntimeException)
{
+ tools::LocalGuard aGuard;
+
return maFontRequest;
}
- rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( ) throw (uno::RuntimeException)
+ rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( ) throw (uno::RuntimeException)
{
+ tools::LocalGuard aGuard;
+
+ // TODO(F1)
return rendering::FontMetrics();
}
- uno::Reference< rendering::XCanvas > SAL_CALL CanvasFont::getAssociatedCanvas( ) throw (uno::RuntimeException)
+ uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( ) throw (uno::RuntimeException)
{
- return uno::Reference< rendering::XCanvas >( mpCanvas.getRef(),
- uno::UNO_QUERY );
+ tools::LocalGuard aGuard;
+
+ // TODO(F1)
+ return uno::Sequence< double >();
+ }
+
+ uno::Sequence< beans::PropertyValue > SAL_CALL CanvasFont::getExtraFontProperties( ) throw (uno::RuntimeException)
+ {
+ tools::LocalGuard aGuard;
+
+ // TODO(F1)
+ return uno::Sequence< beans::PropertyValue >();
}
#define SERVICE_NAME "drafts.com.sun.star.rendering.CanvasFont"