File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | |||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | |||
12 | * contributor license agreements. See the NOTICE file distributed | |||
13 | * with this work for additional information regarding copyright | |||
14 | * ownership. The ASF licenses this file to you under the Apache | |||
15 | * License, Version 2.0 (the "License"); you may not use this file | |||
16 | * except in compliance with the License. You may obtain a copy of | |||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | |||
18 | */ | |||
19 | ||||
20 | #include <memory> | |||
21 | #include <ElementsDockingWindow.hxx> | |||
22 | ||||
23 | #include <starmath.hrc> | |||
24 | #include <strings.hrc> | |||
25 | #include <smmod.hxx> | |||
26 | #include <view.hxx> | |||
27 | #include <visitors.hxx> | |||
28 | #include <document.hxx> | |||
29 | #include <node.hxx> | |||
30 | #include "uiobject.hxx" | |||
31 | #include <strings.hxx> | |||
32 | ||||
33 | #include <sfx2/dispatch.hxx> | |||
34 | #include <sfx2/sfxmodelfactory.hxx> | |||
35 | #include <svl/stritem.hxx> | |||
36 | #include <svtools/colorcfg.hxx> | |||
37 | #include <vcl/event.hxx> | |||
38 | #include <vcl/help.hxx> | |||
39 | #include <vcl/settings.hxx> | |||
40 | #include <vcl/uitest/eventdescription.hxx> | |||
41 | #include <vcl/uitest/logger.hxx> | |||
42 | ||||
43 | SmElement::SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText) : | |||
44 | mpNode(std::move(pNode)), | |||
45 | maText(aText), | |||
46 | maHelpText(aHelpText) | |||
47 | {} | |||
48 | ||||
49 | SmElement::~SmElement() | |||
50 | {} | |||
51 | ||||
52 | const std::unique_ptr<SmNode>& SmElement::getNode() const { return mpNode; } | |||
53 | ||||
54 | SmElementSeparator::SmElementSeparator() : | |||
55 | SmElement(std::unique_ptr<SmNode>(), OUString(), OUString()) | |||
56 | {} | |||
57 | ||||
58 | const SmElementDescr SmElementsControl::m_aUnaryBinaryOperatorsList[] = | |||
59 | { | |||
60 | {RID_PLUSX"+<?> ", RID_PLUSX_HELPreinterpret_cast<char const *>("RID_PLUSX_HELP" "\004" u8"+ Sign" )}, {RID_MINUSX"-<?> ", RID_MINUSX_HELPreinterpret_cast<char const *>("RID_MINUSX_HELP" "\004" u8"- Sign")}, | |||
61 | {RID_PLUSMINUSX"+-<?> ", RID_PLUSMINUSX_HELPreinterpret_cast<char const *>("RID_PLUSMINUSX_HELP" "\004" u8"+- Sign")}, {RID_MINUSPLUSX"-+<?> ", RID_MINUSPLUSX_HELPreinterpret_cast<char const *>("RID_MINUSPLUSX_HELP" "\004" u8"-+ Sign")}, | |||
62 | {nullptr, nullptr}, | |||
63 | {RID_XPLUSY"<?> + <?> ", RID_XPLUSY_HELPreinterpret_cast<char const *>("RID_XPLUSY_HELP" "\004" u8"Addition +")}, {RID_XMINUSY"<?> - <?> ", RID_XMINUSY_HELPreinterpret_cast<char const *>("RID_XMINUSY_HELP" "\004" u8"Subtraction -")}, | |||
64 | {RID_XCDOTY"<?> cdot <?> ", RID_XCDOTY_HELPreinterpret_cast<char const *>("RID_XCDOTY_HELP" "\004" u8"Multiplication (Dot)")}, {RID_XTIMESY"<?> times <?> ", RID_XTIMESY_HELPreinterpret_cast<char const *>("RID_XTIMESY_HELP" "\004" u8"Multiplication (x)")}, | |||
65 | {RID_XSYMTIMESY"<?> * <?> ", RID_XSYMTIMESY_HELPreinterpret_cast<char const *>("RID_XSYMTIMESY_HELP" "\004" u8"Multiplication (*)")}, {RID_XOVERY"{<?>} over {<?>} ", RID_XOVERY_HELPreinterpret_cast<char const *>("RID_XOVERY_HELP" "\004" u8"Division (Fraction)")}, | |||
66 | {RID_XDIVY"<?> div <?> ", RID_XDIVY_HELPreinterpret_cast<char const *>("RID_XDIVY_HELP" "\004" u8"Division (รท)" )}, {RID_XSYMDIVIDEY"<?> / <?> ", RID_XSYMDIVIDEY_HELPreinterpret_cast<char const *>("RID_XSYMDIVIDEY_HELP" "\004" u8"Division (Slash)")}, | |||
67 | {RID_XOPLUSY"<?> oplus <?> ", RID_XOPLUSY_HELPreinterpret_cast<char const *>("RID_XOPLUSY_HELP" "\004" u8"Circled Plus")}, {RID_XOMINUSY"<?> ominus <?> ", RID_XOMINUSY_HELPreinterpret_cast<char const *>("RID_XOMINUSY_HELP" "\004" u8"Circled Minus")}, | |||
68 | {RID_XODOTY"<?> odot <?> ", RID_XODOTY_HELPreinterpret_cast<char const *>("RID_XODOTY_HELP" "\004" u8"Circled Dot")}, {RID_XOTIMESY"<?> otimes <?> ", RID_XOTIMESY_HELPreinterpret_cast<char const *>("RID_XOTIMESY_HELP" "\004" u8"Tensor Product")}, | |||
69 | {RID_XODIVIDEY"<?> odivide <?> ", RID_XODIVIDEY_HELPreinterpret_cast<char const *>("RID_XODIVIDEY_HELP" "\004" u8"Circled Slash")}, {RID_XCIRCY"<?> circ <?> ", RID_XCIRCY_HELPreinterpret_cast<char const *>("RID_XCIRCY_HELP" "\004" u8"Concatenate")}, | |||
70 | {RID_XWIDESLASHY"{<?>} wideslash {<?>} ", RID_XWIDESLASHY_HELPreinterpret_cast<char const *>("RID_XWIDESLASHY_HELP" "\004" u8"Division (wideslash)")}, {RID_XWIDEBSLASHY"{<?>} widebslash {<?>} ", RID_XWIDEBSLASHY_HELPreinterpret_cast<char const *>("RID_XWIDEBSLASHY_HELP" "\004" u8"Division (counter wideslash)")}, | |||
71 | {nullptr, nullptr}, | |||
72 | {RID_NEGX"neg <?> ", RID_NEGX_HELPreinterpret_cast<char const *>("RID_NEGX_HELP" "\004" u8"Boolean NOT" )}, {RID_XANDY"<?> and <?> ", RID_XANDY_HELPreinterpret_cast<char const *>("RID_XANDY_HELP" "\004" u8"Boolean AND" )}, {RID_XORY"<?> or <?> ", RID_XORY_HELPreinterpret_cast<char const *>("RID_XORY_HELP" "\004" u8"Boolean OR" )} | |||
73 | }; | |||
74 | ||||
75 | const SmElementDescr SmElementsControl::m_aRelationsList[] = | |||
76 | { | |||
77 | {RID_XEQY"<?> = <?> ", RID_XEQY_HELPreinterpret_cast<char const *>("RID_XEQY_HELP" "\004" u8"Is Equal" )}, {RID_XNEQY"<?> <> <?> ", RID_XNEQY_HELPreinterpret_cast<char const *>("RID_XNEQY_HELP" "\004" u8"Is Not Equal" )}, {RID_XLTY"<?> < <?> ", RID_XLTY_HELPreinterpret_cast<char const *>("RID_XLTY_HELP" "\004" u8"Is Less Than" )}, | |||
78 | {RID_XLEY"<?> <= <?> ", RID_XLEY_HELPreinterpret_cast<char const *>("RID_XLEY_HELP" "\004" u8"Is Less Than Or Equal To" )}, {RID_XLESLANTY"<?> leslant <?> ", RID_XLESLANTY_HELPreinterpret_cast<char const *>("RID_XLESLANTY_HELP" "\004" u8"Is Less Than Or Equal To")}, {RID_XGTY"<?> > <?> ", RID_XGTY_HELPreinterpret_cast<char const *>("RID_XGTY_HELP" "\004" u8"Is Greater Than" )}, | |||
79 | {RID_XGEY"<?> >= <?> ", RID_XGEY_HELPreinterpret_cast<char const *>("RID_XGEY_HELP" "\004" u8"Is Greater Than Or Equal To" )}, {RID_XGESLANTY"<?> geslant <?> ", RID_XGESLANTY_HELPreinterpret_cast<char const *>("RID_XGESLANTY_HELP" "\004" u8"Is Greater Than Or Equal To")}, | |||
80 | {RID_XLLY"<?> << <?> ", RID_XLLY_HELPreinterpret_cast<char const *>("RID_XLLY_HELP" "\004" u8"Is Much Less Than" )}, {RID_XGGY"<?> >> <?> ", RID_XGGY_HELPreinterpret_cast<char const *>("RID_XGGY_HELP" "\004" u8"Is Much Greater Than" )}, | |||
81 | {nullptr, nullptr}, | |||
82 | {RID_XAPPROXY"<?> approx <?> ", RID_XAPPROXY_HELPreinterpret_cast<char const *>("RID_XAPPROXY_HELP" "\004" u8"Is Approximately Equal")}, {RID_XSIMY"<?> sim <?> ", RID_XSIMY_HELPreinterpret_cast<char const *>("RID_XSIMY_HELP" "\004" u8"Is Similar To" )}, {RID_XSIMEQY"<?> simeq <?> ", RID_XSIMEQY_HELPreinterpret_cast<char const *>("RID_XSIMEQY_HELP" "\004" u8"Is Similar Or Equal")}, | |||
83 | {RID_XEQUIVY"<?> equiv <?> ", RID_XEQUIVY_HELPreinterpret_cast<char const *>("RID_XEQUIVY_HELP" "\004" u8"Is Congruent To")}, {RID_XPROPY"<?> prop <?> ", RID_XPROPY_HELPreinterpret_cast<char const *>("RID_XPROPY_HELP" "\004" u8"Is Proportional To")}, {RID_XPARALLELY"<?> parallel <?> ", RID_XPARALLELY_HELPreinterpret_cast<char const *>("RID_XPARALLELY_HELP" "\004" u8"Is Parallel To")}, | |||
84 | {RID_XORTHOY"<?> ortho <?> ", RID_XORTHOY_HELPreinterpret_cast<char const *>("RID_XORTHOY_HELP" "\004" u8"Is Orthogonal To")}, {RID_XDIVIDESY"<?> divides <?> ", RID_XDIVIDESY_HELPreinterpret_cast<char const *>("RID_XDIVIDESY_HELP" "\004" u8"Divides")}, {RID_XNDIVIDESY"<?> ndivides <?> ", RID_XNDIVIDESY_HELPreinterpret_cast<char const *>("RID_XNDIVIDESY_HELP" "\004" u8"Does Not Divide")}, | |||
85 | {RID_XTOWARDY"<?> toward <?> ", RID_XTOWARDY_HELPreinterpret_cast<char const *>("RID_XTOWARDY_HELP" "\004" u8"Toward")}, {RID_XTRANSLY"<?> transl <?> ", RID_XTRANSLY_HELPreinterpret_cast<char const *>("RID_XTRANSLY_HELP" "\004" u8"Corresponds To (Left)")}, {RID_XTRANSRY"<?> transr <?> ", RID_XTRANSRY_HELPreinterpret_cast<char const *>("RID_XTRANSRY_HELP" "\004" u8"Corresponds To (Right)")}, | |||
86 | {RID_XDEFY"<?> def <?> ", RID_XDEFY_HELPreinterpret_cast<char const *>("RID_XDEFY_HELP" "\004" u8"Is Defined As" )}, | |||
87 | {nullptr, nullptr}, | |||
88 | {RID_DLARROW"<?> dlarrow <?> ", RID_DLARROW_HELPreinterpret_cast<char const *>("RID_DLARROW_HELP" "\004" u8"Double Arrow Left")}, {RID_DLRARROW"<?> dlrarrow <?> ", RID_DLRARROW_HELPreinterpret_cast<char const *>("RID_DLRARROW_HELP" "\004" u8"Double Arrow Left And Right")}, {RID_DRARROW"<?> drarrow <?> ", RID_DRARROW_HELPreinterpret_cast<char const *>("RID_DRARROW_HELP" "\004" u8"Double Arrow Right")}, | |||
89 | {nullptr, nullptr}, | |||
90 | {RID_XPRECEDESY"<?> prec <?> ", RID_XPRECEDESY_HELPreinterpret_cast<char const *>("RID_XPRECEDESY_HELP" "\004" u8"Precedes")}, {RID_XSUCCEEDSY"<?> succ <?> ", RID_XSUCCEEDSY_HELPreinterpret_cast<char const *>("RID_XSUCCEEDSY_HELP" "\004" u8"Succeeds")}, | |||
91 | {RID_XPRECEDESEQUALY"<?> preccurlyeq <?> ", RID_XPRECEDESEQUALY_HELPreinterpret_cast<char const *>("RID_XPRECEDESEQUALY_HELP" "\004" u8"Precedes or equal to")}, {RID_XSUCCEEDSEQUALY"<?> succcurlyeq <?> ", RID_XSUCCEEDSEQUALY_HELPreinterpret_cast<char const *>("RID_XSUCCEEDSEQUALY_HELP" "\004" u8"Succeeds or equal to")}, | |||
92 | {RID_XPRECEDESEQUIVY"<?> precsim <?> ", RID_XPRECEDESEQUIVY_HELPreinterpret_cast<char const *>("RID_XPRECEDESEQUIVY_HELP" "\004" u8"Precedes or equivalent to")}, {RID_XSUCCEEDSEQUIVY"<?> succsim <?> ", RID_XSUCCEEDSEQUIVY_HELPreinterpret_cast<char const *>("RID_XSUCCEEDSEQUIVY_HELP" "\004" u8"Succeeds or equivalent to")}, | |||
93 | {RID_XNOTPRECEDESY"<?> nprec <?> ", RID_XNOTPRECEDESY_HELPreinterpret_cast<char const *>("RID_XNOTPRECEDESY_HELP" "\004" u8"Not precedes")}, {RID_XNOTSUCCEEDSY"<?> nsucc <?> ", RID_XNOTSUCCEEDSY_HELPreinterpret_cast<char const *>("RID_XNOTSUCCEEDSY_HELP" "\004" u8"Not succeeds")}, | |||
94 | }; | |||
95 | ||||
96 | const SmElementDescr SmElementsControl::m_aSetOperationsList[] = | |||
97 | { | |||
98 | {RID_XINY"<?> in <?> ", RID_XINY_HELPreinterpret_cast<char const *>("RID_XINY_HELP" "\004" u8"Is In" )}, {RID_XNOTINY"<?> notin <?> ", RID_XNOTINY_HELPreinterpret_cast<char const *>("RID_XNOTINY_HELP" "\004" u8"Is Not In")}, {RID_XOWNSY"<?> owns <?> ", RID_XOWNSY_HELPreinterpret_cast<char const *>("RID_XOWNSY_HELP" "\004" u8"Owns")}, | |||
99 | {nullptr, nullptr}, | |||
100 | {RID_XINTERSECTIONY"<?> intersection <?> ", RID_XINTERSECTIONY_HELPreinterpret_cast<char const *>("RID_XINTERSECTIONY_HELP" "\004" u8"Intersection")}, {RID_XUNIONY"<?> union <?> ", RID_XUNIONY_HELPreinterpret_cast<char const *>("RID_XUNIONY_HELP" "\004" u8"Union")}, | |||
101 | {RID_XSETMINUSY"<?> setminus <?> ", RID_XSETMINUSY_HELPreinterpret_cast<char const *>("RID_XSETMINUSY_HELP" "\004" u8"Difference")}, {RID_XSLASHY"<?> slash <?> ", RID_XSLASHY_HELPreinterpret_cast<char const *>("RID_XSLASHY_HELP" "\004" u8"Quotient Set")}, | |||
102 | {RID_XSUBSETY"<?> subset <?> ", RID_XSUBSETY_HELPreinterpret_cast<char const *>("RID_XSUBSETY_HELP" "\004" u8"Subset")}, {RID_XSUBSETEQY"<?> subseteq <?> ", RID_XSUBSETEQY_HELPreinterpret_cast<char const *>("RID_XSUBSETEQY_HELP" "\004" u8"Subset Or Equal To")}, | |||
103 | {RID_XSUPSETY"<?> supset <?> ", RID_XSUPSETY_HELPreinterpret_cast<char const *>("RID_XSUPSETY_HELP" "\004" u8"Superset")}, {RID_XSUPSETEQY"<?> supseteq <?> ", RID_XSUPSETEQY_HELPreinterpret_cast<char const *>("RID_XSUPSETEQY_HELP" "\004" u8"Superset Or Equal To")}, | |||
104 | {RID_XNSUBSETY"<?> nsubset <?> ", RID_XNSUBSETY_HELPreinterpret_cast<char const *>("RID_XNSUBSETY_HELP" "\004" u8"Not Subset")}, {RID_XNSUBSETEQY"<?> nsubseteq <?> ", RID_XNSUBSETEQY_HELPreinterpret_cast<char const *>("RID_XNSUBSETEQY_HELP" "\004" u8"Not Subset Or Equal")}, | |||
105 | {RID_XNSUPSETY"<?> nsupset <?> ", RID_XNSUPSETY_HELPreinterpret_cast<char const *>("RID_XNSUPSETY_HELP" "\004" u8"Not Superset")}, {RID_XNSUPSETEQY"<?> nsupseteq <?> ", RID_XNSUPSETEQY_HELPreinterpret_cast<char const *>("RID_XNSUPSETEQY_HELP" "\004" u8"Not Superset Or Equal")}, | |||
106 | {nullptr, nullptr}, | |||
107 | {RID_EMPTYSET"emptyset ", RID_EMPTYSET_HELPreinterpret_cast<char const *>("RID_EMPTYSET_HELP" "\004" u8"Empty Set")}, {RID_ALEPH"aleph ", RID_ALEPH_HELPreinterpret_cast<char const *>("RID_ALEPH_HELP" "\004" u8"Aleph" )}, {RID_SETN"setN ", RID_SETN_HELPreinterpret_cast<char const *>("RID_SETN_HELP" "\004" u8"Natural Numbers Set" )}, | |||
108 | {RID_SETZ"setZ ", RID_SETZ_HELPreinterpret_cast<char const *>("RID_SETZ_HELP" "\004" u8"Integers Set" )}, {RID_SETQ"setQ ", RID_SETQ_HELPreinterpret_cast<char const *>("RID_SETQ_HELP" "\004" u8"Set of Rational Numbers" )}, {RID_SETR"setR ", RID_SETR_HELPreinterpret_cast<char const *>("RID_SETR_HELP" "\004" u8"Real Numbers Set" )}, {RID_SETC"setC ", RID_SETC_HELPreinterpret_cast<char const *>("RID_SETC_HELP" "\004" u8"Complex Numbers Set" )} | |||
109 | }; | |||
110 | ||||
111 | const SmElementDescr SmElementsControl::m_aFunctionsList[] = | |||
112 | { | |||
113 | {RID_ABSX"abs{<?>} ", RID_ABSX_HELPreinterpret_cast<char const *>("RID_ABSX_HELP" "\004" u8"Absolute Value" )}, {RID_FACTX"fact{<?>} ", RID_FACTX_HELPreinterpret_cast<char const *>("RID_FACTX_HELP" "\004" u8"Factorial" )}, {RID_SQRTX"sqrt{<?>} ", RID_SQRTX_HELPreinterpret_cast<char const *>("RID_SQRTX_HELP" "\004" u8"Square Root" )}, | |||
114 | {RID_NROOTXY"nroot{<?>}{<?>} ", RID_NROOTXY_HELPreinterpret_cast<char const *>("RID_NROOTXY_HELP" "\004" u8"N-th Root")}, {RID_RSUPX"<?>^{<?>}", RID_RSUPX_HELPreinterpret_cast<char const *>("RID_RSUPX_HELP" "\004" u8"Power" )}, {RID_EX"func e^{<?>} ", RID_EX_HELPreinterpret_cast<char const *>("RID_EX_HELP" "\004" u8"Exponential Function" )}, | |||
115 | {RID_LNX"ln(<?>) ", RID_LNX_HELPreinterpret_cast<char const *>("RID_LNX_HELP" "\004" u8"Natural Logarithm" )}, {RID_EXPX"exp(<?>) ", RID_EXPX_HELPreinterpret_cast<char const *>("RID_EXPX_HELP" "\004" u8"Exponential Function" )}, {RID_LOGX"log(<?>) ", RID_LOGX_HELPreinterpret_cast<char const *>("RID_LOGX_HELP" "\004" u8"Logarithm" )}, | |||
116 | {nullptr, nullptr}, | |||
117 | {RID_SINX"sin(<?>) ", RID_SINX_HELPreinterpret_cast<char const *>("RID_SINX_HELP" "\004" u8"Sine" )}, {RID_COSX"cos(<?>) ", RID_COSX_HELPreinterpret_cast<char const *>("RID_COSX_HELP" "\004" u8"Cosine" )}, {RID_TANX"tan(<?>) ", RID_TANX_HELPreinterpret_cast<char const *>("RID_TANX_HELP" "\004" u8"Tangent" )}, {RID_COTX"cot(<?>) ", RID_COTX_HELPreinterpret_cast<char const *>("RID_COTX_HELP" "\004" u8"Cotangent" )}, | |||
118 | {RID_SINHX"sinh(<?>) ", RID_SINHX_HELPreinterpret_cast<char const *>("RID_SINHX_HELP" "\004" u8"Hyperbolic Sine" )}, {RID_COSHX"cosh(<?>) ", RID_COSHX_HELPreinterpret_cast<char const *>("RID_COSHX_HELP" "\004" u8"Hyperbolic Cosine" )}, {RID_TANHX"tanh(<?>) ", RID_TANHX_HELPreinterpret_cast<char const *>("RID_TANHX_HELP" "\004" u8"Hyperbolic Tangent" )}, | |||
119 | {RID_COTHX"coth(<?>) ", RID_COTHX_HELPreinterpret_cast<char const *>("RID_COTHX_HELP" "\004" u8"Hyperbolic Cotangent" )}, | |||
120 | {nullptr, nullptr}, | |||
121 | {RID_ARCSINX"arcsin(<?>) ", RID_ARCSINX_HELPreinterpret_cast<char const *>("RID_ARCSINX_HELP" "\004" u8"Arcsine")}, {RID_ARCCOSX"arccos(<?>) ", RID_ARCCOSX_HELPreinterpret_cast<char const *>("RID_ARCCOSX_HELP" "\004" u8"Arccosine")}, {RID_ARCTANX"arctan(<?>) ", RID_ARCTANX_HELPreinterpret_cast<char const *>("RID_ARCTANX_HELP" "\004" u8"Arctangent")}, | |||
122 | {RID_ARCCOTX"arccot(<?>) ", RID_ARCCOTX_HELPreinterpret_cast<char const *>("RID_ARCCOTX_HELP" "\004" u8"Arccotangent")}, {RID_ARSINHX"arsinh(<?>) ", RID_ARSINHX_HELPreinterpret_cast<char const *>("RID_ARSINHX_HELP" "\004" u8"Area Hyperbolic Sine")}, {RID_ARCOSHX"arcosh(<?>) ", RID_ARCOSHX_HELPreinterpret_cast<char const *>("RID_ARCOSHX_HELP" "\004" u8"Area Hyperbolic Cosine")}, | |||
123 | {RID_ARTANHX"artanh(<?>) ", RID_ARTANHX_HELPreinterpret_cast<char const *>("RID_ARTANHX_HELP" "\004" u8"Area Hyperbolic Tangent")}, {RID_ARCOTHX"arcoth(<?>) ", RID_ARCOTHX_HELPreinterpret_cast<char const *>("RID_ARCOTHX_HELP" "\004" u8"Area Hyperbolic Cotangent")}, | |||
124 | {nullptr, nullptr}, | |||
125 | {RID_FUNCX"func func(<?>) ", RID_FUNCX_HELPreinterpret_cast<char const *>("RID_FUNCX_HELP" "\004" u8"General function" )} | |||
126 | }; | |||
127 | ||||
128 | const SmElementDescr SmElementsControl::m_aOperatorsList[] = | |||
129 | { | |||
130 | {RID_LIMX"lim <?> ", RID_LIMX_HELPreinterpret_cast<char const *>("RID_LIMX_HELP" "\004" u8"Limes" )}, {RID_LIM_FROMX"lim from{<?>} <?> ", RID_LIM_FROMX_HELPreinterpret_cast<char const *>("RID_LIM_FROMX_HELP" "\004" u8"Limes Subscript Bottom")}, | |||
131 | {RID_LIM_TOX"lim to{<?>} <?> ", RID_LIM_TOX_HELPreinterpret_cast<char const *>("RID_LIM_TOX_HELP" "\004" u8"Limes Superscript Top")}, {RID_LIM_FROMTOX"lim from{<?>} to{<?>} <?> ", RID_LIM_FROMTOX_HELPreinterpret_cast<char const *>("RID_LIM_FROMTOX_HELP" "\004" u8"Limes Sup/Sub script")}, | |||
132 | {nullptr, nullptr}, | |||
133 | {RID_LIMINFX"liminf <?> ", RID_LIMINFX_HELPreinterpret_cast<char const *>("RID_LIMINFX_HELP" "\004" u8"Limit Inferior")}, {RID_LIMINF_FROMX"liminf from{<?>} <?> ", RID_LIMINF_FROMX_HELPreinterpret_cast<char const *>("RID_LIMINF_FROMX_HELP" "\004" u8"Limit Inferior Subscript Bottom")}, | |||
134 | {RID_LIMINF_TOX"liminf to{<?>} <?> ", RID_LIMINF_TOX_HELPreinterpret_cast<char const *>("RID_LIMINF_TOX_HELP" "\004" u8"Limit Inferior Superscript Top")}, {RID_LIMINF_FROMTOX"liminf from{<?>} to{<?>} <?> ", RID_LIMINF_FROMTOX_HELPreinterpret_cast<char const *>("RID_LIMINF_FROMTOX_HELP" "\004" u8"Limit Inferior Sup/Sub script")}, | |||
135 | {nullptr, nullptr}, | |||
136 | {RID_LIMSUPX"limsup <?> ", RID_LIMSUPX_HELPreinterpret_cast<char const *>("RID_LIMSUPX_HELP" "\004" u8"Limit Superior")}, {RID_LIMSUP_FROMX"limsup from{<?>} <?> ", RID_LIMSUP_FROMX_HELPreinterpret_cast<char const *>("RID_LIMSUP_FROMX_HELP" "\004" u8"Limit Superior Subscript Bottom")}, | |||
137 | {RID_LIMSUP_TOX"limsup to{<?>} <?> ", RID_LIMSUP_TOX_HELPreinterpret_cast<char const *>("RID_LIMSUP_TOX_HELP" "\004" u8"Limit Superior Superscript Top")}, {RID_LIMSUP_FROMTOX"limsup from{<?>} to{<?>} <?> ", RID_LIMSUP_FROMTOX_HELPreinterpret_cast<char const *>("RID_LIMSUP_FROMTOX_HELP" "\004" u8"Limit Superior Sup/Sub script")}, | |||
138 | {nullptr, nullptr}, | |||
139 | {RID_SUMX"sum <?> ", RID_SUMX_HELPreinterpret_cast<char const *>("RID_SUMX_HELP" "\004" u8"Sum" )}, {RID_SUM_FROMX"sum from{<?>} <?> ", RID_SUM_FROMX_HELPreinterpret_cast<char const *>("RID_SUM_FROMX_HELP" "\004" u8"Sum Subscript Bottom")}, | |||
140 | {RID_SUM_TOX"sum to{<?>} <?> ", RID_SUM_TOX_HELPreinterpret_cast<char const *>("RID_SUM_TOX_HELP" "\004" u8"Sum Superscript Top")}, {RID_SUM_FROMTOX"sum from{<?>} to{<?>} <?> ", RID_SUM_FROMTOX_HELPreinterpret_cast<char const *>("RID_SUM_FROMTOX_HELP" "\004" u8"Sum Sup/Sub script")}, | |||
141 | {nullptr, nullptr}, | |||
142 | {RID_PRODX"prod <?> ", RID_PRODX_HELPreinterpret_cast<char const *>("RID_PRODX_HELP" "\004" u8"Product" )}, {RID_PROD_FROMX"prod from{<?>} <?> ", RID_PROD_FROMX_HELPreinterpret_cast<char const *>("RID_PROD_FROMX_HELP" "\004" u8"Product Subscript Bottom")}, | |||
143 | {RID_PROD_TOX"prod to{<?>} <?> ", RID_PROD_TOX_HELPreinterpret_cast<char const *>("RID_PROD_TOX_HELP" "\004" u8"Product Superscript Top")}, {RID_PROD_FROMTOX"prod from{<?>} to{<?>} <?> ", RID_PROD_FROMTOX_HELPreinterpret_cast<char const *>("RID_PROD_FROMTOX_HELP" "\004" u8"Product Sup/Sub script")}, | |||
144 | {nullptr, nullptr}, | |||
145 | {RID_COPRODX"coprod <?> ", RID_COPRODX_HELPreinterpret_cast<char const *>("RID_COPRODX_HELP" "\004" u8"Coproduct")}, {RID_COPROD_FROMX"coprod from{<?>} <?> ", RID_COPROD_FROMX_HELPreinterpret_cast<char const *>("RID_COPROD_FROMX_HELP" "\004" u8"Coproduct Subscript Bottom")}, | |||
146 | {RID_COPROD_TOX"coprod to{<?>} <?> ", RID_COPROD_TOX_HELPreinterpret_cast<char const *>("RID_COPROD_TOX_HELP" "\004" u8"Coproduct Superscript Top")}, {RID_COPROD_FROMTOX"coprod from{<?>} to{<?>} <?> ", RID_COPROD_FROMTOX_HELPreinterpret_cast<char const *>("RID_COPROD_FROMTOX_HELP" "\004" u8"Coproduct Sup/Sub script")}, | |||
147 | {nullptr, nullptr}, | |||
148 | {RID_INTX"int <?> ", RID_INTX_HELPreinterpret_cast<char const *>("RID_INTX_HELP" "\004" u8"Integral" )}, {RID_INT_FROMX"int from{<?>} <?> ", RID_INT_FROMX_HELPreinterpret_cast<char const *>("RID_INT_FROMX_HELP" "\004" u8"Integral Subscript Bottom")}, | |||
149 | {RID_INT_TOX"int to{<?>} <?> ", RID_INT_TOX_HELPreinterpret_cast<char const *>("RID_INT_TOX_HELP" "\004" u8"Integral Superscript Top")}, {RID_INT_FROMTOX"int from{<?>} to{<?>} <?> ", RID_INT_FROMTOX_HELPreinterpret_cast<char const *>("RID_INT_FROMTOX_HELP" "\004" u8"Integral Sup/Sub script")}, | |||
150 | {nullptr, nullptr}, | |||
151 | {RID_IINTX"iint <?> ", RID_IINTX_HELPreinterpret_cast<char const *>("RID_IINTX_HELP" "\004" u8"Double Integral" )}, {RID_IINT_FROMX"iint from{<?>} <?> ", RID_IINT_FROMX_HELPreinterpret_cast<char const *>("RID_IINT_FROMX_HELP" "\004" u8"Double Integral Subscript Bottom")}, | |||
152 | {RID_IINT_TOX"iint to{<?>} <?> ", RID_IINT_TOX_HELPreinterpret_cast<char const *>("RID_IINT_TOX_HELP" "\004" u8"Double Integral Superscript Top")}, {RID_IINT_FROMTOX"iint from{<?>} to{<?>} <?> ", RID_IINT_FROMTOX_HELPreinterpret_cast<char const *>("RID_IINT_FROMTOX_HELP" "\004" u8"Double Integral Sup/Sub script")}, | |||
153 | {nullptr, nullptr}, | |||
154 | {RID_IIINTX"iiint <?> ", RID_IIINTX_HELPreinterpret_cast<char const *>("RID_IIINTX_HELP" "\004" u8"Triple Integral")}, {RID_IIINT_FROMX"iiint from{<?>} <?> ", RID_IIINT_FROMX_HELPreinterpret_cast<char const *>("RID_IIINT_FROMX_HELP" "\004" u8"Triple Integral Subscript Bottom")}, | |||
155 | {RID_IIINT_TOX"iiint to{<?>} <?> ", RID_IIINT_TOX_HELPreinterpret_cast<char const *>("RID_IIINT_TOX_HELP" "\004" u8"Triple Integral Superscript Top")}, {RID_IIINT_FROMTOX"iiint from{<?>} to{<?>} <?> ", RID_IIINT_FROMTOX_HELPreinterpret_cast<char const *>("RID_IIINT_FROMTOX_HELP" "\004" u8"Triple Integral Sup/Sub script")}, | |||
156 | {nullptr, nullptr}, | |||
157 | {RID_LINTX"lint <?> ", RID_LINTX_HELPreinterpret_cast<char const *>("RID_LINTX_HELP" "\004" u8"Curve Integral" )}, {RID_LINT_FROMX"lint from{<?>} <?> ", RID_LINT_FROMX_HELPreinterpret_cast<char const *>("RID_LINT_FROMX_HELP" "\004" u8"Curve Integral Subscript Bottom")}, | |||
158 | {RID_LINT_TOX"lint to{<?>} <?> ", RID_LINT_TOX_HELPreinterpret_cast<char const *>("RID_LINT_TOX_HELP" "\004" u8"Curve Integral Superscript Top")}, {RID_LINT_FROMTOX"lint from{<?>} to{<?>} <?> ", RID_LINT_FROMTOX_HELPreinterpret_cast<char const *>("RID_LINT_FROMTOX_HELP" "\004" u8"Curve Integral Sup/Sub script")}, | |||
159 | {nullptr, nullptr}, | |||
160 | {RID_LLINTX"llint <?> ", RID_LLINTX_HELPreinterpret_cast<char const *>("RID_LLINTX_HELP" "\004" u8"Double Curve Integral")}, {RID_LLINT_FROMX"llint from{<?>} <?> ", RID_LLINT_FROMX_HELPreinterpret_cast<char const *>("RID_LLINT_FROMX_HELP" "\004" u8"Double Curve Integral Subscript Bottom")}, | |||
161 | {RID_LLINT_TOX"llint to{<?>} <?> ", RID_LLINT_TOX_HELPreinterpret_cast<char const *>("RID_LLINT_TOX_HELP" "\004" u8"Double Curve Integral Superscript Top")}, {RID_LLINT_FROMTOX"llint from{<?>} to{<?>} <?> ", RID_LLINT_FROMTOX_HELPreinterpret_cast<char const *>("RID_LLINT_FROMTOX_HELP" "\004" u8"Double Curve Integral Sup/Sub script")}, | |||
162 | {nullptr, nullptr}, | |||
163 | {RID_LLLINTX"lllint <?> ", RID_LLLINTX_HELPreinterpret_cast<char const *>("RID_LLLINTX_HELP" "\004" u8"Triple Curve Integral")}, {RID_LLLINT_FROMX"lllint from{<?>} <?> ", RID_LLLINT_FROMX_HELPreinterpret_cast<char const *>("RID_LLLINT_FROMX_HELP" "\004" u8"Triple Curve Integral Subscript Bottom")}, | |||
164 | {RID_LLLINT_TOX"lllint to{<?>} <?> ", RID_LLLINT_TOX_HELPreinterpret_cast<char const *>("RID_LLLINT_TOX_HELP" "\004" u8"Triple Curve Integral Superscript Top")}, {RID_LLLINT_FROMTOX"lllint from{<?>} to{<?>} <?> ", RID_LLLINT_FROMTOX_HELPreinterpret_cast<char const *>("RID_LLLINT_FROMTOX_HELP" "\004" u8"Triple Curve Integral Sup/Sub script")}, | |||
165 | {nullptr, nullptr}, | |||
166 | {RID_OPERX"oper oper <?> ", RID_OPERX_HELPreinterpret_cast<char const *>("RID_OPERX_HELP" "\004" u8"General operator" )}, {RID_OPER_FROMX"oper oper from{<?>} <?> ", RID_OPER_FROMX_HELPreinterpret_cast<char const *>("RID_OPER_FROMX_HELP" "\004" u8"General operator Subscript Bottom")}, | |||
167 | {RID_OPER_TOX"oper oper to{<?>} <?> ", RID_OPER_TOX_HELPreinterpret_cast<char const *>("RID_OPER_TOX_HELP" "\004" u8"General operator Superscript Top")}, {RID_OPER_FROMTOX"oper oper from{<?>} to{<?>} <?> ", RID_OPER_FROMTOX_HELPreinterpret_cast<char const *>("RID_OPER_FROMTOX_HELP" "\004" u8"General operator Sup/Sub script")} | |||
168 | }; | |||
169 | ||||
170 | const SmElementDescr SmElementsControl::m_aAttributesList[] = | |||
171 | { | |||
172 | {RID_ACUTEX"acute <?> ", RID_ACUTEX_HELPreinterpret_cast<char const *>("RID_ACUTEX_HELP" "\004" u8"Acute Accent")}, {RID_GRAVEX"grave <?> ", RID_GRAVEX_HELPreinterpret_cast<char const *>("RID_GRAVEX_HELP" "\004" u8"Grave Accent")}, {RID_BREVEX"breve <?> ", RID_BREVEX_HELPreinterpret_cast<char const *>("RID_BREVEX_HELP" "\004" u8"Breve")}, | |||
173 | {RID_CIRCLEX"circle <?> ", RID_CIRCLEX_HELPreinterpret_cast<char const *>("RID_CIRCLEX_HELP" "\004" u8"Circle")}, {RID_DOTX"dot <?> ", RID_DOTX_HELPreinterpret_cast<char const *>("RID_DOTX_HELP" "\004" u8"Dot" )}, {RID_DDOTX"ddot <?> ", RID_DDOTX_HELPreinterpret_cast<char const *>("RID_DDOTX_HELP" "\004" u8"Double Dot" )}, | |||
174 | {RID_DDDOTX"dddot <?> ", RID_DDDOTX_HELPreinterpret_cast<char const *>("RID_DDDOTX_HELP" "\004" u8"Triple Dot")}, {RID_BARX"bar <?> ", RID_BARX_HELPreinterpret_cast<char const *>("RID_BARX_HELP" "\004" u8"Line Above" )}, {RID_VECX"vec <?> ", RID_VECX_HELPreinterpret_cast<char const *>("RID_VECX_HELP" "\004" u8"Vector Arrow" )}, | |||
175 | {RID_HARPOONX"harpoon <?> ", RID_HARPOONX_HELPreinterpret_cast<char const *>("RID_HARPOONX_HELP" "\004" u8"Harpoon")}, | |||
176 | {RID_TILDEX"tilde <?> ", RID_TILDEX_HELPreinterpret_cast<char const *>("RID_TILDEX_HELP" "\004" u8"Tilde")}, {RID_HATX"hat <?> ", RID_HATX_HELPreinterpret_cast<char const *>("RID_HATX_HELP" "\004" u8"Circumflex" )}, {RID_CHECKX"check <?> ", RID_CHECKX_HELPreinterpret_cast<char const *>("RID_CHECKX_HELP" "\004" u8"Reverse Circumflex")}, | |||
177 | {nullptr, nullptr}, | |||
178 | {RID_WIDEVECX"widevec {<?>} ", RID_WIDEVECX_HELPreinterpret_cast<char const *>("RID_WIDEVECX_HELP" "\004" u8"Large Vector Arrow")}, {RID_WIDEHARPOONX"wideharpoon {<?>} ", RID_WIDEHARPOONX_HELPreinterpret_cast<char const *>("RID_WIDEHARPOONX_HELP" "\004" u8"Large Harpoon")}, | |||
179 | {RID_WIDETILDEX"widetilde {<?>} ", RID_WIDETILDEX_HELPreinterpret_cast<char const *>("RID_WIDETILDEX_HELP" "\004" u8"Large Tilde")}, {RID_WIDEHATX"widehat {<?>} ", RID_WIDEHATX_HELPreinterpret_cast<char const *>("RID_WIDEHATX_HELP" "\004" u8"Large Circumflex")}, | |||
180 | {RID_OVERLINEX"overline {<?>} ", RID_OVERLINEX_HELPreinterpret_cast<char const *>("RID_OVERLINEX_HELP" "\004" u8"Line Over")}, {RID_UNDERLINEX"underline {<?>} ", RID_UNDERLINEX_HELPreinterpret_cast<char const *>("RID_UNDERLINEX_HELP" "\004" u8"Line Below")}, {RID_OVERSTRIKEX"overstrike {<?>} ", RID_OVERSTRIKEX_HELPreinterpret_cast<char const *>("RID_OVERSTRIKEX_HELP" "\004" u8"Line Through")}, | |||
181 | {nullptr, nullptr}, | |||
182 | {RID_PHANTOMX"phantom {<?>} ", RID_PHANTOMX_HELPreinterpret_cast<char const *>("RID_PHANTOMX_HELP" "\004" u8"Transparent")}, {RID_BOLDX"bold <?> ", RID_BOLDX_HELPreinterpret_cast<char const *>("RID_BOLDX_HELP" "\004" u8"Bold Font" )}, {RID_ITALX"ital <?> ", RID_ITALX_HELPreinterpret_cast<char const *>("RID_ITALX_HELP" "\004" u8"Italic Font" )}, | |||
183 | {RID_SIZEXY"size <?> {<?>} ", RID_SIZEXY_HELPreinterpret_cast<char const *>("RID_SIZEXY_HELP" "\004" u8"Resize")}, {RID_FONTXY"font <?> {<?>} ", RID_FONTXY_HELPreinterpret_cast<char const *>("RID_FONTXY_HELP" "\004" u8"Change Font")}, | |||
184 | {nullptr, nullptr}, | |||
185 | {RID_COLORX_BLACK"color black {<?>} ", RID_COLORX_BLACK_HELPreinterpret_cast<char const *>("RID_COLORX_BLACK_HELP" "\004" u8"Color Black")}, {RID_COLORX_BLUE"color blue {<?>} ", RID_COLORX_BLUE_HELPreinterpret_cast<char const *>("RID_COLORX_BLUE_HELP" "\004" u8"Color Blue")}, | |||
186 | {RID_COLORX_GREEN"color green {<?>} ", RID_COLORX_GREEN_HELPreinterpret_cast<char const *>("RID_COLORX_GREEN_HELP" "\004" u8"Color Green")}, {RID_COLORX_RED"color red {<?>} ", RID_COLORX_RED_HELPreinterpret_cast<char const *>("RID_COLORX_RED_HELP" "\004" u8"Color Red")}, | |||
187 | {RID_COLORX_CYAN"color cyan {<?>} ", RID_COLORX_CYAN_HELPreinterpret_cast<char const *>("RID_COLORX_CYAN_HELP" "\004" u8"Color Cyan")}, {RID_COLORX_MAGENTA"color magenta {<?>} ", RID_COLORX_MAGENTA_HELPreinterpret_cast<char const *>("RID_COLORX_MAGENTA_HELP" "\004" u8"Color Magenta")}, | |||
188 | {RID_COLORX_YELLOW"color yellow {<?>} ", RID_COLORX_YELLOW_HELPreinterpret_cast<char const *>("RID_COLORX_YELLOW_HELP" "\004" u8"Color Yellow")}, {RID_COLORX_GRAY"color gray {<?>} ", RID_COLORX_GRAY_HELPreinterpret_cast<char const *>("RID_COLORX_GRAY_HELP" "\004" u8"Color Gray")}, | |||
189 | {RID_COLORX_LIME"color lime {<?>} ", RID_COLORX_LIME_HELPreinterpret_cast<char const *>("RID_COLORX_LIME_HELP" "\004" u8"Color Lime")}, {RID_COLORX_MAROON"color maroon {<?>} ", RID_COLORX_MAROON_HELPreinterpret_cast<char const *>("RID_COLORX_MAROON_HELP" "\004" u8"Color Maroon")}, | |||
190 | {RID_COLORX_NAVY"color navy {<?>} ", RID_COLORX_NAVY_HELPreinterpret_cast<char const *>("RID_COLORX_NAVY_HELP" "\004" u8"Color Navy")}, {RID_COLORX_OLIVE"color olive {<?>} ", RID_COLORX_OLIVE_HELPreinterpret_cast<char const *>("RID_COLORX_OLIVE_HELP" "\004" u8"Color Olive")}, | |||
191 | {RID_COLORX_PURPLE"color purple {<?>} ", RID_COLORX_PURPLE_HELPreinterpret_cast<char const *>("RID_COLORX_PURPLE_HELP" "\004" u8"Color Purple")}, {RID_COLORX_SILVER"color silver {<?>} ", RID_COLORX_SILVER_HELPreinterpret_cast<char const *>("RID_COLORX_SILVER_HELP" "\004" u8"Color Silver")}, | |||
192 | {RID_COLORX_TEAL"color teal {<?>} ", RID_COLORX_TEAL_HELPreinterpret_cast<char const *>("RID_COLORX_TEAL_HELP" "\004" u8"Color Teal")},{RID_COLORX_RGB"color rgb 0 0 0 {<?>} ", RID_COLORX_RGB_HELPreinterpret_cast<char const *>("RID_COLORX_RGB_HELP" "\004" u8"Color RGB")} | |||
193 | }; | |||
194 | ||||
195 | const SmElementDescr SmElementsControl::m_aBracketsList[] = | |||
196 | { | |||
197 | {RID_LRGROUPX"{<?>} ", RID_LRGROUPX_HELPreinterpret_cast<char const *>("RID_LRGROUPX_HELP" "\004" u8"Group Brackets")}, | |||
198 | {nullptr, nullptr}, | |||
199 | {RID_LRPARENTX"(<?>) ", RID_LRPARENTX_HELPreinterpret_cast<char const *>("RID_LRPARENTX_HELP" "\004" u8"Round Brackets")}, {RID_LRBRACKETX"[<?>] ", RID_LRBRACKETX_HELPreinterpret_cast<char const *>("RID_LRBRACKETX_HELP" "\004" u8"Square Brackets")}, | |||
200 | {RID_LRDBRACKETX"ldbracket <?> rdbracket ", RID_LRDBRACKETX_HELPreinterpret_cast<char const *>("RID_LRDBRACKETX_HELP" "\004" u8"Double Square Brackets")}, {RID_LRBRACEX"lbrace <?> rbrace ", RID_LRBRACEX_HELPreinterpret_cast<char const *>("RID_LRBRACEX_HELP" "\004" u8"Braces")}, | |||
201 | {RID_LRANGLEX"langle <?> rangle ", RID_LRANGLEX_HELPreinterpret_cast<char const *>("RID_LRANGLEX_HELP" "\004" u8"Angle Brackets")}, {RID_LMRANGLEXY"langle <?> mline <?> rangle ", RID_LMRANGLEXY_HELPreinterpret_cast<char const *>("RID_LMRANGLEXY_HELP" "\004" u8"Operator Brackets")}, | |||
202 | {RID_LRCEILX"lceil <?> rceil ", RID_LRCEILX_HELPreinterpret_cast<char const *>("RID_LRCEILX_HELP" "\004" u8"Upper Ceil")}, {RID_LRFLOORX"lfloor <?> rfloor ", RID_LRFLOORX_HELPreinterpret_cast<char const *>("RID_LRFLOORX_HELP" "\004" u8"Floor")}, | |||
203 | {RID_LRLINEX"lline <?> rline ", RID_LRLINEX_HELPreinterpret_cast<char const *>("RID_LRLINEX_HELP" "\004" u8"Single Lines")}, {RID_LRDLINEX"ldline <?> rdline ", RID_LRDLINEX_HELPreinterpret_cast<char const *>("RID_LRDLINEX_HELP" "\004" u8"Double Lines")}, | |||
204 | {nullptr, nullptr}, | |||
205 | {RID_SLRPARENTX"left ( <?> right ) ", RID_SLRPARENTX_HELPreinterpret_cast<char const *>("RID_SLRPARENTX_HELP" "\004" u8"Round Brackets (Scalable)")}, {RID_SLRBRACKETX"left [ <?> right ] ", RID_SLRBRACKETX_HELPreinterpret_cast<char const *>("RID_SLRBRACKETX_HELP" "\004" u8"Square Brackets (Scalable)")}, | |||
206 | {RID_SLRDBRACKETX"left ldbracket <?> right rdbracket ", RID_SLRDBRACKETX_HELPreinterpret_cast<char const *>("RID_SLRDBRACKETX_HELP" "\004" u8"Double Square Brackets (Scalable)")}, {RID_SLRBRACEX"left lbrace <?> right rbrace ", RID_SLRBRACEX_HELPreinterpret_cast<char const *>("RID_SLRBRACEX_HELP" "\004" u8"Braces (Scalable)")}, | |||
207 | {RID_SLRANGLEX"left langle <?> right rangle ", RID_SLRANGLEX_HELPreinterpret_cast<char const *>("RID_SLRANGLEX_HELP" "\004" u8"Angle Brackets (Scalable)")}, {RID_SLMRANGLEXY"left langle <?> mline <?> right rangle ", RID_SLMRANGLEXY_HELPreinterpret_cast<char const *>("RID_SLMRANGLEXY_HELP" "\004" u8"Operator Brackets (Scalable)")}, | |||
208 | {RID_SLRCEILX"left lceil <?> right rceil ", RID_SLRCEILX_HELPreinterpret_cast<char const *>("RID_SLRCEILX_HELP" "\004" u8"Ceiling (Scalable)")}, {RID_SLRFLOORX"left lfloor <?> right rfloor ", RID_SLRFLOORX_HELPreinterpret_cast<char const *>("RID_SLRFLOORX_HELP" "\004" u8"Floor (Scalable)")}, | |||
209 | {RID_SLRLINEX"left lline <?> right rline ", RID_SLRLINEX_HELPreinterpret_cast<char const *>("RID_SLRLINEX_HELP" "\004" u8"Single Lines (Scalable)")}, {RID_SLRDLINEX"left ldline <?> right rdline ", RID_SLRDLINEX_HELPreinterpret_cast<char const *>("RID_SLRDLINEX_HELP" "\004" u8"Double Lines (Scalable)")}, | |||
210 | {RID_XEVALUATEDATY"left none {<?>} right rline_{<?>} ", RID_XEVALUATEDATY_HELPreinterpret_cast<char const *>("RID_XEVALUATEDATY_HELP" "\004" u8"Evaluated At")}, | |||
211 | {nullptr, nullptr}, | |||
212 | {RID_XOVERBRACEY"{<?>} overbrace {<?>} ", RID_XOVERBRACEY_HELPreinterpret_cast<char const *>("RID_XOVERBRACEY_HELP" "\004" u8"Braces Top (Scalable)")}, {RID_XUNDERBRACEY"{<?>} underbrace {<?>} ", RID_XUNDERBRACEY_HELPreinterpret_cast<char const *>("RID_XUNDERBRACEY_HELP" "\004" u8"Braces Bottom (Scalable)")}, | |||
213 | }; | |||
214 | ||||
215 | const SmElementDescr SmElementsControl::m_aFormatsList[] = | |||
216 | { | |||
217 | {RID_RSUPX"<?>^{<?>}", RID_RSUPX_HELPreinterpret_cast<char const *>("RID_RSUPX_HELP" "\004" u8"Power" )}, {RID_RSUBX"<?>_{<?>}", RID_RSUBX_HELPreinterpret_cast<char const *>("RID_RSUBX_HELP" "\004" u8"Subscript Right" )}, {RID_LSUPX"<?> lsup{<?>} ", RID_LSUPX_HELPreinterpret_cast<char const *>("RID_LSUPX_HELP" "\004" u8"Superscript Left" )}, | |||
218 | {RID_LSUBX"<?> lsub{<?>} ", RID_LSUBX_HELPreinterpret_cast<char const *>("RID_LSUBX_HELP" "\004" u8"Subscript Left" )}, {RID_CSUPX"<?> csup{<?>} ", RID_CSUPX_HELPreinterpret_cast<char const *>("RID_CSUPX_HELP" "\004" u8"Superscript Top" )}, {RID_CSUBX"<?> csub{<?>} ", RID_CSUBX_HELPreinterpret_cast<char const *>("RID_CSUBX_HELP" "\004" u8"Subscript Bottom" )}, | |||
219 | {nullptr, nullptr}, | |||
220 | {RID_NEWLINE"newline ", RID_NEWLINE_HELPreinterpret_cast<char const *>("RID_NEWLINE_HELP" "\004" u8"New Line")}, {RID_SBLANK"`", RID_SBLANK_HELPreinterpret_cast<char const *>("RID_SBLANK_HELP" "\004" u8"Small Gap")}, {RID_BLANK"~", RID_BLANK_HELPreinterpret_cast<char const *>("RID_BLANK_HELP" "\004" u8"Blank" )}, | |||
221 | {RID_NOSPACE"nospace {<?>} ", RID_NOSPACE_HELPreinterpret_cast<char const *>("RID_NOSPACE_HELP" "\004" u8"No space")}, | |||
222 | {RID_ALIGNLX"alignl <?> ", RID_ALIGNLX_HELPreinterpret_cast<char const *>("RID_ALIGNLX_HELP" "\004" u8"Align Left")}, {RID_ALIGNCX"alignc <?> ", RID_ALIGNCX_HELPreinterpret_cast<char const *>("RID_ALIGNCX_HELP" "\004" u8"Align Center")}, {RID_ALIGNRX"alignr <?> ", RID_ALIGNRX_HELPreinterpret_cast<char const *>("RID_ALIGNRX_HELP" "\004" u8"Align Right")}, | |||
223 | {nullptr, nullptr}, | |||
224 | {RID_BINOMXY"binom{<?>}{<?>} ", RID_BINOMXY_HELPreinterpret_cast<char const *>("RID_BINOMXY_HELP" "\004" u8"Vertical Stack (2 Elements)")}, {RID_STACK"stack{<?> # <?> # <?>} ", RID_STACK_HELPreinterpret_cast<char const *>("RID_STACK_HELP" "\004" u8"Vertical Stack" )}, | |||
225 | {RID_MATRIX"matrix{<?> # <?> ## <?> # <?>} ", RID_MATRIX_HELPreinterpret_cast<char const *>("RID_MATRIX_HELP" "\004" u8"Matrix Stack")}, | |||
226 | }; | |||
227 | ||||
228 | const SmElementDescr SmElementsControl::m_aOthersList[] = | |||
229 | { | |||
230 | {RID_INFINITY"infinity ", RID_INFINITY_HELPreinterpret_cast<char const *>("RID_INFINITY_HELP" "\004" u8"Infinity")}, {RID_PARTIAL"partial ", RID_PARTIAL_HELPreinterpret_cast<char const *>("RID_PARTIAL_HELP" "\004" u8"Partial")}, {RID_NABLA"nabla ", RID_NABLA_HELPreinterpret_cast<char const *>("RID_NABLA_HELP" "\004" u8"Nabla" )}, | |||
231 | {RID_EXISTS"exists ", RID_EXISTS_HELPreinterpret_cast<char const *>("RID_EXISTS_HELP" "\004" u8"There Exists")}, {RID_NOTEXISTS"notexists ", RID_NOTEXISTS_HELPreinterpret_cast<char const *>("RID_NOTEXISTS_HELP" "\004" u8"There Not Exists")}, {RID_FORALL"forall ", RID_FORALL_HELPreinterpret_cast<char const *>("RID_FORALL_HELP" "\004" u8"For all")}, | |||
232 | {RID_HBAR"hbar ", RID_HBAR_HELPreinterpret_cast<char const *>("RID_HBAR_HELP" "\004" u8"h Bar" )}, {RID_LAMBDABAR"lambdabar ", RID_LAMBDABAR_HELPreinterpret_cast<char const *>("RID_LAMBDABAR_HELP" "\004" u8"Lambda Bar")}, {RID_RE"Re ", RID_RE_HELPreinterpret_cast<char const *>("RID_RE_HELP" "\004" u8"Real Part" )}, | |||
233 | {RID_IM"Im ", RID_IM_HELPreinterpret_cast<char const *>("RID_IM_HELP" "\004" u8"Imaginary Part" )}, {RID_WP"wp ", RID_WP_HELPreinterpret_cast<char const *>("RID_WP_HELP" "\004" u8"Weierstrass p" )}, {RID_LAPLACE"laplace ", RID_LAPLACE_HELPreinterpret_cast<char const *>("RID_LAPLACE_HELP" "\004" u8"Laplace transform")}, | |||
234 | {RID_FOURIER"fourier ", RID_FOURIER_HELPreinterpret_cast<char const *>("RID_FOURIER_HELP" "\004" u8"Fourier transform")}, | |||
235 | {nullptr, nullptr}, | |||
236 | {RID_LEFTARROW"leftarrow ", RID_LEFTARROW_HELPreinterpret_cast<char const *>("RID_LEFTARROW_HELP" "\004" u8"Left Arrow")}, {RID_RIGHTARROW"rightarrow ", RID_RIGHTARROW_HELPreinterpret_cast<char const *>("RID_RIGHTARROW_HELP" "\004" u8"Right Arrow")}, {RID_UPARROW"uparrow ", RID_UPARROW_HELPreinterpret_cast<char const *>("RID_UPARROW_HELP" "\004" u8"Up Arrow")}, | |||
237 | {RID_DOWNARROW"downarrow ", RID_DOWNARROW_HELPreinterpret_cast<char const *>("RID_DOWNARROW_HELP" "\004" u8"Down Arrow")}, | |||
238 | {nullptr, nullptr}, | |||
239 | {RID_DOTSLOW"dotslow ", RID_DOTSLOW_HELPreinterpret_cast<char const *>("RID_DOTSLOW_HELP" "\004" u8"Dots At Bottom")}, {RID_DOTSAXIS"dotsaxis ", RID_DOTSAXIS_HELPreinterpret_cast<char const *>("RID_DOTSAXIS_HELP" "\004" u8"Dots In Middle")}, {RID_DOTSVERT"dotsvert ", RID_DOTSVERT_HELPreinterpret_cast<char const *>("RID_DOTSVERT_HELP" "\004" u8"Dots Vertically")}, | |||
240 | {RID_DOTSUP"dotsup ", RID_DOTSUP_HELPreinterpret_cast<char const *>("RID_DOTSUP_HELP" "\004" u8"Dots To Top")}, {RID_DOTSDOWN"dotsdown ", RID_DOTSDOWN_HELPreinterpret_cast<char const *>("RID_DOTSDOWN_HELP" "\004" u8"Dots To Bottom")} | |||
241 | }; | |||
242 | ||||
243 | const SmElementDescr SmElementsControl::m_aExamplesList[] = | |||
244 | { | |||
245 | {"C=%pi cdot d = 2 cdot %pi cdot r", RID_EXAMPLE_CIRCUMFERENCE_HELPreinterpret_cast<char const *>("RID_EXAMPLE_CIRCUMFERENCE_HELP" "\004" u8"Circumference")}, | |||
246 | {"E=mc^2", RID_EXAMPLE_MASS_ENERGY_EQUIV_HELPreinterpret_cast<char const *>("RID_EXAMPLE_MASS_ENERGY_EQUIV_HELP" "\004" u8"Massโenergy equivalence")}, | |||
247 | {"a^2 + b^2 = c^2", RID_EXAMPLE_PYTHAGOREAN_THEO_HELPreinterpret_cast<char const *>("RID_EXAMPLE_PYTHAGOREAN_THEO_HELP" "\004" u8"Pythagorean theorem")}, | |||
248 | {"f ( x ) = sum from { { i = 0 } } to { infinity } { {f^{(i)}(0)} over {i!} x^i}", RID_EXAMPLE_A_SIMPLE_SERIES_HELPreinterpret_cast<char const *>("RID_EXAMPLE_A_SIMPLE_SERIES_HELP" "\004" u8"A simple series")}, | |||
249 | {"f ( x ) = {1} over {%sigma sqrt{2%pi} }func e^-{{(x-%mu)^2} over {2%sigma^2}}", RID_EXAMPLE_GAUSS_DISTRIBUTION_HELPreinterpret_cast<char const *>("RID_EXAMPLE_GAUSS_DISTRIBUTION_HELP" "\004" u8"Gauss distribution")}, | |||
250 | }; | |||
251 | ||||
252 | #define AS_PAIR(a)a, (sizeof(sal_n_array_size(a))) a, SAL_N_ELEMENTS(a)(sizeof(sal_n_array_size(a))) | |||
253 | const std::tuple<const char*, const SmElementDescr*, size_t> SmElementsControl::m_aCategories[] = | |||
254 | { | |||
255 | {RID_CATEGORY_UNARY_BINARY_OPERATORSreinterpret_cast<char const *>("RID_CATEGORY_UNARY_BINARY_OPERATORS" "\004" u8"Unary/Binary Operators"), AS_PAIR(m_aUnaryBinaryOperatorsList)m_aUnaryBinaryOperatorsList, (sizeof(sal_n_array_size(m_aUnaryBinaryOperatorsList )))}, | |||
256 | {RID_CATEGORY_RELATIONSreinterpret_cast<char const *>("RID_CATEGORY_RELATIONS" "\004" u8"Relations"), AS_PAIR(m_aRelationsList)m_aRelationsList, (sizeof(sal_n_array_size(m_aRelationsList)) )}, | |||
257 | {RID_CATEGORY_SET_OPERATIONSreinterpret_cast<char const *>("RID_CATEGORY_SET_OPERATIONS" "\004" u8"Set Operations"), AS_PAIR(m_aSetOperationsList)m_aSetOperationsList, (sizeof(sal_n_array_size(m_aSetOperationsList )))}, | |||
258 | {RID_CATEGORY_FUNCTIONSreinterpret_cast<char const *>("RID_CATEGORY_FUNCTIONS" "\004" u8"Functions"), AS_PAIR(m_aFunctionsList)m_aFunctionsList, (sizeof(sal_n_array_size(m_aFunctionsList)) )}, | |||
259 | {RID_CATEGORY_OPERATORSreinterpret_cast<char const *>("RID_CATEGORY_OPERATORS" "\004" u8"Operators"), AS_PAIR(m_aOperatorsList)m_aOperatorsList, (sizeof(sal_n_array_size(m_aOperatorsList)) )}, | |||
260 | {RID_CATEGORY_ATTRIBUTESreinterpret_cast<char const *>("RID_CATEGORY_ATTRIBUTES" "\004" u8"Attributes"), AS_PAIR(m_aAttributesList)m_aAttributesList, (sizeof(sal_n_array_size(m_aAttributesList )))}, | |||
261 | {RID_CATEGORY_BRACKETSreinterpret_cast<char const *>("RID_CATEGORY_BRACKETS" "\004" u8"Brackets"), AS_PAIR(m_aBracketsList)m_aBracketsList, (sizeof(sal_n_array_size(m_aBracketsList)))}, | |||
262 | {RID_CATEGORY_FORMATSreinterpret_cast<char const *>("RID_CATEGORY_FORMATS" "\004" u8"Formats"), AS_PAIR(m_aFormatsList)m_aFormatsList, (sizeof(sal_n_array_size(m_aFormatsList)))}, | |||
263 | {RID_CATEGORY_OTHERSreinterpret_cast<char const *>("RID_CATEGORY_OTHERS" "\004" u8"Others"), AS_PAIR(m_aOthersList)m_aOthersList, (sizeof(sal_n_array_size(m_aOthersList)))}, | |||
264 | {RID_CATEGORY_EXAMPLESreinterpret_cast<char const *>("RID_CATEGORY_EXAMPLES" "\004" u8"Examples"), AS_PAIR(m_aExamplesList)m_aExamplesList, (sizeof(sal_n_array_size(m_aExamplesList)))}, | |||
265 | }; | |||
266 | ||||
267 | const size_t SmElementsControl::m_aCategoriesSize = SAL_N_ELEMENTS(m_aCategories)(sizeof(sal_n_array_size(m_aCategories))); | |||
268 | ||||
269 | SmElementsControl::SmElementsControl(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow) | |||
270 | : mpDocShell(new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT)) | |||
271 | , m_nCurrentElement(SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
272 | , m_nCurrentRolloverElement(SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
273 | , m_nCurrentOffset(1) // Default offset of 1 due to the ScrollBar child | |||
274 | , mbVerticalMode(true) | |||
275 | , mxScroll(std::move(xScrolledWindow)) | |||
276 | , m_bFirstPaintAfterLayout(false) | |||
277 | { | |||
278 | mxScroll->connect_hadjustment_changed( LINK(this, SmElementsControl, ScrollHdl)::tools::detail::makeLink( ::tools::detail::castTo<SmElementsControl *>(this), &SmElementsControl::LinkStubScrollHdl) ); | |||
279 | mxScroll->connect_vadjustment_changed( LINK(this, SmElementsControl, ScrollHdl)::tools::detail::makeLink( ::tools::detail::castTo<SmElementsControl *>(this), &SmElementsControl::LinkStubScrollHdl) ); | |||
280 | } | |||
281 | ||||
282 | SmElementsControl::~SmElementsControl() | |||
283 | { | |||
284 | mpDocShell->DoClose(); | |||
285 | } | |||
286 | ||||
287 | void SmElementsControl::setVerticalMode(bool bVerticalMode) | |||
288 | { | |||
289 | if (mbVerticalMode == bVerticalMode) | |||
290 | return; | |||
291 | mbVerticalMode = bVerticalMode; | |||
292 | // turn off scrollbars, LayoutOrPaintContents will enable whichever one | |||
293 | // might be needed | |||
294 | mxScroll->set_vpolicy(VclPolicyType::NEVER); | |||
295 | mxScroll->set_hpolicy(VclPolicyType::NEVER); | |||
296 | LayoutOrPaintContents(GetDrawingArea()->get_ref_device(), false); | |||
297 | Invalidate(); | |||
298 | } | |||
299 | ||||
300 | SmElement* SmElementsControl::current() const | |||
301 | { | |||
302 | sal_uInt16 nCur = (m_nCurrentRolloverElement != SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
303 | ? m_nCurrentRolloverElement | |||
304 | : (HasFocus() ? m_nCurrentElement : SAL_MAX_UINT16((sal_uInt16) 0xFFFF)); | |||
305 | return (nCur < maElementList.size()) ? maElementList[nCur].get() : nullptr; | |||
306 | } | |||
307 | ||||
308 | void SmElementsControl::setCurrentElement(sal_uInt16 nPos) | |||
309 | { | |||
310 | if (m_nCurrentElement == nPos) | |||
311 | return; | |||
312 | if (nPos != SAL_MAX_UINT16((sal_uInt16) 0xFFFF) && nPos >= maElementList.size()) | |||
313 | return; | |||
314 | if (m_xAccessible.is() && m_nCurrentElement != SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
315 | m_xAccessible->ReleaseFocus(m_nCurrentElement); | |||
316 | m_nCurrentElement = nPos; | |||
317 | if (m_xAccessible.is() && m_nCurrentElement != SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
318 | m_xAccessible->AcquireFocus(); | |||
319 | } | |||
320 | ||||
321 | Color SmElementsControl::GetTextColor() | |||
322 | { | |||
323 | const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); | |||
324 | return rStyleSettings.GetFieldTextColor(); | |||
325 | } | |||
326 | ||||
327 | Color SmElementsControl::GetControlBackground() | |||
328 | { | |||
329 | const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); | |||
330 | return rStyleSettings.GetFieldColor(); | |||
331 | } | |||
332 | ||||
333 | /** | |||
334 | * !bDraw => layout only | |||
335 | * | |||
336 | * Layouting is always done without a scrollbar and will show or hide it. | |||
337 | * The first paint (m_bFirstPaintAfterLayout) therefore needs to update a | |||
338 | * visible scrollbar, because the layouting was wrong. | |||
339 | **/ | |||
340 | void SmElementsControl::LayoutOrPaintContents(vcl::RenderContext& rContext, bool bDraw) | |||
341 | { | |||
342 | rContext.Push(); | |||
343 | ||||
344 | rContext.SetMapMode( MapMode(MapUnit::Map100thMM) ); | |||
345 | rContext.SetDrawMode( DrawModeFlags::Default ); | |||
346 | rContext.SetLayoutMode( ComplexTextLayoutFlags::Default ); | |||
347 | rContext.SetDigitLanguage( LANGUAGE_ENGLISHLanguageType(0x0009) ); | |||
348 | if (bDraw) | |||
349 | { | |||
350 | rContext.SetBackground(GetControlBackground()); | |||
351 | rContext.SetTextColor(GetTextColor()); | |||
352 | rContext.Erase(); | |||
353 | } | |||
354 | ||||
355 | const sal_Int32 nControlHeight = GetOutputSizePixel().Height(); | |||
356 | const sal_Int32 nControlWidth = GetOutputSizePixel().Width(); | |||
357 | ||||
358 | sal_Int32 boxX = maMaxElementDimensions.Width() + 10; | |||
359 | sal_Int32 boxY = maMaxElementDimensions.Height() + 10; | |||
360 | ||||
361 | sal_Int32 x = mbVerticalMode ? -mxScroll->hadjustment_get_value() : 0; | |||
362 | sal_Int32 y = !mbVerticalMode ? -mxScroll->vadjustment_get_value() : 0; | |||
363 | ||||
364 | sal_Int32 perLine = 0; | |||
365 | ||||
366 | if (mbVerticalMode) | |||
367 | perLine = nControlHeight / boxY; | |||
368 | else | |||
369 | perLine = nControlWidth / boxX; | |||
370 | if (perLine <= 0) | |||
371 | perLine = 1; | |||
372 | ||||
373 | if (mbVerticalMode) | |||
374 | boxY = nControlHeight / perLine; | |||
375 | else | |||
376 | boxX = nControlWidth / perLine; | |||
377 | ||||
378 | const SmElement* pCurrentElement = current(); | |||
379 | for (const std::unique_ptr<SmElement> & i : maElementList) | |||
380 | { | |||
381 | SmElement* element = i.get(); | |||
382 | if (element->isSeparator()) | |||
383 | { | |||
384 | if (mbVerticalMode) | |||
385 | { | |||
386 | x += boxX; | |||
387 | y = 0; | |||
388 | ||||
389 | element->mBoxLocation = Point(x, y); | |||
390 | element->mBoxSize = Size(10, nControlHeight); | |||
391 | ||||
392 | tools::Rectangle aSelectionRectangle(x + 5 - 1, y + 5, | |||
393 | x + 5 + 1, nControlHeight - 5); | |||
394 | ||||
395 | if (bDraw) | |||
396 | rContext.DrawRect(rContext.PixelToLogic(aSelectionRectangle)); | |||
397 | x += 10; | |||
398 | } | |||
399 | else | |||
400 | { | |||
401 | x = 0; | |||
402 | y += boxY; | |||
403 | ||||
404 | element->mBoxLocation = Point(x, y); | |||
405 | element->mBoxSize = Size(nControlWidth, 10); | |||
406 | ||||
407 | tools::Rectangle aSelectionRectangle(x + 5, y + 5 - 1, | |||
408 | nControlWidth - 5, y + 5 + 1); | |||
409 | ||||
410 | if (bDraw) | |||
411 | rContext.DrawRect(rContext.PixelToLogic(aSelectionRectangle)); | |||
412 | y += 10; | |||
413 | } | |||
414 | } | |||
415 | else | |||
416 | { | |||
417 | if (mbVerticalMode) | |||
418 | { | |||
419 | if (y + boxY > nControlHeight) | |||
420 | { | |||
421 | x += boxX; | |||
422 | y = 0; | |||
423 | } | |||
424 | } | |||
425 | else | |||
426 | { | |||
427 | if ( x + boxX > nControlWidth) | |||
428 | { | |||
429 | x = 0; | |||
430 | y += boxY; | |||
431 | } | |||
432 | } | |||
433 | ||||
434 | element->mBoxLocation = Point(x,y); | |||
435 | element->mBoxSize = Size(boxX, boxY); | |||
436 | ||||
437 | if (bDraw) | |||
438 | { | |||
439 | if (pCurrentElement == element) | |||
440 | { | |||
441 | rContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR); | |||
442 | const StyleSettings& rStyleSettings = rContext.GetSettings().GetStyleSettings(); | |||
443 | rContext.SetLineColor(rStyleSettings.GetHighlightColor()); | |||
444 | rContext.SetFillColor(COL_TRANSPARENT); | |||
445 | rContext.DrawRect(rContext.PixelToLogic(tools::Rectangle(x + 1, y + 1, x + boxX - 1, y + boxY - 1))); | |||
446 | rContext.DrawRect(rContext.PixelToLogic(tools::Rectangle(x + 2, y + 2, x + boxX - 2, y + boxY - 2))); | |||
447 | rContext.Pop(); | |||
448 | } | |||
449 | ||||
450 | Size aSizePixel = rContext.LogicToPixel(Size(element->getNode()->GetWidth(), | |||
451 | element->getNode()->GetHeight())); | |||
452 | Point location(x + ((boxX - aSizePixel.Width()) / 2), | |||
453 | y + ((boxY - aSizePixel.Height()) / 2)); | |||
454 | SmDrawingVisitor(rContext, rContext.PixelToLogic(location), element->getNode().get()); | |||
455 | } | |||
456 | ||||
457 | if (mbVerticalMode) | |||
458 | y += boxY; | |||
459 | else | |||
460 | x += boxX; | |||
461 | } | |||
462 | } | |||
463 | ||||
464 | if (bDraw) | |||
465 | { | |||
466 | if (!m_bFirstPaintAfterLayout) | |||
467 | { | |||
468 | rContext.Pop(); | |||
469 | return; | |||
470 | } | |||
471 | m_bFirstPaintAfterLayout = false; | |||
472 | } | |||
473 | else | |||
474 | m_bFirstPaintAfterLayout = true; | |||
475 | ||||
476 | if (mbVerticalMode) | |||
477 | { | |||
478 | sal_Int32 nTotalControlWidth = x + boxX + mxScroll->hadjustment_get_value(); | |||
479 | if (nTotalControlWidth > GetOutputSizePixel().Width()) | |||
480 | { | |||
481 | mxScroll->hadjustment_set_upper(nTotalControlWidth); | |||
482 | mxScroll->hadjustment_set_page_size(nControlWidth); | |||
483 | mxScroll->hadjustment_set_page_increment(nControlWidth); | |||
484 | mxScroll->set_hpolicy(VclPolicyType::ALWAYS); | |||
485 | } | |||
486 | else | |||
487 | { | |||
488 | mxScroll->hadjustment_set_value(0); | |||
489 | mxScroll->set_hpolicy(VclPolicyType::NEVER); | |||
490 | } | |||
491 | } | |||
492 | else | |||
493 | { | |||
494 | sal_Int32 nTotalControlHeight = y + boxY + mxScroll->vadjustment_get_value(); | |||
495 | if (nTotalControlHeight > GetOutputSizePixel().Height()) | |||
496 | { | |||
497 | mxScroll->vadjustment_set_upper(nTotalControlHeight); | |||
498 | mxScroll->vadjustment_set_page_size(nControlHeight); | |||
499 | mxScroll->vadjustment_set_page_increment(nControlHeight); | |||
500 | mxScroll->set_vpolicy(VclPolicyType::ALWAYS); | |||
501 | } | |||
502 | else | |||
503 | { | |||
504 | mxScroll->vadjustment_set_value(0); | |||
505 | mxScroll->set_vpolicy(VclPolicyType::NEVER); | |||
506 | } | |||
507 | } | |||
508 | rContext.Pop(); | |||
509 | } | |||
510 | ||||
511 | void SmElementsControl::Resize() | |||
512 | { | |||
513 | CustomWidgetController::Resize(); | |||
514 | LayoutOrPaintContents(GetDrawingArea()->get_ref_device(), false); | |||
515 | } | |||
516 | ||||
517 | void SmElementsControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) | |||
518 | { | |||
519 | LayoutOrPaintContents(rRenderContext, true); | |||
520 | } | |||
521 | ||||
522 | OUString SmElementsControl::RequestHelp(tools::Rectangle& rRect) | |||
523 | { | |||
524 | if (!hasRollover()) | |||
525 | return OUString(); | |||
526 | ||||
527 | const SmElement* pHelpElement = current(); | |||
528 | if (!pHelpElement) | |||
529 | return OUString(); | |||
530 | ||||
531 | rRect = tools::Rectangle(pHelpElement->mBoxLocation, pHelpElement->mBoxSize); | |||
532 | ||||
533 | // get text and display it | |||
534 | return pHelpElement->getHelpText(); | |||
535 | } | |||
536 | ||||
537 | bool SmElementsControl::MouseMove( const MouseEvent& rMouseEvent ) | |||
538 | { | |||
539 | if (rMouseEvent.IsLeaveWindow()) | |||
540 | { | |||
541 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
542 | Invalidate(); | |||
543 | return false; | |||
544 | } | |||
545 | ||||
546 | if (tools::Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel())) | |||
547 | { | |||
548 | const SmElement* pPrevElement = current(); | |||
549 | if (pPrevElement) | |||
550 | { | |||
551 | const tools::Rectangle rect(pPrevElement->mBoxLocation, pPrevElement->mBoxSize); | |||
552 | if (rect.IsInside(rMouseEvent.GetPosPixel())) | |||
553 | return true; | |||
554 | } | |||
555 | ||||
556 | const sal_uInt16 nElementCount = maElementList.size(); | |||
557 | for (sal_uInt16 n = 0; n < nElementCount; n++) | |||
558 | { | |||
559 | const SmElement* element = maElementList[n].get(); | |||
560 | if (pPrevElement == element) | |||
561 | continue; | |||
562 | ||||
563 | const tools::Rectangle rect(element->mBoxLocation, element->mBoxSize); | |||
564 | if (rect.IsInside(rMouseEvent.GetPosPixel())) | |||
565 | { | |||
566 | m_nCurrentRolloverElement = n; | |||
567 | Invalidate(); | |||
568 | return true; | |||
569 | } | |||
570 | } | |||
571 | if (pPrevElement && hasRollover()) | |||
572 | Invalidate(); | |||
573 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
574 | return true; | |||
575 | } | |||
576 | ||||
577 | return false; | |||
578 | } | |||
579 | ||||
580 | namespace { | |||
581 | ||||
582 | void collectUIInformation(const OUString& aID) | |||
583 | { | |||
584 | EventDescription aDescription; | |||
585 | aDescription.aID = aID; | |||
586 | aDescription.aParent = "element_selector"; | |||
587 | aDescription.aAction = "SELECT"; | |||
588 | aDescription.aKeyWord = "ElementUIObject"; | |||
589 | UITestLogger::getInstance().logEvent(aDescription); | |||
590 | } | |||
591 | ||||
592 | } | |||
593 | ||||
594 | bool SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent) | |||
595 | { | |||
596 | GrabFocus(); | |||
597 | ||||
598 | if (rMouseEvent.IsLeft() && tools::Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()) && maSelectHdlLink.IsSet()) | |||
599 | { | |||
600 | const SmElement* pPrevElement = hasRollover() ? current() : nullptr; | |||
601 | if (pPrevElement) | |||
602 | { | |||
603 | tools::Rectangle rect(pPrevElement->mBoxLocation, pPrevElement->mBoxSize); | |||
604 | if (rect.IsInside(rMouseEvent.GetPosPixel())) | |||
605 | { | |||
606 | setCurrentElement(m_nCurrentRolloverElement); | |||
607 | maSelectHdlLink.Call(*const_cast<SmElement*>(pPrevElement)); | |||
608 | collectUIInformation(OUString::number(m_nCurrentRolloverElement)); | |||
609 | return true; | |||
610 | } | |||
611 | } | |||
612 | ||||
613 | const sal_uInt16 nElementCount = maElementList.size(); | |||
614 | for (sal_uInt16 n = 0; n < nElementCount; n++) | |||
615 | { | |||
616 | SmElement* element = maElementList[n].get(); | |||
617 | tools::Rectangle rect(element->mBoxLocation, element->mBoxSize); | |||
618 | if (rect.IsInside(rMouseEvent.GetPosPixel())) | |||
619 | { | |||
620 | setCurrentElement(n); | |||
621 | maSelectHdlLink.Call(*element); | |||
622 | collectUIInformation(OUString::number(n)); | |||
623 | return true; | |||
624 | } | |||
625 | } | |||
626 | ||||
627 | return true; | |||
628 | } | |||
629 | return false; | |||
630 | } | |||
631 | ||||
632 | void SmElementsControl::GetFocus() | |||
633 | { | |||
634 | CustomWidgetController::GetFocus(); | |||
635 | Invalidate(); | |||
636 | } | |||
637 | ||||
638 | void SmElementsControl::LoseFocus() | |||
639 | { | |||
640 | CustomWidgetController::LoseFocus(); | |||
641 | Invalidate(); | |||
642 | } | |||
643 | ||||
644 | sal_uInt16 SmElementsControl::nextElement(const bool bBackward, const sal_uInt16 nStartPos, const sal_uInt16 nLastElement) | |||
645 | { | |||
646 | sal_uInt16 nPos = nStartPos; | |||
647 | ||||
648 | while (true) | |||
649 | { | |||
650 | if (bBackward) | |||
651 | { | |||
652 | if (nPos == 0) | |||
653 | break; | |||
654 | nPos--; | |||
655 | } | |||
656 | else | |||
657 | { | |||
658 | if (nPos == nLastElement) | |||
659 | break; | |||
660 | nPos++; | |||
661 | } | |||
662 | ||||
663 | if (nStartPos == nPos) | |||
664 | break; | |||
665 | if (!maElementList[nPos]->isSeparator()) | |||
666 | break; | |||
667 | } | |||
668 | ||||
669 | return nPos; | |||
670 | } | |||
671 | ||||
672 | void SmElementsControl::scrollToElement(const bool bBackward, const SmElement *pCur) | |||
673 | { | |||
674 | if (mbVerticalMode) | |||
675 | { | |||
676 | auto nScrollPos = mxScroll->hadjustment_get_value(); | |||
677 | nScrollPos += pCur->mBoxLocation.X(); | |||
678 | if (!bBackward) | |||
679 | nScrollPos += pCur->mBoxSize.Width() - GetOutputSizePixel().Width(); | |||
680 | mxScroll->hadjustment_set_value(nScrollPos); | |||
681 | } | |||
682 | else | |||
683 | { | |||
684 | auto nScrollPos = mxScroll->vadjustment_get_value(); | |||
685 | nScrollPos += pCur->mBoxLocation.Y(); | |||
686 | if (!bBackward) | |||
687 | nScrollPos += pCur->mBoxSize.Height() - GetOutputSizePixel().Height(); | |||
688 | mxScroll->vadjustment_set_value(nScrollPos); | |||
689 | } | |||
690 | } | |||
691 | ||||
692 | void SmElementsControl::stepFocus(const bool bBackward) | |||
693 | { | |||
694 | const sal_uInt16 nStartPos = m_nCurrentElement; | |||
695 | const sal_uInt16 nLastElement = (maElementList.size() ? maElementList.size() - 1 : 0); | |||
696 | assert(nStartPos <= nLastElement)(static_cast <bool> (nStartPos <= nLastElement) ? void (0) : __assert_fail ("nStartPos <= nLastElement", "/home/maarten/src/libreoffice/core/starmath/source/ElementsDockingWindow.cxx" , 696, __extension__ __PRETTY_FUNCTION__)); | |||
697 | ||||
698 | sal_uInt16 nPos = nextElement(bBackward, nStartPos, nLastElement); | |||
699 | if (nStartPos != nPos) | |||
700 | { | |||
701 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
702 | setCurrentElement(nPos); | |||
703 | ||||
704 | const tools::Rectangle outputRect(Point(0,0), GetOutputSizePixel()); | |||
705 | const SmElement *pCur = maElementList[nPos].get(); | |||
706 | tools::Rectangle elementRect(pCur->mBoxLocation, pCur->mBoxSize); | |||
707 | if (!outputRect.IsInside(elementRect)) | |||
708 | scrollToElement(bBackward, pCur); | |||
709 | Invalidate(); | |||
710 | } | |||
711 | } | |||
712 | ||||
713 | void SmElementsControl::pageFocus(const bool bBackward) | |||
714 | { | |||
715 | const sal_uInt16 nStartPos = m_nCurrentElement; | |||
716 | const sal_uInt16 nLastElement = (maElementList.size() ? maElementList.size() - 1 : 0); | |||
717 | assert(nStartPos <= nLastElement)(static_cast <bool> (nStartPos <= nLastElement) ? void (0) : __assert_fail ("nStartPos <= nLastElement", "/home/maarten/src/libreoffice/core/starmath/source/ElementsDockingWindow.cxx" , 717, __extension__ __PRETTY_FUNCTION__)); | |||
718 | tools::Rectangle outputRect(Point(0,0), GetOutputSizePixel()); | |||
719 | sal_uInt16 nPrevPos = nStartPos; | |||
720 | sal_uInt16 nPos = nPrevPos; | |||
721 | ||||
722 | bool bMoved = false; | |||
723 | while (true) | |||
724 | { | |||
725 | nPrevPos = nPos; | |||
726 | nPos = nextElement(bBackward, nPrevPos, nLastElement); | |||
727 | if (nPrevPos == nPos) | |||
728 | break; | |||
729 | ||||
730 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
731 | ||||
732 | SmElement *pCur = maElementList[nPos].get(); | |||
733 | tools::Rectangle elementRect(pCur->mBoxLocation, pCur->mBoxSize); | |||
734 | if (!outputRect.IsInside(elementRect)) | |||
735 | { | |||
736 | if (nPrevPos != nStartPos) | |||
737 | { | |||
738 | nPos = nPrevPos; | |||
739 | break; | |||
740 | } | |||
741 | if (bMoved) | |||
742 | break; | |||
743 | pCur = maElementList[nPrevPos].get(); | |||
744 | ||||
745 | elementRect = tools::Rectangle(pCur->mBoxLocation, pCur->mBoxSize); | |||
746 | if (mbVerticalMode) | |||
747 | outputRect.Move(bBackward ? -outputRect.GetWidth() + elementRect.Right() : elementRect.Left(), 0); | |||
748 | else | |||
749 | outputRect.Move(0, bBackward ? -outputRect.GetHeight() + elementRect.Bottom() : elementRect.Top()); | |||
750 | bMoved = true; | |||
751 | } | |||
752 | } | |||
753 | ||||
754 | if (nStartPos != nPos) | |||
755 | { | |||
756 | setCurrentElement(nPos); | |||
757 | if (bMoved) | |||
758 | scrollToElement(bBackward, maElementList[nPos].get()); | |||
759 | Invalidate(); | |||
760 | } | |||
761 | } | |||
762 | ||||
763 | bool SmElementsControl::KeyInput(const KeyEvent& rKEvt) | |||
764 | { | |||
765 | vcl::KeyCode aKeyCode = rKEvt.GetKeyCode(); | |||
766 | ||||
767 | if (aKeyCode.GetModifier()) | |||
768 | { | |||
769 | return false; | |||
770 | } | |||
771 | ||||
772 | switch(aKeyCode.GetCode()) | |||
773 | { | |||
774 | case KEY_RETURN: | |||
775 | [[fallthrough]]; | |||
776 | case KEY_SPACE: | |||
777 | assert(m_nCurrentElement < maElementList.size())(static_cast <bool> (m_nCurrentElement < maElementList .size()) ? void (0) : __assert_fail ("m_nCurrentElement < maElementList.size()" , "/home/maarten/src/libreoffice/core/starmath/source/ElementsDockingWindow.cxx" , 777, __extension__ __PRETTY_FUNCTION__)); | |||
778 | assert(maSelectHdlLink.IsSet())(static_cast <bool> (maSelectHdlLink.IsSet()) ? void (0 ) : __assert_fail ("maSelectHdlLink.IsSet()", "/home/maarten/src/libreoffice/core/starmath/source/ElementsDockingWindow.cxx" , 778, __extension__ __PRETTY_FUNCTION__)); | |||
779 | maSelectHdlLink.Call(*maElementList[m_nCurrentElement]); | |||
780 | collectUIInformation(OUString::number(m_nCurrentElement)); | |||
781 | break; | |||
782 | ||||
783 | case KEY_DOWN: | |||
784 | [[fallthrough]]; | |||
785 | case KEY_RIGHT: | |||
786 | stepFocus(false); | |||
787 | break; | |||
788 | ||||
789 | case KEY_LEFT: | |||
790 | [[fallthrough]]; | |||
791 | case KEY_UP: | |||
792 | stepFocus(true); | |||
793 | break; | |||
794 | ||||
795 | case KEY_HOME: | |||
796 | if (!maElementList.empty()) | |||
797 | { | |||
798 | setCurrentElement(0); | |||
799 | mxScroll->vadjustment_set_value(0); | |||
800 | } | |||
801 | break; | |||
802 | case KEY_END: | |||
803 | if (!maElementList.empty()) | |||
804 | { | |||
805 | setCurrentElement(maElementList.size() - 1); | |||
806 | mxScroll->vadjustment_set_value(mxScroll->vadjustment_get_upper()); | |||
807 | } | |||
808 | break; | |||
809 | ||||
810 | case KEY_PAGEUP: | |||
811 | pageFocus(true); | |||
812 | break; | |||
813 | case KEY_PAGEDOWN: | |||
814 | pageFocus(false); | |||
815 | break; | |||
816 | ||||
817 | default: | |||
818 | return false; | |||
819 | break; | |||
820 | } | |||
821 | return true; | |||
822 | } | |||
823 | ||||
824 | IMPL_LINK_NOARG( SmElementsControl, ScrollHdl, weld::ScrolledWindow&, void )void SmElementsControl::LinkStubScrollHdl(void * instance, weld ::ScrolledWindow& data) { return static_cast<SmElementsControl *>(instance)->ScrollHdl(data); } void SmElementsControl ::ScrollHdl(__attribute__ ((unused)) weld::ScrolledWindow& ) | |||
825 | { | |||
826 | Invalidate(); | |||
827 | } | |||
828 | ||||
829 | void SmElementsControl::addElement(SmParser &rParser, const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText) | |||
830 | { | |||
831 | // SAL_MAX_UINT16 is invalid, zero is the scrollbar | |||
832 | assert(maElementList.size() < SAL_MAX_UINT16 - 2)(static_cast <bool> (maElementList.size() < ((sal_uInt16 ) 0xFFFF) - 2) ? void (0) : __assert_fail ("maElementList.size() < SAL_MAX_UINT16 - 2" , "/home/maarten/src/libreoffice/core/starmath/source/ElementsDockingWindow.cxx" , 832, __extension__ __PRETTY_FUNCTION__)); | |||
833 | auto pNode = rParser.ParseExpression(aElementVisual); | |||
834 | ||||
835 | OutputDevice& rDevice = GetDrawingArea()->get_ref_device(); | |||
836 | rDevice.Push(PushFlags::MAPMODE); | |||
837 | rDevice.SetMapMode( MapMode(MapUnit::Map100thMM) ); | |||
838 | ||||
839 | pNode->Prepare(maFormat, *mpDocShell, 0); | |||
840 | pNode->SetSize(Fraction(10,8)); | |||
841 | pNode->Arrange(rDevice, maFormat); | |||
842 | ||||
843 | Size aSizePixel = rDevice.LogicToPixel(Size(pNode->GetWidth(), pNode->GetHeight()), MapMode(MapUnit::Map100thMM)); | |||
844 | if (aSizePixel.Width() > maMaxElementDimensions.Width()) { | |||
845 | maMaxElementDimensions.setWidth( aSizePixel.Width() ); | |||
846 | } | |||
847 | ||||
848 | if (aSizePixel.Height() > maMaxElementDimensions.Height()) { | |||
849 | maMaxElementDimensions.setHeight( aSizePixel.Height() ); | |||
850 | } | |||
851 | ||||
852 | maElementList.push_back(std::make_unique<SmElement>(std::move(pNode), aElementSource, aHelpText)); | |||
853 | ||||
854 | rDevice.Pop(); | |||
855 | } | |||
856 | ||||
857 | void SmElementsControl::setElementSetId(const char* pSetId) | |||
858 | { | |||
859 | if (msCurrentSetId == pSetId) | |||
860 | return; | |||
861 | msCurrentSetId = pSetId; | |||
862 | maMaxElementDimensions = Size(); | |||
863 | build(); | |||
864 | } | |||
865 | ||||
866 | void SmElementsControl::addElements(const SmElementDescr aElementsArray[], sal_uInt16 aElementsArraySize) | |||
867 | { | |||
868 | SmParser aParser; | |||
869 | aParser.SetImportSymbolNames(true); | |||
870 | ||||
871 | for (sal_uInt16 i = 0; i < aElementsArraySize ; i++) | |||
872 | { | |||
873 | const char* pElement = aElementsArray[i].first; | |||
874 | const char* pElementHelp = aElementsArray[i].second; | |||
875 | if (!pElement) { | |||
876 | maElementList.push_back(std::make_unique<SmElementSeparator>()); | |||
877 | } else { | |||
878 | OUString aElement(OUString::createFromAscii(pElement)); | |||
879 | if (aElement == RID_NEWLINE"newline ") | |||
880 | addElement(aParser, OUString(u"\u21B5"), aElement, SmResId(pElementHelp)); | |||
881 | else if (aElement == RID_SBLANK"`") | |||
882 | addElement(aParser, "\"`\"", aElement, SmResId(pElementHelp)); | |||
883 | else if (aElement == RID_BLANK"~") | |||
884 | addElement(aParser, "\"~\"", aElement, SmResId(pElementHelp)); | |||
885 | else if (aElement == RID_PHANTOMX"phantom {<?>} ") | |||
886 | addElement(aParser, "\"" + SmResId(STR_HIDEreinterpret_cast<char const *>("STR_HIDE" "\004" u8"hide" )) +"\"", aElement, SmResId(pElementHelp)); | |||
887 | else if (aElement == RID_BOLDX"bold <?> ") | |||
888 | addElement(aParser, "bold B", aElement, SmResId(pElementHelp)); | |||
889 | else if (aElement == RID_ITALX"ital <?> ") | |||
890 | addElement(aParser, "ital I", aElement, SmResId(pElementHelp)); | |||
891 | else if (aElement == RID_SIZEXY"size <?> {<?>} ") | |||
892 | addElement(aParser, "\"" + SmResId(STR_SIZEreinterpret_cast<char const *>("STR_SIZE" "\004" u8"size" )) + "\"", aElement, SmResId(pElementHelp)); | |||
893 | else if (aElement == RID_FONTXY"font <?> {<?>} ") | |||
894 | addElement(aParser, "\"" + SmResId(STR_FONTreinterpret_cast<char const *>("STR_FONT" "\004" u8"font" )) + "\"", aElement, SmResId(pElementHelp)); | |||
895 | else if (aElement == RID_COLORX_BLACK"color black {<?>} ") | |||
896 | addElement(aParser, "color black { \"" + SmResId(STR_BLACKreinterpret_cast<char const *>("STR_BLACK" "\004" u8"black" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
897 | else if (aElement == RID_COLORX_BLUE"color blue {<?>} ") | |||
898 | addElement(aParser, "color blue { \"" + SmResId(STR_BLUEreinterpret_cast<char const *>("STR_BLUE" "\004" u8"blue" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
899 | else if (aElement == RID_COLORX_GREEN"color green {<?>} ") | |||
900 | addElement(aParser, "color green { \"" + SmResId(STR_GREENreinterpret_cast<char const *>("STR_GREEN" "\004" u8"green" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
901 | else if (aElement == RID_COLORX_RED"color red {<?>} ") | |||
902 | addElement(aParser, "color red { \"" + SmResId(STR_REDreinterpret_cast<char const *>("STR_RED" "\004" u8"red" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
903 | else if (aElement == RID_COLORX_CYAN"color cyan {<?>} ") | |||
904 | addElement(aParser, "color cyan { \"" + SmResId(STR_CYANreinterpret_cast<char const *>("STR_CYAN" "\004" u8"cyan" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
905 | else if (aElement == RID_COLORX_MAGENTA"color magenta {<?>} ") | |||
906 | addElement(aParser, "color magenta { \"" + SmResId(STR_MAGENTAreinterpret_cast<char const *>("STR_MAGENTA" "\004" u8"magenta" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
907 | else if (aElement == RID_COLORX_YELLOW"color yellow {<?>} ") | |||
908 | addElement(aParser, "color yellow { \"" + SmResId(STR_YELLOWreinterpret_cast<char const *>("STR_YELLOW" "\004" u8"yellow" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
909 | else if (aElement == RID_COLORX_GRAY"color gray {<?>} ") | |||
910 | addElement(aParser, "color gray { \"" + SmResId(STR_GRAYreinterpret_cast<char const *>("STR_GRAY" "\004" u8"gray" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
911 | else if (aElement == RID_COLORX_LIME"color lime {<?>} ") | |||
912 | addElement(aParser, "color lime { \"" + SmResId(STR_LIMEreinterpret_cast<char const *>("STR_LIME" "\004" u8"lime" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
913 | else if (aElement == RID_COLORX_MAROON"color maroon {<?>} ") | |||
914 | addElement(aParser, "color maroon { \"" + SmResId(STR_MAROONreinterpret_cast<char const *>("STR_MAROON" "\004" u8"maroon" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
915 | else if (aElement == RID_COLORX_NAVY"color navy {<?>} ") | |||
916 | addElement(aParser, "color navy { \"" + SmResId(STR_NAVYreinterpret_cast<char const *>("STR_NAVY" "\004" u8"navy" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
917 | else if (aElement == RID_COLORX_OLIVE"color olive {<?>} ") | |||
918 | addElement(aParser, "color olive { \"" + SmResId(STR_OLIVEreinterpret_cast<char const *>("STR_OLIVE" "\004" u8"olive" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
919 | else if (aElement == RID_COLORX_PURPLE"color purple {<?>} ") | |||
920 | addElement(aParser, "color purple { \"" + SmResId(STR_PURPLEreinterpret_cast<char const *>("STR_PURPLE" "\004" u8"purple" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
921 | else if (aElement == RID_COLORX_SILVER"color silver {<?>} ") | |||
922 | addElement(aParser, "color silver { \"" + SmResId(STR_SILVERreinterpret_cast<char const *>("STR_SILVER" "\004" u8"silver" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
923 | else if (aElement == RID_COLORX_TEAL"color teal {<?>} ") | |||
924 | addElement(aParser, "color teal { \"" + SmResId(STR_TEALreinterpret_cast<char const *>("STR_TEAL" "\004" u8"teal" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
925 | else if (aElement == RID_COLORX_RGB"color rgb 0 0 0 {<?>} ") | |||
926 | addElement(aParser, "color rgb 0 0 0 { \"" + SmResId(STR_RGBreinterpret_cast<char const *>("STR_RGB" "\004" u8"rgb" )) + "\" }", aElement, SmResId(pElementHelp)); | |||
927 | else if (aElement == RID_ALIGNLX"alignl <?> ") | |||
928 | addElement(aParser, "\"" + SmResId(STR_ALIGN_LEFTreinterpret_cast<char const *>("STR_ALIGN_LEFT" "\004" u8"left" )) + "\"", aElement, SmResId(pElementHelp)); | |||
929 | else if (aElement == RID_ALIGNCX"alignc <?> ") | |||
930 | addElement(aParser, "\"" + SmResId(STR_ALIGN_CENTERreinterpret_cast<char const *>("STR_ALIGN_CENTER" "\004" u8"center")) + "\"", aElement, SmResId(pElementHelp)); | |||
931 | else if (aElement == RID_ALIGNRX"alignr <?> ") | |||
932 | addElement(aParser, "\"" + SmResId(STR_ALIGN_RIGHTreinterpret_cast<char const *>("STR_ALIGN_RIGHT" "\004" u8"right")) + "\"", aElement, SmResId(pElementHelp)); | |||
933 | ||||
934 | else if (aElement == RID_SLRPARENTX"left ( <?> right ) ") | |||
935 | addElement(aParser, "left ( binom{<?>}{<?>} right ) ", aElement, SmResId(pElementHelp)); | |||
936 | else if (aElement == RID_SLRBRACKETX"left [ <?> right ] ") | |||
937 | addElement(aParser, "left [ binom{<?>}{<?>} right ] ", aElement, SmResId(pElementHelp)); | |||
938 | else if (aElement == RID_SLRDBRACKETX"left ldbracket <?> right rdbracket ") | |||
939 | addElement(aParser, "left ldbracket binom{<?>}{<?>} right rdbracket ", aElement, SmResId(pElementHelp)); | |||
940 | else if (aElement == RID_SLRBRACEX"left lbrace <?> right rbrace ") | |||
941 | addElement(aParser, "left lbrace binom{<?>}{<?>} right rbrace ", aElement, SmResId(pElementHelp)); | |||
942 | else if (aElement == RID_SLRANGLEX"left langle <?> right rangle ") | |||
943 | addElement(aParser, "left langle binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); | |||
944 | else if (aElement == RID_SLRCEILX"left lceil <?> right rceil ") | |||
945 | addElement(aParser, "left lceil binom{<?>}{<?>} right rceil ", aElement, SmResId(pElementHelp)); | |||
946 | else if (aElement == RID_SLRFLOORX"left lfloor <?> right rfloor ") | |||
947 | addElement(aParser, "left lfloor binom{<?>}{<?>} right rfloor ", aElement, SmResId(pElementHelp)); | |||
948 | else if (aElement == RID_SLRLINEX"left lline <?> right rline ") | |||
949 | addElement(aParser, "left lline binom{<?>}{<?>} right rline ", aElement, SmResId(pElementHelp)); | |||
950 | else if (aElement == RID_SLRDLINEX"left ldline <?> right rdline ") | |||
951 | addElement(aParser, "left ldline binom{<?>}{<?>} right rdline ", aElement, SmResId(pElementHelp)); | |||
952 | else if (aElement == RID_SLMRANGLEXY"left langle <?> mline <?> right rangle ") | |||
953 | addElement(aParser, "left langle binom{<?>}{<?>} mline binom{<?>}{<?>} right rangle ", aElement, SmResId(pElementHelp)); | |||
954 | ||||
955 | else if (aElement == RID_OPERX"oper oper <?> ") | |||
956 | addElement(aParser, u"oper \xE22B <?>", aElement, SmResId(pElementHelp)); | |||
957 | else if (aElement == RID_OPER_FROMX"oper oper from{<?>} <?> ") | |||
958 | addElement(aParser, u"oper \xE22B from <?> <?>", aElement, SmResId(pElementHelp)); | |||
959 | else if (aElement == RID_OPER_TOX"oper oper to{<?>} <?> ") | |||
960 | addElement(aParser, u"oper \xE22B to <?> <?>", aElement, SmResId(pElementHelp)); | |||
961 | else if (aElement == RID_OPER_FROMTOX"oper oper from{<?>} to{<?>} <?> ") | |||
962 | addElement(aParser, u"oper \xE22B from <?> to <?> <?>", aElement, SmResId(pElementHelp)); | |||
963 | ||||
964 | else if (aElement == RID_XOVERBRACEY"{<?>} overbrace {<?>} ") | |||
965 | addElement(aParser, "{<?><?><?>} overbrace {<?>} ", aElement, SmResId(pElementHelp)); | |||
966 | else if (aElement == RID_XUNDERBRACEY"{<?>} underbrace {<?>} ") | |||
967 | addElement(aParser, "{<?><?><?>} underbrace {<?>} ", aElement, SmResId(pElementHelp)); | |||
968 | else | |||
969 | addElement(aParser, aElement, aElement, pElementHelp ? SmResId(pElementHelp) : ""); | |||
970 | } | |||
971 | } | |||
972 | } | |||
973 | ||||
974 | void SmElementsControl::build() | |||
975 | { | |||
976 | // The order is important! | |||
977 | // 1. Ensure there are no items left, including the default scrollbar! | |||
978 | // 2. Release all the current accessible items. | |||
979 | // This will check for new items after releasing them! | |||
980 | // 3. Set the cursor element | |||
981 | maElementList.clear(); | |||
982 | mxScroll->hadjustment_set_value(0); | |||
983 | mxScroll->vadjustment_set_value(0); | |||
984 | mxScroll->set_hpolicy(VclPolicyType::NEVER); | |||
985 | mxScroll->set_vpolicy(VclPolicyType::NEVER); | |||
986 | ||||
987 | if (m_xAccessible.is()) | |||
988 | m_xAccessible->ReleaseAllItems(); | |||
989 | ||||
990 | setCurrentElement(SAL_MAX_UINT16((sal_uInt16) 0xFFFF)); | |||
991 | ||||
992 | // The first element is the scrollbar. We can't change its indexInParent | |||
993 | // value, as this is set by being a child of the SmElementsControl. | |||
994 | m_nCurrentOffset = 1; | |||
995 | for (sal_uInt16 n = 0; n < SAL_N_ELEMENTS(m_aCategories)(sizeof(sal_n_array_size(m_aCategories))); ++n) | |||
996 | { | |||
997 | if (msCurrentSetId == std::get<0>(m_aCategories[n])) | |||
998 | { | |||
999 | addElements(std::get<1>(m_aCategories[n]), std::get<2>(m_aCategories[n])); | |||
1000 | break; | |||
1001 | } | |||
1002 | else | |||
1003 | m_nCurrentOffset += std::get<2>(m_aCategories[n]); | |||
1004 | } | |||
1005 | ||||
1006 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
1007 | LayoutOrPaintContents(GetDrawingArea()->get_ref_device(), false); | |||
1008 | ||||
1009 | if (m_xAccessible.is()) | |||
1010 | m_xAccessible->AddAllItems(); | |||
1011 | ||||
1012 | setCurrentElement(0); | |||
1013 | Invalidate(); | |||
1014 | } | |||
1015 | ||||
1016 | void SmElementsControl::SetDrawingArea(weld::DrawingArea* pDrawingArea) | |||
1017 | { | |||
1018 | CustomWidgetController::SetDrawingArea(pDrawingArea); | |||
1019 | OutputDevice& rDevice = pDrawingArea->get_ref_device(); | |||
1020 | maFormat.SetBaseSize(rDevice.PixelToLogic(Size(0, SmPtsTo100th_mm(12)))); | |||
1021 | Size aSize(rDevice.LogicToPixel(Size(10, 100), MapMode(MapUnit::MapAppFont))); | |||
1022 | // give it an arbitrary small width request so it can shrink in the sidebar | |||
1023 | pDrawingArea->set_size_request(42, aSize.Height()); | |||
1024 | SetOutputSizePixel(aSize); | |||
1025 | } | |||
1026 | ||||
1027 | FactoryFunction SmElementsControl::GetUITestFactory() const | |||
1028 | { | |||
1029 | return ElementSelectorUIObject::create; | |||
1030 | } | |||
1031 | ||||
1032 | bool SmElementsControl::itemIsSeparator(sal_uInt16 nPos) const | |||
1033 | { | |||
1034 | if (nPos < m_nCurrentOffset) | |||
1035 | return true; | |||
1036 | nPos -= m_nCurrentOffset; | |||
1037 | if (nPos >= maElementList.size()) | |||
1038 | return true; | |||
1039 | return maElementList[nPos]->isSeparator(); | |||
1040 | } | |||
1041 | ||||
1042 | css::uno::Reference<css::accessibility::XAccessible> SmElementsControl::CreateAccessible() | |||
1043 | { | |||
1044 | if (!m_xAccessible.is()) | |||
1045 | { | |||
1046 | m_xAccessible = new AccessibleSmElementsControl(*this); | |||
1047 | m_xAccessible->AddAllItems(); | |||
1048 | } | |||
1049 | return m_xAccessible.get(); | |||
1050 | } | |||
1051 | ||||
1052 | bool SmElementsControl::itemTrigger(sal_uInt16 nPos) | |||
1053 | { | |||
1054 | if (nPos < m_nCurrentOffset) | |||
1055 | return false; | |||
1056 | nPos -= m_nCurrentOffset; | |||
1057 | if (nPos >= maElementList.size()) | |||
1058 | return false; | |||
1059 | ||||
1060 | maSelectHdlLink.Call(*maElementList[nPos]); | |||
1061 | collectUIInformation(OUString::number(nPos)); | |||
1062 | return true; | |||
1063 | } | |||
1064 | ||||
1065 | tools::Rectangle SmElementsControl::itemPosRect(sal_uInt16 nPos) const | |||
1066 | { | |||
1067 | if (nPos < m_nCurrentOffset) | |||
1068 | return tools::Rectangle(); | |||
1069 | nPos -= m_nCurrentOffset; | |||
1070 | if (nPos >= maElementList.size()) | |||
1071 | return tools::Rectangle(); | |||
1072 | ||||
1073 | SmElement* pItem = maElementList[nPos].get(); | |||
1074 | return tools::Rectangle(pItem->mBoxLocation, pItem->mBoxSize); | |||
1075 | } | |||
1076 | ||||
1077 | bool SmElementsControl::itemIsVisible(sal_uInt16 nPos) const | |||
1078 | { | |||
1079 | tools::Rectangle elementRect = itemPosRect(nPos); | |||
1080 | if (elementRect.IsEmpty()) | |||
1081 | return false; | |||
1082 | ||||
1083 | tools::Rectangle outputRect(Point(0, 0), GetOutputSizePixel()); | |||
1084 | return outputRect.IsInside(elementRect); | |||
1085 | } | |||
1086 | ||||
1087 | sal_uInt16 SmElementsControl::itemCount() const { return maElementList.size(); } | |||
1088 | ||||
1089 | sal_uInt16 SmElementsControl::itemHighlighted() const { return m_nCurrentElement; } | |||
1090 | ||||
1091 | void SmElementsControl::setItemHighlighted(sal_uInt16 nPos) | |||
1092 | { | |||
1093 | if (m_nCurrentRolloverElement == nPos) | |||
1094 | return; | |||
1095 | if (nPos != SAL_MAX_UINT16((sal_uInt16) 0xFFFF) && nPos >= maElementList.size()) | |||
1096 | return; | |||
1097 | ||||
1098 | if (maElementList[nPos]->isSeparator()) | |||
1099 | m_nCurrentRolloverElement = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
1100 | else | |||
1101 | m_nCurrentRolloverElement = nPos; | |||
1102 | Invalidate(); | |||
1103 | } | |||
1104 | ||||
1105 | OUString SmElementsControl::itemName(sal_uInt16 nPos) const | |||
1106 | { | |||
1107 | if (nPos < m_nCurrentOffset) | |||
1108 | return OUString(); | |||
1109 | nPos -= m_nCurrentOffset; | |||
1110 | if (nPos >= maElementList.size()) | |||
1111 | return OUString(); | |||
1112 | ||||
1113 | return maElementList[nPos]->getHelpText(); | |||
1114 | } | |||
1115 | ||||
1116 | sal_uInt16 SmElementsControl::itemAtPos(const Point& rPoint) const | |||
1117 | { | |||
1118 | sal_uInt16 nElementCount = maElementList.size(); | |||
1119 | for (sal_uInt16 n = 0; n < nElementCount; n++) | |||
1120 | { | |||
1121 | const SmElement* pItem = maElementList[n].get(); | |||
1122 | tools::Rectangle elementRect(pItem->mBoxLocation, pItem->mBoxSize); | |||
1123 | if (elementRect.IsInside(rPoint)) | |||
1124 | return n; | |||
1125 | } | |||
1126 | return SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
1127 | } | |||
1128 | ||||
1129 | SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent) | |||
1130 | : SfxDockingWindow(pInputBindings, pChildWindow, pParent, "DockingElements", | |||
1131 | "modules/smath/ui/dockingelements.ui") | |||
1132 | , mxElementsControl(new SmElementsControl(m_xBuilder->weld_scrolled_window("scrolledwindow", true))) | |||
1133 | , mxElementsControlWin(new weld::CustomWeld(*m_xBuilder, "element_selector", *mxElementsControl)) | |||
1134 | , mxElementListBox(m_xBuilder->weld_combo_box("listbox")) | |||
1135 | { | |||
1136 | // give it an arbitrary small width request so it can shrink in the sidebar | |||
1137 | mxElementListBox->set_size_request(42, -1); | |||
1138 | ||||
1139 | for (size_t i = 0; i < SmElementsControl::categoriesSize(); ++i) | |||
1140 | mxElementListBox->append_text(SmResId(std::get<0>(SmElementsControl::categories()[i]))); | |||
1141 | ||||
1142 | mxElementListBox->connect_changed(LINK(this, SmElementsDockingWindow, ElementSelectedHandle)::tools::detail::makeLink( ::tools::detail::castTo<SmElementsDockingWindow *>(this), &SmElementsDockingWindow::LinkStubElementSelectedHandle )); | |||
1143 | mxElementListBox->set_active_text(SmResId(RID_CATEGORY_UNARY_BINARY_OPERATORSreinterpret_cast<char const *>("RID_CATEGORY_UNARY_BINARY_OPERATORS" "\004" u8"Unary/Binary Operators"))); | |||
1144 | ||||
1145 | mxElementsControl->setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORSreinterpret_cast<char const *>("RID_CATEGORY_UNARY_BINARY_OPERATORS" "\004" u8"Unary/Binary Operators")); | |||
1146 | mxElementsControl->SetSelectHdl(LINK(this, SmElementsDockingWindow, SelectClickHandler)::tools::detail::makeLink( ::tools::detail::castTo<SmElementsDockingWindow *>(this), &SmElementsDockingWindow::LinkStubSelectClickHandler )); | |||
1147 | } | |||
1148 | ||||
1149 | SmElementsDockingWindow::~SmElementsDockingWindow () | |||
1150 | { | |||
1151 | disposeOnce(); | |||
1152 | } | |||
1153 | ||||
1154 | void SmElementsDockingWindow::dispose() | |||
1155 | { | |||
1156 | mxElementsControlWin.reset(); | |||
1157 | mxElementsControl.reset(); | |||
1158 | mxElementListBox.reset(); | |||
1159 | SfxDockingWindow::dispose(); | |||
1160 | } | |||
1161 | ||||
1162 | void SmElementsDockingWindow::ToggleFloatingMode() | |||
1163 | { | |||
1164 | SfxDockingWindow::ToggleFloatingMode(); | |||
1165 | ||||
1166 | if (GetFloatingWindow()) | |||
1167 | GetFloatingWindow()->SetMinOutputSizePixel( Size(100, 100) ); | |||
1168 | ||||
1169 | Invalidate(); | |||
1170 | } | |||
1171 | ||||
1172 | void SmElementsDockingWindow::EndDocking( const tools::Rectangle& rReactangle, bool bFloatMode) | |||
1173 | { | |||
1174 | SfxDockingWindow::EndDocking(rReactangle, bFloatMode); | |||
1175 | bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM ); | |||
1176 | mxElementsControl->setVerticalMode(bVertical); | |||
1177 | } | |||
1178 | ||||
1179 | IMPL_LINK(SmElementsDockingWindow, SelectClickHandler, SmElement&, rElement, void)void SmElementsDockingWindow::LinkStubSelectClickHandler(void * instance, SmElement& data) { return static_cast<SmElementsDockingWindow *>(instance)->SelectClickHandler(data); } void SmElementsDockingWindow ::SelectClickHandler(SmElement& rElement) | |||
1180 | { | |||
1181 | SmViewShell* pViewSh = GetView(); | |||
1182 | ||||
1183 | if (pViewSh) | |||
1184 | { | |||
1185 | std::unique_ptr<SfxStringItem> pInsertCommand = std::make_unique<SfxStringItem>(SID_INSERTCOMMANDTEXT((30000 + 256) + 106), rElement.getText()); | |||
1186 | pViewSh->GetViewFrame()->GetDispatcher()->ExecuteList( | |||
1187 | SID_INSERTCOMMANDTEXT((30000 + 256) + 106), SfxCallMode::RECORD, | |||
1188 | { pInsertCommand.get() }); | |||
1189 | } | |||
1190 | } | |||
1191 | ||||
1192 | IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, weld::ComboBox&, rList, void)void SmElementsDockingWindow::LinkStubElementSelectedHandle(void * instance, weld::ComboBox& data) { return static_cast< SmElementsDockingWindow *>(instance)->ElementSelectedHandle (data); } void SmElementsDockingWindow::ElementSelectedHandle (weld::ComboBox& rList) | |||
1193 | { | |||
1194 | for (size_t i = 0; i < SmElementsControl::categoriesSize(); ++i) | |||
1195 | { | |||
1196 | const char *pCurrentCategory = std::get<0>(SmElementsControl::categories()[i]); | |||
1197 | OUString aCurrentCategoryString = SmResId(pCurrentCategory); | |||
1198 | if (aCurrentCategoryString == rList.get_active_text()) | |||
1199 | { | |||
1200 | mxElementsControl->setElementSetId(pCurrentCategory); | |||
1201 | return; | |||
1202 | } | |||
1203 | } | |||
1204 | } | |||
1205 | ||||
1206 | SmViewShell* SmElementsDockingWindow::GetView() | |||
1207 | { | |||
1208 | SfxViewShell* pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell(); | |||
1209 | return dynamic_cast<SmViewShell*>( pView); | |||
1210 | } | |||
1211 | ||||
1212 | void SmElementsDockingWindow::Resize() | |||
1213 | { | |||
1214 | bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM ); | |||
1215 | mxElementsControl->setVerticalMode(bVertical); | |||
1216 | ||||
1217 | SfxDockingWindow::Resize(); | |||
1218 | Invalidate(); | |||
1219 | } | |||
1220 | ||||
1221 | SFX_IMPL_DOCKINGWINDOW_WITHID(SmElementsDockingWindowWrapper, SID_ELEMENTSDOCKINGWINDOW)std::unique_ptr<SfxChildWindow> SmElementsDockingWindowWrapper ::CreateImpl( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) { return std::make_unique <SmElementsDockingWindowWrapper>(pParent, nId, pBindings , pInfo); } void SmElementsDockingWindowWrapper::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) { auto pFact = std::make_unique<SfxChildWinFactory>( SmElementsDockingWindowWrapper ::CreateImpl, ((30000 + 256) + 126), (32767 *2 +1) ); pFact-> aInfo.nFlags |= nFlags; pFact->aInfo.bVisible = bVis; SfxChildWindow ::RegisterChildWindow(pMod, std::move(pFact)); } sal_uInt16 SmElementsDockingWindowWrapper ::GetChildWindowId () { return ((30000 + 256) + 126); } SfxChildWinInfo SmElementsDockingWindowWrapper::GetInfo() const { SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); static_cast<SfxDockingWindow *>(GetWindow())->FillInfo( aInfo ); return aInfo; }; | |||
| ||||
1222 | ||||
1223 | SmElementsDockingWindowWrapper::SmElementsDockingWindowWrapper( | |||
1224 | vcl::Window *pParentWindow, sal_uInt16 nId, | |||
1225 | SfxBindings *pBindings, SfxChildWinInfo *pInfo) : | |||
1226 | SfxChildWindow(pParentWindow, nId) | |||
1227 | { | |||
1228 | VclPtrInstance<SmElementsDockingWindow> pDialog(pBindings, this, pParentWindow); | |||
1229 | SetWindow(pDialog); | |||
1230 | pDialog->setDeferredProperties(); | |||
1231 | pDialog->SetPosSizePixel(Point(0, 0), Size(300, 0)); | |||
1232 | pDialog->Show(); | |||
1233 | ||||
1234 | SetAlignment(SfxChildAlignment::LEFT); | |||
1235 | ||||
1236 | pDialog->Initialize( pInfo ); | |||
1237 | } | |||
1238 | ||||
1239 | SmElementsDockingWindowWrapper::~SmElementsDockingWindowWrapper() | |||
1240 | { | |||
1241 | } | |||
1242 | ||||
1243 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | // unique_ptr implementation -*- C++ -*- |
2 | |
3 | // Copyright (C) 2008-2020 Free Software Foundation, Inc. |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free |
6 | // software; you can redistribute it and/or modify it under the |
7 | // terms of the GNU General Public License as published by the |
8 | // Free Software Foundation; either version 3, or (at your option) |
9 | // any later version. |
10 | |
11 | // This library is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU General Public License for more details. |
15 | |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version |
18 | // 3.1, as published by the Free Software Foundation. |
19 | |
20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
23 | // <http://www.gnu.org/licenses/>. |
24 | |
25 | /** @file bits/unique_ptr.h |
26 | * This is an internal header file, included by other library headers. |
27 | * Do not attempt to use it directly. @headername{memory} |
28 | */ |
29 | |
30 | #ifndef _UNIQUE_PTR_H1 |
31 | #define _UNIQUE_PTR_H1 1 |
32 | |
33 | #include <bits/c++config.h> |
34 | #include <debug/assertions.h> |
35 | #include <type_traits> |
36 | #include <utility> |
37 | #include <tuple> |
38 | #include <bits/stl_function.h> |
39 | #include <bits/functional_hash.h> |
40 | #if __cplusplus201703L > 201703L |
41 | # include <compare> |
42 | # include <ostream> |
43 | #endif |
44 | |
45 | namespace std _GLIBCXX_VISIBILITY(default)__attribute__ ((__visibility__ ("default"))) |
46 | { |
47 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
48 | |
49 | /** |
50 | * @addtogroup pointer_abstractions |
51 | * @{ |
52 | */ |
53 | |
54 | #if _GLIBCXX_USE_DEPRECATED1 |
55 | #pragma GCC diagnostic push |
56 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
57 | template<typename> class auto_ptr; |
58 | #pragma GCC diagnostic pop |
59 | #endif |
60 | |
61 | /// Primary template of default_delete, used by unique_ptr for single objects |
62 | template<typename _Tp> |
63 | struct default_delete |
64 | { |
65 | /// Default constructor |
66 | constexpr default_delete() noexcept = default; |
67 | |
68 | /** @brief Converting constructor. |
69 | * |
70 | * Allows conversion from a deleter for objects of another type, `_Up`, |
71 | * only if `_Up*` is convertible to `_Tp*`. |
72 | */ |
73 | template<typename _Up, |
74 | typename = _Require<is_convertible<_Up*, _Tp*>>> |
75 | default_delete(const default_delete<_Up>&) noexcept { } |
76 | |
77 | /// Calls `delete __ptr` |
78 | void |
79 | operator()(_Tp* __ptr) const |
80 | { |
81 | static_assert(!is_void<_Tp>::value, |
82 | "can't delete pointer to incomplete type"); |
83 | static_assert(sizeof(_Tp)>0, |
84 | "can't delete pointer to incomplete type"); |
85 | delete __ptr; |
86 | } |
87 | }; |
88 | |
89 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
90 | // DR 740 - omit specialization for array objects with a compile time length |
91 | |
92 | /// Specialization of default_delete for arrays, used by `unique_ptr<T[]>` |
93 | template<typename _Tp> |
94 | struct default_delete<_Tp[]> |
95 | { |
96 | public: |
97 | /// Default constructor |
98 | constexpr default_delete() noexcept = default; |
99 | |
100 | /** @brief Converting constructor. |
101 | * |
102 | * Allows conversion from a deleter for arrays of another type, such as |
103 | * a const-qualified version of `_Tp`. |
104 | * |
105 | * Conversions from types derived from `_Tp` are not allowed because |
106 | * it is undefined to `delete[]` an array of derived types through a |
107 | * pointer to the base type. |
108 | */ |
109 | template<typename _Up, |
110 | typename = _Require<is_convertible<_Up(*)[], _Tp(*)[]>>> |
111 | default_delete(const default_delete<_Up[]>&) noexcept { } |
112 | |
113 | /// Calls `delete[] __ptr` |
114 | template<typename _Up> |
115 | typename enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type |
116 | operator()(_Up* __ptr) const |
117 | { |
118 | static_assert(sizeof(_Tp)>0, |
119 | "can't delete pointer to incomplete type"); |
120 | delete [] __ptr; |
121 | } |
122 | }; |
123 | |
124 | /// @cond undocumented |
125 | |
126 | // Manages the pointer and deleter of a unique_ptr |
127 | template <typename _Tp, typename _Dp> |
128 | class __uniq_ptr_impl |
129 | { |
130 | template <typename _Up, typename _Ep, typename = void> |
131 | struct _Ptr |
132 | { |
133 | using type = _Up*; |
134 | }; |
135 | |
136 | template <typename _Up, typename _Ep> |
137 | struct |
138 | _Ptr<_Up, _Ep, __void_t<typename remove_reference<_Ep>::type::pointer>> |
139 | { |
140 | using type = typename remove_reference<_Ep>::type::pointer; |
141 | }; |
142 | |
143 | public: |
144 | using _DeleterConstraint = enable_if< |
145 | __and_<__not_<is_pointer<_Dp>>, |
146 | is_default_constructible<_Dp>>::value>; |
147 | |
148 | using pointer = typename _Ptr<_Tp, _Dp>::type; |
149 | |
150 | static_assert( !is_rvalue_reference<_Dp>::value, |
151 | "unique_ptr's deleter type must be a function object type" |
152 | " or an lvalue reference type" ); |
153 | |
154 | __uniq_ptr_impl() = default; |
155 | __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } |
156 | |
157 | template<typename _Del> |
158 | __uniq_ptr_impl(pointer __p, _Del&& __d) |
159 | : _M_t(__p, std::forward<_Del>(__d)) { } |
160 | |
161 | __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept |
162 | : _M_t(std::move(__u._M_t)) |
163 | { __u._M_ptr() = nullptr; } |
164 | |
165 | __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept |
166 | { |
167 | reset(__u.release()); |
168 | _M_deleter() = std::forward<_Dp>(__u._M_deleter()); |
169 | return *this; |
170 | } |
171 | |
172 | pointer& _M_ptr() { return std::get<0>(_M_t); } |
173 | pointer _M_ptr() const { return std::get<0>(_M_t); } |
174 | _Dp& _M_deleter() { return std::get<1>(_M_t); } |
175 | const _Dp& _M_deleter() const { return std::get<1>(_M_t); } |
176 | |
177 | void reset(pointer __p) noexcept |
178 | { |
179 | const pointer __old_p = _M_ptr(); |
180 | _M_ptr() = __p; |
181 | if (__old_p) |
182 | _M_deleter()(__old_p); |
183 | } |
184 | |
185 | pointer release() noexcept |
186 | { |
187 | pointer __p = _M_ptr(); |
188 | _M_ptr() = nullptr; |
189 | return __p; |
190 | } |
191 | |
192 | void |
193 | swap(__uniq_ptr_impl& __rhs) noexcept |
194 | { |
195 | using std::swap; |
196 | swap(this->_M_ptr(), __rhs._M_ptr()); |
197 | swap(this->_M_deleter(), __rhs._M_deleter()); |
198 | } |
199 | |
200 | private: |
201 | tuple<pointer, _Dp> _M_t; |
202 | }; |
203 | |
204 | // Defines move construction + assignment as either defaulted or deleted. |
205 | template <typename _Tp, typename _Dp, |
206 | bool = is_move_constructible<_Dp>::value, |
207 | bool = is_move_assignable<_Dp>::value> |
208 | struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp> |
209 | { |
210 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
211 | __uniq_ptr_data(__uniq_ptr_data&&) = default; |
212 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; |
213 | }; |
214 | |
215 | template <typename _Tp, typename _Dp> |
216 | struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp> |
217 | { |
218 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
219 | __uniq_ptr_data(__uniq_ptr_data&&) = default; |
220 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; |
221 | }; |
222 | |
223 | template <typename _Tp, typename _Dp> |
224 | struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp> |
225 | { |
226 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
227 | __uniq_ptr_data(__uniq_ptr_data&&) = delete; |
228 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; |
229 | }; |
230 | |
231 | template <typename _Tp, typename _Dp> |
232 | struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp> |
233 | { |
234 | using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; |
235 | __uniq_ptr_data(__uniq_ptr_data&&) = delete; |
236 | __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; |
237 | }; |
238 | /// @endcond |
239 | |
240 | /// 20.7.1.2 unique_ptr for single objects. |
241 | template <typename _Tp, typename _Dp = default_delete<_Tp>> |
242 | class unique_ptr |
243 | { |
244 | template <typename _Up> |
245 | using _DeleterConstraint = |
246 | typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; |
247 | |
248 | __uniq_ptr_data<_Tp, _Dp> _M_t; |
249 | |
250 | public: |
251 | using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; |
252 | using element_type = _Tp; |
253 | using deleter_type = _Dp; |
254 | |
255 | private: |
256 | // helper template for detecting a safe conversion from another |
257 | // unique_ptr |
258 | template<typename _Up, typename _Ep> |
259 | using __safe_conversion_up = __and_< |
260 | is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>, |
261 | __not_<is_array<_Up>> |
262 | >; |
263 | |
264 | public: |
265 | // Constructors. |
266 | |
267 | /// Default constructor, creates a unique_ptr that owns nothing. |
268 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
269 | constexpr unique_ptr() noexcept |
270 | : _M_t() |
271 | { } |
272 | |
273 | /** Takes ownership of a pointer. |
274 | * |
275 | * @param __p A pointer to an object of @c element_type |
276 | * |
277 | * The deleter will be value-initialized. |
278 | */ |
279 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
280 | explicit |
281 | unique_ptr(pointer __p) noexcept |
282 | : _M_t(__p) |
283 | { } |
284 | |
285 | /** Takes ownership of a pointer. |
286 | * |
287 | * @param __p A pointer to an object of @c element_type |
288 | * @param __d A reference to a deleter. |
289 | * |
290 | * The deleter will be initialized with @p __d |
291 | */ |
292 | template<typename _Del = deleter_type, |
293 | typename = _Require<is_copy_constructible<_Del>>> |
294 | unique_ptr(pointer __p, const deleter_type& __d) noexcept |
295 | : _M_t(__p, __d) { } |
296 | |
297 | /** Takes ownership of a pointer. |
298 | * |
299 | * @param __p A pointer to an object of @c element_type |
300 | * @param __d An rvalue reference to a (non-reference) deleter. |
301 | * |
302 | * The deleter will be initialized with @p std::move(__d) |
303 | */ |
304 | template<typename _Del = deleter_type, |
305 | typename = _Require<is_move_constructible<_Del>>> |
306 | unique_ptr(pointer __p, |
307 | __enable_if_t<!is_lvalue_reference<_Del>::value, |
308 | _Del&&> __d) noexcept |
309 | : _M_t(__p, std::move(__d)) |
310 | { } |
311 | |
312 | template<typename _Del = deleter_type, |
313 | typename _DelUnref = typename remove_reference<_Del>::type> |
314 | unique_ptr(pointer, |
315 | __enable_if_t<is_lvalue_reference<_Del>::value, |
316 | _DelUnref&&>) = delete; |
317 | |
318 | /// Creates a unique_ptr that owns nothing. |
319 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
320 | constexpr unique_ptr(nullptr_t) noexcept |
321 | : _M_t() |
322 | { } |
323 | |
324 | // Move constructors. |
325 | |
326 | /// Move constructor. |
327 | unique_ptr(unique_ptr&&) = default; |
328 | |
329 | /** @brief Converting constructor from another type |
330 | * |
331 | * Requires that the pointer owned by @p __u is convertible to the |
332 | * type of pointer owned by this object, @p __u does not own an array, |
333 | * and @p __u has a compatible deleter type. |
334 | */ |
335 | template<typename _Up, typename _Ep, typename = _Require< |
336 | __safe_conversion_up<_Up, _Ep>, |
337 | typename conditional<is_reference<_Dp>::value, |
338 | is_same<_Ep, _Dp>, |
339 | is_convertible<_Ep, _Dp>>::type>> |
340 | unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept |
341 | : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) |
342 | { } |
343 | |
344 | #if _GLIBCXX_USE_DEPRECATED1 |
345 | #pragma GCC diagnostic push |
346 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
347 | /// Converting constructor from @c auto_ptr |
348 | template<typename _Up, typename = _Require< |
349 | is_convertible<_Up*, _Tp*>, is_same<_Dp, default_delete<_Tp>>>> |
350 | unique_ptr(auto_ptr<_Up>&& __u) noexcept; |
351 | #pragma GCC diagnostic pop |
352 | #endif |
353 | |
354 | /// Destructor, invokes the deleter if the stored pointer is not null. |
355 | ~unique_ptr() noexcept |
356 | { |
357 | static_assert(__is_invocable<deleter_type&, pointer>::value, |
358 | "unique_ptr's deleter must be invocable with a pointer"); |
359 | auto& __ptr = _M_t._M_ptr(); |
360 | if (__ptr != nullptr) |
361 | get_deleter()(std::move(__ptr)); |
362 | __ptr = pointer(); |
363 | } |
364 | |
365 | // Assignment. |
366 | |
367 | /** @brief Move assignment operator. |
368 | * |
369 | * Invokes the deleter if this object owns a pointer. |
370 | */ |
371 | unique_ptr& operator=(unique_ptr&&) = default; |
372 | |
373 | /** @brief Assignment from another type. |
374 | * |
375 | * @param __u The object to transfer ownership from, which owns a |
376 | * convertible pointer to a non-array object. |
377 | * |
378 | * Invokes the deleter if this object owns a pointer. |
379 | */ |
380 | template<typename _Up, typename _Ep> |
381 | typename enable_if< __and_< |
382 | __safe_conversion_up<_Up, _Ep>, |
383 | is_assignable<deleter_type&, _Ep&&> |
384 | >::value, |
385 | unique_ptr&>::type |
386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept |
387 | { |
388 | reset(__u.release()); |
389 | get_deleter() = std::forward<_Ep>(__u.get_deleter()); |
390 | return *this; |
391 | } |
392 | |
393 | /// Reset the %unique_ptr to empty, invoking the deleter if necessary. |
394 | unique_ptr& |
395 | operator=(nullptr_t) noexcept |
396 | { |
397 | reset(); |
398 | return *this; |
399 | } |
400 | |
401 | // Observers. |
402 | |
403 | /// Dereference the stored pointer. |
404 | typename add_lvalue_reference<element_type>::type |
405 | operator*() const |
406 | { |
407 | __glibcxx_assert(get() != pointer()); |
408 | return *get(); |
409 | } |
410 | |
411 | /// Return the stored pointer. |
412 | pointer |
413 | operator->() const noexcept |
414 | { |
415 | _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); |
416 | return get(); |
417 | } |
418 | |
419 | /// Return the stored pointer. |
420 | pointer |
421 | get() const noexcept |
422 | { return _M_t._M_ptr(); } |
423 | |
424 | /// Return a reference to the stored deleter. |
425 | deleter_type& |
426 | get_deleter() noexcept |
427 | { return _M_t._M_deleter(); } |
428 | |
429 | /// Return a reference to the stored deleter. |
430 | const deleter_type& |
431 | get_deleter() const noexcept |
432 | { return _M_t._M_deleter(); } |
433 | |
434 | /// Return @c true if the stored pointer is not null. |
435 | explicit operator bool() const noexcept |
436 | { return get() == pointer() ? false : true; } |
437 | |
438 | // Modifiers. |
439 | |
440 | /// Release ownership of any stored pointer. |
441 | pointer |
442 | release() noexcept |
443 | { return _M_t.release(); } |
444 | |
445 | /** @brief Replace the stored pointer. |
446 | * |
447 | * @param __p The new pointer to store. |
448 | * |
449 | * The deleter will be invoked if a pointer is already owned. |
450 | */ |
451 | void |
452 | reset(pointer __p = pointer()) noexcept |
453 | { |
454 | static_assert(__is_invocable<deleter_type&, pointer>::value, |
455 | "unique_ptr's deleter must be invocable with a pointer"); |
456 | _M_t.reset(std::move(__p)); |
457 | } |
458 | |
459 | /// Exchange the pointer and deleter with another object. |
460 | void |
461 | swap(unique_ptr& __u) noexcept |
462 | { |
463 | static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); |
464 | _M_t.swap(__u._M_t); |
465 | } |
466 | |
467 | // Disable copy from lvalue. |
468 | unique_ptr(const unique_ptr&) = delete; |
469 | unique_ptr& operator=(const unique_ptr&) = delete; |
470 | }; |
471 | |
472 | /// 20.7.1.3 unique_ptr for array objects with a runtime length |
473 | // [unique.ptr.runtime] |
474 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
475 | // DR 740 - omit specialization for array objects with a compile time length |
476 | template<typename _Tp, typename _Dp> |
477 | class unique_ptr<_Tp[], _Dp> |
478 | { |
479 | template <typename _Up> |
480 | using _DeleterConstraint = |
481 | typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; |
482 | |
483 | __uniq_ptr_data<_Tp, _Dp> _M_t; |
484 | |
485 | template<typename _Up> |
486 | using __remove_cv = typename remove_cv<_Up>::type; |
487 | |
488 | // like is_base_of<_Tp, _Up> but false if unqualified types are the same |
489 | template<typename _Up> |
490 | using __is_derived_Tp |
491 | = __and_< is_base_of<_Tp, _Up>, |
492 | __not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >; |
493 | |
494 | public: |
495 | using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; |
496 | using element_type = _Tp; |
497 | using deleter_type = _Dp; |
498 | |
499 | // helper template for detecting a safe conversion from another |
500 | // unique_ptr |
501 | template<typename _Up, typename _Ep, |
502 | typename _UPtr = unique_ptr<_Up, _Ep>, |
503 | typename _UP_pointer = typename _UPtr::pointer, |
504 | typename _UP_element_type = typename _UPtr::element_type> |
505 | using __safe_conversion_up = __and_< |
506 | is_array<_Up>, |
507 | is_same<pointer, element_type*>, |
508 | is_same<_UP_pointer, _UP_element_type*>, |
509 | is_convertible<_UP_element_type(*)[], element_type(*)[]> |
510 | >; |
511 | |
512 | // helper template for detecting a safe conversion from a raw pointer |
513 | template<typename _Up> |
514 | using __safe_conversion_raw = __and_< |
515 | __or_<__or_<is_same<_Up, pointer>, |
516 | is_same<_Up, nullptr_t>>, |
517 | __and_<is_pointer<_Up>, |
518 | is_same<pointer, element_type*>, |
519 | is_convertible< |
520 | typename remove_pointer<_Up>::type(*)[], |
521 | element_type(*)[]> |
522 | > |
523 | > |
524 | >; |
525 | |
526 | // Constructors. |
527 | |
528 | /// Default constructor, creates a unique_ptr that owns nothing. |
529 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
530 | constexpr unique_ptr() noexcept |
531 | : _M_t() |
532 | { } |
533 | |
534 | /** Takes ownership of a pointer. |
535 | * |
536 | * @param __p A pointer to an array of a type safely convertible |
537 | * to an array of @c element_type |
538 | * |
539 | * The deleter will be value-initialized. |
540 | */ |
541 | template<typename _Up, |
542 | typename _Vp = _Dp, |
543 | typename = _DeleterConstraint<_Vp>, |
544 | typename = typename enable_if< |
545 | __safe_conversion_raw<_Up>::value, bool>::type> |
546 | explicit |
547 | unique_ptr(_Up __p) noexcept |
548 | : _M_t(__p) |
549 | { } |
550 | |
551 | /** Takes ownership of a pointer. |
552 | * |
553 | * @param __p A pointer to an array of a type safely convertible |
554 | * to an array of @c element_type |
555 | * @param __d A reference to a deleter. |
556 | * |
557 | * The deleter will be initialized with @p __d |
558 | */ |
559 | template<typename _Up, typename _Del = deleter_type, |
560 | typename = _Require<__safe_conversion_raw<_Up>, |
561 | is_copy_constructible<_Del>>> |
562 | unique_ptr(_Up __p, const deleter_type& __d) noexcept |
563 | : _M_t(__p, __d) { } |
564 | |
565 | /** Takes ownership of a pointer. |
566 | * |
567 | * @param __p A pointer to an array of a type safely convertible |
568 | * to an array of @c element_type |
569 | * @param __d A reference to a deleter. |
570 | * |
571 | * The deleter will be initialized with @p std::move(__d) |
572 | */ |
573 | template<typename _Up, typename _Del = deleter_type, |
574 | typename = _Require<__safe_conversion_raw<_Up>, |
575 | is_move_constructible<_Del>>> |
576 | unique_ptr(_Up __p, |
577 | __enable_if_t<!is_lvalue_reference<_Del>::value, |
578 | _Del&&> __d) noexcept |
579 | : _M_t(std::move(__p), std::move(__d)) |
580 | { } |
581 | |
582 | template<typename _Up, typename _Del = deleter_type, |
583 | typename _DelUnref = typename remove_reference<_Del>::type, |
584 | typename = _Require<__safe_conversion_raw<_Up>>> |
585 | unique_ptr(_Up, |
586 | __enable_if_t<is_lvalue_reference<_Del>::value, |
587 | _DelUnref&&>) = delete; |
588 | |
589 | /// Move constructor. |
590 | unique_ptr(unique_ptr&&) = default; |
591 | |
592 | /// Creates a unique_ptr that owns nothing. |
593 | template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>> |
594 | constexpr unique_ptr(nullptr_t) noexcept |
595 | : _M_t() |
596 | { } |
597 | |
598 | template<typename _Up, typename _Ep, typename = _Require< |
599 | __safe_conversion_up<_Up, _Ep>, |
600 | typename conditional<is_reference<_Dp>::value, |
601 | is_same<_Ep, _Dp>, |
602 | is_convertible<_Ep, _Dp>>::type>> |
603 | unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept |
604 | : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) |
605 | { } |
606 | |
607 | /// Destructor, invokes the deleter if the stored pointer is not null. |
608 | ~unique_ptr() |
609 | { |
610 | auto& __ptr = _M_t._M_ptr(); |
611 | if (__ptr != nullptr) |
612 | get_deleter()(__ptr); |
613 | __ptr = pointer(); |
614 | } |
615 | |
616 | // Assignment. |
617 | |
618 | /** @brief Move assignment operator. |
619 | * |
620 | * Invokes the deleter if this object owns a pointer. |
621 | */ |
622 | unique_ptr& |
623 | operator=(unique_ptr&&) = default; |
624 | |
625 | /** @brief Assignment from another type. |
626 | * |
627 | * @param __u The object to transfer ownership from, which owns a |
628 | * convertible pointer to an array object. |
629 | * |
630 | * Invokes the deleter if this object owns a pointer. |
631 | */ |
632 | template<typename _Up, typename _Ep> |
633 | typename |
634 | enable_if<__and_<__safe_conversion_up<_Up, _Ep>, |
635 | is_assignable<deleter_type&, _Ep&&> |
636 | >::value, |
637 | unique_ptr&>::type |
638 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept |
639 | { |
640 | reset(__u.release()); |
641 | get_deleter() = std::forward<_Ep>(__u.get_deleter()); |
642 | return *this; |
643 | } |
644 | |
645 | /// Reset the %unique_ptr to empty, invoking the deleter if necessary. |
646 | unique_ptr& |
647 | operator=(nullptr_t) noexcept |
648 | { |
649 | reset(); |
650 | return *this; |
651 | } |
652 | |
653 | // Observers. |
654 | |
655 | /// Access an element of owned array. |
656 | typename std::add_lvalue_reference<element_type>::type |
657 | operator[](size_t __i) const |
658 | { |
659 | __glibcxx_assert(get() != pointer()); |
660 | return get()[__i]; |
661 | } |
662 | |
663 | /// Return the stored pointer. |
664 | pointer |
665 | get() const noexcept |
666 | { return _M_t._M_ptr(); } |
667 | |
668 | /// Return a reference to the stored deleter. |
669 | deleter_type& |
670 | get_deleter() noexcept |
671 | { return _M_t._M_deleter(); } |
672 | |
673 | /// Return a reference to the stored deleter. |
674 | const deleter_type& |
675 | get_deleter() const noexcept |
676 | { return _M_t._M_deleter(); } |
677 | |
678 | /// Return @c true if the stored pointer is not null. |
679 | explicit operator bool() const noexcept |
680 | { return get() == pointer() ? false : true; } |
681 | |
682 | // Modifiers. |
683 | |
684 | /// Release ownership of any stored pointer. |
685 | pointer |
686 | release() noexcept |
687 | { return _M_t.release(); } |
688 | |
689 | /** @brief Replace the stored pointer. |
690 | * |
691 | * @param __p The new pointer to store. |
692 | * |
693 | * The deleter will be invoked if a pointer is already owned. |
694 | */ |
695 | template <typename _Up, |
696 | typename = _Require< |
697 | __or_<is_same<_Up, pointer>, |
698 | __and_<is_same<pointer, element_type*>, |
699 | is_pointer<_Up>, |
700 | is_convertible< |
701 | typename remove_pointer<_Up>::type(*)[], |
702 | element_type(*)[] |
703 | > |
704 | > |
705 | > |
706 | >> |
707 | void |
708 | reset(_Up __p) noexcept |
709 | { _M_t.reset(std::move(__p)); } |
710 | |
711 | void reset(nullptr_t = nullptr) noexcept |
712 | { reset(pointer()); } |
713 | |
714 | /// Exchange the pointer and deleter with another object. |
715 | void |
716 | swap(unique_ptr& __u) noexcept |
717 | { |
718 | static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); |
719 | _M_t.swap(__u._M_t); |
720 | } |
721 | |
722 | // Disable copy from lvalue. |
723 | unique_ptr(const unique_ptr&) = delete; |
724 | unique_ptr& operator=(const unique_ptr&) = delete; |
725 | }; |
726 | |
727 | /// @relates unique_ptr @{ |
728 | |
729 | /// Swap overload for unique_ptr |
730 | template<typename _Tp, typename _Dp> |
731 | inline |
732 | #if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11 |
733 | // Constrained free swap overload, see p0185r1 |
734 | typename enable_if<__is_swappable<_Dp>::value>::type |
735 | #else |
736 | void |
737 | #endif |
738 | swap(unique_ptr<_Tp, _Dp>& __x, |
739 | unique_ptr<_Tp, _Dp>& __y) noexcept |
740 | { __x.swap(__y); } |
741 | |
742 | #if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11 |
743 | template<typename _Tp, typename _Dp> |
744 | typename enable_if<!__is_swappable<_Dp>::value>::type |
745 | swap(unique_ptr<_Tp, _Dp>&, |
746 | unique_ptr<_Tp, _Dp>&) = delete; |
747 | #endif |
748 | |
749 | /// Equality operator for unique_ptr objects, compares the owned pointers |
750 | template<typename _Tp, typename _Dp, |
751 | typename _Up, typename _Ep> |
752 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
753 | operator==(const unique_ptr<_Tp, _Dp>& __x, |
754 | const unique_ptr<_Up, _Ep>& __y) |
755 | { return __x.get() == __y.get(); } |
756 | |
757 | /// unique_ptr comparison with nullptr |
758 | template<typename _Tp, typename _Dp> |
759 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
760 | operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept |
761 | { return !__x; } |
762 | |
763 | #ifndef __cpp_lib_three_way_comparison |
764 | /// unique_ptr comparison with nullptr |
765 | template<typename _Tp, typename _Dp> |
766 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
767 | operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept |
768 | { return !__x; } |
769 | |
770 | /// Inequality operator for unique_ptr objects, compares the owned pointers |
771 | template<typename _Tp, typename _Dp, |
772 | typename _Up, typename _Ep> |
773 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
774 | operator!=(const unique_ptr<_Tp, _Dp>& __x, |
775 | const unique_ptr<_Up, _Ep>& __y) |
776 | { return __x.get() != __y.get(); } |
777 | |
778 | /// unique_ptr comparison with nullptr |
779 | template<typename _Tp, typename _Dp> |
780 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
781 | operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept |
782 | { return (bool)__x; } |
783 | |
784 | /// unique_ptr comparison with nullptr |
785 | template<typename _Tp, typename _Dp> |
786 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
787 | operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept |
788 | { return (bool)__x; } |
789 | #endif // three way comparison |
790 | |
791 | /// Relational operator for unique_ptr objects, compares the owned pointers |
792 | template<typename _Tp, typename _Dp, |
793 | typename _Up, typename _Ep> |
794 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
795 | operator<(const unique_ptr<_Tp, _Dp>& __x, |
796 | const unique_ptr<_Up, _Ep>& __y) |
797 | { |
798 | typedef typename |
799 | std::common_type<typename unique_ptr<_Tp, _Dp>::pointer, |
800 | typename unique_ptr<_Up, _Ep>::pointer>::type _CT; |
801 | return std::less<_CT>()(__x.get(), __y.get()); |
802 | } |
803 | |
804 | /// unique_ptr comparison with nullptr |
805 | template<typename _Tp, typename _Dp> |
806 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
807 | operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
808 | { |
809 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), |
810 | nullptr); |
811 | } |
812 | |
813 | /// unique_ptr comparison with nullptr |
814 | template<typename _Tp, typename _Dp> |
815 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
816 | operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
817 | { |
818 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, |
819 | __x.get()); |
820 | } |
821 | |
822 | /// Relational operator for unique_ptr objects, compares the owned pointers |
823 | template<typename _Tp, typename _Dp, |
824 | typename _Up, typename _Ep> |
825 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
826 | operator<=(const unique_ptr<_Tp, _Dp>& __x, |
827 | const unique_ptr<_Up, _Ep>& __y) |
828 | { return !(__y < __x); } |
829 | |
830 | /// unique_ptr comparison with nullptr |
831 | template<typename _Tp, typename _Dp> |
832 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
833 | operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
834 | { return !(nullptr < __x); } |
835 | |
836 | /// unique_ptr comparison with nullptr |
837 | template<typename _Tp, typename _Dp> |
838 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
839 | operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
840 | { return !(__x < nullptr); } |
841 | |
842 | /// Relational operator for unique_ptr objects, compares the owned pointers |
843 | template<typename _Tp, typename _Dp, |
844 | typename _Up, typename _Ep> |
845 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
846 | operator>(const unique_ptr<_Tp, _Dp>& __x, |
847 | const unique_ptr<_Up, _Ep>& __y) |
848 | { return (__y < __x); } |
849 | |
850 | /// unique_ptr comparison with nullptr |
851 | template<typename _Tp, typename _Dp> |
852 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
853 | operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
854 | { |
855 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr, |
856 | __x.get()); |
857 | } |
858 | |
859 | /// unique_ptr comparison with nullptr |
860 | template<typename _Tp, typename _Dp> |
861 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
862 | operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
863 | { |
864 | return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(), |
865 | nullptr); |
866 | } |
867 | |
868 | /// Relational operator for unique_ptr objects, compares the owned pointers |
869 | template<typename _Tp, typename _Dp, |
870 | typename _Up, typename _Ep> |
871 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
872 | operator>=(const unique_ptr<_Tp, _Dp>& __x, |
873 | const unique_ptr<_Up, _Ep>& __y) |
874 | { return !(__x < __y); } |
875 | |
876 | /// unique_ptr comparison with nullptr |
877 | template<typename _Tp, typename _Dp> |
878 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
879 | operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
880 | { return !(__x < nullptr); } |
881 | |
882 | /// unique_ptr comparison with nullptr |
883 | template<typename _Tp, typename _Dp> |
884 | _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool |
885 | operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) |
886 | { return !(nullptr < __x); } |
887 | |
888 | #ifdef __cpp_lib_three_way_comparison |
889 | template<typename _Tp, typename _Dp, typename _Up, typename _Ep> |
890 | requires three_way_comparable_with<typename unique_ptr<_Tp, _Dp>::pointer, |
891 | typename unique_ptr<_Up, _Ep>::pointer> |
892 | inline |
893 | compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer, |
894 | typename unique_ptr<_Up, _Ep>::pointer> |
895 | operator<=>(const unique_ptr<_Tp, _Dp>& __x, |
896 | const unique_ptr<_Up, _Ep>& __y) |
897 | { return compare_three_way()(__x.get(), __y.get()); } |
898 | |
899 | template<typename _Tp, typename _Dp> |
900 | requires three_way_comparable<typename unique_ptr<_Tp, _Dp>::pointer> |
901 | inline |
902 | compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer> |
903 | operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) |
904 | { |
905 | using pointer = typename unique_ptr<_Tp, _Dp>::pointer; |
906 | return compare_three_way()(__x.get(), static_cast<pointer>(nullptr)); |
907 | } |
908 | #endif |
909 | // @} relates unique_ptr |
910 | |
911 | /// @cond undocumented |
912 | template<typename _Up, typename _Ptr = typename _Up::pointer, |
913 | bool = __poison_hash<_Ptr>::__enable_hash_call> |
914 | struct __uniq_ptr_hash |
915 | #if ! _GLIBCXX_INLINE_VERSION0 |
916 | : private __poison_hash<_Ptr> |
917 | #endif |
918 | { |
919 | size_t |
920 | operator()(const _Up& __u) const |
921 | noexcept(noexcept(std::declval<hash<_Ptr>>()(std::declval<_Ptr>()))) |
922 | { return hash<_Ptr>()(__u.get()); } |
923 | }; |
924 | |
925 | template<typename _Up, typename _Ptr> |
926 | struct __uniq_ptr_hash<_Up, _Ptr, false> |
927 | : private __poison_hash<_Ptr> |
928 | { }; |
929 | /// @endcond |
930 | |
931 | /// std::hash specialization for unique_ptr. |
932 | template<typename _Tp, typename _Dp> |
933 | struct hash<unique_ptr<_Tp, _Dp>> |
934 | : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>, |
935 | public __uniq_ptr_hash<unique_ptr<_Tp, _Dp>> |
936 | { }; |
937 | |
938 | #if __cplusplus201703L >= 201402L |
939 | /// @relates unique_ptr @{ |
940 | #define __cpp_lib_make_unique201304 201304 |
941 | |
942 | /// @cond undocumented |
943 | |
944 | template<typename _Tp> |
945 | struct _MakeUniq |
946 | { typedef unique_ptr<_Tp> __single_object; }; |
947 | |
948 | template<typename _Tp> |
949 | struct _MakeUniq<_Tp[]> |
950 | { typedef unique_ptr<_Tp[]> __array; }; |
951 | |
952 | template<typename _Tp, size_t _Bound> |
953 | struct _MakeUniq<_Tp[_Bound]> |
954 | { struct __invalid_type { }; }; |
955 | |
956 | /// @endcond |
957 | |
958 | /// std::make_unique for single objects |
959 | template<typename _Tp, typename... _Args> |
960 | inline typename _MakeUniq<_Tp>::__single_object |
961 | make_unique(_Args&&... __args) |
962 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } |
963 | |
964 | /// std::make_unique for arrays of unknown bound |
965 | template<typename _Tp> |
966 | inline typename _MakeUniq<_Tp>::__array |
967 | make_unique(size_t __num) |
968 | { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } |
969 | |
970 | /// Disable std::make_unique for arrays of known bound |
971 | template<typename _Tp, typename... _Args> |
972 | inline typename _MakeUniq<_Tp>::__invalid_type |
973 | make_unique(_Args&&...) = delete; |
974 | // @} relates unique_ptr |
975 | #endif // C++14 |
976 | |
977 | #if __cplusplus201703L > 201703L && __cpp_concepts |
978 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
979 | // 2948. unique_ptr does not define operator<< for stream output |
980 | /// Stream output operator for unique_ptr |
981 | template<typename _CharT, typename _Traits, typename _Tp, typename _Dp> |
982 | inline basic_ostream<_CharT, _Traits>& |
983 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
984 | const unique_ptr<_Tp, _Dp>& __p) |
985 | requires requires { __os << __p.get(); } |
986 | { |
987 | __os << __p.get(); |
988 | return __os; |
989 | } |
990 | #endif // C++20 |
991 | |
992 | // @} group pointer_abstractions |
993 | |
994 | #if __cplusplus201703L >= 201703L |
995 | namespace __detail::__variant |
996 | { |
997 | template<typename> struct _Never_valueless_alt; // see <variant> |
998 | |
999 | // Provide the strong exception-safety guarantee when emplacing a |
1000 | // unique_ptr into a variant. |
1001 | template<typename _Tp, typename _Del> |
1002 | struct _Never_valueless_alt<std::unique_ptr<_Tp, _Del>> |
1003 | : std::true_type |
1004 | { }; |
1005 | } // namespace __detail::__variant |
1006 | #endif // C++17 |
1007 | |
1008 | _GLIBCXX_END_NAMESPACE_VERSION |
1009 | } // namespace |
1010 | |
1011 | #endif /* _UNIQUE_PTR_H */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||||
2 | /* | ||||||||||
3 | * This file is part of the LibreOffice project. | ||||||||||
4 | * | ||||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||||
8 | * | ||||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||||
10 | * | ||||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||||
13 | * with this work for additional information regarding copyright | ||||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||||
18 | */ | ||||||||||
19 | |||||||||||
20 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||||
22 | |||||||||||
23 | #include "sal/config.h" | ||||||||||
24 | |||||||||||
25 | #include <cassert> | ||||||||||
26 | #include <cstddef> | ||||||||||
27 | #include <functional> | ||||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||
29 | #include <type_traits> | ||||||||||
30 | #endif | ||||||||||
31 | |||||||||||
32 | #include "sal/types.h" | ||||||||||
33 | |||||||||||
34 | namespace rtl | ||||||||||
35 | { | ||||||||||
36 | |||||||||||
37 | /** Template reference class for reference type. | ||||||||||
38 | */ | ||||||||||
39 | template <class reference_type> | ||||||||||
40 | class Reference | ||||||||||
41 | { | ||||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||||
43 | */ | ||||||||||
44 | reference_type * m_pBody; | ||||||||||
45 | |||||||||||
46 | |||||||||||
47 | public: | ||||||||||
48 | /** Constructor... | ||||||||||
49 | */ | ||||||||||
50 | Reference() | ||||||||||
51 | : m_pBody (NULL__null) | ||||||||||
52 | {} | ||||||||||
53 | |||||||||||
54 | |||||||||||
55 | /** Constructor... | ||||||||||
56 | */ | ||||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||||
58 | : m_pBody (pBody) | ||||||||||
59 | { | ||||||||||
60 | } | ||||||||||
61 | |||||||||||
62 | /** Constructor... | ||||||||||
63 | */ | ||||||||||
64 | Reference (reference_type * pBody) | ||||||||||
65 | : m_pBody (pBody) | ||||||||||
66 | { | ||||||||||
67 | if (m_pBody) | ||||||||||
68 | m_pBody->acquire(); | ||||||||||
69 | } | ||||||||||
70 | |||||||||||
71 | /** Copy constructor... | ||||||||||
72 | */ | ||||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||||
75 | { | ||||||||||
76 | if (m_pBody) | ||||||||||
77 | m_pBody->acquire(); | ||||||||||
78 | } | ||||||||||
79 | |||||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||
81 | /** Move constructor... | ||||||||||
82 | */ | ||||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||||
85 | { | ||||||||||
86 | handle.m_pBody = nullptr; | ||||||||||
87 | } | ||||||||||
88 | #endif | ||||||||||
89 | |||||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||||
92 | |||||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||||
94 | |||||||||||
95 | @param rRef another reference | ||||||||||
96 | */ | ||||||||||
97 | template< class derived_type > | ||||||||||
98 | inline Reference( | ||||||||||
99 | const Reference< derived_type > & rRef, | ||||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||||
101 | : m_pBody (rRef.get()) | ||||||||||
102 | { | ||||||||||
103 | if (m_pBody) | ||||||||||
104 | m_pBody->acquire(); | ||||||||||
105 | } | ||||||||||
106 | #endif | ||||||||||
107 | |||||||||||
108 | /** Destructor... | ||||||||||
109 | */ | ||||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||||
111 | { | ||||||||||
112 | if (m_pBody
| ||||||||||
113 | m_pBody->release(); | ||||||||||
114 | } | ||||||||||
115 | |||||||||||
116 | /** Set... | ||||||||||
117 | Similar to assignment. | ||||||||||
118 | */ | ||||||||||
119 | Reference<reference_type> & | ||||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||||
121 | { | ||||||||||
122 | if (pBody) | ||||||||||
123 | pBody->acquire(); | ||||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||||
125 | m_pBody = pBody; | ||||||||||
126 | if (pOld) | ||||||||||
127 | pOld->release(); | ||||||||||
128 | return *this; | ||||||||||
129 | } | ||||||||||
130 | |||||||||||
131 | /** Assignment. | ||||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||||
133 | bind it to the body represented by the handle. | ||||||||||
134 | */ | ||||||||||
135 | Reference<reference_type> & | ||||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||||
137 | { | ||||||||||
138 | return set( handle.m_pBody ); | ||||||||||
139 | } | ||||||||||
140 | |||||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||
142 | /** Assignment. | ||||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||||
144 | * bind it to the body represented by the handle, and | ||||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||||
146 | */ | ||||||||||
147 | Reference<reference_type> & | ||||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||||
149 | { | ||||||||||
150 | // self-movement guts ourself | ||||||||||
151 | if (m_pBody) | ||||||||||
152 | m_pBody->release(); | ||||||||||
153 | m_pBody = handle.m_pBody; | ||||||||||
154 | handle.m_pBody = nullptr; | ||||||||||
155 | return *this; | ||||||||||
156 | } | ||||||||||
157 | #endif | ||||||||||
158 | |||||||||||
159 | /** Assignment... | ||||||||||
160 | */ | ||||||||||
161 | Reference<reference_type> & | ||||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||||
163 | { | ||||||||||
164 | return set( pBody ); | ||||||||||
165 | } | ||||||||||
166 | |||||||||||
167 | /** Unbind the body from this handle. | ||||||||||
168 | Note that for a handle representing a large body, | ||||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||||
171 | since in the second case two large objects exist in memory | ||||||||||
172 | (the old body and the new body). | ||||||||||
173 | */ | ||||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||||
175 | { | ||||||||||
176 | if (m_pBody) | ||||||||||
177 | { | ||||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||||
179 | m_pBody = NULL__null; | ||||||||||
180 | pOld->release(); | ||||||||||
181 | } | ||||||||||
182 | return *this; | ||||||||||
183 | } | ||||||||||
184 | |||||||||||
185 | |||||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||||
188 | are the same. | ||||||||||
189 | */ | ||||||||||
190 | reference_type * SAL_CALL get() const | ||||||||||
191 | { | ||||||||||
192 | return m_pBody; | ||||||||||
| |||||||||||
193 | } | ||||||||||
194 | |||||||||||
195 | |||||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||||
197 | */ | ||||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||||
199 | { | ||||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||||
201 | return m_pBody; | ||||||||||
202 | } | ||||||||||
203 | |||||||||||
204 | |||||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||||
206 | */ | ||||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||||
208 | { | ||||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||||
210 | return *m_pBody; | ||||||||||
211 | } | ||||||||||
212 | |||||||||||
213 | |||||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||||
215 | */ | ||||||||||
216 | bool SAL_CALL is() const | ||||||||||
217 | { | ||||||||||
218 | return (m_pBody != NULL__null); | ||||||||||
219 | } | ||||||||||
220 | |||||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||||
223 | */ | ||||||||||
224 | explicit operator bool() const | ||||||||||
225 | { | ||||||||||
226 | return is(); | ||||||||||
227 | } | ||||||||||
228 | #endif | ||||||||||
229 | |||||||||||
230 | /** Returns True if this points to pBody. | ||||||||||
231 | */ | ||||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||||
233 | { | ||||||||||
234 | return (m_pBody == pBody); | ||||||||||
235 | } | ||||||||||
236 | |||||||||||
237 | |||||||||||
238 | /** Returns True if handle points to the same body. | ||||||||||
239 | */ | ||||||||||
240 | bool | ||||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||||
242 | { | ||||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||||
244 | } | ||||||||||
245 | |||||||||||
246 | |||||||||||
247 | /** Needed to place References into STL collection. | ||||||||||
248 | */ | ||||||||||
249 | bool | ||||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||||
251 | { | ||||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||||
253 | } | ||||||||||
254 | |||||||||||
255 | |||||||||||
256 | /** Needed to place References into STL collection. | ||||||||||
257 | */ | ||||||||||
258 | bool | ||||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||||
260 | { | ||||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||||
262 | } | ||||||||||
263 | |||||||||||
264 | |||||||||||
265 | /** Needed to place References into STL collection. | ||||||||||
266 | */ | ||||||||||
267 | bool | ||||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||||
269 | { | ||||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||||
271 | } | ||||||||||
272 | }; | ||||||||||
273 | |||||||||||
274 | } // namespace rtl | ||||||||||
275 | |||||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||
277 | namespace std | ||||||||||
278 | { | ||||||||||
279 | |||||||||||
280 | /// @cond INTERNAL | ||||||||||
281 | /** | ||||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||||
283 | |||||||||||
284 | @since LibreOffice 6.3 | ||||||||||
285 | */ | ||||||||||
286 | template<typename T> | ||||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||||
288 | { | ||||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||||
290 | { return std::size_t(s.get()); } | ||||||||||
291 | }; | ||||||||||
292 | /// @endcond | ||||||||||
293 | |||||||||||
294 | } | ||||||||||
295 | |||||||||||
296 | #endif | ||||||||||
297 | |||||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||||
299 | |||||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |