[Libreoffice-commits] core.git: chart2/source offapi/com sc/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sat Apr 22 07:07:15 UTC 2017


 chart2/source/view/main/ChartView.cxx                    |   14 +-
 chart2/source/view/main/VButton.cxx                      |   99 ++++++++++++---
 chart2/source/view/main/VButton.hxx                      |   40 ++++--
 chart2/source/view/main/VLegend.cxx                      |   17 +-
 offapi/com/sun/star/chart2/data/PivotTableFieldEntry.idl |   15 ++
 sc/source/ui/unoobj/PivotTableDataProvider.cxx           |   17 +-
 6 files changed, 163 insertions(+), 39 deletions(-)

New commits:
commit 011057b0ce7552497858afed7252136a3fc09bf8
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Apr 19 22:10:47 2017 +0200

    tdf#107068 add arrow to the buttons, mark if field is filtered
    
    Change-Id: Iba0b4c2ce3ab84229d388a7cb2d20db1f47c0b57
    Reviewed-on: https://gerrit.libreoffice.org/36738
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 364828692c2c..8e85b0063e13 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2513,7 +2513,12 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
             awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100);
             pButton->setLabel(rPageFieldEntry.Name);
             pButton->setCID("FieldButton.Page." + OUString::number(rPageFieldEntry.DimensionIndex));
-            pButton->createShapes(aNewPosition, aSize, xModelPage);
+            pButton->setPosition(aNewPosition);
+            pButton->setSize(aSize);
+            if (rPageFieldEntry.HasHiddenMembers)
+                pButton->setArrowColor(0x0000FF);
+
+            pButton->createShapes(xModelPage);
             x += aSize.Width + 100;
         }
         rRemainingSpace.Y += (aSize.Height + 100 + 100);
@@ -2525,13 +2530,18 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
         x = 200;
         for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : xPivotTableDataProvider->getRowFields())
         {
+
             std::unique_ptr<VButton> pButton(new VButton);
             pButton->init(xPageShapes, xShapeFactory);
             awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100,
                                                  rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100);
             pButton->setLabel(rRowFieldEntry.Name);
             pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex));
-            pButton->createShapes(aNewPosition, aSize, xModelPage);
+            pButton->setPosition(aNewPosition);
+            pButton->setSize(aSize);
+            if (rRowFieldEntry.HasHiddenMembers)
+                pButton->setArrowColor(0x0000FF);
+            pButton->createShapes(xModelPage);
             x += aSize.Width + 100;
         }
         rRemainingSpace.Height -= (aSize.Height + 100 + 100);
diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx
index 996ceff2c288..a8854ac4a951 100644
--- a/chart2/source/view/main/VButton.cxx
+++ b/chart2/source/view/main/VButton.cxx
@@ -18,6 +18,10 @@
 
 #include <memory>
 
+#include "CommonConverters.hxx"
+#include <editeng/unoprnms.hxx>
+#include "macros.hxx"
+
 namespace chart
 {
 
@@ -27,6 +31,8 @@ VButton::VButton()
     : m_xShapeFactory(nullptr)
     , m_xTarget(nullptr)
     , m_xShape(nullptr)
+    , m_bShowArrow(true)
+    , m_nArrowColor(0x00000000)
 {
 }
 
@@ -37,9 +43,54 @@ void VButton::init(const uno::Reference<drawing::XShapes>& xTargetPage,
     m_xShapeFactory = xFactory;
 }
 
-void VButton::createShapes(const awt::Point& rPosition,
-                           const awt::Size& rReferenceSize,
-                           const uno::Reference<beans::XPropertySet>& xTextProp)
+uno::Reference<drawing::XShape> VButton::createTriangle(awt::Size aSize)
+{
+    uno::Reference<drawing::XShape> xShape;
+    xShape.set(m_xShapeFactory->createInstance("com.sun.star.drawing.PolyPolygonShape"), uno::UNO_QUERY);
+
+    if (!xShape.is())
+        return xShape;
+
+    uno::Reference<beans::XPropertySet> xProperies(xShape, uno::UNO_QUERY);
+
+    drawing::PolyPolygonShape3D aPolyPolygon;
+    aPolyPolygon.SequenceX.realloc(1);
+    aPolyPolygon.SequenceY.realloc(1);
+    aPolyPolygon.SequenceZ.realloc(1);
+
+    drawing::DoubleSequence* pOuterSequenceX = aPolyPolygon.SequenceX.getArray();
+    drawing::DoubleSequence* pOuterSequenceY = aPolyPolygon.SequenceY.getArray();
+    drawing::DoubleSequence* pOuterSequenceZ = aPolyPolygon.SequenceZ.getArray();
+
+    pOuterSequenceX->realloc(3);
+    pOuterSequenceY->realloc(3);
+    pOuterSequenceZ->realloc(3);
+
+    double* pInnerSequenceX = pOuterSequenceX->getArray();
+    double* pInnerSequenceY = pOuterSequenceY->getArray();
+    double* pInnerSequenceZ = pOuterSequenceZ->getArray();
+
+    pInnerSequenceX[0] = 0.0;
+    pInnerSequenceY[0] = 0.0;
+    pInnerSequenceZ[0] = 0.0;
+
+    pInnerSequenceX[1] = aSize.Width / 2.0;
+    pInnerSequenceY[1] = aSize.Height;
+    pInnerSequenceZ[1] = 0.0;
+
+    pInnerSequenceX[2] = aSize.Width;
+    pInnerSequenceY[2] = 0.0;
+    pInnerSequenceZ[2] = 0.0;
+
+    xProperies->setPropertyValue("Name", uno::makeAny(m_sCID));
+    xProperies->setPropertyValue(UNO_NAME_POLYPOLYGON, uno::Any(PolyToPointSequence(aPolyPolygon)));
+    xProperies->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE));
+    xProperies->setPropertyValue("FillColor", uno::Any(m_nArrowColor));
+
+    return xShape;
+}
+
+void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp)
 {
     AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
 
@@ -48,36 +99,52 @@ void VButton::createShapes(const awt::Point& rPosition,
 
     PropertyMapper::getTextLabelMultiPropertyLists(xTextProp, *pPropNames, *pPropValues);
 
+    m_xShape.set(pShapeFactory->createGroup2D(m_xTarget, m_sCID), uno::UNO_QUERY);
+    m_xShape->setPosition(m_aPosition);
+    m_xShape->setSize(m_aSize);
+
+    uno::Reference<drawing::XShapes> xContainer(m_xShape, uno::UNO_QUERY);
+    if (!xContainer.is())
+        return;
+
     tPropertyNameValueMap aTextValueMap;
     aTextValueMap["CharHeight"] <<= 10.0f;
-    aTextValueMap["FillColor"] <<= (sal_Int32)0xe6e6e6;
+    aTextValueMap["FillColor"] <<= sal_Int32(0xe6e6e6);
     aTextValueMap["FillStyle"] <<= drawing::FillStyle_SOLID;
-    aTextValueMap["LineColor"] <<= (sal_Int32)0xcccccc;
+    aTextValueMap["LineColor"] <<= sal_Int32(0xcccccc);
     aTextValueMap["LineStyle"] <<= drawing::LineStyle_SOLID;
     aTextValueMap["ParaAdjust"] <<= style::ParagraphAdjust_CENTER;
-    aTextValueMap["TextHorizontalAdjust"] <<= drawing::TextHorizontalAdjust_CENTER;
+    aTextValueMap["TextHorizontalAdjust"] <<= drawing::TextHorizontalAdjust_LEFT;
     aTextValueMap["TextVerticalAdjust"] <<= drawing::TextVerticalAdjust_CENTER;
+    aTextValueMap["ParaLeftMargin"] <<= sal_Int32(100);
+    aTextValueMap["ParaRightMargin"] <<= sal_Int32(600);
 
     aTextValueMap["Name"] <<= m_sCID; //CID OUString
 
     PropertyMapper::getMultiPropertyListsFromValueMap(*pPropNames, *pPropValues, aTextValueMap);
 
     uno::Reference<drawing::XShape> xEntry = pShapeFactory->createText(
-        m_xTarget, m_sLabel, *pPropNames, *pPropValues, uno::Any());
+        xContainer, m_sLabel, *pPropNames, *pPropValues, uno::Any());
 
     if (xEntry.is())
     {
-        m_xShape = xEntry;
-        m_xShape->setPosition(rPosition);
-        m_xShape->setSize(rReferenceSize);
+        xEntry->setPosition(m_aPosition);
+        xEntry->setSize(m_aSize);
     }
-}
 
-void VButton::setWidth(sal_Int32 nWidth)
-{
-    awt::Size aSize = m_xShape->getSize();
-    aSize.Width = nWidth;
-    m_xShape->setSize(aSize);
+    if (m_bShowArrow)
+    {
+        awt::Size aPolySize {280, 180};
+
+        uno::Reference<drawing::XShape> xPoly = createTriangle(aPolySize);
+        if (xPoly.is())
+        {
+            xPoly->setSize(aPolySize);
+            xPoly->setPosition({ sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100),
+                                 sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) });
+            xContainer->add(xPoly);
+        }
+    }
 }
 
 } //namespace chart
diff --git a/chart2/source/view/main/VButton.hxx b/chart2/source/view/main/VButton.hxx
index d27b85acba5d..e64a1049e726 100644
--- a/chart2/source/view/main/VButton.hxx
+++ b/chart2/source/view/main/VButton.hxx
@@ -25,6 +25,13 @@ private:
     css::uno::Reference<css::drawing::XShape> m_xShape;
     OUString m_sLabel;
     OUString m_sCID;
+    css::awt::Point m_aPosition;
+    css::awt::Size m_aSize;
+    bool m_bShowArrow;
+    sal_Int32 m_nArrowColor;
+
+    css::uno::Reference<css::drawing::XShape>
+        createTriangle(css::awt::Size aSize);
 
 public:
     VButton();
@@ -32,18 +39,35 @@ public:
     void init(const css::uno::Reference<css::drawing::XShapes>& xTargetPage,
               const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory);
 
-    void createShapes(const css::awt::Point& rPosition,
-                      const css::awt::Size& rReferenceSize,
-                      const css::uno::Reference<css::beans::XPropertySet>& xTextProp);
+    void createShapes(const css::uno::Reference<css::beans::XPropertySet>& xTextProp);
 
-    void setWidth(sal_Int32 nWidth);
-    void setLabel(OUString const & sLabel)
+    void showArrow(bool bShowArrow)
+    {
+        m_bShowArrow = bShowArrow;
+    }
+    void setArrowColor(sal_Int32 nArrowColor)
+    {
+        m_nArrowColor = nArrowColor;
+    }
+    void setLabel(OUString const & rLabel)
+    {
+        m_sLabel = rLabel;
+    }
+    void setCID(OUString const & rCID)
+    {
+        m_sCID = rCID;
+    }
+    void setPosition(css::awt::Point const & rPosition)
+    {
+        m_aPosition = rPosition;
+    }
+    css::awt::Size getSize()
     {
-        m_sLabel = sLabel;
+        return m_aSize;
     }
-    void setCID(OUString const & sCID)
+    void setSize(css::awt::Size const & rSize)
     {
-        m_sCID = sCID;
+        m_aSize = rSize;
     }
 };
 
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index b20fa6e6b075..bf51d0bd64d8 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -778,8 +778,6 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons(
     if (!xPivotTableDataProvider->getColumnFields().hasElements())
         return aButtons;
 
-    uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground());
-
     awt::Size aSize(2000, 700);
     int y = 100;
     for (chart2::data::PivotTableFieldEntry const & sColumnFieldEntry : xPivotTableDataProvider->getColumnFields())
@@ -790,8 +788,13 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons(
         awt::Point aNewPosition = awt::Point(100, y);
         pButton->setLabel(sColumnFieldEntry.Name);
         pButton->setCID("FieldButton.Column." + OUString::number(sColumnFieldEntry.DimensionIndex));
-        pButton->createShapes(aNewPosition, aSize, xModelPage);
-        y += aSize.Height + 100;;
+        pButton->setPosition(aNewPosition);
+        pButton->setSize(aSize);
+        if (sColumnFieldEntry.Name == "Data")
+            pButton->showArrow(false);
+        if (sColumnFieldEntry.HasHiddenMembers)
+            pButton->setArrowColor(0x0000FF);
+        y += aSize.Height + 100;
     }
     nUsedHeight += y + 100;
 
@@ -936,9 +939,13 @@ void VLegend::createShapes(
                 aLegendSize = lcl_placeLegendEntries(aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent,
                                                      aTextProperties, xLegendContainer, m_xShapeFactory, aRectangle);
 
+
+                uno::Reference<beans::XPropertySet> xModelPage(mrModel.getPageBackground());
+
                 for (std::shared_ptr<VButton> const & pButton : aButtons)
                 {
-                    pButton->setWidth(aLegendSize.Width - 200);
+                    pButton->setSize({aLegendSize.Width - 200, pButton->getSize().Height});
+                    pButton->createShapes(xModelPage);
                 }
             }
 
diff --git a/offapi/com/sun/star/chart2/data/PivotTableFieldEntry.idl b/offapi/com/sun/star/chart2/data/PivotTableFieldEntry.idl
index 126d11d4f804..4a9f7799a8e5 100644
--- a/offapi/com/sun/star/chart2/data/PivotTableFieldEntry.idl
+++ b/offapi/com/sun/star/chart2/data/PivotTableFieldEntry.idl
@@ -22,16 +22,31 @@ module data
 {
 
 /**
+ * Pivot table field entry data.
  *
  * @since LibreOffice 5.4
  */
 struct PivotTableFieldEntry
 {
+    /**
+     * Name of the field entry.
+     */
     string Name;
 
+    /**
+     * The index of the field entry.
+     */
     long DimensionIndex;
 
+    /**
+     * The output position of the field entry in its field type.
+     */
     long DimensionPositionIndex;
+
+    /**
+     * Does it have some members that are hidded (filtered).
+     */
+    boolean HasHiddenMembers;
 };
 
 }; // data
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index 7194d01eaa74..7872870e08c4 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -347,17 +347,18 @@ void PivotTableDataProvider::collectPivotTableData()
             uno::Reference<container::XNamed> xLevelName(xLevel, uno::UNO_QUERY);
             uno::Reference<sheet::XDataPilotMemberResults> xLevelResult(xLevel, uno::UNO_QUERY );
 
-            bool bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(xDimProp, SC_UNO_DP_ISDATALAYOUT);
-            sal_Int32 nDimPos = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_POSITION);
-            sal_Int32 nNumberFormat = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_NUMBERFO);
-
             if (xLevelName.is() && xLevelResult.is())
             {
+                bool bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(xDimProp, SC_UNO_DP_ISDATALAYOUT);
+                sal_Int32 nDimPos = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_POSITION);
+                sal_Int32 nNumberFormat = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_NUMBERFO);
+                bool bHasHiddenMember = ScUnoHelpFunctions::GetBoolProperty(xDimProp, SC_UNO_DP_HAS_HIDDEN_MEMBER);
+
                 switch (eDimOrient)
                 {
                     case sheet::DataPilotFieldOrientation_COLUMN:
                     {
-                        m_aColumnFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos});
+                        m_aColumnFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember});
 
                         uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
                         size_t i = 0;
@@ -395,7 +396,7 @@ void PivotTableDataProvider::collectPivotTableData()
 
                     case sheet::DataPilotFieldOrientation_ROW:
                     {
-                        m_aRowFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos});
+                        m_aRowFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember});
 
                         uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
                         m_aCategoriesRowOrientation.resize(aSequence.getLength());
@@ -448,14 +449,14 @@ void PivotTableDataProvider::collectPivotTableData()
 
                     case sheet::DataPilotFieldOrientation_PAGE:
                     {
-                        m_aPageFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos});
+                        m_aPageFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember});
                     }
                     break;
 
                     case sheet::DataPilotFieldOrientation_DATA:
                     {
                         aDataFieldNumberFormatMap[xLevelName->getName()] = nNumberFormat;
-                        m_aDataFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos});
+                        m_aDataFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember});
                     }
                     break;
 


More information about the Libreoffice-commits mailing list