1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_ENVLOP_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_ENVLOP_HXX
22 #include <sfx2/tabdlg.hxx>
23 #include <vcl/weld.hxx>
24 #include <vcl/customweld.hxx>
27 #define GetFieldVal(rField) (rField).Denormalize((rField).GetValue(FieldUnit::TWIP))
28 #define SetFieldVal(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FieldUnit::TWIP)
30 inline int getfieldval(const weld::MetricSpinButton
& rField
)
32 return rField
.denormalize(rField
.get_value(FieldUnit::TWIP
));
35 inline void setfieldval(weld::MetricSpinButton
& rField
, int lValue
)
37 rField
.set_value(rField
.normalize(lValue
), FieldUnit::TWIP
);
42 class SwEnvFormatPage
;
46 class SwEnvPreview
: public weld::CustomWidgetController
51 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
52 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
56 void SetDialog(SwEnvDlg
* pDialog
) { m_pDialog
= pDialog
; }
59 class SwEnvDlg
: public SfxTabDialogController
61 friend class SwEnvPage
;
62 friend class SwEnvFormatPage
;
63 friend class SwEnvPrtPage
;
64 friend class SwEnvPreview
;
68 VclPtr
<Printer
> pPrinter
;
69 std::unique_ptr
<SfxItemSet
> pAddresseeSet
;
70 std::unique_ptr
<SfxItemSet
> pSenderSet
;
72 std::unique_ptr
<weld::Button
> m_xModify
;
74 virtual void PageCreated(const OString
& rId
, SfxTabPage
& rPage
) override
;
75 virtual short Ok() override
;
78 SwEnvDlg(weld::Window
* pParent
, const SfxItemSet
& rSet
, SwWrtShell
* pWrtSh
, Printer
* pPrt
,
80 virtual ~SwEnvDlg() override
;
83 class SwEnvPage
: public SfxTabPage
87 OUString m_sActDBName
;
89 SwEnvPreview m_aPreview
;
90 std::unique_ptr
<weld::TextView
> m_xAddrEdit
;
91 std::unique_ptr
<weld::ComboBox
> m_xDatabaseLB
;
92 std::unique_ptr
<weld::ComboBox
> m_xTableLB
;
93 std::unique_ptr
<weld::ComboBox
> m_xDBFieldLB
;
94 std::unique_ptr
<weld::Button
> m_xInsertBT
;
95 std::unique_ptr
<weld::CheckButton
> m_xSenderBox
;
96 std::unique_ptr
<weld::TextView
> m_xSenderEdit
;
97 std::unique_ptr
<weld::CustomWeld
> m_xPreview
;
99 DECL_LINK(DatabaseHdl
, weld::ComboBox
&, void);
100 DECL_LINK(FieldHdl
, weld::Button
&, void);
101 DECL_LINK(SenderHdl
, weld::Button
&, void);
103 void InitDatabaseBox();
105 SwEnvDlg
* GetParentSwEnvDlg() { return m_pDialog
; }
108 SwEnvPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
);
109 void Init(SwEnvDlg
* pDialog
);
110 virtual ~SwEnvPage() override
;
112 static std::unique_ptr
<SfxTabPage
>
113 Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rSet
);
115 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
116 virtual DeactivateRC
DeactivatePage(SfxItemSet
* pSet
) override
;
117 void FillItem(SwEnvItem
& rItem
);
118 virtual bool FillItemSet(SfxItemSet
* rSet
) override
;
119 virtual void Reset(const SfxItemSet
* rSet
) override
;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */