summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-12 13:42:04 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-13 09:58:31 +0200
commit2b2fe50f33f7d677098f3ebafa8357aea848c0ea (patch)
treee0c57d555ae443ecb93b2219cc6dbf972debb595
parent34d362b5c249f78ed05c5b069fa90e9597d29c04 (diff)
weld SwAsciiFilterDlg and set an explicit parent for the dialog
Change-Id: Ie2a52a9e2ea7f41a336b227de670cd5f688d7cd4 Reviewed-on: https://gerrit.libreoffice.org/52778 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svx/langbox.hxx1
-rw-r--r--include/svx/txencbox.hxx70
-rw-r--r--svx/source/dialog/txencbox.cxx150
-rw-r--r--sw/inc/swabstdlg.hxx4
-rw-r--r--sw/source/ui/dialog/ascfldlg.cxx150
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx14
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx14
-rw-r--r--sw/source/uibase/inc/SwXFilterOptions.hxx7
-rw-r--r--sw/source/uibase/inc/ascfldlg.hxx32
-rw-r--r--sw/source/uibase/uno/SwXFilterOptions.cxx10
-rw-r--r--sw/uiconfig/swriter/ui/asciifilterdialog.ui71
-rw-r--r--uui/source/iahndl-filter.cxx15
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx2
13 files changed, 392 insertions, 148 deletions
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 45c852fd3cbd..b64f5d28fc3f 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -170,6 +170,7 @@ public:
void SelectEntryPos(int nPos) { m_xControl->set_active(nPos); }
void connect_changed(const Link<weld::ComboBoxText&, void>& rLink) { m_aChangeHdl = rLink; }
+ void hide() { m_xControl->hide(); }
};
class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
diff --git a/include/svx/txencbox.hxx b/include/svx/txencbox.hxx
index b9827c3cc841..41e761f6c6a4 100644
--- a/include/svx/txencbox.hxx
+++ b/include/svx/txencbox.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_SVX_TXENCBOX_HXX
#include <vcl/lstbox.hxx>
+#include <vcl/weld.hxx>
#include <rtl/textenc.h>
#include <svx/svxdllapi.h>
@@ -88,6 +89,75 @@ public:
rtl_TextEncoding GetSelectTextEncoding() const;
};
+class SVX_DLLPUBLIC TextEncodingBox
+{
+private:
+ std::unique_ptr<weld::ComboBoxText> m_xControl;
+
+public:
+ TextEncodingBox(weld::ComboBoxText* pControl);
+
+ ~TextEncodingBox();
+
+ /** Fill with all known encodings but exclude those matching one or more
+ given flags as defined in rtl/tencinfo.h
+
+ <p> If nButIncludeInfoFlags is given, encodings are included even if they
+ match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
+ Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
+ with RTL_TEXTENCODING_INFO_MIME </p>
+
+ @param bExcludeImportSubsets
+ If <TRUE/>, some specific encodings are not listed, as they are a
+ subset of another encoding. This is the case for
+ RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
+ RTL_TEXTENCODING_MS_936, which are covered by
+ RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
+ <TRUE/> whenever the box is used in import dialogs. */
+ void FillFromTextEncodingTable(
+ bool bExcludeImportSubsets,
+ sal_uInt32 nExcludeInfoFlags = 0,
+ sal_uInt32 nButIncludeInfoFlags = 0
+ );
+
+ /** Fill with all encodings known to the dbtools::OCharsetMap but exclude
+ those matching one or more given flags as defined in rtl/tencinfo.h
+
+ <p> If nButIncludeInfoFlags is given, encodings are included even if they
+ match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
+ Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
+ with RTL_TEXTENCODING_INFO_MIME </p>
+
+ @param bExcludeImportSubsets
+ If <TRUE/>, some specific encodings are not listed, as they are a
+ subset of another encoding. This is the case for
+ RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
+ RTL_TEXTENCODING_MS_936, which are covered by
+ RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
+ <TRUE/> whenever the box is used in import dialogs. */
+ void FillFromDbTextEncodingMap(
+ bool bExcludeImportSubsets,
+ sal_uInt32 nExcludeInfoFlags = 0
+ );
+
+ /** Fill with all known MIME encodings and select the best according to
+ <method>GetBestMimeEncoding</method>
+ */
+ void FillWithMimeAndSelectBest();
+
+ void InsertTextEncoding( const rtl_TextEncoding nEnc );
+
+ void InsertTextEncoding( const rtl_TextEncoding nEnc,
+ const OUString& rEntry );
+
+ void SelectTextEncoding( const rtl_TextEncoding nEnc );
+
+ rtl_TextEncoding GetSelectTextEncoding() const;
+
+ void connect_changed(const Link<weld::ComboBoxText&, void>& rLink) { m_xControl->connect_changed(rLink); }
+};
+
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/txencbox.cxx b/svx/source/dialog/txencbox.cxx
index 371e05f5f474..3dd0de769d4e 100644
--- a/svx/source/dialog/txencbox.cxx
+++ b/svx/source/dialog/txencbox.cxx
@@ -223,4 +223,154 @@ void SvxTextEncodingBox::SelectTextEncoding( const rtl_TextEncoding nEnc )
SelectEntryPos( nAt );
}
+TextEncodingBox::TextEncodingBox(weld::ComboBoxText* pControl)
+ : m_xControl(pControl)
+{
+}
+
+TextEncodingBox::~TextEncodingBox()
+{
+}
+
+void TextEncodingBox::FillFromTextEncodingTable(
+ bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags,
+ sal_uInt32 nButIncludeInfoFlags )
+{
+ rtl_TextEncodingInfo aInfo;
+ aInfo.StructSize = sizeof(rtl_TextEncodingInfo);
+ const sal_uInt32 nCount = SAL_N_ELEMENTS(RID_SVXSTR_TEXTENCODING_TABLE);
+ for (sal_uInt32 j = 0; j < nCount; ++j)
+ {
+ bool bInsert = true;
+ rtl_TextEncoding nEnc = RID_SVXSTR_TEXTENCODING_TABLE[j].second;
+ if ( nExcludeInfoFlags )
+ {
+ if ( !rtl_getTextEncodingInfo( nEnc, &aInfo ) )
+ bInsert = false;
+ else
+ {
+ if ( (aInfo.Flags & nExcludeInfoFlags) == 0 )
+ {
+ if ( (nExcludeInfoFlags & RTL_TEXTENCODING_INFO_UNICODE) &&
+ ((nEnc == RTL_TEXTENCODING_UCS2) ||
+ nEnc == RTL_TEXTENCODING_UCS4) )
+ bInsert = false; // InfoFlags don't work for Unicode :-(
+ }
+ else if ( (aInfo.Flags & nButIncludeInfoFlags) == 0 )
+ bInsert = false;
+ }
+ }
+ if ( bInsert )
+ {
+ if ( bExcludeImportSubsets )
+ {
+ switch ( nEnc )
+ {
+ // subsets of RTL_TEXTENCODING_GB_18030
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_MS_936 :
+ bInsert = false;
+ break;
+ }
+ }
+ if ( bInsert )
+ InsertTextEncoding(nEnc, SvxResId(RID_SVXSTR_TEXTENCODING_TABLE[j].first));
+ }
+ }
+}
+
+
+void TextEncodingBox::FillFromDbTextEncodingMap(
+ bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags )
+{
+#if !HAVE_FEATURE_DBCONNECTIVITY
+ (void)bExcludeImportSubsets;
+ (void)nExcludeInfoFlags;
+#else
+ rtl_TextEncodingInfo aInfo;
+ aInfo.StructSize = sizeof(rtl_TextEncodingInfo);
+ ::std::vector< rtl_TextEncoding > aEncs;
+ sal_Int32 nCount = svxform::charset_helper::getSupportedTextEncodings( aEncs );
+ for ( sal_Int32 j=0; j<nCount; j++ )
+ {
+ bool bInsert = true;
+ rtl_TextEncoding nEnc = rtl_TextEncoding( aEncs[j] );
+ if ( nExcludeInfoFlags )
+ {
+ if ( !rtl_getTextEncodingInfo( nEnc, &aInfo ) )
+ bInsert = false;
+ else
+ {
+ if ( (aInfo.Flags & nExcludeInfoFlags) == 0 )
+ {
+ if ( (nExcludeInfoFlags & RTL_TEXTENCODING_INFO_UNICODE) &&
+ ((nEnc == RTL_TEXTENCODING_UCS2) ||
+ nEnc == RTL_TEXTENCODING_UCS4) )
+ bInsert = false; // InfoFlags don't work for Unicode :-(
+ }
+ else
+ bInsert = false;
+ }
+ }
+ if ( bInsert )
+ {
+ if ( bExcludeImportSubsets )
+ {
+ switch ( nEnc )
+ {
+ // subsets of RTL_TEXTENCODING_GB_18030
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_MS_936 :
+ bInsert = false;
+ break;
+ }
+ }
+ // CharsetMap offers a RTL_TEXTENCODING_DONTKNOW for internal use,
+ // makes no sense here and would result in an empty string as list
+ // entry.
+ if ( bInsert && nEnc != RTL_TEXTENCODING_DONTKNOW )
+ InsertTextEncoding( nEnc );
+ }
+ }
+#endif
+}
+
+void TextEncodingBox::FillWithMimeAndSelectBest()
+{
+ FillFromTextEncodingTable( false, 0xffffffff, RTL_TEXTENCODING_INFO_MIME );
+ rtl_TextEncoding nEnc = SvtSysLocale::GetBestMimeEncoding();
+ SelectTextEncoding( nEnc );
+}
+
+void TextEncodingBox::InsertTextEncoding( const rtl_TextEncoding nEnc,
+ const OUString& rEntry )
+{
+ m_xControl->append(OUString::number(nEnc), rEntry);
+}
+
+void TextEncodingBox::InsertTextEncoding( const rtl_TextEncoding nEnc )
+{
+ const OUString& rEntry = SvxTextEncodingTable::GetTextString(nEnc);
+ if (!rEntry.isEmpty())
+ InsertTextEncoding( nEnc, rEntry );
+ else
+ SAL_WARN( "svx.dialog", "TextEncodingBox::InsertTextEncoding: no resource string for text encoding: " << static_cast<sal_Int32>( nEnc ) );
+}
+
+rtl_TextEncoding TextEncodingBox::GetSelectTextEncoding() const
+{
+ OUString sId(m_xControl->get_active_id());
+ if (!sId.isEmpty())
+ return rtl_TextEncoding(sId.toInt32());
+ else
+ return RTL_TEXTENCODING_DONTKNOW;
+}
+
+void TextEncodingBox::SelectTextEncoding( const rtl_TextEncoding nEnc )
+{
+ m_xControl->set_active_id(OUString::number(nEnc));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index c0e2484a4d75..953c5e0c8fd9 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -384,8 +384,8 @@ public:
virtual VclPtr<AbstractSwInsertAbstractDlg> CreateSwInsertAbstractDlg() = 0;
virtual VclPtr<SfxAbstractDialog> CreateSwAddressAbstractDlg(vcl::Window* pParent, const SfxItemSet& rSet) = 0;
- virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg ( SwDocShell& rDocSh,
- SvStream* pStream ) = 0;
+ virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh,
+ SvStream* pStream) = 0;
virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg( vcl::Window *pParent, SwWrtShell &rSh, SfxRequest& rReq ) = 0;
virtual VclPtr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) = 0;
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index b3cd4f6768c2..fb2a79760655 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -27,6 +27,7 @@
#include <i18nlangtag/mslangid.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <unotools/lingucfg.hxx>
+#include <unotools/viewoptions.hxx>
#include <fontcfg.hxx>
#include <swmodule.hxx>
#include <editeng/unolingu.hxx>
@@ -58,38 +59,43 @@ const sal_Int32 nDialogExtraDataLen = 11; // 12345678901
}
-SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
+SwAsciiFilterDlg::SwAsciiFilterDlg( weld::Window* pParent, SwDocShell& rDocSh,
SvStream* pStream )
- : SfxModalDialog(pParent, "AsciiFilterDialog", "modules/swriter/ui/asciifilterdialog.ui")
+ : GenericDialogController(pParent, "modules/swriter/ui/asciifilterdialog.ui", "AsciiFilterDialog")
, m_bSaveLineStatus(true)
+ , m_xCharSetLB(new TextEncodingBox(m_xBuilder->weld_combo_box_text("charset")))
+ , m_xFontFT(m_xBuilder->weld_label("fontft"))
+ , m_xFontLB(m_xBuilder->weld_combo_box_text("font"))
+ , m_xLanguageFT(m_xBuilder->weld_label("languageft"))
+ , m_xLanguageLB(new LanguageBox(m_xBuilder->weld_combo_box_text("language")))
+ , m_xCRLF_RB(m_xBuilder->weld_radio_button("crlf"))
+ , m_xCR_RB(m_xBuilder->weld_radio_button("cr"))
+ , m_xLF_RB(m_xBuilder->weld_radio_button("lf"))
{
- get(m_pCharSetLB, "charset");
- m_pCharSetLB->SetStyle(m_pCharSetLB->GetStyle() | WB_SORT);
- get(m_pFontFT, "fontft");
- get(m_pFontLB, "font");
- m_pFontLB->SetStyle(m_pFontLB->GetStyle() | WB_SORT);
- get(m_pLanguageFT, "languageft");
- get(m_pLanguageLB, "language");
- m_pLanguageLB->SetStyle(m_pLanguageLB->GetStyle() | WB_SORT);
- get(m_pCRLF_RB, "crlf");
- get(m_pCR_RB, "cr");
- get(m_pLF_RB, "lf");
+ m_xFontLB->make_sorted();
SwAsciiOptions aOpt;
{
+ SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+ if (aDlgOpt.Exists())
+ {
+ css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem");
+ aUserItem >>= m_sExtraData;
+ }
+
const OUString sFindNm = OUString::createFromAscii(
pStream ? sDialogImpExtraData
: sDialogExpExtraData);
- sal_Int32 nEnd, nStt = GetExtraData().indexOf( sFindNm );
+ sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm );
if( -1 != nStt )
{
nStt += nDialogExtraDataLen;
- nEnd = GetExtraData().indexOf( cDialogExtraDataClose, nStt );
+ nEnd = m_sExtraData.indexOf( cDialogExtraDataClose, nStt );
if( -1 != nEnd )
{
- aOpt.ReadUserData( GetExtraData().copy( nStt, nEnd - nStt ));
+ aOpt.ReadUserData(m_sExtraData.copy(nStt, nEnd - nStt));
nStt -= nDialogExtraDataLen;
- GetExtraData() = GetExtraData().replaceAt( nStt, nEnd - nStt + 1, "" );
+ m_sExtraData = m_sExtraData.replaceAt(nStt, nEnd - nStt + 1, "");
}
}
}
@@ -172,8 +178,8 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
}
}
- m_pLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, true );
- m_pLanguageLB->SelectLanguage( aOpt.GetLanguage() );
+ m_xLanguageLB->SetLanguageList( SvxLanguageListFlags::ALL, true );
+ m_xLanguageLB->SelectLanguage( aOpt.GetLanguage() );
}
{
@@ -201,7 +207,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
for( std::set< OUString >::const_iterator it = aFontNames.begin();
it != aFontNames.end(); ++it )
{
- m_pFontLB->InsertEntry( *it );
+ m_xFontLB->append_text(*it);
}
if( aOpt.GetFontName().isEmpty() )
@@ -211,7 +217,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
aOpt.SetFontName(aTmpFont.GetFamilyName());
}
- m_pFontLB->SelectEntry( aOpt.GetFontName() );
+ m_xFontLB->set_active(aOpt.GetFontName());
if( bDelPrinter )
pPrt.disposeAndClear();
@@ -221,56 +227,41 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
else
{
// hide the unused Controls for Export
- m_pFontFT->Hide();
- m_pFontLB->Hide();
- m_pLanguageFT->Hide();
- m_pLanguageLB->Hide();
+ m_xFontFT->hide();
+ m_xFontLB->hide();
+ m_xLanguageFT->hide();
+ m_xLanguageLB->hide();
}
// initialize character set
- m_pCharSetLB->FillFromTextEncodingTable( pStream != nullptr );
- m_pCharSetLB->SelectTextEncoding( aOpt.GetCharSet() );
+ m_xCharSetLB->FillFromTextEncodingTable( pStream != nullptr );
+ m_xCharSetLB->SelectTextEncoding( aOpt.GetCharSet() );
- m_pCharSetLB->SetSelectHdl( LINK( this, SwAsciiFilterDlg, CharSetSelHdl ));
- m_pCRLF_RB->SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
- m_pLF_RB->SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
- m_pCR_RB->SetToggleHdl( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
+ m_xCharSetLB->connect_changed( LINK( this, SwAsciiFilterDlg, CharSetSelHdl ));
+ m_xCRLF_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
+ m_xLF_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
+ m_xCR_RB->connect_toggled( LINK( this, SwAsciiFilterDlg, LineEndHdl ));
SetCRLF( aOpt.GetParaFlags() );
- m_pCRLF_RB->SaveValue();
- m_pLF_RB->SaveValue();
- m_pCR_RB->SaveValue();
+ m_xCRLF_RB->save_state();
+ m_xLF_RB->save_state();
+ m_xCR_RB->save_state();
}
SwAsciiFilterDlg::~SwAsciiFilterDlg()
{
- disposeOnce();
-}
-
-void SwAsciiFilterDlg::dispose()
-{
- m_pCharSetLB.clear();
- m_pFontFT.clear();
- m_pFontLB.clear();
- m_pLanguageFT.clear();
- m_pLanguageLB.clear();
- m_pCRLF_RB.clear();
- m_pCR_RB.clear();
- m_pLF_RB.clear();
- SfxModalDialog::dispose();
}
-
void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions )
{
- sal_uLong nCCode = m_pCharSetLB->GetSelectTextEncoding();
+ sal_uLong nCCode = m_xCharSetLB->GetSelectTextEncoding();
OUString sFont;
LanguageType nLng = LANGUAGE_SYSTEM;
- if( m_pFontLB->IsVisible() )
+ if (m_xFontLB->get_visible())
{
- sFont = m_pFontLB->GetSelectedEntry();
- nLng = m_pLanguageLB->GetSelectedLanguage();
+ sFont = m_xFontLB->get_active_text();
+ nLng = m_xLanguageLB->GetSelectedLanguage();
}
rOptions.SetFontName( sFont );
@@ -284,53 +275,58 @@ void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions )
if (!sData.isEmpty())
{
const OUString sFindNm = OUString::createFromAscii(
- m_pFontLB->IsVisible() ? sDialogImpExtraData
+ m_xFontLB->get_visible() ? sDialogImpExtraData
: sDialogExpExtraData);
- sal_Int32 nEnd, nStt = GetExtraData().indexOf( sFindNm );
+ sal_Int32 nEnd, nStt = m_sExtraData.indexOf( sFindNm );
if( -1 != nStt )
{
// called twice, so remove "old" settings
- nEnd = GetExtraData().indexOf( cDialogExtraDataClose,
+ nEnd = m_sExtraData.indexOf( cDialogExtraDataClose,
nStt + nDialogExtraDataLen );
if( -1 != nEnd )
- GetExtraData() = GetExtraData().replaceAt( nStt, nEnd - nStt + 1, "" );
+ m_sExtraData = m_sExtraData.replaceAt( nStt, nEnd - nStt + 1, "" );
}
- GetExtraData() += sFindNm + sData + OUStringLiteral1(cDialogExtraDataClose);
+ m_sExtraData += sFindNm + sData + OUStringLiteral1(cDialogExtraDataClose);
}
}
void SwAsciiFilterDlg::SetCRLF( LineEnd eEnd )
{
- switch( eEnd )
+ switch (eEnd)
{
- case LINEEND_CR: m_pCR_RB->Check(); break;
- case LINEEND_CRLF: m_pCRLF_RB->Check(); break;
- case LINEEND_LF: m_pLF_RB->Check(); break;
+ case LINEEND_CR:
+ m_xCR_RB->set_active(true);
+ break;
+ case LINEEND_CRLF:
+ m_xCRLF_RB->set_active(true);
+ break;
+ case LINEEND_LF:
+ m_xLF_RB->set_active(true);
+ break;
}
}
LineEnd SwAsciiFilterDlg::GetCRLF() const
{
LineEnd eEnd;
- if( m_pCR_RB->IsChecked() )
+ if(m_xCR_RB->get_active())
eEnd = LINEEND_CR;
- else if( m_pLF_RB->IsChecked() )
+ else if (m_xLF_RB->get_active())
eEnd = LINEEND_LF;
else
eEnd = LINEEND_CRLF;
return eEnd;
}
-IMPL_LINK( SwAsciiFilterDlg, CharSetSelHdl, ListBox&, rListBox, void )
+IMPL_LINK_NOARG( SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBoxText&, void )
{
- SvxTextEncodingBox* pBox = static_cast<SvxTextEncodingBox*>(&rListBox);
LineEnd eOldEnd = GetCRLF(), eEnd = LineEnd(-1);
- LanguageType nLng = m_pFontLB->IsVisible()
- ? m_pLanguageLB->GetSelectedLanguage()
+ LanguageType nLng = m_xFontLB->get_visible()
+ ? m_xLanguageLB->GetSelectedLanguage()
: LANGUAGE_SYSTEM,
nOldLng = nLng;
- rtl_TextEncoding nChrSet = pBox->GetSelectTextEncoding();
+ rtl_TextEncoding nChrSet = m_xCharSetLB->GetSelectTextEncoding();
if( nChrSet == osl_getThreadTextEncoding() )
eEnd = GetSystemLineEnd();
else
@@ -386,20 +382,20 @@ IMPL_LINK( SwAsciiFilterDlg, CharSetSelHdl, ListBox&, rListBox, void )
else
{
// restore old user choice (not the automatic!)
- m_pCRLF_RB->Check( m_pCRLF_RB->GetSavedValue() );
- m_pCR_RB->Check( m_pCR_RB->GetSavedValue() );
- m_pLF_RB->Check( m_pLF_RB->GetSavedValue() );
+ m_xCRLF_RB->set_state(m_xCRLF_RB->get_saved_state());
+ m_xCR_RB->set_state(m_xCR_RB->get_saved_state());
+ m_xLF_RB->set_state(m_xLF_RB->get_saved_state());
}
m_bSaveLineStatus = true;
- if( nOldLng != nLng && m_pFontLB->IsVisible() )
- m_pLanguageLB->SelectLanguage( nLng );
+ if (nOldLng != nLng && m_xFontLB->get_visible())
+ m_xLanguageLB->SelectLanguage( nLng );
}
-IMPL_LINK( SwAsciiFilterDlg, LineEndHdl, RadioButton&, rBtn, void )
+IMPL_LINK(SwAsciiFilterDlg, LineEndHdl, weld::ToggleButton&, rBtn, void)
{
- if( m_bSaveLineStatus )
- rBtn.SaveValue();
+ if (m_bSaveLineStatus)
+ rBtn.save_state();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index e43e26335de8..7bf0470ac939 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -92,7 +92,10 @@ using namespace css::uno;
IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSwInsertAbstractDlg_Impl);
IMPL_ABSTDLG_BASE(SwAbstractSfxDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractSwAsciiFilterDlg_Impl);
+short AbstractSwAsciiFilterDlg_Impl::Execute()
+{
+ return m_xDlg->run();
+}
IMPL_ABSTDLG_BASE(VclAbstractDialog_Impl);
short AbstractSplitTableDialog_Impl::Execute()
{
@@ -227,7 +230,7 @@ void SwAbstractSfxDialog_Impl::SetText( const OUString& rStr )
void AbstractSwAsciiFilterDlg_Impl::FillOptions( SwAsciiOptions& rOptions )
{
- pDlg->FillOptions(rOptions);
+ m_xDlg->FillOptions(rOptions);
}
SplitTable_HeadlineOption AbstractSplitTableDialog_Impl::GetSplitMode()
@@ -705,11 +708,10 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateNumFormatDialog( v
return VclPtr<SwAbstractSfxDialog_Impl>::Create( pDlg );
}
-VclPtr<AbstractSwAsciiFilterDlg> SwAbstractDialogFactory_Impl::CreateSwAsciiFilterDlg( SwDocShell& rDocSh,
- SvStream* pStream )
+VclPtr<AbstractSwAsciiFilterDlg> SwAbstractDialogFactory_Impl::CreateSwAsciiFilterDlg(weld::Window* pParent,
+ SwDocShell& rDocSh, SvStream* pStream)
{
- VclPtr<SwAsciiFilterDlg> pDlg = VclPtr<SwAsciiFilterDlg>::Create( nullptr, rDocSh, pStream );
- return VclPtr<AbstractSwAsciiFilterDlg_Impl>::Create( pDlg );
+ return VclPtr<AbstractSwAsciiFilterDlg_Impl>::Create(new SwAsciiFilterDlg(pParent, rDocSh, pStream));
}
VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwInsertBookmarkDlg( vcl::Window *pParent,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index a10c4845fde0..a2ec8568c22b 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -96,9 +96,15 @@ class SwAbstractSfxDialog_Impl :public SfxAbstractDialog
class AbstractSwAsciiFilterDlg_Impl : public AbstractSwAsciiFilterDlg
{
- DECL_ABSTDLG_BASE( AbstractSwAsciiFilterDlg_Impl,SwAsciiFilterDlg )
+protected:
+ std::unique_ptr<SwAsciiFilterDlg> m_xDlg;
+public:
+ explicit AbstractSwAsciiFilterDlg_Impl(SwAsciiFilterDlg* p)
+ : m_xDlg(p)
+ {
+ }
+ virtual short Execute() override;
virtual void FillOptions( SwAsciiOptions& rOptions ) override;
-
};
class VclAbstractDialog_Impl : public VclAbstractDialog
@@ -500,8 +506,8 @@ public:
SfxChildWindow* pChild, vcl::Window *pParent, SfxChildWinInfo* pInfo) override;
virtual VclPtr<AbstractSwInsertAbstractDlg> CreateSwInsertAbstractDlg() override;
virtual VclPtr<SfxAbstractDialog> CreateSwAddressAbstractDlg(vcl::Window* pParent, const SfxItemSet& rSet) override;
- virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg ( SwDocShell& rDocSh,
- SvStream* pStream ) override;
+ virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh,
+ SvStream* pStream) override;
virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg( vcl::Window *pParent, SwWrtShell &rSh, SfxRequest& rReq ) override;
virtual VclPtr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) override;
virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) override;
diff --git a/sw/source/uibase/inc/SwXFilterOptions.hxx b/sw/source/uibase/inc/SwXFilterOptions.hxx
index ebf36a5aa885..85539e391ff7 100644
--- a/sw/source/uibase/inc/SwXFilterOptions.hxx
+++ b/sw/source/uibase/inc/SwXFilterOptions.hxx
@@ -19,10 +19,12 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWXFILTEROPTIONS_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_SWXFILTEROPTIONS_HXX
+#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
@@ -35,12 +37,14 @@ class SwXFilterOptions : public ::cppu::WeakImplHelper<
css::ui::dialogs::XExecutableDialog,
css::document::XImporter,
css::document::XExporter,
+ css::lang::XInitialization,
css::lang::XServiceInfo >
{
OUString sFilterOptions;
css::uno::Reference< css::io::XInputStream > xInputStream;
css::uno::Reference< css::lang::XComponent > xModel;
+ css::uno::Reference< css::awt::XWindow > xDialogParent;
public:
SwXFilterOptions();
@@ -64,6 +68,9 @@ public:
virtual void SAL_CALL setSourceDocument( const css::uno::Reference<
css::lang::XComponent >& xDoc ) override;
+ // XInitialization
+ virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override;
+
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
diff --git a/sw/source/uibase/inc/ascfldlg.hxx b/sw/source/uibase/inc/ascfldlg.hxx
index 99fbba32833f..81c75663fd6c 100644
--- a/sw/source/uibase/inc/ascfldlg.hxx
+++ b/sw/source/uibase/inc/ascfldlg.hxx
@@ -30,30 +30,30 @@ class SwAsciiOptions;
class SvStream;
class SwDocShell;
-class SwAsciiFilterDlg : public SfxModalDialog
+class SwAsciiFilterDlg : public weld::GenericDialogController
{
- VclPtr<SvxTextEncodingBox> m_pCharSetLB;
- VclPtr<FixedText> m_pFontFT;
- VclPtr<ListBox> m_pFontLB;
- VclPtr<FixedText> m_pLanguageFT;
- VclPtr<SvxLanguageBox> m_pLanguageLB;
- VclPtr<RadioButton> m_pCRLF_RB;
- VclPtr<RadioButton> m_pCR_RB;
- VclPtr<RadioButton> m_pLF_RB;
- bool m_bSaveLineStatus;
-
- DECL_LINK( CharSetSelHdl, ListBox&, void );
- DECL_LINK( LineEndHdl, RadioButton&, void );
+ bool m_bSaveLineStatus;
+ OUString m_sExtraData;
+
+ std::unique_ptr<TextEncodingBox> m_xCharSetLB;
+ std::unique_ptr<weld::Label> m_xFontFT;
+ std::unique_ptr<weld::ComboBoxText> m_xFontLB;
+ std::unique_ptr<weld::Label> m_xLanguageFT;
+ std::unique_ptr<LanguageBox> m_xLanguageLB;
+ std::unique_ptr<weld::RadioButton> m_xCRLF_RB;
+ std::unique_ptr<weld::RadioButton> m_xCR_RB;
+ std::unique_ptr<weld::RadioButton> m_xLF_RB;
+
+ DECL_LINK(CharSetSelHdl, weld::ComboBoxText&, void);
+ DECL_LINK(LineEndHdl, weld::ToggleButton&, void);
void SetCRLF( LineEnd eEnd );
LineEnd GetCRLF() const;
public:
// CTOR: for import - pStream is the inputstream
// for export - pStream must be 0
- SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
- SvStream* pStream );
+ SwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh, SvStream* pStream);
virtual ~SwAsciiFilterDlg() override;
- virtual void dispose() override;
void FillOptions( SwAsciiOptions& rOptions );
};
diff --git a/sw/source/uibase/uno/SwXFilterOptions.cxx b/sw/source/uibase/uno/SwXFilterOptions.cxx
index df404103e7e4..5a3dab86c7d5 100644
--- a/sw/source/uibase/uno/SwXFilterOptions.cxx
+++ b/sw/source/uibase/uno/SwXFilterOptions.cxx
@@ -24,6 +24,7 @@
#include <vcl/svapp.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -96,7 +97,7 @@ sal_Int16 SwXFilterOptions::execute()
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- ScopedVclPtr<AbstractSwAsciiFilterDlg> pAsciiDlg(pFact->CreateSwAsciiFilterDlg(*pDocShell,
+ ScopedVclPtr<AbstractSwAsciiFilterDlg> pAsciiDlg(pFact->CreateSwAsciiFilterDlg(Application::GetFrameWeld(xDialogParent), *pDocShell,
pInStream.get()));
OSL_ENSURE(pAsciiDlg, "Dialog creation failed!");
if(RET_OK == pAsciiDlg->Execute())
@@ -121,6 +122,13 @@ void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& x
xModel = xDoc;
}
+void SAL_CALL SwXFilterOptions::initialize(const uno::Sequence<uno::Any>& rArguments)
+{
+ ::comphelper::NamedValueCollection aProperties(rArguments);
+ if (aProperties.has("ParentWindow"))
+ aProperties.get("ParentWindow") >>= xDialogParent;
+}
+
OUString SwXFilterOptions::getImplementationName()
{
return OUString("com.sun.star.comp.Writer.FilterOptionsDialog");
diff --git a/sw/uiconfig/swriter/ui/asciifilterdialog.ui b/sw/uiconfig/swriter/ui/asciifilterdialog.ui
index 3090754c94e6..6bd8f08c3820 100644
--- a/sw/uiconfig/swriter/ui/asciifilterdialog.ui
+++ b/sw/uiconfig/swriter/ui/asciifilterdialog.ui
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
- <!-- interface-requires gtk+ 3.0 -->
- <!-- interface-requires LibreOffice 1.0 -->
+ <requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="AsciiFilterDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="asciifilterdialog|AsciiFilterDialog">ASCII Filter Options</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -58,6 +61,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
+ <property name="secondary">True</property>
</packing>
</child>
</object>
@@ -93,67 +97,59 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="asciifilterdialog|label2">_Character set</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">charset</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="fontft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="asciifilterdialog|fontft">Default fonts</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">font</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="languageft">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="asciifilterdialog|languageft">Lan_guage</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">language</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="asciifilterdialog|label5">_Paragraph break</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="svxlo-SvxTextEncodingBox" id="charset">
+ <object class="GtkComboBoxText" id="charset">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -161,8 +157,6 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -170,27 +164,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="svxcorelo-SvxLanguageBox" id="language">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -209,7 +186,6 @@
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">cr</property>
</object>
<packing>
<property name="expand">False</property>
@@ -227,7 +203,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
- <property name="group">lf</property>
+ <property name="group">crlf</property>
</object>
<packing>
<property name="expand">False</property>
@@ -257,8 +233,24 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="language">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry">
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
</object>
@@ -289,5 +281,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>
diff --git a/uui/source/iahndl-filter.cxx b/uui/source/iahndl-filter.cxx
index 421ce727592e..38c98375f3e5 100644
--- a/uui/source/iahndl-filter.cxx
+++ b/uui/source/iahndl-filter.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/task/XInteractionRequest.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <vcl/svapp.hxx>
@@ -178,6 +179,7 @@ handleNoSuchFilterRequest_(
void
handleFilterOptionsRequest_(
+ uno::Reference<awt::XWindow> const & rWindow,
uno::Reference< uno::XComponentContext > const & xContext,
document::FilterOptionsRequest const & rRequest,
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
@@ -226,11 +228,17 @@ handleFilterOptionsRequest_(
aProps[nProperty].Value >>= aServiceName;
if( !aServiceName.isEmpty() )
{
+ uno::Sequence<uno::Any> aDialogArgs(comphelper::InitAnyPropertySequence(
+ {
+ {"ParentWindow", uno::Any(rWindow)},
+ }));
+
uno::Reference<
ui::dialogs::XExecutableDialog > xFilterDialog(
- xContext->getServiceManager()->createInstanceWithContext(
- aServiceName, xContext ),
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ aServiceName, aDialogArgs, xContext ),
uno::UNO_QUERY );
+
uno::Reference< beans::XPropertyAccess >
xFilterProperties( xFilterDialog,
uno::UNO_QUERY );
@@ -302,7 +310,8 @@ UUIInteractionHelper::handleFilterOptionsRequest(
document::FilterOptionsRequest aFilterOptionsRequest;
if (aAnyRequest >>= aFilterOptionsRequest)
{
- handleFilterOptionsRequest_(m_xContext,
+ handleFilterOptionsRequest_(getParentXWindow(),
+ m_xContext,
aFilterOptionsRequest,
rRequest->getContinuations());
return true;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index ca434d294bff..957b58fcc083 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4281,7 +4281,7 @@ weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWin
{
if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(rWindow.get()))
return pGtkXWindow->getFrameWeld();
- return nullptr;
+ return SalInstance::GetFrameWeld(rWindow);
}
weld::Window* GtkSalFrame::GetFrameWeld() const