1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
21 #include <sal/log.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/numeric/ftools.hxx>
25 #include <cppuhelper/supportsservice.hxx>
27 #include "dx_bitmap.hxx"
28 #include "dx_spritecanvas.hxx"
29 #include "dx_textlayout.hxx"
30 #include "dx_textlayout_drawhelper.hxx"
32 using namespace ::com::sun::star
;
36 TextLayout::TextLayout( const rendering::StringContext
& aText
,
38 sal_Int64
/*nRandomSeed*/,
39 const CanvasFont::ImplRef
& rFont
) :
40 TextLayout_Base( m_aMutex
),
42 maLogicalAdvancements(),
44 mnTextDirection( nDirection
)
48 TextLayout::~TextLayout()
52 void SAL_CALL
TextLayout::disposing()
58 uno::Sequence
< uno::Reference
< rendering::XPolyPolygon2D
> > SAL_CALL
TextLayout::queryTextShapes( )
61 return uno::Sequence
< uno::Reference
< rendering::XPolyPolygon2D
> >();
64 uno::Sequence
< geometry::RealRectangle2D
> SAL_CALL
TextLayout::queryInkMeasures( )
67 return uno::Sequence
< geometry::RealRectangle2D
>();
70 uno::Sequence
< geometry::RealRectangle2D
> SAL_CALL
TextLayout::queryMeasures( )
73 return uno::Sequence
< geometry::RealRectangle2D
>();
76 uno::Sequence
< double > SAL_CALL
TextLayout::queryLogicalAdvancements( )
78 ::osl::MutexGuard
aGuard( m_aMutex
);
80 return maLogicalAdvancements
;
83 void SAL_CALL
TextLayout::applyLogicalAdvancements( const uno::Sequence
< double >& aAdvancements
)
85 ::osl::MutexGuard
aGuard( m_aMutex
);
87 if( aAdvancements
.getLength() != maText
.Length
)
89 SAL_WARN("canvas.directx", "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
90 throw lang::IllegalArgumentException();
93 maLogicalAdvancements
= aAdvancements
;
96 uno::Sequence
< sal_Bool
> SAL_CALL
TextLayout::queryKashidaPositions( )
98 ::osl::MutexGuard
aGuard( m_aMutex
);
100 return maKashidaPositions
;
103 void SAL_CALL
TextLayout::applyKashidaPositions( const uno::Sequence
< sal_Bool
>& aPositions
)
105 ::osl::MutexGuard
aGuard( m_aMutex
);
107 if( aPositions
.hasElements() && aPositions
.getLength() != maText
.Length
)
109 SAL_WARN("canvas.directx", "TextLayout::applyKashidaPositions(): mismatching number of positions" );
110 throw lang::IllegalArgumentException("mismatching number of positions", getXWeak(), 1);
113 maKashidaPositions
= aPositions
;
116 geometry::RealRectangle2D SAL_CALL
TextLayout::queryTextBounds( )
118 ::osl::MutexGuard
aGuard( m_aMutex
);
120 uno::Reference
< rendering::XGraphicDevice
> xGraphicDevice
;
121 ::dxcanvas::TextLayoutDrawHelper
aDrawHelper(xGraphicDevice
);
124 const geometry::RealRectangle2D
aBounds(
125 aDrawHelper
.queryTextBounds(
127 maLogicalAdvancements
,
129 mpFont
->getFontMatrix()));
134 double SAL_CALL
TextLayout::justify( double /*nSize*/ )
140 double SAL_CALL
TextLayout::combinedJustify( const uno::Sequence
< uno::Reference
< rendering::XTextLayout
> >& /*aNextLayouts*/,
147 rendering::TextHit SAL_CALL
TextLayout::getTextHit( const geometry::RealPoint2D
& /*aHitPoint*/ )
150 return rendering::TextHit();
153 rendering::Caret SAL_CALL
TextLayout::getCaret( sal_Int32
/*nInsertionIndex*/,
154 sal_Bool
/*bExcludeLigatures*/ )
157 return rendering::Caret();
160 sal_Int32 SAL_CALL
TextLayout::getNextInsertionIndex( sal_Int32
/*nStartIndex*/,
161 sal_Int32
/*nCaretAdvancement*/,
162 sal_Bool
/*bExcludeLigatures*/ )
168 uno::Reference
< rendering::XPolyPolygon2D
> SAL_CALL
TextLayout::queryVisualHighlighting( sal_Int32
/*nStartIndex*/,
169 sal_Int32
/*nEndIndex*/ )
172 return uno::Reference
< rendering::XPolyPolygon2D
>();
175 uno::Reference
< rendering::XPolyPolygon2D
> SAL_CALL
TextLayout::queryLogicalHighlighting( sal_Int32
/*nStartIndex*/,
176 sal_Int32
/*nEndIndex*/ )
179 return uno::Reference
< rendering::XPolyPolygon2D
>();
182 double SAL_CALL
TextLayout::getBaselineOffset( )
188 sal_Int8 SAL_CALL
TextLayout::getMainTextDirection( )
190 ::osl::MutexGuard
aGuard( m_aMutex
);
192 return mnTextDirection
;
195 uno::Reference
< rendering::XCanvasFont
> SAL_CALL
TextLayout::getFont( )
197 ::osl::MutexGuard
aGuard( m_aMutex
);
202 rendering::StringContext SAL_CALL
TextLayout::getText( )
204 ::osl::MutexGuard
aGuard( m_aMutex
);
209 bool TextLayout::draw( const GraphicsSharedPtr
& rGraphics
,
210 const rendering::ViewState
& rViewState
,
211 const rendering::RenderState
& rRenderState
,
212 const ::basegfx::B2ISize
& rOutputOffset
,
213 const uno::Reference
< rendering::XGraphicDevice
>& xGraphicDevice
,
214 bool bAlphaSurface
) const
216 ::osl::MutexGuard
aGuard( m_aMutex
);
218 ::dxcanvas::TextLayoutDrawHelper
aDrawHelper(xGraphicDevice
);
221 aDrawHelper
.drawText(
227 maLogicalAdvancements
,
230 mpFont
->getFontMatrix(),
232 mnTextDirection
!= 0);
237 OUString SAL_CALL
TextLayout::getImplementationName()
239 return "DXCanvas::TextLayout";
242 sal_Bool SAL_CALL
TextLayout::supportsService( const OUString
& ServiceName
)
244 return cppu::supportsService( this, ServiceName
);
247 uno::Sequence
< OUString
> SAL_CALL
TextLayout::getSupportedServiceNames()
249 return { "com.sun.star.rendering.TextLayout" };
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */