Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / ImplLayoutArgs.hxx
blobfaf170ca72b37897756123410dd24024d9831b18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
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 <i18nlangtag/languagetag.hxx>
21 #include <vcl/outdev.hxx>
23 #include "impglyphitem.hxx"
24 #include "ImplLayoutRuns.hxx"
26 namespace vcl::text
28 class VCL_DLLPUBLIC ImplLayoutArgs
30 public:
31 // string related inputs
32 LanguageTag maLanguageTag;
33 SalLayoutFlags mnFlags;
34 const OUString& mrStr;
35 int mnMinCharPos;
36 int mnEndCharPos;
38 // performance hack
39 vcl::text::TextLayoutCache const* m_pTextLayoutCache;
41 // positioning related inputs
42 const double* mpDXArray; // in floating point pixel units
43 const sal_Bool* mpKashidaArray;
44 double mnLayoutWidth; // in pixel units
45 Degree10 mnOrientation; // in 0-3600 system
47 // data for bidi and glyph+script fallback
48 ImplLayoutRuns maRuns;
49 ImplLayoutRuns maFallbackRuns;
51 ImplLayoutArgs(OUString const& rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags,
52 LanguageTag aLanguageTag, vcl::text::TextLayoutCache const* pLayoutCache);
54 void SetLayoutWidth(double nWidth);
55 void SetDXArray(const double* pDXArray);
56 void SetKashidaArray(const sal_Bool* pKashidaArray);
57 void SetOrientation(Degree10 nOrientation);
59 void ResetPos();
60 bool GetNextPos(int* nCharPos, bool* bRTL);
61 bool GetNextRun(int* nMinRunPos, int* nEndRunPos, bool* bRTL);
62 void AddFallbackRun(int nMinRunPos, int nEndRunPos, bool bRTL);
63 bool HasDXArray() const { return mpDXArray; }
65 // methods used by BiDi and glyph fallback
66 bool HasFallbackRun() const;
67 bool PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl);
69 private:
70 void AddRun(int nMinCharPos, int nEndCharPos, bool bRTL);
74 // For nice SAL_INFO logging of ImplLayoutArgs values
75 std::ostream& operator<<(std::ostream& s, vcl::text::ImplLayoutArgs const& rArgs);
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */