#ifndef UI_GFX_WIN_TEXT_ANALYSIS_SOURCE_H_
#define UI_GFX_WIN_TEXT_ANALYSIS_SOURCE_H_
#include <dwrite.h>
#include <wrl.h>
#include <string>
#include "base/component_export.h"
namespace gfx {
namespace win {
class TextAnalysisSource
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IDWriteTextAnalysisSource> {
public:
static COMPONENT_EXPORT(GFX) HRESULT
Create(IDWriteTextAnalysisSource** text_analysis_out,
const std::wstring& text,
const std::wstring& locale_name,
IDWriteNumberSubstitution* number_substitution,
DWRITE_READING_DIRECTION reading_direction);
TextAnalysisSource();
TextAnalysisSource& operator=(const TextAnalysisSource&) = delete;
HRESULT STDMETHODCALLTYPE GetLocaleName(UINT32 text_position,
UINT32* text_length,
const WCHAR** locale_name) override;
HRESULT STDMETHODCALLTYPE GetNumberSubstitution(
UINT32 text_position,
UINT32* text_length,
IDWriteNumberSubstitution** number_substitution) override;
DWRITE_READING_DIRECTION STDMETHODCALLTYPE
GetParagraphReadingDirection() override;
HRESULT STDMETHODCALLTYPE GetTextAtPosition(UINT32 text_position,
const WCHAR** text_string,
UINT32* text_length) override;
HRESULT STDMETHODCALLTYPE GetTextBeforePosition(UINT32 text_position,
const WCHAR** text_string,
UINT32* text_length) override;
HRESULT STDMETHODCALLTYPE
RuntimeClassInitialize(const std::wstring& text,
const std::wstring& locale_name,
IDWriteNumberSubstitution* number_substitution,
DWRITE_READING_DIRECTION reading_direction);
protected:
~TextAnalysisSource() override;
private:
std::wstring text_;
std::wstring locale_name_;
Microsoft::WRL::ComPtr<IDWriteNumberSubstitution> number_substitution_;
DWRITE_READING_DIRECTION reading_direction_;
};
}
}
#endif