summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-10-22 10:33:03 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-10-24 20:57:51 +0200
commit1b9bc3c3f6f3fb31802be37592fcf4153d3d420d (patch)
treea8f37e14aac80e714678ccba50244e55a251209e /include
parent34e9072344067010b82124a3a104b20c73da9f0c (diff)
Reorganize FrameBorderPrimitive creation
Step1: Basic concept, move stuff to svx and new SdrFrameBorderPrimitive2D Step2: Adapt all creators/usages to use SdrFrameBorderData/SdrFrameBorderPrimitive2D, check functionality Step3: Re-implement mergre of BorderLinePrimitive2D during decomposition of SdrFrameBorderPrimitive2D to keep the number of primitives low from the start, make merge optional (not urgently needed) Step4: Migrate and isolate all helper methods and classes involved in geometry creation of border lines to the implementation (.cxx) of the new primitive Change-Id: I840b6765439bd995f2c57ef36315427b1f0f3e21 Reviewed-on: https://gerrit.libreoffice.org/62247 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de> Reviewed-on: https://gerrit.libreoffice.org/62309 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'include')
-rw-r--r--include/svx/framelink.hxx109
-rw-r--r--include/svx/framelinkarray.hxx5
-rwxr-xr-xinclude/svx/sdr/primitive2d/sdrframeborderprimitive2d.hxx119
-rw-r--r--include/svx/sdr/primitive2d/svx_primitivetypes2d.hxx1
4 files changed, 120 insertions, 114 deletions
diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx
index 65f1920fd093..5861b9eb58f2 100644
--- a/include/svx/framelink.hxx
+++ b/include/svx/framelink.hxx
@@ -201,115 +201,6 @@ public:
inline bool operator>( const Style& rL, const Style& rR ) { return rR.operator<(rL); }
-// Drawing functions
-class SAL_WARN_UNUSED SVX_DLLPUBLIC StyleVectorCombination
-{
-private:
- struct OffsetAndHalfWidthAndColor
- {
- double mfOffset;
- double mfHalfWidth;
- Color maColor;
-
- OffsetAndHalfWidthAndColor(double offset, double halfWidth, Color color) :
- mfOffset(offset),
- mfHalfWidth(halfWidth),
- maColor(color)
- {}
- };
-
- double mfRefModeOffset;
- basegfx::B2DVector maB2DVector;
- double mfAngle;
- std::vector< OffsetAndHalfWidthAndColor > maOffsets;
-
-public:
- StyleVectorCombination(
- const Style& rStyle,
- const basegfx::B2DVector& rB2DVector,
- const double fAngle,
- bool bMirrored,
- const Color* pForceColor = nullptr);
-
- double getRefModeOffset() const { return mfRefModeOffset; }
- const basegfx::B2DVector& getB2DVector() const { return maB2DVector; }
- double getAngle() const { return mfAngle; }
- bool empty() const { return maOffsets.empty(); }
- size_t size() const { return maOffsets.size(); }
- bool operator<( const StyleVectorCombination& rOther) const { return mfAngle < rOther.mfAngle; }
-
- void getColorAndOffsetAndHalfWidth(size_t nIndex, Color& rColor, double& rfOffset, double& rfHalfWidth) const;
-};
-
-class SAL_WARN_UNUSED SVX_DLLPUBLIC StyleVectorTable
-{
-private:
- std::vector< StyleVectorCombination > maEntries;
-
-public:
- StyleVectorTable()
- : maEntries()
- {
- }
-
- void add(
- const Style& rStyle,
- const basegfx::B2DVector& rMyVector,
- const basegfx::B2DVector& rOtherVector,
- bool bMirrored);
-
- void sort();
-
- bool empty() const { return maEntries.empty(); }
- size_t size() const { return maEntries.size(); }
- const std::vector< StyleVectorCombination >& getEntries() const{ return maEntries; }
-};
-
-/**
- * Helper method to create the correct drawinglayer::primitive2d::BorderLinePrimitive2D
- * for the given data, especially the correct drawinglayer::primitive2d::BorderLine entries
- * including the correctly solved/created LineStartEnd extends
- *
- * rTarget : Here the evtl. created BorderLinePrimitive2D will be appended
- * rOrigin : StartPoint of the Borderline
- * rX : Vector of the Borderline
- * rBorder : svx::frame::Style of the of the Borderline
- * rStartStyleVectorTable : All other Borderlines which have to be taken into account because
- * they have the same StartPoint as the current Borderline. These will be used to calculate
- * the correct LineStartEnd extends tor the BorderLinePrimitive2D. The definition should be
- * built up using svx::frame::StyleVectorTable and StyleVectorTable::add and includes:
- * rStyle : the svx::frame::Style of one other BorderLine
- * rMyVector : the Vector of the *new* to-be-defined BorderLine, identical to rX
- * rOtherVector: the Vector of one other BorderLine (may be, but does not need to be normalized),
- * always *pointing away* from the common StartPoint rOrigin
- * bMirrored : define if rStyle of one other BorderLine shall be mirrored (e.g. bottom-right edges)
- * With multiple BorderLines the definitions have to be CounterClockWise. This will be
- * ensured by StyleVectorTable sorting the entries, but knowing this may allow more efficcient
- * data creation.
- * rEndStyleVectorTable: All other BorderLines that have the same EndPoint. There are differences to
- * the Start definitions:
- * - do not forget to consequently use -rX for rMyVector
- * - definitions have to be ClockWise for the EndBorderLines, will be ensured by sorting
- *
- * If you take all this into account, you will gett correctly extended BorderLinePrimitive2D
- * reprsentations for the new to be defined BorderLine. That extensions will overlap nicely
- * with the corresponding BordreLines and take all multiple line definitions in the ::Style into
- * account.
- * The internal solver is *not limitied* to ::Style(s) with three parts (Left/Gap/Right), this is
- * just due to svx::frame::Style's definitions. A new solver based on this one can be created
- * anytime using more mulötiple borders based on the more flexible
- * std::vector< drawinglayer::primitive2d::BorderLine > if needed.
- */
-SVX_DLLPUBLIC void CreateBorderPrimitives(
- drawinglayer::primitive2d::Primitive2DContainer& rTarget, /// target for created primitives
- const basegfx::B2DPoint& rOrigin, /// start point of borderline
- const basegfx::B2DVector& rX, /// X-Axis of borderline with length
- const Style& rBorder, /// Style of borderline
- const StyleVectorTable& rStartStyleVectorTable, /// Styles and vectors (pointing away) at borderline start, ccw
- const StyleVectorTable& rEndStyleVectorTable, /// Styles and vectors (pointing away) at borderline end, cw
- const Color* pForceColor /// If specified, overrides frame border color.
-);
-
}
}
diff --git a/include/svx/framelinkarray.hxx b/include/svx/framelinkarray.hxx
index c2c207cec5a8..7a4d8e9df640 100644
--- a/include/svx/framelinkarray.hxx
+++ b/include/svx/framelinkarray.hxx
@@ -323,11 +323,6 @@ private:
ArrayImplPtr mxImpl;
};
-// helper to merge B2DPrimitive(s) in rSource and add to rTarget
-void SVX_DLLPUBLIC HelperMergeInB2DPrimitiveArray(
- const drawinglayer::primitive2d::Primitive2DContainer& rSource,
- drawinglayer::primitive2d::Primitive2DContainer& rTarget);
-
}
}
diff --git a/include/svx/sdr/primitive2d/sdrframeborderprimitive2d.hxx b/include/svx/sdr/primitive2d/sdrframeborderprimitive2d.hxx
new file mode 100755
index 000000000000..611ec6b20285
--- /dev/null
+++ b/include/svx/sdr/primitive2d/sdrframeborderprimitive2d.hxx
@@ -0,0 +1,119 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRFRAMEBORDERPRIMITIVE2D_HXX
+#define INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRFRAMEBORDERPRIMITIVE2D_HXX
+
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <svx/framelink.hxx>
+
+// predefines
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class SVX_DLLPUBLIC SdrFrameBorderData
+ {
+ private:
+ basegfx::B2DPoint maOrigin; /// start point of borderline
+ basegfx::B2DVector maX; /// X-Axis of borderline with length
+ svx::frame::Style maStyle; /// Style of borderline
+ Color maColor;
+ bool mbForceColor;
+
+ class SdrConnectStyleData
+ {
+ private:
+ svx::frame::Style maStyle;
+ basegfx::B2DVector maNormalizedPerpendicular;
+ bool mbStyleMirrored;
+
+ public:
+ SdrConnectStyleData(
+ const svx::frame::Style& rStyle,
+ const basegfx::B2DVector& rNormalizedPerpendicular,
+ bool bStyleMirrored);
+
+ const svx::frame::Style& getStyle() const { return maStyle; }
+ const basegfx::B2DVector& getNormalizedPerpendicular() const { return maNormalizedPerpendicular; }
+ bool getStyleMirrored() const { return mbStyleMirrored; }
+ };
+
+ std::vector<SdrConnectStyleData> maStart;
+ std::vector<SdrConnectStyleData> maEnd;
+
+ public:
+ SdrFrameBorderData(
+ const basegfx::B2DPoint& rOrigin,
+ const basegfx::B2DVector& rX,
+ const svx::frame::Style& rStyle,
+ const Color* pForceColor);
+
+ void addSdrConnectStyleData(
+ bool bStart,
+ const svx::frame::Style& rStyle,
+ const basegfx::B2DVector& rNormalizedPerpendicular,
+ bool bStyleMirrored);
+
+ void create2DDecomposition(Primitive2DContainer& rContainer) const;
+ };
+
+ typedef std::vector<SdrFrameBorderData> SdrFrameBorderDataVector;
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class SVX_DLLPUBLIC SdrFrameBorderPrimitive2D : public BufferedDecompositionPrimitive2D
+ {
+ private:
+ std::shared_ptr<SdrFrameBorderDataVector> maFrameBorders;
+ bool mbMergeResult;
+
+ protected:
+ // local decomposition.
+ virtual Primitive2DContainer create2DDecomposition(
+ const geometry::ViewInformation2D& aViewInformation) const override;
+
+ public:
+ SdrFrameBorderPrimitive2D(
+ std::shared_ptr<SdrFrameBorderDataVector>& rFrameBorders,
+ bool bMergeResult);
+
+ // compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
+
+ // data access
+ const SdrFrameBorderDataVector& getFrameBorders() const { return *maFrameBorders.get(); }
+ bool getMergeResult() const { return mbMergeResult; }
+
+ // provide unique ID
+ DeclPrimitive2DIDBlock()
+ };
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+
+#endif // INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRFRAMEBORDERPRIMITIVE2D_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/sdr/primitive2d/svx_primitivetypes2d.hxx b/include/svx/sdr/primitive2d/svx_primitivetypes2d.hxx
index d2a16623dd02..d6cb948a6bf6 100644
--- a/include/svx/sdr/primitive2d/svx_primitivetypes2d.hxx
+++ b/include/svx/sdr/primitive2d/svx_primitivetypes2d.hxx
@@ -47,6 +47,7 @@
#define PRIMITIVE2D_ID_SDROLECONTENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SVX| 21)
#define PRIMITIVE2D_ID_SDRAUTOFITTEXTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SVX| 22)
#define PRIMITIVE2D_ID_SDRCHAINEDTEXTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SVX| 23)
+#define PRIMITIVE2D_ID_SDRFRAMEBORDERTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SVX| 24)
#endif // INCLUDED_SVX_SDR_PRIMITIVE2D_SVX_PRIMITIVETYPES2D_HXX