Hello please help to translate the next line of basic code to Delphi for the OOoTools.pas interface.
oChart.Diagram.SymbolType = com.sun.star.chart.ChartSymbolType.SYMBOL1
I know that the SYMBOL1 part is an enumeration and I think I have to use the MakePropertyValue fumction but how?
Have you tried the simpler: oChart.Diagram.SymbolType := SYMBOL1;Just my first shot, btw.
Related
I am building a clang plugin, and I am trying to generate the AST for a C fragment at some point within the plugin. Something like:
std::string c_code = "...";
getAST(c_code);
Can someone point me to, how to go about this?
May be there are several ways to achieve this, but finally I got the following snippet working and to me it looks simple enough:
//arguments to the compiler
std::unique_ptr <std::vector<const char*>> args(new std::vector<const char*>());
args->push_back("my_file.c");
//do the magic
ASTUnit *au = ASTUnit::LoadFromCommandLine(
&(*args)[0],
&(*args)[0] + args->size(),
IntrusiveRefCntPtr<DiagnosticsEngine>(
CompilerInstance::createDiagnostics(new DiagnosticOptions)),
StringRef()
);
//get the translation unit node
Declr *d = au->getASTContext().getTranslationUnitDecl();
Simpler alternatives or suggestions to improve this are welcome.
I don't have a code snipped ready to copy-paste, but the idea that I used before is the following:
Note that clang_parseTranslationUnit has unsaved_files as one of the arguments. So the idea would be to provide a command line g++ main.cpp, and then provide an unsaved file with name main.cpp and the content from your string.
I am using Delphi and I need to prepare some documentation. One of possible solutions to that is to use Doxygen with Pas2Dox filter.
I am currently using pas2dox-0.50rc1.exe filter and Doxygen wizard 1.8.3.1. I am struggling to setup Doxygen properly to display my comments in Delphi but the thing is that I am not sure anymore what is the proper comment format in Delphi. I searched interenet but I can't find any tutorial or example on how to succesfully generate html documentation with delphi.
Is there maybe somebody who can share me some tips how to achieve that?
My current comments are as:
{*------------------------------------------------------------------------------
test
#param AGraphicsOwner ParameterDescription
#param ASettingsPath ParameterDescription
#param AEngineType ParameterDescription
#return ResultDescription
------------------------------------------------------------------------------*}
constructor TBaseEngine.Create(AGraphicsOwner: HWND;
ASettingsPath: PAnsiChar;
AEngineType: byte);
THANKS!!
I succeeded in creating a nice doxygen documentation with comments formated exactly like yours on my delphi code!
Here is how:
Replace all not-doxygen comments with // :
instead of
(* comment *) or { comment }
have
// comment
Why? According to this blog entry for the pas2dox filter it is crucial not to use (* and *) for commentaries in your delphi file. Furthermore simple one-line commentaries embraced by { and } seem to destroy the doxygen documentation as well.
Put the methods you want to see documented in doxygen into the INTERFACE section:
Only the methods "declared" in the INTERFACE section will be visible in doxygen (I have not quite figured out why, yet)
I tested it with a file that had all types of delphi comment-styles. I replaced the comment-idicators with notepad++'s replace-all function in the following order (I am completely sure there is a more elegant way to do that, but for me it was handy):
replace { with //
replace //$ with {$
replace (* with //
after that, all methods (in the INTERFACE section) appeared in doxygen and I started to comment using the doxygen style from above. I left away the ---, but I don't think this should be an issue =)
I was using search engine and not just here, and got tired of it; just want a simple answer (or a link) for a simple question:
How do I open a calc sheet and write 123 into cell A1 from Delphi (7) code? (Or any hello worlds for calc?)
You can take a look at this demo:
http://sourceforge.net/projects/ooomacros/files/Delphi%20OOo/Version%201.2/Delphi_OOo_v12en.zip/download
I tested the Document part a month ago (which works), and I there is also some spreadsheet code in the examples.pas.
Ok, after some research and using the informations above for I thank yas a lot, here is a simple answer:
uses part
Uses ComObj, OOoMessages, OOoTools, OOoConstants, OOoXray;
main code
open blank document, write 'hello 123' text into a1 then save it on desktop
procedure HelloWorldExample;
var
mentesiOpciok,oSheet,oSheets,myCalc : Variant;
begin
ConnectOpenOffice;
myCalc:=StarDesktop.loadComponentFromURL('private:factory/scalc', '_blank', 0, dummyArray);
oSheets:=myCalc.getSheets;
oSheet:=oSheets.getByIndex(0);
//oSheet.getCellByPosition(0, 0).SetValue(123);
oSheet.getCellByPosition(0, 0).SetFormula('hello 123!');
mentesiOpciok:=CreateProperties(['FilterName', 'MS Excel 97']);
myCalc.storeToURL('file:///C:/Documents and Settings/Zéiksz/Asztal/calcdoc.xls', mentesiOpciok);
showMessage('kész :)');
myCalc.close(true);
DisconnectOpenOffice();
end;
use getcellbyposition(...).setvalue to set numeric values, or setformula for strings (not really sure, but there is a string in it LOL).
Péter
edit: most useful information I found on the Internet is in this forum:
http://www.oooforum.org/forum/viewtopic.phtml?t=4996
I'm using Delphi 7 and I'd like to export the contents of a list from my program to OpenOffice Calc using automation, instead of using files.
The task is simple: create new document, iterate through rows/columns and change cell data.
I've found some code but it's not complete, and I was hoping someone has some example code ready to accomplish this very simple task. It could save me a few hours of trying.
Thanks in advance!
Edit: I'd like to automate OpenOffice Calc to achieve what I wrote above. Thanks!
The easiest solution is to write CSV file output, and open that in OpenOffice.
There are also libraries to write .XLS files which both OpenOffice Calc and Excel can read. CSV is so simple, I wonder that you need an example. Create a TStringList, and add strings to it, in comma separated format. Save to file.
The so called "programmatic" method involves OLE automation.
uses
OleAuto;
var
mgr,calc,sheets,sheet1,dt,args:Variant;
begin
args = VarArrayCreate(...);
mgr := CreateOleObject('com.sun.star.ServiceManager');
dt := mgr.createInstance('com.sun.star.frame.Desktop')
calc = dt.loadComponentFromURL('private:factory/scalc', '_blank', 0, args)
sheets = calc.getSheets()
sheet1 = sheets.getByIndex(0)
...
Open Office supports Automation
see: http://udk.openoffice.org/common/man/tutorial/office_automation.html
Open Office info for Delphi can be found at:
http://development.openoffice.org/#OLE
The site ooomacros.org seems to be down, luckily the wayback machine still has a copy:
http://replay.web.archive.org/20090608051118/http://www.ooomacros.org/dev.php
Good luck.
I know as a programmer that is rare for someone to do, but I actually need it and can not at all so someone needs to convert this small function cryptography python for delphi.
function: `
from Crypto.Cipher import Blowfish
class Blowfish(object):
cipher = None
def __init__(self, key, mode = Blowfish.MODE_ECB):
self.cipher = Blowfish.new(key, mode)
def encrypt(self, texto):
encriptar = self.cipher.encrypt(texto)
return encriptar `
-
one example
key = 123key
text = hi man
result = ìûÕ]–•¢
I people much times because I tried to do in Delphi and always shows me different results then do better and ask for someone who understands python / delphi
thank so much!
For the comment on DCPcrypt, maybe your python library results the raw encrypted bytes, and the result of DCPcrypt (or other delphi library like Turbo Lockbox) gives you the result encoded in something like UU64 o MIME (this is done to easily transfer o store the result)
If you just want to implement Blowfish algorithm in Delphi, try DCPcrypt.
#Mili, you can't translate this code to delphi because does not exist a RTL library (or function) in delphi with blowfish support, dou you need use a third party component for this. i recommend you the
Delphi Encryption Compedium Part I v.5.2. you can try out this link for more components.
You can also try TurboPower LockBox 3.1.0 at http://lockbox.seanbdurkin.id.au/ .
This library also implements Blowfish.