[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - include/sfx2 sfx2/sdi sfx2/source sw/inc sw/source sw/uiconfig

Szymon Kłos szymon.klos at collabora.com
Mon May 22 09:24:19 UTC 2017


 include/sfx2/sfxsids.hrc                    |    8 +-
 include/sfx2/watermarkitem.hxx              |   16 +++-
 sfx2/sdi/sfx.sdi                            |    5 +
 sfx2/source/doc/watermarkitem.cxx           |   28 +++++--
 sw/inc/editsh.hxx                           |    2 
 sw/source/core/edit/edfcol.cxx              |   64 +++++++++++++---
 sw/source/uibase/app/docsh2.cxx             |   16 +++-
 sw/source/uibase/app/docst.cxx              |    5 -
 sw/source/uibase/dialog/watermarkdialog.cxx |   46 ++++++++++-
 sw/source/uibase/inc/watermarkdialog.hxx    |    7 +
 sw/uiconfig/swriter/ui/watermarkdialog.ui   |  109 ++++++++++++++++++++++++++--
 11 files changed, 261 insertions(+), 45 deletions(-)

New commits:
commit e6ce02a0eea22468b80ea3fa424fcbefdbcd3b43
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Fri May 19 00:18:15 2017 +0200

    Watermark: extended configuration
    
    * it is possible to set font family,
      color, angle and transparency
    
    Change-Id: Idea2fb9ee748394bb3d706fa790e109238584cdb
    Reviewed-on: https://gerrit.libreoffice.org/37793
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    (cherry picked from commit 48906a5e899e517af76e04afb5659232b336e206)
    Reviewed-on: https://gerrit.libreoffice.org/37835

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index c17b2e850c20..3384b0558287 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -330,7 +330,10 @@
 #define SID_INSERT_FLOATINGFRAME            (SID_SFX_START + 563)
 #define SID_CLASSIFICATION_APPLY            (SID_SFX_START + 672)
 #define SID_WATERMARK                       (SID_SFX_START + 676)
-// FREE                                     (SID_SFX_START + 677)
+#define SID_WATERMARK_FONT                  (SID_SFX_START + 677)
+#define SID_WATERMARK_TRANSPARENCY          (SID_SFX_START + 805)
+#define SID_WATERMARK_COLOR                 (SID_SFX_START + 806)
+#define SID_WATERMARK_ANGLE                 (SID_SFX_START + 807)
 
 #define SID_HYPERLINK_DIALOG                (SID_SFX_START + 678)
 
@@ -394,9 +397,6 @@
 #define SID_PASTE_ONLY_TEXT                 (SID_SFX_START + 802)
 #define SID_PASTE_ONLY_FORMULA              (SID_SFX_START + 803)
 #define SID_PASTE_ONLY_VALUE                (SID_SFX_START + 804)
-    // FREE: SID_SFX_START + 805
-    // FREE: SID_SFX_START + 806
-    // FREE: SID_SFX_START + 807
     // FREE: SID_SFX_START + 808
     // FREE: SID_SFX_START + 809
     // FREE: SID_SFX_START + 810
diff --git a/include/sfx2/watermarkitem.hxx b/include/sfx2/watermarkitem.hxx
index 760aab3b0285..9fd7a91415a4 100644
--- a/include/sfx2/watermarkitem.hxx
+++ b/include/sfx2/watermarkitem.hxx
@@ -17,17 +17,29 @@ class SFX2_DLLPUBLIC SfxWatermarkItem: public SfxPoolItem
 public:
     static SfxPoolItem* CreateDefault();
     SfxWatermarkItem();
-    SfxWatermarkItem( sal_uInt16 nWhich, const OUString &rText );
     SfxWatermarkItem( const SfxWatermarkItem& );
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = nullptr ) const override;
     virtual bool            operator==( const SfxPoolItem& ) const override;
     virtual bool            QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
     virtual bool            PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
 
-    const OUString&         GetText() const { return m_aText; }
+    const OUString          GetText() const { return m_aText; }
+    void                    SetText(const OUString& aText) { m_aText = aText; }
+    const OUString          GetFont() const { return m_aFont; }
+    void                    SetFont(const OUString& aFont) { m_aFont = aFont; }
+    sal_Int16               GetAngle() const { return m_nAngle; }
+    void                    SetAngle(const sal_Int16 nAngle) { m_nAngle = nAngle; }
+    sal_Int16               GetTransparency() const { return m_nTransparency; }
+    void                    SetTransparency(const sal_Int16 nTransparency) { m_nTransparency = nTransparency; }
+    sal_uInt32              GetColor() const { return m_nColor; }
+    void                    SetColor(const sal_uInt32 nColor) { m_nColor = nColor; }
 
 private:
     OUString                m_aText;
+    OUString                m_aFont;
+    sal_Int16               m_nAngle;
+    sal_Int16               m_nTransparency;
+    sal_uInt32              m_nColor;
 };
 
 #endif
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 6fce89a16635..03b536d3c4d6 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4268,7 +4268,10 @@ SfxVoidItem ClassificationApply SID_CLASSIFICATION_APPLY
 ]
 
 SfxWatermarkItem Watermark SID_WATERMARK
-(SfxStringItem Text SID_WATERMARK)
+(SfxStringItem Text SID_WATERMARK, SfxStringItem Font SID_WATERMARK_FONT,
+ SfxInt16Item Angle SID_WATERMARK_ANGLE, SfxInt16Item Transparency SID_WATERMARK_TRANSPARENCY,
+ SfxUInt32Item Color SID_WATERMARK_COLOR
+)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/doc/watermarkitem.cxx b/sfx2/source/doc/watermarkitem.cxx
index 00c31f25d823..ebb794fcd73e 100644
--- a/sfx2/source/doc/watermarkitem.cxx
+++ b/sfx2/source/doc/watermarkitem.cxx
@@ -13,6 +13,10 @@
 SfxWatermarkItem::SfxWatermarkItem()
 : SfxPoolItem( SID_WATERMARK )
 , m_aText( "" )
+, m_aFont( "Liberation Sans" )
+, m_nAngle( 45 )
+, m_nTransparency( 50 )
+, m_nColor( 0xc0c0c0 )
 {
 }
 
@@ -21,22 +25,24 @@ SfxPoolItem* SfxWatermarkItem::CreateDefault()
     return new SfxWatermarkItem();
 }
 
-SfxWatermarkItem::SfxWatermarkItem( sal_uInt16 nWhichId, const OUString& rText )
-: SfxPoolItem( nWhichId )
-, m_aText( rText )
-{
-}
-
 SfxWatermarkItem::SfxWatermarkItem( const SfxWatermarkItem& rCopy )
 : SfxPoolItem( rCopy )
 , m_aText( rCopy.m_aText )
+, m_aFont( rCopy.m_aFont )
+, m_nAngle( rCopy.m_nAngle )
+, m_nTransparency( rCopy.m_nTransparency )
+, m_nColor( rCopy.m_nColor )
 {
 }
 
 bool SfxWatermarkItem::operator==( const SfxPoolItem& rCmp ) const
 {
     return ( SfxPoolItem::operator==( rCmp ) &&
-             m_aText == static_cast<const SfxWatermarkItem&>(rCmp).m_aText );
+             m_aText == static_cast<const SfxWatermarkItem&>(rCmp).m_aText &&
+             m_aFont == static_cast<const SfxWatermarkItem&>(rCmp).m_aFont &&
+             m_nAngle == static_cast<const SfxWatermarkItem&>(rCmp).m_nAngle &&
+             m_nTransparency == static_cast<const SfxWatermarkItem&>(rCmp).m_nTransparency &&
+             m_nColor == static_cast<const SfxWatermarkItem&>(rCmp).m_nColor );
 }
 
 SfxPoolItem* SfxWatermarkItem::Clone( SfxItemPool *) const
@@ -47,6 +53,10 @@ SfxPoolItem* SfxWatermarkItem::Clone( SfxItemPool *) const
 bool SfxWatermarkItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
 {
     rVal <<= m_aText;
+    rVal <<= m_aFont;
+    rVal <<= m_nAngle;
+    rVal <<= m_nTransparency;
+    rVal <<= m_nColor;
 
     return true;
 }
@@ -58,6 +68,10 @@ bool SfxWatermarkItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberI
     if ( rVal >>= aText )
     {
         m_aText = aText;
+        rVal >>= m_aFont;
+        rVal >>= m_nAngle;
+        rVal >>= m_nTransparency;
+        rVal >>= m_nColor;
         return true;
     }
 
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 63842e296c84..6f3669a95ba1 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -368,7 +368,7 @@ public:
     void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
 
     SfxWatermarkItem GetWatermark();
-    void SetWatermark(const OUString& rText);
+    void SetWatermark(const SfxWatermarkItem& rText);
 
     void Insert2(SwField&, const bool bForceExpandHints);
 
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 024278e9971f..97129c354583 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -229,7 +229,9 @@ void SwEditShell::SetClassification(const OUString& rName, SfxClassificationPoli
                 }
             }
 
-            SetWatermark(aWatermark);
+            SfxWatermarkItem aWatermarkItem;
+            aWatermarkItem.SetText(aWatermark);
+            SetWatermark(aWatermarkItem);
         }
 
         if (bFooterIsNeeded)
@@ -260,7 +262,7 @@ SfxWatermarkItem SwEditShell::GetWatermark()
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
     if (!pDocShell)
-        return SfxWatermarkItem(SID_WATERMARK, "");
+        return SfxWatermarkItem();
 
     uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel();
     uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY);
@@ -286,14 +288,30 @@ SfxWatermarkItem SwEditShell::GetWatermark()
 
         if (xWatermark.is())
         {
+            SfxWatermarkItem aItem;
             uno::Reference<text::XTextRange> xTextRange(xWatermark, uno::UNO_QUERY);
-            return SfxWatermarkItem(SID_WATERMARK, xTextRange->getString());
+            uno::Reference<beans::XPropertySet> xPropertySet(xWatermark, uno::UNO_QUERY);
+            sal_uInt32 nColor;
+            sal_Int16 nTransparency;
+            OUString aFont;
+
+            aItem.SetText(xTextRange->getString());
+
+            if (xPropertySet->getPropertyValue(UNO_NAME_CHAR_FONT_NAME) >>= aFont)
+                aItem.SetFont(aFont);
+            if (xPropertySet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= nColor)
+                aItem.SetColor(nColor);
+            // TODO: aItem.SetAngle(nAngle);
+            if (xPropertySet->getPropertyValue(UNO_NAME_FILL_TRANSPARENCE) >>= nTransparency)
+                aItem.SetTransparency(nTransparency);
+
+            return aItem;
         }
     }
-    return SfxWatermarkItem(SID_WATERMARK, "");
+    return SfxWatermarkItem();
 }
 
-void SwEditShell::SetWatermark(const OUString& rWatermark)
+void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark)
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
     if (!pDocShell)
@@ -326,12 +344,26 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
         static const OUString sWatermark = SfxClassificationHelper::PROP_PREFIX_INTELLECTUALPROPERTY() + SfxClassificationHelper::PROP_DOCWATERMARK();
         uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, sWatermark);
 
-        bool bDeleteWatermark = rWatermark.isEmpty();
+        bool bDeleteWatermark = rWatermark.GetText().isEmpty();
         if (xWatermark.is())
         {
+            sal_uInt32 nColor = 0xc0c0c0;
+            sal_Int16 nTransparency = 50;
+            OUString aFont = "";
+
+            uno::Reference<beans::XPropertySet> xPropertySet(xWatermark, uno::UNO_QUERY);
+            xPropertySet->getPropertyValue(UNO_NAME_CHAR_FONT_NAME) >>= aFont;
+            xPropertySet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= nColor;
+            // TODO: Angle
+            xPropertySet->getPropertyValue(UNO_NAME_FILL_TRANSPARENCE) >>= nTransparency;
+
             // If the header already contains a watermark, see if it its text is up to date.
             uno::Reference<text::XTextRange> xTextRange(xWatermark, uno::UNO_QUERY);
-            if (xTextRange->getString() != rWatermark || bDeleteWatermark)
+            if (xTextRange->getString() != rWatermark.GetText()
+                || aFont != rWatermark.GetFont()
+                || nColor != rWatermark.GetColor()
+                || nTransparency != rWatermark.GetTransparency()
+                || bDeleteWatermark)
             {
                 // No: delete it and we'll insert a replacement.
                 uno::Reference<lang::XComponent> xComponent(xWatermark, uno::UNO_QUERY);
@@ -342,12 +374,18 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
 
         if (!xWatermark.is() && !bDeleteWatermark)
         {
+            OUString sFont = rWatermark.GetFont();
+            sal_Int16 nAngle = rWatermark.GetAngle();
+            sal_Int16 nTransparency = rWatermark.GetTransparency();
+            sal_uInt32 nColor = rWatermark.GetColor();
+
             // Calc the ratio.
             double fRatio = 0;
             OutputDevice* pOut = Application::GetDefaultDevice();
             vcl::Font aFont(pOut->GetFont());
+            aFont.SetFamilyName(sFont);
             fRatio = aFont.GetFontSize().Height();
-            fRatio /= pOut->GetTextWidth(rWatermark);
+            fRatio /= pOut->GetTextWidth(rWatermark.GetText());
 
             // Calc the size.
             sal_Int32 nWidth = 0;
@@ -378,7 +416,7 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
             basegfx::B2DHomMatrix aTransformation;
             aTransformation.identity();
             aTransformation.scale(nWidth, nHeight);
-            aTransformation.rotate(F_PI180 * -45);
+            aTransformation.rotate(F_PI180 * -1 * nAngle);
             drawing::HomogenMatrix3 aMatrix;
             aMatrix.Line1.Column1 = aTransformation.get(0, 0);
             aMatrix.Line1.Column2 = aTransformation.get(0, 1);
@@ -397,9 +435,9 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
             // The remaining properties have to be set after the shape is inserted: do that in one batch to avoid flickering.
             uno::Reference<document::XActionLockable> xLockable(xShape, uno::UNO_QUERY);
             xLockable->addActionLock();
-            xPropertySet->setPropertyValue(UNO_NAME_FILLCOLOR, uno::makeAny(static_cast<sal_Int32>(0xc0c0c0)));
+            xPropertySet->setPropertyValue(UNO_NAME_FILLCOLOR, uno::makeAny(static_cast<sal_Int32>(nColor)));
             xPropertySet->setPropertyValue(UNO_NAME_FILLSTYLE, uno::makeAny(drawing::FillStyle_SOLID));
-            xPropertySet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::makeAny(static_cast<sal_Int16>(50)));
+            xPropertySet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::makeAny(nTransparency));
             xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION, uno::makeAny(static_cast<sal_Int16>(text::RelOrientation::PAGE_PRINT_AREA)));
             xPropertySet->setPropertyValue(UNO_NAME_LINESTYLE, uno::makeAny(drawing::LineStyle_NONE));
             xPropertySet->setPropertyValue(UNO_NAME_OPAQUE, uno::makeAny(false));
@@ -409,13 +447,13 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
             xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEWIDTH, uno::makeAny(nWidth));
             xPropertySet->setPropertyValue(UNO_NAME_TEXT_WRAP, uno::makeAny(text::WrapTextMode_THROUGH));
             xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT_RELATION, uno::makeAny(static_cast<sal_Int16>(text::RelOrientation::PAGE_PRINT_AREA)));
-            xPropertySet->setPropertyValue(UNO_NAME_CHAR_FONT_NAME, uno::makeAny(OUString("Liberation Sans")));
+            xPropertySet->setPropertyValue(UNO_NAME_CHAR_FONT_NAME, uno::makeAny(sFont));
             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_VERT_ORIENT, uno::makeAny(static_cast<sal_Int16>(text::VertOrientation::CENTER)));
 
             uno::Reference<text::XTextRange> xTextRange(xShape, uno::UNO_QUERY);
-            xTextRange->setString(rWatermark);
+            xTextRange->setString(rWatermark.GetText());
 
             uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(xShape, uno::UNO_QUERY);
             xDefaulter->createCustomShapeDefaults("fontwork-plain-text");
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 767ddcff9929..4cb22e077ef8 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -56,6 +56,7 @@
 #include <svx/fmshell.hxx>
 #include <sfx2/linkmgr.hxx>
 #include <sfx2/classificationhelper.hxx>
+#include <sfx2/watermarkitem.hxx>
 
 #include <svtools/htmlcfg.hxx>
 #include <svx/ofaitem.hxx>
@@ -1163,8 +1164,19 @@ void SwDocShell::Execute(SfxRequest& rReq)
             {
                 if (pArgs && pArgs->GetItemState( SID_WATERMARK, false, &pItem ) == SfxItemState::SET)
                 {
-                    OUString aText = static_cast<const SfxStringItem*>( pItem )->GetValue();
-                    pSh->SetWatermark( aText );
+                    SfxWatermarkItem aItem;
+                    aItem.SetText( static_cast<const SfxStringItem*>( pItem )->GetValue() );
+
+                    if ( pArgs->GetItemState( SID_WATERMARK_FONT, false, &pItem ) == SfxItemState::SET )
+                        aItem.SetFont( static_cast<const SfxStringItem*>( pItem )->GetValue() );
+                    if ( pArgs->GetItemState( SID_WATERMARK_ANGLE, false, &pItem ) == SfxItemState::SET )
+                        aItem.SetAngle( static_cast<const SfxInt16Item*>( pItem )->GetValue() );
+                    if ( pArgs->GetItemState( SID_WATERMARK_TRANSPARENCY, false, &pItem ) == SfxItemState::SET )
+                        aItem.SetTransparency( static_cast<const SfxInt16Item*>( pItem )->GetValue() );
+                    if ( pArgs->GetItemState( SID_WATERMARK_COLOR, false, &pItem ) == SfxItemState::SET )
+                        aItem.SetColor( static_cast<const SfxUInt32Item*>( pItem )->GetValue() );
+
+                    pSh->SetWatermark( aItem );
                 }
                 else
                 {
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 16fed3f39afd..8193e0416964 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -276,10 +276,9 @@ void  SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
                 break;
             case SID_WATERMARK:
                 {
+                    SfxWatermarkItem aItem = pSh->GetWatermark();
                     if( pSh )
-                        rSet.Put(pSh->GetWatermark());
-
-                    rSet.InvalidateItem(nWhich);
+                        rSet.Put(aItem);
                 }
                 break;
             default:
diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx
index bcc6077e9d03..1246eabce4cc 100644
--- a/sw/source/uibase/dialog/watermarkdialog.cxx
+++ b/sw/source/uibase/dialog/watermarkdialog.cxx
@@ -10,11 +10,14 @@
 #include <watermarkdialog.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/dispatchcommand.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/flstitem.hxx>
 #include <sfx2/sfxsids.hrc>
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
 #include <svl/eitem.hxx>
 #include <sfx2/watermarkitem.hxx>
+#include <svtools/ctrltool.hxx>
 
 SwWatermarkDialog::SwWatermarkDialog( vcl::Window* pParent, SfxBindings& rBindings )
 : ModelessDialog( pParent, "WatermarkDialog", "modules/swriter/ui/watermarkdialog.ui" )
@@ -24,9 +27,10 @@ SwWatermarkDialog::SwWatermarkDialog( vcl::Window* pParent, SfxBindings& rBindin
     get( m_pEnableWatermarkCB, "EnableWatermarkCB" );
     get( m_pTextInput, "TextInput" );
     get( m_pOKButton, "ok" );
-
-    m_pEnableWatermarkCB->SetClickHdl( LINK( this, SwWatermarkDialog, CheckBoxHdl ) );
-    m_pOKButton->SetClickHdl( LINK( this, SwWatermarkDialog, OKButtonHdl ) );
+    get( m_pFont, "FontBox" );
+    get( m_pAngle, "Angle" );
+    get( m_pTransparency, "Transparency" );
+    get( m_pColor, "Color" );
 
     InitFields();
     Update();
@@ -39,6 +43,10 @@ SwWatermarkDialog::~SwWatermarkDialog()
 
 void SwWatermarkDialog::dispose()
 {
+    m_pFont.clear();
+    m_pAngle.clear();
+    m_pTransparency.clear();
+    m_pColor.clear();
     m_pTextGrid.clear();
     m_pEnableWatermarkCB.clear();
     m_pTextInput.clear();
@@ -49,14 +57,36 @@ void SwWatermarkDialog::dispose()
 
 void SwWatermarkDialog::InitFields()
 {
+    // Update font list
+    SfxObjectShell* pDocSh = SfxObjectShell::Current();
+    const SfxPoolItem* pFontItem;
+    const FontList* pFontList = nullptr;
+
+    if ( pDocSh && ( ( pFontItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ) ) != nullptr ) )
+        pFontList = static_cast<const SvxFontListItem*>( pFontItem )->GetFontList();
+
+    if(!pFontList)
+        pFontList = new FontList(Application::GetDefaultDevice(), nullptr);
+
+    m_pFont->Fill( pFontList );
+
+    m_pEnableWatermarkCB->SetClickHdl( LINK( this, SwWatermarkDialog, CheckBoxHdl ) );
+    m_pOKButton->SetClickHdl( LINK( this, SwWatermarkDialog, OKButtonHdl ) );
+
+    // Get watermark properties
     const SfxPoolItem* pItem;
     SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pItem );
 
-    if( eState >= SfxItemState::DEFAULT && pItem )
+    if( eState >= SfxItemState::DEFAULT && pItem && pItem->Which() == SID_WATERMARK)
     {
-        OUString sText = static_cast<const SfxWatermarkItem*>( pItem )->GetText();
+        const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>( pItem );
+        OUString sText = pWatermark->GetText();
         m_pEnableWatermarkCB->Check( !sText.isEmpty() );
         m_pTextInput->SetText( sText );
+        m_pFont->SelectEntryPos( m_pFont->GetEntryPos( pWatermark->GetFont() ) );
+        m_pAngle->SetValue( pWatermark->GetAngle() );
+        m_pColor->SelectEntry( pWatermark->GetColor() );
+        m_pTransparency->SetValue( pWatermark->GetTransparency() );
     }
 }
 
@@ -81,7 +111,11 @@ IMPL_LINK_NOARG( SwWatermarkDialog, OKButtonHdl, Button*, void )
 
     css::uno::Sequence<css::beans::PropertyValue> aPropertyValues( comphelper::InitPropertySequence(
     {
-        { "Text", css::uno::makeAny( sText ) }
+        { "Text", css::uno::makeAny( sText ) },
+        { "Font", css::uno::makeAny( m_pFont->GetSelectEntry() ) },
+        { "Angle", css::uno::makeAny( static_cast<sal_Int16>( m_pAngle->GetValue() ) ) },
+        { "Transparency", css::uno::makeAny( static_cast<sal_Int16>( m_pTransparency->GetValue() ) ) },
+        { "Color", css::uno::makeAny( static_cast<sal_uInt32>( m_pColor->GetSelectEntryColor().GetRGBColor() ) ) }
     } ) );
     comphelper::dispatchCommand( ".uno:Watermark", aPropertyValues );
 
diff --git a/sw/source/uibase/inc/watermarkdialog.hxx b/sw/source/uibase/inc/watermarkdialog.hxx
index e1a60b96637d..7f59fe0a2bb7 100644
--- a/sw/source/uibase/inc/watermarkdialog.hxx
+++ b/sw/source/uibase/inc/watermarkdialog.hxx
@@ -10,7 +10,10 @@
 #define INCLUDED_SW_SOURCE_UIBASE_INC_WATERMARKDIALOG_HXX
 
 #include <sfx2/bindings.hxx>
+#include <vcl/field.hxx>
 #include <vcl/layout.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svx/colorbox.hxx>
 
 class SwWatermarkDialog : public ModelessDialog
 {
@@ -32,6 +35,10 @@ private:
     VclPtr<CheckBox> m_pEnableWatermarkCB;
     VclPtr<Edit> m_pTextInput;
     VclPtr<PushButton> m_pOKButton;
+    VclPtr<FontNameBox> m_pFont;
+    VclPtr<NumericField> m_pAngle;
+    VclPtr<NumericField> m_pTransparency;
+    VclPtr<SvxColorListBox> m_pColor;
 };
 
 #endif
diff --git a/sw/uiconfig/swriter/ui/watermarkdialog.ui b/sw/uiconfig/swriter/ui/watermarkdialog.ui
index f4d9b6377440..316cd0c5d8bc 100644
--- a/sw/uiconfig/swriter/ui/watermarkdialog.ui
+++ b/sw/uiconfig/swriter/ui/watermarkdialog.ui
@@ -2,6 +2,17 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
+  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkAdjustment" id="angle_adj">
+    <property name="upper">359</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="transparenct_adj">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkDialog" id="WatermarkDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -86,6 +97,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="label" translatable="yes">Text</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -103,6 +115,97 @@
                     <property name="top_attach">0</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="svtlo-FontNameBox" id="FontBox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="FontLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Font</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="AngleLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Angle</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="TransparencyLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Transparency</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="ColorLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Color</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" id="Angle">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="adjustment">angle_adj</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" id="Transparency">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="adjustment">transparenct_adj</property>
+                    <property name="value">50</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="svxcorelo-SvxColorListBox" id="Color">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">4</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -124,10 +227,4 @@
       <action-widget response="0">cancel</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkTextBuffer" id="textbuffer1">
-    <property name="text" translatable="yes">You did not specify a new name for the attachment.</property>
-  </object>
-  <object class="GtkTextBuffer" id="textbuffer2">
-    <property name="text" translatable="yes">If you would like to provide one, please type it now.</property>
-  </object>
 </interface>


More information about the Libreoffice-commits mailing list