summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-05-19 00:18:15 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2017-06-01 08:10:00 +0200
commit489597d339af14a6403ee079bea35908112720ec (patch)
tree86fff09ced71a625e030cdc2325e1644ba5c1cd3
parentabf39e521178e3438dc507167e18a24d160b3fd5 (diff)
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@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--include/sfx2/sfxsids.hrc8
-rw-r--r--include/sfx2/watermarkitem.hxx16
-rw-r--r--sfx2/sdi/sfx.sdi5
-rw-r--r--sfx2/source/doc/watermarkitem.cxx28
-rw-r--r--sw/inc/editsh.hxx2
-rw-r--r--sw/source/core/edit/edfcol.cxx66
-rw-r--r--sw/source/uibase/app/docsh2.cxx16
-rw-r--r--sw/source/uibase/app/docst.cxx5
-rw-r--r--sw/source/uibase/dialog/watermarkdialog.cxx46
-rw-r--r--sw/source/uibase/inc/watermarkdialog.hxx7
-rw-r--r--sw/uiconfig/swriter/ui/watermarkdialog.ui109
11 files changed, 262 insertions, 46 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index dbd8ab6ef39d..cfc59403d198 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -344,7 +344,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)
@@ -411,9 +414,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 88735bbf9088..95d16d1588ee 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4458,7 +4458,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 db7a5346a586..e031303b6aae 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -367,7 +367,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 029eb57be727..4f1967dc9648 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));
@@ -407,15 +445,15 @@ void SwEditShell::SetWatermark(const OUString& rWatermark)
xPropertySet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWWIDTH, uno::makeAny(false));
xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEHEIGHT, uno::makeAny(nHeight));
xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEWIDTH, uno::makeAny(nWidth));
- xPropertySet->setPropertyValue(UNO_NAME_TEXT_WRAP, uno::makeAny(text::WrapTextMode_THROUGH));
+ xPropertySet->setPropertyValue(UNO_NAME_TEXT_WRAP, uno::makeAny(text::WrapTextMode_THROUGHT));
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 7268c502230e..55db8a619643 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -57,6 +57,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>
@@ -1167,8 +1168,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 cffd2eca88ca..6eff974face6 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>