Kaydet (Commit) 39c08074 authored tarafından Szymon Kłos's avatar Szymon Kłos

Watermark: not visible if page background was set

Watermark was drawn under the page background.
It has to be placed on the upper layer to be visible.

Change-Id: I132a313eed6fb712aafdca14a38fe559aa4231c8
Reviewed-on: https://gerrit.libreoffice.org/41289Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst ab8b8fb1
...@@ -30,8 +30,10 @@ ...@@ -30,8 +30,10 @@
#include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp>
#include <ftninfo.hxx> #include <ftninfo.hxx>
#include <drawdoc.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx> #include <sfx2/docfilt.hxx>
#include <svx/svdpage.hxx>
class Test : public SwModelTestBase class Test : public SwModelTestBase
{ {
...@@ -993,6 +995,18 @@ DECLARE_OOXMLEXPORT_TEST(testActiveXControlAtRunEnd, "activex_control_at_run_end ...@@ -993,6 +995,18 @@ DECLARE_OOXMLEXPORT_TEST(testActiveXControlAtRunEnd, "activex_control_at_run_end
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType")); CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
} }
DECLARE_OOXMLEXPORT_TEST(testWatermarkLayer, "watermark-layer.docx")
{
// Watermark was not visible if page background was set.
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
SdrPage* pPage = pTextDoc->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
SdrObject* pObject = pPage->GetObj(0);
CPPUNIT_ASSERT(pObject);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(1), pObject->GetLayer().get());
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <pagefrm.hxx> #include <pagefrm.hxx>
#include <rdfhelper.hxx> #include <rdfhelper.hxx>
#include <sfx2/watermarkitem.hxx> #include <sfx2/watermarkitem.hxx>
#include <DocumentDrawModelManager.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
...@@ -352,7 +353,8 @@ SfxWatermarkItem SwEditShell::GetWatermark() ...@@ -352,7 +353,8 @@ SfxWatermarkItem SwEditShell::GetWatermark()
void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
const uno::Reference<frame::XModel>& xModel, const uno::Reference<frame::XModel>& xModel,
const uno::Reference<beans::XPropertySet>& xPageStyle, const uno::Reference<beans::XPropertySet>& xPageStyle,
const uno::Reference<text::XText>& xHeaderText) const uno::Reference<text::XText>& xHeaderText,
sal_Int16 nLayer)
{ {
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY); uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY);
OUString aShapeServiceName = "com.sun.star.drawing.CustomShape"; OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
...@@ -474,6 +476,7 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark, ...@@ -474,6 +476,7 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
xPropertySet->setPropertyValue("Transformation", uno::makeAny(aMatrix)); xPropertySet->setPropertyValue("Transformation", uno::makeAny(aMatrix));
xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::HoriOrientation::CENTER))); xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::HoriOrientation::CENTER)));
xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::VertOrientation::CENTER))); xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::VertOrientation::CENTER)));
xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_LAYERID, uno::makeAny(nLayer));
uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY); uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY);
xTextRange->setString(rWatermark.GetText()); xTextRange->setString(rWatermark.GetText());
...@@ -519,6 +522,8 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark) ...@@ -519,6 +522,8 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark)
uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
sal_Int16 nHeavenId = GetDoc()->getIDocumentDrawModelAccess().GetHeavenId().get();
std::set<OUString> aUsedPageStyles = lcl_getUsedPageStyles(this); std::set<OUString> aUsedPageStyles = lcl_getUsedPageStyles(this);
for (const OUString& rPageStyleName : aUsedPageStyles) for (const OUString& rPageStyleName : aUsedPageStyles)
{ {
...@@ -544,16 +549,16 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark) ...@@ -544,16 +549,16 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark)
uno::Reference<text::XText> xHeaderTextRight; uno::Reference<text::XText> xHeaderTextRight;
xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText; xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText;
lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderText); lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderText, nHeavenId);
xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_FIRST) >>= xHeaderTextFirst; xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_FIRST) >>= xHeaderTextFirst;
lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextFirst); lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextFirst, nHeavenId);
xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_LEFT) >>= xHeaderTextLeft; xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_LEFT) >>= xHeaderTextLeft;
lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextLeft); lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextLeft, nHeavenId);
xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_RIGHT) >>= xHeaderTextRight; xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_RIGHT) >>= xHeaderTextRight;
lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextRight); lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, xHeaderTextRight, nHeavenId);
// tdf#108494 the header height was switched to height of a watermark // tdf#108494 the header height was switched to height of a watermark
// and shape was moved to the lower part of a page // and shape was moved to the lower part of a page
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
#include <comphelper/propertyvalue.hxx> #include <comphelper/propertyvalue.hxx>
#include <comphelper/propertysequence.hxx> #include <comphelper/propertysequence.hxx>
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <editeng/unoprnms.hxx>
...@@ -2185,6 +2185,14 @@ void DomainMapper_Impl::PopShapeContext() ...@@ -2185,6 +2185,14 @@ void DomainMapper_Impl::PopShapeContext()
{ {
} }
} }
// Move Watermark upper to be visible if page background is set
uno::Reference<drawing::XShape> xShape( xObj, uno::UNO_QUERY_THROW );
uno::Reference<container::XNamed> xNamed( xShape, uno::UNO_QUERY );
if ( xNamed.is() && xNamed->getName().match( "PowerPlusWaterMarkObject" ) )
{
uno::Reference<beans::XPropertySet> xShapePropertySet( xShape, uno::UNO_QUERY );
xShapePropertySet->setPropertyValue( UNO_NAME_MISC_OBJ_LAYERID, uno::makeAny( sal_Int16(1) ) );
}
m_aAnchoredStack.pop(); m_aAnchoredStack.pop();
} }
m_bFrameBtLr = false; m_bFrameBtLr = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment