Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi Markus,

Markus Doerr schrieb:
Dear all,

I have a problem with Libreoffice Impressfor which I didn't find any
solution in internet.

My problem:
I have a presentation with lots of equations and I want to change the
fonts in this presentation. For normal text this is easily done changing
the corresponding styles. However, so far I didn't find a way to change
the fonts of all equations (in an efficient way, without modifying each
equation manually).

I understand that I need a macro for doing this. In the Math
documentation
http://wiki.documentfoundation.org/images/3/37/MG40-MathGuide.pdf on
page 46 I found a macro which works nicely in Libreoffice Writer, but
not in Impress.
On page 47 it is said that in Impress some modifications are necessary.

If you have not used a special style for the formulas, then using an input field will work for you. See macro below, put all in one tab in a module in basic IDE. I will sent you a document with that macro in private mail.

Kind regards
Regina

REM  *****  BASIC  *****
option explicit

sub main
        ChangeFormulaSizeDirectly
end sub 
' The macro ChangeFormulaSizeDirectly changes the formula font size for selected
' formulas. The new font size has to be entered in an input box.

' Copyright (C) 2010; Regina Henschel
' Apache License, Version 2.0, rb.henschel@t-online.de

Rem === How To Use ===
' To change the font size of a set of formulas first select them and then run the ' macro ChangeFormulaSizeDirectly. Enter the new font size into the input box.
' The program effects formulas in nested groups as well.
' To change _all_ formulas on several slides in Impress, select the slides in the
' Slide-Sorter and then run the macro ChangeFormulaSizeDirectly.

' Wählen Sie zunächst die Formeln aus und rufen anschließend das Makro
' ChangeFormulaSizeDirectly auf. Tragen Sie die neue Schriftgröße in das Eingabefeld ' ein. Die Formeln werden auch innerhalb von geschachtelten Gruppen geändert. ' Um in Impress _alle_ Formeln auf mehreren Folien zu ändern, wählen Sie die Folien in der ' Foliensortierung aus und rufen dann das Makro ChangeFormulaSizeDirectly auf.

sub ChangeFormulaSizeDirectly
dim oCurrentController as variant: oCurrentController = ThisComponent.getCurrentController()
dim oDoc as variant: oDoc=ThisComponent
if not(oCurrentController.supportsService("com.sun.star.drawing.DrawingDocumentDrawView")) then
        msgbox("Only for Draw and Impress documents.")
        exit sub
end if
dim oShapeCollection as variant: oShapeCollection = oCurrentController.Selection
if isEmpty(oShapeCollection) then
        msgbox("Nothing selected.")
        exit sub
end if
dim nVarType as integer: nVarType = VarType(oShapeCollection)
'9 object; Something is selected in Normal view
'8201=8192+9 array of object; Slides are selected in slide sorter.
if nVarType=9 then
        WorkOnNormalView(oShapeCollection)
else if nVarType=8201 then
                WorkOnSlideSorter(oShapeCollection)
        else
                exit sub
        end if
end if
oDoc.Modified = true
end sub

sub WorkOnNormalView(oShapeCollection as variant)
if not(oShapeCollection.supportsService("com.sun.star.drawing.ShapeCollection")) then
        exit sub
end if
dim sValue as string
sValue = InputBox("Enter new font size","Set Formula Font Size Directly","12")
dim nNewFontSize as integer: nNewFontSize = CInt(sValue)
dim nShapeIndex as long
dim nEndShapeIndex as long: nEndShapeIndex = oShapeCollection.Count-1
dim oShape as variant
for nShapeIndex=0 to nEndShapeIndex
        oShape = oShapeCollection(nShapeIndex)
        SetCharHeightDeep2(oShape,nNewFontSize) 'two parameters
next nShapeIndex
end sub

sub WorkOnSlideSorter(oPagesCollection as variant)
dim nPageIndex as long
dim nShapeIndex as long
dim nEndShapeIndex as long
dim oSelectedPage as variant
dim oShape as variant
dim sValue as string
sValue = InputBox("Enter new font size","Set Formula Font Size Directly","12")
dim nNewFontSize as integer: nNewFontSize = CInt(sValue)
' Iterate over all selected pages, then over all shapes.
for nPageIndex = LBound(oPagesCollection) to UBound(oPagesCollection)
        oSelectedPage = oPagesCollection(nPageIndex)
        nEndShapeIndex = oSelectedPage.Count - 1
        for nShapeIndex=0 to nEndShapeIndex
                oShape = oSelectedPage(nShapeIndex)
                SetCharHeightDeep2(oShape,nNewFontSize)
        next nShapeIndex        
next nPageIndex
end sub

sub SetCharHeightDeep2(oShapeInOut as variant, nNewFontSizeIn as integer)
' recursive solution
dim sShapeType: sShapeType = oShapeInOut.ShapeType
if sShapeType = "com.sun.star.drawing.GroupShape" then
        dim nCount as long: nCount = oShapeInOut.Count
        dim nIndex as long
        dim nEndIndex as long: nEndIndex = nCount -1
        for nIndex = 0 to nEndindex
                SetCharHeightDeep2(oShapeInOut.getByIndex(nIndex),nNewFontSizeIn)
        next nIndex
else
        if oShapeInOut.supportsService("com.sun.star.drawing.OLE2Shape") then
                if oShapeInOut.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" then
                        'Math-object
                        dim oModelFormula as variant: oModelFormula = oShapeInOut.Model
                        oModelFormula.BaseFontHeight = nNewFontSizeIn
                endif
        endif
endif
end sub









--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.