Previous  |  Main  |  Next
AppleScript Logo

Write Style Specs to Log Window

Script for: QuarkXPress
Copyright: Matthias Steffens, use at your own risk!
Description: Gets all style specifications of the frontmost QuarkXPress document and
writes them to a log window in BBEdit. By saving this log window with ".etx"
suffix all headings (style names) and corresponding sub-headings ("font",
"format", "lines", "tabs") get valid setext sections, which can be accessed via
the function pop up menu for convenient browsing!

Important Notes:
  • The generated log window is in german! (I may translate it some day ;-)
  • The log generation may take some time if the QuarkXPress document
    contains many styles.
  • Loading or saving this script may cause an error ("stack overflow")
    with Apple's Scripteditor! If so, this script can be run from BBEdit by
    opening the file "Log_Styles.sx" in BBEdit and running it via BBEdit's
    Scrippy PlugIn!
  • When run from BBEdit / Scrippy make sure to have enough free memory
    available! (otherwise the script may terminate with an error)
Necessary: ACME Script Widgets 2.5 (or greater)  (command: "ACME sort").
Note that this Scripting Addition is shareware.
Download: Log_Styles.sx.hqx  (german version, BBEdit file for use with Scrippy)
The Script:
tell application "QuarkXPress 3.3"
	if exists (document 1) then
		tell document 1
			set DocName to name
			set DocPath to file path
			tell application "Finder"
				copy bounds of desktop's window to screenSize
				set DocInfo to (info for alias DocPath)
				set DocModifiedDate to modification date of DocInfo as string
			end tell
			set StyleCount to count every style spec
			set StyleList to name of every style spec
			-- merge the list of style names in order to write them to the output file:
			copy StyleList to StyleList_ForOutput
			set StyleList_ForOutput to ACME sort StyleList_ForOutput -- "ACME sort" command from ACME Script Widgets 2.5 !
			set oldDelim to AppleScript's text item delimiters
			set AppleScript's text item delimiters to return
			set StyleList_ForOutput to StyleList_ForOutput as text
			set AppleScript's text item delimiters to oldDelim
			-- built the header of the output file:
			tell application "BBEdit 5.1"
				make new window with properties {name:"Stilvorlagen LOG.etx", bounds:{0, 41, (item 3 of screenSize), (item 4 of screenSize)}}
				set contents of document 1 to ("Datei:" & tab & "\"" & DocName & "\"" & return & ¬
					"Pfad:" & tab & "\"" & DocPath as string) & "\"" & return & return & ¬
					"Datei zuletzt geändert: " & DocModifiedDate & return & return & ¬
					"Anzahl Stilvorlagen: " & (StyleCount as text) & return & return & ¬
					StyleList_ForOutput & return & return
			end tell
			set StyleList to ACME sort StyleList -- "ACME sort" command from ACME Script Widgets 2.5 !
			repeat with NextStyleNameInList in StyleList
				repeat with x from 1 to StyleCount
					set StyleName to name of style spec x
					set StyleNameCharLength to length of StyleName
					set Divider to ""
					repeat StyleNameCharLength times
						set Divider to Divider & "-"
					end repeat
					if StyleName = (NextStyleNameInList as text) then -- process next style in StyleList
						try
							set BaseStyle to name of base style of style spec x
						on error
							set BaseStyle to ""
						end try
						set NextStyle to name of next style of style spec x
						set TextProperties to text and paragraph attributes of style spec x
						set FontProperties to "  Schrift" & return & "---------" & return & ¬
							"Schrift:" & tab & tab & tab & tab & tab & ((font of TextProperties) as text) & return & ¬
							"Größe:" & tab & tab & tab & tab & tab & tab & ((size of TextProperties) as text) & return & ¬
							"Farbe:" & tab & tab & tab & tab & tab & tab & ((name of color of TextProperties) as text) & ¬
							" (" & ((color flag of color of TextProperties) as text) & ")" & return & ¬
							"Tonwert:" & tab & tab & tab & tab & tab & ((shade of TextProperties) as text) & return & ¬
							"Skalierung horizontal:" & tab & tab & ((horizontal scale of TextProperties) as text) & return & ¬
							"Skalierung vertikal:" & tab & tab & ((vertical scale of TextProperties) as text) & return & ¬
							"Spationierung:" & tab & tab & tab & tab & ((kern of TextProperties) as text) & return & ¬
							"Grundlinienversatz:" & tab & tab & tab & ((base shift of TextProperties) as text)
						if (grid lock of TextProperties) then
							set StickToBaseLine to "JA"
						else
							set StickToBaseLine to "NEIN"
						end if
						if (justification of TextProperties) is left justified then
							set ParagraphJustification to "Linksbündig"
						else if (justification of TextProperties) is centered then
							set ParagraphJustification to "Zentriert"
						else if (justification of TextProperties) is right justified then
							set ParagraphJustification to "Rechtsbündig"
						else if (justification of TextProperties) is fully justified then
							set ParagraphJustification to "Blocksatz"
						else if (justification of TextProperties) is force justified then
							set ParagraphJustification to "Erzwungener Blocksatz"
						end if
						if (keep with next of TextProperties) then
							set KeepWithNext to "JA"
						else
							set KeepWithNext to "NEIN"
						end if
						if (keep together of TextProperties) then
							if (keep all of TextProperties) then
								set KeepLines to "JA (Alle Zeilen im ¶)"
							else
								set KeepLines to "JA (Start: " & ¬
									(keep together start of TextProperties) & " / " & ¬
									"Ende: " & (keep together end of TextProperties) & ")"
							end if
						else
							set KeepLines to "NEIN"
						end if
						set FormatProperties_1 to "  Format" & return & "--------" & return & ¬
							"Linker Einzug:" & tab & tab & tab & tab & ((left indent of TextProperties) as text) & return & ¬
							"Erste Zeile:" & tab & tab & tab & tab & ((first indent of TextProperties) as text) & return & ¬
							"Rechter Einzug:" & tab & tab & tab & tab & ((right indent of TextProperties) as text) & return & ¬
							"Auf Grundlinie:" & tab & tab & tab & tab & StickToBaseLine & return & ¬
							"Initial - Anz. Zeichen:" & tab & tab & ((drop cap characters of TextProperties) as text) & return & ¬
							"Initial - Anz. Zeilen:" & tab & tab & ((drop cap lines of TextProperties) as text) & return
						set FormatProperties_2 to "Ausrichtung:" & tab & tab & tab & tab & ParagraphJustification & return & ¬
							"S&B:" & tab & tab & tab & tab & tab & tab & ((name of h and j set of TextProperties) as text) & return & ¬
							"Zeilenabstand:" & tab & tab & tab & tab & ((leading of TextProperties) as text) & return & ¬
							"Abstand vor:" & tab & tab & tab & tab & ((space before of TextProperties) as text) & return & ¬
							"Abstand nach:" & tab & tab & tab & tab & ((space after of TextProperties) as text) & return & ¬
							"¶ zusammenhalten:" & tab & tab & tab & KeepWithNext & return & ¬
							"Zeilen zusammenhalten:" & tab & tab & KeepLines
						if (rule on of rule above of TextProperties) then
							if (text length of rule above of TextProperties) then
								set TextLength to "Text"
							else
								set TextLength to "Einzug"
							end if
							if (style of rule above of TextProperties) is solid line then
								set LineStyle to "Durchgezogen"
							else if (style of rule above of TextProperties) is dashed line then
								set LineStyle to "Gestrichelt"
							else if (style of rule above of TextProperties) is densely dashed line then
								set LineStyle to "Dicht gestrichelt"
							else if (style of rule above of TextProperties) is sparsely dashed line then
								set LineStyle to "Strich-Punkt"
							else if (style of rule above of TextProperties) is dotted line then
								set LineStyle to "Gepunktet"
							else if (style of rule above of TextProperties) is double line then
								set LineStyle to "Doppelt"
							else if (style of rule above of TextProperties) is thin thick line then
								set LineStyle to "Dünn-Dick"
							else if (style of rule above of TextProperties) is thick thin line then
								set LineStyle to "Dick-Dünn"
							else if (style of rule above of TextProperties) is thin thick thin line then
								set LineStyle to "Dünn-Dick-Dünn"
							else if (style of rule above of TextProperties) is thick thin thick line then
								set LineStyle to "Dick-Dünn-Dick"
							else if (style of rule above of TextProperties) is thin thin thin line then
								set LineStyle to "Dünn-Dünn-Dünn"
							end if
							set LineAbove_1 to "Linie oben:" & tab & tab & tab & tab & tab & "JA" & return & ¬
								"  Länge:" & tab & tab & tab & tab & tab & TextLength & return & ¬
								"  Linker Einzug:" & tab & tab & tab & ((left indent of rule above of TextProperties) as text) & return & ¬
								"  Abstand:" & tab & tab & tab & tab & tab & ((position of rule above of TextProperties) as text) & return & ¬
								"  Rechter Einzug:" & tab & tab & tab & ((right indent of rule above of TextProperties) as text) & return
							set LineAbove_2 to "" & "  Art:" & tab & tab & tab & tab & tab & tab & LineStyle & return & ¬
								"  Stärke:" & tab & tab & tab & tab & tab & ((width of rule above of TextProperties) as text) & return & ¬
								"  Farbe:" & tab & tab & tab & tab & tab & ((name of color of rule above of TextProperties) as text) & ¬
								" (" & ((color flag of color of rule above of TextProperties) as text) & ")" & return & ¬
								"  Tonwert:" & tab & tab & tab & tab & tab & ((shade of rule above of TextProperties) as text) & return & return
						else
							set LineAbove_1 to "Linie oben:" & tab & tab & tab & tab & tab & "NEIN" & return
							set LineAbove_2 to ""
						end if
						if (rule on of rule below of TextProperties) then
							if (text length of rule below of TextProperties) then
								set TextLength to "Text"
							else
								set TextLength to "Einzug"
							end if
							if (style of rule below of TextProperties) is solid line then
								set LineStyle to "Durchgezogen"
							else if (style of rule below of TextProperties) is dashed line then
								set LineStyle to "Gestrichelt"
							else if (style of rule below of TextProperties) is densely dashed line then
								set LineStyle to "Dicht gestrichelt"
							else if (style of rule below of TextProperties) is sparsely dashed line then
								set LineStyle to "Strich-Punkt"
							else if (style of rule below of TextProperties) is dotted line then
								set LineStyle to "Gepunktet"
							else if (style of rule below of TextProperties) is double line then
								set LineStyle to "Doppelt"
							else if (style of rule below of TextProperties) is thin thick line then
								set LineStyle to "Dünn-Dick"
							else if (style of rule below of TextProperties) is thick thin line then
								set LineStyle to "Dick-Dünn"
							else if (style of rule below of TextProperties) is thin thick thin line then
								set LineStyle to "Dünn-Dick-Dünn"
							else if (style of rule below of TextProperties) is thick thin thick line then
								set LineStyle to "Dick-Dünn-Dick"
							else if (style of rule below of TextProperties) is thin thin thin line then
								set LineStyle to "Dünn-Dünn-Dünn"
							end if
							set LineBelow_1 to "Linie unten:" & tab & tab & tab & tab & "JA" & return & ¬
								"  Länge:" & tab & tab & tab & tab & tab & TextLength & return & ¬
								"  Linker Einzug:" & tab & tab & tab & ((left indent of rule below of TextProperties) as text) & return & ¬
								"  Abstand:" & tab & tab & tab & tab & tab & ((position of rule below of TextProperties) as text) & return & ¬
								"  Rechter Einzug:" & tab & tab & tab & ((right indent of rule below of TextProperties) as text) & return
							set LineBelow_2 to "" & "  Art:" & tab & tab & tab & tab & tab & tab & LineStyle & return & ¬
								"  Stärke:" & tab & tab & tab & tab & tab & ((width of rule below of TextProperties) as text) & return & ¬
								"  Farbe:" & tab & tab & tab & tab & tab & ((name of color of rule below of TextProperties) as text) & ¬
								" (" & ((color flag of color of rule below of TextProperties) as text) & ")" & return & ¬
								"  Tonwert:" & tab & tab & tab & tab & tab & ((shade of rule below of TextProperties) as text) & return
						else
							set LineBelow_1 to "Linie unten:" & tab & tab & tab & tab & "NEIN" & return
							set LineBelow_2 to ""
						end if
						set TabProperties to tab list of TextProperties
						if TabProperties is not {} then
							set TabList to ""
							repeat with n from 1 to count of TabProperties
								set TabItem to item n of TabProperties
								if (justification of TabItem) is left justified then
									set TabJustification to "Linksbündig"
								else if (justification of TabItem) is centered then
									set TabJustification to "Zentriert"
								else if (justification of TabItem) is right justified then
									set TabJustification to "Rechtsbündig"
								else if (justification of TabItem) is align on then
									set AlignChar to (align character of TabItem)
									if AlignChar is "" then -- Ascii #1
										set TabJustification to "Punkt"
									else if AlignChar is "" then -- Ascii #2
										set TabJustification to "Komma"
									else
										set TabJustification to "Ausrichten an \"" & AlignChar & "\""
									end if
								end if
								set Temp to "Position:" & tab & tab & tab & tab & ((position of TabItem) as text) & return & ¬
									"  Ausrichtung:" & tab & tab & tab & TabJustification & return & ¬
									"  Füllzeichen:" & tab & tab & tab & ((fill character of TabItem) as text)
								set TabList to TabList & Temp & return & return
							end repeat
						else
							set TabList to "Tabulatoren:" & tab & tab & tab & tab & "NEIN" & return
						end if
						tell application "BBEdit 5.1"
							activate
							tell document 1
								insert text "" & return & return & "Stilvorlage:        " & StyleName & return & ¬
									"--------------------" & Divider & return & return & ¬
									"Basiert auf Stil:" & tab & BaseStyle & return & ¬
									"Nächster Stil:" & tab & tab & NextStyle & return & return
								insert text FontProperties & return & return
								insert text FormatProperties_1 & FormatProperties_2 & return & return
								insert text "  Linien" & return & "--------" & return & ¬
									LineAbove_1 & LineAbove_2 & LineBelow_1 & LineBelow_2 & return
								insert text "  Tabs" & return & "------" & return & ¬
									TabList & return
							end tell
						end tell
					end if
				end repeat
			end repeat
		end tell
		tell application "BBEdit 5.1"
			tell document 1
				go to line 1
			end tell
		end tell
	end if
end tell

 


Contact: Matthias Steffens  |  Previous  |  Main  |  Next  |  Last Updated: 15-Mar-05