Function: org-odt--render-image/formula

org-odt--render-image/formula is a byte-compiled function defined in ox-odt.el.gz.

Signature

(org-odt--render-image/formula CFG-KEY HREF WIDTH HEIGHT &optional CAPTIONS USER-FRAME-PARAMS &rest TITLE-AND-DESC)

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-odt.el.gz
;;;; Targets

(defun org-odt--render-image/formula (cfg-key href width height &optional
					      captions user-frame-params
					      &rest title-and-desc)
  (let* ((frame-cfg-alist
	  ;; Each element of this alist is of the form (CFG-HANDLE
	  ;; INNER-FRAME-PARAMS OUTER-FRAME-PARAMS).

	  ;; CFG-HANDLE is the key to the alist.

	  ;; INNER-FRAME-PARAMS and OUTER-FRAME-PARAMS specify the
	  ;; frame params for INNER-FRAME and OUTER-FRAME
	  ;; respectively.  See below.

	  ;; Configurations that are meant to be applied to
	  ;; non-captioned image/formula specifies no
	  ;; OUTER-FRAME-PARAMS.

	  ;; TERMINOLOGY
	  ;; ===========
	  ;; INNER-FRAME :: Frame that directly surrounds an
	  ;;                image/formula.

	  ;; OUTER-FRAME :: Frame that encloses the INNER-FRAME.  This
	  ;;                frame also contains the caption, if any.

	  ;; FRAME-PARAMS :: List of the form (FRAME-STYLE-NAME
	  ;;                 FRAME-ATTRIBUTES FRAME-ANCHOR).  Note
	  ;;                 that these are the last three arguments
	  ;;                 to `org-odt--frame'.

	  ;; Note that an un-captioned image/formula requires just an
	  ;; INNER-FRAME, while a captioned image/formula requires
	  ;; both an INNER and an OUTER-FRAME.
	  '(("As-CharImage" ("OrgInlineImage" nil "as-char"))
	    ("ParagraphImage" ("OrgDisplayImage" nil "paragraph"))
	    ("PageImage" ("OrgPageImage" nil "page"))
	    ("CaptionedAs-CharImage"
	     ("OrgCaptionedImage"
	      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
	     ("OrgInlineImage" nil "as-char"))
	    ("CaptionedParagraphImage"
	     ("OrgCaptionedImage"
	      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
	     ("OrgImageCaptionFrame" nil "paragraph"))
	    ("CaptionedPageImage"
	     ("OrgCaptionedImage"
	      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
	     ("OrgPageImageCaptionFrame" nil "page"))
	    ("InlineFormula" ("OrgInlineFormula" nil "as-char"))
	    ("DisplayFormula" ("OrgDisplayFormula" nil "as-char"))
	    ("CaptionedDisplayFormula"
	     ("OrgCaptionedFormula" nil "paragraph")
	     ("OrgFormulaCaptionFrame" nil "paragraph"))))
	 (caption (car captions)) (short-caption (cdr captions))
	 ;; Retrieve inner and outer frame params, from configuration.
	 (frame-cfg (assoc-string cfg-key frame-cfg-alist t))
	 (inner (nth 1 frame-cfg))
	 (outer (nth 2 frame-cfg))
	 ;; User-specified frame params (from #+ATTR_ODT spec)
	 (user user-frame-params)
	 (--merge-frame-params (lambda (default user)
				 "Merge default and user frame params."
				 (if (not user) default
				   (cl-assert (= (length default) 3))
				   (cl-assert (= (length user) 3))
				   (cl-loop for u in user
					    for d in default
					    collect (or u d))))))
    (cond
     ;; Case 1: Image/Formula has no caption.
     ;;         There is only one frame, one that surrounds the image
     ;;         or formula.
     ((not caption)
      ;; Merge user frame params with that from configuration.
      (setq inner (funcall --merge-frame-params inner user))
      (apply 'org-odt--frame href width height
	     (append inner title-and-desc)))
     ;; Case 2: Image/Formula is captioned or labeled.
     ;;         There are two frames: The inner one surrounds the
     ;;         image or formula.  The outer one contains the
     ;;         caption/sequence number.
     (t
      ;; Merge user frame params with outer frame params.
      (setq outer (funcall --merge-frame-params outer user))
      ;; Short caption, if specified, goes as part of inner frame.
      (setq inner (let ((frame-params (copy-sequence inner)))
		    (setcar (cdr frame-params)
			    (concat
			     (cadr frame-params)
			     (when short-caption
			       (format " draw:name=\"%s\" " short-caption))))
		    frame-params))
      (apply 'org-odt--textbox
	     (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
		     "Illustration"
		     (concat
		      (apply 'org-odt--frame href width height
			     (append inner title-and-desc))
		      caption))
	     width height outer)))))