summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorhomeboy445 <akshitsan13@gmail.com>2021-04-12 20:31:05 +0530
committerIlmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>2021-10-29 13:46:12 +0200
commitd37a44a9ebdafec1435f98194417a1d8cc8208b5 (patch)
treede021550906549b9ae78d95cef8329bc6afc7a17 /xmloff
parent31315fea28ad327f36c0e593156bf808c7af3467 (diff)
tdf#141193 Added support for bar codes in qrcode dialog box[API Change].
Change-Id: I6b79ece1d5419ef92b76755d3bd921a64d6e38fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113989 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/draw/QRCodeContext.cxx27
-rw-r--r--xmloff/source/draw/shapeexport.cxx27
-rw-r--r--xmloff/source/token/tokens.txt1
4 files changed, 33 insertions, 23 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 52ecd9038cbb..704f374a5026 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1563,6 +1563,7 @@ namespace xmloff::token {
TOKEN( "qrcode", XML_QRCODE ),
TOKEN( "qrcode-border", XML_QRCODE_BORDER ),
TOKEN( "qrcode-errorcorrection", XML_QRCODE_ERROR_CORRECTION ),
+ TOKEN( "qrcode-type", XML_QRCODE_TYPE ),
TOKEN( "quarter", XML_QUARTER ),
TOKEN( "query-name", XML_QUERY_NAME ),
TOKEN( "quo-vadis", XML_QUO_VADIS ),
diff --git a/xmloff/source/draw/QRCodeContext.cxx b/xmloff/source/draw/QRCodeContext.cxx
index f217fcf17ffa..597838f78cad 100644
--- a/xmloff/source/draw/QRCodeContext.cxx
+++ b/xmloff/source/draw/QRCodeContext.cxx
@@ -13,8 +13,8 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
-#include <com/sun/star/drawing/QRCode.hpp>
-#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
+#include <com/sun/star/drawing/BarCode.hpp>
+#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <xmloff/xmltoken.hxx>
@@ -42,7 +42,7 @@ QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_Int32 /*nElement*/,
{
Reference<beans::XPropertySet> xPropSet(rxShape, UNO_QUERY_THROW);
- css::drawing::QRCode aQRCode;
+ css::drawing::BarCode aBarCode;
for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
{
@@ -53,32 +53,39 @@ QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_Int32 /*nElement*/,
OUString aErrorCorrValue = aIter.toString();
if (aErrorCorrValue == "low")
- aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::LOW;
+ aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::LOW;
else if (aErrorCorrValue == "medium")
- aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::MEDIUM;
+ aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::MEDIUM;
else if (aErrorCorrValue == "quartile")
- aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::QUARTILE;
+ aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::QUARTILE;
else
- aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::HIGH;
+ aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::HIGH;
break;
}
case XML_ELEMENT(LO_EXT, XML_QRCODE_BORDER):
{
sal_Int32 nAttrVal;
if (sax::Converter::convertNumber(nAttrVal, aIter.toView(), 0))
- aQRCode.Border = nAttrVal;
+ aBarCode.Border = nAttrVal;
break;
}
case XML_ELEMENT(OFFICE, XML_STRING_VALUE):
{
- aQRCode.Payload = aIter.toString();
+ aBarCode.Payload = aIter.toString();
+ break;
+ }
+ case XML_ELEMENT(LO_EXT, XML_QRCODE_TYPE):
+ {
+ sal_Int32 nAttrVal;
+ if (sax::Converter::convertNumber(nAttrVal, aIter.toView(), 0))
+ aBarCode.Type = nAttrVal;
break;
}
default:
XMLOFF_WARN_UNKNOWN("xmloff", aIter);
}
}
- xPropSet->setPropertyValue("QRCodeProperties", Any(aQRCode));
+ xPropSet->setPropertyValue("BarCodeProperties", Any(aBarCode));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index fd22a4dca5a2..dbd52fadd1d1 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -59,8 +59,8 @@
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/drawing/XCustomShapeEngine.hpp>
#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
-#include <com/sun/star/drawing/QRCode.hpp>
-#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
+#include <com/sun/star/drawing/BarCode.hpp>
+#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/XShapes3.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XStorage.hpp>
@@ -1370,33 +1370,34 @@ void XMLShapeExport::ImpExportQRCode(const uno::Reference<drawing::XShape>& xSha
{
uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
- uno::Any aAny = xPropSet->getPropertyValue("QRCodeProperties");
+ uno::Any aAny = xPropSet->getPropertyValue("BarCodeProperties");
- css::drawing::QRCode aQRCode;
- if(!(aAny >>= aQRCode))
+ css::drawing::BarCode aBarCode;
+ if(!(aAny >>= aBarCode))
return;
- mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aQRCode.Payload);
+ mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aBarCode.Payload);
/* Export QR Code as per customised schema, @see OpenDocument-schema-v1.3+libreoffice */
OUString temp;
- switch(aQRCode.ErrorCorrection){
- case css::drawing::QRCodeErrorCorrection::LOW :
+ switch(aBarCode.ErrorCorrection){
+ case css::drawing::BarCodeErrorCorrection::LOW :
temp = "low";
break;
- case css::drawing::QRCodeErrorCorrection::MEDIUM:
+ case css::drawing::BarCodeErrorCorrection::MEDIUM:
temp = "medium";
break;
- case css::drawing::QRCodeErrorCorrection::QUARTILE:
+ case css::drawing::BarCodeErrorCorrection::QUARTILE:
temp = "quartile";
break;
- case css::drawing::QRCodeErrorCorrection::HIGH:
+ case css::drawing::BarCodeErrorCorrection::HIGH:
temp = "high";
break;
}
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_ERROR_CORRECTION, temp);
- mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUString::number(aQRCode.Border));
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUStringBuffer(20).append(aBarCode.Border).makeStringAndClear());
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_TYPE, OUStringBuffer(20).append(aBarCode.Type).makeStringAndClear());
- SvXMLElementExport aQRCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true,
+ SvXMLElementExport aBarCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true,
true);
}
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 395dffe62cf1..6e34ec554fab 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1463,6 +1463,7 @@ pyramid
qrcode
qrcode-border
qrcode-errorcorrection
+qrcode-type
quarter
query-name
quo-vadis