summaryrefslogtreecommitdiff
path: root/starmath/qa
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2019-07-13 20:56:27 +1000
committerTomaž Vajngerl <quikee@gmail.com>2019-09-16 11:13:46 +0200
commit78d225f51404d1a98795541bc9c84f7405502411 (patch)
treedf565f5fe47e78c2f454c9e4247bc423ee596d26 /starmath/qa
parente17c5e1247943300f333c8f0a0f34cebc10738d4 (diff)
tdf#74702: remove GetOutDevType() from SmTmpDevice
Adds in logic to OutputDevice that takes a font color and the font's background color - if the font and background is dark then return the stock white color, if the font and background are bright, then return the stock black color, otherwise just return the font color. Also added a unit test to ensure that SmTmpDevice restores font and test color correctly. Change-Id: Id805682778d82826c644e7a27017c8d30b1ff5eb Reviewed-on: https://gerrit.libreoffice.org/75524 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'starmath/qa')
-rw-r--r--starmath/qa/cppunit/test_starmath.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index f694cd888a23..793545879994 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -8,12 +8,17 @@
*/
#include <sal/config.h>
+
+#include <vcl/print.hxx>
+
#include <test/bootstrapfixture.hxx>
#include <smdll.hxx>
#include <document.hxx>
#include <view.hxx>
+#include <tmpdevice.hxx>
+
#include <sfx2/sfxmodelfactory.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/request.hxx>
@@ -61,6 +66,8 @@ public:
void replacePlaceholder();
void viewZoom();
+ void testSmTmpDeviceRestoreFont();
+
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(editUndoRedo);
CPPUNIT_TEST(editMarker);
@@ -80,6 +87,7 @@ public:
CPPUNIT_TEST(ParseErrorDoubleSubsupscript);
CPPUNIT_TEST(replacePlaceholder);
CPPUNIT_TEST(viewZoom);
+ CPPUNIT_TEST(testSmTmpDeviceRestoreFont);
CPPUNIT_TEST_SUITE_END();
private:
@@ -133,6 +141,35 @@ void Test::tearDown()
BootstrapFixture::tearDown();
}
+void Test::testSmTmpDeviceRestoreFont()
+{
+ ScopedVclPtrInstance<Printer> pPrinter;
+ bool bUseMap100th_mm = true;
+
+ OUString aFontName("Linux Libertine G");
+ CPPUNIT_ASSERT(pPrinter->IsFontAvailable(aFontName));
+
+ vcl::Font aOriginalFont = pPrinter->GetFont();
+ aOriginalFont.SetColor(COL_RED);
+ pPrinter->SetTextColor(COL_RED);
+
+ vcl::Font aNewFont;
+
+ {
+ SmTmpDevice aTmpDev(*pPrinter.get(), bUseMap100th_mm);
+
+ aNewFont = pPrinter->GetFont();
+ aNewFont.SetFamilyName(aFontName);
+ aTmpDev.SetFont(aNewFont);
+
+ CPPUNIT_ASSERT_EQUAL(aFontName, pPrinter->GetFont().GetFamilyName());
+ CPPUNIT_ASSERT_EQUAL(COL_BLACK, pPrinter->GetTextColor());
+ }
+
+ CPPUNIT_ASSERT(aNewFont != pPrinter->GetFont());
+ CPPUNIT_ASSERT_EQUAL(COL_RED, pPrinter->GetTextColor());
+}
+
void Test::editMarker()
{
{