Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <canvas/debug.hxx>
22 : #include <tools/diagnose_ex.h>
23 : #include <canvas/verbosetrace.hxx>
24 :
25 : #include <basegfx/matrix/b2dhommatrix.hxx>
26 : #include <basegfx/numeric/ftools.hxx>
27 :
28 : #include "null_textlayout.hxx"
29 : #include "null_spritecanvas.hxx"
30 :
31 :
32 : using namespace ::com::sun::star;
33 :
34 : namespace nullcanvas
35 : {
36 0 : TextLayout::TextLayout( const rendering::StringContext& aText,
37 : sal_Int8 nDirection,
38 : sal_Int64 /*nRandomSeed*/,
39 : const CanvasFont::ImplRef& rFont ) :
40 : TextLayout_Base( m_aMutex ),
41 : maText( aText ),
42 : maLogicalAdvancements(),
43 : mpFont( rFont ),
44 0 : mnTextDirection( nDirection )
45 : {
46 0 : }
47 :
48 0 : TextLayout::~TextLayout()
49 : {
50 0 : }
51 :
52 0 : void SAL_CALL TextLayout::disposing()
53 : {
54 0 : mpFont.reset();
55 0 : }
56 :
57 : // XTextLayout
58 0 : uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException)
59 : {
60 0 : ::osl::MutexGuard aGuard( m_aMutex );
61 :
62 : // TODO
63 0 : return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
64 : }
65 :
66 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
67 : {
68 0 : ::osl::MutexGuard aGuard( m_aMutex );
69 :
70 : // TODO
71 0 : return uno::Sequence< geometry::RealRectangle2D >();
72 : }
73 :
74 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
75 : {
76 0 : ::osl::MutexGuard aGuard( m_aMutex );
77 :
78 : // TODO
79 0 : return uno::Sequence< geometry::RealRectangle2D >();
80 : }
81 :
82 0 : uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException)
83 : {
84 0 : ::osl::MutexGuard aGuard( m_aMutex );
85 :
86 0 : return maLogicalAdvancements;
87 : }
88 :
89 0 : void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException)
90 : {
91 0 : ::osl::MutexGuard aGuard( m_aMutex );
92 :
93 0 : if( aAdvancements.getLength() != maText.Length )
94 : {
95 : OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
96 0 : throw lang::IllegalArgumentException();
97 : }
98 :
99 0 : maLogicalAdvancements = aAdvancements;
100 0 : }
101 :
102 0 : geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException)
103 : {
104 0 : ::osl::MutexGuard aGuard( m_aMutex );
105 :
106 0 : ENSURE_OR_THROW( mpFont.get(),
107 : "TextLayout::queryTextBounds(): invalid font" );
108 :
109 : // fake text bounds by either taking the advancement values,
110 : // or assuming square glyph boxes (width similar to height)
111 0 : const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
112 : const double nFontSize( ::std::max( rFontRequest.CellSize,
113 0 : rFontRequest.ReferenceAdvancement ) );
114 0 : if( maLogicalAdvancements.getLength() )
115 : {
116 : return geometry::RealRectangle2D( 0, -nFontSize/2,
117 0 : maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
118 0 : nFontSize/2 );
119 : }
120 : else
121 : {
122 : return geometry::RealRectangle2D( 0, -nFontSize/2,
123 : nFontSize * maText.Length,
124 0 : nFontSize/2 );
125 0 : }
126 : }
127 :
128 0 : double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
129 : {
130 0 : ::osl::MutexGuard aGuard( m_aMutex );
131 :
132 : // TODO
133 0 : return 0.0;
134 : }
135 :
136 0 : double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
137 : double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
138 : {
139 0 : ::osl::MutexGuard aGuard( m_aMutex );
140 :
141 : // TODO
142 0 : return 0.0;
143 : }
144 :
145 0 : rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException)
146 : {
147 0 : ::osl::MutexGuard aGuard( m_aMutex );
148 :
149 : // TODO
150 0 : return rendering::TextHit();
151 : }
152 :
153 0 : rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
154 : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
155 : {
156 0 : ::osl::MutexGuard aGuard( m_aMutex );
157 :
158 : // TODO
159 0 : return rendering::Caret();
160 : }
161 :
162 0 : sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
163 : sal_Int32 /*nCaretAdvancement*/,
164 : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
165 : {
166 0 : ::osl::MutexGuard aGuard( m_aMutex );
167 :
168 : // TODO
169 0 : return 0;
170 : }
171 :
172 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
173 : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
174 : {
175 0 : ::osl::MutexGuard aGuard( m_aMutex );
176 :
177 : // TODO
178 0 : return uno::Reference< rendering::XPolyPolygon2D >();
179 : }
180 :
181 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
182 : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
183 : {
184 0 : ::osl::MutexGuard aGuard( m_aMutex );
185 :
186 : // TODO
187 0 : return uno::Reference< rendering::XPolyPolygon2D >();
188 : }
189 :
190 0 : double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException)
191 : {
192 0 : ::osl::MutexGuard aGuard( m_aMutex );
193 :
194 : // TODO
195 0 : return 0.0;
196 : }
197 :
198 0 : sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException)
199 : {
200 0 : ::osl::MutexGuard aGuard( m_aMutex );
201 :
202 0 : return mnTextDirection;
203 : }
204 :
205 0 : uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException)
206 : {
207 0 : ::osl::MutexGuard aGuard( m_aMutex );
208 :
209 0 : return mpFont.getRef();
210 : }
211 :
212 0 : rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException)
213 : {
214 0 : ::osl::MutexGuard aGuard( m_aMutex );
215 :
216 0 : return maText;
217 : }
218 :
219 0 : bool TextLayout::draw( const rendering::ViewState& /*rViewState*/,
220 : const rendering::RenderState& /*rRenderState*/,
221 : const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const
222 : {
223 0 : ::osl::MutexGuard aGuard( m_aMutex );
224 :
225 : // TODO
226 :
227 0 : return true;
228 : }
229 :
230 :
231 : #define SERVICE_NAME "com.sun.star.rendering.TextLayout"
232 : #define IMPLEMENTATION_NAME "NullCanvas::TextLayout"
233 :
234 0 : ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException )
235 : {
236 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
237 : }
238 :
239 0 : sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
240 : {
241 0 : return ServiceName == SERVICE_NAME;
242 : }
243 :
244 0 : uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException )
245 : {
246 0 : uno::Sequence< ::rtl::OUString > aRet(1);
247 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
248 :
249 0 : return aRet;
250 : }
251 0 : }
252 :
253 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|