OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

QR Codes [SOLVED]

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
warrisr
General User
General User


Joined: 21 Oct 2006
Posts: 8

PostPosted: Wed Apr 27, 2011 6:22 pm    Post subject: QR Codes [SOLVED] Reply with quote

Has anyone ever run across a way to generate QR Codes in Calc?

Last edited by warrisr on Thu Apr 28, 2011 9:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
james_h
Super User
Super User


Joined: 05 Nov 2005
Posts: 883

PostPosted: Thu Apr 28, 2011 12:16 am    Post subject: How to generate QR Code of selected text in OpenOffice.org Reply with quote

If you are using LInux, you can use your package manager to install a program that will generate QR Codes * called qrencode. See this article for more information.

If you are using a different operating system, and you are online, you can use Google Chart to create QR Codes. The form of the URL is like this:

http://chart.apis.google.com/chart?chs=350x350&cht=qr&chl=Has%20anyone%20ever%20run%20across%20a%20way%20to%20generate%20QR%20Codes%20in%20Calc%3F

For information about how to integrate the Google Chart QR Code web application with OpenOffice.org, read the section entitled "Google chart API (QR Code)" in this article.

I wrote an extension called Read Text Extension that can use an external program or a web service to read selected text. Although it is mostly used for speech synthesis, it can easily be used to generate QR Codes. You can download it for free at the OpenOffice.org extensions site. If you installed qrencode, the option for creating qrencode will automatically appear in the under Read with an External Program under the command line options field with "(CREATE_QR_LABEL_PY)". Otherwise, if you have a web connection, choose http://chart.apis.google.com/chart?chs=350x350&cht=qr&chl=(OOO_WEBTEXT) under the web option.



Quote:
* QR Code is registered trademark of DENSO WAVE INCORPORATED in the following countries: Japan, United States of America, Australia and Europe.
Back to top
View user's profile Send private message
warrisr
General User
General User


Joined: 21 Oct 2006
Posts: 8

PostPosted: Thu Apr 28, 2011 3:24 am    Post subject: Reply with quote

Thank you for your reply. However if I understand your solution correctly, it is not quite what I had in mind.

What I was looking for was a way to have a QR Code embedded into the spreadsheet based on text that was entered into a cell. Kind of like using a barcode font that displays a barcode based on the text entered into a cell formatted with the font.
Back to top
View user's profile Send private message
james_h
Super User
Super User


Joined: 05 Nov 2005
Posts: 883

PostPosted: Thu Apr 28, 2011 5:56 pm    Post subject: Sub ConvertTextToQRCode Reply with quote

Code:
'The term QR code is a registered trademark of Denso Wave Incorporated
'This is a quick and dirty way to embed a Google Charts QR Code into a Calc Doc.
'(c) 2011 James Holgate Vancouver,CANADA(james_h(a)http://openofficeforum.org)
' <http://www.gnu.org/licenses/gpl-2.0.txt>
' THIS IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS
' OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
' EITHER VERSION 2 OF THE LICENSE,OR(AT YOUR OPTION)ANY LATER VERSION. THIS SCRIPT
' IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,BUT WITHOUT ANY WARRANTY;
' WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
' SEE THE GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS.

' YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE ALONG WITH THIS SOFTWARE;
' IF NOT,WRITE TO THE FREE SOFTWARE FOUNDATION,INC.,59 TEMPLE PLACE,SUITE 330,BOSTON,MA
' 02111-1307  USA

Sub ConvertTextToQRCode 
   rem define variables
   dim s1 as String
   dim document   as object
   dim dispatcher as object
   s1=fsRetrieveCalcActiveCellProperty("text")
   s1=InputBox ("Enter text to convert:", "QR Code", s1)
   if s1 <> "" then
      document   = ThisComponent.CurrentController.Frame
      dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
      dim args3(2) as new com.sun.star.beans.PropertyValue
      args3(0).Name = "FileName"
      args3(0).Value = "http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=" & s1
      args3(1).Name = "FilterName"
      args3(1).Value = "<All formats>"
      args3(2).Name = "AsLink"
      args3(2).Value = false
      dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args3())
   endif
end sub

Function fsRetrieveCalcActiveCellProperty(strA) As String
   ' Modified from Sub from: Paolo Mantovani
   ' email: mantovani.paolo@tin.it
   ' published at http://sourceforge.net/projects/ooomacros/files/Andrew%20Pitonyak_s%20Macro%20Doc/2006-01-25/AndrewMacro_2006-01-25.zip/download
   ' Gets property of the active cell.
   Dim oOldSelection 'The original selection of cell ranges
   Dim oRanges       'A blank range created by the document
   Dim oActiveCell   'The current active cell
   Dim sCellContent As String
   
   REM store the current selection
   oOldSelection=ThisComponent.CurrentSelection
   oRanges=ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
   ThisComponent.CurrentController.Select(oRanges)
   'get the active cell!
   oActiveCell=ThisComponent.CurrentSelection
   Select Case strA
   Case "country"
       sCellContent=oActiveCell.CharLocale.Country 
   Case "language"
       sCellContent=oActiveCell.CharLocale.Language
   Case Else
       sCellContent=oActiveCell.getString()
   End Select
   'restore the old selection (but loosing the previous active cell)
   ThisComponent.CurrentController.Select(oOldSelection)
      fsRetrieveCalcActiveCellProperty=sCellContent
End Function
Back to top
View user's profile Send private message
warrisr
General User
General User


Joined: 21 Oct 2006
Posts: 8

PostPosted: Thu Apr 28, 2011 9:26 pm    Post subject: Reply with quote

Fantastic!

That is exactly what I was looking for. Thank you very much for taking the time to put this together for me. I am sure others will find it useful as well.
Back to top
View user's profile Send private message
james_h
Super User
Super User


Joined: 05 Nov 2005
Posts: 883

PostPosted: Fri Apr 29, 2011 9:27 pm    Post subject: Reply with quote

I am glad it was useful to you. I felt a little uncomfortable dashing out a quick and dirty solution.

The GPL 3 allowed me to modify and redistribute an existing openoffice.org extension. The modified copy corrects a couple of things in the original code. For example, question marks, the plus sign, and ampersand are all translated correctly.

I advised the extension's original author of the changes by email, so he will be able to incorporate them in a new release of the Chart2d.oxt software.


Last edited by james_h on Fri May 06, 2011 9:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
Lodahl
General User
General User


Joined: 20 Feb 2007
Posts: 10
Location: Denmark

PostPosted: Wed May 04, 2011 6:06 am    Post subject: Reply with quote

The solution is now implemented ind the Char2D extension.

If you create a function in the Standard Library in "My macros" with the folloing code, you can actually launch it from within a formula
Code:

Function InsertImage(DataContent, Optional Size, Optional Encode)
   'print Size & DataContent & Encode
   DataContent=fsEscapeStr(DataContent)

   If IsMissing(Size) Then
    Size = "150x150"
    End If
   
    If IsMissing(Encode) Then
    Encode = "ISO-8859-1"
    End If
   
   ImgUrl = ConvertToURL("http://chart.apis.google.com/chart?chs=" & Size & "&cht=qr&chl=" & DataContent & "&choe=" & Encode)
   'ImgUrl ="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=Hello%20world&choe=UTF-8"
   rem ----------------------------------------------------------------------
   rem define variables
   dim document   as object
   dim dispatcher as object
   rem ----------------------------------------------------------------------
   rem get access to the document
   document   = ThisComponent.CurrentController.Frame
   dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
   
   rem ----------------------------------------------------------------------
   dim args1(3) as new com.sun.star.beans.PropertyValue
   args1(0).Name = "FileName"
   args1(0).Value = ImgUrl
   args1(1).Name = "FilterName"
   args1(1).Value = "<All formats>"
   args1(2).Name = "AsLink"
   args1(2).Value = false
   args1(3).Name = "Style"
   args1(3).Value = "Grafik"
   
   'dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())
   
   rem ----------------------------------------------------------------------
   InsertImage=dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())

end function


Simply write =InsertImage("Hello world") in a cell and you will automatically get a GR barcode generated.

Optional parameters are Size and Encoding.
_________________
------------------------
Leif Lodahl
DA.libreoffice.org
http://blog.magenta-aps.dk/author/leif/
------------------------
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
james_h
Super User
Super User


Joined: 05 Nov 2005
Posts: 883

PostPosted: Fri May 06, 2011 9:43 pm    Post subject: Thanks to Leif Lodahl for updating extension quickly Reply with quote

The 2D Code extension hosted at the openoffice.org web site is the most recent version. I have no intention of forking the extension. If you want to download the extension, I recommend you download the most recent version from the Openoffice.org extensions site.

It should be obvious from the code and the notes that the operation of the code snippets and of the extension depends on a connection to the Internet. Google Charts API is used to convert text to code.

Thanks again to Leif Lodahl for updating the extension quickly and for making this great extension available with a GPL license.
Back to top
View user's profile Send private message
homedog
Newbie
Newbie


Joined: 08 Jul 2013
Posts: 1

PostPosted: Mon Jul 08, 2013 11:23 pm    Post subject: Reply with quote

Can I ask a QR Code creation question here? I want to create some QR Codes in Java. But I found two types of barcode generators. One is Java Servlet barcode generator library and another one is Java Class barcode generator library. What's difference between them? I am new to this. My boss give his assignment to me. Thanks for any of your reactions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group