From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/source/uibase/envelp/envimg.cxx | 333 +++++++++++++++++++++++++ sw/source/uibase/envelp/labelcfg.cxx | 330 +++++++++++++++++++++++++ sw/source/uibase/envelp/labimg.cxx | 465 +++++++++++++++++++++++++++++++++++ sw/source/uibase/envelp/syncbtn.cxx | 86 +++++++ 4 files changed, 1214 insertions(+) create mode 100644 sw/source/uibase/envelp/envimg.cxx create mode 100644 sw/source/uibase/envelp/labelcfg.cxx create mode 100644 sw/source/uibase/envelp/labimg.cxx create mode 100644 sw/source/uibase/envelp/syncbtn.cxx (limited to 'sw/source/uibase/envelp') diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx new file mode 100644 index 0000000000..b36cfdfa51 --- /dev/null +++ b/sw/source/uibase/envelp/envimg.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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +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 { + std::u16string_view sToken = o3tl::getToken(sSenderToken, 0, ';', nSttPos ); + if (sToken == u"COMPANY") + { + sal_Int32 nOldLen = sRet.getLength(); + sRet.append(rUserOpt.GetCompany()); + bLastLength = sRet.getLength() != nOldLen; + } + else if (sToken == u"CR") + { + if(bLastLength) + sRet.append(SAL_NEWLINE_STRING); + bLastLength = true; + } + else if (sToken == u"FIRSTNAME") + sRet.append(rUserOpt.GetFirstName()); + else if (sToken == u"LASTNAME") + sRet.append(rUserOpt.GetLastName()); + else if (sToken == u"ADDRESS") + sRet.append(rUserOpt.GetStreet()); + else if (sToken == u"COUNTRY") + sRet.append(rUserOpt.GetCountry()); + else if (sToken == u"POSTALCODE") + sRet.append(rUserOpt.GetZip()); + else if (sToken == u"CITY") + sRet.append(rUserOpt.GetCity()); + else if (sToken == u"STATEPROV") + sRet.append(rUserOpt.GetState()); + else if (!sToken.empty()) //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 +{ + assert(SfxPoolItem::operator==(rItem)); + const SwEnvItem& rEnv = static_cast( 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 aNames = GetPropertyNames(); + Sequence aValues = GetProperties(aNames); + EnableNotification(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + + 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(pValues[nProp]); break;// "Inscription/UseSender", + case 3: + pValues[nProp] >>= m_aEnvItem.m_nAddrFromLeft;// "Format/AddresseeFromLeft", + m_aEnvItem.m_nAddrFromLeft = o3tl::toTwips(m_aEnvItem.m_nAddrFromLeft, o3tl::Length::mm100); + break; + case 4: + pValues[nProp] >>= m_aEnvItem.m_nAddrFromTop; // "Format/AddresseeFromTop", + m_aEnvItem.m_nAddrFromTop = o3tl::toTwips(m_aEnvItem.m_nAddrFromTop, o3tl::Length::mm100); + break; + case 5: + pValues[nProp] >>= m_aEnvItem.m_nSendFromLeft; // "Format/SenderFromLeft", + m_aEnvItem.m_nSendFromLeft = o3tl::toTwips(m_aEnvItem.m_nSendFromLeft, o3tl::Length::mm100); + break; + case 6: + pValues[nProp] >>= m_aEnvItem.m_nSendFromTop;// "Format/SenderFromTop", + m_aEnvItem.m_nSendFromTop = o3tl::toTwips(m_aEnvItem.m_nSendFromTop, o3tl::Length::mm100); + break; + case 7: + pValues[nProp] >>= m_aEnvItem.m_nWidth; // "Format/Width", + m_aEnvItem.m_nWidth = o3tl::toTwips(m_aEnvItem.m_nWidth, o3tl::Length::mm100); + break; + case 8: + pValues[nProp] >>= m_aEnvItem.m_nHeight; // "Format/Height", + m_aEnvItem.m_nHeight = o3tl::toTwips(m_aEnvItem.m_nHeight, o3tl::Length::mm100); + break; + case 9: + { + sal_Int32 nTemp = 0; + pValues[nProp] >>= nTemp; m_aEnvItem.m_eAlign = static_cast(nTemp); break;// "Print/Alignment", + } + case 10: m_aEnvItem.m_bPrintFromAbove = *o3tl::doAccess(pValues[nProp]); break;// "Print/FromAbove", + case 11: + pValues[nProp] >>= m_aEnvItem.m_nShiftRight; + m_aEnvItem.m_nShiftRight = o3tl::toTwips(m_aEnvItem.m_nShiftRight, o3tl::Length::mm100);// "Print/Right", + break; + case 12: + pValues[nProp] >>= m_aEnvItem.m_nShiftDown; + m_aEnvItem.m_nShiftDown = o3tl::toTwips(m_aEnvItem.m_nShiftDown, o3tl::Length::mm100); + break;// "Print/Down" + } + } + } +} + +SwEnvCfgItem::~SwEnvCfgItem() +{ +} + +void SwEnvCfgItem::ImplCommit() +{ + Sequence aNames = GetPropertyNames(); + Sequence 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 (convertTwipToMm100(m_aEnvItem.m_nAddrFromLeft)) ; break;// "Format/AddresseeFromLeft", + case 4: pValues[nProp] <<= static_cast (convertTwipToMm100(m_aEnvItem.m_nAddrFromTop)) ; break;// "Format/AddresseeFromTop", + case 5: pValues[nProp] <<= static_cast (convertTwipToMm100(m_aEnvItem.m_nSendFromLeft)) ; break;// "Format/SenderFromLeft", + case 6: pValues[nProp] <<= static_cast (convertTwipToMm100(m_aEnvItem.m_nSendFromTop)) ; break;// "Format/SenderFromTop", + case 7: pValues[nProp] <<= static_cast (convertTwipToMm100(m_aEnvItem.m_nWidth)) ; break;// "Format/Width", + case 8: pValues[nProp] <<= static_cast (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 (convertTwipToMm100(m_aEnvItem.m_nShiftRight));break; // "Print/Right", + case 12: pValues[nProp] <<= static_cast (convertTwipToMm100(m_aEnvItem.m_nShiftDown)); break;// "Print/Down" + } + } + PutProperties(aNames, aValues); +} + +void SwEnvCfgItem::Notify( const css::uno::Sequence< OUString >& ) {} + +Sequence 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 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(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 0000000000..f974a3e799 --- /dev/null +++ b/sw/source/uibase/envelp/labelcfg.cxx @@ -0,0 +1,330 @@ +/* -*- 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +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 lcl_CreatePropertyNames(const OUString& rPrefix) +{ + return { OUString::Concat(rPrefix) + "Name", OUString::Concat(rPrefix) + "Measure" }; +} + +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& rMan = GetNodeNames( OUString() ); + for ( const OUString& rManufacturer : rMan ) + { + const Sequence aLabels = GetNodeNames( rManufacturer ); + for( const OUString& rLabel : aLabels ) + { + OUString sPrefix = rManufacturer + "/" + rLabel + "/"; + Sequence aPropNames = lcl_CreatePropertyNames( sPrefix ); + Sequence 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 lcl_CreateSwLabRec(const OUString& rType, std::u16string_view rMeasure, const OUString& rManufacturer) +{ + std::unique_ptr 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.empty() ? -1 : 0}; + while (nIdx>=0) + { + const std::u16string_view sToken(o3tl::getToken(rMeasure, 0, ';', nIdx)); + int nVal = o3tl::toInt32(sToken); + switch(nTok++) + { + case 0 : pNewRec->m_bCont = sToken[0] == 'C'; break; + case 1 : pNewRec->m_nHDist = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 2 : pNewRec->m_nVDist = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 3 : pNewRec->m_nWidth = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 4 : pNewRec->m_nHeight = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 5 : pNewRec->m_nLeft = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 6 : pNewRec->m_nUpper = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 7 : pNewRec->m_nCols = nVal; break; + case 8 : pNewRec->m_nRows = nVal; break; + case 9 : pNewRec->m_nPWidth = o3tl::toTwips(nVal, o3tl::Length::mm100); break; + case 10 : pNewRec->m_nPHeight = o3tl::toTwips(nVal, o3tl::Length::mm100); 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 lcl_CreateProperties( + Sequence const & rPropNames, OUString& rMeasure, const SwLabRec& rRec) +{ + const OUString* pNames = rPropNames.getConstArray(); + Sequence 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 ? std::u16string_view( u"C" ) : std::u16string_view( u"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) +{ + auto it = m_aLabels.find(rManufacturer); + return ( it != m_aLabels.end() ) && ( it->second.find(rType) != it->second.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 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 aLabels = GetNodeNames( sManufacturer ); + for (const OUString& rLabel : aLabels) + { + OUString sPrefix = sManufacturer + "/" + rLabel + "/"; + Sequence aProperties { sPrefix }; + aProperties.getArray()[0] += "Name"; + Sequence 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 aPropNames = lcl_CreatePropertyNames( sPrefix ); + OUString sMeasure; + Sequence 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 0000000000..b87f9bf5fb --- /dev/null +++ b/sw/source/uibase/envelp/labimg.cxx @@ -0,0 +1,465 @@ +/* -*- 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +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 +{ + assert(SfxPoolItem::operator==(rItem)); + const SwLabItem& rLab = static_cast( 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 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 = m_bIsLabel ? 0 : 34; + const int nLabelCount = m_bIsLabel ? 20 : 17; + Sequence 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")), + m_bIsLabel(bLabel) +{ + Sequence aNames = GetPropertyNames(); + Sequence 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 continuous switch an offset is added + if(nProp == 17 && !m_bIsLabel) + nProperty += 3; + if(nProperty >= 20) + bNoConfigValues = false; + switch(nProperty) + { + case 0: m_aItem.m_bCont = *o3tl::doAccess(pValues[nProp]); break;// "Medium/Continuous", + case 1: pValues[nProp] >>= m_aItem.m_aMake; break;// "Medium/Brand", + case 2: pValues[nProp] >>= m_aItem.m_aType; break;// "Medium/Type", + case 3: pValues[nProp] >>= m_aItem.m_nCols; break;// "Format/Column", + case 4: pValues[nProp] >>= m_aItem.m_nRows; break;// "Format/Row", + case 5: + pValues[nProp] >>= m_aItem.m_lHDist; + m_aItem.m_lHDist = o3tl::toTwips(m_aItem.m_lHDist, o3tl::Length::mm100); + break;// "Format/HorizontalDistance", + case 6: + pValues[nProp] >>= m_aItem.m_lVDist; + m_aItem.m_lVDist = o3tl::toTwips(m_aItem.m_lVDist, o3tl::Length::mm100); + break;// "Format/VerticalDistance", + case 7: + pValues[nProp] >>= m_aItem.m_lWidth; + m_aItem.m_lWidth = o3tl::toTwips(m_aItem.m_lWidth, o3tl::Length::mm100); + break;// "Format/Width", + case 8: + pValues[nProp] >>= m_aItem.m_lHeight; + m_aItem.m_lHeight = o3tl::toTwips(m_aItem.m_lHeight, o3tl::Length::mm100); + break;// "Format/Height", + case 9: + pValues[nProp] >>= m_aItem.m_lLeft; + m_aItem.m_lLeft = o3tl::toTwips(m_aItem.m_lLeft, o3tl::Length::mm100); + break;// "Format/LeftMargin", + case 10: + pValues[nProp] >>= m_aItem.m_lUpper; + m_aItem.m_lUpper = o3tl::toTwips(m_aItem.m_lUpper, o3tl::Length::mm100); + break;// "Format/TopMargin", + case 11: + pValues[nProp] >>= m_aItem.m_lPWidth; + m_aItem.m_lPWidth = o3tl::toTwips(m_aItem.m_lPWidth, o3tl::Length::mm100); + break;// "Format/PageWidth", + case 12: + pValues[nProp] >>= m_aItem.m_lPHeight; + m_aItem.m_lPHeight = o3tl::toTwips(m_aItem.m_lPHeight, o3tl::Length::mm100); + break;// "Format/PageHeight", + case 13: m_aItem.m_bSynchron = *o3tl::doAccess(pValues[nProp]); break;// "Option/Synchronize", + case 14: m_aItem.m_bPage = *o3tl::doAccess(pValues[nProp]); break;// "Option/Page", + case 15: pValues[nProp] >>= m_aItem.m_nCol; break;// "Option/Column", + case 16: pValues[nProp] >>= m_aItem.m_nRow; break;// "Option/Row" + case 17: m_aItem.m_bAddr = *o3tl::doAccess(pValues[nProp]); break;// "Inscription/UseAddress", + case 18: pValues[nProp] >>= m_aItem.m_aWriting; break;// "Inscription/Address", + case 19: pValues[nProp] >>= m_aItem.m_sDBName; break;// "Inscription/Database" + case 20: pValues[nProp] >>= m_aItem.m_aPrivFirstName; break;// "PrivateAddress/FirstName", + case 21: pValues[nProp] >>= m_aItem.m_aPrivName; break;// "PrivateAddress/Name", + case 22: pValues[nProp] >>= m_aItem.m_aPrivShortCut; break;// "PrivateAddress/ShortCut", + case 23: pValues[nProp] >>= m_aItem.m_aPrivFirstName2; break;// "PrivateAddress/SecondFirstName", + case 24: pValues[nProp] >>= m_aItem.m_aPrivName2; break;// "PrivateAddress/SecondName", + case 25: pValues[nProp] >>= m_aItem.m_aPrivShortCut2; break;// "PrivateAddress/SecondShortCut", + case 26: pValues[nProp] >>= m_aItem.m_aPrivStreet; break;// "PrivateAddress/Street", + case 27: pValues[nProp] >>= m_aItem.m_aPrivZip; break;// "PrivateAddress/Zip", + case 28: pValues[nProp] >>= m_aItem.m_aPrivCity; break;// "PrivateAddress/City", + case 29: pValues[nProp] >>= m_aItem.m_aPrivCountry; break;// "PrivateAddress/Country", + case 30: pValues[nProp] >>= m_aItem.m_aPrivState; break;// "PrivateAddress/State", + case 31: pValues[nProp] >>= m_aItem.m_aPrivTitle; break;// "PrivateAddress/Title", + case 32: pValues[nProp] >>= m_aItem.m_aPrivProfession; break;// "PrivateAddress/Profession", + case 33: pValues[nProp] >>= m_aItem.m_aPrivPhone; break;// "PrivateAddress/Phone", + case 34: pValues[nProp] >>= m_aItem.m_aPrivMobile; break;// "PrivateAddress/Mobile", + case 35: pValues[nProp] >>= m_aItem.m_aPrivFax; break;// "PrivateAddress/Fax", + case 36: pValues[nProp] >>= m_aItem.m_aPrivWWW; break;// "PrivateAddress/WebAddress", + case 37: pValues[nProp] >>= m_aItem.m_aPrivMail; break;// "PrivateAddress/Email", + case 38: pValues[nProp] >>= m_aItem.m_aCompCompany; break;// "BusinessAddress/Company", + case 39: pValues[nProp] >>= m_aItem.m_aCompCompanyExt; break;// "BusinessAddress/CompanyExt", + case 40: pValues[nProp] >>= m_aItem.m_aCompSlogan; break;// "BusinessAddress/Slogan", + case 41: pValues[nProp] >>= m_aItem.m_aCompStreet; break;// "BusinessAddress/Street", + case 42: pValues[nProp] >>= m_aItem.m_aCompZip; break;// "BusinessAddress/Zip", + case 43: pValues[nProp] >>= m_aItem.m_aCompCity; break;// "BusinessAddress/City", + case 44: pValues[nProp] >>= m_aItem.m_aCompCountry; break;// "BusinessAddress/Country", + case 45: pValues[nProp] >>= m_aItem.m_aCompState; break;// "BusinessAddress/State", + case 46: pValues[nProp] >>= m_aItem.m_aCompPosition; break;// "BusinessAddress/Position", + case 47: pValues[nProp] >>= m_aItem.m_aCompPhone; break;// "BusinessAddress/Phone", + case 48: pValues[nProp] >>= m_aItem.m_aCompMobile; break;// "BusinessAddress/Mobile", + case 49: pValues[nProp] >>= m_aItem.m_aCompFax; break;// "BusinessAddress/Fax", + case 50: pValues[nProp] >>= m_aItem.m_aCompWWW; break;// "BusinessAddress/WebAddress", + case 51: pValues[nProp] >>= m_aItem.m_aCompMail; break;// "BusinessAddress/Email", + case 52: pValues[nProp] >>= m_aItem.m_sGlossaryGroup; break;// "AutoText/Group" + case 53: pValues[nProp] >>= m_aItem.m_sGlossaryBlockName; break;// "AutoText/Block" + } + } + } + } + + if(m_bIsLabel || !bNoConfigValues) + return; + + SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions(); + m_aItem.m_aPrivFirstName = rUserOpt.GetFirstName(); + m_aItem.m_aPrivName = rUserOpt.GetLastName(); + m_aItem.m_aPrivShortCut = rUserOpt.GetID(); + m_aItem.m_aCompCompany = rUserOpt.GetCompany(); + m_aItem.m_aCompStreet = m_aItem.m_aPrivStreet = rUserOpt.GetStreet(); + + m_aItem.m_aCompCountry = m_aItem.m_aPrivCountry = rUserOpt.GetCountry(); + m_aItem.m_aCompZip = m_aItem.m_aPrivZip= rUserOpt.GetZip(); + m_aItem.m_aCompCity = m_aItem.m_aPrivCity = rUserOpt.GetCity(); + m_aItem.m_aPrivTitle = rUserOpt.GetTitle(); + m_aItem.m_aCompPosition = rUserOpt.GetPosition(); + m_aItem.m_aPrivPhone = rUserOpt.GetTelephoneHome(); + m_aItem.m_aCompPhone = rUserOpt.GetTelephoneWork(); + m_aItem.m_aCompFax = m_aItem.m_aPrivFax = rUserOpt.GetFax(); + m_aItem.m_aCompMail = m_aItem.m_aPrivMail = rUserOpt.GetEmail(); + m_aItem.m_aCompState = m_aItem.m_aPrivState = rUserOpt.GetState(); + m_aItem.m_bSynchron = true; + SetModified(); + +} + +void SwLabCfgItem::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwLabCfgItem::ImplCommit() +{ + Sequence aNames = GetPropertyNames(); + Sequence aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0, nProperty = 0; nProp < aNames.getLength(); nProp++, nProperty++) + { + //to have a continuous switch an offset is added + if(nProp == 17 && !m_bIsLabel) + nProperty += 3; + switch(nProperty) + { + case 0: pValues[nProp] <<= m_aItem.m_bCont; break;// "Medium/Continuous", + case 1: pValues[nProp] <<= m_aItem.m_aMake; break;// "Medium/Brand", + case 2: pValues[nProp] <<= m_aItem.m_aType; break;// "Medium/Type", + case 3: pValues[nProp] <<= m_aItem.m_nCols; break;// "Format/Column", + case 4: pValues[nProp] <<= m_aItem.m_nRows; break;// "Format/Row", + case 5: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lHDist));break;// "Format/HorizontalDistance", + case 6: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lVDist));break;// "Format/VerticalDistance", + case 7: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lWidth)); break;// "Format/Width", + case 8: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lHeight)); break;// "Format/Height", + case 9: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lLeft)); break;// "Format/LeftMargin", + case 10: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lUpper)); break;// "Format/TopMargin", + case 11: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lPWidth)); break;// "Format/Page Width", + case 12: pValues[nProp] <<= static_cast(convertTwipToMm100(m_aItem.m_lPHeight)); break;// "Format/PageHeight", + case 13: pValues[nProp] <<= m_aItem.m_bSynchron; break;// "Option/Synchronize", + case 14: pValues[nProp] <<= m_aItem.m_bPage; break;// "Option/Page", + case 15: pValues[nProp] <<= m_aItem.m_nCol; break;// "Option/Column", + case 16: pValues[nProp] <<= m_aItem.m_nRow; break;// "Option/Row" + case 17: pValues[nProp] <<= m_aItem.m_bAddr; break;// "Inscription/UseAddress", + case 18: pValues[nProp] <<= m_aItem.m_aWriting; break;// "Inscription/Address", + case 19: pValues[nProp] <<= m_aItem.m_sDBName; break;// "Inscription/Database" + case 20: pValues[nProp] <<= m_aItem.m_aPrivFirstName; break;// "PrivateAddress/FirstName", + case 21: pValues[nProp] <<= m_aItem.m_aPrivName; break;// "PrivateAddress/Name", + case 22: pValues[nProp] <<= m_aItem.m_aPrivShortCut; break;// "PrivateAddress/ShortCut", + case 23: pValues[nProp] <<= m_aItem.m_aPrivFirstName2; break;// "PrivateAddress/SecondFirstName", + case 24: pValues[nProp] <<= m_aItem.m_aPrivName2; break;// "PrivateAddress/SecondName", + case 25: pValues[nProp] <<= m_aItem.m_aPrivShortCut2; break;// "PrivateAddress/SecondShortCut", + case 26: pValues[nProp] <<= m_aItem.m_aPrivStreet; break;// "PrivateAddress/Street", + case 27: pValues[nProp] <<= m_aItem.m_aPrivZip; break;// "PrivateAddress/Zip", + case 28: pValues[nProp] <<= m_aItem.m_aPrivCity; break;// "PrivateAddress/City", + case 29: pValues[nProp] <<= m_aItem.m_aPrivCountry; break;// "PrivateAddress/Country", + case 30: pValues[nProp] <<= m_aItem.m_aPrivState; break;// "PrivateAddress/State", + case 31: pValues[nProp] <<= m_aItem.m_aPrivTitle; break;// "PrivateAddress/Title", + case 32: pValues[nProp] <<= m_aItem.m_aPrivProfession; break;// "PrivateAddress/Profession", + case 33: pValues[nProp] <<= m_aItem.m_aPrivPhone; break;// "PrivateAddress/Phone", + case 34: pValues[nProp] <<= m_aItem.m_aPrivMobile; break;// "PrivateAddress/Mobile", + case 35: pValues[nProp] <<= m_aItem.m_aPrivFax; break;// "PrivateAddress/Fax", + case 36: pValues[nProp] <<= m_aItem.m_aPrivWWW; break;// "PrivateAddress/WebAddress", + case 37: pValues[nProp] <<= m_aItem.m_aPrivMail; break;// "PrivateAddress/Email", + case 38: pValues[nProp] <<= m_aItem.m_aCompCompany; break;// "BusinessAddress/Company", + case 39: pValues[nProp] <<= m_aItem.m_aCompCompanyExt; break;// "BusinessAddress/CompanyExt", + case 40: pValues[nProp] <<= m_aItem.m_aCompSlogan; break;// "BusinessAddress/Slogan", + case 41: pValues[nProp] <<= m_aItem.m_aCompStreet; break;// "BusinessAddress/Street", + case 42: pValues[nProp] <<= m_aItem.m_aCompZip; break;// "BusinessAddress/Zip", + case 43: pValues[nProp] <<= m_aItem.m_aCompCity; break;// "BusinessAddress/City", + case 44: pValues[nProp] <<= m_aItem.m_aCompCountry; break;// "BusinessAddress/Country", + case 45: pValues[nProp] <<= m_aItem.m_aCompState; break;// "BusinessAddress/State", + case 46: pValues[nProp] <<= m_aItem.m_aCompPosition; break;// "BusinessAddress/Position", + case 47: pValues[nProp] <<= m_aItem.m_aCompPhone; break;// "BusinessAddress/Phone", + case 48: pValues[nProp] <<= m_aItem.m_aCompMobile; break;// "BusinessAddress/Mobile", + case 49: pValues[nProp] <<= m_aItem.m_aCompFax; break;// "BusinessAddress/Fax", + case 50: pValues[nProp] <<= m_aItem.m_aCompWWW; break;// "BusinessAddress/WebAddress", + case 51: pValues[nProp] <<= m_aItem.m_aCompMail; break;// "BusinessAddress/Email", + case 52: pValues[nProp] <<= m_aItem.m_sGlossaryGroup; break;// "AutoText/Group" + case 53: pValues[nProp] <<= m_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 0000000000..715d769633 --- /dev/null +++ b/sw/source/uibase/envelp/syncbtn.cxx @@ -0,0 +1,86 @@ +/* -*- 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 +#include +#include + +#include +#include +#include +#include + +#include + +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(pBindings, this, _pParent->GetFrameWeld())); + SwSyncBtnDlg* pBtnDlg = static_cast(GetController().get()); + + if (!pInfo->aSize.Width() || !pInfo->aSize.Height()) + { + weld::Dialog* pDlg = pBtnDlg->getDialog(); + Point aPos; + + if (SwView* pActiveView = GetActiveView()) + { + const SwEditWin &rEditWin = pActiveView->GetEditWin(); + aPos = rEditWin.OutputToScreenPixel(Point(0, 0)); + } + else + aPos = _pParent->OutputToScreenPixel(Point(0, 0)); + + vcl::WindowData aState; + aState.setMask(vcl::WindowDataMask::Pos); + aState.setPos(aPos); + 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) +{ + if (SfxViewFrame* pViewFrm = SfxViewFrame::Current()) + pViewFrm->GetDispatcher()->Execute(FN_UPDATE_ALL_LINKS, SfxCallMode::ASYNCHRON); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3