summaryrefslogtreecommitdiffstats
path: root/sw/source/ui/envelp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sw/source/ui/envelp/envfmt.cxx482
-rw-r--r--sw/source/ui/envelp/envfmt.hxx73
-rw-r--r--sw/source/ui/envelp/envlop1.cxx340
-rw-r--r--sw/source/ui/envelp/envprt.cxx190
-rw-r--r--sw/source/ui/envelp/envprt.hxx72
-rw-r--r--sw/source/ui/envelp/label1.cxx725
-rw-r--r--sw/source/ui/envelp/labelexp.cxx104
-rw-r--r--sw/source/ui/envelp/labfmt.cxx609
-rw-r--r--sw/source/ui/envelp/labfmt.hxx142
-rw-r--r--sw/source/ui/envelp/labprt.cxx156
-rw-r--r--sw/source/ui/envelp/labprt.hxx63
-rw-r--r--sw/source/ui/envelp/mailmrge.cxx616
-rw-r--r--sw/source/ui/envelp/swuilabimp.hxx143
13 files changed, 3715 insertions, 0 deletions
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
new file mode 100644
index 000000000..9420a3b5f
--- /dev/null
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -0,0 +1,482 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <hintids.hxx>
+
+#include <editeng/paperinf.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/brushitem.hxx>
+#include <svtools/unitconv.hxx>
+
+#include <cmdid.h>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include "envfmt.hxx"
+#include <fmtcol.hxx>
+#include <swuipardlg.hxx>
+#include <chrdlgmodes.hxx>
+#include <pardlg.hxx>
+#include <poolfmt.hxx>
+#include <uitool.hxx>
+
+#include <vector>
+#include <algorithm>
+
+#include <memory>
+
+#include <swabstdlg.hxx>
+#include <swuiexp.hxx>
+
+namespace {
+ /// Converts a ranges array to a list containing one entry for each
+ /// element covered by the ranges.
+ /// @param aRanges An array containing zero or more range specifications and
+ /// terminated by one or more zero entries. A range
+ /// specification is two consecutive entries that specify
+ /// the start and end points of the range.
+ /// @returns A vector containing one element for each item covered by the
+ /// ranges. This is not guaranteed to be sorted and may contain
+ /// duplicates if the original ranges contained overlaps.
+ std::vector<sal_uInt16> lcl_convertRangesToList(const sal_uInt16 aRanges[]) {
+ std::vector<sal_uInt16> aVec;
+ int i = 0;
+ while (aRanges[i])
+ {
+ for (sal_uInt16 n = aRanges[i]; n <= aRanges[i+1]; ++n)
+ {
+ aVec.push_back(n);
+ }
+ i += 2;
+ }
+ return aVec;
+ }
+
+ /// Converts a list of elements to a ranges array.
+ /// @param rElements Vector of the initial elements, this need not be sorted,
+ /// and may contain duplicate items. The vector is sorted
+ /// on exit from this function but may still contain duplicates.
+ /// @returns An array containing zero or more range specifications and
+ /// terminated by one or more zero entries. A range specification
+ /// is two consecutive entries that specify the start and end
+ /// points of the range. This list will be sorted and will not
+ /// contain any overlapping ranges.
+ sal_uInt16* lcl_convertListToRanges(std::vector<sal_uInt16> &rElements) {
+ std::sort(rElements.begin(), rElements.end());
+ std::vector<sal_uInt16> aRanges;
+ size_t i;
+ for (i = 0; i < rElements.size(); ++i)
+ {
+ //Push the start of the this range.
+ aRanges.push_back(rElements[i]);
+ //Seek to the end of this range.
+ while (i + 1 < rElements.size() && rElements[i+1] - rElements[i] <= 1)
+ {
+ ++i;
+ }
+ //Push the end of this range (may be the same as the start).
+ aRanges.push_back( rElements[i] );
+ }
+
+ // Convert the vector to an array with terminating zero
+ sal_uInt16 *pNewRanges = new sal_uInt16[aRanges.size() + 1];
+ for (i = 0; i < aRanges.size(); ++i)
+ {
+ pNewRanges[i] = aRanges[i];
+ }
+ pNewRanges[i] = 0;
+ return pNewRanges;
+ }
+
+}
+
+static long lUserW = 5669; // 10 cm
+static long lUserH = 5669; // 10 cm
+
+SwEnvFormatPage::SwEnvFormatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/envformatpage.ui", "EnvFormatPage", &rSet)
+ , m_pDialog(nullptr)
+ , m_xAddrLeftField(m_xBuilder->weld_metric_spin_button("leftaddr", FieldUnit::CM))
+ , m_xAddrTopField(m_xBuilder->weld_metric_spin_button("topaddr", FieldUnit::CM))
+ , m_xAddrEditButton(m_xBuilder->weld_menu_button("addredit"))
+ , m_xSendLeftField(m_xBuilder->weld_metric_spin_button("leftsender", FieldUnit::CM))
+ , m_xSendTopField(m_xBuilder->weld_metric_spin_button("topsender", FieldUnit::CM))
+ , m_xSendEditButton(m_xBuilder->weld_menu_button("senderedit"))
+ , m_xSizeFormatBox(m_xBuilder->weld_combo_box("format"))
+ , m_xSizeWidthField(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM))
+ , m_xSizeHeightField(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
+{
+ SetExchangeSupport();
+
+ // Metrics
+ FieldUnit aMetric = ::GetDfltMetric(false);
+ ::SetFieldUnit(*m_xAddrLeftField, aMetric);
+ ::SetFieldUnit(*m_xAddrTopField, aMetric);
+ ::SetFieldUnit(*m_xSendLeftField, aMetric);
+ ::SetFieldUnit(*m_xSendTopField, aMetric);
+ ::SetFieldUnit(*m_xSizeWidthField, aMetric);
+ ::SetFieldUnit(*m_xSizeHeightField, aMetric);
+
+ // Install handlers
+ Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwEnvFormatPage, ModifyHdl);
+ m_xAddrLeftField->connect_value_changed( aLk );
+ m_xAddrTopField->connect_value_changed( aLk );
+ m_xSendLeftField->connect_value_changed( aLk );
+ m_xSendTopField->connect_value_changed( aLk );
+ m_xSizeWidthField->connect_value_changed( aLk );
+ m_xSizeHeightField->connect_value_changed( aLk );
+
+ m_xAddrEditButton->connect_selected(LINK(this, SwEnvFormatPage, AddrEditHdl));
+ m_xSendEditButton->connect_selected(LINK(this, SwEnvFormatPage, SendEditHdl));
+
+ m_xSizeFormatBox->connect_changed(LINK(this, SwEnvFormatPage, FormatHdl));
+
+ // m_xSizeFormatBox
+ for (sal_uInt16 i = PAPER_A3; i <= PAPER_KAI32BIG; i++)
+ {
+ if (i != PAPER_USER)
+ {
+ const OUString aPaperName = SvxPaperInfo::GetName(static_cast<Paper>(i));
+
+ if (aPaperName.isEmpty())
+ continue;
+
+ sal_Int32 nPos = 0;
+ while (nPos < m_xSizeFormatBox->get_count() &&
+ m_xSizeFormatBox->get_text(nPos) < aPaperName)
+ {
+ ++nPos;
+ }
+ m_xSizeFormatBox->insert_text(nPos, aPaperName);
+ m_aIDs.insert( m_aIDs.begin() + nPos, i);
+ }
+ }
+ m_xSizeFormatBox->append_text(SvxPaperInfo::GetName(PAPER_USER));
+ m_aIDs.push_back( sal_uInt16(PAPER_USER) );
+}
+
+void SwEnvFormatPage::Init(SwEnvDlg* pDialog)
+{
+ m_pDialog = pDialog;
+ m_aPreview.SetDialog(m_pDialog);
+}
+
+SwEnvFormatPage::~SwEnvFormatPage()
+{
+}
+
+IMPL_LINK( SwEnvFormatPage, ModifyHdl, weld::MetricSpinButton&, rEdit, void )
+{
+ int lWVal = getfieldval(*m_xSizeWidthField);
+ int lHVal = getfieldval(*m_xSizeHeightField);
+
+ int lWidth = std::max(lWVal, lHVal);
+ int lHeight = std::min(lWVal, lHVal);
+
+ if (&rEdit == m_xSizeWidthField.get() || &rEdit == m_xSizeHeightField.get())
+ {
+ int nRotatedWidth = lHeight;
+ int nRotatedHeight = lWidth;
+ Paper ePaper = SvxPaperInfo::GetSvxPaper(
+ Size(nRotatedWidth, nRotatedHeight), MapUnit::MapTwip);
+ for (size_t i = 0; i < m_aIDs.size(); ++i)
+ if (m_aIDs[i] == static_cast<sal_uInt16>(ePaper))
+ m_xSizeFormatBox->set_active(i);
+
+ // remember user size
+ if (m_aIDs[m_xSizeFormatBox->get_active()] == sal_uInt16(PAPER_USER))
+ {
+ lUserW = lWidth ;
+ lUserH = lHeight;
+ }
+
+ FormatHdl(*m_xSizeFormatBox);
+ }
+ else
+ {
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ SetMinMax();
+ m_xPreview->queue_draw();
+ }
+}
+
+IMPL_LINK(SwEnvFormatPage, AddrEditHdl, const OString&, rIdent, void)
+{
+ Edit(rIdent, false);
+}
+
+IMPL_LINK(SwEnvFormatPage, SendEditHdl, const OString&, rIdent, void)
+{
+ Edit(rIdent, true);
+}
+
+void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender)
+{
+ SwWrtShell* pSh = GetParentSwEnvDlg()->pSh;
+ OSL_ENSURE(pSh, "Shell missing");
+
+ SwTextFormatColl* pColl = pSh->GetTextCollFromPool( static_cast< sal_uInt16 >(
+ bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS));
+ OSL_ENSURE(pColl, "Text collection missing");
+
+ if (rIdent.startsWith("character"))
+ {
+ SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
+
+ // In order for the background color not to get ironed over:
+ SfxAllItemSet aTmpSet(*pCollSet);
+ ::ConvertAttrCharToGen(aTmpSet);
+
+ SwAbstractDialogFactory& rFact = swui::GetFactory();
+
+ const OUString sFormatStr = pColl->GetName();
+ ScopedVclPtr<SfxAbstractTabDialog> pDlg(rFact.CreateSwCharDlg(GetFrameWeld(), pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr));
+ if (pDlg->Execute() == RET_OK)
+ {
+ SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() );
+ ::ConvertAttrGenToChar(aOutputSet, aTmpSet);
+ pCollSet->Put(aOutputSet);
+ }
+ }
+ else if (rIdent.startsWith("paragraph"))
+ {
+ SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);
+
+ // In order for the tabulators not to get ironed over:
+ SfxAllItemSet aTmpSet(*pCollSet);
+
+ // Insert tabs, default tabs into ItemSet
+ const SvxTabStopItem& rDefTabs =
+ pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
+
+ const sal_uInt16 nDefDist = static_cast<sal_uInt16>(::GetTabDist( rDefTabs ));
+ SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
+ aTmpSet.Put( aDefDistItem );
+
+ // Current tab
+ SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
+ aTmpSet.Put( aTabPos );
+
+ // left border as offset
+ const long nOff = aTmpSet.Get( RES_LR_SPACE ).GetTextLeft();
+ SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
+ aTmpSet.Put( aOff );
+
+ // set BoxInfo
+ ::PrepareBoxInfo( aTmpSet, *pSh );
+
+ const OUString sFormatStr = pColl->GetName();
+ SwParaDlg aDlg(GetFrameWeld(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr);
+
+ if (aDlg.run() == RET_OK)
+ {
+ // maybe relocate defaults
+ const SfxPoolItem* pItem = nullptr;
+ SfxItemSet* pOutputSet = const_cast<SfxItemSet*>(aDlg.GetOutputItemSet());
+ sal_uInt16 nNewDist;
+
+ if( SfxItemState::SET == pOutputSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS,
+ false, &pItem ) &&
+ nDefDist != (nNewDist = static_cast<const SfxUInt16Item*>(pItem)->GetValue()) )
+ {
+ SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
+ MakeDefTabs( nNewDist, aDefTabs );
+ pSh->SetDefault( aDefTabs );
+ pOutputSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
+ }
+ if( pOutputSet->Count() )
+ {
+ pCollSet->Put(*pOutputSet);
+ }
+ }
+ }
+}
+
+// A temporary Itemset that gets discarded at abort
+SfxItemSet *SwEnvFormatPage::GetCollItemSet(SwTextFormatColl const * pColl, bool bSender)
+{
+ std::unique_ptr<SfxItemSet>& pAddrSet = bSender ? GetParentSwEnvDlg()->pSenderSet : GetParentSwEnvDlg()->pAddresseeSet;
+ if (!pAddrSet)
+ {
+ // determine range (merge both Itemsets' ranges)
+ const sal_uInt16 *pRanges = pColl->GetAttrSet().GetRanges();
+
+ static sal_uInt16 const aRanges[] =
+ {
+ RES_PARATR_BEGIN, RES_PARATR_ADJUST,
+ RES_PARATR_TABSTOP, RES_PARATR_END-1,
+ RES_LR_SPACE, RES_UL_SPACE,
+ RES_BACKGROUND, RES_SHADOW,
+ SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
+ SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
+ SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ 0, 0
+ };
+
+ // BruteForce merge because MergeRange in SvTools is buggy:
+ std::vector<sal_uInt16> aVec2 = ::lcl_convertRangesToList(pRanges);
+ std::vector<sal_uInt16> aVec = ::lcl_convertRangesToList(aRanges);
+ aVec2.insert(aVec2.end(), aVec.begin(), aVec.end());
+ std::unique_ptr<sal_uInt16[]> pNewRanges(::lcl_convertListToRanges(aVec2));
+
+ pAddrSet.reset(new SfxItemSet(GetParentSwEnvDlg()->pSh->GetView().GetCurShell()->GetPool(),
+ pNewRanges.get()));
+ pAddrSet->Put(pColl->GetAttrSet());
+ }
+
+ return pAddrSet.get();
+}
+
+IMPL_LINK_NOARG(SwEnvFormatPage, FormatHdl, weld::ComboBox&, void)
+{
+ long lWidth;
+ long lHeight;
+ long lSendFromLeft;
+ long lSendFromTop;
+ long lAddrFromLeft;
+ long lAddrFromTop;
+
+ const sal_uInt16 nPaper = m_aIDs[m_xSizeFormatBox->get_active()];
+ if (nPaper != sal_uInt16(PAPER_USER))
+ {
+ Size aSz = SvxPaperInfo::GetPaperSize(static_cast<Paper>(nPaper));
+ lWidth = std::max(aSz.Width(), aSz.Height());
+ lHeight = std::min(aSz.Width(), aSz.Height());
+ }
+ else
+ {
+ lWidth = lUserW;
+ lHeight = lUserH;
+ }
+
+ lSendFromLeft = 566; // 1cm
+ lSendFromTop = 566; // 1cm
+ lAddrFromLeft = lWidth / 2;
+ lAddrFromTop = lHeight / 2;
+
+ setfieldval(*m_xAddrLeftField, lAddrFromLeft);
+ setfieldval(*m_xAddrTopField , lAddrFromTop );
+ setfieldval(*m_xSendLeftField, lSendFromLeft);
+ setfieldval(*m_xSendTopField , lSendFromTop );
+
+ setfieldval(*m_xSizeWidthField , lWidth );
+ setfieldval(*m_xSizeHeightField, lHeight);
+
+ SetMinMax();
+
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ m_xPreview->queue_draw();
+}
+
+void SwEnvFormatPage::SetMinMax()
+{
+ long lWVal = static_cast< long >(getfieldval(*m_xSizeWidthField ));
+ long lHVal = static_cast< long >(getfieldval(*m_xSizeHeightField));
+
+ long lWidth = std::max(lWVal, lHVal),
+ lHeight = std::min(lWVal, lHVal);
+
+ // Min and Max
+ m_xAddrLeftField->set_range(100 * (getfieldval(*m_xSendLeftField) + 566),
+ 100 * (lWidth - 2 * 566), FieldUnit::TWIP);
+ m_xAddrTopField->set_range(100 * (getfieldval(*m_xSendTopField ) + 2 * 566),
+ 100 * (lHeight - 2 * 566), FieldUnit::TWIP);
+ m_xSendLeftField->set_range(100 * 566,
+ 100 * (getfieldval(*m_xAddrLeftField) - 566), FieldUnit::TWIP);
+ m_xSendTopField->set_range(100 * 566,
+ 100 * (getfieldval(*m_xAddrTopField ) - 2 * 566), FieldUnit::TWIP);
+}
+
+std::unique_ptr<SfxTabPage> SwEnvFormatPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwEnvFormatPage>(pPage, pController, *rSet);
+}
+
+void SwEnvFormatPage::ActivatePage(const SfxItemSet& rSet)
+{
+ SfxItemSet aSet(rSet);
+ aSet.Put(GetParentSwEnvDlg()->aEnvItem);
+ Reset(&aSet);
+}
+
+DeactivateRC SwEnvFormatPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if( _pSet )
+ FillItemSet(_pSet);
+ return DeactivateRC::LeavePage;
+}
+
+void SwEnvFormatPage::FillItem(SwEnvItem& rItem)
+{
+ rItem.m_nAddrFromLeft = static_cast< sal_Int32 >(getfieldval(*m_xAddrLeftField));
+ rItem.m_nAddrFromTop = static_cast< sal_Int32 >(getfieldval(*m_xAddrTopField ));
+ rItem.m_nSendFromLeft = static_cast< sal_Int32 >(getfieldval(*m_xSendLeftField));
+ rItem.m_nSendFromTop = static_cast< sal_Int32 >(getfieldval(*m_xSendTopField ));
+
+ const sal_uInt16 nPaper = m_aIDs[m_xSizeFormatBox->get_active()];
+ if (nPaper == sal_uInt16(PAPER_USER))
+ {
+ long lWVal = static_cast< long >(getfieldval(*m_xSizeWidthField ));
+ long lHVal = static_cast< long >(getfieldval(*m_xSizeHeightField));
+ rItem.m_nWidth = std::max(lWVal, lHVal);
+ rItem.m_nHeight = std::min(lWVal, lHVal);
+ }
+ else
+ {
+ long lWVal = SvxPaperInfo::GetPaperSize(static_cast<Paper>(nPaper)).Width ();
+ long lHVal = SvxPaperInfo::GetPaperSize(static_cast<Paper>(nPaper)).Height();
+ rItem.m_nWidth = std::max(lWVal, lHVal);
+ rItem.m_nHeight = std::min(lWVal, lHVal);
+ }
+}
+
+bool SwEnvFormatPage::FillItemSet(SfxItemSet* rSet)
+{
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ rSet->Put(GetParentSwEnvDlg()->aEnvItem);
+ return true;
+}
+
+void SwEnvFormatPage::Reset(const SfxItemSet* rSet)
+{
+ const SwEnvItem& rItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP));
+
+ Paper ePaper = SvxPaperInfo::GetSvxPaper(
+ Size( std::min(rItem.m_nWidth, rItem.m_nHeight),
+ std::max(rItem.m_nWidth, rItem.m_nHeight)), MapUnit::MapTwip);
+ for (size_t i = 0; i < m_aIDs.size(); ++i)
+ if (m_aIDs[i] == static_cast<sal_uInt16>(ePaper))
+ m_xSizeFormatBox->set_active(i);
+
+ // Metric fields
+ setfieldval(*m_xAddrLeftField, rItem.m_nAddrFromLeft);
+ setfieldval(*m_xAddrTopField, rItem.m_nAddrFromTop );
+ setfieldval(*m_xSendLeftField, rItem.m_nSendFromLeft);
+ setfieldval(*m_xSendTopField, rItem.m_nSendFromTop );
+ setfieldval(*m_xSizeWidthField , std::max(rItem.m_nWidth, rItem.m_nHeight));
+ setfieldval(*m_xSizeHeightField , std::min(rItem.m_nWidth, rItem.m_nHeight));
+ SetMinMax();
+
+ GetParentSwEnvDlg()->pSenderSet.reset();
+ GetParentSwEnvDlg()->pAddresseeSet.reset();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx
new file mode 100644
index 000000000..28da3d63d
--- /dev/null
+++ b/sw/source/ui/envelp/envfmt.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_ENVFMT_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_ENVFMT_HXX
+
+#include <vcl/weld.hxx>
+#include <envlop.hxx>
+
+class SwTextFormatColl;
+
+class SwEnvFormatPage : public SfxTabPage
+{
+ SwEnvDlg* m_pDialog;
+ std::vector<sal_uInt16> m_aIDs;
+
+ SwEnvPreview m_aPreview;
+ std::unique_ptr<weld::MetricSpinButton> m_xAddrLeftField;
+ std::unique_ptr<weld::MetricSpinButton> m_xAddrTopField;
+ std::unique_ptr<weld::MenuButton> m_xAddrEditButton;
+ std::unique_ptr<weld::MetricSpinButton> m_xSendLeftField;
+ std::unique_ptr<weld::MetricSpinButton> m_xSendTopField;
+ std::unique_ptr<weld::MenuButton> m_xSendEditButton;
+ std::unique_ptr<weld::ComboBox> m_xSizeFormatBox;
+ std::unique_ptr<weld::MetricSpinButton> m_xSizeWidthField;
+ std::unique_ptr<weld::MetricSpinButton> m_xSizeHeightField;
+ std::unique_ptr<weld::CustomWeld> m_xPreview;
+
+ DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void);
+ DECL_LINK(AddrEditHdl, const OString&, void);
+ DECL_LINK(SendEditHdl, const OString&, void);
+ DECL_LINK(FormatHdl, weld::ComboBox&, void);
+
+ void SetMinMax();
+
+ SfxItemSet *GetCollItemSet(SwTextFormatColl const * pColl, bool bSender);
+
+ void Edit(const OString& rIdent, bool bSender);
+
+ SwEnvDlg *GetParentSwEnvDlg() { return m_pDialog; }
+
+public:
+ SwEnvFormatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ void Init(SwEnvDlg* pDialog);
+ virtual ~SwEnvFormatPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ void FillItem(SwEnvItem& rItem);
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
new file mode 100644
index 000000000..928f67558
--- /dev/null
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <dbmgr.hxx>
+#include <tools/lineend.hxx>
+#include <vcl/print.hxx>
+#include <vcl/settings.hxx>
+
+#include <swwait.hxx>
+#include <viewopt.hxx>
+
+#include <wrtsh.hxx>
+#include <cmdid.h>
+#include "envfmt.hxx"
+#include <envlop.hxx>
+#include "envprt.hxx"
+#include <fmtcol.hxx>
+#include <poolfmt.hxx>
+#include <view.hxx>
+
+#include <comphelper/string.hxx>
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+SwEnvPreview::SwEnvPreview()
+ : m_pDialog(nullptr)
+{
+}
+
+void SwEnvPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
+ pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 20,
+ pDrawingArea->get_text_height() * 8);
+}
+
+void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
+{
+ const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
+ rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor());
+ rRenderContext.Erase();
+
+ const SwEnvItem& rItem = m_pDialog->aEnvItem;
+
+ const long nPageW = std::max(rItem.m_nWidth, rItem.m_nHeight);
+ const long nPageH = std::min(rItem.m_nWidth, rItem.m_nHeight);
+
+ Size aSize(GetOutputSizePixel());
+
+ const double f = 0.8 * std::min(
+ double(aSize.Width()) / double(nPageW),
+ double(aSize.Height()) / double(nPageH));
+
+ Color aBack = rSettings.GetWindowColor();
+ Color aFront = SwViewOption::GetFontColor();
+ Color aMedium((aBack.GetRed() + aFront.GetRed()) / 2,
+ (aBack.GetGreen() + aFront.GetGreen()) / 2,
+ (aBack.GetBlue() + aFront.GetBlue()) / 2);
+
+ rRenderContext.SetLineColor(aFront);
+
+ // Envelope
+ const long nW = static_cast<long>(f * nPageW);
+ const long nH = static_cast<long>(f * nPageH);
+ const long nX = (aSize.Width () - nW) / 2;
+ const long nY = (aSize.Height() - nH) / 2;
+ rRenderContext.SetFillColor(aBack);
+ rRenderContext.DrawRect(tools::Rectangle(Point(nX, nY), Size(nW, nH)));
+
+ // Sender
+ if (rItem.m_bSend)
+ {
+ const long nSendX = nX + static_cast<long>(f * rItem.m_nSendFromLeft);
+ const long nSendY = nY + static_cast<long>(f * rItem.m_nSendFromTop );
+ const long nSendW = static_cast<long>(f * (rItem.m_nAddrFromLeft - rItem.m_nSendFromLeft));
+ const long nSendH = static_cast<long>(f * (rItem.m_nAddrFromTop - rItem.m_nSendFromTop - 566));
+ rRenderContext.SetFillColor(aMedium);
+
+ rRenderContext.DrawRect(tools::Rectangle(Point(nSendX, nSendY), Size(nSendW, nSendH)));
+ }
+
+ // Addressee
+ const long nAddrX = nX + static_cast<long>(f * rItem.m_nAddrFromLeft);
+ const long nAddrY = nY + static_cast<long>(f * rItem.m_nAddrFromTop );
+ const long nAddrW = static_cast<long>(f * (nPageW - rItem.m_nAddrFromLeft - 566));
+ const long nAddrH = static_cast<long>(f * (nPageH - rItem.m_nAddrFromTop - 566));
+ rRenderContext.SetFillColor(aMedium);
+ rRenderContext.DrawRect(tools::Rectangle(Point(nAddrX, nAddrY), Size(nAddrW, nAddrH)));
+
+ // Stamp
+ const long nStmpW = static_cast<long>(f * 1417 /* 2,5 cm */);
+ const long nStmpH = static_cast<long>(f * 1701 /* 3,0 cm */);
+ const long nStmpX = nX + nW - static_cast<long>(f * 566) - nStmpW;
+ const long nStmpY = nY + static_cast<long>(f * 566);
+
+ rRenderContext.SetFillColor(aBack);
+ rRenderContext.DrawRect(tools::Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH)));
+}
+
+SwEnvDlg::SwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet,
+ SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert)
+ : SfxTabDialogController(pParent, "modules/swriter/ui/envdialog.ui", "EnvDialog", &rSet)
+ , aEnvItem(static_cast<const SwEnvItem&>( rSet.Get(FN_ENVELOP)))
+ , pSh(pWrtSh)
+ , pPrinter(pPrt)
+ , m_xModify(m_xBuilder->weld_button("modify"))
+{
+ if (!bInsert)
+ {
+ GetUserButton()->set_label(m_xModify->get_label());
+ }
+
+ AddTabPage("envelope", SwEnvPage::Create, nullptr);
+ AddTabPage("format", SwEnvFormatPage::Create, nullptr);
+ AddTabPage("printer", SwEnvPrtPage::Create, nullptr);
+}
+
+SwEnvDlg::~SwEnvDlg()
+{
+ pAddresseeSet.reset();
+ pSenderSet.reset();
+}
+
+void SwEnvDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
+{
+ if (rId == "printer")
+ {
+ static_cast<SwEnvPrtPage*>(&rPage)->SetPrt(pPrinter);
+ }
+ else if (rId == "envelope")
+ {
+ static_cast<SwEnvPage*>(&rPage)->Init(this);
+ }
+ else if (rId == "format")
+ {
+ static_cast<SwEnvFormatPage*>(&rPage)->Init(this);
+ }
+}
+
+short SwEnvDlg::Ok()
+{
+ short nRet = SfxTabDialogController::Ok();
+
+ if (nRet == RET_OK || nRet == RET_USER)
+ {
+ if (pAddresseeSet)
+ {
+ SwTextFormatColl* pColl = pSh->GetTextCollFromPool(RES_POOLCOLL_JAKETADRESS);
+ pColl->SetFormatAttr(*pAddresseeSet);
+ }
+ if (pSenderSet)
+ {
+ SwTextFormatColl* pColl = pSh->GetTextCollFromPool(RES_POOLCOLL_SENDADRESS);
+ pColl->SetFormatAttr(*pSenderSet);
+ }
+ }
+
+ return nRet;
+}
+
+SwEnvPage::SwEnvPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/envaddresspage.ui", "EnvAddressPage", &rSet)
+ , m_pDialog(nullptr)
+ , m_pSh(nullptr)
+ , m_xAddrEdit(m_xBuilder->weld_text_view("addredit"))
+ , m_xDatabaseLB(m_xBuilder->weld_combo_box("database"))
+ , m_xTableLB(m_xBuilder->weld_combo_box("table"))
+ , m_xDBFieldLB(m_xBuilder->weld_combo_box("field"))
+ , m_xInsertBT(m_xBuilder->weld_button("insert"))
+ , m_xSenderBox(m_xBuilder->weld_check_button("sender"))
+ , m_xSenderEdit(m_xBuilder->weld_text_view("senderedit"))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
+{
+ auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10));
+ auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 25);
+
+ m_xAddrEdit->set_size_request(nTextBoxWidth, nTextBoxHeight);
+ m_xSenderEdit->set_size_request(nTextBoxWidth, nTextBoxHeight);
+
+ auto nListBoxWidth = m_xTableLB->get_approximate_digit_width() * 25;
+ m_xTableLB->set_size_request(nListBoxWidth, -1);
+ m_xDatabaseLB->set_size_request(nListBoxWidth, -1);
+ m_xDBFieldLB->set_size_request(nListBoxWidth, -1);
+
+ SetExchangeSupport();
+}
+
+void SwEnvPage::Init(SwEnvDlg* pDialog)
+{
+ m_pDialog = pDialog;
+ m_pSh = m_pDialog->pSh;
+ m_aPreview.SetDialog(pDialog);
+
+ // Install handlers
+ m_xDatabaseLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl));
+ m_xTableLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl));
+ m_xInsertBT->connect_clicked(LINK(this, SwEnvPage, FieldHdl));
+ m_xSenderBox->connect_clicked(LINK(this, SwEnvPage, SenderHdl));
+
+ SwDBData aData = m_pSh->GetDBData();
+ m_sActDBName = aData.sDataSource + OUStringChar(DB_DELIM) + aData.sCommand;
+ InitDatabaseBox();
+}
+
+SwEnvPage::~SwEnvPage()
+{
+}
+
+IMPL_LINK( SwEnvPage, DatabaseHdl, weld::ComboBox&, rListBox, void )
+{
+ SwWait aWait( *m_pSh->GetView().GetDocShell(), true );
+
+ if (&rListBox == m_xDatabaseLB.get())
+ {
+ m_sActDBName = rListBox.get_active_text();
+ m_pSh->GetDBManager()->GetTableNames(*m_xTableLB, m_sActDBName);
+ m_sActDBName += OUStringChar(DB_DELIM);
+ }
+ else
+ {
+ m_sActDBName = comphelper::string::setToken(m_sActDBName, 1, DB_DELIM, m_xTableLB->get_active_text());
+ }
+ m_pSh->GetDBManager()->GetColumnNames(*m_xDBFieldLB, m_xDatabaseLB->get_active_text(),
+ m_xTableLB->get_active_text());
+}
+
+IMPL_LINK_NOARG(SwEnvPage, FieldHdl, weld::Button&, void)
+{
+ OUString aStr("<" + m_xDatabaseLB->get_active_text() + "." +
+ m_xTableLB->get_active_text() + "." +
+ m_xTableLB->get_active_id() + "." +
+ m_xDBFieldLB->get_active_text() + ">");
+ m_xAddrEdit->replace_selection(aStr);
+ int nStartPos, nEndPos;
+ m_xAddrEdit->get_selection_bounds(nStartPos, nEndPos);
+ m_xAddrEdit->grab_focus();
+ m_xAddrEdit->select_region(nStartPos, nEndPos);
+}
+
+IMPL_LINK_NOARG(SwEnvPage, SenderHdl, weld::Button&, void)
+{
+ const bool bEnable = m_xSenderBox->get_active();
+ GetParentSwEnvDlg()->aEnvItem.m_bSend = bEnable;
+ m_xSenderEdit->set_sensitive(bEnable);
+ if (bEnable)
+ {
+ m_xSenderEdit->grab_focus();
+ if (m_xSenderEdit->get_text().isEmpty())
+ m_xSenderEdit->set_text(MakeSender());
+ }
+ m_xPreview->queue_draw();
+}
+
+void SwEnvPage::InitDatabaseBox()
+{
+ if (m_pSh->GetDBManager())
+ {
+ m_xDatabaseLB->clear();
+ const Sequence<OUString> aDataNames = SwDBManager::GetExistingDatabaseNames();
+
+ for (const OUString& rDataName : aDataNames)
+ m_xDatabaseLB->append_text(rDataName);
+
+ sal_Int32 nIdx{ 0 };
+ OUString sDBName = m_sActDBName.getToken( 0, DB_DELIM, nIdx );
+ OUString sTableName = m_sActDBName.getToken( 0, DB_DELIM, nIdx );
+ m_xDatabaseLB->set_active_text(sDBName);
+ if (m_pSh->GetDBManager()->GetTableNames(*m_xTableLB, sDBName))
+ {
+ m_xTableLB->append_text(sTableName);
+ m_pSh->GetDBManager()->GetColumnNames(*m_xDBFieldLB, sDBName, sTableName);
+ }
+ else
+ m_xDBFieldLB->clear();
+ }
+}
+
+std::unique_ptr<SfxTabPage> SwEnvPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwEnvPage>(pPage, pController, *rSet);
+}
+
+void SwEnvPage::ActivatePage(const SfxItemSet& rSet)
+{
+ SfxItemSet aSet(rSet);
+ aSet.Put(GetParentSwEnvDlg()->aEnvItem);
+ Reset(&aSet);
+}
+
+DeactivateRC SwEnvPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ if( _pSet )
+ FillItemSet(_pSet);
+ return DeactivateRC::LeavePage;
+}
+
+void SwEnvPage::FillItem(SwEnvItem& rItem)
+{
+ rItem.m_aAddrText = m_xAddrEdit->get_text();
+ rItem.m_bSend = m_xSenderBox->get_active();
+ rItem.m_aSendText = m_xSenderEdit->get_text();
+}
+
+bool SwEnvPage::FillItemSet(SfxItemSet* rSet)
+{
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ rSet->Put(GetParentSwEnvDlg()->aEnvItem);
+ return true;
+}
+
+void SwEnvPage::Reset(const SfxItemSet* rSet)
+{
+ SwEnvItem aItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP));
+ m_xAddrEdit->set_text(convertLineEnd(aItem.m_aAddrText, GetSystemLineEnd()));
+ m_xSenderEdit->set_text(convertLineEnd(aItem.m_aSendText, GetSystemLineEnd()));
+ m_xSenderBox->set_active(aItem.m_bSend);
+ SenderHdl(*m_xSenderBox);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/envprt.cxx b/sw/source/ui/envelp/envprt.cxx
new file mode 100644
index 000000000..43dd2f1a9
--- /dev/null
+++ b/sw/source/ui/envelp/envprt.cxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/print.hxx>
+#include <svtools/prnsetup.hxx>
+#include <svtools/unitconv.hxx>
+
+#include <cmdid.h>
+#include "envprt.hxx"
+#include <envlop.hxx>
+#include <uitool.hxx>
+
+SwEnvPrtPage::SwEnvPrtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/envprinterpage.ui", "EnvPrinterPage", &rSet)
+ , m_xUpper(m_xBuilder->weld_widget("upper"))
+ , m_xLower(m_xBuilder->weld_widget("lower"))
+ , m_xTopButton(m_xBuilder->weld_radio_button("top"))
+ , m_xBottomButton(m_xBuilder->weld_radio_button("bottom"))
+ , m_xRightField(m_xBuilder->weld_metric_spin_button("right", FieldUnit::CM))
+ , m_xDownField(m_xBuilder->weld_metric_spin_button("down", FieldUnit::CM))
+ , m_xPrinterInfo(m_xBuilder->weld_label("printername"))
+ , m_xPrtSetup(m_xBuilder->weld_button("setup"))
+ , m_aIdsL { m_xBuilder->weld_radio_button("horileftl"),
+ m_xBuilder->weld_radio_button("horicenterl"),
+ m_xBuilder->weld_radio_button("horirightl"),
+ m_xBuilder->weld_radio_button("vertleftl"),
+ m_xBuilder->weld_radio_button("vertcenterl"),
+ m_xBuilder->weld_radio_button("vertrightl") }
+ , m_aIdsU { m_xBuilder->weld_radio_button("horileftu"),
+ m_xBuilder->weld_radio_button("horicenteru"),
+ m_xBuilder->weld_radio_button("horirightu"),
+ m_xBuilder->weld_radio_button("vertleftu"),
+ m_xBuilder->weld_radio_button("vertcenteru"),
+ m_xBuilder->weld_radio_button("vertrightu") }
+{
+ SetExchangeSupport();
+
+ // Metrics
+ FieldUnit eUnit = ::GetDfltMetric(false);
+ ::SetFieldUnit(*m_xRightField, eUnit);
+ ::SetFieldUnit(*m_xDownField, eUnit);
+
+ // Install handlers
+ m_xTopButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl));
+ m_xBottomButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl));
+
+ m_xPrtSetup->connect_clicked(LINK(this, SwEnvPrtPage, ButtonHdl));
+
+ for (auto& a : m_aIdsL)
+ a->connect_toggled(LINK(this, SwEnvPrtPage, LowerHdl));
+ for (auto& a : m_aIdsU)
+ a->connect_toggled(LINK(this, SwEnvPrtPage, UpperHdl));
+
+ // Bitmaps
+ ClickHdl(*m_xBottomButton);
+}
+
+SwEnvPrtPage::~SwEnvPrtPage()
+{
+ m_xPrt.clear();
+}
+
+IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl, weld::ToggleButton&, void)
+{
+ // Envelope from bottom, otherwise Envelope from top
+ const bool bLowerActive = m_xBottomButton->get_active();
+ m_xUpper->set_visible(!bLowerActive);
+ m_xLower->set_visible(bLowerActive);
+}
+
+IMPL_LINK(SwEnvPrtPage, LowerHdl, weld::ToggleButton&, rButton, void)
+{
+ for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
+ {
+ if (&rButton == m_aIdsL[i].get())
+ {
+ m_aIdsU[i]->set_active(m_aIdsL[i]->get_active());
+ break;
+ }
+ }
+}
+
+IMPL_LINK(SwEnvPrtPage, UpperHdl, weld::ToggleButton&, rButton, void)
+{
+ for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
+ {
+ if (&rButton == m_aIdsU[i].get())
+ {
+ m_aIdsL[i]->set_active(m_aIdsU[i]->get_active());
+ break;
+ }
+ }
+}
+
+IMPL_LINK(SwEnvPrtPage, ButtonHdl, weld::Button&, rBtn, void)
+{
+ if (&rBtn == m_xPrtSetup.get())
+ {
+ // Call printer setup
+ if (m_xPrt)
+ {
+ PrinterSetupDialog aDlg(GetFrameWeld());
+ aDlg.SetPrinter(m_xPrt);
+ aDlg.run();
+ rBtn.grab_focus();
+ m_xPrinterInfo->set_label(m_xPrt->GetName());
+ }
+ }
+}
+
+std::unique_ptr<SfxTabPage> SwEnvPrtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwEnvPrtPage>(pPage, pController, *rSet);
+}
+
+void SwEnvPrtPage::ActivatePage(const SfxItemSet&)
+{
+ if (m_xPrt)
+ m_xPrinterInfo->set_label(m_xPrt->GetName());
+}
+
+DeactivateRC SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if( _pSet )
+ FillItemSet(_pSet);
+ return DeactivateRC::LeavePage;
+}
+
+void SwEnvPrtPage::FillItem(SwEnvItem& rItem)
+{
+ int nOrient = 0;
+ for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i)
+ {
+ assert(m_aIdsL[i]->get_active() == m_aIdsU[i]->get_active());
+ if (m_aIdsL[i]->get_active())
+ {
+ nOrient = i;
+ break;
+ }
+ }
+
+ rItem.m_eAlign = static_cast<SwEnvAlign>(nOrient);
+ rItem.m_bPrintFromAbove = m_xTopButton->get_active();
+ rItem.m_nShiftRight = getfieldval(*m_xRightField);
+ rItem.m_nShiftDown = getfieldval(*m_xDownField);
+}
+
+bool SwEnvPrtPage::FillItemSet(SfxItemSet* rSet)
+{
+ FillItem(GetParentSwEnvDlg()->aEnvItem);
+ rSet->Put(GetParentSwEnvDlg()->aEnvItem);
+ return true;
+}
+
+void SwEnvPrtPage::Reset(const SfxItemSet* rSet)
+{
+ // Read item
+ const SwEnvItem& rItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP) );
+ m_aIdsL[rItem.m_eAlign]->set_active(true);
+ m_aIdsU[rItem.m_eAlign]->set_active(true);
+
+ if (rItem.m_bPrintFromAbove)
+ m_xTopButton->set_active(true);
+ else
+ m_xBottomButton->set_active(true);
+
+ setfieldval(*m_xRightField, rItem.m_nShiftRight);
+ setfieldval(*m_xDownField , rItem.m_nShiftDown );
+
+ ActivatePage(*rSet);
+ ClickHdl(*m_xTopButton);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx
new file mode 100644
index 000000000..00a610cad
--- /dev/null
+++ b/sw/source/ui/envelp/envprt.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_ENVPRT_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_ENVPRT_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/print.hxx>
+#include <vcl/weld.hxx>
+
+#include <envimg.hxx>
+#include <envlop.hxx>
+
+class SwEnvDlg;
+
+class SwEnvPrtPage : public SfxTabPage
+{
+ std::unique_ptr<weld::Widget> m_xUpper;
+ std::unique_ptr<weld::Widget> m_xLower;
+ std::unique_ptr<weld::RadioButton> m_xTopButton;
+ std::unique_ptr<weld::RadioButton> m_xBottomButton;
+ std::unique_ptr<weld::MetricSpinButton> m_xRightField;
+ std::unique_ptr<weld::MetricSpinButton> m_xDownField;
+ std::unique_ptr<weld::Label> m_xPrinterInfo;
+ std::unique_ptr<weld::Button> m_xPrtSetup;
+
+ std::unique_ptr<weld::RadioButton> m_aIdsL[ENV_VER_RGHT-ENV_HOR_LEFT+1];
+ std::unique_ptr<weld::RadioButton> m_aIdsU[ENV_VER_RGHT-ENV_HOR_LEFT+1];
+
+ VclPtr<Printer> m_xPrt;
+
+ DECL_LINK(LowerHdl, weld::ToggleButton&, void);
+ DECL_LINK(UpperHdl, weld::ToggleButton&, void);
+ DECL_LINK(ClickHdl, weld::ToggleButton&, void);
+ DECL_LINK(ButtonHdl, weld::Button&, void );
+
+ SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetDialogController()); }
+
+public:
+ SwEnvPrtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ virtual ~SwEnvPrtPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ void FillItem(SwEnvItem& rItem);
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+
+ void SetPrt(Printer* pPrinter) { m_xPrt = pPrinter; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
new file mode 100644
index 000000000..4ac097718
--- /dev/null
+++ b/sw/source/ui/envelp/label1.cxx
@@ -0,0 +1,725 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <memory>
+#include <vcl/svapp.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/lineend.hxx>
+#include <svtools/unitconv.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <swtypes.hxx>
+#include <labimp.hxx>
+#include "swuilabimp.hxx"
+#include "labfmt.hxx"
+#include "labprt.hxx"
+#include <dbmgr.hxx>
+#include <uitool.hxx>
+#include <cmdid.h>
+#include <helpids.h>
+#include <strings.hrc>
+#include <envimg.hxx>
+
+void SwLabRec::SetFromItem( const SwLabItem& rItem )
+{
+ m_nHDist = rItem.m_lHDist;
+ m_nVDist = rItem.m_lVDist;
+ m_nWidth = rItem.m_lWidth;
+ m_nHeight = rItem.m_lHeight;
+ m_nLeft = rItem.m_lLeft;
+ m_nUpper = rItem.m_lUpper;
+ m_nCols = rItem.m_nCols;
+ m_nRows = rItem.m_nRows;
+ m_nPWidth = rItem.m_lPWidth;
+ m_nPHeight = rItem.m_lPHeight;
+ m_bCont = rItem.m_bCont;
+}
+
+void SwLabRec::FillItem( SwLabItem& rItem ) const
+{
+ rItem.m_lHDist = m_nHDist;
+ rItem.m_lVDist = m_nVDist;
+ rItem.m_lWidth = m_nWidth;
+ rItem.m_lHeight = m_nHeight;
+ rItem.m_lLeft = m_nLeft;
+ rItem.m_lUpper = m_nUpper;
+ rItem.m_nCols = m_nCols;
+ rItem.m_lPWidth = m_nPWidth;
+ rItem.m_lPHeight = m_nPHeight;
+ rItem.m_nRows = m_nRows;
+}
+
+void SwLabDlg::ReplaceGroup_( const OUString &rMake )
+{
+ // Remove old entries
+ m_pRecs->erase(m_pRecs->begin() + 1, m_pRecs->end());
+ aLabelsCfg.FillLabels(rMake, *m_pRecs);
+ aLstGroup = rMake;
+}
+
+void SwLabDlg::PageCreated(const OString &rId, SfxTabPage &rPage)
+{
+ if (rId == "labels")
+ {
+ if (m_bLabel)
+ {
+ static_cast<SwLabPage*>(&rPage)->SetDBManager(pDBManager);
+ static_cast<SwLabPage*>(&rPage)->InitDatabaseBox();
+ }
+ else
+ static_cast<SwLabPage*>(&rPage)->SetToBusinessCard();
+ }
+ else if (rId == "options")
+ m_pPrtPage = static_cast<SwLabPrtPage*>(&rPage);
+}
+
+SwLabDlg::SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
+ SwDBManager* pDBManager_, bool bLabel)
+ : SfxTabDialogController(pParent, "modules/swriter/ui/labeldialog.ui", "LabelDialog", &rSet)
+ , pDBManager(pDBManager_)
+ , m_pPrtPage(nullptr)
+ , aTypeIds(50, 10)
+ , m_pRecs(new SwLabRecs)
+ , m_bLabel(bLabel)
+{
+ weld::WaitObject aWait(pParent);
+
+ // Read user label from writer.cfg
+ SwLabItem aItem(static_cast<const SwLabItem&>(rSet.Get( FN_LABEL )));
+ std::unique_ptr<SwLabRec> pRec(new SwLabRec);
+ pRec->m_aMake = pRec->m_aType = SwResId(STR_CUSTOM_LABEL);
+ pRec->SetFromItem( aItem );
+
+ bool bDouble = false;
+
+ for (const std::unique_ptr<SwLabRec> & i : *m_pRecs)
+ {
+ if (pRec->m_aMake == i->m_aMake &&
+ pRec->m_aType == i->m_aType)
+ {
+ bDouble = true;
+ break;
+ }
+ }
+
+ if (!bDouble)
+ m_pRecs->insert( m_pRecs->begin(), std::move(pRec));
+
+ size_t nLstGroup = 0;
+ const std::vector<OUString>& rMan = aLabelsCfg.GetManufacturers();
+ for(size_t nMan = 0; nMan < rMan.size(); ++nMan)
+ {
+ aMakes.push_back(rMan[nMan]);
+ if ( rMan[nMan] == aItem.m_aLstMake )
+ nLstGroup = nMan;
+ }
+
+ if ( !aMakes.empty() )
+ ReplaceGroup_( aMakes[nLstGroup] );
+
+ if (m_xExampleSet)
+ m_xExampleSet->Put(aItem);
+
+ AddTabPage("format", SwLabFormatPage::Create, nullptr);
+ AddTabPage("options", SwLabPrtPage::Create, nullptr);
+ m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS);
+
+ if (m_bLabel)
+ {
+ RemoveTabPage("business");
+ RemoveTabPage("private");
+ RemoveTabPage("medium");
+ AddTabPage("labels", SwLabPage::Create, nullptr);
+ }
+ else
+ {
+ RemoveTabPage("labels");
+ AddTabPage("medium", SwLabPage::Create, nullptr);
+ AddTabPage("business", SwBusinessDataPage::Create, nullptr );
+ AddTabPage("private", SwPrivateDataPage::Create, nullptr);
+ m_xDialog->set_title(m_sBusinessCardDlg);
+ }
+
+ pParent->set_busy_cursor(false);
+}
+
+SwLabDlg::~SwLabDlg()
+{
+ m_pRecs.reset();
+}
+
+void SwLabDlg::GetLabItem(SwLabItem &rItem)
+{
+ const SwLabItem& rActItem = static_cast<const SwLabItem&>(GetExampleSet()->Get(FN_LABEL));
+ const SwLabItem& rOldItem = static_cast<const SwLabItem&>(GetInputSetImpl()->Get(FN_LABEL));
+
+ if (rActItem != rOldItem)
+ {
+ // Was already "put" with (hopefully) correct content
+ rItem = rActItem;
+ }
+ else
+ {
+ rItem = rOldItem;
+
+ // In rItem there are only settings defined by users.
+ // Therefore get the real settings directly from Record
+ SwLabRec* pRec = GetRecord(rItem.m_aType, rItem.m_bCont);
+ pRec->FillItem( rItem );
+ }
+}
+
+SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, bool bCont)
+{
+ SwLabRec* pRec = nullptr;
+ bool bFound = false;
+ const OUString sCustom(SwResId(STR_CUSTOM_LABEL));
+
+ const size_t nCount = Recs().size();
+ for (size_t i = 0; i < nCount; ++i)
+ {
+ pRec = Recs()[i].get();
+ if (pRec->m_aType != sCustom &&
+ rRecName == pRec->m_aType && bCont == pRec->m_bCont)
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) // User defined
+ pRec = Recs()[0].get();
+
+ return pRec;
+}
+
+Printer *SwLabDlg::GetPrt()
+{
+ if (m_pPrtPage)
+ return m_pPrtPage->GetPrt();
+ else
+ return nullptr;
+}
+
+SwLabPage::SwLabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/cardmediumpage.ui", "CardMediumPage", &rSet)
+ , pDBManager(nullptr)
+ , aItem(static_cast<const SwLabItem&>(rSet.Get(FN_LABEL)))
+ , m_xAddressFrame(m_xBuilder->weld_widget("addressframe"))
+ , m_xAddrBox(m_xBuilder->weld_check_button("address"))
+ , m_xWritingEdit(m_xBuilder->weld_text_view("textview"))
+ , m_xDatabaseLB(m_xBuilder->weld_combo_box("database"))
+ , m_xTableLB(m_xBuilder->weld_combo_box("table"))
+ , m_xInsertBT(m_xBuilder->weld_button("insert"))
+ , m_xDBFieldLB(m_xBuilder->weld_combo_box("field"))
+ , m_xContButton(m_xBuilder->weld_radio_button("continuous"))
+ , m_xSheetButton(m_xBuilder->weld_radio_button("sheet"))
+ , m_xMakeBox(m_xBuilder->weld_combo_box("brand"))
+ , m_xTypeBox(m_xBuilder->weld_combo_box("type"))
+ , m_xHiddenSortTypeBox(m_xBuilder->weld_combo_box("hiddentype"))
+ , m_xFormatInfo(m_xBuilder->weld_label("formatinfo"))
+{
+ weld::WaitObject aWait(GetFrameWeld());
+
+ m_xWritingEdit->set_size_request(m_xWritingEdit->get_approximate_digit_width() * 30,
+ m_xWritingEdit->get_height_rows(10));
+ m_xHiddenSortTypeBox->make_sorted();
+
+ long nListBoxWidth = m_xWritingEdit->get_approximate_digit_width() * 25;
+ m_xTableLB->set_size_request(nListBoxWidth, -1);
+ m_xDatabaseLB->set_size_request(nListBoxWidth, -1);
+ m_xDBFieldLB->set_size_request(nListBoxWidth, -1);
+
+ SetExchangeSupport();
+
+ // Install handlers
+ m_xAddrBox->connect_toggled(LINK(this, SwLabPage, AddrHdl));
+ m_xDatabaseLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xTableLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xDBFieldLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xInsertBT->connect_clicked(LINK(this, SwLabPage, FieldHdl));
+ // Disable insert button first,
+ // it'll be enabled if m_xDatabaseLB, m_pTableLB and m_pInsertBT are filled
+ m_xInsertBT->set_sensitive(false);
+ m_xContButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
+ m_xSheetButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
+ auto nMaxWidth = m_xMakeBox->get_approximate_digit_width() * 32;
+ m_xMakeBox->set_size_request(nMaxWidth, -1);
+ m_xTypeBox->set_size_request(nMaxWidth, -1);
+ m_xMakeBox->connect_changed(LINK(this, SwLabPage, MakeHdl));
+ m_xTypeBox->connect_changed(LINK(this, SwLabPage, TypeHdl));
+
+ InitDatabaseBox();
+}
+
+SwLabPage::~SwLabPage()
+{
+}
+
+void SwLabPage::SetToBusinessCard()
+{
+ m_xContainer->set_help_id(HID_BUSINESS_FMT_PAGE);
+ m_xContButton->set_help_id(HID_BUSINESS_FMT_PAGE_CONT);
+ m_xSheetButton->set_help_id(HID_BUSINESS_FMT_PAGE_SHEET);
+ m_xMakeBox->set_help_id(HID_BUSINESS_FMT_PAGE_BRAND);
+ m_xTypeBox->set_help_id(HID_BUSINESS_FMT_PAGE_TYPE);
+ m_xAddressFrame->hide();
+};
+
+IMPL_LINK_NOARG(SwLabPage, AddrHdl, weld::ToggleButton&, void)
+{
+ OUString aWriting;
+
+ if (m_xAddrBox->get_active())
+ aWriting = convertLineEnd(MakeSender(), GetSystemLineEnd());
+
+ m_xWritingEdit->set_text(aWriting);
+ m_xWritingEdit->grab_focus();
+}
+
+IMPL_LINK( SwLabPage, DatabaseHdl, weld::ComboBox&, rListBox, void )
+{
+ sActDBName = m_xDatabaseLB->get_active_text();
+
+ weld::WaitObject aObj(GetParentSwLabDlg()->getDialog());
+
+ if (&rListBox == m_xDatabaseLB.get())
+ GetDBManager()->GetTableNames(*m_xTableLB, sActDBName);
+
+ if (&rListBox == m_xDatabaseLB.get() || &rListBox == m_xTableLB.get())
+ GetDBManager()->GetColumnNames(*m_xDBFieldLB, sActDBName, m_xTableLB->get_active_text());
+
+ if (!m_xDatabaseLB->get_active_text().isEmpty() && !m_xTableLB->get_active_text().isEmpty()
+ && !m_xDBFieldLB->get_active_text().isEmpty())
+ m_xInsertBT->set_sensitive(true);
+ else
+ m_xInsertBT->set_sensitive(false);
+}
+
+IMPL_LINK_NOARG(SwLabPage, FieldHdl, weld::Button&, void)
+{
+ OUString aStr("<" + m_xDatabaseLB->get_active_text() + "." +
+ m_xTableLB->get_active_text() + "." +
+ m_xTableLB->get_active_id() + "." +
+ m_xDBFieldLB->get_active_text() + ">");
+ m_xWritingEdit->replace_selection(aStr);
+ int nStartPos, nEndPos;
+ m_xWritingEdit->get_selection_bounds(nStartPos, nEndPos);
+ m_xWritingEdit->grab_focus();
+ m_xWritingEdit->select_region(nStartPos, nEndPos);
+}
+
+IMPL_LINK_NOARG(SwLabPage, PageHdl, weld::ToggleButton&, void)
+{
+ MakeHdl(*m_xMakeBox);
+}
+
+IMPL_LINK_NOARG(SwLabPage, MakeHdl, weld::ComboBox&, void)
+{
+ weld::WaitObject aWait(GetParentSwLabDlg()->getDialog());
+
+ m_xTypeBox->clear();
+ m_xHiddenSortTypeBox->clear();
+ GetParentSwLabDlg()->TypeIds().clear();
+
+ const OUString aMake = m_xMakeBox->get_active_text();
+ GetParentSwLabDlg()->ReplaceGroup( aMake );
+ aItem.m_aLstMake = aMake;
+
+ const bool bCont = m_xContButton->get_active();
+ const size_t nCount = GetParentSwLabDlg()->Recs().size();
+ size_t nLstType = 0;
+
+ const OUString sCustom(SwResId(STR_CUSTOM_LABEL));
+ //insert the entries into the sorted list box
+ for ( size_t i = 0; i < nCount; ++i )
+ {
+ const OUString aType(GetParentSwLabDlg()->Recs()[i]->m_aType);
+ bool bInsert = false;
+ if (GetParentSwLabDlg()->Recs()[i]->m_aType == sCustom)
+ {
+ bInsert = true;
+ m_xTypeBox->append_text(aType );
+ }
+ else if (GetParentSwLabDlg()->Recs()[i]->m_bCont == bCont)
+ {
+ if (m_xHiddenSortTypeBox->find_text(aType) == -1)
+ {
+ bInsert = true;
+ m_xHiddenSortTypeBox->append_text( aType );
+ }
+ }
+ if(bInsert)
+ {
+ GetParentSwLabDlg()->TypeIds().push_back(i);
+ if ( !nLstType && aType == aItem.m_aLstType )
+ nLstType = GetParentSwLabDlg()->TypeIds().size();
+ }
+ }
+ for (int nEntry = 0; nEntry < m_xHiddenSortTypeBox->get_count(); ++nEntry)
+ {
+ m_xTypeBox->append_text(m_xHiddenSortTypeBox->get_text(nEntry));
+ }
+ if (nLstType)
+ m_xTypeBox->set_active_text(aItem.m_aLstType);
+ else
+ m_xTypeBox->set_active(0);
+ TypeHdl(*m_xTypeBox);
+}
+
+IMPL_LINK_NOARG(SwLabPage, TypeHdl, weld::ComboBox&, void)
+{
+ DisplayFormat();
+ aItem.m_aType = m_xTypeBox->get_active_text();
+}
+
+void SwLabPage::DisplayFormat()
+{
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/spinbox.ui"));
+ std::unique_ptr<weld::MetricSpinButton> xField(xBuilder->weld_metric_spin_button("spin", FieldUnit::CM));
+ SetFieldUnit(*xField, ::GetDfltMetric(false));
+ xField->set_digits(2);
+ xField->set_range(0, INT_MAX - 1, FieldUnit::NONE);
+
+ SwLabRec* pRec = GetSelectedEntryPos();
+ aItem.m_aLstType = pRec->m_aType;
+ setfldval(*xField, pRec->m_nWidth);
+ xField->reformat();
+ const OUString aWString = xField->get_text();
+
+ setfldval(*xField, pRec->m_nHeight);
+ xField->reformat();
+
+ OUString aText = pRec->m_aType + ": " + aWString +
+ " x " + xField->get_text() +
+ " (" + OUString::number( pRec->m_nCols ) +
+ " x " + OUString::number( pRec->m_nRows ) + ")";
+ m_xFormatInfo->set_label(aText);
+}
+
+SwLabRec* SwLabPage::GetSelectedEntryPos()
+{
+ OUString sSelEntry(m_xTypeBox->get_active_text());
+
+ return GetParentSwLabDlg()->GetRecord(sSelEntry, m_xContButton->get_active());
+}
+
+void SwLabPage::InitDatabaseBox()
+{
+ if( GetDBManager() )
+ {
+ m_xDatabaseLB->clear();
+ const css::uno::Sequence<OUString> aDataNames = SwDBManager::GetExistingDatabaseNames();
+ for (const OUString& rDataName : aDataNames)
+ m_xDatabaseLB->append_text(rDataName);
+ sal_Int32 nIdx{ 0 };
+ OUString sDBName = sActDBName.getToken( 0, DB_DELIM, nIdx );
+ OUString sTableName = sActDBName.getToken( 0, DB_DELIM, nIdx );
+ m_xDatabaseLB->set_active_text(sDBName);
+ if( !sDBName.isEmpty() && GetDBManager()->GetTableNames(*m_xTableLB, sDBName))
+ {
+ m_xTableLB->set_active_text(sTableName);
+ GetDBManager()->GetColumnNames(*m_xDBFieldLB, sActDBName, sTableName);
+ }
+ else
+ m_xDBFieldLB->clear();
+ }
+}
+
+std::unique_ptr<SfxTabPage> SwLabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwLabPage>(pPage, pController, *rSet);
+}
+
+void SwLabPage::ActivatePage(const SfxItemSet& rSet)
+{
+ Reset( &rSet );
+}
+
+DeactivateRC SwLabPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if (_pSet)
+ FillItemSet(_pSet);
+
+ return DeactivateRC::LeavePage;
+}
+
+void SwLabPage::FillItem(SwLabItem& rItem)
+{
+ rItem.m_bAddr = m_xAddrBox->get_active();
+ rItem.m_aWriting = m_xWritingEdit->get_text();
+ rItem.m_bCont = m_xContButton->get_active();
+ rItem.m_aMake = m_xMakeBox->get_active_text();
+ rItem.m_aType = m_xTypeBox->get_active_text();
+ rItem.m_sDBName = sActDBName;
+
+ SwLabRec* pRec = GetSelectedEntryPos();
+ pRec->FillItem( rItem );
+
+ rItem.m_aLstMake = m_xMakeBox->get_active_text();
+ rItem.m_aLstType = m_xTypeBox->get_active_text();
+}
+
+bool SwLabPage::FillItemSet(SfxItemSet* rSet)
+{
+ FillItem( aItem );
+ rSet->Put( aItem );
+
+ return true;
+}
+
+void SwLabPage::Reset(const SfxItemSet* rSet)
+{
+ m_xMakeBox->clear();
+
+ size_t nLstGroup = 0;
+
+ const size_t nCount = GetParentSwLabDlg()->Makes().size();
+ for(size_t i = 0; i < nCount; ++i)
+ {
+ OUString& rStr = GetParentSwLabDlg()->Makes()[i];
+ m_xMakeBox->append_text(rStr);
+
+ if ( rStr == aItem.m_aLstMake)
+ nLstGroup = i;
+ }
+
+ m_xMakeBox->set_active( nLstGroup );
+ MakeHdl(*m_xMakeBox);
+
+ aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL));
+ OUString sDBName = aItem.m_sDBName;
+
+ OUString aWriting(convertLineEnd(aItem.m_aWriting, GetSystemLineEnd()));
+
+ m_xAddrBox->set_active( aItem.m_bAddr );
+ m_xWritingEdit->set_text( aWriting );
+
+ for(const auto& rMake : GetParentSwLabDlg()->Makes())
+ {
+ if (m_xMakeBox->find_text(rMake) == -1)
+ m_xMakeBox->append_text(rMake);
+ }
+
+ m_xMakeBox->set_active_text(aItem.m_aMake);
+ //save the current type
+ OUString sType(aItem.m_aType);
+ MakeHdl(*m_xMakeBox);
+ aItem.m_aType = sType;
+ //#102806# a newly added make may not be in the type ListBox already
+ if (m_xTypeBox->find_text(aItem.m_aType) == -1 && !aItem.m_aMake.isEmpty())
+ GetParentSwLabDlg()->UpdateGroup( aItem.m_aMake );
+ if (m_xTypeBox->find_text(aItem.m_aType) != -1)
+ {
+ m_xTypeBox->set_active_text(aItem.m_aType);
+ TypeHdl(*m_xTypeBox);
+ }
+ if (m_xDatabaseLB->find_text(sDBName) != -1)
+ {
+ m_xDatabaseLB->set_active_text(sDBName);
+ DatabaseHdl(*m_xDatabaseLB);
+ }
+
+ if (aItem.m_bCont)
+ m_xContButton->set_active(true);
+ else
+ m_xSheetButton->set_active(true);
+}
+
+SwPrivateDataPage::SwPrivateDataPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/privateuserpage.ui", "PrivateUserPage", &rSet)
+ , m_xFirstNameED(m_xBuilder->weld_entry("firstname"))
+ , m_xNameED(m_xBuilder->weld_entry("lastname"))
+ , m_xShortCutED(m_xBuilder->weld_entry("shortname"))
+ , m_xFirstName2ED(m_xBuilder->weld_entry("firstname2"))
+ , m_xName2ED(m_xBuilder->weld_entry("lastname2"))
+ , m_xShortCut2ED(m_xBuilder->weld_entry("shortname2"))
+ , m_xStreetED(m_xBuilder->weld_entry("street"))
+ , m_xZipED(m_xBuilder->weld_entry("izip"))
+ , m_xCityED(m_xBuilder->weld_entry("icity"))
+ , m_xCountryED(m_xBuilder->weld_entry("country"))
+ , m_xStateED(m_xBuilder->weld_entry("state"))
+ , m_xTitleED(m_xBuilder->weld_entry("title"))
+ , m_xProfessionED(m_xBuilder->weld_entry("job"))
+ , m_xPhoneED(m_xBuilder->weld_entry("phone"))
+ , m_xMobilePhoneED(m_xBuilder->weld_entry("mobile"))
+ , m_xFaxED(m_xBuilder->weld_entry("fax"))
+ , m_xHomePageED(m_xBuilder->weld_entry("url"))
+ , m_xMailED(m_xBuilder->weld_entry("email"))
+{
+ SetExchangeSupport();
+}
+
+SwPrivateDataPage::~SwPrivateDataPage()
+{
+}
+
+std::unique_ptr<SfxTabPage> SwPrivateDataPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwPrivateDataPage>(pPage, pController, *rSet);
+}
+
+void SwPrivateDataPage::ActivatePage(const SfxItemSet& rSet)
+{
+ Reset(&rSet);
+}
+
+DeactivateRC SwPrivateDataPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if (_pSet)
+ FillItemSet(_pSet);
+ return DeactivateRC::LeavePage;
+}
+
+bool SwPrivateDataPage::FillItemSet(SfxItemSet* rSet)
+{
+ const SfxItemSet* pExampleSet = GetDialogExampleSet();
+ assert(pExampleSet);
+ SwLabItem aItem = static_cast<const SwLabItem&>(pExampleSet->Get(FN_LABEL));
+
+ aItem.m_aPrivFirstName = m_xFirstNameED->get_text();
+ aItem.m_aPrivName = m_xNameED->get_text();
+ aItem.m_aPrivShortCut = m_xShortCutED->get_text();
+ aItem.m_aPrivFirstName2 = m_xFirstName2ED->get_text();
+ aItem.m_aPrivName2 = m_xName2ED->get_text();
+ aItem.m_aPrivShortCut2 = m_xShortCut2ED->get_text();
+ aItem.m_aPrivStreet = m_xStreetED->get_text();
+ aItem.m_aPrivZip = m_xZipED->get_text();
+ aItem.m_aPrivCity = m_xCityED->get_text();
+ aItem.m_aPrivCountry = m_xCountryED->get_text();
+ aItem.m_aPrivState = m_xStateED->get_text();
+ aItem.m_aPrivTitle = m_xTitleED->get_text();
+ aItem.m_aPrivProfession= m_xProfessionED->get_text();
+ aItem.m_aPrivPhone = m_xPhoneED->get_text();
+ aItem.m_aPrivMobile = m_xMobilePhoneED->get_text();
+ aItem.m_aPrivFax = m_xFaxED->get_text();
+ aItem.m_aPrivWWW = m_xHomePageED->get_text();
+ aItem.m_aPrivMail = m_xMailED->get_text();
+
+ rSet->Put(aItem);
+ return true;
+}
+
+void SwPrivateDataPage::Reset(const SfxItemSet* rSet)
+{
+ const SwLabItem& aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL) );
+ m_xFirstNameED->set_text(aItem.m_aPrivFirstName);
+ m_xNameED->set_text(aItem.m_aPrivName);
+ m_xShortCutED->set_text(aItem.m_aPrivShortCut);
+ m_xFirstName2ED->set_text(aItem.m_aPrivFirstName2);
+ m_xName2ED->set_text(aItem.m_aPrivName2);
+ m_xShortCut2ED->set_text(aItem.m_aPrivShortCut2);
+ m_xStreetED->set_text(aItem.m_aPrivStreet);
+ m_xZipED->set_text(aItem.m_aPrivZip);
+ m_xCityED->set_text(aItem.m_aPrivCity);
+ m_xCountryED->set_text(aItem.m_aPrivCountry);
+ m_xStateED->set_text(aItem.m_aPrivState);
+ m_xTitleED->set_text(aItem.m_aPrivTitle);
+ m_xProfessionED->set_text(aItem.m_aPrivProfession);
+ m_xPhoneED->set_text(aItem.m_aPrivPhone);
+ m_xMobilePhoneED->set_text(aItem.m_aPrivMobile);
+ m_xFaxED->set_text(aItem.m_aPrivFax);
+ m_xHomePageED->set_text(aItem.m_aPrivWWW);
+ m_xMailED->set_text(aItem.m_aPrivMail);
+}
+
+SwBusinessDataPage::SwBusinessDataPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/businessdatapage.ui", "BusinessDataPage", &rSet)
+ , m_xCompanyED(m_xBuilder->weld_entry("company"))
+ , m_xCompanyExtED(m_xBuilder->weld_entry("company2"))
+ , m_xSloganED(m_xBuilder->weld_entry("slogan"))
+ , m_xStreetED(m_xBuilder->weld_entry("street"))
+ , m_xZipED(m_xBuilder->weld_entry("izip"))
+ , m_xCityED(m_xBuilder->weld_entry("icity"))
+ , m_xCountryED(m_xBuilder->weld_entry("country"))
+ , m_xStateED(m_xBuilder->weld_entry("state"))
+ , m_xPositionED(m_xBuilder->weld_entry("position"))
+ , m_xPhoneED(m_xBuilder->weld_entry("phone"))
+ , m_xMobilePhoneED(m_xBuilder->weld_entry("mobile"))
+ , m_xFaxED(m_xBuilder->weld_entry("fax"))
+ , m_xHomePageED(m_xBuilder->weld_entry("url"))
+ , m_xMailED(m_xBuilder->weld_entry("email"))
+{
+ SetExchangeSupport();
+}
+
+SwBusinessDataPage::~SwBusinessDataPage()
+{
+}
+
+std::unique_ptr<SfxTabPage> SwBusinessDataPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwBusinessDataPage>(pPage, pController, *rSet);
+}
+
+void SwBusinessDataPage::ActivatePage(const SfxItemSet& rSet)
+{
+ Reset(&rSet);
+}
+
+DeactivateRC SwBusinessDataPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if (_pSet)
+ FillItemSet(_pSet);
+ return DeactivateRC::LeavePage;
+}
+
+bool SwBusinessDataPage::FillItemSet(SfxItemSet* rSet)
+{
+ const SfxItemSet* pExampleSet = GetDialogExampleSet();
+ assert(pExampleSet);
+ SwLabItem aItem = static_cast<const SwLabItem&>(pExampleSet->Get(FN_LABEL));
+
+ aItem.m_aCompCompany = m_xCompanyED->get_text();
+ aItem.m_aCompCompanyExt= m_xCompanyExtED->get_text();
+ aItem.m_aCompSlogan = m_xSloganED->get_text();
+ aItem.m_aCompStreet = m_xStreetED->get_text();
+ aItem.m_aCompZip = m_xZipED->get_text();
+ aItem.m_aCompCity = m_xCityED->get_text();
+ aItem.m_aCompCountry = m_xCountryED->get_text();
+ aItem.m_aCompState = m_xStateED->get_text();
+ aItem.m_aCompPosition = m_xPositionED->get_text();
+ aItem.m_aCompPhone = m_xPhoneED->get_text();
+ aItem.m_aCompMobile = m_xMobilePhoneED->get_text();
+ aItem.m_aCompFax = m_xFaxED->get_text();
+ aItem.m_aCompWWW = m_xHomePageED->get_text();
+ aItem.m_aCompMail = m_xMailED->get_text();
+
+ rSet->Put(aItem);
+ return true;
+}
+
+void SwBusinessDataPage::Reset(const SfxItemSet* rSet)
+{
+ const SwLabItem& aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL) );
+ m_xCompanyED->set_text(aItem.m_aCompCompany);
+ m_xCompanyExtED->set_text(aItem.m_aCompCompanyExt);
+ m_xSloganED->set_text(aItem.m_aCompSlogan);
+ m_xStreetED->set_text(aItem.m_aCompStreet);
+ m_xZipED->set_text(aItem.m_aCompZip);
+ m_xCityED->set_text(aItem.m_aCompCity);
+ m_xCountryED->set_text(aItem.m_aCompCountry);
+ m_xStateED->set_text(aItem.m_aCompState);
+ m_xPositionED->set_text(aItem.m_aCompPosition);
+ m_xPhoneED->set_text(aItem.m_aCompPhone);
+ m_xMobilePhoneED->set_text(aItem.m_aCompMobile);
+ m_xFaxED->set_text(aItem.m_aCompFax);
+ m_xHomePageED->set_text(aItem.m_aCompWWW);
+ m_xMailED->set_text(aItem.m_aCompMail);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx
new file mode 100644
index 000000000..8f3cf437a
--- /dev/null
+++ b/sw/source/ui/envelp/labelexp.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <label.hxx>
+#include <labimg.hxx>
+#include <unoprnms.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+
+void SwLabDlg::UpdateFieldInformation(uno::Reference< frame::XModel > const & xModel, const SwLabItem& rItem)
+{
+ uno::Reference< text::XTextFieldsSupplier > xFields(xModel, uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xFieldMasters = xFields->getTextFieldMasters();
+
+ static const struct SwLabItemMap {
+ const char* pName;
+ OUString SwLabItem:: *pValue;
+ } aArr[] = {
+ { "BC_PRIV_FIRSTNAME" , &SwLabItem::m_aPrivFirstName },
+ { "BC_PRIV_NAME" , &SwLabItem::m_aPrivName },
+ { "BC_PRIV_INITIALS" , &SwLabItem::m_aPrivShortCut },
+ { "BC_PRIV_FIRSTNAME_2", &SwLabItem::m_aPrivFirstName2 },
+ { "BC_PRIV_NAME_2" , &SwLabItem::m_aPrivName2 },
+ { "BC_PRIV_INITIALS_2" , &SwLabItem::m_aPrivShortCut2 },
+ { "BC_PRIV_STREET" , &SwLabItem::m_aPrivStreet },
+ { "BC_PRIV_ZIP" , &SwLabItem::m_aPrivZip },
+ { "BC_PRIV_CITY" , &SwLabItem::m_aPrivCity },
+ { "BC_PRIV_COUNTRY" , &SwLabItem::m_aPrivCountry },
+ { "BC_PRIV_STATE" , &SwLabItem::m_aPrivState },
+ { "BC_PRIV_TITLE" , &SwLabItem::m_aPrivTitle },
+ { "BC_PRIV_PROFESSION" , &SwLabItem::m_aPrivProfession },
+ { "BC_PRIV_PHONE" , &SwLabItem::m_aPrivPhone },
+ { "BC_PRIV_MOBILE" , &SwLabItem::m_aPrivMobile },
+ { "BC_PRIV_FAX" , &SwLabItem::m_aPrivFax },
+ { "BC_PRIV_WWW" , &SwLabItem::m_aPrivWWW },
+ { "BC_PRIV_MAIL" , &SwLabItem::m_aPrivMail },
+ { "BC_COMP_COMPANY" , &SwLabItem::m_aCompCompany },
+ { "BC_COMP_COMPANYEXT" , &SwLabItem::m_aCompCompanyExt },
+ { "BC_COMP_SLOGAN" , &SwLabItem::m_aCompSlogan },
+ { "BC_COMP_STREET" , &SwLabItem::m_aCompStreet },
+ { "BC_COMP_ZIP" , &SwLabItem::m_aCompZip },
+ { "BC_COMP_CITY" , &SwLabItem::m_aCompCity },
+ { "BC_COMP_COUNTRY" , &SwLabItem::m_aCompCountry },
+ { "BC_COMP_STATE" , &SwLabItem::m_aCompState },
+ { "BC_COMP_POSITION" , &SwLabItem::m_aCompPosition },
+ { "BC_COMP_PHONE" , &SwLabItem::m_aCompPhone },
+ { "BC_COMP_MOBILE" , &SwLabItem::m_aCompMobile },
+ { "BC_COMP_FAX" , &SwLabItem::m_aCompFax },
+ { "BC_COMP_WWW" , &SwLabItem::m_aCompWWW },
+ { "BC_COMP_MAIL" , &SwLabItem::m_aCompMail },
+ { nullptr, nullptr }
+ };
+
+ try
+ {
+ for( const SwLabItemMap* p = aArr; p->pName; ++p )
+ {
+ OUString uFieldName(
+ "com.sun.star.text.FieldMaster.User."
+ + OUString::createFromAscii(p->pName));
+ if( xFieldMasters->hasByName( uFieldName ))
+ {
+ uno::Any aFirstName = xFieldMasters->getByName( uFieldName );
+ uno::Reference< beans::XPropertySet > xField;
+ aFirstName >>= xField;
+ uno::Any aContent;
+ aContent <<= rItem.*p->pValue;
+ xField->setPropertyValue( UNO_NAME_CONTENT, aContent );
+ }
+ }
+ }
+ catch (const uno::RuntimeException&)
+ {
+
+ }
+
+ uno::Reference< container::XEnumerationAccess > xFieldAcc = xFields->getTextFields();
+ uno::Reference< util::XRefreshable > xRefresh(xFieldAcc, uno::UNO_QUERY);
+ xRefresh->refresh();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
new file mode 100644
index 000000000..5011c4799
--- /dev/null
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -0,0 +1,609 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svtools/unitconv.hxx>
+#include <tools/poly.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <sal/log.hxx>
+
+#include <viewopt.hxx>
+
+#include <swtypes.hxx>
+#include <cmdid.h>
+#include <label.hxx>
+#include <labimp.hxx>
+#include <labimg.hxx>
+#include "labfmt.hxx"
+#include <uitool.hxx>
+
+#include <strings.hrc>
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+#define ROUND(x) static_cast<long>((x) + .5)
+
+namespace {
+
+// Arrow or interval character
+void DrawArrow(vcl::RenderContext& rRenderContext, const Point &rP1, const Point &rP2, bool bArrow)
+{
+ rRenderContext.DrawLine(rP1, rP2);
+ if (bArrow)
+ {
+ Point aArr[3];
+
+ // Arrow character
+ if (rP1.Y() == rP2.Y())
+ {
+ // Horizontal
+ aArr[0].setX( rP2.X() - 5 );
+ aArr[0].setY( rP2.Y() - 2 );
+ aArr[1].setX( rP2.X() );
+ aArr[1].setY( rP2.Y() );
+ aArr[2].setX( rP2.X() - 5 );
+ aArr[2].setY( rP2.Y() + 2 );
+ }
+ else
+ {
+ // Vertical
+ aArr[0].setX( rP2.X() - 2 );
+ aArr[0].setY( rP2.Y() - 5 );
+ aArr[1].setX( rP2.X() + 2 );
+ aArr[1].setY( rP2.Y() - 5 );
+ aArr[2].setX( rP2.X() );
+ aArr[2].setY( rP2.Y() );
+ }
+
+ const Color& rFieldTextColor = SwViewOption::GetFontColor();
+ rRenderContext.SetFillColor(rFieldTextColor);
+ rRenderContext.DrawPolygon( tools::Polygon(3, aArr));
+ }
+ else
+ {
+ // Interval symbol
+ if (rP1.Y() == rP2.Y())
+ {
+ // Horizontal
+ rRenderContext.DrawLine(Point(rP1.X(), rP1.Y() - 2), Point(rP1.X(), rP1.Y() + 2));
+ rRenderContext.DrawLine(Point(rP2.X(), rP2.Y() - 2), Point(rP2.X(), rP2.Y() + 2));
+ }
+ else
+ {
+ // Vertical
+ rRenderContext.DrawLine(Point(rP1.X() - 2, rP1.Y()), Point(rP1.X() + 2, rP1.Y()));
+ rRenderContext.DrawLine(Point(rP2.X() - 2, rP2.Y()), Point(rP2.X() + 2, rP2.Y()));
+ }
+ }
+}
+
+}
+
+SwLabPreview::SwLabPreview()
+ : m_aGrayColor(COL_LIGHTGRAY)
+ , m_aHDistStr(SwResId(STR_HDIST))
+ , m_aVDistStr(SwResId(STR_VDIST))
+ , m_aWidthStr(SwResId(STR_WIDTH))
+ , m_aHeightStr(SwResId(STR_HEIGHT))
+ , m_aLeftStr(SwResId(STR_LEFT))
+ , m_aUpperStr(SwResId(STR_UPPER))
+ , m_aColsStr(SwResId(STR_COLS))
+ , m_aRowsStr(SwResId(STR_ROWS))
+ , m_lHDistWidth(0)
+ , m_lVDistWidth(0)
+ , m_lHeightWidth(0)
+ , m_lLeftWidth(0)
+ , m_lUpperWidth(0)
+ , m_lColsWidth(0)
+ , m_lXWidth(0)
+ , m_lXHeight(0)
+{
+}
+
+void SwLabPreview::SetDrawingArea(weld::DrawingArea* pWidget)
+{
+ CustomWidgetController::SetDrawingArea(pWidget);
+
+ pWidget->set_size_request(pWidget->get_approximate_digit_width() * 54,
+ pWidget->get_text_height() * 15);
+
+ m_lHDistWidth = pWidget->get_pixel_size(m_aHDistStr).Width();
+ m_lVDistWidth = pWidget->get_pixel_size(m_aVDistStr).Width();
+ m_lHeightWidth = pWidget->get_pixel_size(m_aHeightStr).Width();
+ m_lLeftWidth = pWidget->get_pixel_size(m_aLeftStr).Width();
+ m_lUpperWidth = pWidget->get_pixel_size(m_aUpperStr).Width();
+ m_lColsWidth = pWidget->get_pixel_size(m_aColsStr).Width();
+ m_lXWidth = pWidget->get_pixel_size(OUString('X')).Width();
+ m_lXHeight = pWidget->get_text_height();
+}
+
+void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
+{
+ const Size aSize(GetOutputSizePixel());
+ const long lOutWPix = aSize.Width();
+ const long lOutHPix = aSize.Height();
+
+ // Scale factor
+ const double fxpix = double(lOutWPix - (2 * (m_lLeftWidth + 15))) / double(lOutWPix);
+
+ const long lOutWPix23 = long(double(lOutWPix) * fxpix);
+ const long lOutHPix23 = long(double(lOutHPix) * fxpix);
+
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ const Color& rWinColor = rStyleSettings.GetWindowColor();
+ const Color& rFieldTextColor = SwViewOption::GetFontColor();
+
+ vcl::Font aFont = rRenderContext.GetFont();
+ aFont.SetFillColor(rWinColor);
+ aFont.SetColor(rFieldTextColor);
+ rRenderContext.SetFont(aFont);
+
+ rRenderContext.SetBackground(Wallpaper(rWinColor));
+ rRenderContext.Erase();
+
+ rRenderContext.SetLineColor(rWinColor);
+ rRenderContext.SetFillColor(m_aGrayColor);
+ vcl::Font aPaintFont(rRenderContext.GetFont());
+ aPaintFont.SetTransparent(false);
+ rRenderContext.SetFont(aPaintFont);
+
+ // size of region to be displayed
+ const long lDispW = m_aItem.m_lLeft + m_aItem.m_lHDist + ((m_aItem.m_nCols == 1)
+ ? m_aItem.m_lLeft
+ : ROUND(m_aItem.m_lHDist / 10.0));
+
+ const long lDispH = m_aItem.m_lUpper + m_aItem.m_lVDist + ((m_aItem.m_nRows == 1)
+ ? m_aItem.m_lUpper
+ : ROUND(m_aItem.m_lVDist / 10.0));
+
+ // Scale factor
+ const float fx = float(lOutWPix23) / std::max(1L, lDispW);
+ const float fy = float(lOutHPix23) / std::max(1L, lDispH);
+ const float f = std::min(fx, fy);
+
+ // zero point
+ const long lOutlineW = ROUND(f * lDispW);
+ const long lOutlineH = ROUND(f * lDispH);
+
+ const long lX0 = (lOutWPix - lOutlineW) / 2;
+ const long lY0 = (lOutHPix - lOutlineH) / 2;
+ const long lX1 = lX0 + ROUND(f * m_aItem.m_lLeft );
+ const long lY1 = lY0 + ROUND(f * m_aItem.m_lUpper);
+ const long lX2 = lX0 + ROUND(f * (m_aItem.m_lLeft + m_aItem.m_lWidth ));
+ const long lY2 = lY0 + ROUND(f * (m_aItem.m_lUpper + m_aItem.m_lHeight));
+ const long lX3 = lX0 + ROUND(f * (m_aItem.m_lLeft + m_aItem.m_lHDist ));
+ const long lY3 = lY0 + ROUND(f * (m_aItem.m_lUpper + m_aItem.m_lVDist ));
+
+ // draw outline (area)
+ rRenderContext.DrawRect(tools::Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH)));
+
+ // draw outline (border)
+ rRenderContext.SetLineColor(rFieldTextColor);
+ rRenderContext.DrawLine(Point(lX0, lY0), Point(lX0 + lOutlineW - 1, lY0)); // Up
+ rRenderContext.DrawLine(Point(lX0, lY0), Point(lX0, lY0 + lOutlineH - 1)); // Left
+ if (m_aItem.m_nCols == 1)
+ rRenderContext.DrawLine(Point(lX0 + lOutlineW - 1, lY0), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Right
+ if (m_aItem.m_nRows == 1)
+ rRenderContext.DrawLine(Point(lX0, lY0 + lOutlineH - 1), Point(lX0 + lOutlineW - 1, lY0 + lOutlineH - 1)); // Down
+
+ // Labels
+ rRenderContext.SetClipRegion(vcl::Region(tools::Rectangle(Point(lX0, lY0), Size(lOutlineW, lOutlineH))));
+ rRenderContext.SetFillColor(COL_LIGHTGRAYBLUE);
+ const sal_Int32 nRows = std::min<sal_Int32>(2, m_aItem.m_nRows);
+ const sal_Int32 nCols = std::min<sal_Int32>(2, m_aItem.m_nCols);
+ for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
+ for (sal_Int32 nCol = 0; nCol < nCols; ++nCol)
+ rRenderContext.DrawRect(tools::Rectangle(Point(lX0 + ROUND(f * (m_aItem.m_lLeft + nCol * m_aItem.m_lHDist)),
+ lY0 + ROUND(f * (m_aItem.m_lUpper + nRow * m_aItem.m_lVDist))),
+ Size(ROUND(f * m_aItem.m_lWidth),
+ ROUND(f * m_aItem.m_lHeight))));
+ rRenderContext.SetClipRegion();
+
+ // annotation: left border
+ if (m_aItem.m_lLeft)
+ {
+ long lX = (lX0 + lX1) / 2;
+ DrawArrow(rRenderContext, Point(lX0, lY0 - 5), Point(lX1, lY0 - 5), false);
+ DrawArrow(rRenderContext, Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
+ rRenderContext.DrawText(Point(lX1 - m_lLeftWidth, lY0 - 10 - m_lXHeight), m_aLeftStr);
+ }
+
+ // annotation: upper border
+ if (m_aItem.m_lUpper)
+ {
+ DrawArrow(rRenderContext, Point(lX0 - 5, lY0), Point(lX0 - 5, lY1), false);
+ rRenderContext.DrawText(Point(lX0 - 10 - m_lUpperWidth, lY0 + ROUND(f*m_aItem.m_lUpper/2.0 - m_lXHeight/2.0)), m_aUpperStr);
+ }
+
+ // annotation: width and height
+ {
+ long lX = lX2 - m_lXWidth / 2 - m_lHeightWidth / 2;
+ long lY = lY1 + m_lXHeight;
+
+ rRenderContext.DrawLine(Point(lX1, lY), Point(lX2 - 1, lY));
+ rRenderContext.DrawLine(Point(lX, lY1), Point(lX, lY2 - 1));
+
+ rRenderContext.DrawText(Point(lX1 + m_lXWidth / 2, lY - m_lXHeight / 2), m_aWidthStr);
+ rRenderContext.DrawText(Point(lX - m_lHeightWidth / 2, lY2 - m_lXHeight - m_lXHeight / 2), m_aHeightStr);
+ }
+
+ // annotation: horizontal gap
+ if (m_aItem.m_nCols > 1)
+ {
+ long lX = (lX1 + lX3) / 2;
+ DrawArrow(rRenderContext, Point(lX1, lY0 - 5), Point(lX3, lY0 - 5), false);
+ DrawArrow(rRenderContext, Point(lX, lY0 - 10), Point(lX, lY0 - 5), true);
+ rRenderContext.DrawText(Point(lX - m_lHDistWidth / 2, lY0 - 10 - m_lXHeight), m_aHDistStr);
+ }
+
+ // annotation: vertical gap
+ if (m_aItem.m_nRows > 1)
+ {
+ DrawArrow(rRenderContext, Point(lX0 - 5, lY1), Point(lX0 - 5, lY3), false);
+ rRenderContext.DrawText(Point(lX0 - 10 - m_lVDistWidth, lY1 + ROUND(f*m_aItem.m_lVDist/2.0 - m_lXHeight/2.0)), m_aVDistStr);
+ }
+
+ // annotation: columns
+ {
+ long lY = lY0 + lOutlineH + 4;
+ DrawArrow(rRenderContext, Point(lX0, lY), Point(lX0 + lOutlineW - 1, lY), true);
+ rRenderContext.DrawText(Point((lX0 + lX0 + lOutlineW - 1) / 2 - m_lColsWidth / 2, lY + 5), m_aColsStr);
+ }
+
+ // annotation: lines
+ {
+ long lX = lX0 + lOutlineW + 4;
+ DrawArrow(rRenderContext, Point(lX, lY0), Point(lX, lY0 + lOutlineH - 1), true);
+ rRenderContext.DrawText(Point(lX + 5, (lY0 + lY0 + lOutlineH - 1 - m_lXHeight / 2) / 2), m_aRowsStr);
+ }
+}
+
+void SwLabPreview::UpdateItem(const SwLabItem& rItem)
+{
+ m_aItem = rItem;
+ Invalidate();
+}
+
+SwLabFormatPage::SwLabFormatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/labelformatpage.ui", "LabelFormatPage", &rSet)
+ , aPreviewIdle("SwLabFormatPage Preview")
+ , aItem(static_cast<const SwLabItem&>( rSet.Get(FN_LABEL) ))
+ , bModified(false)
+ , m_xMakeFI(m_xBuilder->weld_label("make"))
+ , m_xTypeFI(m_xBuilder->weld_label("type"))
+ , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview))
+ , m_xHDistField(m_xBuilder->weld_metric_spin_button("hori", FieldUnit::CM))
+ , m_xVDistField(m_xBuilder->weld_metric_spin_button("vert", FieldUnit::CM))
+ , m_xWidthField(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM))
+ , m_xHeightField(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM))
+ , m_xLeftField(m_xBuilder->weld_metric_spin_button("left", FieldUnit::CM))
+ , m_xUpperField(m_xBuilder->weld_metric_spin_button("top", FieldUnit::CM))
+ , m_xColsField(m_xBuilder->weld_spin_button("cols"))
+ , m_xRowsField(m_xBuilder->weld_spin_button("rows"))
+ , m_xPWidthField(m_xBuilder->weld_metric_spin_button("pagewidth", FieldUnit::CM))
+ , m_xPHeightField(m_xBuilder->weld_metric_spin_button("pageheight", FieldUnit::CM))
+ , m_xSavePB(m_xBuilder->weld_button("save"))
+{
+ SetExchangeSupport();
+
+ // Metrics
+ FieldUnit aMetric = ::GetDfltMetric(false);
+ ::SetFieldUnit(*m_xHDistField, aMetric);
+ ::SetFieldUnit(*m_xVDistField , aMetric);
+ ::SetFieldUnit(*m_xWidthField , aMetric);
+ ::SetFieldUnit(*m_xHeightField, aMetric);
+ ::SetFieldUnit(*m_xLeftField , aMetric);
+ ::SetFieldUnit(*m_xUpperField , aMetric);
+ ::SetFieldUnit(*m_xPWidthField , aMetric);
+ ::SetFieldUnit(*m_xPHeightField, aMetric);
+
+ // Install handlers
+ Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwLabFormatPage, MetricModifyHdl);
+ m_xHDistField->connect_value_changed( aLk );
+ m_xVDistField->connect_value_changed( aLk );
+ m_xWidthField->connect_value_changed( aLk );
+ m_xHeightField->connect_value_changed( aLk );
+ m_xLeftField->connect_value_changed( aLk );
+ m_xUpperField->connect_value_changed( aLk );
+ m_xPWidthField->connect_value_changed( aLk );
+ m_xPHeightField->connect_value_changed( aLk );
+
+ m_xColsField->connect_value_changed(LINK(this, SwLabFormatPage, ModifyHdl));
+ m_xRowsField->connect_value_changed(LINK(this, SwLabFormatPage, ModifyHdl));
+
+ m_xSavePB->connect_clicked( LINK (this, SwLabFormatPage, SaveHdl));
+ // Set timer
+ aPreviewIdle.SetPriority(TaskPriority::LOWEST);
+ aPreviewIdle.SetInvokeHandler(LINK(this, SwLabFormatPage, PreviewHdl));
+}
+
+SwLabFormatPage::~SwLabFormatPage()
+{
+}
+
+// Modify-handler of MetricFields. start preview timer
+IMPL_LINK_NOARG(SwLabFormatPage, MetricModifyHdl, weld::MetricSpinButton&, void)
+{
+ bModified = true;
+ aPreviewIdle.Start();
+}
+
+IMPL_LINK_NOARG(SwLabFormatPage, ModifyHdl, weld::SpinButton&, void)
+{
+ bModified = true;
+ aPreviewIdle.Start();
+}
+
+// Invalidate preview
+IMPL_LINK_NOARG(SwLabFormatPage, PreviewHdl, Timer *, void)
+{
+ aPreviewIdle.Stop();
+ ChangeMinMax();
+ FillItem( aItem );
+ m_aPreview.UpdateItem(aItem);
+}
+
+void SwLabFormatPage::ChangeMinMax()
+{
+ long lMax = 31748; // 56 cm
+ long nMinSize = 10; // 0,1cm
+
+ // Min and Max
+
+ int nCols = m_xColsField->get_value(),
+ nRows = m_xRowsField->get_value();
+ long lLeft = static_cast< long >(getfldval(*m_xLeftField )),
+ lUpper = static_cast< long >(getfldval(*m_xUpperField)),
+ lHDist = static_cast< long >(getfldval(*m_xHDistField)),
+ lVDist = static_cast< long >(getfldval(*m_xVDistField)),
+ lWidth = static_cast< long >(getfldval(*m_xWidthField)),
+ lHeight = static_cast< long >(getfldval(*m_xHeightField)),
+ lMinPWidth = lLeft + (nCols - 1) * lHDist + lWidth,
+ lMinPHeight = lUpper + (nRows - 1) * lVDist + lHeight;
+
+ m_xHDistField->set_min(nMinSize, FieldUnit::CM);
+ m_xVDistField->set_min(nMinSize, FieldUnit::CM);
+
+ m_xHDistField->set_max(long(100) * ((lMax - lLeft ) / std::max(1L, static_cast<long>(nCols))), FieldUnit::TWIP);
+ m_xVDistField->set_max(long(100) * ((lMax - lUpper) / std::max(1L, static_cast<long>(nRows))), FieldUnit::TWIP);
+
+ m_xWidthField->set_min(nMinSize, FieldUnit::CM);
+ m_xHeightField->set_min(nMinSize, FieldUnit::CM);
+
+ m_xWidthField->set_max(long(100) * lHDist, FieldUnit::TWIP);
+ m_xHeightField->set_max(long(100) * lVDist, FieldUnit::TWIP);
+
+ m_xLeftField->set_max(long(100) * (lMax - nCols * lHDist), FieldUnit::TWIP);
+ m_xUpperField->set_max(long(100) * (lMax - nRows * lVDist), FieldUnit::TWIP);
+
+ m_xColsField->set_range(1, (lMax - lLeft ) / std::max(1L, lHDist));
+ m_xRowsField->set_range(1, (lMax - lUpper) / std::max(1L, lVDist));
+
+ m_xPWidthField->set_range(long(100) * lMinPWidth, long(100) * lMax, FieldUnit::TWIP);
+ m_xPHeightField->set_range(long(100) * lMinPHeight, long(100) * lMax, FieldUnit::TWIP);
+}
+
+std::unique_ptr<SfxTabPage> SwLabFormatPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwLabFormatPage>(pPage, pController, *rSet);
+}
+
+void SwLabFormatPage::ActivatePage(const SfxItemSet& rSet)
+{
+ SfxItemSet aSet(rSet);
+ Reset(&aSet);
+}
+
+DeactivateRC SwLabFormatPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if (_pSet)
+ FillItemSet(_pSet);
+
+ return DeactivateRC::LeavePage;
+}
+
+void SwLabFormatPage::FillItem(SwLabItem& rItem)
+{
+ if (!bModified)
+ return;
+
+ rItem.m_aMake = rItem.m_aType = SwResId(STR_CUSTOM_LABEL);
+
+ SwLabRec& rRec = *GetParentSwLabDlg()->Recs()[0];
+ rItem.m_lHDist = rRec.m_nHDist = static_cast< long >(getfldval(*m_xHDistField ));
+ rItem.m_lVDist = rRec.m_nVDist = static_cast< long >(getfldval(*m_xVDistField ));
+ rItem.m_lWidth = rRec.m_nWidth = static_cast< long >(getfldval(*m_xWidthField ));
+ rItem.m_lHeight = rRec.m_nHeight = static_cast< long >(getfldval(*m_xHeightField));
+ rItem.m_lLeft = rRec.m_nLeft = static_cast< long >(getfldval(*m_xLeftField ));
+ rItem.m_lUpper = rRec.m_nUpper = static_cast< long >(getfldval(*m_xUpperField ));
+ rItem.m_nCols = rRec.m_nCols = static_cast< sal_Int32 >(m_xColsField->get_value());
+ rItem.m_nRows = rRec.m_nRows = static_cast< sal_Int32 >(m_xRowsField->get_value());
+ rItem.m_lPWidth = rRec.m_nPWidth = static_cast< long >(getfldval(*m_xPWidthField ));
+ rItem.m_lPHeight = rRec.m_nPHeight = static_cast< long >(getfldval(*m_xPHeightField));
+
+}
+
+bool SwLabFormatPage::FillItemSet(SfxItemSet* rSet)
+{
+ FillItem(aItem);
+ rSet->Put(aItem);
+
+ return true;
+}
+
+void SwLabFormatPage::Reset(const SfxItemSet* )
+{
+ // Initialise fields
+ GetParentSwLabDlg()->GetLabItem(aItem);
+
+ m_xHDistField->set_max(100 * aItem.m_lHDist , FieldUnit::TWIP);
+ m_xVDistField->set_max(100 * aItem.m_lVDist , FieldUnit::TWIP);
+ m_xWidthField->set_max(100 * aItem.m_lWidth , FieldUnit::TWIP);
+ m_xHeightField->set_max(100 * aItem.m_lHeight, FieldUnit::TWIP);
+ m_xLeftField->set_max(100 * aItem.m_lLeft , FieldUnit::TWIP);
+ m_xUpperField->set_max(100 * aItem.m_lUpper , FieldUnit::TWIP);
+ m_xPWidthField->set_max(100 * aItem.m_lPWidth , FieldUnit::TWIP);
+ m_xPHeightField->set_max(100 * aItem.m_lPHeight, FieldUnit::TWIP);
+
+ setfldval(*m_xHDistField, aItem.m_lHDist );
+ setfldval(*m_xVDistField , aItem.m_lVDist );
+ setfldval(*m_xWidthField , aItem.m_lWidth );
+ setfldval(*m_xHeightField, aItem.m_lHeight);
+ setfldval(*m_xLeftField , aItem.m_lLeft );
+ setfldval(*m_xUpperField , aItem.m_lUpper );
+ setfldval(*m_xPWidthField , aItem.m_lPWidth );
+ setfldval(*m_xPHeightField, aItem.m_lPHeight);
+
+ m_xColsField->set_max(aItem.m_nCols);
+ m_xRowsField->set_max(aItem.m_nRows);
+
+ m_xColsField->set_value(aItem.m_nCols);
+ m_xRowsField->set_value(aItem.m_nRows);
+ m_xMakeFI->set_label(aItem.m_aMake);
+ m_xTypeFI->set_label(aItem.m_aType);
+ PreviewHdl(nullptr);
+}
+
+IMPL_LINK_NOARG(SwLabFormatPage, SaveHdl, weld::Button&, void)
+{
+ SwLabRec aRec;
+ aRec.m_nHDist = static_cast< long >(getfldval(*m_xHDistField));
+ aRec.m_nVDist = static_cast< long >(getfldval(*m_xVDistField ));
+ aRec.m_nWidth = static_cast< long >(getfldval(*m_xWidthField ));
+ aRec.m_nHeight = static_cast< long >(getfldval(*m_xHeightField));
+ aRec.m_nLeft = static_cast< long >(getfldval(*m_xLeftField ));
+ aRec.m_nUpper = static_cast< long >(getfldval(*m_xUpperField ));
+ aRec.m_nCols = static_cast< sal_Int32 >(m_xColsField->get_value());
+ aRec.m_nRows = static_cast< sal_Int32 >(m_xRowsField->get_value());
+ aRec.m_nPWidth = static_cast< long >(getfldval(*m_xPWidthField ));
+ aRec.m_nPHeight = static_cast< long >(getfldval(*m_xPHeightField));
+ aRec.m_bCont = aItem.m_bCont;
+ SwSaveLabelDlg aSaveDlg(GetParentSwLabDlg(), aRec);
+ aSaveDlg.SetLabel(aItem.m_aLstMake, aItem.m_aLstType);
+ aSaveDlg.run();
+ if (aSaveDlg.GetLabel(aItem))
+ {
+ bModified = false;
+ const std::vector<OUString>& rMan = GetParentSwLabDlg()->GetLabelsConfig().GetManufacturers();
+ std::vector<OUString>& rMakes(GetParentSwLabDlg()->Makes());
+ if(rMakes.size() < rMan.size())
+ {
+ rMakes = rMan;
+ }
+ m_xMakeFI->set_label(aItem.m_aMake);
+ m_xTypeFI->set_label(aItem.m_aType);
+ }
+}
+
+SwSaveLabelDlg::SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec)
+ : GenericDialogController(pParent->getDialog(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog")
+ , bSuccess(false)
+ , m_pLabDialog(pParent)
+ , rLabRec(rRec)
+ , m_xMakeCB(m_xBuilder->weld_combo_box("brand"))
+ , m_xTypeED(m_xBuilder->weld_entry("type"))
+ , m_xOKPB(m_xBuilder->weld_button("ok"))
+{
+ m_xOKPB->connect_clicked(LINK(this, SwSaveLabelDlg, OkHdl));
+ m_xMakeCB->connect_changed(LINK(this, SwSaveLabelDlg, ModifyComboHdl));
+ m_xTypeED->connect_changed(LINK(this, SwSaveLabelDlg, ModifyEntryHdl));
+
+ SwLabelConfig& rCfg = m_pLabDialog->GetLabelsConfig();
+ const std::vector<OUString>& rMan = rCfg.GetManufacturers();
+ for (const auto & i : rMan)
+ {
+ m_xMakeCB->append_text(i);
+ }
+}
+
+SwSaveLabelDlg::~SwSaveLabelDlg()
+{
+}
+
+IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl, weld::Button&, void)
+{
+ SwLabelConfig& rCfg = m_pLabDialog->GetLabelsConfig();
+ OUString sMake(m_xMakeCB->get_active_text());
+ OUString sType(m_xTypeED->get_text());
+ if(rCfg.HasLabel(sMake, sType))
+ {
+ if ( rCfg.IsPredefinedLabel(sMake, sType) )
+ {
+ SAL_WARN( "sw.envelp", "label is predefined and cannot be overwritten" );
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/swriter/ui/cannotsavelabeldialog.ui"));
+ std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("CannotSaveLabelDialog"));
+ xBox->run();
+ return;
+ }
+
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/swriter/ui/querysavelabeldialog.ui"));
+ std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QuerySaveLabelDialog"));
+ xQuery->set_primary_text(xQuery->get_primary_text().
+ replaceAll("%1", sMake).replaceAll("%2", sType));
+ xQuery->set_secondary_text(xQuery->get_secondary_text().
+ replaceAll("%1", sMake).replaceAll("%2", sType));
+
+ if (RET_YES != xQuery->run())
+ return;
+ }
+ rLabRec.m_aType = sType;
+ rCfg.SaveLabel(sMake, sType, rLabRec);
+ bSuccess = true;
+ m_xDialog->response(RET_OK);
+}
+
+void SwSaveLabelDlg::Modify()
+{
+ m_xOKPB->set_sensitive(!m_xMakeCB->get_active_text().isEmpty() && !m_xTypeED->get_text().isEmpty());
+}
+
+IMPL_LINK_NOARG(SwSaveLabelDlg, ModifyComboHdl, weld::ComboBox&, void)
+{
+ Modify();
+}
+
+IMPL_LINK_NOARG(SwSaveLabelDlg, ModifyEntryHdl, weld::Entry&, void)
+{
+ Modify();
+}
+
+bool SwSaveLabelDlg::GetLabel(SwLabItem& rItem)
+{
+ if(bSuccess)
+ {
+ rItem.m_aMake = m_xMakeCB->get_active_text();
+ rItem.m_aType = m_xTypeED->get_text();
+ rItem.m_lHDist = rLabRec.m_nHDist;
+ rItem.m_lVDist = rLabRec.m_nVDist;
+ rItem.m_lWidth = rLabRec.m_nWidth;
+ rItem.m_lHeight = rLabRec.m_nHeight;
+ rItem.m_lLeft = rLabRec.m_nLeft;
+ rItem.m_lUpper = rLabRec.m_nUpper;
+ rItem.m_nCols = rLabRec.m_nCols;
+ rItem.m_nRows = rLabRec.m_nRows;
+ rItem.m_lPWidth = rLabRec.m_nPWidth;
+ rItem.m_lPHeight = rLabRec.m_nPHeight;
+ }
+ return bSuccess;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx
new file mode 100644
index 000000000..8e6d6a1a2
--- /dev/null
+++ b/sw/source/ui/envelp/labfmt.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_LABFMT_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_LABFMT_HXX
+
+#include <labimg.hxx>
+#include <label.hxx>
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/idle.hxx>
+#include <vcl/customweld.hxx>
+#include <vcl/weld.hxx>
+
+class SwLabFormatPage;
+
+class SwLabPreview : public weld::CustomWidgetController
+{
+ Color m_aGrayColor;
+
+ OUString m_aHDistStr;
+ OUString m_aVDistStr;
+ OUString m_aWidthStr;
+ OUString m_aHeightStr;
+ OUString m_aLeftStr;
+ OUString m_aUpperStr;
+ OUString m_aColsStr;
+ OUString m_aRowsStr;
+
+ long m_lHDistWidth;
+ long m_lVDistWidth;
+ long m_lHeightWidth;
+ long m_lLeftWidth;
+ long m_lUpperWidth;
+ long m_lColsWidth;
+
+ long m_lXWidth;
+ long m_lXHeight;
+
+ SwLabItem m_aItem;
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+
+public:
+
+ SwLabPreview();
+
+ void UpdateItem(const SwLabItem& rItem);
+};
+
+class SwLabFormatPage : public SfxTabPage
+{
+ Idle aPreviewIdle;
+ SwLabItem aItem;
+ bool bModified;
+
+ SwLabPreview m_aPreview;
+
+ std::unique_ptr<weld::Label> m_xMakeFI;
+ std::unique_ptr<weld::Label> m_xTypeFI;
+ std::unique_ptr<weld::CustomWeld> m_xPreview;
+ std::unique_ptr<weld::MetricSpinButton> m_xHDistField;
+ std::unique_ptr<weld::MetricSpinButton> m_xVDistField;
+ std::unique_ptr<weld::MetricSpinButton> m_xWidthField;
+ std::unique_ptr<weld::MetricSpinButton> m_xHeightField;
+ std::unique_ptr<weld::MetricSpinButton> m_xLeftField;
+ std::unique_ptr<weld::MetricSpinButton> m_xUpperField;
+ std::unique_ptr<weld::SpinButton> m_xColsField;
+ std::unique_ptr<weld::SpinButton> m_xRowsField;
+ std::unique_ptr<weld::MetricSpinButton> m_xPWidthField;
+ std::unique_ptr<weld::MetricSpinButton> m_xPHeightField;
+ std::unique_ptr<weld::Button> m_xSavePB;
+
+
+ DECL_LINK( ModifyHdl, weld::SpinButton&, void );
+ DECL_LINK( MetricModifyHdl, weld::MetricSpinButton&, void );
+ DECL_LINK( PreviewHdl, Timer *, void );
+ DECL_LINK( SaveHdl, weld::Button&, void );
+
+ void ChangeMinMax();
+
+public:
+ SwLabFormatPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ virtual ~SwLabFormatPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ void FillItem(SwLabItem& rItem);
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+
+ SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());}
+};
+
+class SwSaveLabelDlg : public weld::GenericDialogController
+{
+ bool bSuccess;
+ SwLabDlg* m_pLabDialog;
+ SwLabRec& rLabRec;
+
+ std::unique_ptr<weld::ComboBox> m_xMakeCB;
+ std::unique_ptr<weld::Entry> m_xTypeED;
+ std::unique_ptr<weld::Button> m_xOKPB;
+
+ DECL_LINK(OkHdl, weld::Button&, void);
+ DECL_LINK(ModifyEntryHdl, weld::Entry&, void);
+ DECL_LINK(ModifyComboHdl, weld::ComboBox&, void);
+
+ void Modify();
+
+public:
+ SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec);
+ virtual ~SwSaveLabelDlg() override;
+
+ void SetLabel(const OUString& rMake, const OUString& rType)
+ {
+ m_xMakeCB->set_entry_text(rMake);
+ m_xTypeED->set_text(rType);
+ }
+ bool GetLabel(SwLabItem& rItem);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
new file mode 100644
index 000000000..edede9718
--- /dev/null
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <osl/diagnose.h>
+#include <svtools/prnsetup.hxx>
+#include <unotools/cmdoptions.hxx>
+#include <vcl/print.hxx>
+#include <label.hxx>
+#include "labprt.hxx"
+#include <labimg.hxx>
+
+SwLabPrtPage::SwLabPrtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/swriter/ui/labeloptionspage.ui", "LabelOptionsPage", &rSet)
+ , pPrinter(nullptr)
+ , m_xPageButton(m_xBuilder->weld_radio_button("entirepage"))
+ , m_xSingleButton(m_xBuilder->weld_radio_button("singlelabel"))
+ , m_xSingleGrid(m_xBuilder->weld_widget("singlegrid"))
+ , m_xPrinterFrame(m_xBuilder->weld_widget("printerframe"))
+ , m_xColField(m_xBuilder->weld_spin_button("cols"))
+ , m_xRowField(m_xBuilder->weld_spin_button("rows"))
+ , m_xSynchronCB(m_xBuilder->weld_check_button("synchronize"))
+ , m_xPrinterInfo(m_xBuilder->weld_label("printername"))
+ , m_xPrtSetup(m_xBuilder->weld_button("setup"))
+{
+ SetExchangeSupport();
+
+ // Install handlers
+ Link<weld::Button&,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
+ m_xPageButton->connect_clicked( aLk );
+ m_xSingleButton->connect_clicked( aLk );
+ m_xPrtSetup->connect_clicked( aLk );
+
+ SvtCommandOptions aCmdOpts;
+ if (aCmdOpts.Lookup(SvtCommandOptions::CMDOPTION_DISABLED, "Print"))
+ {
+ m_xPrinterFrame->hide();
+ }
+}
+
+SwLabPrtPage::~SwLabPrtPage()
+{
+ pPrinter.disposeAndClear();
+}
+
+IMPL_LINK( SwLabPrtPage, CountHdl, weld::Button&, rButton, void )
+{
+ if (&rButton == m_xPrtSetup.get())
+ {
+ // Call printer setup
+ if (!pPrinter)
+ pPrinter = VclPtr<Printer>::Create();
+
+ PrinterSetupDialog aDlg(GetFrameWeld());
+ aDlg.SetPrinter(pPrinter);
+ aDlg.run();
+ rButton.grab_focus();
+ m_xPrinterInfo->set_label(pPrinter->GetName());
+ return;
+ }
+ const bool bEnable = &rButton == m_xSingleButton.get();
+ m_xSingleGrid->set_sensitive(bEnable);
+ m_xSynchronCB->set_sensitive(!bEnable);
+
+ OSL_ENSURE(!bEnable || &rButton == m_xPageButton.get(), "NewButton?" );
+ if ( bEnable )
+ {
+ m_xColField->grab_focus();
+ }
+}
+
+std::unique_ptr<SfxTabPage> SwLabPrtPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
+{
+ return std::make_unique<SwLabPrtPage>(pPage, pController, *rSet );
+}
+
+void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
+{
+ Reset(&rSet);
+}
+
+DeactivateRC SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
+{
+ if ( _pSet )
+ FillItemSet(_pSet);
+
+ return DeactivateRC::LeavePage;
+}
+
+void SwLabPrtPage::FillItem(SwLabItem& rItem)
+{
+ rItem.m_bPage = m_xPageButton->get_active();
+ rItem.m_nCol = m_xColField->get_value();
+ rItem.m_nRow = m_xRowField->get_value();
+ rItem.m_bSynchron = m_xSynchronCB->get_active() && m_xSynchronCB->get_sensitive();
+}
+
+bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet)
+{
+ SwLabItem aItem;
+ GetParentSwLabDlg()->GetLabItem(aItem);
+ FillItem(aItem);
+ rSet->Put(aItem);
+
+ return true;
+}
+
+void SwLabPrtPage::Reset(const SfxItemSet* )
+{
+ SwLabItem aItem;
+ GetParentSwLabDlg()->GetLabItem(aItem);
+
+ m_xColField->set_value(aItem.m_nCol);
+ m_xRowField->set_value(aItem.m_nRow);
+
+ if (aItem.m_bPage)
+ {
+ m_xPageButton->set_active(true);
+ CountHdl(*m_xPageButton);
+ }
+ else
+ {
+ CountHdl(*m_xSingleButton);
+ m_xSingleButton->set_active(true);
+ }
+
+ if (pPrinter)
+ {
+ // show printer
+ m_xPrinterInfo->set_label(pPrinter->GetName());
+ }
+ else
+ m_xPrinterInfo->set_label(Printer::GetDefaultPrinterName());
+
+ m_xColField->set_max(aItem.m_nCols);
+ m_xRowField->set_max(aItem.m_nRows);
+
+ m_xSynchronCB->set_active(aItem.m_bSynchron);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labprt.hxx b/sw/source/ui/envelp/labprt.hxx
new file mode 100644
index 000000000..c69d44ea4
--- /dev/null
+++ b/sw/source/ui/envelp/labprt.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_LABPRT_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_LABPRT_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <label.hxx>
+
+class SwLabDlg;
+class SwLabItem;
+
+class SwLabPrtPage : public SfxTabPage
+{
+ VclPtr<Printer> pPrinter; // for the shaft setting - unfortunately
+
+ std::unique_ptr<weld::RadioButton> m_xPageButton;
+ std::unique_ptr<weld::RadioButton> m_xSingleButton;
+ std::unique_ptr<weld::Widget> m_xSingleGrid;
+ std::unique_ptr<weld::Widget> m_xPrinterFrame;
+ std::unique_ptr<weld::SpinButton> m_xColField;
+ std::unique_ptr<weld::SpinButton> m_xRowField;
+ std::unique_ptr<weld::CheckButton> m_xSynchronCB;
+ std::unique_ptr<weld::Label> m_xPrinterInfo;
+ std::unique_ptr<weld::Button> m_xPrtSetup;
+
+ DECL_LINK( CountHdl, weld::Button&, void );
+
+ SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());}
+
+public:
+ SwLabPrtPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ virtual ~SwLabPrtPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ void FillItem(SwLabItem& rItem);
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+ Printer* GetPrt() { return pPrinter; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
new file mode 100644
index 000000000..972f7d04a
--- /dev/null
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -0,0 +1,616 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
+#include <tools/urlobj.hxx>
+#include <svl/urihelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <IDocumentDeviceAccess.hxx>
+#include <printdata.hxx>
+#include <wrtsh.hxx>
+#include <dbmgr.hxx>
+#include <swmodule.hxx>
+#include <modcfg.hxx>
+#include <mailmergehelper.hxx>
+#include <mailmrge.hxx>
+#include <sfx2/docfile.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <com/sun/star/container/XContainerQuery.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/frame/Frame.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::ui::dialogs;
+
+struct SwMailMergeDlg_Impl {
+ uno::Reference<runtime::XFormController> xFController;
+ uno::Reference<XSelectionChangeListener> xChgLstnr;
+ uno::Reference<XSelectionSupplier> xSelSupp;
+};
+
+class SwXSelChgLstnr_Impl : public cppu::WeakImplHelper
+ <
+ view::XSelectionChangeListener
+ >
+{
+ SwMailMergeDlg& rParent;
+public:
+ explicit SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg);
+
+ virtual void SAL_CALL selectionChanged( const EventObject& aEvent ) override;
+ virtual void SAL_CALL disposing( const EventObject& Source ) override;
+};
+
+SwXSelChgLstnr_Impl::SwXSelChgLstnr_Impl(SwMailMergeDlg& rParentDlg) :
+ rParent(rParentDlg)
+{}
+
+void SwXSelChgLstnr_Impl::selectionChanged( const EventObject& )
+{
+ //call the parent to enable selection mode
+ Sequence <Any> aSelection;
+ if(rParent.pImpl->xSelSupp.is())
+ rParent.pImpl->xSelSupp->getSelection() >>= aSelection;
+
+ bool bEnable = aSelection.hasElements();
+ rParent.m_xMarkedRB->set_sensitive(bEnable);
+ if(bEnable)
+ rParent.m_xMarkedRB->set_active(true);
+ else if(rParent.m_xMarkedRB->get_active()) {
+ rParent.m_xAllRB->set_active(true);
+ rParent.m_aSelection.realloc(0);
+ }
+}
+
+void SwXSelChgLstnr_Impl::disposing( const EventObject& )
+{
+ OSL_FAIL("disposing");
+}
+
+SwMailMergeDlg::SwMailMergeDlg(weld::Window* pParent, SwWrtShell& rShell,
+ const OUString& rSourceName,
+ const OUString& rTableName,
+ sal_Int32 nCommandType,
+ const uno::Reference< XConnection>& _xConnection,
+ Sequence< Any > const * pSelection)
+ : SfxDialogController(pParent, "modules/swriter/ui/mailmerge.ui", "MailmergeDialog")
+ , pImpl(new SwMailMergeDlg_Impl)
+ , rSh(rShell)
+ , nMergeType(DBMGR_MERGE_EMAIL)
+ , m_xBeamerWin(m_xBuilder->weld_container("beamer"))
+ , m_xAllRB(m_xBuilder->weld_radio_button("all"))
+ , m_xMarkedRB(m_xBuilder->weld_radio_button("selected"))
+ , m_xFromRB(m_xBuilder->weld_radio_button("rbfrom"))
+ , m_xFromNF(m_xBuilder->weld_spin_button("from"))
+ , m_xToNF(m_xBuilder->weld_spin_button("to"))
+ , m_xPrinterRB(m_xBuilder->weld_radio_button("printer"))
+ , m_xMailingRB(m_xBuilder->weld_radio_button("electronic"))
+ , m_xFileRB(m_xBuilder->weld_radio_button("file"))
+ , m_xSingleJobsCB(m_xBuilder->weld_check_button("singlejobs"))
+ , m_xPasswordCB(m_xBuilder->weld_check_button("passwd-check"))
+ , m_xSaveMergedDocumentFT(m_xBuilder->weld_label("savemergeddoclabel"))
+ , m_xSaveSingleDocRB(m_xBuilder->weld_radio_button("singledocument"))
+ , m_xSaveIndividualRB(m_xBuilder->weld_radio_button("individualdocuments"))
+ , m_xGenerateFromDataBaseCB(m_xBuilder->weld_check_button("generate"))
+ , m_xColumnFT(m_xBuilder->weld_label("fieldlabel"))
+ , m_xColumnLB(m_xBuilder->weld_combo_box("field"))
+ , m_xPasswordFT(m_xBuilder->weld_label("passwd-label"))
+ , m_xPasswordLB(m_xBuilder->weld_combo_box("passwd-combobox"))
+ , m_xPathFT(m_xBuilder->weld_label("pathlabel"))
+ , m_xPathED(m_xBuilder->weld_entry("path"))
+ , m_xPathPB(m_xBuilder->weld_button("pathpb"))
+ , m_xFilterFT(m_xBuilder->weld_label("fileformatlabel"))
+ , m_xFilterLB(m_xBuilder->weld_combo_box("fileformat"))
+ , m_xAddressFieldLB(m_xBuilder->weld_combo_box("address"))
+ , m_xSubjectFT(m_xBuilder->weld_label("subjectlabel"))
+ , m_xSubjectED(m_xBuilder->weld_entry("subject"))
+ , m_xFormatFT(m_xBuilder->weld_label("mailformatlabel"))
+ , m_xAttachFT(m_xBuilder->weld_label("attachmentslabel"))
+ , m_xAttachED(m_xBuilder->weld_entry("attachments"))
+ , m_xAttachPB(m_xBuilder->weld_button("attach"))
+ , m_xFormatHtmlCB(m_xBuilder->weld_check_button("html"))
+ , m_xFormatRtfCB(m_xBuilder->weld_check_button("rtf"))
+ , m_xFormatSwCB(m_xBuilder->weld_check_button("swriter"))
+ , m_xOkBTN(m_xBuilder->weld_button("ok"))
+{
+ m_xSingleJobsCB->hide(); // not supported in since cws printerpullpages anymore
+ //task #97066# mailing of form letters is currently not supported
+ m_xMailingRB->hide();
+ m_xSubjectFT->hide();
+ m_xSubjectED->hide();
+ m_xFormatFT->hide();
+ m_xFormatSwCB->hide();
+ m_xFormatHtmlCB->hide();
+ m_xFormatRtfCB->hide();
+ m_xAttachFT->hide();
+ m_xAttachED->hide();
+ m_xAttachPB->hide();
+ m_xPasswordCB->hide();
+ m_xPasswordFT->hide();
+ m_xPasswordLB->hide();
+
+ uno::Reference< lang::XMultiServiceFactory > xMSF = comphelper::getProcessServiceFactory();
+ if(pSelection) {
+ m_aSelection = *pSelection;
+ m_xBeamerWin->hide();
+ } else {
+ try {
+ // create a frame wrapper for myself
+ m_xFrame = frame::Frame::create( comphelper::getProcessComponentContext() );
+ m_xFrame->initialize(m_xBeamerWin->CreateChildFrame());
+ } catch (const Exception&) {
+ m_xFrame.clear();
+ }
+ if(m_xFrame.is()) {
+ URL aURL;
+ aURL.Complete = ".component:DB/DataSourceBrowser";
+ uno::Reference<XDispatch> xD = m_xFrame->queryDispatch(aURL,
+ "",
+ 0x0C);
+ if(xD.is()) {
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pProperties = aProperties.getArray();
+ pProperties[0].Name = "DataSourceName";
+ pProperties[0].Value <<= rSourceName;
+ pProperties[1].Name = "Command";
+ pProperties[1].Value <<= rTableName;
+ pProperties[2].Name = "CommandType";
+ pProperties[2].Value <<= nCommandType;
+ xD->dispatch(aURL, aProperties);
+ m_xBeamerWin->show();
+ }
+ uno::Reference<XController> xController = m_xFrame->getController();
+ pImpl->xFController.set(xController, UNO_QUERY);
+ if(pImpl->xFController.is()) {
+ uno::Reference< awt::XControl > xCtrl = pImpl->xFController->getCurrentControl( );
+ pImpl->xSelSupp.set(xCtrl, UNO_QUERY);
+ if(pImpl->xSelSupp.is()) {
+ pImpl->xChgLstnr = new SwXSelChgLstnr_Impl(*this);
+ pImpl->xSelSupp->addSelectionChangeListener( pImpl->xChgLstnr );
+ }
+ }
+ }
+ }
+
+ pModOpt = SW_MOD()->GetModuleConfig();
+
+ MailTextFormats nMailingMode(pModOpt->GetMailingFormats());
+ m_xFormatSwCB->set_active(bool(nMailingMode & MailTextFormats::OFFICE));
+ m_xFormatHtmlCB->set_active(bool(nMailingMode & MailTextFormats::HTML));
+ m_xFormatRtfCB->set_active(bool(nMailingMode & MailTextFormats::RTF));
+
+ m_xAllRB->set_active(true);
+
+ // Install handlers
+ m_xOkBTN->connect_clicked(LINK(this, SwMailMergeDlg, ButtonHdl));
+
+ m_xPathPB->connect_clicked(LINK(this, SwMailMergeDlg, InsertPathHdl));
+
+ m_xPrinterRB->connect_toggled(LINK(this, SwMailMergeDlg, OutputTypeHdl));
+ m_xFileRB->connect_toggled(LINK(this, SwMailMergeDlg, OutputTypeHdl));
+
+ //#i63267# printing might be disabled
+ bool bIsPrintable = !Application::GetSettings().GetMiscSettings().GetDisablePrinting();
+ m_xPrinterRB->set_sensitive(bIsPrintable);
+ OutputTypeHdl(bIsPrintable ? *m_xPrinterRB : *m_xFileRB);
+
+ m_xGenerateFromDataBaseCB->connect_toggled(LINK(this, SwMailMergeDlg, FilenameHdl));
+ bool bColumn = pModOpt->IsNameFromColumn();
+ if(bColumn)
+ m_xGenerateFromDataBaseCB->set_active(true);
+
+ FilenameHdl(*m_xGenerateFromDataBaseCB);
+ m_xSaveSingleDocRB->set_active(true);
+ m_xSaveSingleDocRB->connect_toggled(LINK(this, SwMailMergeDlg, SaveTypeHdl));
+ m_xSaveIndividualRB->connect_toggled(LINK(this, SwMailMergeDlg, SaveTypeHdl));
+ SaveTypeHdl(*m_xSaveSingleDocRB);
+
+ m_xFilterLB->connect_changed(LINK(this, SwMailMergeDlg, FileFormatHdl));
+
+ Link<weld::SpinButton&,void> aLk2 = LINK(this, SwMailMergeDlg, ModifyHdl);
+ m_xFromNF->connect_value_changed(aLk2);
+ m_xToNF->connect_value_changed(aLk2);
+ m_xFromNF->set_max(SAL_MAX_INT32);
+ m_xToNF->set_max(SAL_MAX_INT32);
+
+ SwDBManager* pDBManager = rSh.GetDBManager();
+ if(_xConnection.is())
+ SwDBManager::GetColumnNames(*m_xAddressFieldLB, _xConnection, rTableName);
+ else
+ pDBManager->GetColumnNames(*m_xAddressFieldLB, rSourceName, rTableName);
+ for(sal_Int32 nEntry = 0, nEntryCount = m_xAddressFieldLB->get_count(); nEntry < nEntryCount; ++nEntry)
+ {
+ m_xColumnLB->append_text(m_xAddressFieldLB->get_text(nEntry));
+ m_xPasswordLB->append_text(m_xAddressFieldLB->get_text(nEntry));
+ }
+
+ m_xAddressFieldLB->set_active_text("EMAIL");
+
+ OUString sPath(pModOpt->GetMailingPath());
+ if(sPath.isEmpty()) {
+ SvtPathOptions aPathOpt;
+ sPath = aPathOpt.GetWorkPath();
+ }
+ INetURLObject aURL(sPath);
+ if(aURL.GetProtocol() == INetProtocol::File)
+ m_xPathED->set_text(aURL.PathToFileName());
+ else
+ m_xPathED->set_text(aURL.GetFull());
+
+ if (!bColumn )
+ {
+ m_xColumnLB->set_active_text("NAME");
+ m_xPasswordLB->set_active_text("PASSWORD");
+ }
+ else
+ {
+ m_xColumnLB->set_active_text(pModOpt->GetNameFromColumn());
+ m_xPasswordLB->set_active_text(pModOpt->GetPasswordFromColumn());
+ }
+
+ if (m_xAddressFieldLB->get_active() == -1)
+ m_xAddressFieldLB->set_active(0);
+ if (m_xColumnLB->get_active() == -1)
+ m_xColumnLB->set_active(0);
+ if (m_xPasswordLB->get_active() == -1)
+ m_xPasswordLB->set_active(0);
+
+ const bool bEnable = m_aSelection.hasElements();
+ m_xMarkedRB->set_sensitive(bEnable);
+ if (bEnable)
+ m_xMarkedRB->set_active(true);
+ else {
+ m_xAllRB->set_active(true);
+ m_xMarkedRB->set_sensitive(false);
+ }
+ try {
+ uno::Reference< container::XNameContainer> xFilterFactory(
+ xMSF->createInstance("com.sun.star.document.FilterFactory"), UNO_QUERY_THROW);
+ uno::Reference< container::XContainerQuery > xQuery(xFilterFactory, UNO_QUERY_THROW);
+ const OUString sCommand("matchByDocumentService=com.sun.star.text.TextDocument:iflags="
+ + OUString::number(static_cast<sal_Int32>(SfxFilterFlags::EXPORT))
+ + ":eflags="
+ + OUString::number(static_cast<sal_Int32>(SfxFilterFlags::NOTINFILEDLG))
+ + ":default_first");
+ uno::Reference< container::XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand);
+ const OUString sName("Name");
+ sal_Int32 nODT = -1;
+ while(xList->hasMoreElements()) {
+ comphelper::SequenceAsHashMap aFilter(xList->nextElement());
+ const OUString sFilter = aFilter.getUnpackedValueOrDefault(sName, OUString());
+
+ uno::Any aProps = xFilterFactory->getByName(sFilter);
+ uno::Sequence< beans::PropertyValue > aFilterProperties;
+ aProps >>= aFilterProperties;
+ OUString sUIName2;
+ auto pProp = std::find_if(aFilterProperties.begin(), aFilterProperties.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "UIName"; });
+ if (pProp != aFilterProperties.end())
+ pProp->Value >>= sUIName2;
+ if( !sUIName2.isEmpty() ) {
+ if( sFilter == "writer8" )
+ nODT = m_xFilterLB->get_count();
+ m_xFilterLB->append(sFilter, sUIName2);
+ }
+ }
+ m_xFilterLB->set_active( nODT );
+ } catch (const uno::Exception&) {
+ }
+}
+
+SwMailMergeDlg::~SwMailMergeDlg()
+{
+ if(m_xFrame.is()) {
+ m_xFrame->setComponent(nullptr, nullptr);
+ m_xFrame->dispose();
+ }
+}
+
+IMPL_LINK_NOARG(SwMailMergeDlg, ButtonHdl, weld::Button&, void)
+{
+ if (ExecQryShell())
+ m_xDialog->response(RET_OK);
+}
+
+IMPL_LINK_NOARG(SwMailMergeDlg, OutputTypeHdl, weld::ToggleButton&, void)
+{
+ bool bPrint = m_xPrinterRB->get_active();
+ m_xSingleJobsCB->set_sensitive(bPrint);
+
+ m_xSaveMergedDocumentFT->set_sensitive( !bPrint );
+ m_xSaveSingleDocRB->set_sensitive( !bPrint );
+ m_xSaveIndividualRB->set_sensitive( !bPrint );
+
+ if( !bPrint ) {
+ SaveTypeHdl( m_xSaveSingleDocRB->get_active() ? *m_xSaveSingleDocRB : *m_xSaveIndividualRB );
+ } else {
+ m_xPathFT->set_sensitive(false);
+ m_xPathED->set_sensitive(false);
+ m_xPathPB->set_sensitive(false);
+ m_xColumnFT->set_sensitive(false);
+ m_xColumnLB->set_sensitive(false);
+ m_xFilterFT->set_sensitive(false);
+ m_xFilterLB->set_sensitive(false);
+ m_xGenerateFromDataBaseCB->set_sensitive(false);
+ m_xPasswordCB->set_sensitive( false );
+ m_xPasswordFT->set_sensitive( false );
+ m_xPasswordLB->set_sensitive( false );
+ }
+}
+
+IMPL_LINK_NOARG(SwMailMergeDlg, SaveTypeHdl, weld::ToggleButton&, void)
+{
+ bool bIndividual = m_xSaveIndividualRB->get_active();
+
+ m_xGenerateFromDataBaseCB->set_sensitive( bIndividual );
+ if( bIndividual )
+ {
+ FilenameHdl(*m_xGenerateFromDataBaseCB);
+ }
+ else
+ {
+ m_xColumnFT->set_sensitive(false);
+ m_xColumnLB->set_sensitive(false);
+ m_xPathFT->set_sensitive( false );
+ m_xPathED->set_sensitive( false );
+ m_xPathPB->set_sensitive( false );
+ m_xFilterFT->set_sensitive( false );
+ m_xFilterLB->set_sensitive( false );
+ m_xPasswordCB->set_sensitive( false );
+ m_xPasswordFT->set_sensitive( false );
+ m_xPasswordLB->set_sensitive( false );
+ }
+}
+
+IMPL_LINK( SwMailMergeDlg, FilenameHdl, weld::ToggleButton&, rBox, void )
+{
+ bool bEnable = rBox.get_active();
+ m_xColumnFT->set_sensitive( bEnable );
+ m_xColumnLB->set_sensitive(bEnable);
+ m_xPathFT->set_sensitive( bEnable );
+ m_xPathED->set_sensitive(bEnable);
+ m_xPathPB->set_sensitive( bEnable );
+ m_xFilterFT->set_sensitive( bEnable );
+ m_xFilterLB->set_sensitive( bEnable );
+
+ if(m_xFilterLB->get_active_id() == "writer_pdf_Export")
+ {
+ m_xPasswordCB->show();
+ m_xPasswordFT->show();
+ m_xPasswordLB->show();
+
+ m_xPasswordCB->set_sensitive( bEnable );
+ m_xPasswordFT->set_sensitive( bEnable );
+ m_xPasswordLB->set_sensitive( bEnable );
+ }
+}
+
+IMPL_LINK_NOARG( SwMailMergeDlg, FileFormatHdl, weld::ComboBox&, void )
+{
+ if(m_xFilterLB->get_active_id() == "writer_pdf_Export")
+ {
+ m_xPasswordCB->show();
+ m_xPasswordFT->show();
+ m_xPasswordLB->show();
+
+ m_xPasswordCB->set_sensitive( true );
+ m_xPasswordFT->set_sensitive( true );
+ m_xPasswordLB->set_sensitive( true );
+ }
+ else
+ {
+ m_xPasswordCB->hide();
+ m_xPasswordFT->hide();
+ m_xPasswordLB->hide();
+ }
+}
+
+IMPL_LINK_NOARG(SwMailMergeDlg, ModifyHdl, weld::SpinButton&, void)
+{
+ m_xFromRB->set_active(true);
+}
+
+bool SwMailMergeDlg::AskUserFilename() const
+{
+ return (m_xSaveSingleDocRB->get_active() || !m_xGenerateFromDataBaseCB->get_active());
+}
+
+OUString SwMailMergeDlg::GetURLfromPath() const
+{
+ SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
+ INetURLObject aAbs;
+ if( pMedium )
+ aAbs = pMedium->GetURLObject();
+ if( INetProtocol::NotValid == aAbs.GetProtocol() )
+ {
+ SvtPathOptions aPathOpt;
+ aAbs.SetURL( aPathOpt.GetWorkPath() );
+ }
+ return URIHelper::SmartRel2Abs(
+ aAbs, m_xPathED->get_text(), URIHelper::GetMaybeFileHdl());
+}
+
+bool SwMailMergeDlg::ExecQryShell()
+{
+ if(pImpl->xSelSupp.is()) {
+ pImpl->xSelSupp->removeSelectionChangeListener( pImpl->xChgLstnr );
+ }
+
+ if (m_xPrinterRB->get_active())
+ nMergeType = DBMGR_MERGE_PRINTER;
+ else {
+ nMergeType = DBMGR_MERGE_FILE;
+ pModOpt->SetMailingPath( GetURLfromPath() );
+ pModOpt->SetIsNameFromColumn(m_xGenerateFromDataBaseCB->get_active());
+ pModOpt->SetIsFileEncryptedFromColumn(m_xPasswordCB->get_active());
+
+ if (!AskUserFilename())
+ {
+ pModOpt->SetNameFromColumn(m_xColumnLB->get_active_text());
+ pModOpt->SetPasswordFromColumn(m_xPasswordLB->get_active_text());
+ if (m_xFilterLB->get_active() != -1)
+ m_sSaveFilter = m_xFilterLB->get_active_id();
+ m_sFilename = OUString();
+ } else {
+ //#i97667# reset column name - otherwise it's remembered from the last run
+ pModOpt->SetNameFromColumn(OUString());
+ pModOpt->SetPasswordFromColumn(OUString());
+ //start save as dialog
+ OUString sFilter;
+ m_sFilename = SwMailMergeHelper::CallSaveAsDialog(m_xDialog.get(), sFilter);
+ if (m_sFilename.isEmpty())
+ return false;
+ m_sSaveFilter = sFilter;
+ }
+ }
+
+ if (m_xFromRB->get_active()) { // Insert list
+ // Safe: the maximal value of the fields is limited
+ sal_Int32 nStart = m_xFromNF->get_value();
+ sal_Int32 nEnd = m_xToNF->get_value();
+
+ if (nEnd < nStart)
+ std::swap(nEnd, nStart);
+
+ m_aSelection.realloc(nEnd - nStart + 1);
+ Any* pSelection = m_aSelection.getArray();
+ for (sal_Int32 i = nStart; i <= nEnd; ++i, ++pSelection)
+ *pSelection <<= i;
+ } else if (m_xAllRB->get_active() )
+ m_aSelection.realloc(0); // Empty selection = insert all
+ else {
+ if(pImpl->xSelSupp.is()) {
+ //update selection
+ uno::Reference< XRowLocate > xRowLocate(GetResultSet(),UNO_QUERY);
+ uno::Reference< XResultSet > xRes(xRowLocate,UNO_QUERY);
+ pImpl->xSelSupp->getSelection() >>= m_aSelection;
+ if ( xRowLocate.is() ) {
+ for (Any& rRow : m_aSelection) {
+ if ( xRowLocate->moveToBookmark(rRow) )
+ rRow <<= xRes->getRow();
+ }
+ }
+ }
+ }
+ IDocumentDeviceAccess& rIDDA = rSh.getIDocumentDeviceAccess();
+ SwPrintData aPrtData( rIDDA.getPrintData() );
+ aPrtData.SetPrintSingleJobs(m_xSingleJobsCB->get_active());
+ rIDDA.setPrintData(aPrtData);
+
+ pModOpt->SetSinglePrintJob(m_xSingleJobsCB->get_active());
+
+ MailTextFormats nMailingMode = MailTextFormats::NONE;
+
+ if (m_xFormatSwCB->get_active())
+ nMailingMode |= MailTextFormats::OFFICE;
+ if (m_xFormatHtmlCB->get_active())
+ nMailingMode |= MailTextFormats::HTML;
+ if (m_xFormatRtfCB->get_active())
+ nMailingMode |= MailTextFormats::RTF;
+ pModOpt->SetMailingFormats(nMailingMode);
+ return true;
+}
+
+OUString SwMailMergeDlg::GetTargetURL() const
+{
+ if( AskUserFilename() )
+ return m_sFilename;
+ OUString sPath( pModOpt->GetMailingPath() );
+ if( sPath.isEmpty() ) {
+ SvtPathOptions aPathOpt;
+ sPath = aPathOpt.GetWorkPath();
+ }
+ if( !sPath.endsWith("/") )
+ sPath += "/";
+ return sPath;
+}
+
+IMPL_LINK_NOARG(SwMailMergeDlg, InsertPathHdl, weld::Button&, void)
+{
+ uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
+ uno::Reference < XFolderPicker2 > xFP = FolderPicker::create(xContext);
+ xFP->setDisplayDirectory( GetURLfromPath() );
+ if( xFP->execute() == RET_OK ) {
+ INetURLObject aURL(xFP->getDirectory());
+ if(aURL.GetProtocol() == INetProtocol::File)
+ m_xPathED->set_text(aURL.PathToFileName());
+ else
+ m_xPathED->set_text(aURL.GetFull());
+ }
+}
+
+uno::Reference<XResultSet> SwMailMergeDlg::GetResultSet() const
+{
+ uno::Reference< XResultSet > xResSetClone;
+ if ( pImpl->xFController.is() ) {
+ // we create a clone to do the task
+ uno::Reference< XResultSetAccess > xResultSetAccess( pImpl->xFController->getModel(),UNO_QUERY);
+ if ( xResultSetAccess.is() )
+ xResSetClone = xResultSetAccess->createResultSet();
+ }
+ return xResSetClone;
+}
+
+SwMailMergeCreateFromDlg::SwMailMergeCreateFromDlg(weld::Window* pParent)
+ : GenericDialogController(pParent, "modules/swriter/ui/mailmergedialog.ui", "MailMergeDialog")
+ , m_xThisDocRB(m_xBuilder->weld_radio_button("document"))
+{
+}
+
+SwMailMergeCreateFromDlg::~SwMailMergeCreateFromDlg()
+{
+}
+
+SwMailMergeFieldConnectionsDlg::SwMailMergeFieldConnectionsDlg(weld::Window* pParent)
+ : GenericDialogController(pParent, "modules/swriter/ui/mergeconnectdialog.ui", "MergeConnectDialog")
+ , m_xUseExistingRB(m_xBuilder->weld_radio_button("existing"))
+{
+}
+
+SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/swuilabimp.hxx b/sw/source/ui/envelp/swuilabimp.hxx
new file mode 100644
index 000000000..5634b4c2c
--- /dev/null
+++ b/sw/source/ui/envelp/swuilabimp.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_UI_ENVELP_SWUILABIMP_HXX
+#define INCLUDED_SW_SOURCE_UI_ENVELP_SWUILABIMP_HXX
+
+#include <label.hxx>
+#include <labimg.hxx>
+#include <labrec.hxx>
+#include <sfx2/tabdlg.hxx>
+
+class SwLabPage : public SfxTabPage
+{
+ SwDBManager* pDBManager;
+ OUString sActDBName;
+ SwLabItem aItem;
+
+ std::unique_ptr<weld::Widget> m_xAddressFrame;
+ std::unique_ptr<weld::CheckButton> m_xAddrBox;
+ std::unique_ptr<weld::TextView> m_xWritingEdit;
+ std::unique_ptr<weld::ComboBox> m_xDatabaseLB;
+ std::unique_ptr<weld::ComboBox> m_xTableLB;
+ std::unique_ptr<weld::Button> m_xInsertBT;
+ std::unique_ptr<weld::ComboBox> m_xDBFieldLB;
+ std::unique_ptr<weld::RadioButton> m_xContButton;
+ std::unique_ptr<weld::RadioButton> m_xSheetButton;
+ std::unique_ptr<weld::ComboBox> m_xMakeBox;
+ std::unique_ptr<weld::ComboBox> m_xTypeBox;
+ std::unique_ptr<weld::ComboBox> m_xHiddenSortTypeBox;
+ std::unique_ptr<weld::Label> m_xFormatInfo;
+
+ DECL_LINK(AddrHdl, weld::ToggleButton&, void);
+ DECL_LINK(DatabaseHdl, weld::ComboBox&, void );
+ DECL_LINK(FieldHdl, weld::Button&, void);
+ DECL_LINK(PageHdl, weld::ToggleButton&, void);
+ DECL_LINK(MakeHdl, weld::ComboBox&, void);
+ DECL_LINK(TypeHdl, weld::ComboBox&, void);
+
+ void DisplayFormat ();
+ SwLabRec* GetSelectedEntryPos();
+
+public:
+ SwLabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+
+ virtual ~SwLabPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ void FillItem(SwLabItem& rItem);
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+
+ SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());}
+
+ void SetToBusinessCard();
+
+ void InitDatabaseBox();
+ void SetDBManager(SwDBManager* pDBManager_) { pDBManager = pDBManager_; }
+ SwDBManager* GetDBManager() const { return pDBManager; }
+};
+
+class SwPrivateDataPage : public SfxTabPage
+{
+ std::unique_ptr<weld::Entry> m_xFirstNameED;
+ std::unique_ptr<weld::Entry> m_xNameED;
+ std::unique_ptr<weld::Entry> m_xShortCutED;
+ std::unique_ptr<weld::Entry> m_xFirstName2ED;
+ std::unique_ptr<weld::Entry> m_xName2ED;
+ std::unique_ptr<weld::Entry> m_xShortCut2ED;
+ std::unique_ptr<weld::Entry> m_xStreetED;
+ std::unique_ptr<weld::Entry> m_xZipED;
+ std::unique_ptr<weld::Entry> m_xCityED;
+ std::unique_ptr<weld::Entry> m_xCountryED;
+ std::unique_ptr<weld::Entry> m_xStateED;
+ std::unique_ptr<weld::Entry> m_xTitleED;
+ std::unique_ptr<weld::Entry> m_xProfessionED;
+ std::unique_ptr<weld::Entry> m_xPhoneED;
+ std::unique_ptr<weld::Entry> m_xMobilePhoneED;
+ std::unique_ptr<weld::Entry> m_xFaxED;
+ std::unique_ptr<weld::Entry> m_xHomePageED;
+ std::unique_ptr<weld::Entry> m_xMailED;
+
+public:
+ SwPrivateDataPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ virtual ~SwPrivateDataPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+};
+
+class SwBusinessDataPage : public SfxTabPage
+{
+ std::unique_ptr<weld::Entry> m_xCompanyED;
+ std::unique_ptr<weld::Entry> m_xCompanyExtED;
+ std::unique_ptr<weld::Entry> m_xSloganED;
+ std::unique_ptr<weld::Entry> m_xStreetED;
+ std::unique_ptr<weld::Entry> m_xZipED;
+ std::unique_ptr<weld::Entry> m_xCityED;
+ std::unique_ptr<weld::Entry> m_xCountryED;
+ std::unique_ptr<weld::Entry> m_xStateED;
+ std::unique_ptr<weld::Entry> m_xPositionED;
+ std::unique_ptr<weld::Entry> m_xPhoneED;
+ std::unique_ptr<weld::Entry> m_xMobilePhoneED;
+ std::unique_ptr<weld::Entry> m_xFaxED;
+ std::unique_ptr<weld::Entry> m_xHomePageED;
+ std::unique_ptr<weld::Entry> m_xMailED;
+
+public:
+ SwBusinessDataPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
+ virtual ~SwBusinessDataPage() override;
+
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
+
+ virtual void ActivatePage(const SfxItemSet& rSet) override;
+ virtual DeactivateRC DeactivatePage(SfxItemSet* pSet) override;
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */