Can I increase a number by a macro in LibreOffice Impress? - libreoffice

I want to make a counter with Libreoffice Impress.
Each Time I click on a rectangle, the number inside increases.
Dim Doc As Object
Dim Page As Object
Dim Rect As Object
Doc = ThisComponent
Page = Doc.drawPages.getByName("Test")
Rect = Page.getByIndex(0)
Rect.String = CInt(Rect.String) + 1
It works everywhere except in presentation mode.
Is it possible to make it work in presentation mode ?

Related

Roblox studio How do I change a TextLabel text in script

I want to make a gui that show your coordinates in game with text labels but my script seems didn't change the text at all
players = game.Players.LocalPlayer
players.CharacterAdded:Wait()
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text = script.Parent.Text
while true do
text = X..","..Y..","..Z
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
end
please help me
I wanted to change the text to XYZ position in string
but everytime i launch the game the text didnt change
and it still at default text in roblox ui text label
The simple answer to your question of how do I change a TextLabel text is you just set the Text property.
script.Parent.Text = "Hello World"
If you want a simple way to track the changing position of a player's character, I would recommend using the Changed signal on the Part. It will fire the connected function every time the property changes, and it allows you to avoid using an infinite while-loop.
local text = script.Parent
local player = game.Players.LocalPlayer
-- wait for the player's character to exist
if not player.Character then
player.CharacterAdded:Wait()
end
-- listen for changes to the player's position
local hrp = player.Character.HumanoidRootPart
hrp:GetPropertyChangedSignal("Position"):Connect(function()
local position = hrp.Position
local x, y, z = math.floor(position.X), math.floor(position.Y), math.floor(position.Z)
-- format the position, and display it in the TextLabel
local positionString = string.format("(%d, %d, %d)", x, y, z)
text.Text = positionString
end)
So I can see that you have made few mistakes here
Explanation:
First of all, players.CharacterAdded:Wait() doesn't always work and never works in studio. So instead of that, you should use players.Character:WaitForChild("HumanoidRootPart").
Second thing. By calling text = script.Parent.Text you were requesting the text inside of it (you were getting it as a string), so to simply fix that you have to use text = script.Parent and then when changing text you will have to use text.Text = "your text".
The next one is making your while loop infinite by using bool true. You can't make it like that or else the playar may experience lag or even script may crash. So I'd suggest to put this to something like wait(0.1).
And the last thing is that you should get X,Y,Z before putting it into the text or else it will be delayed.
And your final script should be looking like this:
players = game.Players.LocalPlayer
players.Character:WaitForChild("HumanoidRootPart")
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text = script.Parent
while wait(0.1) do
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text.Text = X..","..Y..","..Z
end
Keep scripting, nothing is easy without practice,
KubaDC

Why does Rotation change not change the crop box?

I want to crop / remove / cut away a part of a pdf page.
Somebody provided a code for me to do that in this question.
2 new problems occured:
I want to print the PDF in a different orientation
I want to cut away more of the blank space around the DHL label
Because dealing with the coordinates in iTextSharp requires (0,0) based coders to twist their mind a bit, I first wanted to rotate the PDF so that I can follow it along more easily.
I did that using the following code:
Dim testFile As String = "new pdf1.pdf"
Dim resultFile As String = "new pdf1-Rotated.pdf"
Using pdfReader As PdfReader = New PdfReader(testFile)
Using pdfStamper As PdfStamper = New PdfStamper(pdfReader, File.Create(resultFile))
For i As Integer = 1 To pdfReader.NumberOfPages
Dim rotate As Integer = pdfReader.GetPageRotation(i)
Dim pageDictionary As PdfDictionary = pdfReader.GetPageN(i)
pageDictionary.Put(PdfName.ROTATE, New PdfNumber(90))
Next
End Using
End Using
It does work.
I expected that the page rotation change would automatically affect the crop box.
However, it does not.
Dim testFile As String = "new pdf1.pdf" 'they both give the same cropbox
Dim testFile As String = "new pdf1-Rotated.pdf"'they both give the same cropbox
Using pdfReader As PdfReader = New PdfReader(testFile)
For i As Integer = 1 To pdfReader.NumberOfPages
Dim cropBox As Rectangle = pdfReader.GetCropBox(i)
Why is that so?

Document generator, different margins for certain pages

I am creating a document using MATLAB's mlreportgen.dom.*;
I would like to be able to set the first and last page of a document to have no margins. This way I can get images to fit right across the page.
I am having difficulties with this, see example code
import mlreportgen.dom.*;
d = Document('myreport', 'pdf');
open(d);
currentLayout = d.CurrentPageLayout;
pdfheader = PDFPageHeader();
p = Paragraph('Sample Traffic Data in Austin');
p.Style = [p.Style, {HAlign('left'), Bold(true), FontSize('12pt')}];
append(pdfheader, p);
currentLayout.PageHeaders = pdfheader;
currentLayout.PageMargins.Gutter = '0.0in';
currentLayout.PageMargins.Left = '0.0in';
currentLayout.PageMargins.Right = '0.0in';
close(d);
rptview(d.OutputPath);
So far, I have naively tried to add a page break and redefine margins with no success. It appears to use the margins that come last in the document.

Word 2007 Script random font generator

Would any one know or be able to help me get this to work with Word 2007.
This is a code snippet that is supposed to set styles randomly.
//Create instance of Word application
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
//Open an existing Word document, Make sure the file is exist in this path- otherwise the program fails.
Set objDoc = objWord.Documents.Open("C:\Scripts\Test.doc")
//Create instance of random object
Set objRandom = CreateObject("System.Random")
intLow = 1
intHigh = 5
//Get the text of word document
Set objRange = objDoc.Range()
//Get the charcters of the text
Set colCharacters = objRange.Characters
//Set different styles randomly
For Each strCharacter in colCharacters
intRandom = objRandom.Next_2(intLow,intHigh)
Select Case intRandom
Case 1 strCharacter.Font.Name = "Arial"
Case 2 strCharacter.Font.Name = "Times New Roman"
Case 3 strCharacter.Font.Name = "Courier New"
Case 4 strCharacter.Font.Name = "Forte"
End Select
Next
You should add to the program the following references:
Microsoft.Office.Interop.Word
Microsoft Office Object Library
You can do it by right ckick on project -> Add reference, from the GAC tab select the first reference I mentioned above, from the COM tab select the second one.

iTextSharp - Force text below image

My issue with images and iTextSharp is that I want to put a header in and the have the text below that point.
I can display the image and wrap the text but not get it to display below, even when adding New paragraph.
I am assuming there is some command around the aligmnent but I am struggling to find it even when looking at tutorials such as http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images
'Import Image
Dim vImagePath = "C:\sites\images\" & "Logo.jpg"
Dim jpg As Image = Image.GetInstance(vImagePath)
jpg.ScaleToFit(139.0F, 106.0F)
jpg.Alignment = Image.ALIGN_RIGHT Or Image.TEXTWRAP
jpg.IndentationLeft = 7.0F
jpg.SpacingAfter = 9.0F
jpg.BorderWidthTop = 6.0F
jpg.BorderColorTop = Color.WHITE
document.Add(jpg)
'##Main Document Header
Dim tableHeader As New PdfPTable(1) ' Number in brackets is number of columns
tableHeader.DefaultCell.Border = Rectangle.NO_BORDER
Dim phFirst As Phrase = New Phrase("Title", HeaderFont)
tableHeader.AddCell(phFirst)
document.Add(tableHeader)