Kaydet (Commit) 08de2c31 authored tarafından Szymon Kłos's avatar Szymon Kłos

Watermark: Insert watermark command

* added new command .uno:Watermark
* if no arguments are provided the dialog
  is opened where user can enter the text
* with provided Text argument the watermark
  is created
* created SfxWatermarkItem to transfer
  watermark properties
* dialog loads current setings
* SetClassification use SetWatermark

Change-Id: Ifc1319f5aa7c11bb141f8e4b5b9a5088613021c2
Reviewed-on: https://gerrit.libreoffice.org/37599Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst 3884bb38
......@@ -329,7 +329,7 @@
#define SID_INSERT_OBJECT (SID_SFX_START + 561)
#define SID_INSERT_FLOATINGFRAME (SID_SFX_START + 563)
#define SID_CLASSIFICATION_APPLY (SID_SFX_START + 672)
// FREE (SID_SFX_START + 676)
#define SID_WATERMARK (SID_SFX_START + 676)
// FREE (SID_SFX_START + 677)
#define SID_HYPERLINK_DIALOG (SID_SFX_START + 678)
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SFX2_WATERMARKITEM_HXX
#define INCLUDED_SFX2_WATERMARKITEM_HXX
#include <sfx2/dllapi.h>
#include <svl/poolitem.hxx>
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; }
private:
OUString m_aText;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -2916,6 +2916,14 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:Watermark" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Watermark</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
</node>
</node>
</oor:component-data>
......@@ -233,6 +233,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/syspath \
sfx2/source/doc/zoomitem \
sfx2/source/doc/templatedlg \
sfx2/source/doc/watermarkitem \
sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
......
......@@ -4267,6 +4267,23 @@ SfxVoidItem ClassificationApply SID_CLASSIFICATION_APPLY
GroupId = GID_DOCUMENT;
]
SfxWatermarkItem Watermark SID_WATERMARK
(SfxStringItem Text SID_WATERMARK)
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = GID_DOCUMENT;
]
SfxUInt16Item SwitchViewShell SID_VIEWSHELL
[
......
......@@ -34,6 +34,7 @@
item String SfxObjectShellItem //! Dummy
item String SfxUsrAnyItem //! Dummy
item String SfxUnoFrameItem //! Dummy
item String SfxWatermarkItem //! Dummy
struct Point
{
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sfx2/watermarkitem.hxx>
#include <sfx2/sfxsids.hrc>
SfxWatermarkItem::SfxWatermarkItem()
: SfxPoolItem( SID_WATERMARK )
, m_aText( "" )
{
}
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 )
{
}
bool SfxWatermarkItem::operator==( const SfxPoolItem& rCmp ) const
{
return ( SfxPoolItem::operator==( rCmp ) &&
m_aText == static_cast<const SfxWatermarkItem&>(rCmp).m_aText );
}
SfxPoolItem* SfxWatermarkItem::Clone( SfxItemPool *) const
{
return new SfxWatermarkItem(*this);
}
bool SfxWatermarkItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{
rVal <<= m_aText;
return true;
}
bool SfxWatermarkItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
OUString aText;
if ( rVal >>= aText )
{
m_aText = aText;
return true;
}
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -592,6 +592,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/dialog/regionsw \
sw/source/uibase/dialog/swabstdlg \
sw/source/uibase/dialog/swwrtshitem \
sw/source/uibase/dialog/watermarkdialog \
sw/source/uibase/dochdl/gloshdl \
sw/source/uibase/dochdl/swdtflvr \
sw/source/uibase/docvw/AnchorOverlayObject \
......
......@@ -277,6 +277,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/viewoptionspage \
sw/uiconfig/swriter/ui/warndatasourcedialog \
sw/uiconfig/swriter/ui/warnemaildialog \
sw/uiconfig/swriter/ui/watermarkdialog \
sw/uiconfig/swriter/ui/wordcount \
sw/uiconfig/swriter/ui/wrapdialog \
sw/uiconfig/swriter/ui/wrappage \
......
......@@ -54,6 +54,7 @@ class CommandExtTextInputData;
class SvNumberFormatter;
class SfxPoolItem;
class SfxItemSet;
class SfxWatermarkItem;
class SvxAutoCorrect;
class SwField;
......@@ -366,6 +367,9 @@ public:
void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
SfxWatermarkItem GetWatermark();
void SetWatermark(const OUString& rText);
void Insert2(SwField&, const bool bForceExpandHints);
void UpdateFields( SwField & ); ///< One single field.
......
......@@ -372,6 +372,12 @@ interface BaseTextSelection
]
SID_CLASSIFICATION_APPLY
[
ExecMethod = Execute ;
StateMethod = StateStyle ;
]
SID_WATERMARK
[
ExecMethod = Execute ;
StateMethod = StateStyle ;
......
This diff is collapsed.
......@@ -123,6 +123,7 @@
#include "dialog.hrc"
#include "swabstdlg.hxx"
#include "watermarkdialog.hxx"
#include <ndtxt.hxx>
......@@ -1155,6 +1156,27 @@ void SwDocShell::Execute(SfxRequest& rReq)
SAL_WARN("sw.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
}
break;
case SID_WATERMARK:
{
SwWrtShell* pSh = GetWrtShell();
if ( pSh )
{
if (pArgs && pArgs->GetItemState( SID_WATERMARK, false, &pItem ) == SfxItemState::SET)
{
OUString aText = static_cast<const SfxStringItem*>( pItem )->GetValue();
pSh->SetWatermark( aText );
}
else
{
SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current();
SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() );
ScopedVclPtr<SwWatermarkDialog> pDlg( VclPtr<SwWatermarkDialog>::Create( nullptr, rBindings ) );
pDlg->Execute();
pDlg.disposeAndClear();
}
}
}
break;
case SID_NOTEBOOKBAR:
{
const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( SID_NOTEBOOKBAR );
......
......@@ -85,6 +85,7 @@
#include <list.hxx>
#include <paratr.hxx>
#include <tblafmt.hxx>
#include <sfx2/watermarkitem.hxx>
using namespace ::com::sun::star;
......@@ -273,6 +274,14 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
break;
case SID_STYLE_EDIT:
break;
case SID_WATERMARK:
{
if( pSh )
rSet.Put(pSh->GetWatermark());
rSet.InvalidateItem(nWhich);
}
break;
default:
OSL_FAIL("Invalid SlotId");
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <watermarkdialog.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/dispatchcommand.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <svl/eitem.hxx>
#include <sfx2/watermarkitem.hxx>
SwWatermarkDialog::SwWatermarkDialog( vcl::Window* pParent, SfxBindings& rBindings )
: ModelessDialog( pParent, "WatermarkDialog", "modules/swriter/ui/watermarkdialog.ui" )
, m_rBindings( rBindings )
{
get( m_pTextGrid, "TextGrid" );
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 ) );
InitFields();
Update();
}
SwWatermarkDialog::~SwWatermarkDialog()
{
disposeOnce();
}
void SwWatermarkDialog::dispose()
{
m_pTextGrid.clear();
m_pEnableWatermarkCB.clear();
m_pTextInput.clear();
m_pOKButton.clear();
ModelessDialog::dispose();
}
void SwWatermarkDialog::InitFields()
{
const SfxPoolItem* pItem;
SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pItem );
if( eState >= SfxItemState::DEFAULT && pItem )
{
OUString sText = static_cast<const SfxWatermarkItem*>( pItem )->GetText();
m_pEnableWatermarkCB->Check( !sText.isEmpty() );
m_pTextInput->SetText( sText );
}
}
void SwWatermarkDialog::Update()
{
if( m_pEnableWatermarkCB->IsChecked() )
m_pTextGrid->Enable();
else
m_pTextGrid->Disable();
}
IMPL_LINK_NOARG( SwWatermarkDialog, CheckBoxHdl, Button*, void )
{
Update();
}
IMPL_LINK_NOARG( SwWatermarkDialog, OKButtonHdl, Button*, void )
{
OUString sText = "";
if( m_pEnableWatermarkCB->IsChecked() )
sText = m_pTextInput->GetText();
css::uno::Sequence<css::beans::PropertyValue> aPropertyValues( comphelper::InitPropertySequence(
{
{ "Text", css::uno::makeAny( sText ) }
} ) );
comphelper::dispatchCommand( ".uno:Watermark", aPropertyValues );
Close();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_WATERMARKDIALOG_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_WATERMARKDIALOG_HXX
#include <sfx2/bindings.hxx>
#include <vcl/layout.hxx>
class SwWatermarkDialog : public ModelessDialog
{
public:
SwWatermarkDialog( vcl::Window* pParent, SfxBindings& rBindings );
virtual ~SwWatermarkDialog() override;
virtual void dispose() override;
void InitFields();
void Update();
private:
DECL_LINK( CheckBoxHdl, Button*, void );
DECL_LINK( OKButtonHdl, Button*, void );
SfxBindings& m_rBindings;
VclPtr<VclGrid> m_pTextGrid;
VclPtr<CheckBox> m_pEnableWatermarkCB;
VclPtr<Edit> m_pTextInput;
VclPtr<PushButton> m_pOKButton;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -957,6 +957,11 @@ void SwBaseShell::Execute(SfxRequest &rReq)
GetView().GetDocShell()->Execute(rReq);
}
break;
case SID_WATERMARK:
{
GetView().GetDocShell()->Execute(rReq);
}
break;
case FN_ESCAPE:
GetView().ExecuteSlot(rReq);
break;
......
......@@ -40,6 +40,7 @@
#include <svx/pageitem.hxx>
#include <svl/srchitem.hxx>
#include <sfx2/tplpitem.hxx>
#include <sfx2/watermarkitem.hxx>
#include <editeng/wrlmitem.hxx>
#include <editeng/protitem.hxx>
#include <editeng/opaqitem.hxx>
......
......@@ -9,4 +9,5 @@
-->
<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
<toolbar:toolbaritem xlink:href=".uno:ClassificationApply"/>
<toolbar:toolbaritem xlink:href=".uno:Watermark"/>
</toolbar:toolbar>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="WatermarkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Watermark</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="Box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="EnableWatermarkCB">
<property name="label" translatable="yes">Insert watermark</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="TextGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="TextLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Text</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="TextInput">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">ok</action-widget>
<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>
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