diff options
Diffstat (limited to '')
6 files changed, 556 insertions, 0 deletions
diff --git a/drawinglayer/inc/primitive2d/cropprimitive2d.hxx b/drawinglayer/inc/primitive2d/cropprimitive2d.hxx new file mode 100644 index 000000000..ba427eb6f --- /dev/null +++ b/drawinglayer/inc/primitive2d/cropprimitive2d.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/groupprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** CropPrimitive2D class + + Caution: Due to old constraints (old core definitions) the + crop distances describe how the uncropped content is defined + relative to the current object size. This means that maTransformation + describes the current object size (the part of the object visible + with the crop applied). To get the original size and orientation + of the uncropped content it is necessary to calc back from the + current situation (maTransformation) using the crop values + to get to the uncropped original content. + + Thus a transformation has to be calculated which will be applied + to the already existing content to get it to the uncropped state + and then this is masked with the current state (mask polygon + created from unit polygon and maTransformation). + + At least in this primitive the units of the crop values are + already in the local coordinate system; in the core these distances + are defined relative to the object content size (PrefMapMode + and PrefSize of the content)... + + Of course this is a primitive, so feel free to just ignore all that + stuff and use the automatically generated decomposition. Sigh. + */ + class CropPrimitive2D final : public GroupPrimitive2D + { + private: + // the transformation already applied to the child geometry + basegfx::B2DHomMatrix maTransformation; + + // the crop offsets relative to the range of the unrotated content + double mfCropLeft; + double mfCropTop; + double mfCropRight; + double mfCropBottom; + + public: + /// constructor + CropPrimitive2D( + const Primitive2DContainer& rChildren, + const basegfx::B2DHomMatrix& rTransformation, + double fCropLeft, + double fCropTop, + double fCropRight, + double fCropBottom); + + /// data read access + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + double getCropLeft() const { return mfCropLeft; } + double getCropTop() const { return mfCropTop; } + double getCropRight() const { return mfCropRight; } + double getCropBottom() const { return mfCropBottom; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// 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 primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx b/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx new file mode 100644 index 000000000..fb1431152 --- /dev/null +++ b/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx @@ -0,0 +1,59 @@ +/* -*- 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 <vcl/GraphicObject.hxx> + +class Graphic; + +namespace drawinglayer::primitive2d +{ + /** Helper method with supports decomposing a Graphic with all + possible contents to lower level primitives. + + #i121194# Unified to use this helper for FillGraphicPrimitive2D + and GraphicPrimitive2D at the same time. It is able to handle + Bitmaps (with the sub-categories animated bitmap, and SVG), + and Metafiles. + */ + void create2DDecompositionOfGraphic( + Primitive2DContainer& rContainer, + const Graphic& rGraphic, + const basegfx::B2DHomMatrix& rTransform); + + /** Helper to embed given sequence of primitives to evtl. a stack + of ModifiedColorPrimitive2D's to get all the needed modifications + applied. + */ + Primitive2DContainer create2DColorModifierEmbeddingsAsNeeded( + const Primitive2DContainer& rChildren, + GraphicDrawMode aGraphicDrawMode, + double fLuminance = 0.0, // [-1.0 .. 1.0] + double fContrast = 0.0, // [-1.0 .. 1.0] + double fRed = 0.0, // [-1.0 .. 1.0] + double fGreen = 0.0, // [-1.0 .. 1.0] + double fBlue = 0.0, // [-1.0 .. 1.0] + double fGamma = 1.0, // ]0.0 .. 10.0] + bool bInvert = false); + +} // end of namespace drawinglayer::primitive2d + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx new file mode 100644 index 000000000..a39256453 --- /dev/null +++ b/drawinglayer/inc/primitive2d/texteffectprimitive2d.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/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** TextEffectStyle2D definition */ + enum class TextEffectStyle2D + { + ReliefEmbossedDefault, + ReliefEngravedDefault, + ReliefEmbossed, + ReliefEngraved, + Outline + }; + + /** TextEffectPrimitive2D class + + This primitive embeds text primitives (normally, as can be seen can + also be used for any other primitives) which have some TextEffect applied + and create the needed geometry and embedding on decomposition. + */ + class TextEffectPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the text (or other) content + Primitive2DContainer maTextContent; + + /// the style to apply, the direction and the rotation center + const basegfx::B2DPoint maRotationCenter; + double mfDirection; + TextEffectStyle2D meTextEffectStyle2D; + + /** the last used object to view transformtion used from getDecomposition + for decide buffering + */ + basegfx::B2DHomMatrix maLastObjectToViewTransformation; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextEffectPrimitive2D( + const Primitive2DContainer& rTextContent, + const basegfx::B2DPoint& rRotationCenter, + double fDirection, + TextEffectStyle2D eTextEffectStyle2D); + + /// data read access + const Primitive2DContainer& getTextContent() const { return maTextContent; } + const basegfx::B2DPoint& getRotationCenter() const { return maRotationCenter; } + double getDirection() const { return mfDirection; } + TextEffectStyle2D getTextEffectStyle2D() const { return meTextEffectStyle2D; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /** own get range implementation to solve more effective. Content is by definition displaced + by a fixed discrete unit, thus the contained geometry needs only once be asked for its + own basegfx::B2DRange + */ + 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 primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/textlineprimitive2d.hxx b/drawinglayer/inc/primitive2d/textlineprimitive2d.hxx new file mode 100644 index 000000000..059c69bd7 --- /dev/null +++ b/drawinglayer/inc/primitive2d/textlineprimitive2d.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/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextLinePrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + double mfOffset; + double mfHeight; + + /// decoration definitions + TextLine meTextLine; + basegfx::BColor maLineColor; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextLinePrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + double fOffset, + double fHeight, + TextLine eTextLine, + const basegfx::BColor& rLineColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + double getOffset() const { return mfOffset; } + double getHeight() const { return mfHeight; } + TextLine getTextLine() const { return meTextLine; } + const basegfx::BColor& getLineColor() const { return maLineColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx b/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx new file mode 100644 index 000000000..1e1e75f7c --- /dev/null +++ b/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx @@ -0,0 +1,143 @@ +/* -*- 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/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <com/sun/star/lang/Locale.hpp> + + +namespace drawinglayer +{ + namespace primitive2d + { + class BaseTextStrikeoutPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + + /// decoration definitions + basegfx::BColor maFontColor; + + public: + /// constructor + BaseTextStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + const basegfx::BColor& getFontColor() const { return maFontColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextCharacterStrikeoutPrimitive2D final : public BaseTextStrikeoutPrimitive2D + { + private: + sal_Unicode maStrikeoutChar; + attribute::FontAttribute maFontAttribute; + css::lang::Locale maLocale; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextCharacterStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + sal_Unicode aStrikeoutChar, + const attribute::FontAttribute& rFontAttribute, + const css::lang::Locale& rLocale); + + /// data read access + sal_Unicode getStrikeoutChar() const { return maStrikeoutChar; } + const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; } + const css::lang::Locale& getLocale() const { return maLocale; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextGeometryStrikeoutPrimitive2D final : public BaseTextStrikeoutPrimitive2D + { + private: + double mfHeight; + double mfOffset; + TextStrikeout meTextStrikeout; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextGeometryStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + double fHeight, + double fOffset, + TextStrikeout eTextStrikeout); + + /// data read access + double getHeight() const { return mfHeight; } + double getOffset() const { return mfOffset; } + TextStrikeout getTextStrikeout() const { return meTextStrikeout; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx b/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx new file mode 100644 index 000000000..a8e4b158f --- /dev/null +++ b/drawinglayer/inc/primitive2d/wallpaperprimitive2d.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/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/wall.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** WallpaperBitmapPrimitive2D class + + This is a specialized primitive for the Wallpaper definitions included in + VCL and Metafiles. The extraordinary about the bitmap definition part of + the Wallpaper is that it uses PIXEL size of the given Bitmap and not + the logic and/or discrete size derived by PrefMapMode/PrefSize methods. + To emulate this, a ViewTransformation dependent primitive is needed which + takes over the correct scaling(s). + + Since a specialized primitive is needed anyways, i opted to also add the + layouting which is dependent from WallpaperStyle; thus it does not need + to be handled anywhere else in the future. + */ + class WallpaperBitmapPrimitive2D final : public ViewTransformationDependentPrimitive2D + { + private: + basegfx::B2DRange maObjectRange; + BitmapEx maBitmapEx; + WallpaperStyle meWallpaperStyle; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + WallpaperBitmapPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const BitmapEx& rBitmapEx, + WallpaperStyle eWallpaperStyle); + + /// data read access + const basegfx::B2DRange& getLocalObjectRange() const { return maObjectRange; } + const BitmapEx& getBitmapEx() const { return maBitmapEx ; } + WallpaperStyle getWallpaperStyle() const { return meWallpaperStyle; } + + /// 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 primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |