22#include <config_folders.h>
26#include <rtl/bootstrap.hxx>
31#include <osl/diagnose.h>
34#include <com/sun/star/beans/PropertyValue.hpp>
46 assert(res == xmlreader::XmlReader::Result::End);
57 assert(res == xmlreader::XmlReader::Result::Begin &&
name == span);
58 res = reader.
nextItem(xmlreader::XmlReader::Text::Raw, &
name, &nsId);
59 assert(res == xmlreader::XmlReader::Result::Text);
60 (void) res; (void) span;
61 OUString sTmp =
name.convertFromUtf8();
68 return { OUString::Concat(rPrefix) +
"Name", OUString::Concat(rPrefix) +
"Measure" };
74 OUString uri(
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/labels/labels.xml");
75 rtl::Bootstrap::expandMacros(uri);
80 OUString sManufacturer;
88 res == xmlreader::XmlReader::Result::Begin
89 &&
name ==
"manufacturers");
92 while (res != xmlreader::XmlReader::Result::End)
96 res == xmlreader::XmlReader::Result::Begin
97 &&
name ==
"manufacturer");
109 if (res == xmlreader::XmlReader::Result::End)
112 res == xmlreader::XmlReader::Result::Begin
131 assert(res == xmlreader::XmlReader::Result::Done);
134 const Sequence<OUString>& rMan =
GetNodeNames( OUString() );
135 for (
const OUString& rManufacturer : rMan )
137 const Sequence<OUString> aLabels =
GetNodeNames( rManufacturer );
138 for(
const OUString& rLabel : aLabels )
140 OUString
sPrefix = rManufacturer +
"/" + rLabel +
"/";
144 if (aValues.getLength() >= 1)
147 if (aValues.getLength() >= 2)
167static std::unique_ptr<SwLabRec>
lcl_CreateSwLabRec(
const OUString& rType, std::u16string_view rMeasure,
const OUString& rManufacturer)
169 std::unique_ptr<SwLabRec> pNewRec(
new SwLabRec);
170 pNewRec->m_aMake = rManufacturer;
171 pNewRec->m_nPWidth = 0;
172 pNewRec->m_nPHeight = 0;
173 pNewRec->m_aType = rType;
177 sal_Int32 nIdx{rMeasure.empty() ? -1 : 0};
180 const std::u16string_view sToken(
o3tl::getToken(rMeasure, 0,
';', nIdx));
184 case 0 : pNewRec->m_bCont = sToken[0] ==
'C';
break;
191 case 7 : pNewRec->m_nCols = nVal;
break;
192 case 8 : pNewRec->m_nRows = nVal;
break;
198 if (pNewRec->m_nPWidth == 0 || pNewRec->m_nPHeight == 0)
201 pNewRec->m_nPWidth = 2 * pNewRec->m_nLeft + (pNewRec->m_nCols - 1) * pNewRec->m_nHDist + pNewRec->m_nWidth;
202 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 );
208 Sequence<OUString>
const & rPropNames, OUString& rMeasure,
const SwLabRec& rRec)
210 const OUString* pNames = rPropNames.getConstArray();
211 Sequence<PropertyValue> aRet(rPropNames.getLength());
212 PropertyValue*
pValues = aRet.getArray();
215 for(sal_Int32 nProp = 0; nProp < rPropNames.getLength(); nProp++)
217 pValues[nProp].Name = pNames[nProp];
224 rMeasure += rRec.
m_bCont ? std::u16string_view(
u"C" ) : std::u16string_view(
u"S" ); rMeasure +=
sColon;
231 rMeasure += OUString::number( rRec.
m_nCols ); rMeasure +=
sColon;
232 rMeasure += OUString::number( rRec.
m_nRows ); rMeasure +=
sColon;
235 pValues[nProp].Value <<= rMeasure;
248 for (
const auto& rEntry :
m_aLabels[rManufacturer])
249 rLabArr.push_back(
lcl_CreateSwLabRec(rEntry.first, rEntry.second.m_aMeasure, rManufacturer) );
261 const OUString& rType,
const SwLabRec& rRec )
264 bool bManufacturerNodeFound;
268 bManufacturerNodeFound =
false;
270 if ( !
AddNode( OUString(), rManufacturer ) )
272 OSL_FAIL(
"New configuration node could not be created");
278 bManufacturerNodeFound =
true;
280 if ( !bManufacturerNodeFound ||
284 const Sequence<OUString> aLabels =
GetNodeNames( rManufacturer );
285 sal_Int32
nIndex = aLabels.getLength();
297 const Sequence<OUString> aLabels =
GetNodeNames( sManufacturer );
298 for (
const OUString& rLabel : aLabels)
300 OUString
sPrefix = sManufacturer +
"/" + rLabel +
"/";
319 "/" + sFoundNode +
"/";
326 m_aLabels[rManufacturer][rType].m_aMeasure = sMeasure;
327 m_aLabels[rManufacturer][rType].m_bPredefined =
false;
const PropertyValue * pValues
PropertiesInfo aProperties
constexpr auto convertTwipToMm100(N n)
void SaveLabel(const OUString &rManufacturer, const OUString &rType, const SwLabRec &rRec)
bool HasLabel(const OUString &rManufacturer, const OUString &rType)
virtual ~SwLabelConfig() override
std::vector< OUString > m_aManufacturers
std::map< OUString, std::map< OUString, SwLabelMeasure > > m_aLabels
void FillLabels(const OUString &rManufacturer, SwLabRecs &rLabArr)
virtual void ImplCommit() override
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
static bool SetSetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, const css::uno::Sequence< css::beans::PropertyValue > &rValues)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
bool AddNode(const OUString &rNode, const OUString &rNewNode)
static css::uno::Sequence< OUString > GetNodeNames(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, ConfigNameFormat eFormat)
Result nextItem(Text reportText, Span *data, int *nsId)
bool nextAttribute(int *nsId, Span *localName)
Span getAttributeValue(bool fullyNormalize)
constexpr OStringLiteral sColon
static std::unique_ptr< SwLabRec > lcl_CreateSwLabRec(const OUString &rType, std::u16string_view rMeasure, const OUString &rManufacturer)
static void lcl_assertEndingItem(xmlreader::XmlReader &reader)
static Sequence< PropertyValue > lcl_CreateProperties(Sequence< OUString > const &rPropNames, OUString &rMeasure, const SwLabRec &rRec)
static Sequence< OUString > lcl_CreatePropertyNames(const OUString &rPrefix)
static OUString lcl_getValue(xmlreader::XmlReader &reader, const xmlreader::Span &span)
std::vector< std::unique_ptr< SwLabRec > > SwLabRecs
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr auto toTwips(N number, Length from)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OUString wrapConfigurationElementName(std::u16string_view _sElementName)
const PropertyStruct aPropNames[]
rtl::OUString convertFromUtf8() const