clipboard manager extension for writer - libreoffice

I am trying to build a clipboard manager extension for Libre office. When-ever I cut (or copy) text from a document, it should be appended to another file so that I will never loose my work even if I forget to paste it somewhere. Is it possible in libre office?

This chapter explains how to register a clipboard listener: https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Common_Application_Features
I wonder how your extension will handle when someone copies an image instead of text. Perhaps in that case you could catch an exception and end the call cleanly. Or perhaps you could determine that ahead of time, based on the mime type.

Related

How to replace value in txt file with powershell from GitHub

I want to build a simple script that may be useful for others as well, but I have only very basic programming knowledge and can't do it myself without learning how to write powershell scripts from scratch.
What this script is supposed to do is, open an INI file (really just a txt), look for a variable with an assigned value and replace that value from a txt hosted on GitHub, save and then run a program.
This is for the tracker list of qBittorrent, since that feature still hasn't been implemented and the only other script that I could find that does this is for linux and mac, there seem to be none for windows.
The basic idea is this:
get-content "c:\users\[user]\appdata\roaming\qbittorrent\qbittorrent.ini"
# This is where pseudo code starts
get file from "[github-link.txt]"
save file to cache # keeping it is useless as it gets updated daily
find variable "Session\AdditionalTrackers=" in qbittorrent.ini
replace value of variable with content of cached file # this is what I struggle with most when looking for example code. Everything I could find specified the exact string that needed replacing, which in this case is quite long and may change with every update of the file.
overwrite original file
launch program qbittorrent.exe
end script
Conveniently or most likely deliberately all (most) of the tracker lists on GitHub are already formatted in a way that they can be directly pasted into the file without having to worry about formatting. Example.
I can totally understand if nobody wants to do the work, but I would greatly appreciate it and possibly others that are looking for a stopgap for the lacking feature.
If this already exists, go ahead and call me an idiot and while you're at it drop a link ;)
I just found a little tool called Power Automate and it pretty much does what I was looking for. It's not quite as elegant as a single click script but it does the job. Sadly I can't share the "flow" I built because, well, there is no option for it - thanks Microsoft. So, I'll try my best to write it out.
Not quite a "solution" but pretty to close to it.
Here is the "flow":
get file from web // from github for example
read text from file // read downloaded .txt file
read text from file // read qBittorrent.ini
crop text // crop between flags in qBittorrent.ini use "Session\AdditionalTrackers=" as start and "Session\GlobalMaxRatio=" as end and save to cropVar2
crop text // crop before flag use "Session\AdditionalTrackers=" as flag and save to cropVar1
crop text // crop after flag use cropVar2 as flag and save to cropVar3
replace text // replace cropVar2 with content of downloaded file and save to cropVar2
write text to file // write cropVar1,cropVar2,cropVar3
end flow
Keep in mind that any changes to the qBittorrent.ini may change the order of the entries. Which means you have to check if it's still correct after every update and after every change you make in the options. This is a massive cludge after all...
You can input fail saves so that you won't break anything if the order changed.

Drag something out of a form in C++ builder

I have made a form like this
there is only a label in the form, when I drag a file and drop the file in the form, the label will show the path of the files, just as shown above.
Now I am going to do something like this, I will open disk D: in explorer (MyComputer) and drag the label into the window and drop, and then the file AOP.mm will be copy to disk D:.
but when I drop the file, how can I get the target path, just like D:/dragToHere/?
In order to drag&drop something onto Windows Explorer, you must implement the IDropSource and IDataObject interfaces, and then call the DoDragDrop() function when you are ready to start a new drag operation. Or use a wrapper component/library, such as the TDropFileSource component in Ander Melander's Drag&Drop Suite (an updated version is on Github).
For what you are attempting, all you need to do is put the source filename from your TLabel into your IDataObject object formatted using the CF_HDROP clipboard format. Or, if using Anders' components, put the filename in the TDropFileSource::Files property. Windows Explorer itself can then copy the file when a drop is performed. You do not need to manage the copy yourself. In fact, it is actually very difficult (almost impossible) to determine the folder that is being dropped onto, so you are better off not even trying to do that. The target is supposed to handle the drop, so let Windows Explorer copy the file as it knows both the source file and the target folder.

How to append text to a file in Objective C?

I have a form in my app that the user fills out, then the app needs to write what the user entered into a .java file that is then sent to the user. Basically, I'm making a mobile Java IDE. Please help! I need to know how to append text into certain locations in the file. Excuse me if this doesn't make sense, just ask me what part is confusing, I might be able to explain it better.
You are probably a lot better off storing all your text in a database, where you can easily insert new text at any location.
Actually storing the text in a file is problematic - appending is easy, you just open the file, seek to the end, and then write new text. But you really want arbitrary insertion of text which means seeking to that point in the file, reading in the rest of the file, writing out your new data, then writing out the old remainder of the file...
If you store all the text in a database you can organize it to make it easy to insert new text, probably append some useful metadata about the text, and when the user asks to email the file simply write everything you have out to a file in temporary storage and send that (or create the text in memory and send it as NSData).

Word 2010 additional file format

I'm not sure whether this is the best approach for this or whether I perhaps should ask the question more clearer.
What I want to do is to create an additional file output - e.g. if the user uses Word to create a description consisting of known tags, I want to be able to save this as bbcode.
Now I do have an idea of how to do this, but is there a way to say add another file format to the "Save file"-dialog box and have it run a parser and file writer, that'd read the current document and export it using known bbcode-tags (that perhaps would be adjustable from some configuration window)?
The result would be a file containing bbcode as well as the text information that the user has entered.
How would I hook up my addin to the file output dialog? Is there a way to do this? I'm not sure it's custom XML since I won't be using the XML at all.
Thanks in advance and please excuse my poor English.
Edit: after having a look at the Word 2010 AddIn-project, I figured, that I'm looking for a way to define my own "export"-format. I'd like to export the BBCode to a .txt (or even .bbcode) file. The Microsoft.Office.Interop.Word.WdExportFormat seems to have its own fixed enumeration. Is there a way to add an export-format?
There is some code for this here:
phpbb.com/community/viewtopic.php?f=17&t=395554

Is there a way to show all docvariables from a word file?

I have a Microsoft-Word File which contains several DocVariables.
In our application we fill/replace these DocVariables with content.
With the shortcut Alt+F9 I can switch in a mode in which I can see the DocVariable.
But in the document I have now, there are DocVariable which I cannot see.
Is there a way/mode in Word 2007 in which I can see all the DocVariables which are defined in the Word-File?
As far as I know there is not a way to do this with MS Word's built in features. You could write a custom VBA script that would get a list of all the DocVariables. But even easier than that I use the following program when I need to do what you are saying: http://gregmaxey.mvps.org/word_tip_pages/cc_var_bm_doc_prop_tools_addin.html
It is a free add-in for Word that has done the job very well the times I used it.