tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / drawinglayer / source / primitive2d / texthierarchyprimitive2d.cxx
blob73a21e3c572230be3d17bc470f530edffdb3d71b
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/.
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 <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
21 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
24 using namespace com::sun::star;
27 namespace drawinglayer::primitive2d
29 TextHierarchyLinePrimitive2D::TextHierarchyLinePrimitive2D(Primitive2DContainer&& aChildren)
30 : GroupPrimitive2D(std::move(aChildren))
34 // provide unique ID
35 sal_uInt32 TextHierarchyLinePrimitive2D::getPrimitive2DID() const
37 return PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D;
41 TextHierarchyParagraphPrimitive2D::TextHierarchyParagraphPrimitive2D(
42 Primitive2DContainer&& aChildren,
43 sal_Int16 nOutlineLevel)
44 : GroupPrimitive2D(std::move(aChildren)),
45 mnOutlineLevel(nOutlineLevel)
49 bool TextHierarchyParagraphPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
51 if(GroupPrimitive2D::operator==(rPrimitive))
53 const TextHierarchyParagraphPrimitive2D& rCompare = static_cast<const TextHierarchyParagraphPrimitive2D&>(rPrimitive);
55 return (getOutlineLevel() == rCompare.getOutlineLevel());
58 return false;
61 // provide unique ID
62 sal_uInt32 TextHierarchyParagraphPrimitive2D::getPrimitive2DID() const
64 return PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D;
69 TextHierarchyBulletPrimitive2D::TextHierarchyBulletPrimitive2D(Primitive2DContainer&& aChildren)
70 : GroupPrimitive2D(std::move(aChildren))
74 // provide unique ID
75 sal_uInt32 TextHierarchyBulletPrimitive2D::getPrimitive2DID() const
77 return PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D;
81 TextHierarchyBlockPrimitive2D::TextHierarchyBlockPrimitive2D(Primitive2DContainer&& aChildren)
82 : GroupPrimitive2D(std::move(aChildren))
86 // provide unique ID
87 sal_uInt32 TextHierarchyBlockPrimitive2D::getPrimitive2DID() const
89 return PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D;
93 TextHierarchyFieldPrimitive2D::TextHierarchyFieldPrimitive2D(
94 Primitive2DContainer&& aChildren,
95 const FieldType& rFieldType,
96 const std::vector< std::pair< OUString, OUString>>* pNameValue)
97 : GroupPrimitive2D(std::move(aChildren)),
98 meType(rFieldType)
100 if (nullptr != pNameValue)
102 meNameValue = *pNameValue;
106 OUString TextHierarchyFieldPrimitive2D::getValue(const OUString& rName) const
108 for (const std::pair< OUString, OUString >& candidate : meNameValue)
110 if (candidate.first.equals(rName))
112 return candidate.second;
116 return OUString();
119 bool TextHierarchyFieldPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
121 if(GroupPrimitive2D::operator==(rPrimitive))
123 const TextHierarchyFieldPrimitive2D& rCompare = static_cast<const TextHierarchyFieldPrimitive2D&>(rPrimitive);
125 return (getType() == rCompare.getType()
126 && meNameValue == rCompare.meNameValue);
129 return false;
132 // provide unique ID
133 sal_uInt32 TextHierarchyFieldPrimitive2D::getPrimitive2DID() const
135 return PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D;
139 TextHierarchyEditPrimitive2D::TextHierarchyEditPrimitive2D(Primitive2DContainer&& aContent)
140 : GroupPrimitive2D(std::move(aContent))
144 void TextHierarchyEditPrimitive2D::get2DDecomposition(
145 Primitive2DDecompositionVisitor& rVisitor,
146 const geometry::ViewInformation2D& rViewInformation) const
148 // check if TextEdit is active. If not, process. If yes, suppress the content
149 if (!rViewInformation.getTextEditActive())
150 GroupPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
153 // provide unique ID
154 sal_uInt32 TextHierarchyEditPrimitive2D::getPrimitive2DID() const
156 return PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D;
160 TextHierarchyEmphasisMarkPrimitive2D::TextHierarchyEmphasisMarkPrimitive2D(Primitive2DContainer&& aContent)
161 : GroupPrimitive2D(std::move(aContent))
165 // provide unique ID
166 sal_uInt32 TextHierarchyEmphasisMarkPrimitive2D::getPrimitive2DID() const
168 return PRIMITIVE2D_ID_TEXTHIERARCHYEMPHASISMARKPRIMITIVE2D;
171 } // end of namespace
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */