summaryrefslogtreecommitdiffstats
path: root/sw/source/uibase/envelp
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/envelp')
-rw-r--r--sw/source/uibase/envelp/envimg.cxx334
-rw-r--r--sw/source/uibase/envelp/labelcfg.cxx333
-rw-r--r--sw/source/uibase/envelp/labimg.cxx463
-rw-r--r--sw/source/uibase/envelp/syncbtn.cxx87
4 files changed, 1217 insertions, 0 deletions
diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx
new file mode 100644
index 000000000..6f8494601
--- /dev/null
+++ b/sw/source/uibase/envelp/envimg.cxx
@@ -0,0 +1,334 @@
+/* -*- 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 <o3tl/any.hxx>
+#include <osl/diagnose.h>
+#include <editeng/paperinf.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <unotools/useroptions.hxx>
+#include <swmodule.hxx>
+#include <swtypes.hxx>
+#include <envimg.hxx>
+#include <strings.hrc>
+
+#include <cmdid.h>
+
+#include <unomid.h>
+
+#ifdef _WIN32
+#define NEXTLINE "\r\n"
+#else
+#define NEXTLINE "\n"
+#endif
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+
+
+SfxPoolItem* SwEnvItem::CreateDefault() { return new SwEnvItem; }
+
+OUString MakeSender()
+{
+ SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
+
+ const OUString sSenderToken(SwResId(STR_SENDER_TOKENS));
+ if (sSenderToken.isEmpty())
+ return OUString();
+
+ OUStringBuffer sRet;
+ sal_Int32 nSttPos = 0;
+ bool bLastLength = true;
+ do {
+ OUString sToken = sSenderToken.getToken( 0, ';', nSttPos );
+ if (sToken == "COMPANY")
+ {
+ sal_Int32 nOldLen = sRet.getLength();
+ sRet.append(rUserOpt.GetCompany());
+ bLastLength = sRet.getLength() != nOldLen;
+ }
+ else if (sToken == "CR")
+ {
+ if(bLastLength)
+ sRet.append(NEXTLINE);
+ bLastLength = true;
+ }
+ else if (sToken == "FIRSTNAME")
+ sRet.append(rUserOpt.GetFirstName());
+ else if (sToken == "LASTNAME")
+ sRet.append(rUserOpt.GetLastName());
+ else if (sToken == "ADDRESS")
+ sRet.append(rUserOpt.GetStreet());
+ else if (sToken == "COUNTRY")
+ sRet.append(rUserOpt.GetCountry());
+ else if (sToken == "POSTALCODE")
+ sRet.append(rUserOpt.GetZip());
+ else if (sToken == "CITY")
+ sRet.append(rUserOpt.GetCity());
+ else if (sToken == "STATEPROV")
+ sRet.append(rUserOpt.GetState());
+ else if (!sToken.isEmpty()) //spaces
+ sRet.append(sToken);
+ } while (nSttPos>=0);
+ return sRet.makeStringAndClear();
+}
+
+SwEnvItem::SwEnvItem() :
+ SfxPoolItem(FN_ENVELOP)
+{
+ m_bSend = true;
+ m_aSendText = MakeSender();
+ m_nSendFromLeft = 566; // 1 cm
+ m_nSendFromTop = 566; // 1 cm
+ Size aEnvSz = SvxPaperInfo::GetPaperSize(PAPER_ENV_C65);
+ m_nWidth = aEnvSz.Width();
+ m_nHeight = aEnvSz.Height();
+ m_eAlign = ENV_HOR_LEFT;
+ m_bPrintFromAbove = true;
+ m_nShiftRight = 0;
+ m_nShiftDown = 0;
+
+ m_nAddrFromLeft = std::max(m_nWidth, m_nHeight) / 2;
+ m_nAddrFromTop = std::min(m_nWidth, m_nHeight) / 2;
+}
+
+SwEnvItem& SwEnvItem::operator =(const SwEnvItem& rItem)
+{
+ m_aAddrText = rItem.m_aAddrText;
+ m_bSend = rItem.m_bSend;
+ m_aSendText = rItem.m_aSendText;
+ m_nSendFromLeft = rItem.m_nSendFromLeft;
+ m_nSendFromTop = rItem.m_nSendFromTop;
+ m_nAddrFromLeft = rItem.m_nAddrFromLeft;
+ m_nAddrFromTop = rItem.m_nAddrFromTop;
+ m_nWidth = rItem.m_nWidth;
+ m_nHeight = rItem.m_nHeight;
+ m_eAlign = rItem.m_eAlign;
+ m_bPrintFromAbove = rItem.m_bPrintFromAbove;
+ m_nShiftRight = rItem.m_nShiftRight;
+ m_nShiftDown = rItem.m_nShiftDown;
+ return *this;
+}
+
+bool SwEnvItem::operator ==(const SfxPoolItem& rItem) const
+{
+ const SwEnvItem& rEnv = static_cast<const SwEnvItem&>( rItem);
+
+ return m_aAddrText == rEnv.m_aAddrText &&
+ m_bSend == rEnv.m_bSend &&
+ m_aSendText == rEnv.m_aSendText &&
+ m_nSendFromLeft == rEnv.m_nSendFromLeft &&
+ m_nSendFromTop == rEnv.m_nSendFromTop &&
+ m_nAddrFromLeft == rEnv.m_nAddrFromLeft &&
+ m_nAddrFromTop == rEnv.m_nAddrFromTop &&
+ m_nWidth == rEnv.m_nWidth &&
+ m_nHeight == rEnv.m_nHeight &&
+ m_eAlign == rEnv.m_eAlign &&
+ m_bPrintFromAbove == rEnv.m_bPrintFromAbove &&
+ m_nShiftRight == rEnv.m_nShiftRight &&
+ m_nShiftDown == rEnv.m_nShiftDown;
+}
+
+SwEnvItem* SwEnvItem::Clone(SfxItemPool*) const
+{
+ return new SwEnvItem(*this);
+}
+
+SwEnvCfgItem::SwEnvCfgItem() :
+ ConfigItem("Office.Writer/Envelope")
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= m_aEnvItem.m_aAddrText; break;// "Inscription/Addressee",
+ case 1: pValues[nProp] >>= m_aEnvItem.m_aSendText; break;// "Inscription/Sender",
+ case 2: m_aEnvItem.m_bSend = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Inscription/UseSender",
+ case 3:
+ pValues[nProp] >>= m_aEnvItem.m_nAddrFromLeft;// "Format/AddresseeFromLeft",
+ m_aEnvItem.m_nAddrFromLeft = convertMm100ToTwip(m_aEnvItem.m_nAddrFromLeft);
+ break;
+ case 4:
+ pValues[nProp] >>= m_aEnvItem.m_nAddrFromTop; // "Format/AddresseeFromTop",
+ m_aEnvItem.m_nAddrFromTop = convertMm100ToTwip(m_aEnvItem.m_nAddrFromTop);
+ break;
+ case 5:
+ pValues[nProp] >>= m_aEnvItem.m_nSendFromLeft; // "Format/SenderFromLeft",
+ m_aEnvItem.m_nSendFromLeft = convertMm100ToTwip(m_aEnvItem.m_nSendFromLeft);
+ break;
+ case 6:
+ pValues[nProp] >>= m_aEnvItem.m_nSendFromTop;// "Format/SenderFromTop",
+ m_aEnvItem.m_nSendFromTop = convertMm100ToTwip(m_aEnvItem.m_nSendFromTop);
+ break;
+ case 7:
+ pValues[nProp] >>= m_aEnvItem.m_nWidth; // "Format/Width",
+ m_aEnvItem.m_nWidth = convertMm100ToTwip(m_aEnvItem.m_nWidth);
+ break;
+ case 8:
+ pValues[nProp] >>= m_aEnvItem.m_nHeight; // "Format/Height",
+ m_aEnvItem.m_nHeight = convertMm100ToTwip(m_aEnvItem.m_nHeight);
+ break;
+ case 9:
+ {
+ sal_Int32 nTemp = 0;
+ pValues[nProp] >>= nTemp; m_aEnvItem.m_eAlign = static_cast<SwEnvAlign>(nTemp); break;// "Print/Alignment",
+ }
+ case 10: m_aEnvItem.m_bPrintFromAbove = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Print/FromAbove",
+ case 11:
+ pValues[nProp] >>= m_aEnvItem.m_nShiftRight;
+ m_aEnvItem.m_nShiftRight = convertMm100ToTwip(m_aEnvItem.m_nShiftRight);// "Print/Right",
+ break;
+ case 12:
+ pValues[nProp] >>= m_aEnvItem.m_nShiftDown;
+ m_aEnvItem.m_nShiftDown = convertMm100ToTwip(m_aEnvItem.m_nShiftDown);
+ break;// "Print/Down"
+ }
+ }
+ }
+ }
+}
+
+SwEnvCfgItem::~SwEnvCfgItem()
+{
+}
+
+void SwEnvCfgItem::ImplCommit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= m_aEnvItem.m_aAddrText; break;// "Inscription/Addressee",
+ case 1: pValues[nProp] <<= m_aEnvItem.m_aSendText; break;// "Inscription/Sender",
+ case 2: pValues[nProp] <<= m_aEnvItem.m_bSend; break;// "Inscription/UseSender",
+ case 3: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nAddrFromLeft)) ; break;// "Format/AddresseeFromLeft",
+ case 4: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nAddrFromTop)) ; break;// "Format/AddresseeFromTop",
+ case 5: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nSendFromLeft)) ; break;// "Format/SenderFromLeft",
+ case 6: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nSendFromTop)) ; break;// "Format/SenderFromTop",
+ case 7: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nWidth)) ; break;// "Format/Width",
+ case 8: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nHeight)) ; break;// "Format/Height",
+ case 9: pValues[nProp] <<= sal_Int32(m_aEnvItem.m_eAlign); break;// "Print/Alignment",
+ case 10: pValues[nProp] <<= m_aEnvItem.m_bPrintFromAbove; break;// "Print/FromAbove",
+ case 11: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nShiftRight));break; // "Print/Right",
+ case 12: pValues[nProp] <<= static_cast <sal_Int32>(convertTwipToMm100(m_aEnvItem.m_nShiftDown)); break;// "Print/Down"
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+void SwEnvCfgItem::Notify( const css::uno::Sequence< OUString >& ) {}
+
+Sequence<OUString> SwEnvCfgItem::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Inscription/Addressee", // 0
+ "Inscription/Sender", // 1
+ "Inscription/UseSender", // 2
+ "Format/AddresseeFromLeft", // 3
+ "Format/AddresseeFromTop", // 4
+ "Format/SenderFromLeft", // 5
+ "Format/SenderFromTop", // 6
+ "Format/Width", // 7
+ "Format/Height", // 8
+ "Print/Alignment", // 9
+ "Print/FromAbove", // 10
+ "Print/Right", // 11
+ "Print/Down" // 12
+ };
+ const int nCount = 13;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+
+ for(int i = 0; i < nCount; i++)
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+
+ return aNames;
+}
+
+bool SwEnvItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
+{
+ bool bRet = true;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_ENV_ADDR_TEXT : rVal <<= m_aAddrText; break;
+ case MID_ENV_SEND : rVal <<= m_bSend; break;
+ case MID_SEND_TEXT : rVal <<= m_aSendText; break;
+ case MID_ENV_ADDR_FROM_LEFT : rVal <<= m_nAddrFromLeft; break;
+ case MID_ENV_ADDR_FROM_TOP : rVal <<= m_nAddrFromTop; break;
+ case MID_ENV_SEND_FROM_LEFT : rVal <<= m_nSendFromLeft; break;
+ case MID_ENV_SEND_FROM_TOP : rVal <<= m_nSendFromTop; break;
+ case MID_ENV_WIDTH : rVal <<= m_nWidth; break;
+ case MID_ENV_HEIGHT : rVal <<= m_nHeight; break;
+ case MID_ENV_ALIGN : rVal <<= static_cast<sal_Int16>(m_eAlign); break;
+ case MID_ENV_PRINT_FROM_ABOVE : rVal <<= m_bPrintFromAbove; break;
+ case MID_ENV_SHIFT_RIGHT : rVal <<= m_nShiftRight; break;
+ case MID_ENV_SHIFT_DOWN : rVal <<= m_nShiftDown; break;
+ default:
+ OSL_FAIL("Wrong memberId");
+ bRet = false;
+ }
+ return bRet;
+}
+
+bool SwEnvItem::PutValue(const Any& rVal, sal_uInt8 nMemberId)
+{
+ bool bRet = false;
+ switch(nMemberId & ~CONVERT_TWIPS)
+ {
+ case MID_ENV_ADDR_TEXT : bRet = (rVal >>= m_aAddrText); break;
+ case MID_ENV_SEND : bRet = (rVal >>= m_bSend); break;
+ case MID_SEND_TEXT : bRet = (rVal >>= m_aSendText); break;
+ case MID_ENV_ADDR_FROM_LEFT : bRet = (rVal >>= m_nAddrFromLeft); break;
+ case MID_ENV_ADDR_FROM_TOP : bRet = (rVal >>= m_nAddrFromTop); break;
+ case MID_ENV_SEND_FROM_LEFT : bRet = (rVal >>= m_nSendFromLeft); break;
+ case MID_ENV_SEND_FROM_TOP : bRet = (rVal >>= m_nSendFromTop); break;
+ case MID_ENV_WIDTH : bRet = (rVal >>= m_nWidth); break;
+ case MID_ENV_HEIGHT : bRet = (rVal >>= m_nHeight); break;
+ case MID_ENV_ALIGN :
+ {
+ sal_Int16 nTemp = 0;
+ bRet = (rVal >>= nTemp);
+ if (bRet)
+ m_eAlign = SwEnvAlign(nTemp);
+ break;
+ }
+ case MID_ENV_PRINT_FROM_ABOVE : bRet = (rVal >>= m_bPrintFromAbove); break;
+ case MID_ENV_SHIFT_RIGHT : bRet = (rVal >>= m_nShiftRight); break;
+ case MID_ENV_SHIFT_DOWN : bRet = (rVal >>= m_nShiftDown); break;
+ default:
+ OSL_FAIL("Wrong memberId");
+ }
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx
new file mode 100644
index 000000000..59c252be0
--- /dev/null
+++ b/sw/source/uibase/envelp/labelcfg.cxx
@@ -0,0 +1,333 @@
+/* -*- 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 <config_folders.h>
+
+#include <swtypes.hxx>
+#include <labelcfg.hxx>
+#include <rtl/bootstrap.hxx>
+#include <unotools/configpaths.hxx>
+#include <xmlreader/xmlreader.hxx>
+#include <comphelper/sequence.hxx>
+#include <osl/diagnose.h>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+static void lcl_assertEndingItem(xmlreader::XmlReader& reader)
+{
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ res = reader.nextItem(xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::Result::End);
+ (void) res;
+}
+
+static OUString lcl_getValue(xmlreader::XmlReader& reader,
+ const xmlreader::Span& span)
+{
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ res = reader.nextItem(xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::Result::Begin && name == span);
+ res = reader.nextItem(xmlreader::XmlReader::Text::Raw, &name, &nsId);
+ assert(res == xmlreader::XmlReader::Result::Text);
+ (void) res; (void) span;
+ OUString sTmp = name.convertFromUtf8();
+ lcl_assertEndingItem(reader);
+ return sTmp;
+}
+
+static Sequence<OUString> lcl_CreatePropertyNames(const OUString& rPrefix)
+{
+ Sequence<OUString> aProperties(2);
+ OUString* pProperties = aProperties.getArray();
+ std::fill(aProperties.begin(), aProperties.end(), rPrefix);
+
+ pProperties[ 0] += "Name";
+ pProperties[ 1] += "Measure";
+ return aProperties;
+}
+
+SwLabelConfig::SwLabelConfig() :
+ ConfigItem("Office.Labels/Manufacturer")
+{
+ OUString uri("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/labels/labels.xml");
+ rtl::Bootstrap::expandMacros(uri);
+ xmlreader::XmlReader reader(uri);
+ int nsId;
+ xmlreader::Span name;
+ xmlreader::XmlReader::Result res;
+ OUString sManufacturer;
+ OUString sName;
+ OUString sMeasure;
+
+ // fill m_aLabels and m_aManufacturers with the predefined labels
+ res = reader.nextItem(
+ xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ assert(
+ res == xmlreader::XmlReader::Result::Begin
+ && name == "manufacturers");
+ res = reader.nextItem(
+ xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ while (res != xmlreader::XmlReader::Result::End)
+ {
+ // Opening manufacturer
+ assert(
+ res == xmlreader::XmlReader::Result::Begin
+ && name == "manufacturer");
+ // Get the name
+ (void)reader.nextAttribute(&nsId, &name);
+ assert(
+ nsId == xmlreader::XmlReader::NAMESPACE_NONE
+ && name == "name");
+ sManufacturer = reader.getAttributeValue(false).convertFromUtf8();
+
+ for(;;) {
+ // Opening label or ending manufacturer
+ res = reader.nextItem(
+ xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ if (res == xmlreader::XmlReader::Result::End)
+ break;
+ assert(
+ res == xmlreader::XmlReader::Result::Begin
+ && name == "label");
+ // Get name value
+ sName = lcl_getValue(reader, xmlreader::Span("name"));
+ // Get measure value
+ sMeasure = lcl_getValue(reader, xmlreader::Span("measure"));
+ // Ending label mark
+ lcl_assertEndingItem(reader);
+ if ( m_aLabels.find( sManufacturer ) == m_aLabels.end() )
+ m_aManufacturers.push_back( sManufacturer );
+ m_aLabels[sManufacturer][sName].m_aMeasure = sMeasure;
+ m_aLabels[sManufacturer][sName].m_bPredefined = true;
+ }
+ // Get next manufacturer or end
+ res = reader.nextItem(
+ xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ };
+ res = reader.nextItem(
+ xmlreader::XmlReader::Text::NONE, &name, &nsId);
+ assert(res == xmlreader::XmlReader::Result::Done);
+
+ // add to m_aLabels and m_aManufacturers the custom labels
+ const Sequence<OUString>& rMan = GetNodeNames( OUString() );
+ for ( const OUString& rManufacturer : rMan )
+ {
+ const Sequence<OUString> aLabels = GetNodeNames( rManufacturer );
+ for( const OUString& rLabel : aLabels )
+ {
+ OUString sPrefix = rManufacturer + "/" + rLabel + "/";
+ Sequence<OUString> aPropNames = lcl_CreatePropertyNames( sPrefix );
+ Sequence<Any> aValues = GetProperties( aPropNames );
+ const Any* pValues = aValues.getConstArray();
+ if (aValues.getLength() >= 1)
+ if(pValues[0].hasValue())
+ pValues[0] >>= sName;
+ if (aValues.getLength() >= 2)
+ if(pValues[1].hasValue())
+ pValues[1] >>= sMeasure;
+ if ( m_aLabels.find( rManufacturer ) == m_aLabels.end() )
+ m_aManufacturers.push_back( rManufacturer );
+ m_aLabels[rManufacturer][sName].m_aMeasure = sMeasure;
+ m_aLabels[rManufacturer][sName].m_bPredefined = false;
+ }
+ }
+}
+
+SwLabelConfig::~SwLabelConfig()
+{
+}
+
+// the config item is not writable ?:
+void SwLabelConfig::ImplCommit() {}
+
+void SwLabelConfig::Notify( const css::uno::Sequence< OUString >& ) {}
+
+static std::unique_ptr<SwLabRec> lcl_CreateSwLabRec(const OUString& rType, const OUString& rMeasure, const OUString& rManufacturer)
+{
+ std::unique_ptr<SwLabRec> pNewRec(new SwLabRec);
+ pNewRec->m_aMake = rManufacturer;
+ pNewRec->m_nPWidth = 0;
+ pNewRec->m_nPHeight = 0;
+ pNewRec->m_aType = rType;
+ //all values are contained as colon-separated 1/100 mm values
+ //except for the continuous flag ('C'/'S') and nCols, nRows (sal_Int32)
+ sal_Int32 nTok{0};
+ sal_Int32 nIdx{rMeasure.isEmpty() ? -1 : 0};
+ while (nIdx>=0)
+ {
+ const OUString sToken(rMeasure.getToken(0, ';', nIdx));
+ int nVal = sToken.toInt32();
+ switch(nTok++)
+ {
+ case 0 : pNewRec->m_bCont = sToken[0] == 'C'; break;
+ case 1 : pNewRec->m_nHDist = convertMm100ToTwip(nVal); break;
+ case 2 : pNewRec->m_nVDist = convertMm100ToTwip(nVal); break;
+ case 3 : pNewRec->m_nWidth = convertMm100ToTwip(nVal); break;
+ case 4 : pNewRec->m_nHeight = convertMm100ToTwip(nVal); break;
+ case 5 : pNewRec->m_nLeft = convertMm100ToTwip(nVal); break;
+ case 6 : pNewRec->m_nUpper = convertMm100ToTwip(nVal); break;
+ case 7 : pNewRec->m_nCols = nVal; break;
+ case 8 : pNewRec->m_nRows = nVal; break;
+ case 9 : pNewRec->m_nPWidth = convertMm100ToTwip(nVal); break;
+ case 10 : pNewRec->m_nPHeight = convertMm100ToTwip(nVal); break;
+ }
+ }
+ // lines added for compatibility with custom label definitions saved before patch fdo#44516
+ if (pNewRec->m_nPWidth == 0 || pNewRec->m_nPHeight == 0)
+ {
+ // old style definition (no paper dimensions), calculate probable values
+ pNewRec->m_nPWidth = 2 * pNewRec->m_nLeft + (pNewRec->m_nCols - 1) * pNewRec->m_nHDist + pNewRec->m_nWidth;
+ pNewRec->m_nPHeight = ( pNewRec->m_bCont ? pNewRec->m_nRows * pNewRec->m_nVDist : 2 * pNewRec->m_nUpper + (pNewRec->m_nRows - 1) * pNewRec->m_nVDist + pNewRec->m_nHeight );
+ }
+ return pNewRec;
+}
+
+static Sequence<PropertyValue> lcl_CreateProperties(
+ Sequence<OUString> const & rPropNames, OUString& rMeasure, const SwLabRec& rRec)
+{
+ const OUString* pNames = rPropNames.getConstArray();
+ Sequence<PropertyValue> aRet(rPropNames.getLength());
+ PropertyValue* pValues = aRet.getArray();
+ OUString sColon(";");
+
+ for(sal_Int32 nProp = 0; nProp < rPropNames.getLength(); nProp++)
+ {
+ pValues[nProp].Name = pNames[nProp];
+ switch(nProp)
+ {
+ case 0: pValues[nProp].Value <<= rRec.m_aType; break;
+ case 1:
+ {
+ rMeasure.clear();
+ rMeasure += rRec.m_bCont ? OUStringLiteral( "C" ) : OUStringLiteral( "S" ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nHDist ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nVDist ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nWidth ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nHeight ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nLeft ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nUpper ) ); rMeasure += sColon;
+ rMeasure += OUString::number( rRec.m_nCols ); rMeasure += sColon;
+ rMeasure += OUString::number( rRec.m_nRows ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nPWidth ) ); rMeasure += sColon;
+ rMeasure += OUString::number( convertTwipToMm100( rRec.m_nPHeight ) );
+ pValues[nProp].Value <<= rMeasure;
+ }
+ break;
+ }
+ }
+ return aRet;
+}
+
+// function fills SwLabDlg with label definitions for manufacturer rManufacturer
+void SwLabelConfig::FillLabels(const OUString& rManufacturer, SwLabRecs& rLabArr)
+{
+ if (m_aLabels.find(rManufacturer) == m_aLabels.end())
+ return;
+ for (const auto& rEntry : m_aLabels[rManufacturer])
+ rLabArr.push_back( lcl_CreateSwLabRec(rEntry.first, rEntry.second.m_aMeasure, rManufacturer) );
+}
+
+bool SwLabelConfig::HasLabel(const OUString& rManufacturer, const OUString& rType)
+{
+ return ( ( m_aLabels.find(rManufacturer) != m_aLabels.end() ) &&
+ ( m_aLabels[rManufacturer].find(rType) != m_aLabels[rManufacturer].end() ) );
+}
+
+// label is always saved as a custom label
+// predefined labels can NOT be overwritten by custom labels with same manufacturer/name
+void SwLabelConfig::SaveLabel( const OUString& rManufacturer,
+ const OUString& rType, const SwLabRec& rRec )
+{
+ OUString sFoundNode;
+ bool bManufacturerNodeFound;
+ if ( m_aLabels.find( rManufacturer ) == m_aLabels.end() ||
+ !GetNodeNames( rManufacturer ).hasElements() )
+ {
+ bManufacturerNodeFound = false;
+ // manufacturer node does not exist, add (and also to m_aManufacturers)
+ if ( !AddNode( OUString(), rManufacturer ) )
+ {
+ OSL_FAIL("New configuration node could not be created");
+ return ;
+ }
+ m_aManufacturers.push_back( rManufacturer );
+ }
+ else
+ bManufacturerNodeFound = true;
+
+ if ( !bManufacturerNodeFound ||
+ m_aLabels[rManufacturer].find( rType ) == m_aLabels[rManufacturer].end() )
+ {
+ // type does not yet exist, add to config
+ const Sequence<OUString> aLabels = GetNodeNames( rManufacturer );
+ sal_Int32 nIndex = aLabels.getLength();
+ OUString sPrefix( "Label" );
+ sFoundNode = sPrefix + OUString::number( nIndex );
+ while ( comphelper::findValue(aLabels, sFoundNode) != -1 )
+ {
+ sFoundNode = sPrefix + OUString::number(nIndex++);
+ }
+ }
+ else
+ {
+ // get the appropriate node
+ OUString sManufacturer( wrapConfigurationElementName( rManufacturer ) );
+ const Sequence<OUString> aLabels = GetNodeNames( sManufacturer );
+ for (const OUString& rLabel : aLabels)
+ {
+ OUString sPrefix = sManufacturer + "/" + rLabel + "/";
+ Sequence<OUString> aProperties { sPrefix };
+ aProperties.getArray()[0] += "Name";
+ Sequence<Any> aValues = GetProperties( aProperties );
+ const Any* pValues = aValues.getConstArray();
+ if ( pValues[0].hasValue() )
+ {
+ OUString sTmp;
+ pValues[0] >>= sTmp;
+ if ( rType == sTmp )
+ {
+ sFoundNode = rLabel;
+ break;
+ }
+ }
+ }
+ }
+
+ OUString sPrefix = wrapConfigurationElementName( rManufacturer ) +
+ "/" + sFoundNode + "/";
+ Sequence<OUString> aPropNames = lcl_CreatePropertyNames( sPrefix );
+ OUString sMeasure;
+ Sequence<PropertyValue> aPropValues = lcl_CreateProperties( aPropNames, sMeasure, rRec );
+ SetSetProperties( wrapConfigurationElementName( rManufacturer ), aPropValues );
+
+ //update m_aLabels
+ m_aLabels[rManufacturer][rType].m_aMeasure = sMeasure;
+ m_aLabels[rManufacturer][rType].m_bPredefined = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/envelp/labimg.cxx b/sw/source/uibase/envelp/labimg.cxx
new file mode 100644
index 000000000..03a38a853
--- /dev/null
+++ b/sw/source/uibase/envelp/labimg.cxx
@@ -0,0 +1,463 @@
+/* -*- 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 <sal/config.h>
+
+#include <o3tl/any.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <unotools/useroptions.hxx>
+#include <swmodule.hxx>
+#include <labimg.hxx>
+#include <cmdid.h>
+
+using namespace utl;
+using namespace ::com::sun::star::uno;
+
+SwLabItem::SwLabItem() :
+
+ SfxPoolItem(FN_LABEL),
+ m_lLeft (0),
+ m_lUpper(0),
+ m_nCols (1),
+ m_nRows (1),
+ m_nCol (1),
+ m_nRow (1)
+{
+ m_bAddr =
+ m_bCont =
+ m_bSynchron = false;
+ m_bPage = true;
+ m_lHDist =
+ m_lVDist =
+ m_lWidth =
+ m_lHeight =
+ m_lPWidth =
+ m_lPHeight = 5669; // 10 cm
+}
+
+SwLabItem& SwLabItem::operator =(const SwLabItem& rItem)
+{
+ m_bAddr = rItem.m_bAddr;
+ m_aWriting = rItem.m_aWriting;
+ m_bCont = rItem.m_bCont;
+ m_sDBName = rItem.m_sDBName;
+ m_aLstMake = rItem.m_aLstMake;
+ m_aLstType = rItem.m_aLstType;
+ m_aMake = rItem.m_aMake;
+ m_aType = rItem.m_aType;
+ m_bPage = rItem.m_bPage;
+ m_bSynchron = rItem.m_bSynchron;
+ m_nCol = rItem.m_nCol;
+ m_nRow = rItem.m_nRow;
+ m_lHDist = rItem.m_lHDist;
+ m_lVDist = rItem.m_lVDist;
+ m_lWidth = rItem.m_lWidth;
+ m_lHeight = rItem.m_lHeight;
+ m_lLeft = rItem.m_lLeft;
+ m_lUpper = rItem.m_lUpper;
+ m_nCols = rItem.m_nCols;
+ m_nRows = rItem.m_nRows;
+ m_lPWidth = rItem.m_lPWidth;
+ m_lPHeight = rItem.m_lPHeight;
+ m_aPrivFirstName = rItem.m_aPrivFirstName;
+ m_aPrivName = rItem.m_aPrivName;
+ m_aPrivShortCut = rItem.m_aPrivShortCut;
+ m_aPrivFirstName2 = rItem.m_aPrivFirstName2;
+ m_aPrivName2 = rItem.m_aPrivName2;
+ m_aPrivShortCut2 = rItem.m_aPrivShortCut2;
+ m_aPrivStreet = rItem.m_aPrivStreet;
+ m_aPrivZip = rItem.m_aPrivZip;
+ m_aPrivCity = rItem.m_aPrivCity;
+ m_aPrivCountry = rItem.m_aPrivCountry;
+ m_aPrivState = rItem.m_aPrivState;
+ m_aPrivTitle = rItem.m_aPrivTitle;
+ m_aPrivProfession = rItem.m_aPrivProfession;
+ m_aPrivPhone = rItem.m_aPrivPhone;
+ m_aPrivMobile = rItem.m_aPrivMobile;
+ m_aPrivFax = rItem.m_aPrivFax;
+ m_aPrivWWW = rItem.m_aPrivWWW;
+ m_aPrivMail = rItem.m_aPrivMail;
+ m_aCompCompany = rItem.m_aCompCompany;
+ m_aCompCompanyExt = rItem.m_aCompCompanyExt;
+ m_aCompSlogan = rItem.m_aCompSlogan;
+ m_aCompStreet = rItem.m_aCompStreet;
+ m_aCompZip = rItem.m_aCompZip;
+ m_aCompCity = rItem.m_aCompCity;
+ m_aCompCountry = rItem.m_aCompCountry;
+ m_aCompState = rItem.m_aCompState;
+ m_aCompPosition = rItem.m_aCompPosition;
+ m_aCompPhone = rItem.m_aCompPhone;
+ m_aCompMobile = rItem.m_aCompMobile;
+ m_aCompFax = rItem.m_aCompFax;
+ m_aCompWWW = rItem.m_aCompWWW;
+ m_aCompMail = rItem.m_aCompMail;
+ m_sGlossaryGroup = rItem.m_sGlossaryGroup;
+ m_sGlossaryBlockName = rItem.m_sGlossaryBlockName;
+ return *this;
+}
+
+bool SwLabItem::operator ==(const SfxPoolItem& rItem) const
+{
+ const SwLabItem& rLab = static_cast<const SwLabItem&>( rItem);
+
+ return m_bAddr == rLab.m_bAddr &&
+ m_bCont == rLab.m_bCont &&
+ m_bPage == rLab.m_bPage &&
+ m_bSynchron == rLab.m_bSynchron &&
+ m_nCol == rLab.m_nCol &&
+ m_nRow == rLab.m_nRow &&
+ m_lHDist == rLab.m_lHDist &&
+ m_lVDist == rLab.m_lVDist &&
+ m_lWidth == rLab.m_lWidth &&
+ m_lHeight == rLab.m_lHeight &&
+ m_lLeft == rLab.m_lLeft &&
+ m_lUpper == rLab.m_lUpper &&
+ m_nCols == rLab.m_nCols &&
+ m_nRows == rLab.m_nRows &&
+ m_lPWidth == rLab.m_lPWidth &&
+ m_lPHeight == rLab.m_lPHeight&&
+ m_aWriting == rLab.m_aWriting&&
+ m_aMake == rLab.m_aMake &&
+ m_aType == rLab.m_aType &&
+ m_aLstMake == rLab.m_aLstMake&&
+ m_aLstType == rLab.m_aLstType&&
+ m_sDBName == rLab.m_sDBName &&
+ m_aPrivFirstName == rLab.m_aPrivFirstName&&
+ m_aPrivName == rLab.m_aPrivName&&
+ m_aPrivShortCut == rLab.m_aPrivShortCut&&
+ m_aPrivFirstName2 == rLab.m_aPrivFirstName2&&
+ m_aPrivName2 == rLab.m_aPrivName2&&
+ m_aPrivShortCut2 == rLab.m_aPrivShortCut2&&
+ m_aPrivStreet == rLab.m_aPrivStreet&&
+ m_aPrivZip == rLab.m_aPrivZip&&
+ m_aPrivCity == rLab.m_aPrivCity&&
+ m_aPrivCountry == rLab.m_aPrivCountry&&
+ m_aPrivState == rLab.m_aPrivState&&
+ m_aPrivTitle == rLab.m_aPrivTitle&&
+ m_aPrivProfession == rLab.m_aPrivProfession&&
+ m_aPrivPhone == rLab.m_aPrivPhone&&
+ m_aPrivMobile == rLab.m_aPrivMobile&&
+ m_aPrivFax == rLab.m_aPrivFax&&
+ m_aPrivWWW == rLab.m_aPrivWWW&&
+ m_aPrivMail == rLab.m_aPrivMail&&
+ m_aCompCompany == rLab.m_aCompCompany&&
+ m_aCompCompanyExt == rLab.m_aCompCompanyExt&&
+ m_aCompSlogan == rLab.m_aCompSlogan&&
+ m_aCompStreet == rLab.m_aCompStreet&&
+ m_aCompZip == rLab.m_aCompZip&&
+ m_aCompCity == rLab.m_aCompCity&&
+ m_aCompCountry == rLab.m_aCompCountry&&
+ m_aCompState == rLab.m_aCompState&&
+ m_aCompPosition == rLab.m_aCompPosition&&
+ m_aCompPhone == rLab.m_aCompPhone&&
+ m_aCompMobile == rLab.m_aCompMobile&&
+ m_aCompFax == rLab.m_aCompFax&&
+ m_aCompWWW == rLab.m_aCompWWW&&
+ m_aCompMail == rLab.m_aCompMail &&
+ m_sGlossaryGroup == rLab.m_sGlossaryGroup &&
+ m_sGlossaryBlockName == rLab.m_sGlossaryBlockName;
+}
+
+SwLabItem* SwLabItem::Clone(SfxItemPool*) const
+{
+ return new SwLabItem(*this);
+}
+
+Sequence<OUString> SwLabCfgItem::GetPropertyNames() const
+{
+ static const char* aLabelPropNames[] =
+ {
+ "Medium/Continuous", // 0
+ "Medium/Brand", // 1
+ "Medium/Type", // 2
+ "Format/Column", // 3
+ "Format/Row", // 4
+ "Format/HorizontalDistance",// 5
+ "Format/VerticalDistance", // 6
+ "Format/Width", // 7
+ "Format/Height", // 8
+ "Format/LeftMargin", // 9
+ "Format/TopMargin", //10
+ "Format/PageWidth", //11
+ "Format/PageHeight", //12
+ "Option/Synchronize", //13
+ "Option/Page", //14
+ "Option/Column", //15
+ "Option/Row", //16
+ "Inscription/UseAddress", //17
+ "Inscription/Address", //18
+ "Inscription/Database" //19
+ };
+ static const char* aBusinessPropNames[] =
+ {
+ "PrivateAddress/FirstName", // 0
+ "PrivateAddress/Name", // 1
+ "PrivateAddress/ShortCut", // 2
+ "PrivateAddress/SecondFirstName", // 3
+ "PrivateAddress/SecondName", // 4
+ "PrivateAddress/SecondShortCut", // 5
+ "PrivateAddress/Street", // 6
+ "PrivateAddress/Zip", // 7
+ "PrivateAddress/City", // 8
+ "PrivateAddress/Country", // 9
+ "PrivateAddress/State", // 10
+ "PrivateAddress/Title", // 11
+ "PrivateAddress/Profession", // 12
+ "PrivateAddress/Phone", // 13
+ "PrivateAddress/Mobile", // 14
+ "PrivateAddress/Fax", // 15
+ "PrivateAddress/WebAddress", // 16
+ "PrivateAddress/Email", // 17
+ "BusinessAddress/Company", // 18
+ "BusinessAddress/CompanyExt", // 19
+ "BusinessAddress/Slogan", // 20
+ "BusinessAddress/Street", // 21
+ "BusinessAddress/Zip", // 22
+ "BusinessAddress/City", // 23
+ "BusinessAddress/Country", // 24
+ "BusinessAddress/State", // 25
+ "BusinessAddress/Position", // 26
+ "BusinessAddress/Phone", // 27
+ "BusinessAddress/Mobile", // 28
+ "BusinessAddress/Fax", // 29
+ "BusinessAddress/WebAddress", // 30
+ "BusinessAddress/Email", // 31
+ "AutoText/Group", // 32
+ "AutoText/Block" // 33
+ };
+ const int nBusinessCount = bIsLabel ? 0 : 34;
+ const int nLabelCount = bIsLabel ? 20 : 17;
+ Sequence<OUString> aNames(nBusinessCount + nLabelCount);
+ OUString* pNames = aNames.getArray();
+ int nIndex = 0;
+ for(int nLabel = 0; nLabel < nLabelCount; nLabel++)
+ pNames[nIndex++] = OUString::createFromAscii(aLabelPropNames[nLabel]);
+ for(int nBusiness = 0; nBusiness < nBusinessCount; nBusiness++)
+ pNames[nIndex++] = OUString::createFromAscii(aBusinessPropNames[nBusiness]);
+ return aNames;
+}
+
+SwLabCfgItem::SwLabCfgItem(bool bLabel) :
+ ConfigItem(bLabel ? OUString("Office.Writer/Label") : OUString("Office.Writer/BusinessCard")),
+ bIsLabel(bLabel)
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+ bool bNoConfigValues = true;
+ if(aValues.getLength() == aNames.getLength())
+ {
+ for(int nProp = 0, nProperty = 0; nProp < aNames.getLength(); nProp++, nProperty++)
+ {
+
+ if(pValues[nProp].hasValue())
+ {
+ //to have a contiuous switch an offset is added
+ if(nProp == 17 && !bIsLabel)
+ nProperty += 3;
+ if(nProperty >= 20)
+ bNoConfigValues = false;
+ switch(nProperty)
+ {
+ case 0: aItem.m_bCont = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Medium/Continuous",
+ case 1: pValues[nProp] >>= aItem.m_aMake; break;// "Medium/Brand",
+ case 2: pValues[nProp] >>= aItem.m_aType; break;// "Medium/Type",
+ case 3: pValues[nProp] >>= aItem.m_nCols; break;// "Format/Column",
+ case 4: pValues[nProp] >>= aItem.m_nRows; break;// "Format/Row",
+ case 5:
+ pValues[nProp] >>= aItem.m_lHDist;
+ aItem.m_lHDist = convertMm100ToTwip(aItem.m_lHDist);
+ break;// "Format/HorizontalDistance",
+ case 6:
+ pValues[nProp] >>= aItem.m_lVDist;
+ aItem.m_lVDist = convertMm100ToTwip(aItem.m_lVDist);
+ break;// "Format/VerticalDistance",
+ case 7:
+ pValues[nProp] >>= aItem.m_lWidth;
+ aItem.m_lWidth = convertMm100ToTwip(aItem.m_lWidth);
+ break;// "Format/Width",
+ case 8:
+ pValues[nProp] >>= aItem.m_lHeight;
+ aItem.m_lHeight = convertMm100ToTwip(aItem.m_lHeight);
+ break;// "Format/Height",
+ case 9:
+ pValues[nProp] >>= aItem.m_lLeft;
+ aItem.m_lLeft = convertMm100ToTwip(aItem.m_lLeft);
+ break;// "Format/LeftMargin",
+ case 10:
+ pValues[nProp] >>= aItem.m_lUpper;
+ aItem.m_lUpper = convertMm100ToTwip(aItem.m_lUpper);
+ break;// "Format/TopMargin",
+ case 11:
+ pValues[nProp] >>= aItem.m_lPWidth;
+ aItem.m_lPWidth = convertMm100ToTwip(aItem.m_lPWidth);
+ break;// "Format/PageWidth",
+ case 12:
+ pValues[nProp] >>= aItem.m_lPHeight;
+ aItem.m_lPHeight = convertMm100ToTwip(aItem.m_lPHeight);
+ break;// "Format/PageHeight",
+ case 13: aItem.m_bSynchron = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Option/Synchronize",
+ case 14: aItem.m_bPage = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Option/Page",
+ case 15: pValues[nProp] >>= aItem.m_nCol; break;// "Option/Column",
+ case 16: pValues[nProp] >>= aItem.m_nRow; break;// "Option/Row"
+ case 17: aItem.m_bAddr = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Inscription/UseAddress",
+ case 18: pValues[nProp] >>= aItem.m_aWriting; break;// "Inscription/Address",
+ case 19: pValues[nProp] >>= aItem.m_sDBName; break;// "Inscription/Database"
+ case 20: pValues[nProp] >>= aItem.m_aPrivFirstName; break;// "PrivateAddress/FirstName",
+ case 21: pValues[nProp] >>= aItem.m_aPrivName; break;// "PrivateAddress/Name",
+ case 22: pValues[nProp] >>= aItem.m_aPrivShortCut; break;// "PrivateAddress/ShortCut",
+ case 23: pValues[nProp] >>= aItem.m_aPrivFirstName2; break;// "PrivateAddress/SecondFirstName",
+ case 24: pValues[nProp] >>= aItem.m_aPrivName2; break;// "PrivateAddress/SecondName",
+ case 25: pValues[nProp] >>= aItem.m_aPrivShortCut2; break;// "PrivateAddress/SecondShortCut",
+ case 26: pValues[nProp] >>= aItem.m_aPrivStreet; break;// "PrivateAddress/Street",
+ case 27: pValues[nProp] >>= aItem.m_aPrivZip; break;// "PrivateAddress/Zip",
+ case 28: pValues[nProp] >>= aItem.m_aPrivCity; break;// "PrivateAddress/City",
+ case 29: pValues[nProp] >>= aItem.m_aPrivCountry; break;// "PrivateAddress/Country",
+ case 30: pValues[nProp] >>= aItem.m_aPrivState; break;// "PrivateAddress/State",
+ case 31: pValues[nProp] >>= aItem.m_aPrivTitle; break;// "PrivateAddress/Title",
+ case 32: pValues[nProp] >>= aItem.m_aPrivProfession; break;// "PrivateAddress/Profession",
+ case 33: pValues[nProp] >>= aItem.m_aPrivPhone; break;// "PrivateAddress/Phone",
+ case 34: pValues[nProp] >>= aItem.m_aPrivMobile; break;// "PrivateAddress/Mobile",
+ case 35: pValues[nProp] >>= aItem.m_aPrivFax; break;// "PrivateAddress/Fax",
+ case 36: pValues[nProp] >>= aItem.m_aPrivWWW; break;// "PrivateAddress/WebAddress",
+ case 37: pValues[nProp] >>= aItem.m_aPrivMail; break;// "PrivateAddress/Email",
+ case 38: pValues[nProp] >>= aItem.m_aCompCompany; break;// "BusinessAddress/Company",
+ case 39: pValues[nProp] >>= aItem.m_aCompCompanyExt; break;// "BusinessAddress/CompanyExt",
+ case 40: pValues[nProp] >>= aItem.m_aCompSlogan; break;// "BusinessAddress/Slogan",
+ case 41: pValues[nProp] >>= aItem.m_aCompStreet; break;// "BusinessAddress/Street",
+ case 42: pValues[nProp] >>= aItem.m_aCompZip; break;// "BusinessAddress/Zip",
+ case 43: pValues[nProp] >>= aItem.m_aCompCity; break;// "BusinessAddress/City",
+ case 44: pValues[nProp] >>= aItem.m_aCompCountry; break;// "BusinessAddress/Country",
+ case 45: pValues[nProp] >>= aItem.m_aCompState; break;// "BusinessAddress/State",
+ case 46: pValues[nProp] >>= aItem.m_aCompPosition; break;// "BusinessAddress/Position",
+ case 47: pValues[nProp] >>= aItem.m_aCompPhone; break;// "BusinessAddress/Phone",
+ case 48: pValues[nProp] >>= aItem.m_aCompMobile; break;// "BusinessAddress/Mobile",
+ case 49: pValues[nProp] >>= aItem.m_aCompFax; break;// "BusinessAddress/Fax",
+ case 50: pValues[nProp] >>= aItem.m_aCompWWW; break;// "BusinessAddress/WebAddress",
+ case 51: pValues[nProp] >>= aItem.m_aCompMail; break;// "BusinessAddress/Email",
+ case 52: pValues[nProp] >>= aItem.m_sGlossaryGroup; break;// "AutoText/Group"
+ case 53: pValues[nProp] >>= aItem.m_sGlossaryBlockName; break;// "AutoText/Block"
+ }
+ }
+ }
+ }
+
+ if(bIsLabel || !bNoConfigValues)
+ return;
+
+ SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions();
+ aItem.m_aPrivFirstName = rUserOpt.GetFirstName();
+ aItem.m_aPrivName = rUserOpt.GetLastName();
+ aItem.m_aPrivShortCut = rUserOpt.GetID();
+ aItem.m_aCompCompany = rUserOpt.GetCompany();
+ aItem.m_aCompStreet = aItem.m_aPrivStreet = rUserOpt.GetStreet();
+
+ aItem.m_aCompCountry = aItem.m_aPrivCountry = rUserOpt.GetCountry();
+ aItem.m_aCompZip = aItem.m_aPrivZip= rUserOpt.GetZip();
+ aItem.m_aCompCity = aItem.m_aPrivCity = rUserOpt.GetCity();
+ aItem.m_aPrivTitle = rUserOpt.GetTitle();
+ aItem.m_aCompPosition = rUserOpt.GetPosition();
+ aItem.m_aPrivPhone = rUserOpt.GetTelephoneHome();
+ aItem.m_aCompPhone = rUserOpt.GetTelephoneWork();
+ aItem.m_aCompFax = aItem.m_aPrivFax = rUserOpt.GetFax();
+ aItem.m_aCompMail = aItem.m_aPrivMail = rUserOpt.GetEmail();
+ aItem.m_aCompState = aItem.m_aPrivState = rUserOpt.GetState();
+ aItem.m_bSynchron = true;
+ SetModified();
+
+}
+
+void SwLabCfgItem::Notify( const css::uno::Sequence< OUString >& ) {}
+
+void SwLabCfgItem::ImplCommit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0, nProperty = 0; nProp < aNames.getLength(); nProp++, nProperty++)
+ {
+ //to have a contiuous switch an offset is added
+ if(nProp == 17 && !bIsLabel)
+ nProperty += 3;
+ switch(nProperty)
+ {
+ case 0: pValues[nProp] <<= aItem.m_bCont; break;// "Medium/Continuous",
+ case 1: pValues[nProp] <<= aItem.m_aMake; break;// "Medium/Brand",
+ case 2: pValues[nProp] <<= aItem.m_aType; break;// "Medium/Type",
+ case 3: pValues[nProp] <<= aItem.m_nCols; break;// "Format/Column",
+ case 4: pValues[nProp] <<= aItem.m_nRows; break;// "Format/Row",
+ case 5: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lHDist));break;// "Format/HorizontalDistance",
+ case 6: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lVDist));break;// "Format/VerticalDistance",
+ case 7: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lWidth)); break;// "Format/Width",
+ case 8: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lHeight)); break;// "Format/Height",
+ case 9: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lLeft)); break;// "Format/LeftMargin",
+ case 10: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lUpper)); break;// "Format/TopMargin",
+ case 11: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lPWidth)); break;// "Format/Page Width",
+ case 12: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(aItem.m_lPHeight)); break;// "Format/PageHeight",
+ case 13: pValues[nProp] <<= aItem.m_bSynchron; break;// "Option/Synchronize",
+ case 14: pValues[nProp] <<= aItem.m_bPage; break;// "Option/Page",
+ case 15: pValues[nProp] <<= aItem.m_nCol; break;// "Option/Column",
+ case 16: pValues[nProp] <<= aItem.m_nRow; break;// "Option/Row"
+ case 17: pValues[nProp] <<= aItem.m_bAddr; break;// "Inscription/UseAddress",
+ case 18: pValues[nProp] <<= aItem.m_aWriting; break;// "Inscription/Address",
+ case 19: pValues[nProp] <<= aItem.m_sDBName; break;// "Inscription/Database"
+ case 20: pValues[nProp] <<= aItem.m_aPrivFirstName; break;// "PrivateAddress/FirstName",
+ case 21: pValues[nProp] <<= aItem.m_aPrivName; break;// "PrivateAddress/Name",
+ case 22: pValues[nProp] <<= aItem.m_aPrivShortCut; break;// "PrivateAddress/ShortCut",
+ case 23: pValues[nProp] <<= aItem.m_aPrivFirstName2; break;// "PrivateAddress/SecondFirstName",
+ case 24: pValues[nProp] <<= aItem.m_aPrivName2; break;// "PrivateAddress/SecondName",
+ case 25: pValues[nProp] <<= aItem.m_aPrivShortCut2; break;// "PrivateAddress/SecondShortCut",
+ case 26: pValues[nProp] <<= aItem.m_aPrivStreet; break;// "PrivateAddress/Street",
+ case 27: pValues[nProp] <<= aItem.m_aPrivZip; break;// "PrivateAddress/Zip",
+ case 28: pValues[nProp] <<= aItem.m_aPrivCity; break;// "PrivateAddress/City",
+ case 29: pValues[nProp] <<= aItem.m_aPrivCountry; break;// "PrivateAddress/Country",
+ case 30: pValues[nProp] <<= aItem.m_aPrivState; break;// "PrivateAddress/State",
+ case 31: pValues[nProp] <<= aItem.m_aPrivTitle; break;// "PrivateAddress/Title",
+ case 32: pValues[nProp] <<= aItem.m_aPrivProfession; break;// "PrivateAddress/Profession",
+ case 33: pValues[nProp] <<= aItem.m_aPrivPhone; break;// "PrivateAddress/Phone",
+ case 34: pValues[nProp] <<= aItem.m_aPrivMobile; break;// "PrivateAddress/Mobile",
+ case 35: pValues[nProp] <<= aItem.m_aPrivFax; break;// "PrivateAddress/Fax",
+ case 36: pValues[nProp] <<= aItem.m_aPrivWWW; break;// "PrivateAddress/WebAddress",
+ case 37: pValues[nProp] <<= aItem.m_aPrivMail; break;// "PrivateAddress/Email",
+ case 38: pValues[nProp] <<= aItem.m_aCompCompany; break;// "BusinessAddress/Company",
+ case 39: pValues[nProp] <<= aItem.m_aCompCompanyExt; break;// "BusinessAddress/CompanyExt",
+ case 40: pValues[nProp] <<= aItem.m_aCompSlogan; break;// "BusinessAddress/Slogan",
+ case 41: pValues[nProp] <<= aItem.m_aCompStreet; break;// "BusinessAddress/Street",
+ case 42: pValues[nProp] <<= aItem.m_aCompZip; break;// "BusinessAddress/Zip",
+ case 43: pValues[nProp] <<= aItem.m_aCompCity; break;// "BusinessAddress/City",
+ case 44: pValues[nProp] <<= aItem.m_aCompCountry; break;// "BusinessAddress/Country",
+ case 45: pValues[nProp] <<= aItem.m_aCompState; break;// "BusinessAddress/State",
+ case 46: pValues[nProp] <<= aItem.m_aCompPosition; break;// "BusinessAddress/Position",
+ case 47: pValues[nProp] <<= aItem.m_aCompPhone; break;// "BusinessAddress/Phone",
+ case 48: pValues[nProp] <<= aItem.m_aCompMobile; break;// "BusinessAddress/Mobile",
+ case 49: pValues[nProp] <<= aItem.m_aCompFax; break;// "BusinessAddress/Fax",
+ case 50: pValues[nProp] <<= aItem.m_aCompWWW; break;// "BusinessAddress/WebAddress",
+ case 51: pValues[nProp] <<= aItem.m_aCompMail; break;// "BusinessAddress/Email",
+ case 52: pValues[nProp] <<= aItem.m_sGlossaryGroup; break;// "AutoText/Group"
+ case 53: pValues[nProp] <<= aItem.m_sGlossaryBlockName; break;// "AutoText/Block"
+ }
+ }
+ PutProperties(aNames, aValues);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/envelp/syncbtn.cxx b/sw/source/uibase/envelp/syncbtn.cxx
new file mode 100644
index 000000000..009525d02
--- /dev/null
+++ b/sw/source/uibase/envelp/syncbtn.cxx
@@ -0,0 +1,87 @@
+/* -*- 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 <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/windowstate.hxx>
+
+#include <cmdid.h>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+
+#include <syncbtn.hxx>
+
+SFX_IMPL_MODELESSDIALOGCONTOLLER(SwSyncChildWin, FN_SYNC_LABELS)
+
+SwSyncChildWin::SwSyncChildWin(vcl::Window* _pParent,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo)
+ : SfxChildWindow(_pParent, nId)
+{
+ SetController(std::make_shared<SwSyncBtnDlg>(pBindings, this, _pParent->GetFrameWeld()));
+ SwSyncBtnDlg* pBtnDlg = static_cast<SwSyncBtnDlg*>(GetController().get());
+
+ if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
+ {
+ weld::Dialog* pDlg = pBtnDlg->getDialog();
+ Point aPos;
+
+ SwView* pActiveView = ::GetActiveView();
+ if (pActiveView)
+ {
+ const SwEditWin &rEditWin = pActiveView->GetEditWin();
+ aPos = rEditWin.OutputToScreenPixel(Point(0, 0));
+ }
+ else
+ aPos = _pParent->OutputToScreenPixel(Point(0, 0));
+
+ WindowStateData aState;
+ aState.SetMask(WindowStateMask::Pos);
+ aState.SetX(aPos.X());
+ aState.SetY(aPos.Y());
+ pDlg->set_window_state(aState.ToStr());
+
+ pInfo->aPos = pDlg->get_position();
+ pInfo->aSize = pDlg->get_size();
+ }
+
+ pBtnDlg->Initialize(pInfo);
+}
+
+SwSyncBtnDlg::SwSyncBtnDlg(SfxBindings* pBindings,
+ SfxChildWindow* pChild,
+ weld::Window *pParent)
+ : SfxModelessDialogController(pBindings, pChild, pParent, "modules/swriter/ui/floatingsync.ui", "FloatingSync")
+ , m_xSyncBtn(m_xBuilder->weld_button("sync"))
+{
+ m_xSyncBtn->connect_clicked(LINK(this, SwSyncBtnDlg, BtnHdl));
+}
+
+SwSyncBtnDlg::~SwSyncBtnDlg()
+{
+}
+
+IMPL_STATIC_LINK_NOARG(SwSyncBtnDlg, BtnHdl, weld::Button&, void)
+{
+ SfxViewFrame::Current()->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */