Have created a Gtk "calculator" that has a spreadsheet-like element (similar to and partially based on GtkSheet/GtkExtra). It is capable of, amongst other things, using the usual Ctrl-X/C and Ctrl-V to Cut/Copy/Paste data/strings within itself, and also across to other apps, such as Excel/OpenOffice etc (i.e. in both directions) using GtkClipboard elements.
For example, it can also perform Cut/Copy/Past of ranges (though via a different route, and this in not in Python) discussed in this SO posting.
However, when an Excel, OpenOffice, etc cell contains a formula (and displays the formula's value ... eg. formula in cell =1+2, displays 3), copying the Cell into the proprietary Gtk-Spreadsheet via GtkClipboard only pastes/contains the "display value" (not the formula).
How does one get GtkClipboard to pass the formula instead? Does this require some GDKAtom specification, is it necessary to use gtk_clipboard_request_text() vs. _request_content() etc. and work through the "(Gtk) target", or ???
P.S. Copying, say, an Excel cell (with formula) to, say, an OpenOffice cell works correctly in that OO will contain the formula and display the result (though we cannot be certain if the formula is contained in the OS's clipboard, or if OO et al. are doing something extra). Is it presumptuous to imagine that GtkClipboard should be able to do it as well ... ?
UPDATE: Since the Original Post (OP), we have followed-up with some testing to further assess our "intuition" that perhaps the GtkClipboard or the Windows clipboard, or some combination therein, may not be capable of directly passing spreadsheet formulas (or "full" Cell contents) via Cut/Copy/Paste (CCP). Here are some results:
1) We tried to look at the OO, POI, etc source code to see how they do it, but it's much too big. We tried to look at GNumerics source code, but from our perspective, it uses a coding style that is much too difficult (at least for us) to follow.
2) So, we performed a few additional test to see if we could determine at least the possibility of relying on the OS/GtkClipboard. During these tests we also "kept an eye" on the Windows clipboard via clipbrd.exe (the Windows clipboard viewer (WCV)):
a) As before, when CCP from Excel to OO (and both apps are simultaneous running), everything is passed.
Though, WCV only shows the display value, not the formula or any other property of the cell (e.g. colours, etc)[Note: WCV can pass some colours etc if an image format is used, but not the explicit Cell "contents/formulas/properties" etc]. This is a bit worrying for Gtk, as it implies the passing of the formula etc is not actually via the (basic OS) clipboard.
b) When CCP in reverse, from OO to Excel (with both apps running), it does NOT work, only the display value is passed (no formula's, properties, etc).
Again, a bit worrying with respect to (wrt) GtkClipboard possibilities.
c) When the Copy is performed from Excel, but before OO is launched, and then Excel is closed, and the Paste after OO launched, it does NOT work for formula's etc, only the display value.
Again, a bit worrying wrt GtkClipboard possibilities.
d) Skipping some details to avoid diluting this point, our sense is that the (only) "successful" CCP (from Excel to OO while both are running) is somehow performed with some combination of OO accessing the OfficeClipoard (c.f. the Win clipboard, which Gtk has access to) and/or using some ODBC/OLE or whatever direct internal connection to Excel to effect the passing of the full Cell contents. That the CCP does not work in reverse (i.e. OO -> Excel), or only when both are running, also supports this contention.
Although these tests/results do not in themselves decisively prove that the OS/GtkClipboard is not actually usable for CCP of "full" Cell/Range contents, they are highly suggestive of that. However, for all we know, there may be some GtkClipboard (GdkAtom etc) settings that might permit access to other (e.g. Office) clipboards, but we can't find any info on this.
Similarly, it would be useful to know if anybody has succeeded in CCP'ing these sort of things in a Unix/Linux environment with Gtk (we are testing via a couple different MingW setups on Win, but the Win and Office clipboards seem to have some difference under Gtk compared to under Linux).
... as such, we would be grateful to anybody with actual knowledge on the subject at least to confirm whether or not the Win/GtkClipboard strategy is a waste of time, and if not, any hints for implementation would be much appreciated.
OK, sussed it, found (an) answer to our own question:
It is possible to CCP Cells/Ranges from Excel to a GTK entity via GtkClipoard.
... having said so, the Gtk side documentation is almost non-existent, and essentially requires a huge amount of trial and error.
... to confuse matters exponentially, the documentation/discussions regarding the Win OS clipboard, and the actual mechanism Excel uses (which is actually via attaching items to the OS clipboard via various machinations of the OfficeClipboard, OLEClipboard, iDatatObjects, etc.) is, indeed, overwhelmingly documented and creates a hugely expensive distraction.
The entire key to the matter does lie in the Gtk/Gdk "Atoms", "Targets" etc. as speculated/enquired in the OP.
One solution (with CAVEATS):
1) Use either gtk_clipboard_request_targets() or gtk_clipboard_request_contents() to obtain a list of the "Targets" that the "owner" of CCP'd material on the clipboard can support (i.e. convert into). gtk_clipboard_request_contents() can do this is it is given gdk_atom_intern("TARGETS") as its "target".
This process can be used to produce the list of targets from which to choose to convert into. For example, in a test case copying an Excel Cell with a formula, colours, grid etc, the "available targets" lists that the "owner" (e.g. Excel) will support was:
"DataObject"
"Biff8"
"Biff5"
"Biff4"
"Biff3"
"Biff"
"Wk1"
"XML Spreadsheet"
"HTML Format"
"UTF8_STRING"
"Csv"
"Rich Text Format"
"Embed Source"
"Native"
"OwnerLink"
"Object Descriptor"
"Link Source"
"Link Source Descriptor"
"Link"
"ObjectLink"
"Ole Private Data"
"image/bmp"
CAVEAT: we tested a number of these "targets" for conversion inside Gtk following CCP from Excel, but some of them produced "empty/faulty" 'GtkSelectionData'.
Some worked to various extents, depending on what "you" actually want. For example, the Target "UTF8_STRING" brought just the "display text/value" (e.g. of the Excel-side formula was "=1+2", which displayed as "3", then this Target provides Gtk with "3".
To demonstrate that the "full splendour" of the Cell "object" can be brought into Gtk, the Target "XML Spreadsheet" was used to CCP a Cell with formula, colours, etc from Excel, into Gtk, and inside Gtk it produced a variable (Data_Alloc) with the "value" of:
GtkClipboardContntReceivedFuncX Data_Alloc = <?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s25">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="Bauhaus 93" x:Family="Decorative" ss:Size="12"/>
<Interior ss:Color="#CCFFFF" ss:Pattern="Solid"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1">
<Row ss:Height="18.75">
<Cell ss:StyleID="s25" ss:Formula="=1+2"><Data ss:Type="Number">3</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
<< GtkClipboardContntReceivedFuncX - Exit
Clearly, all the crucial information was passed into Gtk, and then its just a matter of parsing the "data" to whatever is required in the Gtk app. For example, to CCP the Excel formula to Gtk (instead of the "value"), just parse the 6th line from the bottom where it has Formula = "=1+2"
... whoo hoo :)
Unfortunately, the "XML Spreadsheet" may not be sufficiently robust for all cases (e.g. it seems to have difficulty CPP'ing anything with Cell references e.g. "= 1+B1" gives it trouble (see ** note below), and which may be Gtk version, Excel version, etc issues). So one or another of the other "targets" may be required, and some of which are rather complex (e.g. any of the BIFF's).
** Note: Some of the Targets/conversion actually create an entire spreadsheet based on the Cell/Range that was CCP'd. Thus, in the case of sending a single Cell with a formula, and using the "XML Spreadsheet" Target/conversion in Gtk, the "result" is an "entire single cell spreadsheet" (as can be seen in the XML example above). Since many of these conversions convert "A1" style cell referencing to "(relative) RC" referencing, any dependencies that lie "outside" of the Range/Cell that was CCP'd and converted into an "entire clipboard (XML) spreadsheet" would not include the "outside cells", and then the RC referencing is referencing "nothing", so it cannot convert the formula correctly/at all.
... again, there is much going on here, and much depends on OS, Excel, Gtk etc versions and protocols.
Related
I'm using mainly Notepad++ for my C++ developing and recently i'm in need for some kind of basic autocompletion, nothing fuzzy, just want to type some letters and get my function declaration instead of having a manual opened all of the time..
The integrated autocompletion feature of my Notepad++ version (6.9.2) gives the declaration of basic C functionality like say fopen and parses my current file user defined functions, but without declaration.
I guess it's normal for a text editor to not give easily such information since it has nothing to parse i.e. other files where your declarations are (as it's not an IDE), but i don't want either to mess again with MSVC just for the sake of autocomplete.
Is there an easy, not so-hackish way to add some basic C++ and/or user defined autocomplete?
UPDATE
Adding declarations the "hard way" in some file cpp.xml is a no-no for me as i have a pretty big base of ever changing declarations. Is there a way to just input say some list of h/cpp files and get declarations? or this falls into custom plugin area ?
Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure you add them in alphabetical order or they will not show up.
Another option is to select Function and word completion in the Auto-Completion area of the Settings-->Preferences dialog. NPP will suggest every "word" in the current file that starts with the first N letters you type (you choose a value for N in the Auto-Completion controls).
My question is partly liguistic, but very related to programming (of almost anything, web pages or anything else).
I would like to know why word refactor was chosen for changing of program or its part, if else word probably would be more exact and better describing done change.
IDEs (for example NetBeans or Eclipse) use this word only for renaming of any part of chosen program (project), including moving of file to else place (from view of any OS it is probably only renaming).
But renaming is not about changing of factor (because it is something that is not changed when it is renamed).
Closer to meaning of word refactor (as changing of factor) is manual rewriting of any part, when rewritten part has changed behaviour (but not what program does from outer view - as is written in topic What is refactoring and what is only modifying code?).
The word "Refactoring" is derived from mathematics where you find an equivalent expression by applying factoring again. The equivalent expression does not change the final outcome but it is much easier to understand, use, or reuse.
There are many refactoring techniques and renaming is one of them. Other techniques include extract method, extract class, move method, move class, pull/push method to super/sub-class and many more.
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I need to translate with gettext. These are email templates (usually short, but still several lines) and parts of view templates (longer descriptive blocks of text). These texts would include some simple HTML (things like bold/italic for emphasis, probably a link here or there). The templates are PHP scripts whose output is captured.
The problem is that gettext seems very clumsy for handling longer texts. Longer texts would generally have more changes over time than short texts — I can either change the msgid and make sure to update it in all translations (could be lots of work and very error-prone when the msgid is long), or I can keep the msgid unchanged and modify only the translations (which would leave misleading outdated texts in the templates). Also, I've seen advice against including HTML in gettext strings, but avoiding it would break a single natural piece of text into lots of chunks, which will be an even bigger nightmare to translate and reassemble, and I've also seen advice against unnecessary splitting of gettext strings into separate msgids.
The other approach I see is to ignore gettext altogether for these longer texts, and to separate those blocks in external subtemplates for each locale, and just include the one for the current locale. The disadvantage is that I'm separating the translation effort between gettext .po files and separate templates located in a completely different location.
Since this application will be used as a starting point for other applications in the future, I'm trying to come up with the best approach for the long term. I need some advice for best practices in such scenarios. How have you implemented similar cases? What turned out to work and what turned out a bad idea?
Here's the workflow I used, on a very heavily-trafficked site that had about several dozen long-ish blocks of styled textual content, translated into six languages:
Pick a text-based markup language (we used Markdown)
For long strings, use fixed message IDs like "About_page_intro_markdown" that:
describes the intent of the text
makes clear that it will be interpreted in markdown format
Have our app render "*_markdown" strings appropriately, making sure to allow only a few safe HTML tags
Build a tool for translators that:
shows them their Markdown rendered in realtime (sort of like the Markdown dingus)
makes it easy for them to see the now-authoritative base language translation of the text (since that's no longer in the msgid)
Teach translators how to use the new workflow
Pros of this workflow:
Message IDs don't change all the time
Because translators are editing in a safe higher-level syntax, hard to mess up HTML
Non-technical translators found it very easy to write in Markdown, vs. HTML
Cons of this workflow:
Having static unchanging message IDs means changes in the text need to be transmitted out of band (which we'd do anyway, as long text can raise questions about tone or emphasis)
I'm very happy with the way this workflow operated for our website, and would absolutely recommend it, and use it again. It took a couple of days to get started, but it was easy to build, train, and launch.
Hope this helps, and good luck with your project.
I just had this particular problem, and I believe I solved it in an elegant way.
The problem: We wanted to use Gettext in PHP, and use primary language strings as keys translations. However, for large blocks of HTML (with h1, h2, p, a, etc...) I'd either have to:
Create a translation for each tag with content.
or
Put the entire block with tags in one translation.
Neither of those options appealed to me, so this is what I did:
Keep simple strings ("OK","Add","Confirm","My Awesome App") as regular Gettext .po entries, with the original text as the key
Write content (large text blocks) in markdown, and keep them in files.
Example files would be /homepage/content.md (primary / source text), /homepage/content.da-DK.md, /homepage/content.de-DE.md
Write a class that fetches the content files (for the current locale) and parses it. I then used it like:
<?=Template::getContent("homepage/content")?>
However, what about dynamic large text? Simple. Use a templating engine. I decided on Smarty, and used it in my Template class.
I could now use templating logic.. within markdown! How awesome is that?!
Then came the tricky part..
For content to look good, at times you need to structure your HTML differently. Consider a campaign area with 3 "feature boxes" beneath it. The easy solution: Have a file for the campaign area, and one for each of the 3 boxes.
But I could do better than that.
I wrote a quick block parser, so I would write all the content in one file, and then render each block seperately.
Example file:
[block campaign]
Buy this now!
=============
Blaaaah... And a smarty tag: {$cool}
[/block]
[block feature 1]
Feature 1
---------
asdasd you get it..
[/block]
[block feature 2] ...
And this is how I would render them in the markup:
<?php
// At the top of the document...
// Class handles locale. :)
$template = Template::getContent("homepage/content", [
"cool" => "Smarty variable! AWESOME!"
]);
?>
...
<title><?=_("My Awesome App")?></title>
...
<div class="hero">
<!-- Template data already processed! :) -->
<?=$template->renderBlock("campaign")?>
</div>
<div class="featurebox">
<?=$template->renderBlock("feature 1")?>
</div>
<div class="featurebox">
<?=$template->renderBlock("feature 2")?>
</div>
I'm afraid I can't provide any source code, as this was for a company project, but I hope you get the idea.
gettext wasn't really designed for translating large pieces of text.
fwiw I've included basic HTML (strong, a, etc) in gettext strings as I was confident our translators knew what they were doing (mostly right) and that the translations would be well tested.
I've tried the approach of breaking up the text into one string per paragraph. Roughly as it looks odd if there's one paragraph of English in the middle of the text. Where one of those strings have changed this has meant that we have had to wait for translations before releasing a new version, which has slowed us down. On the plus side it's easy for translators to see which part of the text has changed. This approach worked well for the one application I've tried it with.
Splitting some text out into external locations also worked, but it caused management overhead, rather than just a .po file or two, there was a whole bunch of other text that had to be manually compared to the English version and updated accordingly. This is doable if you remember to provide notes to your translators explaining where and what the difference was in the English version.
I'm still not sold on either approach myself.
Is there any diff tool for Lotus Notes which allows to compare scripts, design elements and documents?
I see this is an old question, and most of the other answers are a little outdated now, so I thought I would add some hopefully valuable information for those who should stumble upon this now.
In Domino Designer, open either the Navigator or Package Explorer (Window menu -> Show Eclipse Views). Here you can expand databases/templates to see the design elements they contain. Select two or three elements (CTRL-click). They can be in different databases or the same database. Right click on one of the elements and select Compare with -> Each other.
You can also compare two databases element by element by selecting two databases/templates, right-clicking and selecting Compare with -> Each other. You will then get the differences between the two databases listed. You will be able to see which elements differ between the two databases, and which elements exist in one database but not the other. By double-clicking on a differing element, you will open a diff tool which lets you see differences line by line, and you can easily copy changes from left to right or right to left.
There is a tool from TeamStudio called Delta: http://www.teamstudio.com/products/delta.html
If all else fails (and by "all else" I mean the often ridiculous corporate procurement system) you can always do a an export to DXL (or a Design Synopsis for code alone) and use any decent text editor with a diff function. It's not TeamStudio Delta, but it will get you where you want to go.
There is a free tool from OpenNTF which does document comparisons:
http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Compare%20Notes%20Documents
Ytria also has a product which, among other things, will compare data documents (I don't believe it compares design elements).
http://www.ytria.com/website.nsf/WebPageRequest/Solutions_scanEZ_specen
And, I believe Martin Scott (http://www.martinscott.com) has a similar product which compares documents.
DDE (Domino Designer on Eclipse) let's you compare design elements natively. Same way as the search. It's pretty efficient (faster than a DXL exportation) and it's free.
I had a discussion on my blog a little while back about this:
http://rosshawkins.net/archive/2009/12/24/notesdomino-refactoringanalysis-tools.aspx
However what I've ended up doing in the past is exporting the design to the filesystem and using standard text tools (WinMerge and SublimeText for me personally) to do what I need.
Being able to do the raw dump is something that was added with the Eclipse based designer, and isn't overly obvious, but you can read more about it here:
rosshawkins.net/archive/2010/01/20/searching-the-contents-of-notesdomino-design-elements.aspx
(link mangled as my rep is too low to post 2 links in one post yet!)
Teamstudio Delta is really nice. However it might kill you with too many details. As Ross pointed out the Domino Designer 8.5 can use the Diff tool inherited from Eclipse. You also could head over to http://www.openntf.org and look for the DXLMagic project. It can generate a report that shows differences (including code) between 2 databases (typically a template and a variation of it). It is not as complete as Delta, but shows the essentials. It's free and source is included (Disclaimer: I wrote it).
This is what I do. I run a design synopsis of the database using the Notes Designer. Dump the file to a text file. You can actually split the synopsis out to different objects like Agents, Forms, Views, etc. Then you can run UNIX/Linux/Mac Unix commands to compare the elements. By doing this operation you find out what code is active, and have a complete documented source code. You do a lot of csplit and a few sed commands.
Version 12.0.1 has such a tool as part of the server. Look for comparedbs.ntf and designsynopsis.ntf on the Domino server.
I have a lot of HTML files (10,000's and GBs worth) scraped from a server and I want to check to make sure the server produces the same results after some modifications but ignore kinds of differences that don't matter, e.g. whitespace, missing newlines, timestamps, small changes in some kinds of number, etc.
Does anyone know of a tool for doing this? I'd really rather not do more filtering than I have to.
(Oh and it needs to run under linux)
You might consider using a clone detector such as our CloneDR. This tool parses large sets of computer program (HTML is special case) files, builds abstract syntax trees representing the essential structure of each files, and compares programs for similarity.
Because it is comparing essential program structure, it ignores inessential differences such as comments and whitespace, and deterimines that two code segments are either identical or one can be obtained from the other by substituting other blocks of code. The latter allows the recognition of code that has been modified in various ways. You can see samples of clone detection runs on a variety of computer languages at the web site.
In your case, what you would be looking for are files in system A which are essentially clones (exact or near misses) of files in system B. As a general rule, if a file a is a variant of file b (e.g., with a few changes) the CloneDr will report it as a clone and show the exact differences.
At the scale of 20,000 files, I can see why you want a tool, and I can see why you want near-miss matches rather than exact matches.
Doesn't run under Linux, but I assume your problem is hard to enough to solve so that isn't what you are optimizing.
I use winmerge alot in windows and from what i can see some people enjoy meld in linux, so perhaps that could do the trick for you
http://meld.sourceforge.net/
Other examples i saw from a quick googling was Kompare,xxdiff.sourceforge.net, and kdiff3.sourceforge.net
(could only post 1 link so wrote the adresses to xxdiff and kdiff3 as text)
Beyond Compare is purchased software that is actually worth the money (I never thought I'd hear myself typing that!). It is GUI based but handles thousands of files very well. It will allow you to specify unimportant changes with regular expressions as well as whitespace (beginning, middle and end of line). The feature set is very extensive, check out a trial download.
I do not work for this company, I just use Beyond Compare every day at work and enjoy it every time!