534cf707bc4aec2d91ba69a5033b003d673f55f5
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / tizen-wayland / atspi / accessibility-impl.h
1 #ifndef DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H
2 #define DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/math/rect.h>
24 #include <atomic>
25 #include <bitset>
26 #include <exception>
27 #include <functional>
28 #include <memory>
29 #include <string>
30 #include <unordered_map>
31 #include <unordered_set>
32 #include <vector>
33 #include <stdexcept>
34
35 //INTERNAL INCLUDES
36 #include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
37 #include <dali/internal/accessibility/tizen-wayland/atspi/accessibility.h>
38 #include <dali/integration-api/debug.h>
39
40 namespace Dali
41 {
42 namespace Accessibility
43 {
44 class Accessible;
45 class Text;
46 class Value;
47 class Component;
48 class Collection;
49 class Action;
50
51 /**
52  * @brief Base class for different accessibility bridges
53  *
54  * Bridge is resposible for initializing and managing connection on accessibility bus.
55  * Accessibility clients will not get any information about UI without initialized and upraised bridge.
56  * Concrete implementation depends on the accessibility technology available on the platform.
57  *
58  * @note This class is singleton.
59  */
60 struct Bridge
61 {
62   enum class ForceUpResult
63   {
64     JUST_STARTED,
65     ALREADY_UP
66   };
67
68   /**
69    * @brief Destructor
70    */
71   virtual ~Bridge() = default;
72
73   /**
74    * @brief Get bus name which bridge is initialized on
75    */
76   virtual const std::string& GetBusName() const = 0;
77
78   /**
79    * @brief Registers top level window
80    *
81    * Hierarchy of objects visible for accessibility clients is based on tree-like
82    * structure created from Actors objects. This method allows to connect chosen
83    * object as direct ancestor of application and therefore make it visible for
84    * accessibility clients.
85    */
86   virtual void AddTopLevelWindow( Accessible* ) = 0;
87
88   /**
89    * @brief Removes top level window
90    *
91    * Hierarchy of objects visible for accessibility clients is based on tree-like
92    * structure created from Actors objects. This method removes previously added
93    * window from visible accessibility objects.
94    */
95   virtual void RemoveTopLevelWindow( Accessible* ) = 0;
96
97   /**
98    * @brief Adds popup window
99    *
100    * Hierarchy of objects visible for accessibility clients is based on tree-like
101    * structure created from Actors objects. This method adds new popup to the tree.
102    */
103   virtual void AddPopup( Accessible* ) = 0;
104
105   /**
106    * @brief Removes popup window
107    *
108    * Hierarchy of objects visible for accessibility clients is based on tree-like
109    * structure created from Actors objects. This method removes previously added
110    * popup window.
111    */
112   virtual void RemovePopup( Accessible* ) = 0;
113
114   /**
115    * @brief Set name of current application which will be visible on accessibility bus
116    */
117   virtual void SetApplicationName( std::string ) = 0;
118
119   /**
120    * @brief Get object being root of accessibility tree
121    *
122    * @return handler to accessibility object
123    */
124   virtual Accessible* GetApplication() const = 0;
125
126   /**
127    * @brief Find an object in accessibility tree
128    *
129    * @param[in] s path to object
130    *
131    * @return handler to accessibility object
132    */
133   virtual Accessible* FindByPath( const std::string& s) const = 0;
134
135   /**
136    * @brief Show application on accessibility bus
137    */
138   virtual void ApplicationShown() = 0;
139
140   /**
141    * @brief Hide application on accessibility bus
142    */
143   virtual void ApplicationHidden() = 0;
144
145   /**
146    * @brief Initialize accessibility bus
147    */
148   virtual void Initialize() = 0;
149
150   /**
151    * @brief Terminate accessibility bus
152    */
153   virtual void Terminate() = 0;
154
155   /**
156    * @brief This method is called, when bridge is being activated.
157    */
158   virtual ForceUpResult ForceUp()
159   {
160     if( data )
161     {
162       return ForceUpResult::ALREADY_UP;
163     }
164     data = std::make_shared< Data >();
165     data->bridge = this;
166     return ForceUpResult::JUST_STARTED;
167   }
168
169   /**
170    * @brief This method is called, when bridge is being deactivated.
171    */
172   virtual void ForceDown() = 0;
173
174   /**
175    * @brief Check if bridge is activated or not.
176    * @return True if brige is activated.
177    */
178   bool IsUp() const
179   {
180     return bool(data);
181   }
182
183   /**
184    * @brief Emits caret-moved event on at-spi bus.
185    **/
186   virtual void EmitCaretMoved( Accessible* obj, unsigned int cursorPosition ) = 0;
187
188   /**
189    * @brief Emits active-descendant-changed event on at-spi bus.
190    **/
191   virtual void EmitActiveDescendantChanged( Accessible* obj, Accessible *child ) = 0;
192
193   /**
194    * @brief Emits text-changed event on at-spi bus.
195    **/
196   virtual void EmitTextChanged( Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string &content ) = 0;
197
198   /**
199    * @brief Emits state-changed event on at-spi bus.
200    **/
201   virtual void EmitStateChanged( Accessible* obj, State state, int val1, int val2 = 0 ) = 0;
202
203   /**
204    * @brief Emits window event on at-spi bus.
205    **/
206   virtual void Emit( Accessible* obj, WindowEvent we, unsigned int detail1 = 0 ) = 0;
207
208   /**
209    * @brief Emits property-changed event on at-spi bus.
210    **/
211   virtual void Emit( Accessible* obj, ObjectPropertyChangeEvent event ) = 0;
212
213   /**
214    * @brief Emits bounds-changed event on at-spi bus.
215    **/
216   virtual void EmitBoundsChanged( Accessible* obj, Rect<> rect ) = 0;
217
218   /**
219    * @brief Emits key event on at-spi bus.
220    *
221    * Screen-reader might receive this event and reply, that given keycode is consumed. In that case
222    * further processing of the keycode should be ignored.
223    **/
224   virtual Consumed Emit( KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText ) = 0;
225
226   /**
227    * @brief Reads given text by screen reader
228    *
229    * @param text The text to read
230    * @param discardable If TRUE, reading can be discarded by subsequent reading requests,
231    * if FALSE the reading must finish before next reading request can be started
232    * @param callback the callback function that is called on reading signals emitted
233    * during processing of this reading request.
234    * Callback can be one of the following signals:
235    * ReadingCancelled, ReadingStopped, ReadingSkipped
236    */
237   virtual void Say( const std::string& text, bool discardable, std::function<void(std::string)> callback ) = 0;
238
239   /**
240    * @brief Force accessibility client to pause.
241    */
242   virtual void Pause() = 0;
243
244   /**
245    * @brief Force accessibility client to resume.
246    */
247   virtual void Resume() = 0;
248
249   /**
250    * @brief Get screen reader status.
251    */
252   virtual bool GetScreenReaderEnabled() = 0;
253
254   /**
255    * @brief Get ATSPI status.
256    */
257   virtual bool GetIsEnabled() = 0;
258
259   /**
260    * @brief Returns instance of bridge singleton object.
261    **/
262   static Bridge* GetCurrentBridge();
263
264 protected:
265   struct Data
266   {
267     std::unordered_set< Accessible* > knownObjects;
268     std::string busName;
269     Bridge* bridge = nullptr;
270     Actor highlightActor, currentlyHighlightedActor;
271   };
272   std::shared_ptr< Data > data;
273   friend class Accessible;
274
275   /**
276    * @brief Registers accessible object to be known in bridge object
277    *
278    * Bridge must known about all currently alive accessible objects, as some requst
279    * might come and object will be identified by number id (it's memory address).
280    * To avoid memory corruption number id is checked against set of known objects.
281    **/
282   void RegisterOnBridge( Accessible* );
283
284   /**
285    * @brief Tells bridge, that given object is considered root (doesn't have any parents).
286    *
287    * All root objects will have the same parent - application object. Application object
288    * is controlled by bridge and private.
289    **/
290   void SetIsOnRootLevel( Accessible* );
291 };
292
293 /**
294  * @brief Check if ATSPI is activated or not.
295  * @return True if ATSPI is activated.
296  */
297 inline bool IsUp()
298 {
299   if( Bridge::GetCurrentBridge() == nullptr )
300   {
301     return false;
302   }
303   if( Bridge::GetCurrentBridge()->GetIsEnabled() == false )
304   {
305     return false;
306   }
307   return Bridge::GetCurrentBridge()->IsUp();
308 }
309
310 /**
311  * @brief Basic interface implemented by all accessibility objects
312  */
313 class Accessible
314 {
315 public:
316   virtual ~Accessible();
317
318   using utf8_t = unsigned char;
319
320   /**
321    * @brief Calculaties word boundaries in given utf8 text.
322    *
323    * s and length represents source text pointer and it's length respectively. langauge represents
324    * language to use. Word boundaries are returned as non-zero values in table breaks, which
325    * must be of size at least length.
326    **/
327   void FindWordSeparationsUtf8( const utf8_t *s, size_t length, const char *language, char *breaks );
328
329   /**
330    * @brief Calculaties line boundaries in given utf8 text.
331    *
332    * s and length represents source text pointer and it's length respectively. langauge represents
333    * language to use. Line boundaries are returned as non-zero values in table breaks, which
334    * must be of size at least length.
335    **/
336   void FindLineSeparationsUtf8( const utf8_t *s, size_t length, const char *language, char *breaks );
337
338   /**
339    * @brief Helper function for emiting active-descendant-changed event
340    **/
341   void EmitActiveDescendantChanged( Accessible* obj, Accessible *child );
342
343   /**
344    * @brief Helper function for emiting state-changed event
345    **/
346   void EmitStateChanged( State state, int newValue1, int newValue2 = 0 );
347
348   /**
349    * @brief Helper function for emiting bounds-changed event
350    **/
351   void EmitBoundsChanged( Rect<> rect );
352
353   /**
354    * @brief Emit "showing" event.
355    * The method inform accessibility clients about "showing" state
356    *
357    * @param[in] showing flag pointing if object is showing
358    */
359   void EmitShowing( bool showing );
360
361   /**
362    * @brief Emit "visible" event.
363    * The method inform accessibility clients about "visible" state
364    *
365    * @param[in] visible flag pointing if object is visible
366    */
367   void EmitVisible( bool visible );
368
369   /**
370    * @brief Emit "highlighted" event.
371    * The method inform accessibility clients about "highlighted" state
372    *
373    * @param[in] set flag pointing if object is highlighted
374    */
375   void EmitHighlighted( bool set );
376
377   /**
378    * @brief Emit "focused" event.
379    * The method inform accessibility clients about "focused" state
380    *
381    * @param[in] set flag pointing if object is focused
382    */
383   void EmitFocused( bool set );
384
385   /**
386    * @brief Emit "text inserted" event
387    *
388    * @param[in] position caret position
389    * @param[in] length text length
390    * @param[in] content inserted text
391    */
392   void EmitTextInserted( unsigned int position, unsigned int length, const std::string &content );
393
394   /**
395    * @brief Emit "text deleted" event
396    *
397    * @param[in] position caret position
398    * @param[in] length text length
399    * @param[in] content deleted text
400    */
401   void EmitTextDeleted( unsigned int position, unsigned int length, const std::string &content );
402
403   /**
404    * @brief Emit "caret moved" event
405    *
406    * @param[in] cursorPosition new caret position
407    */
408   void EmitTextCaretMoved( unsigned int cursorPosition );
409
410   /**
411    * @brief Emit "highlighted" event
412    *
413    * @param[in] we enumerated window event
414    * @param[in] detail1 additional parameter which interpretation depends on chosen event
415    */
416   void Emit( WindowEvent we, unsigned int detail1 = 0 );
417
418   /**
419    * @brief Emits property-changed event
420    * @param[in] Property changed event
421    **/
422   void Emit( ObjectPropertyChangeEvent event );
423
424   /**
425    * @brief Get accessibility name
426    *
427    * @return string with name
428    */
429   virtual std::string GetName() = 0;
430
431   /**
432    * @brief Get accessibility description
433    *
434    * @return string with description
435    */
436   virtual std::string GetDescription() = 0;
437
438   /**
439    * @brief Get parent
440    *
441    * @return handler to accessibility object
442    */
443   virtual Accessible* GetParent() = 0;
444
445   /**
446    * @brief Get count of children
447    *
448    * @return unsigned integer value
449    */
450   virtual size_t GetChildCount() = 0;
451
452   /**
453    * @brief Get collection with all children
454    *
455    * @return collection of accessibility objects
456    */
457   virtual std::vector< Accessible* > GetChildren();
458
459   /**
460    * @brief Get nth child
461    *
462    * @return accessibility object
463    */
464   virtual Accessible* GetChildAtIndex( size_t index ) = 0;
465
466   /**
467    * @brief Get index that current object has in its parent's children collection
468    *
469    * @return unsigned integer index
470    */
471   virtual size_t GetIndexInParent() = 0;
472
473   /**
474    * @brief Get accessibility role
475    *
476    * @return Role enumeration
477    *
478    * @see Dali::Accessibility::Role
479    */
480   virtual Role GetRole() = 0;
481
482   /**
483    * @brief Get name of accessibility role
484    *
485    * @return string with human readable role converted from enumeration
486    *
487    * @see Dali::Accessibility::Role
488    * @see Accessibility::Accessible::GetRole
489    */
490   virtual std::string GetRoleName();
491
492   /**
493    * @brief Get localized name of accessibility role
494    *
495    * @return string with human readable role translated according to current
496    * translation domain
497    *
498    * @see Dali::Accessibility::Role
499    * @see Accessibility::Accessible::GetRole
500    * @see Accessibility::Accessible::GetRoleName
501    *
502    * @note translation is not supported in this version
503    */
504   virtual std::string GetLocalizedRoleName();
505
506   /**
507    * @brief Get accessibility states
508    *
509    * @return collection of states
510    *
511    * @note States class is instatation of ArrayBitset template class
512    *
513    * @see Dali::Accessibility::State
514    * @see Dali::Accessibility::ArrayBitset
515    */
516   virtual States GetStates() = 0;
517
518   /**
519    * @brief Get accessibility attributes
520    *
521    * @return map of attributes and their values
522    */
523   virtual Attributes GetAttributes() = 0;
524
525   /**
526    * @brief Check if this is proxy
527    *
528    * @return True if this is proxy
529    */
530   virtual bool IsProxy();
531
532   /**
533    * @brief Get unique address on accessibility bus
534    *
535    * @return class containing address
536    *
537    * @see Dali::Accessibility::Address
538    */
539   virtual Address GetAddress();
540
541   /**
542    * @brief Get accessibility object, which is "default label" for this object
543    */
544   virtual Accessible* GetDefaultLabel();
545
546   /**
547    * @brief Depute an object to perform provided gesture
548    *
549    * @param[in] gestureInfo structure describing the gesture
550    *
551    * @return true on success, false otherwise
552    *
553    * @see Dali::Accessibility::GestureInfo
554    */
555   virtual bool DoGesture(const GestureInfo &gestureInfo) = 0;
556
557   /**
558    * @brief Re-emits selected states of an Accessibility Object
559    *
560    * @param[in] states chosen states to re-emit
561    * @param[in] doRecursive if true all children of the Accessibility Object will also re-emit the states
562    */
563   void NotifyAccessibilityStateChange( Dali::Accessibility::States states, bool doRecursive );
564
565   /**
566    * @brief Get information about current object and all relations that connects
567    * it with other accessibility objects
568    *
569    * @return iterable collection of Relation objects
570    *
571    * @see Dali::Accessibility::Relation
572    */
573   virtual std::vector<Relation> GetRelationSet() = 0;
574
575   /**
576    * @brief Get all implemented interfaces
577    *
578    * @return collection of strings with implemented interfaces
579    */
580   std::vector< std::string > GetInterfaces();
581
582   /**
583    * @brief Check if object is on root level
584    */
585   bool GetIsOnRootLevel() const { return isOnRootLevel; }
586
587   /**
588    * @brief The method registers functor resposible for converting Actor into Accessible
589    * @param functor returning Accessible handle from Actor object
590    */
591   static void RegisterControlAccessibilityGetter( std::function< Accessible*( Dali::Actor ) > functor);
592
593   /**
594    * @brief Acquire Accessible object from Actor object
595    *
596    * @param[in] actor Actor object
597    * @param[in] root true, if it's top level object (window)
598    *
599    * @return handle to Accessible object
600    */
601   static Accessible* Get( Dali::Actor actor, bool root = false );
602
603 protected:
604   Accessible();
605   Accessible( const Accessible& ) = delete;
606   Accessible( Accessible&& ) = delete;
607   Accessible& operator=( const Accessible& ) = delete;
608   Accessible& operator=( Accessible&& ) = delete;
609   std::shared_ptr< Bridge::Data > GetBridgeData();
610   static Dali::Actor GetHighlightActor();
611   static void SetHighlightActor(Dali::Actor actor);
612   static Dali::Actor GetCurrentlyHighlightedActor();
613   static void SetCurrentlyHighlightedActor(Dali::Actor);
614
615 private:
616   friend class Bridge;
617
618   std::weak_ptr< Bridge::Data > bridgeData;
619   bool isOnRootLevel = false;
620 };
621
622 /**
623  * @brief Interface enabling to perform provided actions
624  */
625 class Action : public virtual Accessible
626 {
627 public:
628   /**
629    * @brief Get name of action with given index
630    *
631    * @param[in] index index of action
632    *
633    * @return string with name of action
634    */
635   virtual std::string GetActionName( size_t index ) = 0;
636
637   /**
638    * @brief Get translated name of action with given index
639    *
640    * @param[in] index index of action
641    *
642    * @return string with name of action translated according to current translation domain
643    *
644    * @note translation is not supported in this version
645    */
646   virtual std::string GetLocalizedActionName( size_t index ) = 0;
647
648   /**
649    * @brief Get description of action with given index
650    *
651    * @param[in] index index of action
652    *
653    * @return string with description of action
654    */
655   virtual std::string GetActionDescription( size_t index ) = 0;
656
657   /**
658    * @brief Get key code binded to action with given index
659    *
660    * @param[in] index index of action
661    *
662    * @return string with key name
663    */
664   virtual std::string GetActionKeyBinding( size_t index ) = 0;
665
666   /**
667    * @brief Get number of provided actions
668    *
669    * @return unsigned integer with number of actions
670    */
671   virtual size_t GetActionCount() = 0;
672
673   /**
674    * @brief Perform an action with given index
675    *
676    * @param index index of action
677    *
678    * @return true on success, false otherwise
679    */
680   virtual bool DoAction( size_t index ) = 0;
681
682   /**
683    * @brief Perform an action with given name
684    *
685    * @param name name of action
686    *
687    * @return true on success, false otherwise
688    */
689   virtual bool DoAction( const std::string& name ) = 0;
690
691 };
692
693 /**
694  * @brief Interface enabling advanced quering of accessibility objects
695  *
696  * @note since all mathods can be implemented inside bridge,
697  * none methods have to be overrided
698  */
699 class Collection : public virtual Accessible
700 {
701 public:
702 };
703
704 /**
705  * @brief Interface representing objects having screen coordinates
706  */
707 class Component : public virtual Accessible
708 {
709 public:
710   /**
711    * @brief Get rectangle describing size
712    *
713    * @param[in] ctype enumeration with type of coordinate systems
714    *
715    * @return Rect<> object
716    *
717    * @see Dali::Rect
718    */
719   virtual Rect<> GetExtents( CoordType ctype ) = 0;
720
721   /**
722    * @brief Get layer current object is localized on
723    *
724    * @return enumeration pointing layer
725    *
726    * @see Dali::Accessibility::ComponentLayer
727    */
728   virtual ComponentLayer GetLayer() = 0;
729
730   /**
731    * @brief Get value of z-order
732    *
733    * @return value of z-order
734    */
735   virtual int16_t GetMdiZOrder() = 0;
736
737   /**
738    * @brief Set current object as "focused"
739    *
740    * @return true on success, false otherwise
741    */
742   virtual bool GrabFocus() = 0;
743
744   /**
745    * @brief Get value of alpha channel
746    *
747    * @return alpha channel value in range [0.0, 1.0]
748    */
749   virtual double GetAlpha() = 0;
750
751   /**
752    * @brief Set current object as "highlighted"
753    *
754    * The method assings "highlighted" state, simultaneously removing it
755    * from currently highlighted object.
756    *
757    * @return true on success, false otherwise
758    */
759   virtual bool GrabHighlight() = 0;
760
761   /**
762    * @brief Set current object as "unhighlighted"
763    *
764    * The method removes "highlighted" state from object.
765    *
766    * @return true on success, false otherwise
767    *
768    * @see Dali:Accessibility::State
769    */
770   virtual bool ClearHighlight() = 0;
771
772   /**
773    * @brief Get index of "highlighted" object
774    *
775    * @return The index of "highlighted" object
776    *
777    * @see Dali:Accessibility::State
778    */
779   virtual int GetHighlightIndex() = 0;
780
781   /**
782    * @brief Check whether object can be scrolled
783    *
784    * @return true if object is scrollable, false otherwise
785    *
786    * @see Dali:Accessibility::State
787    */
788   virtual bool IsScrollable();
789
790   /**
791    * @brief Get Accessible object containing given point
792    *
793    * @param[in] p two-dimensional point
794    * @param[in] ctype enumeration with type of coordinate system
795    *
796    * @return handle to last child of current object which contains given point
797    *
798    * @see Dali::Accessibility::Point
799    */
800   virtual Accessible* GetAccessibleAtPoint( Point p, CoordType ctype );
801
802   /**
803    * @brief Check if current object contains given point
804    *
805    * @param[in] p two-dimensional point
806    * @param[in] ctype enumeration with type of coordinate system
807    *
808    * @return handle to Accessible object
809    *
810    * @see Dali::Accessibility::Point
811    */
812   virtual bool Contains( Point p, CoordType ctype );
813 };
814
815 /**
816  * @brief Interface representing objects which can store numeric value
817  */
818 class Value : public virtual Accessible
819 {
820 public:
821   /**
822    * @brief Get the lowest possible value
823    *
824    * @return double value
825   */
826   virtual double GetMinimum() = 0;
827
828   /**
829    * @brief Get current value
830    *
831    * @return double value
832   */
833   virtual double GetCurrent() = 0;
834
835   /**
836    * @brief Get the highest possible value
837    *
838    * @return double value
839   */
840   virtual double GetMaximum() = 0;
841
842   /**
843    * @brief Set value
844    *
845    * @param[in] val double value
846    *
847    * @return true if value could have been assigned, false otherwise
848   */
849   virtual bool SetCurrent( double val) = 0;
850
851   /**
852    * @brief Get the lowest increment that can be distinguished
853    *
854    * @return double value
855   */
856   virtual double GetMinimumIncrement() = 0;
857 };
858
859 /**
860  * @brief Interface representing objects which can store immutable texts
861  *
862  * @see Dali::Accessibility::EditableText
863  */
864 class Text : public virtual Accessible
865 {
866 public:
867   /**
868    * @brief Get stored text in given range
869    *
870    * @param[in] startOffset index of first character
871    * @param[in] endOffset index of first character after the last one expected
872    *
873    * @return substring of stored text
874    */
875   virtual std::string GetText( size_t startOffset, size_t endOffset ) = 0;
876
877   /**
878    * @brief Get number of all stored characters
879    *
880    * @return number of characters
881    */
882   virtual size_t GetCharacterCount() = 0;
883
884   /**
885    * @brief Get caret offset
886    *
887    * @return Value of caret offset
888    */
889   virtual size_t GetCaretOffset() = 0;
890
891   /**
892    * @brief Set caret offset
893    *
894    * @param[in] caret offset
895    *
896    * @return True if successful
897    */
898   virtual bool SetCaretOffset(size_t offset) = 0;
899
900   /**
901    * @brief Get substring of stored text truncated in concrete gradation
902    *
903    * @param[in] offset position in stored text
904    * @param[in] boundary enumeration describing text gradation
905    *
906    * @return Range structure containing acquired text and offsets in original string
907    *
908    * @see Dali::Accessibility::Range
909    */
910   virtual Range GetTextAtOffset( size_t offset, TextBoundary boundary ) = 0;
911
912   /**
913    * @brief Get selected text
914    *
915    * @param[in] selectionNum selection index
916    * @note Currently only one selection (i.e. with index = 0) is supported
917    *
918    * @return Range structure containing acquired text and offsets in original string
919    *
920    * @see Dali::Accessibility::Range
921    */
922   virtual Range GetSelection( size_t selectionNum ) = 0;
923
924   /**
925    * @brief Remove selection
926    *
927    * @param[in] selectionNum selection index
928    * @note Currently only one selection (i.e. with index = 0) is supported
929    *
930    * @return bool on success, false otherwise
931    */
932   virtual bool RemoveSelection( size_t selectionNum ) = 0;
933
934   /**
935    * @brief Get selected text
936    *
937    * @param[in] selectionNum selection index
938    * @param[in] startOffset index of first character
939    * @param[in] endOffset index of first character after the last one expected
940    *
941    * @note Currently only one selection (i.e. with index = 0) is supported
942    *
943    * @return true on success, false otherwise
944    */
945   virtual bool SetSelection( size_t selectionNum, size_t startOffset, size_t endOffset ) = 0;
946 };
947
948 /**
949  * @brief Interface representing objects which can store editable texts
950  *
951  * @note Paste method is entirely implemented inside bridge
952  *
953  * @see Dali::Accessibility::EditableText
954  */
955 class EditableText : public virtual Accessible
956 {
957 public:
958   /**
959    * @brief Copy text in range to system clipboard
960    *
961    * @param[in] startPosition index of first character
962    * @param[in] endPosition index of first character after the last one expected
963    *
964    * @return true on success, false otherwise
965    */
966   virtual bool CopyText( size_t startPosition, size_t endPosition ) = 0;
967
968   /**
969    * @brief Cut text in range to system clipboard
970    *
971    * @param[in] startPosition index of first character
972    * @param[in] endPosition index of first character after the last one expected
973    *
974    * @return true on success, false otherwise
975    */
976   virtual bool CutText( size_t startPosition, size_t endPosition ) = 0;
977 };
978
979 /**
980  * @brief minimalistic, always empty Accessible object with settable address
981  *
982  * For those situations, where you want to return address in different bridge
983  * (embedding for example), but the object itself ain't planned to be used otherwise.
984  * This object has null parent, no children, empty name and so on
985  */
986 class EmptyAccessibleWithAddress : public virtual Accessible
987 {
988 public:
989   EmptyAccessibleWithAddress() = default;
990   EmptyAccessibleWithAddress( Address address ) : address( std::move( address ) ) {}
991
992   void SetAddress( Address address ) { this->address = std::move( address ); }
993
994   std::string GetName() override { return ""; }
995   std::string GetDescription() override { return ""; }
996   Accessible* GetParent() override { return nullptr; }
997   size_t GetChildCount() override { return 0; }
998   std::vector< Accessible* > GetChildren() override { return {}; }
999   Accessible* GetChildAtIndex( size_t index ) override
1000   {
1001     throw std::domain_error{"out of bounds index (" + std::to_string( index ) + ") - no children"};
1002   }
1003   size_t GetIndexInParent() override { return static_cast< size_t >( -1 ); }
1004   Role GetRole() override { return {}; }
1005   std::string GetRoleName() override;
1006   States GetStates() override { return {}; }
1007   Attributes GetAttributes() override { return {}; }
1008   Address GetAddress() override
1009   {
1010     return address;
1011   }
1012   bool DoGesture(const GestureInfo &gestureInfo) override
1013   {
1014     return false;
1015   }
1016   std::vector<Relation> GetRelationSet() override
1017   {
1018     return {};
1019   }
1020
1021 private:
1022   Address address;
1023 };
1024
1025 }
1026 }
1027
1028 #endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H