X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flogical-model-impl.h;h=c54c5230767e55a88fad3ceb6c7eb435f5cf1c28;hp=7085d797cdea548bf49086776374798f5ae392d4;hb=29bbe2381a1cfdd96757dfd441e7f9747560b2c8;hpb=eefe73d95db6e9be0b518c5b796e1f1a081cce12 diff --git a/dali-toolkit/internal/text/logical-model-impl.h b/dali-toolkit/internal/text/logical-model-impl.h index 7085d79..c54c523 100644 --- a/dali-toolkit/internal/text/logical-model-impl.h +++ b/dali-toolkit/internal/text/logical-model-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__ -#define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__ +#ifndef DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H +#define DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,22 +24,25 @@ #include // INTERNAL INCLUDES +#include #include #include +#include #include -#include +#include #include +#include +#include #include +#include +#include namespace Dali { - namespace Toolkit { - namespace Text { - class LogicalModel; typedef IntrusivePtr LogicalModelPtr; struct InputStyle; @@ -53,7 +56,6 @@ struct InputStyle; class LogicalModel : public RefObject { public: - /** * @brief Create a new instance of a LogicalModel. * @@ -70,7 +72,7 @@ public: * * @return The character's script. */ - Script GetScript( CharacterIndex characterIndex ) const; + Script GetScript(CharacterIndex characterIndex) const; // Bidirectional support interface. @@ -83,35 +85,51 @@ public: * * @return The character's direction. */ - CharacterDirection GetCharacterDirection( CharacterIndex characterIndex ) const; + CharacterDirection GetCharacterDirection(CharacterIndex characterIndex) const; // Visual <--> Logical conversion tables. /** - * @brief Sets the visual to logical and the logical to visual map tables. + * @brief Retrieves the logical cursor index for the given visual cursor index. * - * Replaces any map tables previously set. + * @pre The method FetchBidirectionalLineInfo() must be called before. If the result of FetchBidirectionalLineInfo() is false, + * then the character is not in a bidirectional line and the result will be invalid. * - * @note If the number of runs is zero the bidirectional info buffer is cleared. + * @param[in] visualCursorIndex The visual cursor index. * - * @param[in] bidirectionalInfo Pointer to a buffer with all the bidirectional info runs. - * @param[in] numberOfRuns The number of bidirectional info runs. - * @param[in] startIndex Character index from where the conversion tables are set. - * @param[in] numberOfCharacters The number of characters. + * @return The logical cursor index. */ - void SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo, - Length numberOfRuns, - CharacterIndex startIndex, - Length numberOfCharacters ); + CharacterIndex GetLogicalCursorIndex(CharacterIndex visualCursorIndex); /** * @brief Retrieves the logical character index for the given visual character index. * + * @pre The method FetchBidirectionalLineInfo() must be called before. If the result of FetchBidirectionalLineInfo() is false, + * then the character is not in a bidirectional line and the result will be invalid. + * * @param[in] visualCharacterIndex The visual character index. * * @return The logical character index. */ - CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const; + CharacterIndex GetLogicalCharacterIndex(CharacterIndex visualCharacterIndex); + + /** + * @brief Fetch the bidirectional line info for the given character. + * + * Call GetBidirectionalLineInfo() to retrieve the last fetched line. + * + * @param[in] characterIndex The character index. + * + * @return @e true if the given @e character is in a bidirectional line. + */ + bool FetchBidirectionalLineInfo(CharacterIndex characterIndex); + + /** + * @brief Retrieves the last fetched bidirectional line info. + * + * @return The index of the bidirectional line info. + */ + BidirectionalLineRunIndex GetBidirectionalLineInfo() const; // Text style. @@ -121,7 +139,7 @@ public: * @param[in] index The character's index. * @param[in] numberOfCharacters The number of characters added or removed. If the value is negative the characters are removed. */ - void UpdateTextStyleRuns( CharacterIndex index, int numberOfCharacters ); + void UpdateTextStyleRuns(CharacterIndex index, int numberOfCharacters); /** * @brief Retrieves the text's style for the given character index. @@ -129,48 +147,105 @@ public: * @param[in] index The character index. * @param[out] style The text's style in the given style. */ - void RetrieveStyle( CharacterIndex index, InputStyle& style ); + void RetrieveStyle(CharacterIndex index, InputStyle& style); /** * @brief Clears the font description runs. */ void ClearFontDescriptionRuns(); -protected: + /** + * @brief Clears the strikethrough runs. + */ + void ClearStrikethroughRuns(); + + // Paragraphs /** + * @brief Creates the paragraph info. + * + * @pre The line break info must be set. + * + * @param[in] startIndex The character from where the paragraph info is set. + * @param[in] numberOfCharacters The number of characters. + */ + void CreateParagraphInfo(CharacterIndex startIndex, + Length numberOfCharacters); + + /** + * @brief Find the paragraphs which contains the given characters. + * + * @param[in] index The first character's index of the run. + * @param[in] numberOfCharacters The number of characters of the run. + * @param[out] paragraphs Indices to the paragraphs which contain the characters. + */ + void FindParagraphs(CharacterIndex index, + Length numberOfCharacters, + Vector& paragraphs); + + /** + * @brief Retrieves the number of bounded paragraph runs. + * + * @return The number of bounded paragraph runs. + */ + Length GetNumberOfBoundedParagraphRuns() const; + + /** + * @brief Retrieves the reference for bounded paragraph runs. + * + * @return The reference for bounded paragraph runs. + */ + const Vector& GetBoundedParagraphRuns() const; + + // Embedded images + + /** + * @brief Clears the embedded images. + */ + void ClearEmbeddedImages(); + + /** + * @brief Clears the anchors. + */ + void ClearAnchors(); + +protected: + /** * @brief A reference counted object may only be deleted by calling Unreference(). */ virtual ~LogicalModel(); private: - /** * @brief Private constructor. */ LogicalModel(); // Undefined - LogicalModel( const LogicalModel& handle ); + LogicalModel(const LogicalModel& handle); // Undefined - LogicalModel& operator=( const LogicalModel& handle ); + LogicalModel& operator=(const LogicalModel& handle); public: - Vector mText; Vector mScriptRuns; Vector mFontRuns; Vector mColorRuns; + Vector mBackgroundColorRuns; Vector mFontDescriptionRuns; Vector mLineBreakInfo; - Vector mWordBreakInfo; + Vector mParagraphInfo; Vector mBidirectionalParagraphInfo; - Vector mCharacterDirections; ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ). + Vector mCharacterDirections; ///< For each character, whether is right to left. ( @e flase is left to right, @e true right to left ). Vector mBidirectionalLineInfo; - Vector mLogicalToVisualMap; ///< Bidirectional logical to visual conversion table. - Vector mVisualToLogicalMap; ///< Bidirectional visual to logical conversion table. - Vector mVisualToLogicalCursorMap; ///< Bidirectional visual to logical cursor conversion table. + Vector mEmbeddedItems; + Vector mAnchors; + Vector mUnderlinedCharacterRuns; ///< The underlined character run from markup-processor + Vector mStrikethroughCharacterRuns; ///< The strikethrough character run from markup-processor + Vector mBoundedParagraphRuns; ///< The bounded paragraph is used to handle a paragraph mark-up tag and it's attributes. Like TextAlign, TextDirection, TextIndent, LineHeight, etc. + + BidirectionalLineRunIndex mBidirectionalLineIndex; ///< The last fetched bidirectional line info. }; } // namespace Text @@ -179,4 +254,4 @@ public: } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H__ +#endif // DALI_TOOLKIT_TEXT_LOGICAL_MODEL_IMPL_H