LibreOffice Module canvas (master)  1
cairo_textlayout.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_TEXTLAYOUT_HXX
21 #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_TEXTLAYOUT_HXX
22 
23 #include <cppuhelper/compbase.hxx>
24 #include <cppuhelper/basemutex.hxx>
25 
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/rendering/RenderState.hpp>
28 #include <com/sun/star/rendering/ViewState.hpp>
29 #include <com/sun/star/rendering/XTextLayout.hpp>
30 
31 #include <vcl/outdev.hxx>
32 
33 #include <vcl/cairo.hxx>
34 #include "cairo_canvasfont.hxx"
35 
36 
37 /* Definition of TextLayout class */
38 
39 namespace cairocanvas
40 {
41  typedef ::cppu::WeakComponentImplHelper< css::rendering::XTextLayout,
42  css::lang::XServiceInfo > TextLayout_Base;
43 
44  class TextLayout : public ::cppu::BaseMutex,
45  public TextLayout_Base
46  {
47  public:
49  TextLayout(const TextLayout&) = delete;
50  const TextLayout& operator=(const TextLayout&) = delete;
51 
52  TextLayout( const css::rendering::StringContext& aText,
53  sal_Int8 nDirection,
54  sal_Int64 nRandomSeed,
55  const CanvasFont::Reference& rFont,
56  const SurfaceProviderRef& rRefDevice );
57 
59  virtual void SAL_CALL disposing() override;
60 
61  // XTextLayout
62  virtual css::uno::Sequence< css::uno::Reference< css::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes( ) override;
63  virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryInkMeasures( ) override;
64  virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures( ) override;
65  virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements( ) override;
66  virtual void SAL_CALL applyLogicalAdvancements( const css::uno::Sequence< double >& aAdvancements ) override;
67  virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds( ) override;
68  virtual double SAL_CALL justify( double nSize ) override;
69  virtual double SAL_CALL combinedJustify( const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > >& aNextLayouts, double nSize ) override;
70  virtual css::rendering::TextHit SAL_CALL getTextHit( const css::geometry::RealPoint2D& aHitPoint ) override;
71  virtual css::rendering::Caret SAL_CALL getCaret( sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures ) override;
72  virtual sal_Int32 SAL_CALL getNextInsertionIndex( sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures ) override;
73  virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryVisualHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
74  virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryLogicalHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
75  virtual double SAL_CALL getBaselineOffset( ) override;
76  virtual sal_Int8 SAL_CALL getMainTextDirection( ) override;
77  virtual css::uno::Reference< css::rendering::XCanvasFont > SAL_CALL getFont( ) override;
78  virtual css::rendering::StringContext SAL_CALL getText( ) override;
79 
80  // XServiceInfo
81  virtual OUString SAL_CALL getImplementationName() override;
82  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
83  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
84 
85  void draw( OutputDevice& rOutDev,
86  const Point& rOutpos,
87  const css::rendering::ViewState& viewState,
88  const css::rendering::RenderState& renderState ) const;
89 
90  void setupTextOffsets( long* outputOffsets,
91  const css::uno::Sequence< double >& inputOffsets,
92  const css::rendering::ViewState& viewState,
93  const css::rendering::RenderState& renderState ) const;
94 
95  protected:
96  virtual ~TextLayout() override; // we're a ref-counted UNO class. _We_ destroy ourselves.
97 
98  private:
99  css::rendering::StringContext maText;
100  css::uno::Sequence< double > maLogicalAdvancements;
104  };
105 
106 }
107 
108 #endif // INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_TEXTLAYOUT_HXX
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int32 SAL_CALL getNextInsertionIndex(sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures) override
virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryVisualHighlighting(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
TextLayout(const TextLayout &)=delete
make noncopyable
signed char sal_Int8
virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds() override
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryInkMeasures() override
virtual css::rendering::Caret SAL_CALL getCaret(sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures) override
virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements() override
virtual sal_Int8 SAL_CALL getMainTextDirection() override
void setupTextOffsets(long *outputOffsets, const css::uno::Sequence< double > &inputOffsets, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) const
virtual double SAL_CALL combinedJustify(const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > > &aNextLayouts, double nSize) override
virtual css::uno::Reference< css::rendering::XCanvasFont > SAL_CALL getFont() override
::cppu::WeakComponentImplHelper< css::rendering::XTextLayout, css::lang::XServiceInfo > TextLayout_Base
css::rendering::StringContext maText
virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryLogicalHighlighting(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures() override
virtual css::rendering::StringContext SAL_CALL getText() override
unsigned char sal_Bool
virtual void SAL_CALL applyLogicalAdvancements(const css::uno::Sequence< double > &aAdvancements) override
virtual css::uno::Sequence< css::uno::Reference< css::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes() override
const TextLayout & operator=(const TextLayout &)=delete
virtual double SAL_CALL getBaselineOffset() override
virtual void SAL_CALL disposing() override
Dispose all internal references.
virtual ~TextLayout() override
SurfaceProviderRef mpRefDevice
virtual double SAL_CALL justify(double nSize) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
CanvasFont::Reference mpFont
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Sequence< double > maLogicalAdvancements
virtual css::rendering::TextHit SAL_CALL getTextHit(const css::geometry::RealPoint2D &aHitPoint) override
void draw(OutputDevice &rOutDev, const Point &rOutpos, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) const