Simplify a bit
[LibreOffice.git] / canvas / source / opengl / ogl_textlayout.cxx
bloba87365275436c0a9bf2bf724fbac19d2af99129b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <sal/config.h>
11 #include <sal/log.hxx>
12 #include <utility>
14 #include <comphelper/diagnose_ex.hxx>
16 #include "ogl_textlayout.hxx"
18 using namespace ::com::sun::star;
20 namespace oglcanvas
22 TextLayout::TextLayout( rendering::StringContext aText,
23 sal_Int8 nDirection,
24 sal_Int64 /*nRandomSeed*/,
25 CanvasFont::ImplRef rFont ) :
26 maText(std::move( aText )),
27 mpFont(std::move( rFont )),
28 mnTextDirection( nDirection )
32 void TextLayout::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
34 mpFont.clear();
37 // XTextLayout
38 uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( )
40 // TODO
41 return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
44 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( )
46 // TODO
47 return uno::Sequence< geometry::RealRectangle2D >();
50 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( )
52 // TODO
53 return uno::Sequence< geometry::RealRectangle2D >();
56 uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( )
58 std::unique_lock aGuard( m_aMutex );
60 return maLogicalAdvancements;
63 void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements )
65 std::unique_lock aGuard( m_aMutex );
67 if( aAdvancements.getLength() != maText.Length )
69 SAL_INFO("canvas.ogl", "TextLayout::applyLogicalAdvancements(): mismatching number of advancements");
70 throw lang::IllegalArgumentException();
73 maLogicalAdvancements = aAdvancements;
76 uno::Sequence< sal_Bool > SAL_CALL TextLayout::queryKashidaPositions( )
78 std::unique_lock aGuard( m_aMutex );
80 return maKashidaPositions;
83 void SAL_CALL TextLayout::applyKashidaPositions( const uno::Sequence< sal_Bool >& aPositions )
85 std::unique_lock aGuard( m_aMutex );
87 if( aPositions.hasElements() && aPositions.getLength() != maText.Length )
89 SAL_WARN("canvas.ogl", "TextLayout::applyKashidaPositions(): mismatching number of positions" );
90 throw lang::IllegalArgumentException("mismatching number of positions", getXWeak(), 1);
93 maKashidaPositions = aPositions;
96 geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( )
98 std::unique_lock aGuard( m_aMutex );
100 ENSURE_OR_THROW( mpFont,
101 "TextLayout::queryTextBounds(): invalid font" );
103 // fake text bounds by either taking the advancement values,
104 // or assuming square glyph boxes (width similar to height)
105 const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
106 const double nFontSize( std::max( rFontRequest.CellSize,
107 rFontRequest.ReferenceAdvancement ) );
108 if( maLogicalAdvancements.hasElements() )
110 return geometry::RealRectangle2D( 0, -nFontSize/2,
111 maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
112 nFontSize/2 );
114 else
116 return geometry::RealRectangle2D( 0, -nFontSize/2,
117 nFontSize * maText.Length,
118 nFontSize/2 );
122 double SAL_CALL TextLayout::justify( double /*nSize*/ )
124 // TODO
125 return 0.0;
128 double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
129 double /*nSize*/ )
131 // TODO
132 return 0.0;
135 rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ )
137 // TODO
138 return rendering::TextHit();
141 rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
142 sal_Bool /*bExcludeLigatures*/ )
144 // TODO
145 return rendering::Caret();
148 sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
149 sal_Int32 /*nCaretAdvancement*/,
150 sal_Bool /*bExcludeLigatures*/ )
152 // TODO
153 return 0;
156 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
157 sal_Int32 /*nEndIndex*/ )
159 // TODO
160 return uno::Reference< rendering::XPolyPolygon2D >();
163 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
164 sal_Int32 /*nEndIndex*/ )
166 // TODO
167 return uno::Reference< rendering::XPolyPolygon2D >();
170 double SAL_CALL TextLayout::getBaselineOffset( )
172 // TODO
173 return 0.0;
176 sal_Int8 SAL_CALL TextLayout::getMainTextDirection( )
178 return mnTextDirection;
181 uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( )
183 std::unique_lock aGuard( m_aMutex );
185 return mpFont;
188 rendering::StringContext SAL_CALL TextLayout::getText( )
190 return maText;
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */