LibreOffice Module canvas (master)  1
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 #pragma once
21 
22 #include <cppuhelper/compbase.hxx>
23 #include <cppuhelper/basemutex.hxx>
24 
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/StringContext.hpp>
27 #include <com/sun/star/rendering/XTextLayout.hpp>
28 
29 #include "canvasfont.hxx"
30 #include "impltools.hxx"
31 
32 
33 /* Definition of TextLayout class */
34 
35 namespace vclcanvas
36 {
37  typedef ::cppu::WeakComponentImplHelper< css::rendering::XTextLayout,
38  css::lang::XServiceInfo > TextLayout_Base;
39 
40  class TextLayout : public ::cppu::BaseMutex,
41  public TextLayout_Base
42  {
43  public:
45  TextLayout(const TextLayout&) = delete;
46  const TextLayout& operator=(const TextLayout&) = delete;
47 
48  TextLayout( const css::rendering::StringContext& aText,
49  sal_Int8 nDirection,
50  const CanvasFont::Reference& rFont,
51  const css::uno::Reference<
52  css::rendering::XGraphicDevice>& xDevice,
53  const OutDevProviderSharedPtr& rOutDev );
54 
56  virtual void SAL_CALL disposing() override;
57 
58  // XTextLayout
59  virtual css::uno::Sequence< css::uno::Reference< css::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes( ) override;
60  virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryInkMeasures( ) override;
61  virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures( ) override;
62  virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements( ) override;
63  virtual void SAL_CALL applyLogicalAdvancements( const css::uno::Sequence< double >& aAdvancements ) override;
64  virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds( ) override;
65  virtual double SAL_CALL justify( double nSize ) override;
66  virtual double SAL_CALL combinedJustify( const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > >& aNextLayouts, double nSize ) override;
67  virtual css::rendering::TextHit SAL_CALL getTextHit( const css::geometry::RealPoint2D& aHitPoint ) override;
68  virtual css::rendering::Caret SAL_CALL getCaret( sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures ) override;
69  virtual sal_Int32 SAL_CALL getNextInsertionIndex( sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures ) override;
70  virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryVisualHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
71  virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryLogicalHighlighting( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
72  virtual double SAL_CALL getBaselineOffset( ) override;
73  virtual sal_Int8 SAL_CALL getMainTextDirection( ) override;
74  virtual css::uno::Reference< css::rendering::XCanvasFont > SAL_CALL getFont( ) override;
75  virtual css::rendering::StringContext SAL_CALL getText( ) override;
76 
77  // XServiceInfo
78  virtual OUString SAL_CALL getImplementationName() override;
79  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
80  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
81 
82  void draw( OutputDevice& rOutDev,
83  const Point& rOutpos,
84  const css::rendering::ViewState& viewState,
85  const css::rendering::RenderState& renderState ) const;
86 
87  private:
88  void setupTextOffsets( ::tools::Long* outputOffsets,
89  const css::uno::Sequence< double >& inputOffsets,
90  const css::rendering::ViewState& viewState,
91  const css::rendering::RenderState& renderState ) const;
92 
93  css::rendering::StringContext maText;
94  css::uno::Sequence< double > maLogicalAdvancements;
96  css::uno::Reference< css::rendering::XGraphicDevice> mxDevice;
99  };
100 
101 }
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
virtual css::uno::Reference< css::rendering::XCanvasFont > SAL_CALL getFont() override
Definition: textlayout.cxx:311
void setupTextOffsets(::tools::Long *outputOffsets, const css::uno::Sequence< double > &inputOffsets, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) const
css::uno::Sequence< double > maLogicalAdvancements
Definition: textlayout.hxx:94
signed char sal_Int8
CanvasFont::Reference mpFont
Definition: textlayout.hxx:95
virtual sal_Int8 SAL_CALL getMainTextDirection() override
Definition: textlayout.cxx:304
long Long
virtual css::uno::Sequence< css::uno::Reference< css::rendering::XPolyPolygon2D > > SAL_CALL queryTextShapes() override
Definition: textlayout.cxx:100
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryMeasures() override
Definition: textlayout.cxx:194
virtual OUString SAL_CALL getImplementationName() override
Definition: textlayout.cxx:411
virtual void SAL_CALL applyLogicalAdvancements(const css::uno::Sequence< double > &aAdvancements) override
virtual double SAL_CALL justify(double nSize) override
Definition: textlayout.cxx:255
virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryVisualHighlighting(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: textlayout.cxx:286
void draw(OutputDevice &rOutDev, const Point &rOutpos, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) const
virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL queryLogicalHighlighting(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: textlayout.cxx:292
::cppu::WeakComponentImplHelper< css::rendering::XTextLayout, css::lang::XServiceInfo > TextLayout_Base
Definition: textlayout.hxx:38
virtual css::rendering::StringContext SAL_CALL getText() override
Definition: textlayout.cxx:318
virtual sal_Int32 SAL_CALL getNextInsertionIndex(sal_Int32 nStartIndex, sal_Int32 nCaretAdvancement, sal_Bool bExcludeLigatures) override
Definition: textlayout.cxx:280
TextLayout(const TextLayout &)=delete
make noncopyable
virtual css::geometry::RealRectangle2D SAL_CALL queryTextBounds() override
Definition: textlayout.cxx:217
css::rendering::StringContext maText
Definition: textlayout.hxx:93
unsigned char sal_Bool
virtual css::uno::Sequence< double > SAL_CALL queryLogicalAdvancements() override
Definition: textlayout.cxx:200
virtual double SAL_CALL combinedJustify(const css::uno::Sequence< css::uno::Reference< css::rendering::XTextLayout > > &aNextLayouts, double nSize) override
virtual css::rendering::Caret SAL_CALL getCaret(sal_Int32 nInsertionIndex, sal_Bool bExcludeLigatures) override
Definition: textlayout.cxx:274
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: textlayout.cxx:421
virtual void SAL_CALL disposing() override
Dispose all internal references.
Definition: textlayout.cxx:90
OutDevProviderSharedPtr mpOutDevProvider
Definition: textlayout.hxx:97
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: textlayout.cxx:416
virtual double SAL_CALL getBaselineOffset() override
Definition: textlayout.cxx:298
css::uno::Reference< css::rendering::XGraphicDevice > mxDevice
Definition: textlayout.hxx:96
const TextLayout & operator=(const TextLayout &)=delete
virtual css::rendering::TextHit SAL_CALL getTextHit(const css::geometry::RealPoint2D &aHitPoint) override
virtual css::uno::Sequence< css::geometry::RealRectangle2D > SAL_CALL queryInkMeasures() override
Definition: textlayout.cxx:147