[Libreoffice-commits] core.git: 5 commits - cui/source cui/uiconfig include/svtools include/svx svtools/source svx/source
Eike Rathke
erack at redhat.com
Thu May 22 10:37:06 PDT 2014
cui/source/inc/chardlg.hxx | 2
cui/source/tabpages/chardlg.cxx | 24 ++++++++++
cui/uiconfig/ui/charnamepage.ui | 4 -
include/svtools/langtab.hxx | 1
include/svx/langbox.hxx | 16 ++++++-
svtools/source/misc/langtab.cxx | 14 ++++++
svx/source/dialog/langbox.cxx | 90 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 147 insertions(+), 4 deletions(-)
New commits:
commit fe2b8ef18b11b226fddd1cf3fc7f9133426a1b1a
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 22 19:23:14 2014 +0200
advance start of edit selection on a matching entry
... to allow continuous typing.
Change-Id: I4717e72e422037a441e582004bc87689ea7bc455
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 77ec154..028e33d 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -711,7 +711,24 @@ IMPL_LINK( SvxLanguageComboBox, EditModifyHdl, SvxLanguageComboBox*, /*pEd*/ )
{
const sal_Int32 nPos = GetEntryPos( aStr);
if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ {
+ // Advance start of full selection by one so the next character
+ // will already continue the string instead of having to type the
+ // same character again to start a new string. The selection
+ // includes formatting characters and is reverse when obtained from
+ // the Edit control.
+ Selection aSel( GetSelection());
+ if (aSel.Max() == 1)
+ {
+ OUString aText( GetText());
+ if (aSel.Min() == aText.getLength())
+ {
+ ++aSel.Max();
+ SetSelection( aSel);
+ }
+ }
meEditedAndValid = EDITED_NO;
+ }
else
{
OUString aCanonicalized;
commit dbe8b3b6d4f2d2cc2e8c702b78034e9013f71e8f
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 22 16:31:09 2014 +0200
finally switch the Western language list box to SvxLanguageComboBox
Change-Id: Ibf0cb4c0fa951adcd0a7f185d7dd45b06913a40d
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index d90c2cb..69b46c8 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -86,7 +86,7 @@ private:
FixedText* m_pWestFontSizeFT;
FontSizeBox* m_pWestFontSizeLB;
FixedText* m_pWestFontLanguageFT;
- SvxLanguageBox* m_pWestFontLanguageLB;
+ SvxLanguageComboBox* m_pWestFontLanguageLB;
FixedText* m_pWestFontTypeFT;
VclContainer* m_pEastFrame;
diff --git a/cui/uiconfig/ui/charnamepage.ui b/cui/uiconfig/ui/charnamepage.ui
index 25c67f1..6205dfd 100644
--- a/cui/uiconfig/ui/charnamepage.ui
+++ b/cui/uiconfig/ui/charnamepage.ui
@@ -54,7 +54,7 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxLanguageBox" id="westlanglb-nocjk">
+ <object class="svxcorelo-SvxLanguageComboBox" id="westlanglb-nocjk">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
@@ -342,7 +342,7 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxLanguageBox" id="westlanglb-cjk">
+ <object class="svxcorelo-SvxLanguageComboBox" id="westlanglb-cjk">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
commit 1aad7628dcd7fd14d48814d00c3d04e4ec0c59d5
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 22 16:30:11 2014 +0200
handle SvxLanguageComboBox edit
Change-Id: Icc2a4829b8a859756ed194f35df214f8bb55c7ae
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 1f0e58560..f36ae8e 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1086,6 +1086,30 @@ bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp
}
nWhich = GetWhich( nSlot );
pOld = GetOldItem( rSet, nSlot );
+
+ // For language list boxes acting as ComboBox, check for, add and select an
+ // edited entry.
+ SvxLanguageComboBox* pLangComboBox = dynamic_cast<SvxLanguageComboBox*>(pLangBox);
+ if (pLangComboBox)
+ {
+ switch (pLangComboBox->GetEditedAndValid())
+ {
+ case SvxLanguageComboBox::EDITED_NO:
+ ; // nothing to do
+ break;
+ case SvxLanguageComboBox::EDITED_VALID:
+ {
+ const sal_Int32 nPos = pLangComboBox->SaveEditedAsEntry();
+ if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ pLangComboBox->SelectEntryPos( nPos);
+ }
+ break;
+ case SvxLanguageComboBox::EDITED_INVALID:
+ pLangComboBox->SelectEntryPos( pLangComboBox->GetSavedValueLBB());
+ break;
+ }
+ }
+
sal_Int32 nLangPos = pLangBox->GetSelectEntryPosLBB();
LanguageType eLangType = (LanguageType)(sal_uLong)pLangBox->GetEntryDataLBB( nLangPos );
commit 29c024afbe6a46459e37c5ceec510de1cd0ca7c8
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 22 16:15:37 2014 +0200
+ SvxLanguageComboBox EditModifyHdl(), SaveEditedAsEntry()
Change-Id: I6acc7538fcbf8aa7a5e50ba72b27409252cffa15
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 410b240..91b788c 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -144,8 +144,20 @@ public:
SvxLanguageComboBox( Window* pParent, WinBits nBits, bool bCheck = false );
virtual ~SvxLanguageComboBox();
+ enum EditedAndValid
+ {
+ EDITED_NO,
+ EDITED_VALID,
+ EDITED_INVALID
+ };
+
+ EditedAndValid GetEditedAndValid() const;
+ sal_Int32 SaveEditedAsEntry();
+
+
private:
- sal_Int32 mnSavedValuePos;
+ sal_Int32 mnSavedValuePos;
+ EditedAndValid meEditedAndValid;
SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) SAL_OVERRIDE;
SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) SAL_OVERRIDE;
@@ -164,6 +176,8 @@ private:
SVX_DLLPRIVATE virtual void ImplDisable() SAL_OVERRIDE;
SVX_DLLPRIVATE virtual void ImplSaveValue() SAL_OVERRIDE;
SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const SAL_OVERRIDE;
+
+ DECL_LINK( EditModifyHdl, SvxLanguageComboBox* );
};
#endif
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 92f5cb6..77ec154 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -33,6 +33,7 @@
#include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc>
#include <vcl/builder.hxx>
+#include <vcl/i18nhelp.hxx>
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
@@ -507,6 +508,7 @@ SvxLanguageComboBox::SvxLanguageComboBox( Window* pParent, WinBits nBits, bool b
: ComboBox( pParent, nBits )
, SvxLanguageBoxBase( bCheck )
, mnSavedValuePos( COMBOBOX_ENTRY_NOTFOUND )
+ , meEditedAndValid( EDITED_NO )
{
// display entries sorted
SetStyle( GetStyle() | WB_SORT );
@@ -514,6 +516,8 @@ SvxLanguageComboBox::SvxLanguageComboBox( Window* pParent, WinBits nBits, bool b
EnableMultiSelection( false );
ImplLanguageBoxBaseInit();
+
+ SetModifyHdl( LINK( this, SvxLanguageComboBox, EditModifyHdl ) );
}
SvxLanguageComboBox::~SvxLanguageComboBox()
@@ -698,4 +702,73 @@ sal_Int32 SvxLanguageComboBox::ImplGetSavedValue() const
}
+IMPL_LINK( SvxLanguageComboBox, EditModifyHdl, SvxLanguageComboBox*, /*pEd*/ )
+{
+ OUString aStr( vcl::I18nHelper::filterFormattingChars( GetText()));
+ if (aStr.isEmpty())
+ meEditedAndValid = EDITED_INVALID;
+ else
+ {
+ const sal_Int32 nPos = GetEntryPos( aStr);
+ if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ meEditedAndValid = EDITED_NO;
+ else
+ {
+ OUString aCanonicalized;
+ bool bValid = LanguageTag::isValidBcp47( aStr, &aCanonicalized);
+ meEditedAndValid = (bValid ? EDITED_VALID : EDITED_INVALID);
+ if (bValid && aCanonicalized != aStr)
+ {
+ SetText( aCanonicalized);
+ SetSelection( Selection( aCanonicalized.getLength()));
+ }
+ }
+ }
+ return 0;
+}
+
+
+SvxLanguageComboBox::EditedAndValid SvxLanguageComboBox::GetEditedAndValid() const
+{
+ return meEditedAndValid;
+}
+
+
+sal_Int32 SvxLanguageComboBox::SaveEditedAsEntry()
+{
+ if (meEditedAndValid != EDITED_VALID)
+ return COMBOBOX_ENTRY_NOTFOUND;
+
+ LanguageTag aLanguageTag( vcl::I18nHelper::filterFormattingChars( GetText()));
+ LanguageType nLang = aLanguageTag.getLanguageType();
+ if (nLang == LANGUAGE_DONTKNOW)
+ {
+ SAL_WARN( "svx.dialog", "SvxLanguageComboBox::SaveEditedAsEntry: unknown tag");
+ return COMBOBOX_ENTRY_NOTFOUND;
+ }
+
+ sal_Int32 nPos = ImplTypeToPos( nLang);
+ if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ return nPos; // Already present but with a different string.
+
+ if (SvtLanguageTable::HasLanguageType( nLang))
+ {
+ // In SvtLanguageTable but not in SvxLanguageComboBox. On purpose? This
+ // may be an entry with different settings or CTL instead of Western or
+ // ... all things we don't handle yet.
+ SAL_WARN( "svx.dialog", "SvxLanguageComboBox::SaveEditedAsEntry: already in SvtLanguageTable: " <<
+ SvtLanguageTable::GetLanguageString( nLang) << ", " << nLang);
+ }
+ else
+ {
+ // Add to both, SvtLanguageTable and SvxLanguageComboBox.
+ /* TODO: a descriptive user comment would be a nice to have here. */
+ SvtLanguageTable::AddLanguageTag( aLanguageTag, OUString());
+ }
+
+ nPos = InsertLanguage( nLang);
+
+ return nPos;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2a8eff589a53c8dd65e18d7a9d11cdb98a937e68
Author: Eike Rathke <erack at redhat.com>
Date: Thu May 22 12:28:02 2014 +0200
+bool SvtLanguageTable::HasLanguageType()
Change-Id: Id57eb51b69e50be78f85d19a7b3623c1acdf6509
diff --git a/include/svtools/langtab.hxx b/include/svtools/langtab.hxx
index 0034873..56d0618 100644
--- a/include/svtools/langtab.hxx
+++ b/include/svtools/langtab.hxx
@@ -29,6 +29,7 @@ class SVT_DLLPUBLIC SvtLanguageTable
{
public:
+ static bool HasLanguageType( const LanguageType eType );
static OUString GetLanguageString( const LanguageType eType );
static LanguageType GetLanguageType( const OUString& rStr );
static sal_uInt32 GetLanguageEntryCount();
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx
index b8eeec0..3cd6b93 100644
--- a/svtools/source/misc/langtab.cxx
+++ b/svtools/source/misc/langtab.cxx
@@ -43,6 +43,7 @@ public:
SvtLanguageTableImpl();
virtual ~SvtLanguageTableImpl();
+ bool HasType( const LanguageType eType ) const;
const OUString GetString( const LanguageType eType, bool bUserInterfaceSelection = false ) const;
LanguageType GetType( const OUString& rStr ) const;
sal_uInt32 GetEntryCount() const;
@@ -148,6 +149,19 @@ SvtLanguageTableImpl::~SvtLanguageTableImpl()
}
+bool SvtLanguageTableImpl::HasType( const LanguageType eType ) const
+{
+ LanguageType eLang = MsLangId::getReplacementForObsoleteLanguage( eType, false);
+ sal_uInt32 nPos = FindIndex( eLang );
+
+ return RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count();
+}
+
+bool SvtLanguageTable::HasLanguageType( const LanguageType eType )
+{
+ return theLanguageTable::get().HasType( eType );
+}
+
const OUString SvtLanguageTableImpl::GetString( const LanguageType eType, bool bUserInterfaceSelection ) const
{
More information about the Libreoffice-commits
mailing list