26#include <rtl/textenc.h>
28#include <com/sun/star/i18n/ScriptType.hpp>
31#include <sfx2/sfxsids.hrc>
51const char sDialogImpExtraData[] =
"EncImpDlg:{";
52const char sDialogExpExtraData[] =
"EncExpDlg:{";
53const sal_Int32 nDialogExtraDataLen = 11;
59 :
SfxDialogController(pParent,
"modules/swriter/ui/asciifilterdialog.ui",
"AsciiFilterDialog")
60 , m_bSaveLineStatus(true)
62 , m_xFontFT(m_xBuilder->weld_label(
"fontft"))
63 , m_xFontLB(m_xBuilder->weld_combo_box(
"font"))
64 , m_xLanguageFT(m_xBuilder->weld_label(
"languageft"))
65 , m_xLanguageLB(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"language")))
66 , m_xCRLF_RB(m_xBuilder->weld_radio_button(
"crlf"))
67 , m_xCR_RB(m_xBuilder->weld_radio_button(
"cr"))
68 , m_xLF_RB(m_xBuilder->weld_radio_button(
"lf"))
69 , m_xIncludeBOM_CB(m_xBuilder->weld_check_button(
"includebom"))
78 css::uno::Any aUserItem = aDlgOpt.
GetUserItem(
"UserItem");
83 OUString sAsciiOptions;
90 const OUString sFindNm = OUString::createFromAscii(
91 pStream ? sDialogImpExtraData
92 : sDialogExpExtraData);
96 nStt += nDialogExtraDataLen;
97 sal_Int32 nEnd =
m_sExtraData.indexOf( cDialogExtraDataClose, nStt );
100 if(sAsciiOptions.isEmpty())
102 nStt -= nDialogExtraDataLen;
106 if(!sAsciiOptions.isEmpty())
114 const sal_uInt64 nOldPos = pStream->
Tell();
116 pStream->
Seek( nOldPos );
118 if( nBytesRead <= 4096 )
124 bool bCR =
false, bLF =
false, bNullChar =
false;
125 for( sal_uInt64 nCnt = 0; nCnt < nBytesRead; ++nCnt )
128 case 0x0: bNullChar =
true;
break;
129 case 0xA: bLF =
true;
break;
130 case 0xD: bCR =
true;
break;
173 switch(nAppScriptType)
175 case css::i18n::ScriptType::ASIAN:
178 case css::i18n::ScriptType::COMPLEX:
188 m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL,
true );
193 bool bDelPrinter =
false;
198 <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
199 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC>>( rDocSh.
GetPool() );
205 std::set< OUString > aFontNames;
206 int nFontNames = pPrt->GetFontFaceCollectionCount();
207 for(
int i = 0;
i < nFontNames;
i++ )
209 FontMetric aFontMetric( pPrt->GetFontMetricFromCollection(
i ) );
214 for(
const auto& rFontName : aFontNames )
249 m_xCharSetLB->FillFromTextEncodingTable( pStream !=
nullptr );
284 rOptions.
SetCharSet( rtl_TextEncoding( nCCode ) );
295 const OUString sFindNm = OUString::createFromAscii(
296 m_xFontLB->get_visible() ? sDialogImpExtraData
297 : sDialogExpExtraData);
302 sal_Int32 nEnd =
m_sExtraData.indexOf( cDialogExtraDataClose,
303 nStt + nDialogExtraDataLen );
307 m_sExtraData += sFindNm + sData + OUStringChar(cDialogExtraDataClose);
355 case RTL_TEXTENCODING_UTF8:
356 case RTL_TEXTENCODING_UCS2:
368 std::optional<LineEnd> eEnd;
370 ? m_xLanguageLB->get_active_id()
374 rtl_TextEncoding nChrSet = m_xCharSetLB->GetSelectTextEncoding();
375 if( nChrSet == osl_getThreadTextEncoding() )
381 case RTL_TEXTENCODING_MS_1252:
389 case RTL_TEXTENCODING_APPLE_ROMAN:
393 case RTL_TEXTENCODING_IBM_850:
397 case RTL_TEXTENCODING_APPLE_ARABIC:
398 case RTL_TEXTENCODING_APPLE_CENTEURO:
399 case RTL_TEXTENCODING_APPLE_CROATIAN:
400 case RTL_TEXTENCODING_APPLE_CYRILLIC:
401 case RTL_TEXTENCODING_APPLE_DEVANAGARI:
402 case RTL_TEXTENCODING_APPLE_FARSI:
403 case RTL_TEXTENCODING_APPLE_GREEK:
404 case RTL_TEXTENCODING_APPLE_GUJARATI:
405 case RTL_TEXTENCODING_APPLE_GURMUKHI:
406 case RTL_TEXTENCODING_APPLE_HEBREW:
407 case RTL_TEXTENCODING_APPLE_ICELAND:
408 case RTL_TEXTENCODING_APPLE_ROMANIAN:
409 case RTL_TEXTENCODING_APPLE_THAI:
410 case RTL_TEXTENCODING_APPLE_TURKISH:
411 case RTL_TEXTENCODING_APPLE_UKRAINIAN:
412 case RTL_TEXTENCODING_APPLE_CHINSIMP:
413 case RTL_TEXTENCODING_APPLE_CHINTRAD:
414 case RTL_TEXTENCODING_APPLE_JAPANESE:
415 case RTL_TEXTENCODING_APPLE_KOREAN:
421 m_bSaveLineStatus =
false;
424 if( eOldEnd != *eEnd )
430 m_xCRLF_RB->set_state(m_xCRLF_RB->get_saved_state());
431 m_xCR_RB->set_state(m_xCR_RB->get_saved_state());
432 m_xLF_RB->set_state(m_xLF_RB->get_saved_state());
434 m_bSaveLineStatus =
true;
436 if (nOldLng != nLng && m_xFontLB->get_visible())
437 m_xLanguageLB->set_active_id(nLng);
439 UpdateIncludeBOMSensitiveState();
444 if (m_bSaveLineStatus)
IMPL_LINK(SwAsciiFilterDlg, LineEndHdl, weld::Toggleable &, rBtn, void)
IMPL_LINK_NOARG(SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBox &, void)
Reference< XExecutableDialog > m_xDialog
const OUString & GetValue() const
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemSet & GetItemSet() const
SfxMedium * GetMedium() const
SfxItemPool & GetPool() const
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
void GetOptions(SvtLinguOptions &rOptions) const
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
SwAsciiFilterDlg(weld::Window *pParent, SwDocShell &rDocSh, SvStream *pStream)
std::unique_ptr< weld::Label > m_xFontFT
void SetCRLF(LineEnd eEnd)
std::unique_ptr< weld::Label > m_xLanguageFT
void UpdateIncludeBOMSensitiveState()
std::unique_ptr< weld::RadioButton > m_xCRLF_RB
void SetIncludeBOM(bool bIncludeBOM)
virtual ~SwAsciiFilterDlg() override
std::unique_ptr< weld::RadioButton > m_xLF_RB
std::unique_ptr< SvxTextEncodingBox > m_xCharSetLB
void FillOptions(SwAsciiOptions &rOptions)
bool GetIncludeBOM() const
std::unique_ptr< weld::CheckButton > m_xIncludeBOM_CB
std::unique_ptr< weld::ComboBox > m_xFontLB
std::unique_ptr< weld::RadioButton > m_xCR_RB
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
void WriteUserData(OUString &) const
void SetLanguage(LanguageType nVal)
void SetFontName(const OUString &rFont)
rtl_TextEncoding GetCharSet() const
LanguageType GetLanguage() const
LineEnd GetParaFlags() const
void SetIncludeBOM(bool bVal)
void SetParaFlags(LineEnd eVal)
const OUString & GetFontName() const
void SetCharSet(rtl_TextEncoding nVal)
bool GetIncludeBOM() const
void ReadUserData(std::u16string_view)
SwDoc * GetDoc()
returns Doc. But be careful!
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
static VclPtr< reference_type > Create(Arg &&... arg)
const OUString & GetFamilyName() const
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
LanguageType GetAppLanguage()
LineEnd GetSystemLineEnd()
#define LINK(Instance, Class, Member)
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
LanguageType nDefaultLanguage
LanguageType nDefaultLanguage_CTL
LanguageType nDefaultLanguage_CJK
std::unique_ptr< char[]> aBuffer