[Libreoffice-commits] core.git: 2 commits - chart2/qa editeng/source include/xmloff xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 5 11:46:30 UTC 2020


 chart2/qa/extras/chart2export.cxx            |   16 +++++++++++++
 chart2/qa/extras/data/ods/legend_overlay.ods |binary
 editeng/source/xml/xmltxtimp.cxx             |    8 +++++-
 include/xmloff/xmltoken.hxx                  |    1 
 xmloff/source/chart/SchXMLExport.cxx         |   18 ++++++++++++++-
 xmloff/source/chart/SchXMLLegendContext.cxx  |   31 ++++++++++++++++++---------
 xmloff/source/core/xmltoken.cxx              |    1 
 xmloff/source/token/tokens.txt               |    1 
 8 files changed, 63 insertions(+), 13 deletions(-)

New commits:
commit 76b4fb8b7149af1d68a75b10acb4d9a83875e114
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Mar 5 12:17:18 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Mar 5 12:46:06 2020 +0100

    use more FastParser in SvxXMLTextImportContex
    
    Change-Id: I3d9586ec11538193fd0b8eb410d2a56202e666d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90010
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx
index fdfc588c2679..6497ac2e9ae8 100644
--- a/editeng/source/xml/xmltxtimp.cxx
+++ b/editeng/source/xml/xmltxtimp.cxx
@@ -79,6 +79,11 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLTextImportContex
     {
         pContext = new SvxXMLTextImportContext( GetImport(), mxText );
     }
+    else if( nElement == XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES ) )
+    {
+        pContext = new SvXMLStylesContext( GetImport() );
+        GetImport().GetTextImport()->SetAutoStyles( static_cast<SvXMLStylesContext*>(pContext) );
+    }
     return pContext;
 }
 
@@ -91,8 +96,7 @@ SvXMLImportContextRef SvxXMLTextImportContext::CreateChildContext( sal_uInt16 nP
     }
     else if( XML_NAMESPACE_OFFICE == nPrefix && IsXMLToken( rLocalName, XML_AUTOMATIC_STYLES ) )
     {
-        pContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList );
-        GetImport().GetTextImport()->SetAutoStyles( static_cast<SvXMLStylesContext*>(pContext) );
+        // dealt with in createFastChildContext
     }
     else
     {
commit 65123d41f62597053bc3893ee4fb46868a6b1f2d
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Mon Mar 2 14:57:20 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu Mar 5 12:45:54 2020 +0100

    tdf#75330 chart: implement ODF import/export of legend overlay feature
    
    Follow-up of commit 9fab1ba8ddc59924c633aa17c65f7330a4762726
    (tdf#75330 add a new overlay/no-overlay feature for the legend).
    
    Change-Id: I7781fd8b926d4add56f3db0d56dceab8e27e5f85
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89836
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 217e766e42fc..c3bd2283bf4e 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -158,6 +158,7 @@ public:
     void testDeletedLegendEntries();
     void testTdf130225();
     void testTdf126076();
+    void testTdf75330();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -279,6 +280,7 @@ public:
     CPPUNIT_TEST(testDeletedLegendEntries);
     CPPUNIT_TEST(testTdf130225);
     CPPUNIT_TEST(testTdf126076);
+    CPPUNIT_TEST(testTdf75330);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2580,6 +2582,20 @@ void Chart2ExportTest::testTdf126076()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker", 0);
 }
 
+void Chart2ExportTest::testTdf75330()
+{
+    mbSkipValidation = true;
+    load("/chart2/qa/extras/data/ods/", "legend_overlay.ods");
+    reload("calc8");
+    uno::Reference< chart2::XChartDocument > xChart2Doc = getChartDocFromSheet(0, mxComponent);
+    uno::Reference< chart::XChartDocument > xChartDoc (xChart2Doc, uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xLegend = xChartDoc->getLegend();
+    Reference<beans::XPropertySet> xPropertySet(xLegend, uno::UNO_QUERY_THROW);
+    bool bOverlay = false;
+    CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay);
+    CPPUNIT_ASSERT(bOverlay);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/ods/legend_overlay.ods b/chart2/qa/extras/data/ods/legend_overlay.ods
new file mode 100644
index 000000000000..fade626405c1
Binary files /dev/null and b/chart2/qa/extras/data/ods/legend_overlay.ods differ
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index ba4a588d85eb..a40aa974d327 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1386,6 +1386,7 @@ namespace xmloff { namespace token {
         XML_OUTSET,
         XML_OUTSIDE,
         XML_OVERLAP,
+        XML_OVERLAY,
         XML_P,
         XML_PACKAGE_NAME,
         XML_PADDING,
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 51f399956ae0..4344d6187b5e 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1370,6 +1370,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
             Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
             if( xProp.is())
             {
+                const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+
                 // export legend anchor position
                 try
                 {
@@ -1382,12 +1384,26 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
                     SAL_WARN("xmloff.chart", "Property Align not found in ChartLegend" );
                 }
 
+                // export legend overlay
+                try
+                {
+                    if (nCurrentODFVersion > SvtSaveOptions::ODFVER_012)
+                    {
+                        Any aAny( xProp->getPropertyValue("Overlay"));
+                        if(aAny.get<bool>())
+                            mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_OVERLAY, OUString::boolean(true));
+                    }
+                }
+                catch( const beans::UnknownPropertyException & )
+                {
+                    SAL_WARN("xmloff.chart", "Property Overlay not found in ChartLegend" );
+                }
+
                 // export absolute legend position
                 Reference< drawing::XShape > xLegendShape( xProp, uno::UNO_QUERY );
                 addPosition( xLegendShape );
 
                 // export legend size
-                const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
                 if( xLegendShape.is() && nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
                 {
                     try
diff --git a/xmloff/source/chart/SchXMLLegendContext.cxx b/xmloff/source/chart/SchXMLLegendContext.cxx
index 902fffb25f46..3427fa3683a7 100644
--- a/xmloff/source/chart/SchXMLLegendContext.cxx
+++ b/xmloff/source/chart/SchXMLLegendContext.cxx
@@ -40,6 +40,7 @@ namespace
 enum LegendAttributeTokens
 {
     XML_TOK_LEGEND_POSITION,
+    XML_TOK_LEGEND_OVERLAY,
     XML_TOK_LEGEND_X,
     XML_TOK_LEGEND_Y,
     XML_TOK_LEGEND_STYLE_NAME,
@@ -54,6 +55,7 @@ enum LegendAttributeTokens
 const SvXMLTokenMapEntry aLegendAttributeTokenMap[] =
 {
     { XML_NAMESPACE_CHART,      XML_LEGEND_POSITION,    XML_TOK_LEGEND_POSITION     },
+    { XML_NAMESPACE_LO_EXT,     XML_OVERLAY,            XML_TOK_LEGEND_OVERLAY      },
     { XML_NAMESPACE_SVG,        XML_X,                  XML_TOK_LEGEND_X            },
     { XML_NAMESPACE_SVG,        XML_Y,                  XML_TOK_LEGEND_Y            },
     { XML_NAMESPACE_CHART,      XML_STYLE_NAME,         XML_TOK_LEGEND_STYLE_NAME   },
@@ -117,6 +119,7 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu
     const SvXMLTokenMap& rAttrTokenMap = theLegendAttributeTokenMap::get();
 
     awt::Point aLegendPos;
+    bool bOverlay = false;
     bool bHasXPosition=false;
     bool bHasYPosition=false;
     awt::Size aLegendSize;
@@ -138,19 +141,27 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu
         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
         {
             case XML_TOK_LEGEND_POSITION:
+                try
                 {
-                    try
-                    {
-                        if( SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() ) )
-                            xLegendProps->setPropertyValue("Alignment", aAny );
-                    }
-                    catch(const beans::UnknownPropertyException&)
-                    {
-                        SAL_INFO("xmloff.chart", "Property Alignment (legend) not found" );
-                    }
+                    if( SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() ) )
+                        xLegendProps->setPropertyValue("Alignment", aAny );
+                }
+                catch(const beans::UnknownPropertyException&)
+                {
+                    SAL_INFO("xmloff.chart", "Property Alignment (legend) not found" );
+                }
+                break;
+            case XML_TOK_LEGEND_OVERLAY:
+                try
+                {
+                    bOverlay = xAttrList->getValueByIndex(i).toBoolean();
+                    xLegendProps->setPropertyValue("Overlay", uno::makeAny(bOverlay));
+                }
+                catch(const beans::UnknownPropertyException&)
+                {
+                    SAL_INFO("xmloff.chart", "Property Overlay (legend) not found" );
                 }
                 break;
-
             case XML_TOK_LEGEND_X:
                 GetImport().GetMM100UnitConverter().convertMeasureToCore(
                         aLegendPos.X, aValue );
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 46125e067982..b55c4c9c7a7b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1391,6 +1391,7 @@ namespace xmloff::token {
         TOKEN( "outset",                          XML_OUTSET ),
         TOKEN( "outside",                         XML_OUTSIDE ),
         TOKEN( "overlap",                         XML_OVERLAP ),
+        TOKEN( "overlay",                         XML_OVERLAY ),
         TOKEN( "p",                               XML_P ),
         TOKEN( "package-name",                    XML_PACKAGE_NAME ),
         TOKEN( "padding",                         XML_PADDING ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 31dae860a15e..5d14dd65c820 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1304,6 +1304,7 @@ outline-style
 outset
 outside
 overlap
+overlay
 p
 package-name
 padding


More information about the Libreoffice-commits mailing list