/* * $Id$ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ package org.apache.fop.layout; import java.util.HashMap; import org.apache.fop.fo.properties.FontVariant; import org.apache.fop.render.pdf.CodePointMapping; public class FontState { private String _fontName; private int _fontSize; private String _fontFamily; private String _fontStyle; private int _fontWeight; /** * normal or small-caps font */ private int _fontVariant; private FontMetric _metric; private static HashMap EMPTY_HASHMAP = new HashMap(); public FontState(String key, FontMetric met, int fontSize) { _fontSize = fontSize; _fontName = key; _metric = met; } public int getAscender() { return _metric.getAscender(_fontSize) / 1000; } public int getCapHeight() { return _metric.getCapHeight(_fontSize) / 1000; } public int getDescender() { return _metric.getDescender(_fontSize) / 1000; } public String getFontName() { return _fontName; } public int getFontSize() { return _fontSize; } public int getXHeight() { return _metric.getXHeight(_fontSize) / 1000; } public HashMap getKerning() { if (_metric instanceof FontDescriptor) { HashMap ret = ((FontDescriptor)_metric).getKerningInfo(); if (ret != null) return ret; } return EMPTY_HASHMAP; } public int width(int charnum) { // returns width of given character number in millipoints return (_metric.width(charnum, _fontSize) / 1000); } /** * Map a java character (unicode) to a font character * Default uses CodePointMapping */ public char mapChar(char c) { if (_metric instanceof org.apache.fop.render.pdf.Font) { return ((org.apache.fop.render.pdf.Font)_metric).mapChar(c); } // Use default CodePointMapping char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c); if (d != 0) { c = d; } else { c = '#'; } return c; } public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append('('); sbuf.append(_fontFamily); sbuf.append(','); sbuf.append(_fontName); sbuf.append(','); sbuf.append(_fontSize); sbuf.append(','); sbuf.append(_fontStyle); sbuf.append(','); sbuf.append(_fontWeight); sbuf.append(')'); return sbuf.toString(); } } Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/FullTextSearch/Model/ISearchTemplate.php
blob: 89f683ca013bfc45e5afaeaff05090fed69f5a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCP\FullTextSearch\Model;

use OCP\FullTextSearch\IFullTextSearchProvider;

/**
 * Class ISearchTemplate
 *
 * This is a data transfer object that should be created by Content Provider
 * when the getSearchTemplate() method is called.
 *
 * The object will contain templates to be displayed, and the list of the different
 * options to be available to the user when they start a new search.
 *
 * The display of the Options is generated by the FullTextSearch app and Options
 * can be displayed in 2 places:
 *
 * - the navigation page of the app that generate the indexed content.
 *   (files, bookmarks, deck, mails, ...)
 * - the navigation page of the FullTextSearch app.
 *
 * Both pages will have different Options, and only the first one can integrate
 * a specific template.
 *
 * @see IFullTextSearchProvider::getSearchTemplate
 *
 * @since 16.0.0
 *
 */
interface ISearchTemplate {
	/**
	 * Set the class of the icon to be displayed in the left panel of the
	 * FullTextSearch navigation page, in front of the related Content Provider.
	 *
	 * @since 16.0.0
	 *
	 * @param string $class
	 *
	 * @return ISearchTemplate
	 */
	public function setIcon(string $class): ISearchTemplate;

	/**
	 * Get the class of the icon.
	 *
	 * @since 16.0.0
	 *
	 * @return string
	 */
	public function getIcon(): string;


	/**
	 * Set the path of a CSS file that will be loaded when needed.
	 *
	 * @since 16.0.0
	 *
	 * @param string $css
	 *
	 * @return ISearchTemplate
	 */
	public function setCss(string $css): ISearchTemplate;

	/**
	 * Get the path of the CSS file.
	 *
	 * @since 16.0.0
	 *
	 * @return string
	 */
	public function getCss(): string;


	/**
	 * Set the path of the file of a template that the HTML will be displayed
	 * below the Options.
	 * This should only be used if your Content Provider needs to set options in
	 * a way not generated by FullTextSearch
	 *
	 * @since 16.0.0
	 *
	 * @param string $template
	 *
	 * @return ISearchTemplate
	 */
	public function setTemplate(string $template): ISearchTemplate;

	/**
	 * Get the path of the template file.
	 *
	 * @since 16.0.0
	 *
	 * @return string
	 */
	public function getTemplate(): string;


	/**
	 * Add an option in the Panel that is displayed when the user start a search
	 * within the app that generate the content.
	 *
	 * @see ISearchOption
	 *
	 * @since 16.0.0
	 *
	 * @param ISearchOption $option
	 *
	 * @return ISearchTemplate
	 */
	public function addPanelOption(ISearchOption $option): ISearchTemplate;

	/**
	 * Get all options to be displayed in the Panel.
	 *
	 * @since 16.0.0
	 *
	 * @return ISearchOption[]
	 */
	public function getPanelOptions(): array;


	/**
	 * Add an option in the left panel of the FullTextSearch navigation page.
	 *
	 * @see ISearchOption
	 *
	 * @since 16.0.0
	 *
	 * @param ISearchOption $option
	 *
	 * @return ISearchTemplate
	 */
	public function addNavigationOption(ISearchOption $option): ISearchTemplate;

	/**
	 * Get all options to be displayed in the FullTextSearch navigation page.
	 *
	 * @since 16.0.0
	 *
	 * @return array
	 */
	public function getNavigationOptions(): array;
}