[Solved] How to Copy a Border to All Images in a Document?

Discuss the word processor
Post Reply
sandysewin
Posts: 2
Joined: Wed Feb 07, 2018 2:44 am

[Solved] How to Copy a Border to All Images in a Document?

Post by sandysewin »

Hi there, I have searched the forums for the answer to this, but perhaps I'm using the wrong terms.

I use Open Office to create tutorials that are quite image heavy. I have several of these tutorials and like to do them all with similar formatting, but change up the colors in each. I like to have all of the photos framed nicely, like with a thick-thin border in a color that compliments the overall scheme.

But, adding a new border to each and every image is a tedious drag! Is there a way to add my desired borders to one image, then copy that onto all the other images in the document?

Thank you!

Sandy

P.S. I'm using Open Office 4.1.3 and Windows 10.
Last edited by sandysewin on Fri Feb 09, 2018 3:30 am, edited 1 time in total.
OpenOffice 4.1.3
Windows 10
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to Copy a Border to All Images in a Document?

Post by Zizi64 »

Use the styles. In this case: a user defined Frame style.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: How to Copy a Border to All Images in a Document?

Post by John_Ha »

See [Tutorial] Some useful hints on using images for a discussion on how best to handle images in Writer.

Record a macro where, after selecting an image, you border it. Save the macro. Add the macro to a toolbar.

Now, when you want to border an image, select the image and click the macro icon in the toolbar - all done in two keystrokes. See [Tutorial] How to record a macro (and Regular Expressions)

I have uploaded the macro icon I use for my "Border a paragraph" macro. Resave it as a BMP file.
BlackBorder.png
BlackBorder.png (92 Bytes) Viewed 1413 times
If you want multiple colours either record macros adding red, blue etc borders, and create red, blue etc icons. Or add a question in the macro Colour? 1 = Red, 2 = Blue etc, where you type 1 to get a red border.

You need code something like this, where I needed to insert a bespoke bullet, and choose between Large and Small bullet symbols in a macro. The single quotes signify comments.

Code: Select all

sub Bullet
'
'   inserts a large / small bullet at the cursor position. 
'   Small [2022], large [25CF]
'   Or, to make small larger use Calibri, ITC ZAPF Chancery, MS Reference sans serif, Tahoma,
'   bold, AR Destine, AR Julian,  Arial rounded MT bold 
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")
dim args1(1) as new com.sun.star.beans.PropertyValue
rem ----------------------------------------------------------------------
'jh MsgBox(prompt, buttons, title)
'jh buttons = 1 means 2 buttons - OK (resp = 1) and CANCEL (resp = 2)
'jh buttons = 4 means 2 buttons - YES (resp = 6) and NO (resp = 7)

   response = MsgBox( "Large?",4,"Large or small?")  ' YES and NO buttons

   If (response = 6) Then                  ' 6 = YES, I want large

rem ----------------------------------------------------------------------

args1(0).Name = "Symbols"
args1(0).Value = "  ●  "                 ' large
args1(1).Name = "FontName"
args1(1).Value = "Times New Roman"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())   
 
   Else       '   Response is 7 = NO, give me small

args1(0).Name = "Symbols"
args1(0).Value = "  •  "                 ' small
args1(1).Name = "FontName"
args1(1).Value = "Times New Roman"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())
 
   EndIf

end sub
Attachments
Clipboard01.png
Clipboard01.png (2.36 KiB) Viewed 1411 times
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: How to Copy a Border to All Images in a Document?

Post by John_Ha »

It took less than a minute to record this macro which gives the selected image a red border set off by 2mm from the image.

If your macro fails, just go Tools > Macros ..., etc to find your saved macro. Now edit your macro and replace it with this code.

Code: Select all

sub Border_Image
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(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = "BorderOuter.LeftBorder"
args1(0).Value = Array(16724787,0,88,0)
args1(1).Name = "BorderOuter.LeftDistance"
args1(1).Value = 199
args1(2).Name = "BorderOuter.RightBorder"
args1(2).Value = Array(16724787,0,88,0)
args1(3).Name = "BorderOuter.RightDistance"
args1(3).Value = 199
args1(4).Name = "BorderOuter.TopBorder"
args1(4).Value = Array(16724787,0,88,0)
args1(5).Name = "BorderOuter.TopDistance"
args1(5).Value = 199
args1(6).Name = "BorderOuter.BottomBorder"
args1(6).Value = Array(16724787,0,88,0)
args1(7).Name = "BorderOuter.BottomDistance"
args1(7).Value = 199

dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(3) as new com.sun.star.beans.PropertyValue
args2(0).Name = "BorderShadow.Location"
args2(0).Value = com.sun.star.table.ShadowLocation.NONE
args2(1).Name = "BorderShadow.Width"
args2(1).Value = 180
args2(2).Name = "BorderShadow.IsTransparent"
args2(2).Value = false
args2(3).Name = "BorderShadow.Color"
args2(3).Value = 8421504

dispatcher.executeDispatch(document, ".uno:BorderShadow", "", 0, args2())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, Array())

end sub
Border added by macro
Border added by macro
If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

Re: How to Copy a Border to All Images in a Document?

Post by musikai »

Why so complicated?
If the graphics were inserted the regular way they all have the frame style "Graphics". Just use the Navigator, go to "Frame Styles" and right-click on "Graphics" to "Modify" it. Now you can edit the borders and with ok all graphics will get the edited borders. Only graphics that you manually edited the borders before won't be affected. For these you can use the "Fill Bucket" on the top right side of the Frame Style Navigator tab.
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
sandysewin
Posts: 2
Joined: Wed Feb 07, 2018 2:44 am

Re: How to Copy a Border to All Images in a Document?

Post by sandysewin »

Thank you, everyone for the quick replies... and so many different ways to do it! My work will be much more efficient now. :D
OpenOffice 4.1.3
Windows 10
Post Reply