Kaydet (Commit) 257d1f4f authored tarafından Caolán McNamara's avatar Caolán McNamara

allow simple MessageDialogs to be created from just message strings

Change-Id: I9f8324d1c61bd55ccc78e67699ebdfa946e48af6
üst f6cb7ff0
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <vcl/msgbox.hxx> #include <vcl/layout.hxx>
#include <sot/storinfo.hxx> #include <sot/storinfo.hxx>
#include <moduldlg.hrc> #include <moduldlg.hrc>
...@@ -291,7 +291,7 @@ sal_Bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, Selection& ) ...@@ -291,7 +291,7 @@ sal_Bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
OUString aLibName = GetEntryText( pEntry, 0 ); OUString aLibName = GetEntryText( pEntry, 0 );
if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) ) if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) )
{ {
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_CANNOTCHANGENAMESTDLIB) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_CANNOTCHANGENAMESTDLIB)).Execute();
return false; return false;
} }
...@@ -301,7 +301,7 @@ sal_Bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, Selection& ) ...@@ -301,7 +301,7 @@ sal_Bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) || if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) ) ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
{ {
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_LIBISREADONLY) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_LIBISREADONLY)).Execute();
return false; return false;
} }
...@@ -353,7 +353,7 @@ sal_Bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewNam ...@@ -353,7 +353,7 @@ sal_Bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewNam
} }
catch (const container::ElementExistException& ) catch (const container::ElementExistException& )
{ {
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED)).Execute();
return false; return false;
} }
catch (const container::NoSuchElementException& ) catch (const container::NoSuchElementException& )
...@@ -366,9 +366,9 @@ sal_Bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewNam ...@@ -366,9 +366,9 @@ sal_Bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewNam
if ( !bValid ) if ( !bValid )
{ {
if ( rNewName.getLength() > 30 ) if ( rNewName.getLength() > 30 )
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_LIBNAMETOLONG) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_LIBNAMETOLONG)).Execute();
else else
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_BADSBXNAME) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_BADSBXNAME)).Execute();
} }
return bValid; return bValid;
...@@ -384,7 +384,7 @@ IMPL_LINK_NOARG(NewObjectDialog, OkButtonHandler) ...@@ -384,7 +384,7 @@ IMPL_LINK_NOARG(NewObjectDialog, OkButtonHandler)
EndDialog(1); EndDialog(1);
else else
{ {
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_BADSBXNAME) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_BADSBXNAME)).Execute();
m_pEdit->GrabFocus(); m_pEdit->GrabFocus();
} }
return 0; return 0;
...@@ -860,7 +860,7 @@ void LibPage::InsertLib() ...@@ -860,7 +860,7 @@ void LibPage::InsertLib()
} }
if ( !pLibDlg ) if ( !pLibDlg )
InfoBox( this, IDE_RESSTR(RID_STR_NOLIBINSTORAGE) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_NOLIBINSTORAGE), VCL_MESSAGE_INFO).Execute();
else else
{ {
bool bChanges = false; bool bChanges = false;
...@@ -897,7 +897,7 @@ void LibPage::InsertLib() ...@@ -897,7 +897,7 @@ void LibPage::InsertLib()
// check, if the library is the Standard library // check, if the library is the Standard library
if ( aLibName == "Standard" ) if ( aLibName == "Standard" )
{ {
ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_REPLACESTDLIB) ).Execute(); MessageDialog(this, IDE_RESSTR(RID_STR_REPLACESTDLIB)).Execute();
continue; continue;
} }
...@@ -909,7 +909,7 @@ void LibPage::InsertLib() ...@@ -909,7 +909,7 @@ void LibPage::InsertLib()
aErrStr = aErrStr.replaceAll("XX", aLibName); aErrStr = aErrStr.replaceAll("XX", aLibName);
aErrStr += "\n"; aErrStr += "\n";
aErrStr += IDE_RESSTR(RID_STR_LIBISREADONLY); aErrStr += IDE_RESSTR(RID_STR_LIBISREADONLY);
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute(); MessageDialog(this, aErrStr).Execute();
continue; continue;
} }
...@@ -926,7 +926,7 @@ void LibPage::InsertLib() ...@@ -926,7 +926,7 @@ void LibPage::InsertLib()
aErrStr = aErrStr.replaceAll("XX", aLibName); aErrStr = aErrStr.replaceAll("XX", aLibName);
aErrStr += "\n" ; aErrStr += "\n" ;
aErrStr += IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED); aErrStr += IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED);
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute(); MessageDialog(this, aErrStr).Execute();
continue; continue;
} }
} }
...@@ -945,7 +945,7 @@ void LibPage::InsertLib() ...@@ -945,7 +945,7 @@ void LibPage::InsertLib()
{ {
OUString aErrStr( IDE_RESSTR(RID_STR_NOIMPORT) ); OUString aErrStr( IDE_RESSTR(RID_STR_NOIMPORT) );
aErrStr = aErrStr.replaceAll("XX", aLibName); aErrStr = aErrStr.replaceAll("XX", aLibName);
ErrorBox( this, WB_OK | WB_DEF_OK, aErrStr ).Execute(); MessageDialog(this, aErrStr).Execute();
continue; continue;
} }
} }
...@@ -1537,17 +1537,15 @@ void createLibImpl( Window* pWin, const ScriptDocument& rDocument, ...@@ -1537,17 +1537,15 @@ void createLibImpl( Window* pWin, const ScriptDocument& rDocument,
if ( aLibName.getLength() > 30 ) if ( aLibName.getLength() > 30 )
{ {
ErrorBox( pWin, WB_OK | WB_DEF_OK, IDEResId(RID_STR_LIBNAMETOLONG).toString() ).Execute(); MessageDialog(pWin, IDEResId(RID_STR_LIBNAMETOLONG).toString()).Execute();
} }
else if ( !IsValidSbxName( aLibName ) ) else if ( !IsValidSbxName( aLibName ) )
{ {
ErrorBox( pWin, WB_OK | WB_DEF_OK, MessageDialog(pWin, IDEResId(RID_STR_BADSBXNAME).toString()).Execute();
IDEResId(RID_STR_BADSBXNAME).toString() ).Execute();
} }
else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) ) else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
{ {
ErrorBox( pWin, WB_OK | WB_DEF_OK, MessageDialog(pWin, IDEResId(RID_STR_SBXNAMEALLREADYUSED2).toString()).Execute();
IDEResId(RID_STR_SBXNAMEALLREADYUSED2).toString() ).Execute();
} }
else else
{ {
......
...@@ -693,6 +693,8 @@ class VCL_DLLPUBLIC MessageDialog : public Dialog ...@@ -693,6 +693,8 @@ class VCL_DLLPUBLIC MessageDialog : public Dialog
private: private:
VclButtonsType m_eButtonsType; VclButtonsType m_eButtonsType;
VclMessageType m_eMessageType; VclMessageType m_eMessageType;
VclBox *m_pOwnedContentArea;
VclButtonBox *m_pOwnedActionArea;
VclGrid* m_pGrid; VclGrid* m_pGrid;
FixedImage* m_pImage; FixedImage* m_pImage;
VclMultiLineEdit* m_pPrimaryMessage; VclMultiLineEdit* m_pPrimaryMessage;
...@@ -704,14 +706,15 @@ private: ...@@ -704,14 +706,15 @@ private:
DECL_DLLPRIVATE_LINK(ButtonHdl, Button *); DECL_DLLPRIVATE_LINK(ButtonHdl, Button *);
void setButtonHandlers(VclButtonBox *pButtonBox); void setButtonHandlers(VclButtonBox *pButtonBox);
short get_response(const Window *pWindow) const; short get_response(const Window *pWindow) const;
void create_owned_areas();
public: public:
MessageDialog(Window* pParent, MessageDialog(Window* pParent,
const OUString &rMessage, const OUString &rMessage,
VclMessageType eMessageType = VCL_MESSAGE_ERROR, VclMessageType eMessageType = VCL_MESSAGE_ERROR,
VclButtonsType eButtonsType = VCL_BUTTONS_OK, VclButtonsType eButtonsType = VCL_BUTTONS_OK,
WinBits nStyle = WB_CLIPCHILDREN | WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE); WinBits nStyle = WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE);
MessageDialog(Window* pParent, WinBits nStyle = WB_CLIPCHILDREN); MessageDialog(Window* pParent, WinBits nStyle = WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE);
MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription); MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
virtual bool set_property(const OString &rKey, const OString &rValue); virtual bool set_property(const OString &rKey, const OString &rValue);
virtual short Execute(); virtual short Execute();
......
...@@ -1897,6 +1897,17 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue) ...@@ -1897,6 +1897,17 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue)
return true; return true;
} }
void MessageDialog::create_owned_areas()
{
set_border_width(12);
m_pOwnedContentArea = new VclVBox(this, false, 24);
set_content_area(m_pOwnedContentArea);
m_pOwnedContentArea->Show();
m_pOwnedActionArea = new VclHButtonBox(m_pOwnedContentArea);
set_action_area(m_pOwnedActionArea);
m_pOwnedActionArea->Show();
}
MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) MessageDialog::MessageDialog(Window* pParent, WinBits nStyle)
: Dialog(pParent, nStyle) : Dialog(pParent, nStyle)
, m_eButtonsType(VCL_BUTTONS_NONE) , m_eButtonsType(VCL_BUTTONS_NONE)
...@@ -1907,6 +1918,7 @@ MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) ...@@ -1907,6 +1918,7 @@ MessageDialog::MessageDialog(Window* pParent, WinBits nStyle)
, m_pSecondaryMessage(NULL) , m_pSecondaryMessage(NULL)
{ {
SetType(WINDOW_MESSBOX); SetType(WINDOW_MESSBOX);
create_owned_areas();
} }
MessageDialog::MessageDialog(Window* pParent, MessageDialog::MessageDialog(Window* pParent,
...@@ -1924,12 +1936,15 @@ MessageDialog::MessageDialog(Window* pParent, ...@@ -1924,12 +1936,15 @@ MessageDialog::MessageDialog(Window* pParent,
, m_sPrimaryString(rMessage) , m_sPrimaryString(rMessage)
{ {
SetType(WINDOW_MESSBOX); SetType(WINDOW_MESSBOX);
create_owned_areas();
} }
MessageDialog::MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) MessageDialog::MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
: Dialog(pParent, rID, rUIXMLDescription, WINDOW_MESSBOX) : Dialog(pParent, rID, rUIXMLDescription, WINDOW_MESSBOX)
, m_eButtonsType(VCL_BUTTONS_NONE) , m_eButtonsType(VCL_BUTTONS_NONE)
, m_eMessageType(VCL_MESSAGE_INFO) , m_eMessageType(VCL_MESSAGE_INFO)
, m_pOwnedContentArea(NULL)
, m_pOwnedActionArea(NULL)
, m_pGrid(NULL) , m_pGrid(NULL)
, m_pImage(NULL) , m_pImage(NULL)
, m_pPrimaryMessage(NULL) , m_pPrimaryMessage(NULL)
...@@ -1945,6 +1960,8 @@ MessageDialog::~MessageDialog() ...@@ -1945,6 +1960,8 @@ MessageDialog::~MessageDialog()
delete m_pPrimaryMessage; delete m_pPrimaryMessage;
delete m_pImage; delete m_pImage;
delete m_pGrid; delete m_pGrid;
delete m_pOwnedActionArea;
delete m_pOwnedContentArea;
} }
void MessageDialog::response(short nResponseId) void MessageDialog::response(short nResponseId)
...@@ -2085,6 +2102,7 @@ short MessageDialog::Execute() ...@@ -2085,6 +2102,7 @@ short MessageDialog::Execute()
VclButtonBox *pButtonBox = get_action_area(); VclButtonBox *pButtonBox = get_action_area();
assert(pButtonBox); assert(pButtonBox);
PushButton *pBtn; PushButton *pBtn;
switch (m_eButtonsType) switch (m_eButtonsType)
{ {
...@@ -2140,7 +2158,6 @@ short MessageDialog::Execute() ...@@ -2140,7 +2158,6 @@ short MessageDialog::Execute()
setButtonHandlers(pButtonBox); setButtonHandlers(pButtonBox);
pButtonBox->sort_native_button_order(); pButtonBox->sort_native_button_order();
m_pGrid->Show(); m_pGrid->Show();
} }
return Dialog::Execute(); return Dialog::Execute();
} }
......
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