Kaydet (Commit) 8ec5c249 authored tarafından tagezi's avatar tagezi Kaydeden (comit) Mike Kaganski

Format and document combobox classes of BasicIDE

Change-Id: Ie4f9c142d221b16072748c9c2deaa96c4704b90d
Reviewed-on: https://gerrit.libreoffice.org/64422
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst efe28895
...@@ -31,28 +31,42 @@ ...@@ -31,28 +31,42 @@
namespace basctl namespace basctl
{ {
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
SFX_IMPL_TOOLBOX_CONTROL( LibBoxControl, SfxStringItem ); /*! Macro for implementation two metods for LibBoxControl Class
*
* @code
* SfxToolBoxControl* LibBoxControl::CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* {
* return new LibBoxControl(nSlotId, nId, rTbx);
* }
*
* void LibBoxControl::RegisterControl(sal_uInt16 nSlotId, SfxModule* pMod)
* {
* SfxToolBoxControl::RegisterToolBoxControl(
* pMod, SfxTbxCtrlFactory(* LibBoxControl::CreateImpl, typeid(nItemClass), nSlotId));
* }
* @endcode
* @see Macro SFX_DECL_TOOLBOX_CONTROL
*/
SFX_IMPL_TOOLBOX_CONTROL(LibBoxControl, SfxStringItem);
LibBoxControl::LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) LibBoxControl::LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
: SfxToolBoxControl( nSlotId, nId, rTbx ) : SfxToolBoxControl(nSlotId, nId, rTbx)
{ {
} }
void LibBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pState)
void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
{ {
LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId())); LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId()));
DBG_ASSERT( pBox, "Box not found" ); DBG_ASSERT(pBox, "Box not found");
if ( !pBox ) if (!pBox)
return; return;
if ( eState != SfxItemState::DEFAULT ) if (eState != SfxItemState::DEFAULT)
pBox->Disable(); pBox->Disable();
else else
{ {
...@@ -61,92 +75,65 @@ void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPool ...@@ -61,92 +75,65 @@ void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPool
} }
} }
VclPtr<vcl::Window> LibBoxControl::CreateItemWindow(vcl::Window* pParent)
VclPtr<vcl::Window> LibBoxControl::CreateItemWindow( vcl::Window *pParent )
{ {
return VclPtr<LibBox>::Create( pParent ); return VclPtr<LibBox>::Create(pParent);
} }
DocListenerBox::DocListenerBox(vcl::Window* pParent)
DocListenerBox::DocListenerBox( vcl::Window* pParent ) : ListBox(pParent, WinBits(WB_BORDER | WB_DROPDOWN))
:ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ) , maNotifier(*this)
,m_aNotifier( *this )
{ {
} }
DocListenerBox::~DocListenerBox() DocListenerBox::~DocListenerBox() { disposeOnce(); }
{
disposeOnce();
}
void DocListenerBox::dispose() void DocListenerBox::dispose()
{ {
m_aNotifier.dispose(); maNotifier.dispose();
ListBox::dispose(); ListBox::dispose();
} }
void DocListenerBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) /// Only calls FillBox(). Parameter is not used.
{ void DocListenerBox::onDocumentCreated(const ScriptDocument& /*_rDoc*/) { FillBox(); }
FillBox();
}
void DocListenerBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ ) /// Only calls FillBox(). Parameter is not used.
{ void DocListenerBox::onDocumentOpened(const ScriptDocument& /*_rDoc*/) { FillBox(); }
FillBox();
}
void DocListenerBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ ) /// Only calls FillBox(). Parameter is not used.
{ void DocListenerBox::onDocumentSaveAsDone(const ScriptDocument& /*_rDoc*/) { FillBox(); }
// not interested in
}
void DocListenerBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ ) /// Only calls FillBox(). Parameter is not used.
{ void DocListenerBox::onDocumentClosed(const ScriptDocument& /*_rDoc*/) { FillBox(); }
// not interested in
}
void DocListenerBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ ) /// Not interested in. Do nothing.
{ void DocListenerBox::onDocumentSave(const ScriptDocument& /*_rDoc*/) {}
// not interested in
}
void DocListenerBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ ) /// Not interested in. Do nothing.
{ void DocListenerBox::onDocumentSaveDone(const ScriptDocument& /*_rDoc*/) {}
FillBox();
}
void DocListenerBox::onDocumentClosed( const ScriptDocument& /*_rDocument*/ ) /// Not interested in. Do nothing.
{ void DocListenerBox::onDocumentSaveAs(const ScriptDocument& /*_rDoc*/) {}
FillBox();
}
void DocListenerBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ ) /// Not interested in. Do nothing.
{ void DocListenerBox::onDocumentTitleChanged(const ScriptDocument& /*_rDoc*/) {}
// not interested in
}
void DocListenerBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ ) /// Not interested in. Do nothing.
{ void DocListenerBox::onDocumentModeChanged(const ScriptDocument& /*_rDoc*/) {}
// not interested in
}
LibBox::LibBox( vcl::Window* pParent ) : LibBox::LibBox(vcl::Window* pParent)
DocListenerBox( pParent ) : DocListenerBox(pParent)
{ {
FillBox(); FillBox();
bIgnoreSelect = true; // do not yet transfer select of 0 mbIgnoreSelect = true; // do not yet transfer select of 0
bFillBox = true; mbFillBox = true;
SelectEntryPos( 0 ); SelectEntryPos(0);
aCurText = GetEntry( 0 ); maCurrentText = GetEntry(0);
SetSizePixel( Size( 250, 200 ) ); SetSizePixel(Size(250, 200));
bIgnoreSelect = false; mbIgnoreSelect = false;
} }
LibBox::~LibBox() { disposeOnce(); }
LibBox::~LibBox()
{
disposeOnce();
}
void LibBox::dispose() void LibBox::dispose()
{ {
...@@ -154,32 +141,31 @@ void LibBox::dispose() ...@@ -154,32 +141,31 @@ void LibBox::dispose()
DocListenerBox::dispose(); DocListenerBox::dispose();
} }
void LibBox::Update( const SfxStringItem* pItem ) void LibBox::Update(const SfxStringItem* pItem)
{ {
// if ( !pItem || !pItem->GetValue().Len() )
FillBox();
// if ( !pItem || !pItem->GetValue().Len() ) if (pItem)
FillBox();
if ( pItem )
{ {
aCurText = pItem->GetValue(); maCurrentText = pItem->GetValue();
if ( aCurText.isEmpty() ) if (maCurrentText.isEmpty())
aCurText = IDEResId(RID_STR_ALL); maCurrentText = IDEResId(RID_STR_ALL);
} }
if ( GetSelectedEntry() != aCurText ) if (GetSelectedEntry() != maCurrentText)
SelectEntry( aCurText ); SelectEntry(maCurrentText);
} }
void LibBox::ReleaseFocus() void LibBox::ReleaseFocus()
{ {
SfxViewShell* pCurSh = SfxViewShell::Current(); SfxViewShell* pCurSh = SfxViewShell::Current();
DBG_ASSERT( pCurSh, "Current ViewShell not found!" ); DBG_ASSERT(pCurSh, "Current ViewShell not found!");
if ( pCurSh ) if (pCurSh)
{ {
vcl::Window* pShellWin = pCurSh->GetWindow(); vcl::Window* pShellWin = pCurSh->GetWindow();
if ( !pShellWin ) if (!pShellWin)
pShellWin = Application::GetDefDialogParent(); pShellWin = Application::GetDefDialogParent();
pShellWin->GrabFocus(); pShellWin->GrabFocus();
...@@ -189,20 +175,22 @@ void LibBox::ReleaseFocus() ...@@ -189,20 +175,22 @@ void LibBox::ReleaseFocus()
void LibBox::FillBox() void LibBox::FillBox()
{ {
SetUpdateMode(false); SetUpdateMode(false);
bIgnoreSelect = true; mbIgnoreSelect = true;
aCurText = GetSelectedEntry(); maCurrentText = GetSelectedEntry();
SelectEntryPos( 0 ); SelectEntryPos(0);
ClearBox(); ClearBox();
// create list box entries // create list box entries
sal_Int32 nPos = InsertEntry(IDEResId(RID_STR_ALL)); sal_Int32 nPos = InsertEntry(IDEResId(RID_STR_ALL));
SetEntryData( nPos, new LibEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_UNKNOWN, OUString() ) ); SetEntryData(nPos, new LibEntry(ScriptDocument::getApplicationScriptDocument(),
InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER ); LIBRARY_LOCATION_UNKNOWN, OUString()));
InsertEntries( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE ); InsertEntries(ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER);
InsertEntries(ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE);
ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) ); ScriptDocuments aDocuments(
ScriptDocument::getAllScriptDocuments(ScriptDocument::DocumentsSorted));
for (auto const& doc : aDocuments) for (auto const& doc : aDocuments)
{ {
InsertEntries(doc, LIBRARY_LOCATION_DOCUMENT); InsertEntries(doc, LIBRARY_LOCATION_DOCUMENT);
...@@ -210,43 +198,43 @@ void LibBox::FillBox() ...@@ -210,43 +198,43 @@ void LibBox::FillBox()
SetUpdateMode(true); SetUpdateMode(true);
SelectEntry( aCurText ); SelectEntry(maCurrentText);
if ( !GetSelectedEntryCount() ) if (!GetSelectedEntryCount())
{ {
SelectEntryPos( GetEntryCount() ); SelectEntryPos(GetEntryCount());
aCurText = GetSelectedEntry(); maCurrentText = GetSelectedEntry();
} }
bIgnoreSelect = false; mbIgnoreSelect = false;
} }
void LibBox::InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation ) void LibBox::InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLocation)
{ {
// get a sorted list of library names // get a sorted list of library names
Sequence< OUString > aLibNames = rDocument.getLibraryNames(); Sequence<OUString> aLibNames = rDocument.getLibraryNames();
sal_Int32 nLibCount = aLibNames.getLength(); sal_Int32 nLibCount = aLibNames.getLength();
const OUString* pLibNames = aLibNames.getConstArray(); const OUString* pLibNames = aLibNames.getConstArray();
for ( sal_Int32 i = 0 ; i < nLibCount ; ++i ) for (sal_Int32 i = 0; i < nLibCount; ++i)
{ {
OUString aLibName = pLibNames[ i ]; OUString aLibName = pLibNames[i];
if ( eLocation == rDocument.getLibraryLocation( aLibName ) ) if (eLocation == rDocument.getLibraryLocation(aLibName))
{ {
OUString aName( rDocument.getTitle( eLocation ) ); OUString aName(rDocument.getTitle(eLocation));
OUString aEntryText( CreateMgrAndLibStr( aName, aLibName ) ); OUString aEntryText(CreateMgrAndLibStr(aName, aLibName));
sal_Int32 nPos = InsertEntry( aEntryText ); sal_Int32 nPos = InsertEntry(aEntryText);
SetEntryData( nPos, new LibEntry( rDocument, eLocation, aLibName ) ); SetEntryData(nPos, new LibEntry(rDocument, eLocation, aLibName));
} }
} }
} }
bool LibBox::PreNotify( NotifyEvent& rNEvt ) bool LibBox::PreNotify(NotifyEvent& rNEvt)
{ {
bool bDone = false; bool bDone = false;
if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
{ {
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode(); sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode();
switch( nKeyCode ) switch (nKeyCode)
{ {
case KEY_RETURN: case KEY_RETURN:
{ {
...@@ -254,44 +242,43 @@ bool LibBox::PreNotify( NotifyEvent& rNEvt ) ...@@ -254,44 +242,43 @@ bool LibBox::PreNotify( NotifyEvent& rNEvt )
bDone = true; bDone = true;
} }
break; break;
case KEY_ESCAPE: case KEY_ESCAPE:
{ {
SelectEntry( aCurText ); SelectEntry(maCurrentText);
ReleaseFocus(); ReleaseFocus();
bDone = true; bDone = true;
} }
break; break;
} }
} }
else if( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS ) else if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS)
{ {
if ( bFillBox ) if (mbFillBox)
{ {
FillBox(); FillBox();
bFillBox = false; mbFillBox = false;
} }
} }
else if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS ) else if (rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS)
{ {
if ( !HasChildPathFocus(true) ) if (!HasChildPathFocus(true))
{ {
bIgnoreSelect = true; mbIgnoreSelect = true;
bFillBox = true; mbFillBox = true;
} }
} }
return bDone || ListBox::PreNotify( rNEvt ); return bDone || ListBox::PreNotify(rNEvt);
} }
void LibBox::Select() void LibBox::Select()
{ {
if ( !IsTravelSelect() ) if (!IsTravelSelect())
{ {
if ( !bIgnoreSelect ) if (!mbIgnoreSelect)
NotifyIDE(); NotifyIDE();
else else
SelectEntry( aCurText ); // since 306... (Select after Escape) SelectEntry(maCurrentText); // since 306... (Select after Escape)
} }
} }
...@@ -300,15 +287,14 @@ void LibBox::NotifyIDE() ...@@ -300,15 +287,14 @@ void LibBox::NotifyIDE()
sal_Int32 nSelPos = GetSelectedEntryPos(); sal_Int32 nSelPos = GetSelectedEntryPos();
if (LibEntry* pEntry = static_cast<LibEntry*>(GetEntryData(nSelPos))) if (LibEntry* pEntry = static_cast<LibEntry*>(GetEntryData(nSelPos)))
{ {
const ScriptDocument& aDocument( pEntry->GetDocument() ); const ScriptDocument& aDocument(pEntry->GetDocument());
SfxUnoAnyItem aDocumentItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, uno::Any( aDocument.getDocumentOrNull() ) ); SfxUnoAnyItem aDocumentItem(SID_BASICIDE_ARG_DOCUMENT_MODEL,
uno::Any(aDocument.getDocumentOrNull()));
const OUString& aLibName = pEntry->GetLibName(); const OUString& aLibName = pEntry->GetLibName();
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName ); SfxStringItem aLibNameItem(SID_BASICIDE_ARG_LIBNAME, aLibName);
if (SfxDispatcher* pDispatcher = GetDispatcher()) if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->ExecuteList( pDispatcher->ExecuteList(SID_BASICIDE_LIBSELECTED, SfxCallMode::SYNCHRON,
SID_BASICIDE_LIBSELECTED, SfxCallMode::SYNCHRON, { &aDocumentItem, &aLibNameItem });
{ &aDocumentItem, &aLibNameItem }
);
} }
ReleaseFocus(); ReleaseFocus();
} }
...@@ -316,9 +302,9 @@ void LibBox::NotifyIDE() ...@@ -316,9 +302,9 @@ void LibBox::NotifyIDE()
void LibBox::ClearBox() void LibBox::ClearBox()
{ {
sal_Int32 nCount = GetEntryCount(); sal_Int32 nCount = GetEntryCount();
for ( sal_Int32 i = 0; i < nCount; ++i ) for (sal_Int32 i = 0; i < nCount; ++i)
{ {
LibEntry* pEntry = static_cast<LibEntry*>(GetEntryData( i )); LibEntry* pEntry = static_cast<LibEntry*>(GetEntryData(i));
delete pEntry; delete pEntry;
} }
ListBox::Clear(); ListBox::Clear();
...@@ -326,14 +312,30 @@ void LibBox::ClearBox() ...@@ -326,14 +312,30 @@ void LibBox::ClearBox()
// class LanguageBoxControl ---------------------------------------------- // class LanguageBoxControl ----------------------------------------------
SFX_IMPL_TOOLBOX_CONTROL( LanguageBoxControl, SfxStringItem ); /*! Macro for implementation two metods for LanguageBoxControl Class
*
* @code
* SfxToolBoxControl* LanguageBoxControl::CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* {
* return new LanguageBoxControl(nSlotId, nId, rTbx);
* }
*
* void LanguageBoxControl::RegisterControl(sal_uInt16 nSlotId, SfxModule* pMod)
* {
* SfxToolBoxControl::RegisterToolBoxControl(
* pMod, SfxTbxCtrlFactory(* LanguageBoxControl::CreateImpl, typeid(nItemClass), nSlotId));
* }
* @endcode
* @see Macro SFX_DECL_TOOLBOX_CONTROL
*/
SFX_IMPL_TOOLBOX_CONTROL(LanguageBoxControl, SfxStringItem);
LanguageBoxControl::LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) LanguageBoxControl::LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
: SfxToolBoxControl( nSlotId, nId, rTbx ) : SfxToolBoxControl(nSlotId, nId, rTbx)
{ {
} }
void LanguageBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pItem ) void LanguageBoxControl::StateChanged(sal_uInt16, SfxItemState eState, const SfxPoolItem* pItem)
{ {
if (LanguageBox* pBox = static_cast<LanguageBox*>(GetToolBox().GetItemWindow(GetId()))) if (LanguageBox* pBox = static_cast<LanguageBox*>(GetToolBox().GetItemWindow(GetId())))
{ {
...@@ -347,32 +349,23 @@ void LanguageBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const Sf ...@@ -347,32 +349,23 @@ void LanguageBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const Sf
} }
} }
VclPtr<vcl::Window> LanguageBoxControl::CreateItemWindow( vcl::Window *pParent ) VclPtr<vcl::Window> LanguageBoxControl::CreateItemWindow(vcl::Window* pParent)
{ {
return VclPtr<LanguageBox>::Create( pParent ); return VclPtr<LanguageBox>::Create(pParent);
} }
// class basctl::LanguageBox ----------------------------------------------- // class basctl::LanguageBox -----------------------------------------------
LanguageBox::LanguageBox(vcl::Window* pParent)
LanguageBox::LanguageBox( vcl::Window* pParent ) : : DocListenerBox(pParent)
, msNotLocalizedStr(IDEResId(RID_STR_TRANSLATION_NOTLOCALIZED))
DocListenerBox( pParent ), , msDefaultLanguageStr(IDEResId(RID_STR_TRANSLATION_DEFAULT))
, mbIgnoreSelect(false)
m_sNotLocalizedStr( IDEResId( RID_STR_TRANSLATION_NOTLOCALIZED ) ),
m_sDefaultLanguageStr( IDEResId( RID_STR_TRANSLATION_DEFAULT ) ),
m_bIgnoreSelect( false )
{ {
SetSizePixel( Size( 210, 200 ) ); SetSizePixel(Size(210, 200));
FillBox(); FillBox();
} }
LanguageBox::~LanguageBox() LanguageBox::~LanguageBox() { disposeOnce(); }
{
disposeOnce();
}
void LanguageBox::dispose() void LanguageBox::dispose()
{ {
...@@ -383,58 +376,58 @@ void LanguageBox::dispose() ...@@ -383,58 +376,58 @@ void LanguageBox::dispose()
void LanguageBox::FillBox() void LanguageBox::FillBox()
{ {
SetUpdateMode(false); SetUpdateMode(false);
m_bIgnoreSelect = true; mbIgnoreSelect = true;
m_sCurrentText = GetSelectedEntry(); msCurrentText = GetSelectedEntry();
ClearBox(); ClearBox();
std::shared_ptr<LocalizationMgr> pCurMgr(GetShell()->GetCurLocalizationMgr()); std::shared_ptr<LocalizationMgr> pCurMgr(GetShell()->GetCurLocalizationMgr());
if ( pCurMgr->isLibraryLocalized() ) if (pCurMgr->isLibraryLocalized())
{ {
Enable(); Enable();
Locale aDefaultLocale = pCurMgr->getStringResourceManager()->getDefaultLocale(); Locale aDefaultLocale = pCurMgr->getStringResourceManager()->getDefaultLocale();
Locale aCurrentLocale = pCurMgr->getStringResourceManager()->getCurrentLocale(); Locale aCurrentLocale = pCurMgr->getStringResourceManager()->getCurrentLocale();
Sequence< Locale > aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales(); Sequence<Locale> aLocaleSeq = pCurMgr->getStringResourceManager()->getLocales();
const Locale* pLocale = aLocaleSeq.getConstArray(); const Locale* pLocale = aLocaleSeq.getConstArray();
sal_Int32 i, nCount = aLocaleSeq.getLength(); sal_Int32 i, nCount = aLocaleSeq.getLength();
sal_Int32 nSelPos = LISTBOX_ENTRY_NOTFOUND; sal_Int32 nSelPos = LISTBOX_ENTRY_NOTFOUND;
for ( i = 0; i < nCount; ++i ) for (i = 0; i < nCount; ++i)
{ {
bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] ); bool bIsDefault = localesAreEqual(aDefaultLocale, pLocale[i]);
bool bIsCurrent = localesAreEqual( aCurrentLocale, pLocale[i] ); bool bIsCurrent = localesAreEqual(aCurrentLocale, pLocale[i]);
LanguageType eLangType = LanguageTag::convertToLanguageType( pLocale[i] ); LanguageType eLangType = LanguageTag::convertToLanguageType(pLocale[i]);
OUString sLanguage = SvtLanguageTable::GetLanguageString( eLangType ); OUString sLanguage = SvtLanguageTable::GetLanguageString(eLangType);
if ( bIsDefault ) if (bIsDefault)
{ {
sLanguage += " " + m_sDefaultLanguageStr; sLanguage += " " + msDefaultLanguageStr;
} }
sal_Int32 nPos = InsertEntry( sLanguage ); sal_Int32 nPos = InsertEntry(sLanguage);
SetEntryData( nPos, new LanguageEntry( pLocale[i], bIsDefault ) ); SetEntryData(nPos, new LanguageEntry(pLocale[i], bIsDefault));
if ( bIsCurrent ) if (bIsCurrent)
nSelPos = nPos; nSelPos = nPos;
} }
if ( nSelPos != LISTBOX_ENTRY_NOTFOUND ) if (nSelPos != LISTBOX_ENTRY_NOTFOUND)
{ {
SelectEntryPos( nSelPos ); SelectEntryPos(nSelPos);
m_sCurrentText = GetSelectedEntry(); msCurrentText = GetSelectedEntry();
} }
} }
else else
{ {
InsertEntry( m_sNotLocalizedStr ); InsertEntry(msNotLocalizedStr);
SelectEntryPos(0); SelectEntryPos(0);
Disable(); Disable();
} }
SetUpdateMode(true); SetUpdateMode(true);
m_bIgnoreSelect = false; mbIgnoreSelect = false;
} }
void LanguageBox::ClearBox() void LanguageBox::ClearBox()
{ {
sal_Int32 nCount = GetEntryCount(); sal_Int32 nCount = GetEntryCount();
for ( sal_Int32 i = 0; i < nCount; ++i ) for (sal_Int32 i = 0; i < nCount; ++i)
{ {
LanguageEntry* pEntry = static_cast<LanguageEntry*>(GetEntryData(i)); LanguageEntry* pEntry = static_cast<LanguageEntry*>(GetEntryData(i));
delete pEntry; delete pEntry;
...@@ -445,25 +438,25 @@ void LanguageBox::ClearBox() ...@@ -445,25 +438,25 @@ void LanguageBox::ClearBox()
void LanguageBox::SetLanguage() void LanguageBox::SetLanguage()
{ {
LanguageEntry* pEntry = static_cast<LanguageEntry*>(GetSelectedEntryData()); LanguageEntry* pEntry = static_cast<LanguageEntry*>(GetSelectedEntryData());
if ( pEntry ) if (pEntry)
GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale( pEntry->m_aLocale ); GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale(pEntry->m_aLocale);
} }
void LanguageBox::Select() void LanguageBox::Select()
{ {
if ( !m_bIgnoreSelect ) if (!mbIgnoreSelect)
SetLanguage(); SetLanguage();
else else
SelectEntry( m_sCurrentText ); // Select after Escape SelectEntry(msCurrentText); // Select after Escape
} }
bool LanguageBox::PreNotify( NotifyEvent& rNEvt ) bool LanguageBox::PreNotify(NotifyEvent& rNEvt)
{ {
bool bDone = false; bool bDone = false;
if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
{ {
sal_uInt16 nKeyCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); sal_uInt16 nKeyCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
switch( nKeyCode ) switch (nKeyCode)
{ {
case KEY_RETURN: case KEY_RETURN:
{ {
...@@ -471,32 +464,30 @@ bool LanguageBox::PreNotify( NotifyEvent& rNEvt ) ...@@ -471,32 +464,30 @@ bool LanguageBox::PreNotify( NotifyEvent& rNEvt )
bDone = true; bDone = true;
} }
break; break;
case KEY_ESCAPE: case KEY_ESCAPE:
{ {
SelectEntry( m_sCurrentText ); SelectEntry(msCurrentText);
bDone = true; bDone = true;
} }
break; break;
} }
} }
return bDone || ListBox::PreNotify( rNEvt ); return bDone || ListBox::PreNotify(rNEvt);
} }
void LanguageBox::Update( const SfxStringItem* pItem ) void LanguageBox::Update(const SfxStringItem* pItem)
{ {
FillBox(); FillBox();
if ( pItem && !pItem->GetValue().isEmpty() ) if (pItem && !pItem->GetValue().isEmpty())
{ {
m_sCurrentText = pItem->GetValue(); msCurrentText = pItem->GetValue();
if ( GetSelectedEntry() != m_sCurrentText ) if (GetSelectedEntry() != msCurrentText)
SelectEntry( m_sCurrentText ); SelectEntry(msCurrentText);
} }
} }
} // namespace basctl } // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -26,116 +26,228 @@ ...@@ -26,116 +26,228 @@
namespace basctl namespace basctl
{ {
/*!
class LibBoxControl: public SfxToolBoxControl * @brief Manage states of macro and dialog Library ComboBox
*
* @see LibBox Class
*/
class LibBoxControl : public SfxToolBoxControl
{ {
public: public:
SFX_DECL_TOOLBOX_CONTROL(); /*!
* Macro for registring two metods
*
* @code
* static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
* @endcode
* @see Macro SFX_IMPL_TOOLBOX_CONTROL
*/
SFX_DECL_TOOLBOX_CONTROL();
LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); /*!
* @param nSlotId -- the slot as internal operation number
* @param nId -- this item's unique id in ToolBox
* @param rTbx -- the ToolBox which contains this ComboBox
*/
LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, /*!
const SfxPoolItem* pState ) override; * Triggered if state was changed
virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; *
* @param nSlotID -- the slot as internal operation number (not used in this place)
* @param eState -- enum value which contains ComboBox state
* @param pState --
*/
virtual void StateChanged(sal_uInt16 nSlotID, SfxItemState eState,
const SfxPoolItem* pState) override;
/*!
* Create combobox of Macro and Dialog Library
*
* @param pParent -- parent window
* @return ComboBox of macro and dialog Library
*/
virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override;
}; };
/** base class for list boxes which need to update their content according to the list /*!
of open documents * @brief Base class for all ComboBox elements.
*/ *
class DocListenerBox :public ListBox * Base class for ComboBoxes which need to update their content according
,public DocumentEventListener * to the list of open documents.
*/
class DocListenerBox : public ListBox, public DocumentEventListener
{ {
protected: protected:
DocListenerBox( vcl::Window* pParent ); /// @param pParent -- parent window
DocListenerBox(vcl::Window* pParent);
virtual ~DocListenerBox() override; virtual ~DocListenerBox() override;
virtual void dispose() override; virtual void dispose() override;
protected: virtual void FillBox() = 0;
virtual void FillBox() = 0;
private: private:
// DocumentEventListener // DocumentEventListener
virtual void onDocumentCreated( const ScriptDocument& _rDocument ) override; virtual void onDocumentCreated(const ScriptDocument& _rDoc) override;
virtual void onDocumentOpened( const ScriptDocument& _rDocument ) override; virtual void onDocumentOpened(const ScriptDocument& _rDoc) override;
virtual void onDocumentSave( const ScriptDocument& _rDocument ) override; virtual void onDocumentSave(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) override; virtual void onDocumentSaveDone(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) override; virtual void onDocumentSaveAs(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) override; virtual void onDocumentSaveAsDone(const ScriptDocument& _rDoc) override;
virtual void onDocumentClosed( const ScriptDocument& _rDocument ) override; virtual void onDocumentClosed(const ScriptDocument& _rDoc) override;
virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) override; virtual void onDocumentTitleChanged(const ScriptDocument& _rDoc) override;
virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) override; virtual void onDocumentModeChanged(const ScriptDocument& _rDoc) override;
private: DocumentEventNotifier maNotifier;
DocumentEventNotifier m_aNotifier;
}; };
/*!
* @brief Macros and Dialogs Library ComboBox
*
* @see LibBoxControl Class
*/
class LibBox : public DocListenerBox class LibBox : public DocListenerBox
{ {
private: public:
OUString aCurText; /// @param pParent
bool bIgnoreSelect; LibBox(vcl::Window* pParent);
bool bFillBox; virtual ~LibBox() override;
virtual void dispose() override;
static void ReleaseFocus(); using Window::Update;
void InsertEntries( const ScriptDocument& rDocument, LibraryLocation eLocation ); /*!
* Update selection in ComboBox of macro and dialog Library
*
* @param pItem -- string that was selected
*/
void Update(const SfxStringItem* pItem);
void ClearBox(); protected:
void NotifyIDE(); /// Called for setting language when user selects a language in ComboBox
virtual void Select() override;
// DocListenerBox /*!
virtual void FillBox() override; * Handle keystrokes and mouse
*
* @param rNEvt represents mouse event
* @return a bool value: true if was handled, and false if there was nothing handled
*/
virtual bool PreNotify(NotifyEvent& rNEvt) override;
protected: private:
virtual void Select() override; static void ReleaseFocus();
virtual bool PreNotify( NotifyEvent& rNEvt ) override;
public: /*!
LibBox( vcl::Window* pParent ); * Insert name library in specified position
virtual ~LibBox() override; *
virtual void dispose() override; * @param rDocument -- macro or dialog
* @param eLocation -- enum value of Locations
*/
void InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLocation);
using Window::Update; void ClearBox();
void Update( const SfxStringItem* pItem ); void NotifyIDE();
/// Fill up the combobox
virtual void FillBox() override;
OUString maCurrentText;
bool mbIgnoreSelect;
bool mbFillBox; ///< If true, when FillBox() is called
}; };
class LanguageBoxControl: public SfxToolBoxControl /*!
* @brief Manage stats of Language ComboBox
*
* @see LanguageBox Class
*/
class LanguageBoxControl : public SfxToolBoxControl
{ {
public: public:
SFX_DECL_TOOLBOX_CONTROL(); /*! Macro for registring two metods
*
* @code
* static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
* @endcode
* @see Macro SFX_IMPL_TOOLBOX_CONTROL
*/
SFX_DECL_TOOLBOX_CONTROL();
LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); /*!
* @param nSlotId -- the slot as internal operation number
* @param nId -- this item's unique id in ToolBox
* @param rTbx -- the ToolBox which contains this ComboBox
*/
LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; /*!
virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override; * Triggered if state was changed
*
* @param nSlotID -- the slot as internal operation number (not used in this place)
* @param eState -- enum value which contains ComboBox state
* @param pState --
*/
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState) override;
/*!
* Create ComboBox of Language
*
* @param pParent
* @return LanguageBox ComboBox
*/
virtual VclPtr<vcl::Window> CreateItemWindow(vcl::Window* pParent) override;
}; };
/*!
* @brief Class language ComboBox
*
* @see LanguageBoxControl Class
*/
class LanguageBox : public DocListenerBox class LanguageBox : public DocListenerBox
{ {
private: public:
OUString m_sNotLocalizedStr; /*!
OUString m_sDefaultLanguageStr; * @param pParent
OUString m_sCurrentText; */
LanguageBox(vcl::Window* pParent);
virtual ~LanguageBox() override;
virtual void dispose() override;
bool m_bIgnoreSelect; using Window::Update;
/*!
* Update selection in ComboBox of macro and dialog Library
*
* @param pItem -- string that was selected
*/
void Update(const SfxStringItem* pItem);
void ClearBox(); protected:
void SetLanguage(); /// Called for setting language when user selects a language in ComboBox
virtual void Select() override;
// DocListenerBox /*!
virtual void FillBox() override; * Handle keystrokes and mouse
*
* @param rNEvt represents mouse event
* @return a bool value: true if was handled, and false if there was nothing handled
*/
virtual bool PreNotify(NotifyEvent& rNEvt) override;
protected: private:
virtual void Select() override; /// Delete all langiages form ComboBox
virtual bool PreNotify( NotifyEvent& rNEvt ) override; void ClearBox();
/// Swich inferface of dialog to selected language
void SetLanguage();
public: /// Fill up the language combobox
LanguageBox( vcl::Window* pParent ); virtual void FillBox() override;
virtual ~LanguageBox() override;
virtual void dispose() override; OUString msNotLocalizedStr;
OUString msDefaultLanguageStr;
OUString msCurrentText;
using Window::Update; bool mbIgnoreSelect; ///< do not use in this class
void Update( const SfxStringItem* pItem );
}; };
} // namespace basctl } // namespace basctl
......
...@@ -245,8 +245,6 @@ basctl/source/accessibility/accessibledialogcontrolshape.cxx ...@@ -245,8 +245,6 @@ basctl/source/accessibility/accessibledialogcontrolshape.cxx
basctl/source/accessibility/accessibledialogwindow.cxx basctl/source/accessibility/accessibledialogwindow.cxx
basctl/source/basicide/basdoc.cxx basctl/source/basicide/basdoc.cxx
basctl/source/basicide/basdoc.hxx basctl/source/basicide/basdoc.hxx
basctl/source/basicide/basicbox.cxx
basctl/source/basicide/basicbox.hxx
basctl/source/basicide/basicmod.hxx basctl/source/basicide/basicmod.hxx
basctl/source/basicide/basicrenderable.cxx basctl/source/basicide/basicrenderable.cxx
basctl/source/basicide/basicrenderable.hxx basctl/source/basicide/basicrenderable.hxx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment