[Libreoffice-commits] core.git: 5 commits - sc/CppunitTest_sc_condformats.mk sc/inc sc/Module_sc.mk sc/qa sc/source vcl/inc vcl/opengl

Markus Mohrhard markus.mohrhard at collabora.co.uk
Tue Jan 6 23:55:30 PST 2015


 sc/CppunitTest_sc_condformats.mk |  109 +++++++++++++++++++++++++++++++
 sc/Module_sc.mk                  |    1 
 sc/inc/attarray.hxx              |    1 
 sc/qa/extras/sccondformats.cxx   |  136 +++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/attarray.cxx |    8 +-
 sc/source/ui/app/inputhdl.cxx    |   11 ++-
 sc/source/ui/unoobj/cellsuno.cxx |   23 +++++-
 vcl/inc/openglgdiimpl.hxx        |    2 
 vcl/opengl/gdiimpl.cxx           |   15 ++--
 9 files changed, 288 insertions(+), 18 deletions(-)

New commits:
commit 1ddb7c2c9d10c92371d76c59c69086115b2c4051
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Jan 7 08:31:50 2015 +0100

    it makes no sense to use the line color in some cases
    
    Hopefully that helps a little bit with some strange rendering effects.
    
    Change-Id: I6b001bf31d745d6d19f91acadee5ceb0e5480025

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index fb436a4..feb8bdc 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -732,7 +732,8 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol
 #ifdef DBG_UTIL
         assert( mProgramIsSolidLineColor );
 #endif
-        UseSolidAA( mnLineColor );
+        bool bUseLineColor = bLine || mnLineColor != SALCOLOR_NONE;
+        UseSolidAA( bUseLineColor ? mnLineColor : mnFillColor );
         for( sal_uInt32 i = 0; i < aSimplePolyPolygon.count(); i++ )
         {
             const basegfx::B2DPolygon& rPolygon( aSimplePolyPolygon.getB2DPolygon( i ) );
commit 3a74b40f0f862fc099adb93a528d469903031583
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Wed Jan 7 08:31:28 2015 +0100

    make sure to use the FillColor when we used it before
    
    Change-Id: I36443d12e1607221b9505d1e05a51e804d714e16

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 4ca30b3..69c211d 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -84,7 +84,7 @@ public:
     void DrawRect( long nX, long nY, long nWidth, long nHeight );
     void DrawRect( const Rectangle& rRect );
     void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry );
-    void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool blockAA = false );
+    void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bLine, bool blockAA = false );
     void DrawRegionBand( const RegionBand& rRegion );
     void DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false );
     void DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 69b4138..fb436a4 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -198,7 +198,7 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa
         if( rClip.getRegionBand() )
             DrawRegionBand( *rClip.getRegionBand() );
         else
-            DrawPolyPolygon( rClip.GetAsB2DPolyPolygon(), true );
+            DrawPolyPolygon( rClip.GetAsB2DPolyPolygon(), false, true );
     }
 
     glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
@@ -695,11 +695,11 @@ void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
     else
     {
         const ::basegfx::B2DPolyPolygon aPolyPolygon( aPolygon );
-        DrawPolyPolygon( aPolyPolygon );
+        DrawPolyPolygon( aPolyPolygon, false );
     }
 }
 
-void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool blockAA )
+void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bLine, bool blockAA )
 {
     ::std::vector< GLfloat > aVertices;
     GLfloat nWidth = GetWidth();
@@ -745,7 +745,7 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol
                 DrawLineAA( rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY());
             }
         }
-        UseSolid( mnLineColor );
+        UseSolid( bLine ? mnLineColor : mnFillColor );
     }
 
     CHECK_GL_ERROR();
@@ -1133,7 +1133,7 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rP
         for( sal_uInt32 i = 0; i < rPolyPolygon.count(); i++ )
         {
             const ::basegfx::B2DPolyPolygon aOnePoly( rPolyPolygon.getB2DPolygon( i ) );
-            DrawPolyPolygon( aOnePoly );
+            DrawPolyPolygon( aOnePoly, false );
         }
     }
 
@@ -1216,7 +1216,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
         for( sal_uInt32 i = 0; i < aAreaPolyPoly.count(); i++ )
         {
             const ::basegfx::B2DPolyPolygon aOnePoly( aAreaPolyPoly.getB2DPolygon( i ) );
-            DrawPolyPolygon( aOnePoly );
+            DrawPolyPolygon( aOnePoly, true );
         }
     }
     PostDraw();
commit 2ca2b8c2e0926a1562ea9dfbe16b686230e20638
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Mon Dec 22 14:09:25 2014 +0100

    UNO API test for conditional formats
    
    Change-Id: I45d4b9652f35174eaf59c8868d593764c2ef2ebf

diff --git a/sc/CppunitTest_sc_condformats.mk b/sc/CppunitTest_sc_condformats.mk
new file mode 100644
index 0000000..3f742b8
--- /dev/null
+++ b/sc/CppunitTest_sc_condformats.mk
@@ -0,0 +1,109 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_condformats))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_condformats, \
+	sc/qa/extras/sccondformats \
+))
+
+$(eval $(call gb_CppunitTest_use_external,sc_condformats,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_condformats, \
+	basegfx \
+	comphelper \
+	cppu \
+	cppuhelper \
+	drawinglayer \
+	editeng \
+	for \
+	forui \
+	i18nlangtag \
+	msfilter \
+	oox \
+	sal \
+	salhelper \
+	sax \
+	sb \
+	sfx \
+	sot \
+	subsequenttest \
+	svl \
+	svt \
+	svx \
+	svxcore \
+	test \
+	tk \
+	tl \
+	ucbhelper \
+	unotest \
+	utl \
+	vbahelper \
+	vcl \
+	xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_condformats,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_condformats,\
+	offapi \
+	udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_condformats))
+$(eval $(call gb_CppunitTest_use_vcl,sc_condformats))
+
+$(eval $(call gb_CppunitTest_use_components,sc_condformats,\
+	basic/util/sb \
+	comphelper/util/comphelp \
+	configmgr/source/configmgr \
+	dbaccess/util/dba \
+	filter/source/config/cache/filterconfig1 \
+	filter/source/storagefilterdetect/storagefd \
+	forms/util/frm \
+	framework/util/fwk \
+	i18npool/util/i18npool \
+	linguistic/source/lng \
+	oox/util/oox \
+	package/source/xstor/xstor \
+	package/util/package2 \
+	sax/source/expatwrap/expwrap \
+	scripting/source/basprov/basprov \
+	scripting/util/scriptframe \
+	sc/util/sc \
+	sc/util/scd \
+	sc/util/scfilt \
+	$(call gb_Helper_optional,SCRIPTING, \
+		sc/util/vbaobj) \
+	sfx2/util/sfx \
+	sot/util/sot \
+	svl/source/fsstor/fsstorage \
+	toolkit/util/tk \
+	ucb/source/core/ucb1 \
+	ucb/source/ucp/file/ucpfile1 \
+	ucb/source/ucp/tdoc/ucptdoc1 \
+	unotools/util/utl \
+	unoxml/source/rdf/unordf \
+	unoxml/source/service/unoxml \
+	xmloff/util/xo \
+	svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_condformats))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_condformats))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 9385dc5..18a1eb8 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -51,6 +51,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
 ))
 
 $(eval $(call gb_Module_add_slowcheck_targets,sc, \
+    CppunitTest_sc_condformats \
     CppunitTest_sc_subsequent_filters_test \
     CppunitTest_sc_subsequent_export_test \
     CppunitTest_sc_html_export_test \
diff --git a/sc/qa/extras/sccondformats.cxx b/sc/qa/extras/sccondformats.cxx
new file mode 100644
index 0000000..4a664c4
--- /dev/null
+++ b/sc/qa/extras/sccondformats.cxx
@@ -0,0 +1,136 @@
+/* -*- 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/.
+ */
+
+#include <test/calc_unoapi_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/ConditionOperator.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <unonames.hxx>
+
+using namespace css;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 1
+
+class ScConditionalFormatTest : public CalcUnoApiTest
+{
+public:
+    ScConditionalFormatTest();
+
+    virtual void setUp() SAL_OVERRIDE;
+    virtual void tearDown() SAL_OVERRIDE;
+
+    uno::Reference< uno::XInterface > init();
+    void testCondFormat();
+
+    CPPUNIT_TEST_SUITE(ScConditionalFormatTest);
+    CPPUNIT_TEST(testCondFormat);
+    CPPUNIT_TEST_SUITE_END();
+private:
+
+    static sal_Int32 nTest;
+    static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScConditionalFormatTest::nTest = 0;
+uno::Reference< lang::XComponent > ScConditionalFormatTest::mxComponent;
+
+ScConditionalFormatTest::ScConditionalFormatTest()
+    : CalcUnoApiTest("sc/qa/unit/data/ods")
+{
+}
+
+uno::Reference< uno::XInterface > ScConditionalFormatTest::init()
+{
+    // get the test file
+    OUString aFileURL;
+    createFileURL(OUString("new_cond_format_test.ods"), aFileURL);
+    if(!mxComponent.is())
+        mxComponent = loadFromDesktop(aFileURL);
+    CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
+
+    // get the first sheet
+    uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
+
+    return xSheet;
+}
+
+void ScConditionalFormatTest::testCondFormat()
+{
+    uno::Reference< sheet::XSpreadsheet > aSheet(init(), uno::UNO_QUERY_THROW);
+    uno::Reference< beans::XPropertySet > xProps;
+    uno::Reference< sheet::XSheetConditionalEntries > xSheetConditionalEntries;
+
+    xProps.set(aSheet->getCellRangeByPosition(1, 1, 1, 21), uno::UNO_QUERY_THROW);
+    xSheetConditionalEntries.set(xProps->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSheetConditionalEntries->getCount());
+
+    uno::Sequence< beans::PropertyValue > aPropertyValueList(5);
+    aPropertyValueList[0].Name = SC_UNONAME_STYLENAME;
+    aPropertyValueList[0].Value <<= uno::makeAny<OUString>("Result2");
+    aPropertyValueList[1].Name = SC_UNONAME_FORMULA1;
+    aPropertyValueList[1].Value <<= uno::makeAny<OUString>("$Sheet1.$B$2");
+    aPropertyValueList[2].Name = SC_UNONAME_FORMULA2;
+    aPropertyValueList[2].Value <<= uno::makeAny<OUString>("$Sheet1.$A$2");
+    aPropertyValueList[3].Name = SC_UNONAME_OPERATOR;
+    aPropertyValueList[3].Value <<= sheet::ConditionOperator_EQUAL;
+    aPropertyValueList[4].Name = SC_UNONAME_SOURCEPOS;
+    aPropertyValueList[4].Value <<= uno::makeAny(table::CellAddress(0, 0, 16));
+    xSheetConditionalEntries->addNew(aPropertyValueList);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSheetConditionalEntries->getCount());
+    xProps->setPropertyValue(SC_UNONAME_CONDFMT, uno::makeAny(xSheetConditionalEntries));
+
+    xProps.set(aSheet->getCellByPosition(0, 16), uno::UNO_QUERY_THROW);
+    xSheetConditionalEntries.set(xProps->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSheetConditionalEntries->getCount());
+
+    // clear conditional formatting in cell $B$17
+    xProps.set(aSheet->getCellByPosition(1, 16), uno::UNO_QUERY_THROW);
+    xSheetConditionalEntries.set(xProps->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSheetConditionalEntries->getCount());
+    xSheetConditionalEntries->clear();
+    xProps->setPropertyValue(SC_UNONAME_CONDFMT, uno::makeAny(xSheetConditionalEntries));
+
+    xProps.set(aSheet->getCellByPosition(1, 16), uno::UNO_QUERY_THROW);
+    xSheetConditionalEntries.set(xProps->getPropertyValue(SC_UNONAME_CONDFMT), uno::UNO_QUERY_THROW);
+    // This was 1 before - conditional formats were not removed
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xSheetConditionalEntries->getCount());
+}
+
+void ScConditionalFormatTest::setUp()
+{
+    nTest++;
+    CalcUnoApiTest::setUp();
+}
+
+void ScConditionalFormatTest::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScConditionalFormatTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 67c989adc57eb279c478f59869499439ec65665f
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Tue Dec 23 20:39:53 2014 +0100

    fdo#82014: Remove old conditional formats when setting new one by UNO API
    
    Change-Id: I76488045eba281227124041da505e38c4c3d31c1

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 26d55e1..21a8eb6 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -132,6 +132,7 @@ public:
                                 const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
 
     void    AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
+    /// if nIndex == 0, remove all conditional format data
     void    RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
 
     void    ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 0f7683c..1e360ab 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -308,15 +308,17 @@ void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 n
             {
                 std::vector< sal_uInt32 > aCondFormatData = static_cast<const ScCondFormatItem*>(pItem)->GetCondFormatData();
                 std::vector<sal_uInt32>::iterator itr = std::find(aCondFormatData.begin(), aCondFormatData.end(), nIndex);
-                if(itr != aCondFormatData.end())
+                if(itr != aCondFormatData.end() || nIndex == 0)
                 {
                     ScCondFormatItem aItem;
-                    aCondFormatData.erase(itr);
+                    if (nIndex == 0)
+                        aCondFormatData.clear();
+                    else
+                        aCondFormatData.erase(itr);
                     aItem.SetCondFormatData( aCondFormatData );
                     aPattern.GetItemSet().Put( aItem );
                     SetPatternArea( nTempStartRow, nTempEndRow, &aPattern, true );
                 }
-
             }
         }
         else
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 6ec3abe..5228bab 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2392,11 +2392,26 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
                                        formula::FormulaGrammar::GRAM_UNSPECIFIED :
                                        formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
 
-                                ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc );    // Index wird beim Einfuegen gesetzt
-                                pFormat->FillFormat( *pNew, &rDoc, eGrammar );
-                                pNew->AddRange( aRanges );
                                 SCTAB nTab = aRanges.front()->aStart.Tab();
-                                pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
+                                // To remove conditional formats for all cells in aRanges we need to:
+                                // Remove conditional format data from cells' attributes
+                                rDoc.RemoveCondFormatData( aRanges, nTab,  0 );
+                                // And also remove ranges from conditional formats list
+                                for (size_t i = 0; i < aRanges.size(); ++i)
+                                {
+                                    rDoc.GetCondFormList( aRanges[i]->aStart.Tab() )->DeleteArea(
+                                        aRanges[i]->aStart.Col(), aRanges[i]->aStart.Row(),
+                                        aRanges[i]->aEnd.Col(), aRanges[i]->aEnd.Row() );
+                                }
+
+                                // Then we can apply new conditional format if there is one
+                                if (pFormat->getCount())
+                                {
+                                    ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc );    // Index wird beim Einfuegen gesetzt
+                                    pFormat->FillFormat( *pNew, &rDoc, eGrammar );
+                                    pNew->AddRange( aRanges );
+                                    pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
+                                }
                             }
                         }
                     }
commit 57fa90ba145455a48247b0fef110aa8f87a86a5d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Jan 4 02:54:38 2015 +0100

    fix invalid string access
    
    Change-Id: I758ee4a53a80d89662bc081f435b01bc6f9c3087

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index bd07118..180c864 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1034,11 +1034,16 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult )
         return false; // last character is not part of any function name, quit
 
     ::std::vector<sal_Unicode> aTemp;
-    while ( nPos >= 0 && p != maFormulaChar.end() )
+    aTemp.push_back( c );
+    for(sal_Int32 i = nPos - 1; i >= 0; --i)
     {
-        aTemp.push_back( c );
-        c = aStart[ --nPos ];
+        c = aStart[ i ];
         p = maFormulaChar.find( c );
+
+        if (p == maFormulaChar.end())
+            break;
+
+        aTemp.push_back( c );
     }
 
     ::std::vector<sal_Unicode>::reverse_iterator rIt = aTemp.rbegin();


More information about the Libreoffice-commits mailing list