diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-14 15:09:02 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-18 00:44:34 +0200 |
commit | 08de2c31cb0da07ffc23f813379f810607e1cc7e (patch) | |
tree | 0e7152435d71df47c6a1adb17025d627862d801d /sw/source/uibase/dialog | |
parent | 3884bb38f0712b6b1616b5d788cd00e90b14fcd3 (diff) |
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/37599
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/source/uibase/dialog')
-rw-r--r-- | sw/source/uibase/dialog/watermarkdialog.cxx | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx new file mode 100644 index 000000000000..bcc6077e9d03 --- /dev/null +++ b/sw/source/uibase/dialog/watermarkdialog.cxx @@ -0,0 +1,91 @@ +/* -*- 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: */ |