diff options
Diffstat (limited to 'include/drawinglayer/primitive2d')
67 files changed, 6588 insertions, 0 deletions
diff --git a/include/drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx b/include/drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx new file mode 100644 index 0000000000..a1cfee3879 --- /dev/null +++ b/include/drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + +namespace drawinglayer::primitive2d +{ +/** BufferedDecompositionGroupPrimitive2D class + + Baseclass for all C++ implementations which are derived from GroupPrimitive2D + which want to buffer the decomposition result + + For discussion please refer to BufferedDecompositionPrimitive2D, this is the same + but for GroupPrimitive2D which want to buffer their decomposition + */ +class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionGroupPrimitive2D : public GroupPrimitive2D +{ +private: + /// a sequence used for buffering the last create2DDecomposition() result + Primitive2DContainer maBuffered2DDecomposition; + +protected: + /// identical to BufferedDecompositionPrimitive2D, see there please + const Primitive2DContainer& getBuffered2DDecomposition() const + { + return maBuffered2DDecomposition; + } + void setBuffered2DDecomposition(Primitive2DContainer&& rNew) + { + maBuffered2DDecomposition = std::move(rNew); + } + + /// method which is to be used to implement the local decomposition of a 2D group primitive. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const = 0; + +public: + /// constructor/destructor. For GroupPrimitive2D we need the child parameter, too. + BufferedDecompositionGroupPrimitive2D(Primitive2DContainer&& aChildren); + + /// identical to BufferedDecompositionPrimitive2D, see there please + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx b/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx new file mode 100644 index 0000000000..8087a6544d --- /dev/null +++ b/include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> + +namespace drawinglayer::geometry +{ +class ViewInformation2D; +} + +namespace drawinglayer::primitive2d +{ +/** BufferedDecompositionPrimitive2D class + + Baseclass for all C++ implementations of css::graphic::XPrimitive2D + which want to buffer the decomposition result + + Buffering the decomposition is the most-used buffering and is thus used my most + primitive implementations which support a decomposition as base class. + + The buffering is done by holding the last decomposition in the local parameter + maBuffered2DDecomposition. The default implementation of get2DDecomposition checks + if maBuffered2DDecomposition is empty. If yes, it uses create2DDecomposition + to create the content. In all cases, maBuffered2DDecomposition is returned. + + For view-dependent primitives derived from Primitive2DBufferDecomposition more needs + to be done when the decomposition depends on parts of the parameter ViewInformation2D. + This defines a standard method for processing these: + + Implement a view-dependent get2DDecomposition doing the following steps: + (a) Locally extract needed parameters from ViewInformation2D to new, local parameters + (this may be a complete local copy of ViewInformation2D) + (b) If a buffered decomposition exists, ckeck if one of the new local parameters + differs from the corresponding locally remembered (as member) ones. If yes, + clear maBuffered2DDecomposition + (d) call baseclass::get2DDecomposition which will use create2DDecomposition + to fill maBuffered2DDecomposition if it's empty + (e) copy the new local parameters to the corresponding locally remembered ones + to identify if a new decomposition is needed at the next call + (f) return maBuffered2DDecomposition + */ +class DRAWINGLAYERCORE_DLLPUBLIC BufferedDecompositionPrimitive2D : public BasePrimitive2D +{ +private: + /// a sequence used for buffering the last create2DDecomposition() result + Primitive2DContainer maBuffered2DDecomposition; + + /// When a shadow wraps a list of primitives, this primitive wants to influence the transparency + /// of the shadow. + sal_uInt16 mnTransparenceForShadow = 0; + +protected: + /** access methods to maBuffered2DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive2DContainer& getBuffered2DDecomposition() const + { + return maBuffered2DDecomposition; + } + void setBuffered2DDecomposition(Primitive2DContainer&& rNew) + { + maBuffered2DDecomposition = std::move(rNew); + } + + /** method which is to be used to implement the local decomposition of a 2D primitive. */ + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const = 0; + +public: + // constructor/destructor + BufferedDecompositionPrimitive2D(); + + /** The getDecomposition default implementation will on demand use create2DDecomposition() if + maBuffered2DDecomposition is empty. It will set maBuffered2DDecomposition to this obtained decomposition + to buffer it. If the decomposition is also ViewInformation2D-dependent, this method needs to be + overridden and the ViewInformation2D for the last decomposition need to be remembered, too, and + be used in the next call to decide if the buffered decomposition may be reused or not. + */ + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + void setTransparenceForShadow(sal_uInt16 nTransparenceForShadow) + { + mnTransparenceForShadow = nTransparenceForShadow; + } + + sal_uInt16 getTransparenceForShadow() const { return mnTransparenceForShadow; } +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/CommonTypes.hxx b/include/drawinglayer/primitive2d/CommonTypes.hxx new file mode 100644 index 0000000000..3e14b05daa --- /dev/null +++ b/include/drawinglayer/primitive2d/CommonTypes.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <rtl/ref.hxx> + +namespace drawinglayer::primitive2d +{ +class BasePrimitive2D; +typedef rtl::Reference<BasePrimitive2D> Primitive2DReference; +typedef css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>> Primitive2DSequence; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx new file mode 100644 index 0000000000..0bb67c3d0c --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonColorPrimitive2D class + + This primitive defines a tools::PolyPolygon filled with a single color. + This is one of the non-decomposable primitives, so a renderer + should process it. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonColorPrimitive2D final : public BasePrimitive2D +{ +private: + /// the tools::PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the polygon fill color + basegfx::BColor maBColor; + +public: + /// constructor + PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +/** FilledRectanglePrimitive2D class + + Tooling: This primitive defines a simple rectangle. It is + sometimes useful for simpler tasks and decomposes to a + more generalized PolyPolygonColorPrimitive2D (see above) +*/ +class DRAWINGLAYER_DLLPUBLIC FilledRectanglePrimitive2D final : public BasePrimitive2D +{ +private: + /// the geometry + basegfx::B2DRange maB2DRange; + + /// the fill color + basegfx::BColor maBColor; + +public: + /// constructor + FilledRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange, const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DRange& getB2DRange() const { return maB2DRange; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// return as PolyPolygonColorPrimitive2D + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonGradientPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonGradientPrimitive2D.hxx new file mode 100644 index 0000000000..6009c5b238 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonGradientPrimitive2D.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonColorPrimitive2D class + + This primitive defines a tools::PolyPolygon filled with a gradient. The + decomosition will create a MaskPrimitive2D containing a + FillGradientPrimitive2D. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonGradientPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the tools::PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the definition range + basegfx::B2DRange maDefinitionRange; + + /// the gradient definition + attribute::FillGradientAttribute maFillGradient; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructors. The one without definition range will use output range as definition range + PolyPolygonGradientPrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, + attribute::FillGradientAttribute rFillGradient); + PolyPolygonGradientPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::B2DRange& rDefinitionRange, + attribute::FillGradientAttribute aFillGradient); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx new file mode 100644 index 0000000000..e6c9c0f753 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonGraphicPrimitive2D class + + This primitive defines a tools::PolyPolygon filled with bitmap data + (including transparence). The decomosition will create a MaskPrimitive2D + containing a FillGraphicPrimitive2D. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonGraphicPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the tools::PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the definition range + basegfx::B2DRange maDefinitionRange; + + /// the bitmap fill definition (may include tiling) + attribute::FillGraphicAttribute maFillGraphic; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + PolyPolygonGraphicPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::B2DRange& rDefinitionRange, + const attribute::FillGraphicAttribute& rFillGraphic); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonHairlinePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonHairlinePrimitive2D.hxx new file mode 100644 index 0000000000..7cb2fbb73d --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonHairlinePrimitive2D.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonHairlinePrimitive2D class + + This primitive defines a multi-PolygonHairlinePrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonHairlinePrimitive2Ds. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonHairlinePrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the hairline geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the hairline color + basegfx::BColor maBColor; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolyPolygonHairlinePrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx new file mode 100644 index 0000000000..8fb9514c72 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonHatchPrimitive2D class + + This primitive defines a tools::PolyPolygon filled with a hatch. The + decomosition will create a MaskPrimitive2D containing a + FillHatchPrimitive2D. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonHatchPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the tools::PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the definition range + basegfx::B2DRange maDefinitionRange; + + /// the hatch background color (if used) + basegfx::BColor maBackgroundColor; + + /// the hatch definition + attribute::FillHatchAttribute maFillHatch; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructors. The one without definition range will use output range as definition range + PolyPolygonHatchPrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rBackgroundColor, + attribute::FillHatchAttribute aFillHatch); + PolyPolygonHatchPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rBackgroundColor, + attribute::FillHatchAttribute aFillHatch); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; } + const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx new file mode 100644 index 0000000000..dcf29ba9e4 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +// PolyPolygonMarkerPrimitive2D class + +/** PolyPolygonMarkerPrimitive2D class + + This primitive defines a multi-PolygonMarkerPrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonMarkerPrimitive2Ds. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonMarkerPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the marker hairline geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the two colors + basegfx::BColor maRGBColorA; + basegfx::BColor maRGBColorB; + + /// the dash distance in 'pixels' + double mfDiscreteDashLength; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolyPolygonMarkerPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, double fDiscreteDashLength); + + // data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } + const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx new file mode 100644 index 0000000000..15366abf87 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonSelectionPrimitive2D class + + This primitive defines a tools::PolyPolygon which gets filled with a defined color + and a defined transparence, but also gets extended ('grown') by the given + discrete size (thus being a view-dependent primitive) + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonSelectionPrimitive2D final + : public DiscreteMetricDependentPrimitive2D +{ +private: + /// the tools::PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the color + basegfx::BColor maColor; + + /// the transparence [0.0 .. 1.0] + double mfTransparence; + + /// the discrete grow size ('pixels'), only positive values allowed + double mfDiscreteGrow; + + /// draw polygons filled when fill is set + bool mbFill : 1; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolyPolygonSelectionPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const basegfx::BColor& rColor, double fTransparence, + double fDiscreteGrow, bool bFill); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getColor() const { return maColor; } + double getTransparence() const { return mfTransparence; } + double getDiscreteGrow() const { return mfDiscreteGrow; } + bool getFill() const { return mbFill; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx new file mode 100644 index 0000000000..f7cadeb944 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolyPolygonStrokePrimitive2D class + + This primitive defines a multi-PolygonStrokePrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonStrokePrimitive2Ds. + */ +class DRAWINGLAYER_DLLPUBLIC PolyPolygonStrokePrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the line geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the line attributes like width, join and color + attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) + attribute::StrokeAttribute maStrokeAttribute; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolyPolygonStrokePrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const attribute::LineAttribute& rLineAttribute, + attribute::StrokeAttribute aStrokeAttribute); + + PolyPolygonStrokePrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, + const attribute::LineAttribute& rLineAttribute); + + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } + const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx new file mode 100644 index 0000000000..bcee8a5ec0 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolygonHairlinePrimitive2D class + + This primitive defines a Hairline. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + This is one of the non-decomposable primitives, so a renderer + should process it. + */ +class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive2D final : public BasePrimitive2D +{ +private: + /// the hairline geometry + basegfx::B2DPolygon maPolygon; + + /// the hairline color + basegfx::BColor maBColor; + +public: + /// constructor + PolygonHairlinePrimitive2D(basegfx::B2DPolygon aPolygon, const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +/** SingleLinePrimitive2D class + + This primitive defines a simple line, just two points. It is + sometimes useful for simpler tasks and decomposes to a + PolygonHairlinePrimitive2D (see above). It is also a + hairline-primitive, see above. +*/ +class DRAWINGLAYER_DLLPUBLIC SingleLinePrimitive2D final : public BasePrimitive2D +{ +private: + /// the line geometry + basegfx::B2DPoint maStart; + basegfx::B2DPoint maEnd; + + /// the line color + basegfx::BColor maBColor; + +public: + /// constructor + SingleLinePrimitive2D(const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd, + const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DPoint& getStart() const { return maStart; } + const basegfx::B2DPoint& getEnd() const { return maEnd; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// return as PolygonHairlinePrimitive2D + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +/** LineRectanglePrimitive2D class + + Tooling: This primitive defines a simple rectangle. It is + sometimes useful for simpler tasks and decomposes to a + more generalized PolygonHairlinePrimitive2D (see above) +*/ +class DRAWINGLAYER_DLLPUBLIC LineRectanglePrimitive2D final : public BasePrimitive2D +{ +private: + /// the geometry + basegfx::B2DRange maB2DRange; + + /// the line color + basegfx::BColor maBColor; + +public: + /// constructor + LineRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange, const basegfx::BColor& rBColor); + + /// data read access + const basegfx::B2DRange& getB2DRange() const { return maB2DRange; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// return as PolygonHairlinePrimitive2D + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolygonMarkerPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonMarkerPrimitive2D.hxx new file mode 100644 index 0000000000..d2087b608c --- /dev/null +++ b/include/drawinglayer/primitive2d/PolygonMarkerPrimitive2D.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/color/bcolor.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolygonMarkerPrimitive2D class + + This primitive defines a two-colored marker hairline which is + dashed with the given dash length. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + It will be decomposed to the needed PolygonHairlinePrimitive2D if + not handled directly by a renderer. + */ +class DRAWINGLAYER_DLLPUBLIC PolygonMarkerPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the marker hairline geometry + basegfx::B2DPolygon maPolygon; + + /// the two colors + basegfx::BColor maRGBColorA; + basegfx::BColor maRGBColorB; + + /// the dash distance in 'pixels' + double mfDiscreteDashLength; + + /// decomposition is view-dependent, remember last InverseObjectToViewTransformation + basegfx::B2DHomMatrix maLastInverseObjectToViewTransformation; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolygonMarkerPrimitive2D(basegfx::B2DPolygon aPolygon, const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, double fDiscreteDashLength); + + /// data read access + const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } + const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } + const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx new file mode 100644 index 0000000000..2577ffdfbe --- /dev/null +++ b/include/drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx> +#include <drawinglayer/attribute/linestartendattribute.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolygonStrokeArrowPrimitive2D class + + This primitive defines a PolygonStrokePrimitive2D, + possibly extended by start and end definitions, which are + normally used for arrows. + */ +class DRAWINGLAYER_DLLPUBLIC PolygonStrokeArrowPrimitive2D final : public PolygonStrokePrimitive2D +{ +private: + /// geometric definitions for line start and end + attribute::LineStartEndAttribute maStart; + attribute::LineStartEndAttribute maEnd; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolygonStrokeArrowPrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute, + const attribute::LineStartEndAttribute& rStart, + const attribute::LineStartEndAttribute& rEnd); + + /// constructor without stroking + PolygonStrokeArrowPrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + const attribute::LineStartEndAttribute& rStart, + const attribute::LineStartEndAttribute& rEnd); + + /// data read access + const attribute::LineStartEndAttribute& getStart() const { return maStart; } + const attribute::LineStartEndAttribute& getEnd() const { return maEnd; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx new file mode 100644 index 0000000000..351af896d6 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolygonStrokePrimitive2D class + + This primitive defines a line with line width, line join, line color + and stroke attributes. It will be decomposed dependent on the definition + to the needed primitives, e.g. filled PolyPolygons for fat lines. + */ +class DRAWINGLAYER_DLLPUBLIC PolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D +{ +private: + /// the line geometry + basegfx::B2DPolygon maPolygon; + + /// the line attributes like width, join and color + attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) + attribute::StrokeAttribute maStrokeAttribute; + + /// the buffered result of PolygonStrokePrimitive2D::getB2DRange + mutable basegfx::B2DRange maBufferedRange; + +protected: + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolygonStrokePrimitive2D(basegfx::B2DPolygon aPolygon, + const attribute::LineAttribute& rLineAttribute, + attribute::StrokeAttribute aStrokeAttribute); + + /// constructor without stroking + PolygonStrokePrimitive2D(basegfx::B2DPolygon aPolygon, + const attribute::LineAttribute& rLineAttribute); + + /// data read access + const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } + const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } + const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/PolygonWavePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonWavePrimitive2D.hxx new file mode 100644 index 0000000000..72d875a5e4 --- /dev/null +++ b/include/drawinglayer/primitive2d/PolygonWavePrimitive2D.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx> + +namespace drawinglayer::primitive2d +{ +/** PolygonWavePrimitive2D class + + This primitive defines a waveline based on a PolygonStrokePrimitive2D + where the wave is defined by wave width and wave length. + */ +class PolygonWavePrimitive2D final : public PolygonStrokePrimitive2D +{ +private: + /// wave definition + double mfWaveWidth; + double mfWaveHeight; + + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, + const attribute::StrokeAttribute& rStrokeAttribute, double fWaveWidth, + double fWaveHeight); + + /// constructor without stroking + PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon, + const attribute::LineAttribute& rLineAttribute, double fWaveWidth, + double fWaveHeight); + + /// data read access + double getWaveWidth() const { return mfWaveWidth; } + double getWaveHeight() const { return mfWaveHeight; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace primitive2d::drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/Primitive2DContainer.hxx b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx new file mode 100644 index 0000000000..2368ea45ce --- /dev/null +++ b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/CommonTypes.hxx> +#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx> + +#include <basegfx/range/b2drange.hxx> +#include <deque> + +namespace drawinglayer::geometry +{ +class ViewInformation2D; +} + +namespace drawinglayer::primitive2d +{ +class SAL_WARN_UNUSED DRAWINGLAYERCORE_DLLPUBLIC Primitive2DContainer final + : public std::deque<Primitive2DReference>, + public Primitive2DDecompositionVisitor +{ +public: + // use zero because we allocate a lot of empty containers + explicit Primitive2DContainer() + : deque(0) + { + } + explicit Primitive2DContainer(size_type count) + : deque(count) + { + } + virtual ~Primitive2DContainer() override; + Primitive2DContainer(const Primitive2DContainer& other) + : deque(other) + { + } + Primitive2DContainer(Primitive2DContainer&& other) noexcept + : deque(std::move(other)) + { + } + Primitive2DContainer(std::initializer_list<Primitive2DReference> init) + : deque(init) + { + } + Primitive2DContainer( + const css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>>&); + Primitive2DContainer(const std::deque<css::uno::Reference<css::graphic::XPrimitive2D>>&); + + virtual void visit(const Primitive2DReference& rSource) override { append(rSource); } + virtual void visit(const Primitive2DContainer& rSource) override { append(rSource); } + virtual void visit(Primitive2DContainer&& rSource) override { append(std::move(rSource)); } + + void append(const Primitive2DReference&); + void append(const Primitive2DContainer& rSource); + void append(Primitive2DContainer&& rSource); + Primitive2DContainer& operator=(const Primitive2DContainer& r) + { + deque::operator=(r); + return *this; + } + Primitive2DContainer& operator=(Primitive2DContainer&& r) noexcept + { + deque::operator=(std::move(r)); + return *this; + } + bool operator==(const Primitive2DContainer& rB) const; + bool operator!=(const Primitive2DContainer& rB) const { return !operator==(rB); } + basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& aViewInformation) const; + Primitive2DContainer maybeInvert(bool bInvert = false); + + css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>> toSequence() const; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx b/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx new file mode 100644 index 0000000000..559a82c664 --- /dev/null +++ b/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/CommonTypes.hxx> + +namespace drawinglayer::primitive2d +{ +class Primitive2DContainer; + +// Visitor class for walking a tree of Primitive2DReference +class DRAWINGLAYERCORE_DLLPUBLIC Primitive2DDecompositionVisitor +{ +public: + virtual void visit(const Primitive2DReference&) = 0; + virtual void visit(const Primitive2DContainer&) = 0; + virtual void visit(Primitive2DContainer&&) = 0; + virtual ~Primitive2DDecompositionVisitor() {} +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/Tools.hxx b/include/drawinglayer/primitive2d/Tools.hxx new file mode 100644 index 0000000000..dd3e714a76 --- /dev/null +++ b/include/drawinglayer/primitive2d/Tools.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/CommonTypes.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> +#include <basegfx/range/b2drange.hxx> + +namespace drawinglayer::primitive2d +{ +/// get B2DRange from a given Primitive2DReference +basegfx::B2DRange DRAWINGLAYERCORE_DLLPUBLIC getB2DRangeFromPrimitive2DReference( + const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation); + +/** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ +bool DRAWINGLAYERCORE_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA, + const Primitive2DReference& rB); + +/** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ +bool DRAWINGLAYERCORE_DLLPUBLIC +arePrimitive2DReferencesEqual(const css::uno::Reference<css::graphic::XPrimitive2D>& rA, + const css::uno::Reference<css::graphic::XPrimitive2D>& rB); + +OUString DRAWINGLAYERCORE_DLLPUBLIC idToString(sal_uInt32 nId); + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/animatedprimitive2d.hxx b/include/drawinglayer/primitive2d/animatedprimitive2d.hxx new file mode 100644 index 0000000000..61ff4d33ef --- /dev/null +++ b/include/drawinglayer/primitive2d/animatedprimitive2d.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <memory> + +// predefines +namespace drawinglayer::animation +{ +class AnimationEntry; +} + +namespace basegfx +{ +class B2DHomMatrix; +} + +namespace drawinglayer::primitive2d +{ +/** AnimatedSwitchPrimitive2D class + + This is the basic class for simple, animated primitives. The basic idea + is to have an animation definition (AnimationEntry) who's basic + functionality is to return a state value for any given animation time in + the range of [0.0 .. 1.0]. Depending on the state, the decomposition + calculates an index, which of the members of the child vector is to + be visualized. + + An example: For blinking, the Child vector should exist of two entries; + for values of [0.0 .. 0.5] the first, else the last entry will be used. + This mechanism is not limited to two entries, though. + */ +class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D : public GroupPrimitive2D +{ +private: + /** + The animation definition which allows translation of a point in time + to an animation state [0.0 .. 1.0]. This member contains a cloned + definition and is owned by this implementation. + */ + std::unique_ptr<animation::AnimationEntry> mpAnimationEntry; + + /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate + between both types if they are on/off + */ + bool mbIsTextAnimation : 1; + +protected: + /** write access right for classes deriving from this who want to do special + things (e.g. optimization, buffering). + Caution: This is an exception from the read-only, non-modifiable paradigm + for primitives, so special preparations may be needed. Usually should + only be used for initialization (e.g. in a derived constructor) + */ + void setAnimationEntry(const animation::AnimationEntry& rNew); + +public: + /// constructor + AnimatedSwitchPrimitive2D(const animation::AnimationEntry& rAnimationEntry, + Primitive2DContainer&& aChildren, bool bIsTextAnimation); + + /// destructor - needed due to mpAnimationEntry + virtual ~AnimatedSwitchPrimitive2D() override; + + /// data read access + const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; } + bool isTextAnimation() const { return mbIsTextAnimation; } + bool isGraphicAnimation() const { return !isTextAnimation(); } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /** Override getDecomposition() here since the decompose + depends on the point in time, so the default implementation is + not useful here, it needs to be handled locally + */ + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +/** AnimatedBlinkPrimitive2D class + + Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the + decomposition is specialized in delivering the children in the + range [0.0.. 0.5] and an empty sequence else + */ +class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D final : public AnimatedSwitchPrimitive2D +{ +public: + /// constructor + AnimatedBlinkPrimitive2D(const animation::AnimationEntry& rAnimationEntry, + Primitive2DContainer&& aChildren); + + /// create local decomposition + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +/** AnimatedInterpolatePrimitive2D class + + Specialized on multi-step animations based on matrix transformations. The + Child sequence will be embedded in a matrix transformation. That transformation + will be linearly combined from the decomposed values and the animation value + to allow a smooth animation. + */ +class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D final : public AnimatedSwitchPrimitive2D +{ +private: + /// the transformations + std::vector<basegfx::utils::B2DHomMatrixBufferedDecompose> maMatrixStack; + +public: + /// constructor + AnimatedInterpolatePrimitive2D(const std::vector<basegfx::B2DHomMatrix>& rmMatrixStack, + const animation::AnimationEntry& rAnimationEntry, + Primitive2DContainer&& aChildren); + + /// create local decomposition + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx b/include/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx new file mode 100644 index 0000000000..191fde1b84 --- /dev/null +++ b/include/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/color/bcolor.hxx> + +// BackgroundColorPrimitive2D class + +namespace drawinglayer::primitive2d +{ +/** BackgroundColorPrimitive2D class + + This primitive is defined to fill the whole visible Viewport with + the given color (and thus decomposes to a filled polygon). This + makes it a view-dependent primitive by definition. It only has + a valid decomposition if a valid Viewport is given in the + ViewInformation2D at decomposition time. + + It will try to buffer its last decomposition using maLastViewport + to detect changes in the get2DDecomposition call. + */ +class DRAWINGLAYER_DLLPUBLIC BackgroundColorPrimitive2D final + : public BufferedDecompositionPrimitive2D +{ +private: + /// the fill color to use + basegfx::BColor maBColor; + double mfTransparency; + + /// the last used viewInformation, used from getDecomposition for buffering + basegfx::B2DRange maLastViewport; + + /// create local decomposition + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + explicit BackgroundColorPrimitive2D(const basegfx::BColor& rBColor, double fTransparency = 0); + + /// data read access + const basegfx::BColor& getBColor() const { return maBColor; } + double getTransparency() const { return mfTransparency; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get B2Drange + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition call to be view-dependent here + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx new file mode 100644 index 0000000000..4d6d6250a5 --- /dev/null +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> + +#include <com/sun/star/util/XAccounting.hpp> +#include <basegfx/range/b2drange.hxx> +#include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <comphelper/compbase.hxx> +#include <salhelper/simplereferenceobject.hxx> +#include <rtl/ref.hxx> +#include <deque> +#include <utility> + +namespace drawinglayer::geometry +{ +class ViewInformation2D; +} + +typedef comphelper::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting> + BasePrimitive2DImplBase; + +namespace drawinglayer::primitive2d +{ +/** BasePrimitive2D class + + Baseclass for all C++ implementations of css::graphic::XPrimitive2D + + This class is strongly virtual due to the lack of getPrimitiveID() implementation. + This is by purpose, this base class shall not be incarnated and be used directly as + a XPrimitive2D. + + It is noncopyable to make clear that a primitive is a read-only + instance and copying or changing values is not intended. The idea is to hold all data + needed for visualisation of this primitive in unchangeable form. + + It is derived from cppu::BaseMutex to have a Mutex at hand; in a base + implementation this may not be needed, but e.g. when buffering at last decomposition + in a local member, multiple threads may try to decompose at the same time, so locking + is needed to avoid race conditions seen from the UNO object implementation. + + A method to get a simplified representation is provided by get2DDecomposition. The + default implementation returns an empty sequence. The idea is that processors + using this primitive and do not know it, may get the decomposition and process + these instead. An example is e.g. a fat line, who's decomposition may contain + the geometric representation of that line using filled polygon primitives. When + the renderer knows how to handle fat lines, he may process this primitive directly; + if not he can use the decomposition. With this functionality, renderers may operate by + knowing only a small set of primitives. + + When a primitive does not implement get2DDecomposition, it is called a 'Basic Primitive' and + belongs to the set of primitives which a processor should be able to handle. Practice + will define this minimal sets of primitives. When defined and the concept is proved, + unique UNO APIs may be defined/implemented for these set to allow more intense work + with primitives using UNO. + + Current Basic 2D Primitives are: + + - BitmapPrimitive2D (bitmap data, evtl. with transparence) + - PointArrayPrimitive2D (single points) + - PolygonHairlinePrimitive2D (hairline curves/polygons) + - PolyPolygonColorPrimitive2D (colored polygons) + + UPDATE: MetafilePrimitive2D (VCL Metafile) is taken off this list since + it is implemented with the integration of CWS aw078 into DV300m69. + + All other implemented primitives have a defined decomposition and can thus be + decomposed down to this small set. + + A renderer implementing support for this minimal set of primitives can completely + render primitive-based visualisations. Of course, he also has to take states into account + which are represented by GroupPrimitive2D derivations, see groupprimitive2d.hxx + + To support getting the geometric BoundRect, getB2DRange is used. The default + implementation will use the get2DDecomposition result and merge a range from the + entries. Thus, an implementation is only necessary for the Basic Primitives, but + of course speedups are possible (and are used) by implementing the method at higher-level + primitives. + + For primitive identification, getPrimitiveID is used currently in this implementations + to allow a fast switch/case processing. This needs a unique identifier mechanism which + currently uses defines (see drawinglayer_primitivetypes2d.hxx). For UNO primitive API + it will be needed to add a unique descriptor (Name?) later to the API. + + This base implementation provides mappings from the methods from XPrimitive2D + (getDecomposition/getRange) to the appropriate methods in the C++ implementations + (get2DDecomposition/getB2DRange). The PropertyValue ViewParameters is converted to + the appropriate C++ implementation class ViewInformation2D. + + This base class does not implement any buffering; e.g. buffering the decomposition + and/or the range. These may be buffered anytime since the definition is that the primitive + is read-only and thus unchangeable. This implies that the decomposition and/or getting + the range will lead to the same result as last time, under the precondition that + the parameter ViewInformation2D is the same as the last one. This is usually the case + for view-independent primitives which are defined by not using ViewInformation2D + in their get2DDecomposition/getB2DRange implementations. +*/ +class DRAWINGLAYERCORE_DLLPUBLIC BasePrimitive2D : public salhelper::SimpleReferenceObject +{ + BasePrimitive2D(const BasePrimitive2D&) = delete; + BasePrimitive2D& operator=(const BasePrimitive2D&) = delete; + +public: + // constructor/destructor + BasePrimitive2D(); + virtual ~BasePrimitive2D() override; + + /** the ==operator is mainly needed to allow testing newly-created primitives against their last + incarnation which buffers/holds the made decompositions. The default implementation + uses getPrimitive2DID()-calls to test if it's the same ID at last. + Overridden implementations are then based on this implementation + */ + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + bool operator!=(const BasePrimitive2D& rPrimitive) const { return !operator==(rPrimitive); } + + /// The default implementation will use getDecomposition results to create the range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /** provide unique ID for fast identifying of known primitive implementations in renderers. These use + the defines from drawinglayer_primitivetypes2d.hxx to define unique IDs. + */ + virtual sal_uInt32 getPrimitive2DID() const = 0; + + /// The default implementation will return an empty sequence + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const; + + // Methods from XPrimitive2D + + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + Primitive2DContainer + getDecomposition(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters); + + /** The getRange implementation for UNO API will use getRange from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + css::geometry::RealRectangle2D + getRange(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters); + + // XAccounting + virtual sal_Int64 estimateUsage(); +}; + +/** + Rather than make all the BasePrimitive2D classes bear the cost of being an UNO + object, we just wrap the top level BasePrimitive2D in this class when we need + to pass them over UNO +*/ +class DRAWINGLAYERCORE_DLLPUBLIC UnoPrimitive2D final : public BasePrimitive2DImplBase +{ + UnoPrimitive2D(const UnoPrimitive2D&) = delete; + UnoPrimitive2D& operator=(const UnoPrimitive2D&) = delete; + +public: + // constructor/destructor + UnoPrimitive2D(rtl::Reference<BasePrimitive2D> xPrimitive) + : mxPrimitive(std::move(xPrimitive)) + { + } + virtual ~UnoPrimitive2D() override; + + // Methods from XPrimitive2D + + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + virtual css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL + getDecomposition(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters) override; + + /** The getRange implementation for UNO API will use getRange from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ + virtual css::geometry::RealRectangle2D SAL_CALL + getRange(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters) override; + + // XAccounting + virtual sal_Int64 SAL_CALL estimateUsage() override; + + rtl::Reference<BasePrimitive2D> const& getBasePrimitive2D() const { return mxPrimitive; } + +private: + rtl::Reference<BasePrimitive2D> mxPrimitive; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx new file mode 100644 index 0000000000..79ddb8b609 --- /dev/null +++ b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/bitmapex.hxx> + +namespace drawinglayer::primitive2d +{ +/** BitmapPrimitive2D class + + This class is the central primitive for Bitmap-based primitives. + */ +class DRAWINGLAYER_DLLPUBLIC BitmapPrimitive2D final : public BasePrimitive2D +{ +private: + /// the Bitmap-data + BitmapEx maBitmap; + + /** the object transformation from unit coordinates, defining + size, shear, rotate and position + */ + basegfx::B2DHomMatrix maTransform; + +public: + /// constructor + BitmapPrimitive2D(BitmapEx xBitmap, basegfx::B2DHomMatrix aTransform); + + /// data read access + const BitmapEx& getBitmap() const { return maBitmap; } + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + // XAccounting + virtual sal_Int64 estimateUsage() override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx new file mode 100644 index 0000000000..5d58feded5 --- /dev/null +++ b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> + +enum class SvxBorderLineStyle : sal_Int16; + +namespace drawinglayer::primitive2d +{ +/** BorderLine class + Helper class holding the style definition for a single part of a full BorderLine definition. + Line extends are for start/end and for Left/Right, seen in vector direction. If + Left != Right that means the line has a diagonal start/end. + Think about it similar to a trapezoid, but not aligned to X-Axis and using the + perpendicular vector to the given one in a right-handed coordinate system. +*/ +class DRAWINGLAYER_DLLPUBLIC BorderLine +{ +private: + // line attribute containing Width, Color and others + drawinglayer::attribute::LineAttribute maLineAttribute; + + // line extends + double mfStartLeft; + double mfStartRight; + double mfEndLeft; + double mfEndRight; + + // if this is a gap, this is set to true + bool mbIsGap; + +public: + // Constructor for visible BorderLine segments + BorderLine(const drawinglayer::attribute::LineAttribute& rLineAttribute, + double fStartLeft = 0.0, double fStartRight = 0.0, double fEndLeft = 0.0, + double fEndRight = 0.0); + + // Constructor for gap BorderLine segments + BorderLine(double fWidth); + + ~BorderLine(); + + BorderLine(BorderLine const&) = default; + BorderLine(BorderLine&&) = default; + BorderLine& operator=(BorderLine const&) = default; + BorderLine& operator=(BorderLine&&) = default; + + const drawinglayer::attribute::LineAttribute& getLineAttribute() const + { + return maLineAttribute; + } + double getStartLeft() const { return mfStartLeft; } + double getStartRight() const { return mfStartRight; } + double getEndLeft() const { return mfEndLeft; } + double getEndRight() const { return mfEndRight; } + bool isGap() const { return mbIsGap; } + + /// compare operator + bool operator==(const BorderLine& rBorderLine) const; +}; + +/** BorderLinePrimitive2D class + + This is the basic primitive to build frames around objects, e.g. tables. + It defines a single or double line from Start to End using the LeftWidth, + Distance and RightWidth definitions. + The LineStart/End overlap is defined in the BorderLines definitions (see + class BorderLine above). +*/ +class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D final : public BufferedDecompositionPrimitive2D +{ +private: + /// the line definition + basegfx::B2DPoint maStart; + basegfx::B2DPoint maEnd; + + /// the single BorderLine style definition(s), one or three mostly used + std::vector<BorderLine> maBorderLines; + + /// common style definitions + const drawinglayer::attribute::StrokeAttribute maStrokeAttribute; + + /// create local decomposition + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// helper to get the full width from maBorderLines + double getFullWidth() const; + +public: + /// simplified constructor for BorderLine with single edge + BorderLinePrimitive2D(const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd, + std::vector<BorderLine>&& rBorderLines, + drawinglayer::attribute::StrokeAttribute aStrokeAttribute); + + /// data read access + const basegfx::B2DPoint& getStart() const { return maStart; } + const basegfx::B2DPoint& getEnd() const { return maEnd; } + const std::vector<BorderLine>& getBorderLines() const { return maBorderLines; } + const drawinglayer::attribute::StrokeAttribute& getStrokeAttribute() const + { + return maStrokeAttribute; + } + + /// helper to decide if AntiAliasing should be used + bool isHorizontalOrVertical(const geometry::ViewInformation2D& rViewInformation) const; + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +/// helper to try to merge two instances of BorderLinePrimitive2D. If it was possible, +/// a merged version is in the returned Primitive2DReference. Lots of preconditions +/// have to be met to allow that, see implementation (and maybe even expand) +Primitive2DReference DRAWINGLAYER_DLLPUBLIC tryMergeBorderLinePrimitive2D( + const BorderLinePrimitive2D* pCandidateA, const BorderLinePrimitive2D* pCandidateB); + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/controlprimitive2d.hxx b/include/drawinglayer/primitive2d/controlprimitive2d.hxx new file mode 100644 index 0000000000..a7128b7f73 --- /dev/null +++ b/include/drawinglayer/primitive2d/controlprimitive2d.hxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +namespace com::sun::star::awt +{ +class XControl; +} +namespace com::sun::star::awt +{ +class XControlModel; +} + +namespace drawinglayer::primitive2d +{ +/** ControlPrimitive2D class + + Base class for ControlPrimitive handling. It decomposes to a + graphical representation (Bitmap data) of the control. This + representation is limited to a quadratic pixel maximum defined + in the application settings. + */ +class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D final : public BufferedDecompositionPrimitive2D +{ +private: + /// object's base data + basegfx::B2DHomMatrix maTransform; + css::uno::Reference<css::awt::XControlModel> mxControlModel; + + /// the created and cached awt::XControl + css::uno::Reference<css::awt::XControl> mxXControl; + + /// the last used scaling, used from getDecomposition for buffering + basegfx::B2DVector maLastViewScaling; + + /// yet another special snowflake way to generate PDF Alt text + OUString m_AltText; + + /// anchor structure element (Writer) + void const* const m_pAnchorStructureElementKey; + + /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl + and from thereon always used and returned by getXControl() + */ + void createXControl(); + + /// single local decompositions, used from create2DDecomposition() + Primitive2DReference + createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + Primitive2DReference createPlaceholderDecomposition() const; + + /// local decomposition + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /** constructor with an optional XControl as parameter to allow to hand it over at incarnation time + if it exists. This will avoid to create a 2nd one on demand in createXControl() + and thus double the XControls. + */ + ControlPrimitive2D(basegfx::B2DHomMatrix aTransform, + css::uno::Reference<css::awt::XControlModel> xControlModel, + css::uno::Reference<css::awt::XControl> xXControl, + ::std::u16string_view rTitle, ::std::u16string_view rDescription, + void const* pAnchorKey); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + const css::uno::Reference<css::awt::XControlModel>& getControlModel() const + { + return mxControlModel; + } + + /** mxControl access. This will on demand create the awt::XControl using createXControl() + if it does not exist. It may already have been created or even handed over at + incarnation + */ + const css::uno::Reference<css::awt::XControl>& getXControl() const; + + OUString const& GetAltText() const { return m_AltText; } + + void const* GetAnchorStructureElementKey() const { return m_pAnchorStructureElementKey; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx b/include/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx new file mode 100644 index 0000000000..cbdb21ad9d --- /dev/null +++ b/include/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> + + +// DiscreteBitmapPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** DiscreteBitmapPrimitive2D class + + This class defines a view-dependent BitmapPrimitive which has a + logic position for the top-left position and is always to be + painted in 1:1 pixel resolution. It will never be sheared, rotated + or scaled with the view. + */ + class DRAWINGLAYER_DLLPUBLIC DiscreteBitmapPrimitive2D final : public ObjectAndViewTransformationDependentPrimitive2D + { + private: + /// the RGBA Bitmap-data + BitmapEx maBitmapEx; + + /** the top-left object position */ + basegfx::B2DPoint maTopLeft; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + DiscreteBitmapPrimitive2D( + const BitmapEx& rBitmapEx, + const basegfx::B2DPoint& rTopLeft); + + /// data read access + const BitmapEx& getBitmapEx() const { return maBitmapEx; } + const basegfx::B2DPoint& getTopLeft() const { return maTopLeft; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/discreteshadowprimitive2d.hxx b/include/drawinglayer/primitive2d/discreteshadowprimitive2d.hxx new file mode 100644 index 0000000000..435ab98253 --- /dev/null +++ b/include/drawinglayer/primitive2d/discreteshadowprimitive2d.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +// DiscreteShadowPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** DiscreteShadow data class + + */ + class DRAWINGLAYER_DLLPUBLIC DiscreteShadow + { + private: + /// the original shadow BitmapEx in a special form + BitmapEx maBitmapEx; + + /// buffered extracted parts of CombinedShadow for easier usage + BitmapEx maTopLeft; + BitmapEx maTop; + BitmapEx maTopRight; + BitmapEx maRight; + BitmapEx maBottomRight; + BitmapEx maBottom; + BitmapEx maBottomLeft; + BitmapEx maLeft; + + public: + /// constructor + explicit DiscreteShadow(const BitmapEx& rBitmapEx); + + /// data read access + const BitmapEx& getBitmapEx() const { return maBitmapEx; } + + /// compare operator + bool operator==(const DiscreteShadow& rCompare) const + { + return getBitmapEx() == rCompare.getBitmapEx(); + } + + /// helper accesses which create on-demand needed segments + const BitmapEx& getTopLeft() const; + const BitmapEx& getTop() const; + const BitmapEx& getTopRight() const; + const BitmapEx& getRight() const; + const BitmapEx& getBottomRight() const; + const BitmapEx& getBottom() const; + const BitmapEx& getBottomLeft() const; + const BitmapEx& getLeft() const; + }; + + /** DiscreteShadowPrimitive2D class + + */ + class DRAWINGLAYER_DLLPUBLIC DiscreteShadowPrimitive2D final : public DiscreteMetricDependentPrimitive2D + { + private: + // the object transformation of the rectangular object + basegfx::B2DHomMatrix maTransform; + + // the bitmap shadow data + DiscreteShadow maDiscreteShadow; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + DiscreteShadowPrimitive2D( + const basegfx::B2DHomMatrix& rTransform, + const DiscreteShadow& rDiscreteShadow); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + const DiscreteShadow& getDiscreteShadow() const { return maDiscreteShadow; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx new file mode 100644 index 0000000000..e860476e7e --- /dev/null +++ b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +// define ranges for other libraries + +#define PRIMITIVE2D_ID_RANGE_DRAWINGLAYER (0 << 16) +#define PRIMITIVE2D_ID_RANGE_SVX (1 << 16) +#define PRIMITIVE2D_ID_RANGE_SD (2 << 16) +#define PRIMITIVE2D_ID_RANGE_SW (3 << 16) +#define PRIMITIVE2D_ID_RANGE_SC (4 << 16) + + +// local primitives + +#define PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 0) +#define PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 1) +#define PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 2) +#define PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 3) +#define PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 4) +#define PRIMITIVE2D_ID_BITMAPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 5) +#define PRIMITIVE2D_ID_CONTROLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 6) +#define PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 7) +#define PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 8) +#define PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 9) +#define PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 10) +#define PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 11) +#define PRIMITIVE2D_ID_GRIDPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 12) +#define PRIMITIVE2D_ID_GROUPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 13) +#define PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 14) +#define PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 15) +#define PRIMITIVE2D_ID_MASKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 16) +#define PRIMITIVE2D_ID_MEDIAPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 17) +#define PRIMITIVE2D_ID_METAFILEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 18) +#define PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 19) +#define PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 20) +#define PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 21) +#define PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 22) +#define PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 23) +#define PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 24) +#define PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 25) +#define PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 26) +#define PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 27) +#define PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 28) +#define PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 29) +#define PRIMITIVE2D_ID_SCENEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 30) +#define PRIMITIVE2D_ID_SHADOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 31) +#define PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 32) +#define PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 33) +#define PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 34) +#define PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 35) +#define PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 36) +#define PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 37) +#define PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 38) +#define PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 39) +#define PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 40) +#define PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 41) +#define PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 42) +#define PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 43) +#define PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 44) +#define PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 45) +#define PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 46) +#define PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 47) +#define PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) +#define PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) +#define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) +#define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) +#define PRIMITIVE2D_ID_HITTESTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 52) +#define PRIMITIVE2D_ID_INVERTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 53) +#define PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 54) +#define PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 55) +#define PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 56) +#define PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 57) +#define PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 58) +#define PRIMITIVE2D_ID_EPSPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 59) +#define PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 60) +#define PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 61) +#define PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 62) +#define PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 63) +#define PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 64) +#define PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 65) +#define PRIMITIVE2D_ID_CROPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 66) +#define PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 67) +#define PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 68) +#define PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 69) +#define PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 70) +#define PRIMITIVE2D_ID_GLOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 71) +#define PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 72) +#define PRIMITIVE2D_ID_LINERECTANGLEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 73) +#define PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 74) +#define PRIMITIVE2D_ID_SINGLELINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 75) +// When you add a new primitive, please update the drawinglayer::primitive2d::idToString() function +// in drawinglayer/source/primitive2d/Tools.cxx. + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/embedded3dprimitive2d.hxx b/include/drawinglayer/primitive2d/embedded3dprimitive2d.hxx new file mode 100644 index 0000000000..3fc9ab5be6 --- /dev/null +++ b/include/drawinglayer/primitive2d/embedded3dprimitive2d.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <drawinglayer/geometry/viewinformation3d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +// Embedded3DPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** Embedded3DPrimitive2D class + + This is a helper primitive which allows embedding of single 3D + primitives to the 2D primitive logic. It will get the scene it's + involved and thus the 3D transformation. With this information it + is able to provide 2D range data for a 3D primitive. + + This primitive will not be visualized and decomposes to a yellow + 2D rectangle to visualize that this should never be visualized + */ + class DRAWINGLAYER_DLLPUBLIC Embedded3DPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the sequence of 3d primitives + primitive3d::Primitive3DContainer mxChildren3D; + + /// the 2D scene object transformation + basegfx::B2DHomMatrix maObjectTransformation; + + /// the 3D transformations + geometry::ViewInformation3D maViewInformation3D; + + /** if the embedded 3D primitives contain shadow, these parameters are needed + to extract the shadow which is a sequence of 2D primitives and may expand + the 2D range. Since every single 3D object in a scene may individually + have shadow or not, these values need to be provided and prepared. The shadow + distance itself (a 2D transformation) is part of the 3D shadow definition + */ + basegfx::B3DVector maLightNormal; + double mfShadowSlant; + basegfx::B3DRange maScene3DRange; + + /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) + Primitive2DContainer maShadowPrimitives; + + /// #i96669# add simple range buffering for this primitive + basegfx::B2DRange maB2DRange; + + /** flag if given 3D geometry is already checked for shadow definitions and 2d shadows + are created in maShadowPrimitives + */ + bool mbShadow3DChecked : 1; + + /// private helpers + bool impGetShadow3D() const; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + Embedded3DPrimitive2D( + primitive3d::Primitive3DContainer xChildren3D, + basegfx::B2DHomMatrix aObjectTransformation, + geometry::ViewInformation3D aViewInformation3D, + const basegfx::B3DVector& rLightNormal, + double fShadowSlant, + const basegfx::B3DRange& rScene3DRange); + + /// data read access + const primitive3d::Primitive3DContainer& getChildren3D() const { return mxChildren3D; } + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } + const basegfx::B3DVector& getLightNormal() const { return maLightNormal; } + double getShadowSlant() const { return mfShadowSlant; } + const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/epsprimitive2d.hxx b/include/drawinglayer/primitive2d/epsprimitive2d.hxx new file mode 100644 index 0000000000..39782bf3cc --- /dev/null +++ b/include/drawinglayer/primitive2d/epsprimitive2d.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/gdimtf.hxx> + +namespace drawinglayer::primitive2d +{ + /** EpsPrimitive2D class */ + class EpsPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the geometry definition + basegfx::B2DHomMatrix maEpsTransform; + + /// the Eps content definition + GfxLink maGfxLink; + + /// the replacement content definition + GDIMetaFile maMetaFile; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + EpsPrimitive2D( + basegfx::B2DHomMatrix aEpsTransform, + GfxLink aGfxLink, + const GDIMetaFile& rMetaFile); + + /// data read access + const basegfx::B2DHomMatrix& getEpsTransform() const { return maEpsTransform; } + const GfxLink& getGfxLink() const { return maGfxLink; } + const GDIMetaFile& getMetaFile() const { return maMetaFile; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get B2Drange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx new file mode 100644 index 0000000000..ffdf874fa9 --- /dev/null +++ b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> + + +// predefines + +namespace basegfx { class B2DPolygon; } + + +// FillGradientPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** FillGradientPrimitive2D class + + This class defines a gradient filling for a rectangular area. The + Range is defined by the Transformation, the gradient by the FillGradientAttribute. + + The decomposition will deliver the decomposed gradient, e.g. for an ellipse + gradient the various ellipses in various color steps will be created. + + I have added functionality to create both versions of filled decompositions: + Those who overlap and non-overlapping ones. The overlapping version is the + default one since it works with and without AntiAliasing. The non-overlapping + version is used in the MetafilePrimitive2D decomposition when the old XOR + paint was recorded. + */ + class DRAWINGLAYER_DLLPUBLIC FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// the geometrically visible area + basegfx::B2DRange maOutputRange; + + /// the area the gradient definition is based on + /// in the simplest case identical to OutputRange + basegfx::B2DRange maDefinitionRange; + + /// the gradient definition + attribute::FillGradientAttribute maFillGradient; + + + protected: + /// local helper + void createFill(Primitive2DContainer& rContainer, bool bOverlapping) const; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// helpers that support e.g. direct paint/geometry creation + basegfx::B2DPolygon getUnitPolygon() const; + basegfx::BColor getOuterColor() const; + void generateMatricesAndColors( + std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) const; + + /// constructors. The one without definition range will use output range as definition range + FillGradientPrimitive2D( + const basegfx::B2DRange& rOutputRange, + attribute::FillGradientAttribute aFillGradient); + FillGradientPrimitive2D( + const basegfx::B2DRange& rOutputRange, + const basegfx::B2DRange& rDefinitionRange, + attribute::FillGradientAttribute aFillGradient); + + /// data read access + const basegfx::B2DRange& getOutputRange() const { return maOutputRange; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx b/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx new file mode 100644 index 0000000000..d119c8f9c2 --- /dev/null +++ b/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> +#include <vcl/bitmapex.hxx> + +namespace drawinglayer::primitive2d +{ +class FillGraphicPrimitive2D; +} + +namespace drawinglayer::processor2d +{ +// define a simple accessor which can be used as friend. That method exists +// only locally at SDPRProcessor2dTools.cxx and is thus only usable/callable +// from there +void setOffsetXYCreatedBitmap( + drawinglayer::primitive2d::FillGraphicPrimitive2D&, + const BitmapEx&); +} + +// FillbitmapPrimitive2D class +namespace drawinglayer::primitive2d +{ + /** FillGraphicPrimitive2D class + + This class defines a bitmap filling for a rectangular area. The + Range is defined by the Transformation, the fill by the FillGraphicAttribute. + There, the fill consists of a Bitmap (not transparent) defining the fill data + and a Point/Vector pair defining the relative position/size [0.0 .. 1.0] + inside the area where the bitmap is positioned. A flag defines then if this + is tiled or not. + + Renderers should handle this primitive; it has a geometrically correct + decomposition, but on pixel outputs the areas where the tiled pieces are + aligned tend to show up (one overlapping or empty pixel) + */ + class DRAWINGLAYER_DLLPUBLIC FillGraphicPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the geometric definition + basegfx::B2DHomMatrix maTransformation; + + /// the fill attributes + attribute::FillGraphicAttribute maFillGraphic; + + /// the evtl. buffered OffsetXYCreatedBitmap + BitmapEx maOffsetXYCreatedBitmap; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + // allow this single accessor to change it to set buggered data + friend void drawinglayer::processor2d::setOffsetXYCreatedBitmap( + drawinglayer::primitive2d::FillGraphicPrimitive2D&, + const BitmapEx&); + + // private tooling method to be called by setOffsetXYCreatedBitmap + void impSetOffsetXYCreatedBitmap(const BitmapEx& rBitmap) + { + maOffsetXYCreatedBitmap = rBitmap; + } + + public: + /// constructor + FillGraphicPrimitive2D( + basegfx::B2DHomMatrix aTransformation, + const attribute::FillGraphicAttribute& rFillGraphic); + + /// data read access + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } + const BitmapEx& getOffsetXYCreatedBitmap() const { return maOffsetXYCreatedBitmap; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx b/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx new file mode 100644 index 0000000000..09a74618d7 --- /dev/null +++ b/include/drawinglayer/primitive2d/fillhatchprimitive2d.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> +#include <basegfx/color/bcolor.hxx> + + +// FillHatchPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** FillHatchPrimitive2D class + + This class defines a hatch filling for a rectangular area. The + Range is defined by the Transformation, the hatch by the FillHatchAttribute. + If the background is to be filled, a flag in FillHatchAttribute is set and + the BColor defines the background color. + + #i120230# This primitive is now evtl. metric dependent due to the value + MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero. + This is used for a more appealing, VCL-like visualisation by not letting the + distances get too small between lines. + + The decomposition will deliver the hatch lines. + */ + class FillHatchPrimitive2D final : public DiscreteMetricDependentPrimitive2D + { + private: + /// the geometrically visible area + basegfx::B2DRange maOutputRange; + + /// the area the gradient definition is based on + /// in the simplest case identical to OutputRange + basegfx::B2DRange maDefinitionRange; + + /// the hatch definition + attribute::FillHatchAttribute maFillHatch; + + /// hatch background color (if used) + basegfx::BColor maBColor; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructors. The one without definition range will use output range as definition range + FillHatchPrimitive2D( + const basegfx::B2DRange& rOutputRange, + const basegfx::BColor& rBColor, + attribute::FillHatchAttribute aFillHatch); + FillHatchPrimitive2D( + const basegfx::B2DRange& rOutputRange, + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rBColor, + attribute::FillHatchAttribute aFillHatch); + + /// data read access + const basegfx::B2DRange& getOutputRange() const { return maOutputRange; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/glowprimitive2d.hxx b/include/drawinglayer/primitive2d/glowprimitive2d.hxx new file mode 100644 index 0000000000..985137e232 --- /dev/null +++ b/include/drawinglayer/primitive2d/glowprimitive2d.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx> +#include <tools/color.hxx> + +namespace drawinglayer::primitive2d +{ +class DRAWINGLAYER_DLLPUBLIC GlowPrimitive2D final : public BufferedDecompositionGroupPrimitive2D +{ +private: + /// the Glow color to which all geometry is to be forced; includes alpha + Color maGlowColor; + + /// the Glow size, in logical units (100ths of mm) + double mfGlowRadius; + + /// last used DiscreteGlowRadius and ClippedRange + double mfLastDiscreteGlowRadius; + basegfx::B2DRange maLastClippedRange; + + /// helpers + bool prepareValuesAndcheckValidity(basegfx::B2DRange& rRange, basegfx::B2DRange& rClippedRange, + basegfx::B2DVector& rDiscreteSize, + double& rfDiscreteGlowRadius, + const geometry::ViewInformation2D& rViewInformation) const; + +protected: + /** method which is to be used to implement the local decomposition of a 2D primitive. */ + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + GlowPrimitive2D(const Color& rGlowColor, double fRadius, Primitive2DContainer&& rChildren); + + /// data read access + const Color& getGlowColor() const { return maGlowColor; } + double getGlowRadius() const { return mfGlowRadius; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// The default implementation will return an empty sequence + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/graphicprimitive2d.hxx b/include/drawinglayer/primitive2d/graphicprimitive2d.hxx new file mode 100644 index 0000000000..1857eef4c9 --- /dev/null +++ b/include/drawinglayer/primitive2d/graphicprimitive2d.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/GraphicObject.hxx> + +namespace drawinglayer::primitive2d +{ +/** GraphicPrimitive2D class + + Primitive to hold graphics defined by GraphicObject and GraphicAttr + combination. This includes MetaFiles and diverse pixel-oriented graphic + formats. It even includes animated GIFs, Croppings and other changes + defined in GraphicAttr. + + This makes the decomposition contain a wide variety of possibilities, + too. From a simple BitmapPrimitive over AnimatedSwitchPrimitive2D, + MetafilePrimitive2D (with and without embedding in a masking when e.g. + the Metafile is bigger than the geometry) and embeddings in + TransformPrimitive2D and MaskPrimitive2D for croppings. + + The primitive geometry area is defined by Transform. + */ +class DRAWINGLAYER_DLLPUBLIC GraphicPrimitive2D final : public BufferedDecompositionPrimitive2D +{ +private: + /// the geometric definition + basegfx::B2DHomMatrix maTransform; + + /// the GraphicObject with all its content possibilities + GraphicObject maGraphicObject; + + /// The GraphicAttr with all its modification possibilities + GraphicAttr maGraphicAttr; + + /// local decomposition + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor(s) + GraphicPrimitive2D(basegfx::B2DHomMatrix aTransform, const GraphicObject& rGraphicObject, + const GraphicAttr& rGraphicAttr); + GraphicPrimitive2D(basegfx::B2DHomMatrix aTransform, const GraphicObject& rGraphicObject); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + const GraphicObject& getGraphicObject() const { return maGraphicObject; } + const GraphicAttr& getGraphicAttr() const { return maGraphicAttr; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/gridprimitive2d.hxx b/include/drawinglayer/primitive2d/gridprimitive2d.hxx new file mode 100644 index 0000000000..a6d4d03c58 --- /dev/null +++ b/include/drawinglayer/primitive2d/gridprimitive2d.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> +#include <vcl/bitmapex.hxx> + + +// GridPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** GridPrimitive2D class + + This primitive is specialized to Grid visualisation. The graphic definition + (Transform) contains the whole grid area, but will of course be combined + with the visible area (Viewport) when decomposed. Also a resolution-dependent + point reduction is used to not create too much grid visualisation data. This + makes this primitive highly view-dependent and it dynamically buffers + the last decomposition dependent from the Viewport used. + */ + class DRAWINGLAYER_DLLPUBLIC GridPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// The geometry definition for the grid area + basegfx::B2DHomMatrix maTransform; + + /// grid layout definitions + double mfWidth; + double mfHeight; + double mfSmallestViewDistance; + double mfSmallestSubdivisionViewDistance; + sal_uInt32 mnSubdivisionsX; + sal_uInt32 mnSubdivisionsY; + + /// Grid color for single-pixel grid points + basegfx::BColor maBColor; + + /// The Bitmap (with transparence) for grid cross points + BitmapEx maCrossMarker; + + /** the last used object to view transformtion and the last Viewport, + used from getDecomposition for decide buffering + */ + basegfx::B2DHomMatrix maLastObjectToViewTransformation; + basegfx::B2DRange maLastViewport; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + GridPrimitive2D( + basegfx::B2DHomMatrix aTransform, + double fWidth, + double fHeight, + double fSmallestViewDistance, + double fSmallestSubdivisionViewDistance, + sal_uInt32 nSubdivisionsX, + sal_uInt32 nSubdivisionsY, + const basegfx::BColor& rBColor, + const BitmapEx& rCrossMarker); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + double getWidth() const { return mfWidth; } + double getHeight() const { return mfHeight; } + double getSmallestViewDistance() const { return mfSmallestViewDistance; } + double getSmallestSubdivisionViewDistance() const { return mfSmallestSubdivisionViewDistance; } + sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; } + sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; } + const basegfx::BColor& getBColor() const { return maBColor; } + const BitmapEx& getCrossMarker() const { return maCrossMarker; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get 2d range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/groupprimitive2d.hxx b/include/drawinglayer/primitive2d/groupprimitive2d.hxx new file mode 100644 index 0000000000..b34bef834f --- /dev/null +++ b/include/drawinglayer/primitive2d/groupprimitive2d.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> + +// GroupPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** GroupPrimitive2D class + + Baseclass for all grouping 2D primitives + + The grouping primitive in its basic form is capable of holding + a child primitive content and returns it on decomposition on default. + It is used for two main purposes, but more may apply: + + - to transport extended information, e.g. for text classification, + see e.g. TextHierarchy*Primitive2D implementations. Since they + decompose to their child content, renderers not aware/interested + in that extra information will just ignore these primitives + + - to encapsulate common geometry, e.g. the ShadowPrimitive2D implements + applying a generic shadow to a child sequence by adding the needed + offset and color stuff in the decomposition + + In most cases the decomposition is straightforward, so by default + this primitive will not buffer the result and is not derived from + BufferedDecompositionPrimitive2D, but from BasePrimitive2D. + + A renderer has to take GroupPrimitive2D derivations into account which + are used to hold a state. + + Current Basic 2D StatePrimitives are: + + - TransparencePrimitive2D (objects with freely defined transparence) + - InvertPrimitive2D (for XOR) + - MaskPrimitive2D (for masking) + - ModifiedColorPrimitive2D (for a stack of color modifications) + - TransformPrimitive2D (for a transformation stack) + */ + class DRAWINGLAYER_DLLPUBLIC GroupPrimitive2D : public BasePrimitive2D + { + private: + /// the children. Declared private since this shall never be changed at all after construction + Primitive2DContainer maChildren; + + public: + /// constructor + explicit GroupPrimitive2D(Primitive2DContainer&& aChildren); + + /// data read access + const Primitive2DContainer& getChildren() const { return maChildren; } + + void getChildren(Primitive2DDecompositionVisitor& rVisitor) const { rVisitor.visit(maChildren); } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// local decomposition. Implementation will just return children + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + // XAccounting + virtual sal_Int64 estimateUsage() override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/helplineprimitive2d.hxx b/include/drawinglayer/primitive2d/helplineprimitive2d.hxx new file mode 100644 index 0000000000..075715b9b6 --- /dev/null +++ b/include/drawinglayer/primitive2d/helplineprimitive2d.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +// HelplinePrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** HelplineStyle2D definition + + The available styles of Helplines + */ + enum class HelplineStyle2D + { + Point, + Line + }; + + /** HelplinePrimitive2D class + + This primitive provides a view-dependent helpline definition. The Helpline + is defined by a line equation (Point and vector) and a style. When the style + is a line, dependent from Viewport the visible part of that Helpline is + constructed. For Point, a cross is constructed. This primitive is highly + view-dependent. + + The visualisation uses the two given colors to create a dashed line with + the given dash length. + */ + class DRAWINGLAYER_DLLPUBLIC HelplinePrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// Helpline geometry definition + basegfx::B2DPoint maPosition; + basegfx::B2DVector maDirection; + HelplineStyle2D meStyle; + + /// Helpline style definition + basegfx::BColor maRGBColA; + basegfx::BColor maRGBColB; + double mfDiscreteDashLength; + + /** the last used object to view transformtion and the last Viewport, + used from getDecomposition for decide buffering + */ + basegfx::B2DHomMatrix maLastObjectToViewTransformation; + basegfx::B2DRange maLastViewport; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + HelplinePrimitive2D( + const basegfx::B2DPoint& rPosition, + const basegfx::B2DVector& rDirection, + HelplineStyle2D eStyle, + const basegfx::BColor& rRGBColA, + const basegfx::BColor& aRGBColB, + double fDiscreteDashLength); + + /// data read access + const basegfx::B2DPoint& getPosition() const { return maPosition; } + const basegfx::B2DVector& getDirection() const { return maDirection; } + HelplineStyle2D getStyle() const { return meStyle; } + const basegfx::BColor& getRGBColA() const { return maRGBColA; } + const basegfx::BColor& getRGBColB() const { return maRGBColB; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx b/include/drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx new file mode 100644 index 0000000000..3a13d2ab4d --- /dev/null +++ b/include/drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + + +namespace drawinglayer::primitive2d +{ + // This primitive is used to represent geometry for non-visible objects, + // e.g. a PresObj's outline. To still be able to use primitives for HitTest + // functionality, the 2d decompositions will produce an as much as possible + // simplified line geometry encapsulated in this primitive when there is no + // line geometry. In a further enhanced version this may change to 'if neither + // filled nor lines' creation criteria. The whole primitive decomposes to nothing, + // so no one not knowing it will be influenced. Only helper processors for hit test + // (and maybe BoundRect extractors) will use it and its children subcontent. + class DRAWINGLAYER_DLLPUBLIC HiddenGeometryPrimitive2D final : public GroupPrimitive2D + { + public: + explicit HiddenGeometryPrimitive2D(Primitive2DContainer&& aChildren); + + // despite returning an empty decomposition since it's no visualisation data, + // range calculation is intended to use hidden geometry, so + // the local implementation will return the children's range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// local decomposition. Implementation will return empty Primitive2DSequence + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + // provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/invertprimitive2d.hxx b/include/drawinglayer/primitive2d/invertprimitive2d.hxx new file mode 100644 index 0000000000..ccafd51561 --- /dev/null +++ b/include/drawinglayer/primitive2d/invertprimitive2d.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + + +namespace drawinglayer::primitive2d +{ + /** InvertPrimitive2D class + + This is a helper class which encapsulates geometry that should be + painted XOR, e.g. old cursor visualisations. It decomposes to + its content, so when not supporting it, the contained geometry + will be visualized normally. + Unfortunately this is still needed, but hard to support on various + systems. XOR painting needs read access to the target, so modern + graphic systems tend to not support it anymore. + */ + class DRAWINGLAYER_DLLPUBLIC InvertPrimitive2D final : public GroupPrimitive2D + { + public: + /// constructor + explicit InvertPrimitive2D(Primitive2DContainer&& aChildren); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/markerarrayprimitive2d.hxx b/include/drawinglayer/primitive2d/markerarrayprimitive2d.hxx new file mode 100644 index 0000000000..40f6236cf2 --- /dev/null +++ b/include/drawinglayer/primitive2d/markerarrayprimitive2d.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <vcl/bitmapex.hxx> + + +// MarkerArrayPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** MarkerArrayPrimitive2D class + + This primitive defines an array of markers. Their size is defined + in pixels and independent from the view transformation which makes + this primitive highly view-dependent. It is also transformation + invariant, so that the bitmap is always visualized unscaled and + unrotated. + It is used e.g. for grid position visualisation. The given Bitmap + (with transparence) is defined to be visible centered at each of the given + positions. + It decomposes to the needed number of BitmapPrimitive2D's, so it would + be efficient to handle it directly in a renderer. + */ + class DRAWINGLAYER_DLLPUBLIC MarkerArrayPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the positions for the marker + std::vector< basegfx::B2DPoint > maPositions; + + /// the marker definition to visualize + BitmapEx maMarker; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + MarkerArrayPrimitive2D( + std::vector< basegfx::B2DPoint >&& rPositions, + const BitmapEx& rMarker); + + /// data read access + const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } + const BitmapEx& getMarker() const { return maMarker; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/maskprimitive2d.hxx b/include/drawinglayer/primitive2d/maskprimitive2d.hxx new file mode 100644 index 0000000000..cf62ced669 --- /dev/null +++ b/include/drawinglayer/primitive2d/maskprimitive2d.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + + +namespace drawinglayer::primitive2d +{ + /** MaskPrimitive2D class + + This is the central masking primitive. It's a grouping + primitive and contains a tools::PolyPolygon which defines the visible + area. Only visualisation parts of the Child primitive sequence + inside of the mask tools::PolyPolygon is defined to be visible. + + This primitive should be handled by a renderer. If it is not handled, + it decomposes to its Child content, and thus the visualisation would + contain no clips. + + The geometry range of this primitive is completely defined by the Mask + tools::PolyPolygon since by definition nothing outside of the mask is visible. + */ + class DRAWINGLAYER_DLLPUBLIC MaskPrimitive2D final : public GroupPrimitive2D + { + private: + /// the mask PolyPolygon + basegfx::B2DPolyPolygon maMask; + + public: + /// constructor + MaskPrimitive2D( + basegfx::B2DPolyPolygon aMask, + Primitive2DContainer&& aChildren); + + /// data read access + const basegfx::B2DPolyPolygon& getMask() const { return maMask; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/mediaprimitive2d.hxx b/include/drawinglayer/primitive2d/mediaprimitive2d.hxx new file mode 100644 index 0000000000..e0a3e04e8d --- /dev/null +++ b/include/drawinglayer/primitive2d/mediaprimitive2d.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> +#include <vcl/graph.hxx> + + +namespace drawinglayer::primitive2d +{ + /** MediaPrimitive2D class + + This is a unified primitive for Media visualisation, e.g. animations + or sounds. It's geometry is defined by Transform. For convenience, + it also contains a discrete border size (aka Pixels) which will be added + if used. This makes it a view-dependent primitive. It also gets a filled + background and the decomposition will try to create a graphic representation + if the content (defined by the URL), e.g. a still frame for animated stuff. + */ + class DRAWINGLAYER_DLLPUBLIC MediaPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the geometry definition + basegfx::B2DHomMatrix maTransform; + + /// the content definition + OUString maURL; + + /// style: background color + basegfx::BColor maBackgroundColor; + + /// discrete border (in 'pixels') + sal_uInt32 mnDiscreteBorder; + + const Graphic maSnapshot; + + /// local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + MediaPrimitive2D( + basegfx::B2DHomMatrix aTransform, + OUString aURL, + const basegfx::BColor& rBackgroundColor, + sal_uInt32 nDiscreteBorder, + Graphic aSnapshot); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; } + sal_uInt32 getDiscreteBorder() const { return mnDiscreteBorder; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/metafileprimitive2d.hxx b/include/drawinglayer/primitive2d/metafileprimitive2d.hxx new file mode 100644 index 0000000000..2f82270aeb --- /dev/null +++ b/include/drawinglayer/primitive2d/metafileprimitive2d.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/gdimetafiletools.hxx> + + +// MetafilePrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** MetafilePrimitive2D class + + This is the MetaFile representing primitive. It's geometry is defined + by MetaFileTransform. The content (defined by MetaFile) will be scaled + to the geometric definition by using PrefMapMode and PrefSize of the + Metafile. + + It has shown that this not always guarantees that all Metafile content + is inside the geometric definition, but this primitive defines that this + is the case to allow a getB2DRange implementation. If it cannot be + guaranteed that the Metafile is inside the geometric definition, it should + be embedded to a MaskPrimitive2D. + + This primitive has no decomposition yet, so when not supported by a renderer, + it will not be visualized. + + In the future, a decomposition implementation would be appreciated and would + have many advantages; Metafile would no longer have to be rendered by + sub-systems and a standard way for converting Metafiles would exist. + */ + class DRAWINGLAYER_DLLPUBLIC MetafilePrimitive2D final : public BufferedDecompositionPrimitive2D, public MetafileAccessor + { + private: + /// the geometry definition + basegfx::B2DHomMatrix maMetaFileTransform; + + /// the content definition + GDIMetaFile maMetaFile; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + public: + /// constructor + MetafilePrimitive2D( + basegfx::B2DHomMatrix aMetaFileTransform, + const GDIMetaFile& rMetaFile); + + /// data read access + const basegfx::B2DHomMatrix& getTransform() const { return maMetaFileTransform; } + const GDIMetaFile& getMetaFile() const { return maMetaFile; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// from MetafileAccessor + virtual void accessMetafile(GDIMetaFile& rTargetMetafile) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx b/include/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx new file mode 100644 index 0000000000..b48d178ec0 --- /dev/null +++ b/include/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <basegfx/color/bcolormodifier.hxx> + + +namespace drawinglayer::primitive2d +{ + /** ModifiedColorPrimitive2D class + + This primitive is a grouping primitive and allows to define + how the colors of its child content shall be modified for + visualisation. This can be (and is) used e.g. for generic shadow + visualisation by forcing all color usages of the contained + sub-content to the shadow color. + + For the possibilities of color modifications, please refer + to the basegfx::BColorModifier definitions in basegfx. For + processing there is tooling in basegfx to build a stack of + BColorModifierSharedPtrs to always be able to process the correct + colors. + + If a renderer does not handle this primitive, the content will + be visualized unchanged. + */ + class DRAWINGLAYER_DLLPUBLIC ModifiedColorPrimitive2D final : public GroupPrimitive2D + { + private: + /// The ColorModifier to use + basegfx::BColorModifierSharedPtr maColorModifier; + + public: + /// constructor + ModifiedColorPrimitive2D( + Primitive2DContainer&& aChildren, + basegfx::BColorModifierSharedPtr xColorModifier); + + /// data read access + const basegfx::BColorModifierSharedPtr& getColorModifier() const { return maColorModifier; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/objectinfoprimitive2d.hxx b/include/drawinglayer/primitive2d/objectinfoprimitive2d.hxx new file mode 100644 index 0000000000..6dc410b86c --- /dev/null +++ b/include/drawinglayer/primitive2d/objectinfoprimitive2d.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <rtl/ustring.hxx> + +namespace drawinglayer::primitive2d +{ + /** ObjectInfoPrimitive2D class + + Info hierarchy helper class to hold contents like Name, Title and + Description which are valid for the child content, e.g. created for + primitives based on DrawingLayer objects or SVG parts. It decomposes + to its content, so all direct renderers may ignore it. May e.g. + be used when re-creating graphical content from a sequence of primitives + */ + class DRAWINGLAYER_DLLPUBLIC ObjectInfoPrimitive2D final : public GroupPrimitive2D + { + private: + OUString maName; + OUString maTitle; + OUString maDesc; + + public: + /// constructor + ObjectInfoPrimitive2D( + Primitive2DContainer&& aChildren, + OUString aName, + OUString aTitle, + OUString aDesc); + + /// data read access + const OUString& getName() const { return maName; } + const OUString& getTitle() const { return maTitle; } + const OUString& getDesc() const { return maDesc; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/pagehierarchyprimitive2d.hxx b/include/drawinglayer/primitive2d/pagehierarchyprimitive2d.hxx new file mode 100644 index 0000000000..8b6a08aa7f --- /dev/null +++ b/include/drawinglayer/primitive2d/pagehierarchyprimitive2d.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + + +namespace drawinglayer::primitive2d +{ + /** PageHierarchyPrimitive2D class + + This primitive encapsulates text lines. + */ + class DRAWINGLAYER_DLLPUBLIC PageHierarchyPrimitive2D final : public GroupPrimitive2D + { + private: + public: + /// constructor + explicit PageHierarchyPrimitive2D(Primitive2DContainer&& aChildren); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx b/include/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx new file mode 100644 index 0000000000..f1ec668a9e --- /dev/null +++ b/include/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +namespace com::sun::star::drawing { class XDrawPage; } + + +namespace drawinglayer::primitive2d +{ + /** PagePreviewPrimitive2D class + + This primitive is needed to have the correct XDrawPage as ViewInformation for decomposing + the page contents (given as PageContent here) if these contain e.g. + view-dependent (in this case XDrawPage-dependent) text fields like PageNumber. If You want + those primitives to be visualized correctly, Your renderer needs to locally correct its + ViewInformation2D to reference the new XDrawPage. + */ + class DRAWINGLAYER_DLLPUBLIC PagePreviewPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /** the XDrawPage visualized by this primitive. When we go forward with primitives + this will not only be used by the renderers to provide the correct decompose + graphic attribute context, but also to completely create the page's sub-content. + */ + const css::uno::Reference< css::drawing::XDrawPage > mxDrawPage; + + /// the PageContent + Primitive2DContainer maPageContent; + + /// the own geometry + basegfx::B2DHomMatrix maTransform; + + /// content width and height + double mfContentWidth; + double mfContentHeight; + + /// local decomposition. Implementation will just return children + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + PagePreviewPrimitive2D( + css::uno::Reference< css::drawing::XDrawPage > xDrawPage, + basegfx::B2DHomMatrix aTransform, + double fContentWidth, + double fContentHeight, + Primitive2DContainer&& rPageContent); + + /// data read access + const css::uno::Reference< css::drawing::XDrawPage >& getXDrawPage() const { return mxDrawPage; } + const Primitive2DContainer& getPageContent() const { return maPageContent; } + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + double getContentWidth() const { return mfContentWidth; } + double getContentHeight() const { return mfContentHeight; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// own getB2DRange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx new file mode 100644 index 0000000000..c12a7622c3 --- /dev/null +++ b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <vcl/bitmapex.hxx> + + +namespace drawinglayer::primitive2d +{ + /** PatternFillPrimitive2D class + + This primitive allows filling a given tools::PolyPolygon with a pattern + defined by a sequence of primitives which are mapped to the unit range. + The pattern is defined using a reference range which defines a rectangular + area relative to the tools::PolyPolygon (in unit coordinates) which is virtually + infinitely repeated. + */ + class DRAWINGLAYER_DLLPUBLIC PatternFillPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + const basegfx::B2DPolyPolygon maMask; + const Primitive2DContainer maChildren; + const basegfx::B2DRange maReferenceRange; + + /// values holding the discrete buffer size + sal_uInt32 mnDiscreteWidth; + sal_uInt32 mnDiscreteHeight; + + /// helper that is capable to calculate the needed discrete buffer size for + /// eventually buffered content + void calculateNeededDiscreteBufferSize( + sal_uInt32& rWidth, + sal_uInt32& rHeight, + const geometry::ViewInformation2D& rViewInformation) const; + + /// helper which creates the content - checks if clipping is needed and eventually + /// creates buffered content to speed up rendering + Primitive2DContainer createContent(const geometry::ViewInformation2D& rViewInformation) const; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + PatternFillPrimitive2D( + basegfx::B2DPolyPolygon aMask, + Primitive2DContainer&& rChildren, + const basegfx::B2DRange& rReferenceRange); + + /// data read access + const basegfx::B2DPolyPolygon& getMask() const { return maMask; } + const Primitive2DContainer& getChildren() const { return maChildren; } + const basegfx::B2DRange& getReferenceRange() const { return maReferenceRange; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// overload to react on evtl. buffered content + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + // XAccounting + virtual sal_Int64 estimateUsage() override; + + /// helper which creates the content - checks if clipping is needed and eventually + /// creates buffered content to speed up rendering + BitmapEx createTileImage(sal_uInt32 nWidth, sal_uInt32 nHeight) const; + + /// helper that is capable to calculate the needed discrete buffer size for + /// eventually buffered content + void getTileSize( + sal_uInt32& rWidth, + sal_uInt32& rHeight, + const geometry::ViewInformation2D& rViewInformation) const; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/pointarrayprimitive2d.hxx b/include/drawinglayer/primitive2d/pointarrayprimitive2d.hxx new file mode 100644 index 0000000000..a2eb5f611d --- /dev/null +++ b/include/drawinglayer/primitive2d/pointarrayprimitive2d.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/color/bcolor.hxx> + + +// PointArrayPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** PointArrayPrimitive2D class + + This primitive defines single,discrete 'pixels' for the given + positions in the given color. This makes it view-dependent since + the logic size of a 'pixel' depends on the view transformation. + + This is one of the non-decomposable primitives, so a renderer + should process it (Currently it is only used for grid visualisation, + but this may change). + */ + class PointArrayPrimitive2D final : public BasePrimitive2D + { + private: + /// the array of positions + std::vector< basegfx::B2DPoint > maPositions; + + /// the color to use + basegfx::BColor maRGBColor; + + /// #i96669# add simple range buffering for this primitive + basegfx::B2DRange maB2DRange; + + public: + /// constructor + PointArrayPrimitive2D( + std::vector< basegfx::B2DPoint >&& rPositions, + const basegfx::BColor& rRGBColor); + + /// data read access + const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } + const basegfx::BColor& getRGBColor() const { return maRGBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/primitivetools2d.hxx b/include/drawinglayer/primitive2d/primitivetools2d.hxx new file mode 100644 index 0000000000..97e4f770e3 --- /dev/null +++ b/include/drawinglayer/primitive2d/primitivetools2d.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer::primitive2d +{ + /** DiscreteMetricDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + regarding the size of a discrete unit. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date DiscreteUnit accessible using getDiscreteUnit() + */ + class DRAWINGLAYER_DLLPUBLIC DiscreteMetricDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used fDiscreteUnit definitions for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ + double mfDiscreteUnit; + + public: + /// constructor + DiscreteMetricDependentPrimitive2D() + : mfDiscreteUnit(0.0) + { + } + + /// data read access + double getDiscreteUnit() const { return mfDiscreteUnit; } + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; + + /** ViewportDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + regarding the viewport. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date Viewport accessible using getViewport() + */ + class DRAWINGLAYER_DLLPUBLIC ViewportDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used Viewport definition for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ + basegfx::B2DRange maViewport; + + public: + /// constructor + ViewportDependentPrimitive2D() + { + } + + /// data read access + const basegfx::B2DRange& getViewport() const { return maViewport; } + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; + + /** ViewTransformationDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + regarding the complete Viewtransformation. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date ViewTransformation accessible using getViewTransformation() + */ + class DRAWINGLAYER_DLLPUBLIC ViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used ViewTransformation definition for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ + basegfx::B2DHomMatrix maViewTransformation; + + public: + /// constructor + ViewTransformationDependentPrimitive2D() + { + } + + /// data read access + const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; + + /** ObjectAndViewTransformationDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + and Object-Transform dependent. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date ViewTransformation accessible using getViewTransformation() + and an object transformation via getObjectTransformation() + */ + class DRAWINGLAYER_DLLPUBLIC ObjectAndViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used ViewTransformation and the last ObjectTransformation + definition for decomposition. Since this is checked and updated from + get2DDecomposition() it will be current and usable in create2DDecomposition() + */ + basegfx::B2DHomMatrix maViewTransformation; + basegfx::B2DHomMatrix maObjectTransformation; + + public: + /// constructor + ObjectAndViewTransformationDependentPrimitive2D() + { + } + + /// data read access + const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/sceneprimitive2d.hxx b/include/drawinglayer/primitive2d/sceneprimitive2d.hxx new file mode 100644 index 0000000000..5965962a70 --- /dev/null +++ b/include/drawinglayer/primitive2d/sceneprimitive2d.hxx @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <drawinglayer/geometry/viewinformation3d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/bitmapex.hxx> +#include <drawinglayer/attribute/sdrsceneattribute3d.hxx> +#include <drawinglayer/attribute/sdrlightingattribute3d.hxx> + +namespace drawinglayer::primitive2d +{ + /** ScenePrimitive2D class + + This primitive defines a 3D scene as a 2D primitive and is the anchor point + for a 3D visualisation. The decomposition is view-dependent and will try to + re-use already rendered 3D content. + + The rendering is done using the default-3D renderer from basegfx which supports + AntiAliasing. + + The 2D primitive's geometric range is defined completely by the + ObjectTransformation combined with evtl. 2D shadows from the 3D objects. The + shadows of 3D objects are 2D polygons, projected with the 3D transformation. + + This is the class a renderer may process directly when he wants to implement + an own (e.g. system-specific) 3D renderer. + */ + class DRAWINGLAYER_DLLPUBLIC ScenePrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the 3D geometry definition + primitive3d::Primitive3DContainer mxChildren3D; + + /// 3D scene attribute set + attribute::SdrSceneAttribute maSdrSceneAttribute; + + /// lighting attribute set + attribute::SdrLightingAttribute maSdrLightingAttribute; + + /// object transformation for scene for 2D definition + basegfx::B2DHomMatrix maObjectTransformation; + + /// scene transformation set and object transformation + geometry::ViewInformation3D maViewInformation3D; + + /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) + Primitive2DContainer maShadowPrimitives; + + /** flag if given 3D geometry is already checked for shadow definitions and 2d shadows + are created in maShadowPrimitives + */ + bool mbShadow3DChecked : 1; + + /// the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition + double mfOldDiscreteSizeX; + double mfOldDiscreteSizeY; + basegfx::B2DRange maOldUnitVisiblePart; + + /** the last created BitmapEx, e.g. for fast HitTest. This does not really need + memory since BitmapEx is internally RefCounted + */ + BitmapEx maOldRenderedBitmap; + + /// private helpers + bool impGetShadow3D() const; + void calculateDiscreteSizes( + const geometry::ViewInformation2D& rViewInformation, + basegfx::B2DRange& rDiscreteRange, + basegfx::B2DRange& rVisibleDiscreteRange, + basegfx::B2DRange& rUnitVisibleRange) const; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// public helpers + /** Geometry extractor. Shadow will be added as in create2DDecomposition, but + the 3D content is not converted to a bitmap visualisation but to projected 2D geometry. This + helper is useful e.g. for Contour extraction or HitTests. + */ + Primitive2DContainer getGeometry2D() const; + Primitive2DContainer getShadow2D() const; + + /** Fast HitTest which uses the last buffered BitmapEx from the last + rendered area if available. The return value describes if the check + could be done with the current information, so do NOT use o_rResult + when it returns false. o_rResult will be changed on return true and + then contains a definitive answer if content of this scene is hit or + not. On return false, it is normally necessary to use the geometric + HitTest (see CutFindProcessor usages). The given HitPoint + has to be in logic coordinates in scene's ObjectCoordinateSystem. + */ + bool tryToCheckLastVisualisationDirectHit(const basegfx::B2DPoint& rLogicHitPoint, bool& o_rResult) const; + + /// constructor + ScenePrimitive2D( + primitive3d::Primitive3DContainer xChildren3D, + attribute::SdrSceneAttribute aSdrSceneAttribute, + attribute::SdrLightingAttribute aSdrLightingAttribute, + basegfx::B2DHomMatrix aObjectTransformation, + geometry::ViewInformation3D aViewInformation3D); + + /// data read access + const primitive3d::Primitive3DContainer& getChildren3D() const { return mxChildren3D; } + const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; } + const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; } + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// get local decomposition. Override since this decomposition is view-dependent + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/sdrdecompositiontools2d.hxx b/include/drawinglayer/primitive2d/sdrdecompositiontools2d.hxx new file mode 100644 index 0000000000..408abe952a --- /dev/null +++ b/include/drawinglayer/primitive2d/sdrdecompositiontools2d.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <basegfx/range/b2drange.hxx> +#include <drawinglayer/primitive2d/CommonTypes.hxx> + + +// predefines + +namespace basegfx { + class B2DPolyPolygon; + class B2DHomMatrix; +} + + +namespace drawinglayer::primitive2d +{ + // helpers to create HitTestPrimitives Line + Primitive2DReference DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives2D( + const basegfx::B2DHomMatrix& rMatrix); + + Primitive2DReference DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives2D( + const basegfx::B2DPolyPolygon& rPolygon); + + Primitive2DReference DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives2D( + bool bFilled, + const basegfx::B2DRange& rRange); + + Primitive2DReference DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives2D( + bool bFilled, + const basegfx::B2DRange& rRange, + const basegfx::B2DHomMatrix& rMatrix); + + Primitive2DReference DRAWINGLAYER_DLLPUBLIC createHiddenGeometryPrimitives2D( + bool bFilled, + const basegfx::B2DPolyPolygon& rPolygon, + const basegfx::B2DHomMatrix& rMatrix); + +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/shadowprimitive2d.hxx b/include/drawinglayer/primitive2d/shadowprimitive2d.hxx new file mode 100644 index 0000000000..39dcbca9fa --- /dev/null +++ b/include/drawinglayer/primitive2d/shadowprimitive2d.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +namespace drawinglayer::primitive2d +{ +/** ShadowPrimitive2D class + + This primitive defines a generic shadow geometry construction + for 2D objects. It decomposes to a TransformPrimitive2D embedded + into a ModifiedColorPrimitive2D. + + It's for primitive usage convenience, so that not everyone has + to implement the generic shadow construction by himself. + + The same geometry as sequence of primitives is used as geometry and + as shadow. Since these are RefCounted Uno-Api objects, no extra objects + are needed for the shadow itself; all the local decompositions of the + original geometry can be reused from the renderer for shadow visualisation. + */ +class DRAWINGLAYER_DLLPUBLIC ShadowPrimitive2D final : public BufferedDecompositionGroupPrimitive2D +{ +private: + /// the shadow transformation, normally just an offset + basegfx::B2DHomMatrix maShadowTransform; + + /// the shadow color to which all geometry is to be forced + basegfx::BColor maShadowColor; + + /// the blur radius of the shadow + double mfShadowBlur; + + /// last used DiscreteBlurRadius and ClippedRange + double mfLastDiscreteBlurRadius; + basegfx::B2DRange maLastClippedRange; + + /// helpers + void getFullyEmbeddedShadowPrimitives(Primitive2DContainer& rContainer) const; + bool prepareValuesAndcheckValidity(basegfx::B2DRange& rRange, basegfx::B2DRange& rClippedRange, + basegfx::B2DVector& rDiscreteSize, + double& rfDiscreteBlurRadius, + const geometry::ViewInformation2D& rViewInformation) const; + +protected: + /** method which is to be used to implement the local decomposition of a 2D primitive. */ + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + ShadowPrimitive2D(basegfx::B2DHomMatrix aShadowTransform, const basegfx::BColor& rShadowColor, + double fShadowBlur, Primitive2DContainer&& aChildren); + + /// data read access + const basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } + const basegfx::BColor& getShadowColor() const { return maShadowColor; } + double getShadowBlur() const { return mfShadowBlur; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// create decomposition + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/softedgeprimitive2d.hxx b/include/drawinglayer/primitive2d/softedgeprimitive2d.hxx new file mode 100644 index 0000000000..4a49444560 --- /dev/null +++ b/include/drawinglayer/primitive2d/softedgeprimitive2d.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/BufferedDecompositionGroupPrimitive2D.hxx> + +namespace drawinglayer::primitive2d +{ +class DRAWINGLAYER_DLLPUBLIC SoftEdgePrimitive2D final + : public BufferedDecompositionGroupPrimitive2D +{ +private: + /// Soft edge size, in logical units (100ths of mm) + double mfRadius; + + /// last used DiscreteSoftRadius and ClippedRange + double mfLastDiscreteSoftRadius; + basegfx::B2DRange maLastClippedRange; + + /// helpers + bool prepareValuesAndcheckValidity(basegfx::B2DRange& rSoftRange, + basegfx::B2DRange& rClippedRange, + basegfx::B2DVector& rDiscreteSoftSize, + double& rfDiscreteSoftRadius, + const geometry::ViewInformation2D& rViewInformation) const; + +protected: + /** method which is to be used to implement the local decomposition of a 2D primitive. */ + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + SoftEdgePrimitive2D(double fRadius, Primitive2DContainer&& aChildren); + + /// data read access + double getRadius() const { return mfRadius; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// The default implementation will return an empty sequence + virtual void + get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, + const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/structuretagprimitive2d.hxx b/include/drawinglayer/primitive2d/structuretagprimitive2d.hxx new file mode 100644 index 0000000000..0d7e6ba577 --- /dev/null +++ b/include/drawinglayer/primitive2d/structuretagprimitive2d.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <vcl/pdfwriter.hxx> + + +namespace drawinglayer::primitive2d +{ + /** StructureTagPrimitive2D class + + This class is used to provide simple support for adding grouped + pdf writer structured element information like used in sd from + unomodel.cxx where a ViewObjectContactRedirector is used to add + such information for diverse objects. + This primitive encapsulates these and the VCLPdfRenderer uses it + to apply the needed infos directly to the pdf export in a compatible + way. + If a renderer ignores this, it just decomposes to its child + content. + */ + class DRAWINGLAYER_DLLPUBLIC StructureTagPrimitive2D final : public GroupPrimitive2D + { + private: + /// the PDF structure element this grouping represents + vcl::PDFWriter::StructElement maStructureElement; + + /// flag for background object + bool mbBackground; + /// flag for image (OBJ_GRAF) + bool mbIsImage; + /// anchor structure element (Writer) + void const* m_pAnchorStructureElementKey; + /// for Annot structure element, the ids of the annotations + ::std::vector<sal_Int32> m_AnnotIds; + + public: + /// constructor + StructureTagPrimitive2D( + const vcl::PDFWriter::StructElement& rStructureElement, + bool bBackground, + bool bIsImage, + Primitive2DContainer&& aChildren, + void const* pAnchorStructureElementKey = nullptr, + ::std::vector<sal_Int32> const* pAnnotIds = nullptr); + + /// data read access + const vcl::PDFWriter::StructElement& getStructureElement() const { return maStructureElement; } + bool isBackground() const { return mbBackground; } + bool isImage() const { return mbIsImage; } + bool isTaggedSdrObject() const; + void const* GetAnchorStructureElementKey() const { return m_pAnchorStructureElementKey; } + ::std::vector<sal_Int32> GetAnnotIds() const { return m_AnnotIds; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx b/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx new file mode 100644 index 0000000000..119ccb3b5f --- /dev/null +++ b/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx @@ -0,0 +1,369 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vector> + + +// SvgGradientEntry class + +namespace drawinglayer::primitive2d +{ + /// a single GradientStop defining a color and opacity at a distance + class SvgGradientEntry + { + private: + double mfOffset; + basegfx::BColor maColor; + double mfOpacity; + + public: + SvgGradientEntry(double fOffset, const basegfx::BColor& rColor, double fOpacity) + : mfOffset(fOffset), + maColor(rColor), + mfOpacity(fOpacity) + { + } + + double getOffset() const { return mfOffset; } + const basegfx::BColor& getColor() const { return maColor; } + double getOpacity() const { return mfOpacity; } + + bool operator==(const SvgGradientEntry& rCompare) const + { + return (getOffset() == rCompare.getOffset() + && getColor() == rCompare.getColor() + && getOpacity() == rCompare.getOpacity()); + } + + bool operator<(const SvgGradientEntry& rCompare) const + { + return getOffset() < rCompare.getOffset(); + } + }; + + typedef ::std::vector< SvgGradientEntry > SvgGradientEntryVector; + + // SvgGradientHelper class + + enum class SpreadMethod + { + Pad, + Reflect, + Repeat + }; + + /* helper for linear and radial gradient, both get derived from this + to share common definitions and functionality + **/ + class SAL_LOPLUGIN_ANNOTATE("crosscast") SvgGradientHelper + { + private: + /// the extra gradient transform + basegfx::B2DHomMatrix maGradientTransform; + + /// geometric definition, the geometry to be filled + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the gradient definition + SvgGradientEntryVector maGradientEntries; + + // internal helper for case SpreadMethod::Reflect + SvgGradientEntryVector maMirroredGradientEntries; + + /// start and/or center point + basegfx::B2DPoint maStart; + + /// how to spread + SpreadMethod maSpreadMethod; + + bool mbPreconditionsChecked : 1; + bool mbCreatesContent : 1; + bool mbSingleEntry : 1; + bool mbFullyOpaque : 1; + + // true = interpret in unit coordinate system -> object aspect ratio will scale result + // false = interpret in object coordinate system -> object aspect ratio will not scale result + // (related to SVG's gradientUnits (userSpaceOnUse|objectBoundingBox) + bool mbUseUnitCoordinates : 1; + + /// local helpers + const SvgGradientEntryVector& getMirroredGradientEntries() const; + void createMirroredGradientEntries(); + const SvgGradientEntry& FindEntryLessOrEqual(sal_Int32& rInt, const double fFrac) const; + const SvgGradientEntry& FindEntryMore(sal_Int32& rInt,const double fFrac) const; + + protected: + /// local helpers + void createSingleGradientEntryFill(Primitive2DContainer& rContainer) const; + virtual void createAtom( + Primitive2DContainer& rTargetColor, + Primitive2DContainer& rTargetOpacity, + const SvgGradientEntry& rFrom, + const SvgGradientEntry& rTo, + sal_Int32 nOffsetFrom, + sal_Int32 nOffsetTo) const = 0; + void createRun( + Primitive2DContainer& rTargetColor, + Primitive2DContainer& rTargetOpacity, + double fStart, + double fEnd) const; + virtual void checkPreconditions(); + void createResult( + Primitive2DContainer& rContainer, + Primitive2DContainer aTargetColor, + Primitive2DContainer aTargetOpacity, + const basegfx::B2DHomMatrix& rUnitGradientToObject, + bool bInvert = false) const; + bool getCreatesContent() const { return mbCreatesContent; } + bool getSingleEntry() const { return mbSingleEntry; } + void setSingleEntry() { mbSingleEntry = true; } + bool getPreconditionsChecked() const { return mbPreconditionsChecked; } + bool getFullyOpaque() const { return mbFullyOpaque; } + + public: + /// constructor + SvgGradientHelper( + basegfx::B2DHomMatrix aGradientTransform, + basegfx::B2DPolyPolygon aPolyPolygon, + SvgGradientEntryVector&& rGradientEntries, + const basegfx::B2DPoint& rStart, + bool bUseUnitCoordinates, + SpreadMethod aSpreadMethod); + virtual ~SvgGradientHelper(); + + /// data read access + const basegfx::B2DHomMatrix& getGradientTransform() const { return maGradientTransform; } + const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } + const SvgGradientEntryVector& getGradientEntries() const { return maGradientEntries; } + const basegfx::B2DPoint& getStart() const { return maStart; } + bool getUseUnitCoordinates() const { return mbUseUnitCoordinates; } + SpreadMethod getSpreadMethod() const { return maSpreadMethod; } + + /// compare operator + bool operator==(const SvgGradientHelper& rSvgGradientHelper) const; + }; + + /// the basic linear gradient primitive + class DRAWINGLAYER_DLLPUBLIC SvgLinearGradientPrimitive2D final : public BufferedDecompositionPrimitive2D, public SvgGradientHelper + { + private: + /// the end point for linear gradient + basegfx::B2DPoint maEnd; + + /// local helpers + virtual void createAtom( + Primitive2DContainer& rTargetColor, + Primitive2DContainer& rTargetOpacity, + const SvgGradientEntry& rFrom, + const SvgGradientEntry& rTo, + sal_Int32 nOffsetFrom, + sal_Int32 nOffsetTo) const override; + virtual void checkPreconditions() override; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + SvgLinearGradientPrimitive2D( + const basegfx::B2DHomMatrix& rGradientTransform, + const basegfx::B2DPolyPolygon& rPolyPolygon, + SvgGradientEntryVector&& rGradientEntries, + const basegfx::B2DPoint& rStart, + const basegfx::B2DPoint& rEnd, + bool bUseUnitCoordinates, + SpreadMethod aSpreadMethod); + virtual ~SvgLinearGradientPrimitive2D() override; + + /// data read access + const basegfx::B2DPoint& getEnd() const { return maEnd; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /// the basic radial gradient primitive + class DRAWINGLAYER_DLLPUBLIC SvgRadialGradientPrimitive2D final : public BufferedDecompositionPrimitive2D, public SvgGradientHelper + { + private: + /// the geometric definition + double mfRadius; + + /// Focal only used when focal is set at all, see constructors + basegfx::B2DPoint maFocal; + basegfx::B2DVector maFocalVector; + double maFocalLength; + + bool mbFocalSet : 1; + + /// local helpers + virtual void createAtom( + Primitive2DContainer& rTargetColor, + Primitive2DContainer& rTargetOpacity, + const SvgGradientEntry& rFrom, + const SvgGradientEntry& rTo, + sal_Int32 nOffsetFrom, + sal_Int32 nOffsetTo) const override; + virtual void checkPreconditions() override; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + SvgRadialGradientPrimitive2D( + const basegfx::B2DHomMatrix& rGradientTransform, + const basegfx::B2DPolyPolygon& rPolyPolygon, + SvgGradientEntryVector&& rGradientEntries, + const basegfx::B2DPoint& rStart, + double fRadius, + bool bUseUnitCoordinates, + SpreadMethod aSpreadMethod, + const basegfx::B2DPoint* pFocal); + virtual ~SvgRadialGradientPrimitive2D() override; + + /// data read access + double getRadius() const { return mfRadius; } + const basegfx::B2DPoint& getFocal() const { return maFocal; } + bool isFocalSet() const { return mbFocalSet; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + // SvgLinearAtomPrimitive2D class + + /* basic primitive for a single linear GradientRun in unit coordinates. + It's derived from DiscreteMetricDependentPrimitive2D to allow view-dependent + decompositions allowing reduced color steps + **/ + class SvgLinearAtomPrimitive2D final : public DiscreteMetricDependentPrimitive2D + { + private: + /// the geometric definition in unit coordinates + basegfx::BColor maColorA; + basegfx::BColor maColorB; + double mfOffsetA; + double mfOffsetB; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + SvgLinearAtomPrimitive2D( + const basegfx::BColor& aColorA, double fOffsetA, + const basegfx::BColor& aColorB, double fOffsetB); + + /// data read access + const basegfx::BColor& getColorA() const { return maColorA; } + const basegfx::BColor& getColorB() const { return maColorB; } + double getOffsetA() const { return mfOffsetA; } + double getOffsetB() const { return mfOffsetB; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + // SvgRadialAtomPrimitive2D class + + /* basic primitive for a single radial GradientRun in unit coordinates. + It's derived from DiscreteMetricDependentPrimitive2D to allow view-dependent + decompositions allowing reduced color steps + **/ + class SvgRadialAtomPrimitive2D final : public DiscreteMetricDependentPrimitive2D + { + private: + /// the geometric definition in unit coordinates + basegfx::BColor maColorA; + basegfx::BColor maColorB; + double mfScaleA; + double mfScaleB; + + // helper to hold translation vectors when given (for focal) + struct VectorPair + { + basegfx::B2DVector maTranslateA; + basegfx::B2DVector maTranslateB; + + VectorPair(const basegfx::B2DVector& rTranslateA, const basegfx::B2DVector& rTranslateB) + : maTranslateA(rTranslateA), + maTranslateB(rTranslateB) + { + } + }; + + /// Only used when focal is set + std::unique_ptr<VectorPair> mpTranslate; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + SvgRadialAtomPrimitive2D( + const basegfx::BColor& aColorA, double fScaleA, const basegfx::B2DVector& rTranslateA, + const basegfx::BColor& aColorB, double fScaleB, const basegfx::B2DVector& rTranslateB); + SvgRadialAtomPrimitive2D( + const basegfx::BColor& aColorA, double fScaleA, + const basegfx::BColor& aColorB, double fScaleB); + virtual ~SvgRadialAtomPrimitive2D() override; + + /// data read access + const basegfx::BColor& getColorA() const { return maColorA; } + const basegfx::BColor& getColorB() const { return maColorB; } + double getScaleA() const { return mfScaleA; } + double getScaleB() const { return mfScaleB; } + bool isTranslateSet() const { return (nullptr != mpTranslate); } + basegfx::B2DVector getTranslateA() const { if(mpTranslate) return mpTranslate->maTranslateA; return basegfx::B2DVector(); } + basegfx::B2DVector getTranslateB() const { if(mpTranslate) return mpTranslate->maTranslateB; return basegfx::B2DVector(); } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/textbreakuphelper.hxx b/include/drawinglayer/primitive2d/textbreakuphelper.hxx new file mode 100644 index 0000000000..8bee843e88 --- /dev/null +++ b/include/drawinglayer/primitive2d/textbreakuphelper.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> + +namespace drawinglayer::primitive2d { class TextSimplePortionPrimitive2D; } + + +namespace drawinglayer::primitive2d +{ + enum class BreakupUnit + { + Character, + Word + }; + + class DRAWINGLAYER_DLLPUBLIC TextBreakupHelper + { + private: + const TextSimplePortionPrimitive2D& mrSource; + Primitive2DContainer mxResult; + TextLayouterDevice maTextLayouter; + basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose maDecTrans; + + bool mbNoDXArray : 1; + + /// create a portion from nIndex to nLength and append to rTempResult + void breakupPortion(Primitive2DContainer& rTempResult, sal_Int32 nIndex, sal_Int32 nLength, bool bWordLineMode); + + /// breakup complete primitive + void breakup(BreakupUnit aBreakupUnit); + + protected: + /// allow user callback to allow changes to the new TextTransformation. Default + /// does nothing. Retval defines if a primitive gets created, e.g. return false + /// to suppress creation + virtual bool allowChange(sal_uInt32 nCount, basegfx::B2DHomMatrix& rNewTransform, sal_uInt32 nIndex, sal_uInt32 nLength); + + /// allow read access to evtl. useful local parts + const TextLayouterDevice& getTextLayouter() const { return maTextLayouter; } + const TextSimplePortionPrimitive2D& getSource() const { return mrSource; } + + public: + TextBreakupHelper(const TextSimplePortionPrimitive2D& rSource); + virtual ~TextBreakupHelper(); + + /// get result + Primitive2DContainer extractResult(BreakupUnit aBreakupUnit = BreakupUnit::Character); + }; + +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/include/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx new file mode 100644 index 0000000000..a854a88337 --- /dev/null +++ b/include/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> + +namespace basegfx::utils { + class B2DHomMatrixBufferedOnDemandDecompose; +} + +namespace drawinglayer::primitive2d +{ + /** TextDecoratedPortionPrimitive2D class + + This primitive expands the TextSimplePortionPrimitive2D by common + decorations used in the office. It can be decomposed and will create + a TextSimplePortionPrimitive2D and all the contained decorations (if used) + as geometry. + */ + class DRAWINGLAYER_DLLPUBLIC TextDecoratedPortionPrimitive2D final : public TextSimplePortionPrimitive2D + { + private: + /// decoration definitions + basegfx::BColor maOverlineColor; + basegfx::BColor maTextlineColor; + TextLine meFontOverline; + TextLine meFontUnderline; + TextStrikeout meTextStrikeout; + TextEmphasisMark meTextEmphasisMark; + TextRelief meTextRelief; + + bool mbUnderlineAbove : 1; + bool mbWordLineMode : 1; + bool mbEmphasisMarkAbove : 1; + bool mbEmphasisMarkBelow : 1; + bool mbShadow : 1; + + /// helper methods + void impCreateGeometryContent( + Primitive2DContainer& rTarget, + basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose const & rDecTrans, + const OUString& rText, + sal_Int32 nTextPosition, + sal_Int32 nTextLength, + const ::std::vector< double >& rDXArray, + const ::std::vector< sal_Bool >& rKashidaArray, + const attribute::FontAttribute& rFontAttribute) const; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextDecoratedPortionPrimitive2D( + /// TextSimplePortionPrimitive2D parameters + const basegfx::B2DHomMatrix& rNewTransform, + const OUString& rText, + sal_Int32 nTextPosition, + sal_Int32 nTextLength, + std::vector< double >&& rDXArray, + std::vector< sal_Bool >&& rKashidaArray, + const attribute::FontAttribute& rFontAttribute, + const css::lang::Locale& rLocale, + const basegfx::BColor& rFontColor, + const Color& rFillColor, + + /// local parameters + const basegfx::BColor& rOverlineColor, + const basegfx::BColor& rTextlineColor, + TextLine eFontOverline = TEXT_LINE_NONE, + TextLine eFontUnderline = TEXT_LINE_NONE, + bool bUnderlineAbove = false, + TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE, + bool bWordLineMode = false, + TextEmphasisMark eTextEmphasisMark = TEXT_FONT_EMPHASIS_MARK_NONE, + bool bEmphasisMarkAbove = true, + bool bEmphasisMarkBelow = false, + TextRelief eTextRelief = TEXT_RELIEF_NONE, + bool bShadow = false); + + /// data read access + TextLine getFontOverline() const { return meFontOverline; } + TextLine getFontUnderline() const { return meFontUnderline; } + TextStrikeout getTextStrikeout() const { return meTextStrikeout; } + TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; } + TextRelief getTextRelief() const { return meTextRelief; } + const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } + const basegfx::BColor& getTextlineColor() const { return maTextlineColor; } + bool getUnderlineAbove() const { return mbUnderlineAbove; } + bool getWordLineMode() const { return mbWordLineMode; } + bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; } + bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow; } + bool getShadow() const { return mbShadow; } + + void CreateDecorationGeometryContent( + Primitive2DContainer& rTarget, + basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose const & rDecTrans, + const OUString& rText, + sal_Int32 nTextPosition, + sal_Int32 nTextLength, + const std::vector< double >& rDXArray) const; + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/textenumsprimitive2d.hxx b/include/drawinglayer/primitive2d/textenumsprimitive2d.hxx new file mode 100644 index 0000000000..1017888d10 --- /dev/null +++ b/include/drawinglayer/primitive2d/textenumsprimitive2d.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <tools/fontenum.hxx> + + +namespace drawinglayer::primitive2d +{ + /** TextLine definition + + This is used for both underline and overline + */ + enum TextLine + { + TEXT_LINE_NONE, + TEXT_LINE_SINGLE, + TEXT_LINE_DOUBLE, + TEXT_LINE_DOTTED, + TEXT_LINE_DASH, + TEXT_LINE_LONGDASH, + TEXT_LINE_DASHDOT, + TEXT_LINE_DASHDOTDOT, + TEXT_LINE_SMALLWAVE, + TEXT_LINE_WAVE, + TEXT_LINE_DOUBLEWAVE, + TEXT_LINE_BOLD, + TEXT_LINE_BOLDDOTTED, + TEXT_LINE_BOLDDASH, + TEXT_LINE_BOLDLONGDASH, + TEXT_LINE_BOLDDASHDOT, + TEXT_LINE_BOLDDASHDOTDOT, + TEXT_LINE_BOLDWAVE + }; + + /** helper to convert LineStyle */ + TextLine DRAWINGLAYER_DLLPUBLIC mapFontLineStyleToTextLine(FontLineStyle eLineStyle); + FontLineStyle DRAWINGLAYER_DLLPUBLIC mapTextLineToFontLineStyle(TextLine eLineStyle); + + /** FontStrikeout definition */ + enum TextStrikeout + { + TEXT_STRIKEOUT_NONE, + TEXT_STRIKEOUT_SINGLE, + TEXT_STRIKEOUT_DOUBLE, + TEXT_STRIKEOUT_BOLD, + TEXT_STRIKEOUT_SLASH, + TEXT_STRIKEOUT_X + }; + + /** helper to convert FontStrikeout */ + TextStrikeout DRAWINGLAYER_DLLPUBLIC mapFontStrikeoutToTextStrikeout(::FontStrikeout eFontStrikeout); + ::FontStrikeout DRAWINGLAYER_DLLPUBLIC mapTextStrikeoutToFontStrikeout(TextStrikeout eFontStrikeout); + + /** TextEmphasisMark definition */ + enum TextEmphasisMark + { + TEXT_FONT_EMPHASIS_MARK_NONE, + TEXT_FONT_EMPHASIS_MARK_DOT, + TEXT_FONT_EMPHASIS_MARK_CIRCLE, + TEXT_FONT_EMPHASIS_MARK_DISC, + TEXT_FONT_EMPHASIS_MARK_ACCENT + }; + + /** TextRelief definition */ + enum TextRelief + { + TEXT_RELIEF_NONE, + TEXT_RELIEF_EMBOSSED, + TEXT_RELIEF_ENGRAVED + }; + +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx b/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx new file mode 100644 index 0000000000..da388d935e --- /dev/null +++ b/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <rtl/ustring.hxx> + + +namespace drawinglayer::primitive2d +{ + /** TextHierarchyLinePrimitive2D class + + Text format hierarchy helper class. It decomposes to its + content, so all direct renderers may ignore it. If You need + to know more about line hierarchies You may react on it and + also need to take care that the source of data uses it. + + This primitive encapsulates text lines. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyLinePrimitive2D final : public GroupPrimitive2D + { + private: + public: + /// constructor + explicit TextHierarchyLinePrimitive2D(Primitive2DContainer&& aChildren); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /** TextHierarchyBulletPrimitive2D class + + This primitive encapsulates text bullets. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyBulletPrimitive2D final : public GroupPrimitive2D + { + private: + public: + /// constructor + explicit TextHierarchyBulletPrimitive2D(Primitive2DContainer&& aChildren); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /** TextHierarchyParagraphPrimitive2D class + + This primitive encapsulates text paragraphs. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyParagraphPrimitive2D final : public GroupPrimitive2D + { + private: + // outline level of the encapsulated paragraph data. + // -1 means no level, >= 0 is the level + sal_Int16 mnOutlineLevel; + + public: + /// constructor + explicit TextHierarchyParagraphPrimitive2D( + Primitive2DContainer&& aChildren, + sal_Int16 nOutlineLevel = -1); + + /// data read access + sal_Int16 getOutlineLevel() const { return mnOutlineLevel; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /** TextHierarchyBlockPrimitive2D class + + This primitive encapsulates text blocks. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyBlockPrimitive2D final : public GroupPrimitive2D + { + private: + public: + /// constructor + explicit TextHierarchyBlockPrimitive2D(Primitive2DContainer&& aChildren); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /** FieldType definition */ + enum FieldType + { + /** unspecified. If more info is needed for a FieldType, + create a new type and its handling + */ + FIELD_TYPE_COMMON, + + /** uses "FIELD_SEQ_BEGIN;PageField" -> special handling */ + FIELD_TYPE_PAGE, + + /** uses URL as string -> special handling */ + FIELD_TYPE_URL + }; + + /** TextHierarchyFieldPrimitive2D class + + This primitive encapsulates text fields. + Also: This type uses a type enum to transport the encapsulated field + type. Also added is a String which is type-dependent. E.g. for URL + fields, it contains the URL. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyFieldPrimitive2D final : public GroupPrimitive2D + { + private: + /// field type definition + FieldType meType; + + /// field data as name/value pairs (dependent of field type definition) + std::vector< std::pair< OUString, OUString>> meNameValue; + + public: + /// constructor + TextHierarchyFieldPrimitive2D( + Primitive2DContainer&& aChildren, + const FieldType& rFieldType, + const std::vector< std::pair< OUString, OUString>>* pNameValue = nullptr); + + /// data read access + FieldType getType() const { return meType; } + OUString getValue(const OUString& rName) const; + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + + /** TextHierarchyEditPrimitive2D class + + Primitive to encapsulate text from an active text edit; this is + separate from other text data since some renderers need to suppress + this output due to painting the edited text in e.g. an + OutlinerEditView in the active text edit control. + Deriving now from BasePrimitive2D to turn around functionality: + This will decompose to nothing -> suppress. In renderers that need to + visualize it (only VclMetafileProcessor2D for now), it needs + to be detected and used (see there). + Doing it this way around since we will potentially have many + pixel renderers and only one MetafileProcessor, so it will + be one action less to support (and to potentially forget about ) + in these implementations. + */ + class DRAWINGLAYER_DLLPUBLIC TextHierarchyEditPrimitive2D final : public BasePrimitive2D + { + private: + /// the content + Primitive2DContainer maContent; + + public: + /// constructor + explicit TextHierarchyEditPrimitive2D(Primitive2DContainer&& aContent); + + /// data read access + const Primitive2DContainer& getContent() const { return maContent; } + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/textlayoutdevice.hxx b/include/drawinglayer/primitive2d/textlayoutdevice.hxx new file mode 100644 index 0000000000..6f98b50a4f --- /dev/null +++ b/include/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <basegfx/range/b2drange.hxx> +#include <vector> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <vcl/svapp.hxx> + +// predefines +class VirtualDevice; +class GDIMetaFile; +enum class DrawTextFlags; +namespace vcl +{ +class Font; +} +namespace tools +{ +class Rectangle; +} +namespace drawinglayer::attribute +{ +class FontAttribute; +} +namespace com::sun::star::lang +{ +struct Locale; +} + +// access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive + +namespace drawinglayer::primitive2d +{ +/** TextLayouterDevice class + + This helper class exists to isolate all accesses to VCL + text formatting/handling functionality for primitive implementations. + When in the future FontHandling may move to an own library independent + from VCL, primitives will be prepared. + */ +class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice +{ + /// internally used VirtualDevice + SolarMutexGuard maSolarGuard; + VirtualDevice& mrDevice; + +public: + /// constructor/destructor + TextLayouterDevice(); + ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE; + + /// tooling methods + void setFont(const vcl::Font& rFont); + void setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX, + double fFontScaleY, const css::lang::Locale& rLocale); + + double getTextHeight() const; + double getOverlineHeight() const; + double getOverlineOffset() const; + double getUnderlineHeight() const; + double getUnderlineOffset() const; + double getStrikeoutOffset() const; + + double getTextWidth(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const; + + void getTextOutlines(basegfx::B2DPolyPolygonVector&, const OUString& rText, sal_uInt32 nIndex, + sal_uInt32 nLength, const ::std::vector<double>& rDXArray, + const ::std::vector<sal_Bool>& rKashidaArray) const; + + basegfx::B2DRange getTextBoundRect(const OUString& rText, sal_uInt32 nIndex, + sal_uInt32 nLength) const; + + double getFontAscent() const; + double getFontDescent() const; + + void addTextRectActions(const tools::Rectangle& rRectangle, const OUString& rText, + DrawTextFlags nStyle, GDIMetaFile& rGDIMetaFile) const; + + ::std::vector<double> getTextArray(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength, + bool bCaret = false) const; +}; + +// helper methods for vcl font handling + +/** Create a VCL-Font based on the definitions in FontAttribute + and the given FontScaling. The FontScaling defines the FontHeight + (fFontScaleY) and the FontWidth (fFontScaleX). The combination of + both defines FontStretching, where no stretching happens at + fFontScaleY == fFontScaleX + */ +vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute( + const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, + double fFontRotation, const css::lang::Locale& rLocale); + +/** Generate FontAttribute DataSet derived from the given VCL-Font. + The FontScaling with fFontScaleY, fFontScaleX relationship (see + above) will be set in return parameter o_rSize to allow further + processing + */ +attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont( + basegfx::B2DVector& o_rSize, const vcl::Font& rFont, bool bRTL, bool bBiDiStrong); + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx b/include/drawinglayer/primitive2d/textprimitive2d.hxx new file mode 100644 index 0000000000..4182b0c0fb --- /dev/null +++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <rtl/ustring.hxx> +#include <tools/color.hxx> +#include <tools/long.hxx> +#include <basegfx/color/bcolor.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <vector> + +namespace drawinglayer::primitive2d +{ +/** TextSimplePortionPrimitive2D class + + This is the basic primitive for representing a text portion. It contains + all needed information. If it is not handled by a renderer, its decomposition + will provide the text tools::PolyPolygon outlines as filled polygons, correctly + transformed. + + To get better text quality, it is suggested to handle this primitive directly + in a renderer. In that case, e.g. hintings on the system can be supported. + + @param maTextTransform + The text transformation contains the text start position (always baselined) + as translation, the FontSize as scale (where width relative to height defines + font scaling and width == height means no font scaling) and the font rotation + and shear. + When shear is used and a renderer does not support it, it may be better to use + the decomposition which will do everything correctly. Same is true for mirroring + which would be expressed as negative scalings. + + @param rText + The text to be used. Only a part may be used, but a bigger part of the string + may be necessary for correct layouting (e.g. international) + + @param aTextPosition + The index to the first character to use from rText + + @param aTextLength + The number of characters to use from rText + + @param rDXArray + The distances between the characters. This parameter may be empty, in that case + the renderer is responsible to do something useful. If it is given, it has to be of + the size aTextLength. Its values are in logical coordinates and describe the + distance for each character to use. This is independent from the font width which + is given with maTextTransform. The first value is the offset to use from the start + point in FontCoordinateSystem X-Direction (given by maTextTransform) to the start + point of the second character + + @param rKashidaArray + The Kashida insertion positions. + + @param rFontAttribute + The font definition + + @param rLocale + The locale to use + + @param rFontColor + The font color to use + + @param bFilled + + @param nWidthToFill + + @param rTextFillColor + Text background color (has nothing to do with bFilled and nWidthToFill) + + */ +class DRAWINGLAYER_DLLPUBLIC TextSimplePortionPrimitive2D : public BufferedDecompositionPrimitive2D +{ +private: + /// text transformation (FontCoordinateSystem) + basegfx::B2DHomMatrix maTextTransform; + + /// The text, used from maTextPosition up to maTextPosition + maTextLength + OUString maText; + + /// The index from where on maText is used + sal_Int32 mnTextPosition; + + /// The length for maText usage, starting from maTextPosition + sal_Int32 mnTextLength; + + /// The DX array in logic units + std::vector<double> maDXArray; + + /// The Kashida array + std::vector<sal_Bool> maKashidaArray; + + /// The font definition + attribute::FontAttribute maFontAttribute; + + /// The Locale for the text + css::lang::Locale maLocale; + + /// font color + basegfx::BColor maFontColor; + + // Whether to fill a given width with the text + bool mbFilled; + + // the width to fill + tools::Long mnWidthToFill; + + /// The fill color of the text + Color maTextFillColor; + + /// #i96669# internal: add simple range buffering for this primitive + basegfx::B2DRange maB2DRange; + +protected: + /// local decomposition. + virtual void + create2DDecomposition(Primitive2DContainer& rContainer, + const geometry::ViewInformation2D& rViewInformation) const override; + +public: + /// constructor + TextSimplePortionPrimitive2D(basegfx::B2DHomMatrix aNewTransform, OUString aText, + sal_Int32 nTextPosition, sal_Int32 nTextLength, + std::vector<double>&& rDXArray, + std::vector<sal_Bool>&& rKashidaArray, + attribute::FontAttribute aFontAttribute, css::lang::Locale aLocale, + const basegfx::BColor& rFontColor, bool bFilled = false, + tools::Long nWidthToFill = 0, + const Color& rTextFillColor = COL_TRANSPARENT); + + /** get text outlines as polygons and their according ObjectTransformation. Handles all + the necessary VCL outline extractions, scaling adaptations and other stuff. + */ + void getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector& rTarget, + basegfx::B2DHomMatrix& rTransformation) const; + + /// data read access + const basegfx::B2DHomMatrix& getTextTransform() const { return maTextTransform; } + const OUString& getText() const { return maText; } + sal_Int32 getTextPosition() const { return mnTextPosition; } + sal_Int32 getTextLength() const { return mnTextLength; } + const ::std::vector<double>& getDXArray() const { return maDXArray; } + const ::std::vector<sal_Bool>& getKashidaArray() const { return maKashidaArray; } + const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; } + const css::lang::Locale& getLocale() const { return maLocale; } + const basegfx::BColor& getFontColor() const { return maFontColor; } + const Color& getTextFillColor() const { return maTextFillColor; } + bool isFilled() const { return mbFilled; } + tools::Long getWidthToFill() const { return mnWidthToFill; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange + getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; +}; + +/// small helper to have a compare operator for Locale +bool DRAWINGLAYER_DLLPUBLIC LocalesAreEqual(const css::lang::Locale& rA, + const css::lang::Locale& rB); + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/transformprimitive2d.hxx b/include/drawinglayer/primitive2d/transformprimitive2d.hxx new file mode 100644 index 0000000000..73e589b8c2 --- /dev/null +++ b/include/drawinglayer/primitive2d/transformprimitive2d.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer::primitive2d +{ + /** TransformPrimitive2D class + + This is one of the basic grouping primitives and it provides + embedding a sequence of primitives (a geometry) into a + transformation. All renderers have to handle this, usually by + building a current transformation stack (linear combination) + and applying this to all to-be-rendered geometry. If not handling + this, the output will be mostly wrong since this primitive is + widely used. + + It does transform by embedding an existing geometry into a + transformation as Child-content. This allows re-usage of the + refcounted Uno-Api primitives and their existing, buffered + decompositions. + + It could e.g. be used to show a single object geometry in 1000 + different, transformed states without the need to create those + thousand primitive contents. + */ + class DRAWINGLAYER_DLLPUBLIC TransformPrimitive2D final : public GroupPrimitive2D + { + private: + // the transformation to apply to the child geometry + basegfx::B2DHomMatrix maTransformation; + + public: + /// constructor + TransformPrimitive2D( + basegfx::B2DHomMatrix aTransformation, + Primitive2DContainer&& rChildren); + + /// data read access + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/transparenceprimitive2d.hxx b/include/drawinglayer/primitive2d/transparenceprimitive2d.hxx new file mode 100644 index 0000000000..14658abe3d --- /dev/null +++ b/include/drawinglayer/primitive2d/transparenceprimitive2d.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + + +namespace drawinglayer::primitive2d +{ + /** TransparencePrimitive2D class + + This is the basic primitive for applying freely defined transparence + to freely defined content. The basic idea is to associate a content + which is defined as a sequence of primitives and hold as child content + in the GroupPrimitive2D with a transparence channel also defined as a sequence + of primitives and hold in the transparence member. + + The basic definition is to use the transparence content as transparence-Mask by + interpreting the transparence-content not as RGB, but as Luminance transparence mask + using the common RGB_to_luminance definition as e.g. used by VCL. + + The defining geometry is the Range of the child primitive sequence, + this means the renderers will/shall use this geometric information for + rendering, not the transparent one. The transparent one should/will be clipped + accordingly. + */ + class DRAWINGLAYER_DLLPUBLIC TransparencePrimitive2D final : public GroupPrimitive2D + { + private: + /// The transparence-Mask who's RGB-Values are interpreted as Luminance + Primitive2DContainer maTransparence; + + public: + /** constructor + + @param rChildren + The content which is defined to have a transparency. The + range of this primitive is defined by this content + + @param rTransparence + The definition of the Transparence-channel for this primitive. It + will be interpreted as mask by interpreting as gray values + using the common RGB_to_luminance definitions + */ + TransparencePrimitive2D( + Primitive2DContainer&& rChildren, + Primitive2DContainer&& aTransparence); + + /// data read access + const Primitive2DContainer& getTransparence() const { return maTransparence; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx b/include/drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx new file mode 100644 index 0000000000..b5a75f295c --- /dev/null +++ b/include/drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> + + +namespace drawinglayer::primitive2d +{ + /** UnifiedTransparencePrimitive2D class + + This primitive encapsulates a child hierarchy and defines + that it shall be visualized with the given transparency. That + transparency is unique for all contained geometry, so that + e.g. overlapping polygons in the child geometry will not show + regions of combined transparency, but be all rendered with the + defined, single transparency. + */ + class DRAWINGLAYER_DLLPUBLIC UnifiedTransparencePrimitive2D final : public GroupPrimitive2D + { + private: + /// the unified transparence + double mfTransparence; + + public: + /// constructor + UnifiedTransparencePrimitive2D( + Primitive2DContainer&& rChildren, + double fTransparence); + + /// data read access + double getTransparence() const { return mfTransparence; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// own getB2DRange implementation to include transparent geometries to BoundRect calculations + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// create decomposition + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/primitive2d/wrongspellprimitive2d.hxx b/include/drawinglayer/primitive2d/wrongspellprimitive2d.hxx new file mode 100644 index 0000000000..8fe794a40c --- /dev/null +++ b/include/drawinglayer/primitive2d/wrongspellprimitive2d.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +// WrongSpellPrimitive2D class + +namespace drawinglayer::primitive2d +{ + /** WrongSpellPrimitive2D class + + This is a helper primitive to hold evtl. WrongSpell visualisations + in the sequence of primitives. The primitive holds this information + separated from the TextPortions to where it belongs to, to expand the + TextSimplePortionPrimitive2D more as needed. + + A renderer who does not want to visualize this (if contained at all) + can detect and ignore this primitive. If its decomposition is used, + it will be visualized as red wavelines. + + The geometric definition defines a line on the X-Axis (no Y-coordinates) + which will when transformed by Transformation, create the coordinate data. + */ + class DRAWINGLAYER_DLLPUBLIC WrongSpellPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// geometry definition + basegfx::B2DHomMatrix maTransformation; + double mfStart; + double mfStop; + + /// color (usually red) + basegfx::BColor maColor; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + WrongSpellPrimitive2D( + basegfx::B2DHomMatrix aTransformation, + double fStart, + double fStop, + const basegfx::BColor& rColor); + + /// data read access + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + double getStart() const { return mfStart; } + double getStop() const { return mfStop; } + const basegfx::BColor& getColor() const { return maColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |