| 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 <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> |
| 23 |
#include <basegfx/polygon/b2dpolypolygon.hxx> |
| 24 |
#include <basegfx/matrix/b2dhommatrix.hxx> |
| 25 |
#include <com/sun/star/drawing/XDrawPage.hpp> |
| 26 |
#include <editeng/outlobj.hxx> |
| 27 |
#include <tools/color.hxx> |
| 28 |
#include <sdr/attribute/sdrformtextattribute.hxx> |
| 29 |
#include <svx/sdtaitm.hxx> |
| 30 |
#include <rtl/ref.hxx> |
| 31 |
#include <unotools/weakref.hxx> |
| 32 |
|
| 33 |
|
| 34 |
// predefines |
| 35 |
class SdrText; |
| 36 |
|
| 37 |
|
| 38 |
namespace drawinglayer::primitive2d |
| 39 |
{ |
| 40 |
class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D |
| 41 |
{ |
| 42 |
private: |
| 43 |
// The text model data; this should later just be the OutlinerParaObject or |
| 44 |
// something equal |
| 45 |
::unotools::WeakReference< SdrText > mxSdrText; |
| 46 |
|
| 47 |
// #i97628# |
| 48 |
// The text content; now as local OutlinerParaObject copy (internally RefCounted and |
| 49 |
// COW) and in exclusive, local form as needed in a primitive |
| 50 |
const OutlinerParaObject maOutlinerParaObject; |
| 51 |
|
| 52 |
// remember last VisualizingPage for which a decomposition was made. If the new target |
| 53 |
// is not given or different, the decomposition needs to be potentially removed |
| 54 |
// for supporting e.g. page number change on MasterPage objects or the different |
| 55 |
// field renderings in SubGeometry and MasterPage node |
| 56 |
css::uno::Reference< css::drawing::XDrawPage > mxLastVisualizingPage; |
| 57 |
|
| 58 |
// remember last PageNumber for which a decomposition was made. This is only used |
| 59 |
// when mbContainsPageField is true, else it is 0 |
| 60 |
sal_Int16 mnLastPageNumber; |
| 61 |
|
| 62 |
// remember last PageCount for which a decomposition was made. This is only used |
| 63 |
// when mbContainsPageCountField is true, else it is 0 |
| 64 |
sal_Int16 mnLastPageCount; |
| 65 |
|
| 66 |
// #i101443# remember last TextBackgroundColor to decide if a new decomposition is |
| 67 |
// needed because of background color change |
| 68 |
Color maLastTextBackgroundColor; |
| 69 |
|
| 70 |
// is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction |
| 71 |
bool mbContainsPageField : 1; |
| 72 |
bool mbContainsPageCountField : 1; |
| 73 |
bool mbContainsOtherFields : 1; |
| 74 |
|
| 75 |
protected: |
| 76 |
// support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments |
| 77 |
static Primitive2DReference encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer&& aCandidate); |
| 78 |
|
| 79 |
public: |
| 80 |
SdrTextPrimitive2D( |
| 81 |
const SdrText* pSdrText, |
| 82 |
OutlinerParaObject aOutlinerParaObjectPtr); |
| 83 |
|
| 84 |
// get data |
| 85 |
const SdrText* getSdrText() const; |
| 86 |
const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; } |
| 87 |
|
| 88 |
// compare operator |
| 89 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 90 |
|
| 91 |
// own get2DDecomposition to take aspect of decomposition with or without spell checker |
| 92 |
// into account |
| 93 |
virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; |
| 94 |
|
| 95 |
// transformed clone operator |
| 96 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0; |
| 97 |
}; |
| 98 |
} // end of namespace drawinglayer::primitive2d |
| 99 |
|
| 100 |
|
| 101 |
namespace drawinglayer::primitive2d |
| 102 |
{ |
| 103 |
class SdrContourTextPrimitive2D final : public SdrTextPrimitive2D |
| 104 |
{ |
| 105 |
private: |
| 106 |
// unit contour polygon (scaled to [0.0 .. 1.0]) |
| 107 |
basegfx::B2DPolyPolygon maUnitPolyPolygon; |
| 108 |
|
| 109 |
// complete contour polygon transform (scale, rotate, shear, translate) |
| 110 |
basegfx::B2DHomMatrix maObjectTransform; |
| 111 |
|
| 112 |
// local decomposition. |
| 113 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 114 |
|
| 115 |
public: |
| 116 |
SdrContourTextPrimitive2D( |
| 117 |
const SdrText* pSdrText, |
| 118 |
const OutlinerParaObject& rOutlinerParaObjectPtr, |
| 119 |
basegfx::B2DPolyPolygon aUnitPolyPolygon, |
| 120 |
basegfx::B2DHomMatrix aObjectTransform); |
| 121 |
|
| 122 |
// get data |
| 123 |
const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; } |
| 124 |
const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; } |
| 125 |
|
| 126 |
// compare operator |
| 127 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 128 |
|
| 129 |
// transformed clone operator |
| 130 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override; |
| 131 |
|
| 132 |
// provide unique ID |
| 133 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 134 |
}; |
| 135 |
} // end of namespace drawinglayer::primitive2d |
| 136 |
|
| 137 |
|
| 138 |
namespace drawinglayer::primitive2d |
| 139 |
{ |
| 140 |
class SdrPathTextPrimitive2D final : public SdrTextPrimitive2D |
| 141 |
{ |
| 142 |
private: |
| 143 |
// the path to use. Each paragraph will use one Polygon. |
| 144 |
basegfx::B2DPolyPolygon maPathPolyPolygon; |
| 145 |
|
| 146 |
// the Fontwork parameters |
| 147 |
attribute::SdrFormTextAttribute maSdrFormTextAttribute; |
| 148 |
|
| 149 |
// local decomposition. |
| 150 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 151 |
|
| 152 |
public: |
| 153 |
SdrPathTextPrimitive2D( |
| 154 |
const SdrText* pSdrText, |
| 155 |
const OutlinerParaObject& rOutlinerParaObjectPtr, |
| 156 |
basegfx::B2DPolyPolygon aPathPolyPolygon, |
| 157 |
attribute::SdrFormTextAttribute aSdrFormTextAttribute); |
| 158 |
|
| 159 |
// get data |
| 160 |
const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; } |
| 161 |
const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; } |
| 162 |
|
| 163 |
// compare operator |
| 164 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 165 |
|
| 166 |
// transformed clone operator |
| 167 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override; |
| 168 |
|
| 169 |
// provide unique ID |
| 170 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 171 |
}; |
| 172 |
} // end of namespace drawinglayer::primitive2d |
| 173 |
|
| 174 |
|
| 175 |
namespace drawinglayer::primitive2d |
| 176 |
{ |
| 177 |
class SdrBlockTextPrimitive2D final : public SdrTextPrimitive2D |
| 178 |
{ |
| 179 |
private: |
| 180 |
// text range transformation from unit range ([0.0 .. 1.0]) to text range |
| 181 |
basegfx::B2DHomMatrix maTextRangeTransform; |
| 182 |
|
| 183 |
// text alignments |
| 184 |
SdrTextHorzAdjust maSdrTextHorzAdjust; |
| 185 |
SdrTextVertAdjust maSdrTextVertAdjust; |
| 186 |
|
| 187 |
bool mbFixedCellHeight : 1; |
| 188 |
bool mbUnlimitedPage : 1; // force layout with no text break |
| 189 |
bool mbCellText : 1; // this is a cell text as block text |
| 190 |
bool mbWordWrap : 1; // for CustomShapes text layout |
| 191 |
|
| 192 |
// local decomposition. |
| 193 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 194 |
|
| 195 |
public: |
| 196 |
SdrBlockTextPrimitive2D( |
| 197 |
const SdrText* pSdrText, |
| 198 |
const OutlinerParaObject& rOutlinerParaObjectPtr, |
| 199 |
basegfx::B2DHomMatrix aTextRangeTransform, |
| 200 |
SdrTextHorzAdjust aSdrTextHorzAdjust, |
| 201 |
SdrTextVertAdjust aSdrTextVertAdjust, |
| 202 |
bool bFixedCellHeight, |
| 203 |
bool bUnlimitedPage, |
| 204 |
bool bCellText, |
| 205 |
bool bWordWrap); |
| 206 |
|
| 207 |
// get data |
| 208 |
const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } |
| 209 |
SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; } |
| 210 |
SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; } |
| 211 |
bool isFixedCellHeight() const { return mbFixedCellHeight; } |
| 212 |
bool getUnlimitedPage() const { return mbUnlimitedPage; } |
| 213 |
bool getCellText() const { return mbCellText; } |
| 214 |
bool getWordWrap() const { return mbWordWrap; } |
| 215 |
|
| 216 |
// compare operator |
| 217 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 218 |
|
| 219 |
// transformed clone operator |
| 220 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override; |
| 221 |
|
| 222 |
// provide unique ID |
| 223 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 224 |
}; |
| 225 |
} // end of namespace drawinglayer::primitive2d |
| 226 |
|
| 227 |
|
| 228 |
namespace drawinglayer::primitive2d |
| 229 |
{ |
| 230 |
class SdrStretchTextPrimitive2D final : public SdrTextPrimitive2D |
| 231 |
{ |
| 232 |
private: |
| 233 |
// text range transformation from unit range ([0.0 .. 1.0]) to text range |
| 234 |
basegfx::B2DHomMatrix maTextRangeTransform; |
| 235 |
|
| 236 |
bool mbFixedCellHeight : 1; |
| 237 |
|
| 238 |
// local decomposition. |
| 239 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 240 |
|
| 241 |
public: |
| 242 |
SdrStretchTextPrimitive2D( |
| 243 |
const SdrText* pSdrText, |
| 244 |
const OutlinerParaObject& rOutlinerParaObjectPtr, |
| 245 |
basegfx::B2DHomMatrix aTextRangeTransform, |
| 246 |
bool bFixedCellHeight); |
| 247 |
|
| 248 |
// get data |
| 249 |
const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } |
| 250 |
bool isFixedCellHeight() const { return mbFixedCellHeight; } |
| 251 |
|
| 252 |
// compare operator |
| 253 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 254 |
|
| 255 |
// transformed clone operator |
| 256 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override; |
| 257 |
|
| 258 |
// provide unique ID |
| 259 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 260 |
}; |
| 261 |
} // end of namespace drawinglayer::primitive2d |
| 262 |
|
| 263 |
|
| 264 |
namespace drawinglayer::primitive2d |
| 265 |
{ |
| 266 |
class SdrAutoFitTextPrimitive2D final : public SdrTextPrimitive2D |
| 267 |
{ |
| 268 |
private: |
| 269 |
::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range |
| 270 |
|
| 271 |
bool mbWordWrap : 1; // for CustomShapes text layout |
| 272 |
bool mbFixedCellHeight : 1; |
| 273 |
|
| 274 |
// local decomposition. |
| 275 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 276 |
|
| 277 |
public: |
| 278 |
SdrAutoFitTextPrimitive2D( |
| 279 |
const SdrText* pSdrText, |
| 280 |
const OutlinerParaObject& rOutlinerParaObjectPtr, |
| 281 |
::basegfx::B2DHomMatrix aTextRangeTransform, |
| 282 |
bool bWordWrap, |
| 283 |
bool bFixedCellHeight); |
| 284 |
|
| 285 |
// get data |
| 286 |
const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } |
| 287 |
bool getWordWrap() const { return mbWordWrap; } |
| 288 |
bool isFixedCellHeight() const { return mbFixedCellHeight; } |
| 289 |
|
| 290 |
// compare operator |
| 291 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 292 |
|
| 293 |
// transformed clone operator |
| 294 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const override; |
| 295 |
|
| 296 |
// provide unique ID |
| 297 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 298 |
}; |
| 299 |
} // end of namespace drawinglayer::primitive2d |
| 300 |
|
| 301 |
namespace drawinglayer::primitive2d |
| 302 |
{ |
| 303 |
class SdrChainedTextPrimitive2D final : public SdrTextPrimitive2D |
| 304 |
{ |
| 305 |
private: |
| 306 |
// XXX: might have position of overflowing text |
| 307 |
|
| 308 |
::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range |
| 309 |
|
| 310 |
// local decomposition. |
| 311 |
virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override; |
| 312 |
|
| 313 |
public: |
| 314 |
SdrChainedTextPrimitive2D( |
| 315 |
const SdrText* pSdrText, |
| 316 |
const OutlinerParaObject& rOutlinerParaObjectPtrs, |
| 317 |
::basegfx::B2DHomMatrix aTextRangeTransform); |
| 318 |
|
| 319 |
// get data |
| 320 |
const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } |
| 321 |
//bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation// |
| 322 |
|
| 323 |
// compare operator |
| 324 |
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
| 325 |
|
| 326 |
// transformed clone operator |
| 327 |
virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override; |
| 328 |
|
| 329 |
// provide unique ID |
| 330 |
virtual sal_uInt32 getPrimitive2DID() const override; |
| 331 |
}; |
| 332 |
} // end of namespace drawinglayer::primitive2d |
| 333 |
|
| 334 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |