summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-10 17:46:55 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-04-13 10:46:29 +0200
commit7ed2e2e74d86cc2c9c3e1fe18f5ab160c89d3a44 (patch)
treec18837b9d0974a5b4d3c2d11c883742eee439aa8
parentf8d654bba844050a01a232eb8013561da57ed6e0 (diff)
tdf#116925 sw: consider fill styles of shape for in-textbox auto color
Automatic color is determined in SwDrawTextInfo::ApplyAutoColor(), but it uses this function to determine the background color. Be consistent and consider the same background in both the shape-with-editeng-text and shape-with-sw-text cases. (cherry picked from commit f966767e1ccfa432da33e1a0fd6de69e17a36bc3) Change-Id: I52249a908193765bc128789d96187af334c1017c Reviewed-on: https://gerrit.libreoffice.org/52707 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/qa/extras/layout/data/tdf116925.docxbin0 -> 13476 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx22
-rw-r--r--sw/source/core/layout/paintfrm.cxx26
3 files changed, 47 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/data/tdf116925.docx b/sw/qa/extras/layout/data/tdf116925.docx
new file mode 100644
index 000000000000..1c99752e9eba
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf116925.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 16efa14c5875..3709e306f53d 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -17,9 +17,11 @@ class SwLayoutWriter : public SwModelTestBase
{
public:
void testTdf116830();
+ void testTdf116925();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
+ CPPUNIT_TEST(testTdf116925);
CPPUNIT_TEST_SUITE_END();
private:
@@ -62,6 +64,26 @@ void SwLayoutWriter::testTdf116830()
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/rect", 1);
}
+void SwLayoutWriter::testTdf116925()
+{
+ SwDoc* pDoc = createDoc("tdf116925.docx");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocPtr pXmlDoc = dumper.dumpAndParse(*xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPathContent(pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textarray/text",
+ "hello");
+ // This failed, text color was #000000.
+ assertXPath(
+ pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textcolor[@color='#ffffff']", 1);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 80d12a53f873..4c54017b14b7 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -100,6 +100,7 @@
#include <edtwin.hxx>
#include <view.hxx>
#include <paintfrm.hxx>
+#include <textboxhelper.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <vcl/BitmapTools.hxx>
@@ -7347,7 +7348,30 @@ bool SwFrame::GetBackgroundBrush(
return false;
if (pFrame->supportsFullDrawingLayerFillAttributeSet())
- rFillAttributes = pFrame->getSdrAllFillAttributesHelper();
+ {
+ bool bTextBox = false;
+ if (pFrame->IsFlyFrame())
+ {
+ const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(pFrame);
+ SwFrameFormat* pShape
+ = SwTextBoxHelper::getOtherTextBoxFormat(pFlyFrame->GetFormat(), RES_FLYFRMFMT);
+ if (pShape)
+ {
+ SdrObject* pObject = pShape->FindRealSdrObject();
+ if (pObject)
+ {
+ // Work with the fill attributes of the shape of the fly frame.
+ rFillAttributes.reset(
+ new drawinglayer::attribute::SdrAllFillAttributesHelper(
+ pObject->GetMergedItemSet()));
+ bTextBox = true;
+ }
+ }
+ }
+
+ if (!bTextBox)
+ rFillAttributes = pFrame->getSdrAllFillAttributesHelper();
+ }
const SvxBrushItem &rBack = pFrame->GetAttrSet()->GetBackground();
if( pFrame->IsSctFrame() )