avoid intermediate vcl::Windows

Change-Id: Iac6bc83265e007a699a8993b89ac2efaa3739d95
Reviewed-on: https://gerrit.libreoffice.org/81761
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2019-10-30 11:34:27 +00:00
parent 32c53b465b
commit e2aa85a6fb
7 changed files with 23 additions and 31 deletions

View File

@ -50,10 +50,7 @@ protected:
virtual bool SpellMore() override; virtual bool SpellMore() override;
public: public:
EditSpellWrapper( vcl::Window* pWin, EditSpellWrapper(weld::Window* pWin, bool bIsStart, EditView* pView);
bool bIsStart,
EditView* pView );
}; };
/** /**

View File

@ -38,9 +38,9 @@ using namespace com::sun::star::beans;
using namespace com::sun::star::linguistic2; using namespace com::sun::star::linguistic2;
EditSpellWrapper::EditSpellWrapper( vcl::Window* _pWin, EditSpellWrapper::EditSpellWrapper(weld::Window* pWindow,
bool bIsStart, EditView* pView ) : bool bIsStart, EditView* pView )
SvxSpellWrapper( _pWin, bIsStart, false/*bIsAllRight*/ ) : SvxSpellWrapper(pWindow, bIsStart, false/*bIsAllRight*/)
{ {
SAL_WARN_IF( !pView, "editeng", "One view has to be abandoned!" ); SAL_WARN_IF( !pView, "editeng", "One view has to be abandoned!" );
// Keep IgnoreList, delete ReplaceList... // Keep IgnoreList, delete ReplaceList...

View File

@ -1447,7 +1447,8 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc )
else if ( CreateEPaM( aEditDoc.GetStartPaM() ) == pSpellInfo->aSpellStart ) else if ( CreateEPaM( aEditDoc.GetStartPaM() ) == pSpellInfo->aSpellStart )
bIsStart = true; bIsStart = true;
std::unique_ptr<EditSpellWrapper> pWrp(new EditSpellWrapper( Application::GetDefDialogParent(), vcl::Window* pParent = Application::GetDefDialogParent();
std::unique_ptr<EditSpellWrapper> pWrp(new EditSpellWrapper(pParent ? pParent->GetFrameWeld() : nullptr,
bIsStart, pEditView )); bIsStart, pEditView ));
pWrp->SpellDocument(); pWrp->SpellDocument();
pWrp.reset(); pWrp.reset();

View File

@ -45,10 +45,6 @@
#include <map> #include <map>
#include <memory> #include <memory>
#define WAIT_ON() if(pWin != nullptr) { pWin->EnterWait(); }
#define WAIT_OFF() if(pWin != nullptr) { pWin->LeaveWait(); }
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
@ -139,7 +135,7 @@ SvxSpellWrapper::~SvxSpellWrapper()
* *
--------------------------------------------------------------------*/ --------------------------------------------------------------------*/
SvxSpellWrapper::SvxSpellWrapper( vcl::Window* pWn, SvxSpellWrapper::SvxSpellWrapper( weld::Window* pWn,
const bool bStart, const bool bIsAllRight ) : const bool bStart, const bool bIsAllRight ) :
pWin ( pWn ), pWin ( pWn ),
@ -156,7 +152,7 @@ SvxSpellWrapper::SvxSpellWrapper( vcl::Window* pWn,
} }
SvxSpellWrapper::SvxSpellWrapper( vcl::Window* pWn, SvxSpellWrapper::SvxSpellWrapper( weld::Window* pWn,
Reference< XHyphenator > const &xHyphenator, Reference< XHyphenator > const &xHyphenator,
const bool bStart, const bool bOther ) : const bool bStart, const bool bOther ) :
pWin ( pWn ), pWin ( pWn ),
@ -275,7 +271,7 @@ void SvxSpellWrapper::SpellDocument( )
{ {
EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create(); EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
ScopedVclPtr<AbstractHyphenWordDialog> pDlg(pFact->CreateHyphenWordDialog( ScopedVclPtr<AbstractHyphenWordDialog> pDlg(pFact->CreateHyphenWordDialog(
pWin ? pWin->GetFrameWeld() : nullptr, pWin,
xHyphWord->getWord(), xHyphWord->getWord(),
LanguageTag( xHyphWord->getLocale() ).getLanguageType(), LanguageTag( xHyphWord->getLocale() ).getLanguageType(),
xHyph, this )); xHyph, this ));
@ -347,16 +343,16 @@ bool SvxSpellWrapper::SpellNext( )
else else
{ {
// a BODY_area done, ask for the other BODY_area // a BODY_area done, ask for the other BODY_area
WAIT_OFF(); xWait.reset();
const char* pResId = bReverse ? RID_SVXSTR_QUERY_BW_CONTINUE : RID_SVXSTR_QUERY_CONTINUE; const char* pResId = bReverse ? RID_SVXSTR_QUERY_BW_CONTINUE : RID_SVXSTR_QUERY_CONTINUE;
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin,
VclMessageType::Question, VclButtonsType::YesNo, VclMessageType::Question, VclButtonsType::YesNo,
EditResId(pResId))); EditResId(pResId)));
if (xBox->run() != RET_YES) if (xBox->run() != RET_YES)
{ {
// sacrifice the other area if necessary ask for special area // sacrifice the other area if necessary ask for special area
WAIT_ON(); xWait.reset(new weld::WaitObject(pWin));
bStartDone = bEndDone = true; bStartDone = bEndDone = true;
return SpellNext(); return SpellNext();
} }
@ -366,7 +362,7 @@ bool SvxSpellWrapper::SpellNext( )
SpellStart( bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd ); SpellStart( bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd );
bGoOn = true; bGoOn = true;
} }
WAIT_ON(); xWait.reset(new weld::WaitObject(pWin));
} }
return bGoOn; return bGoOn;
} }
@ -419,7 +415,7 @@ bool SvxSpellWrapper::FindSpellError()
{ {
ShowLanguageErrors(); ShowLanguageErrors();
WAIT_ON(); xWait.reset(new weld::WaitObject(pWin));
bool bSpell = true; bool bSpell = true;
Reference< XDictionary > xAllRightDic; Reference< XDictionary > xAllRightDic;
@ -465,7 +461,7 @@ bool SvxSpellWrapper::FindSpellError()
bSpell = SpellNext(); bSpell = SpellNext();
} }
} }
WAIT_OFF(); xWait.reset();
return GetLast().is(); return GetLast().is();
} }

View File

@ -776,10 +776,9 @@ bool OImageControlControl::implInsertGraphics()
// build some arguments for the upcoming dialog // build some arguments for the upcoming dialog
try try
{ {
Reference< XWindowPeer > xWindowPeer = getPeer(); Reference< XWindow > xWindow( static_cast< ::cppu::OWeakObject* >( this ), UNO_QUERY );
VclPtr<vcl::Window> xWin = VCLUnoHelper::GetWindow(xWindowPeer);
::sfx2::FileDialogHelper aDialog(TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic, ::sfx2::FileDialogHelper aDialog(TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic,
xWin ? xWin->GetFrameWeld() : nullptr); Application::GetFrameWeld(xWindow));
aDialog.SetTitle( sTitle ); aDialog.SetTitle( sTitle );
Reference< XFilePickerControlAccess > xController( aDialog.GetFilePicker(), UNO_QUERY_THROW ); Reference< XFilePickerControlAccess > xController( aDialog.GetFilePicker(), UNO_QUERY_THROW );

View File

@ -24,7 +24,7 @@
#include <i18nlangtag/lang.h> #include <i18nlangtag/lang.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <vcl/vclptr.hxx> #include <vcl/weld.hxx>
// forward --------------------------------------------------------------- // forward ---------------------------------------------------------------
@ -34,8 +34,6 @@ namespace com { namespace sun { namespace star { namespace linguistic2 {
class XHyphenator; class XHyphenator;
}}}} }}}}
namespace vcl { class Window; }
// misc functions --------------------------------------------------------------- // misc functions ---------------------------------------------------------------
void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( OUString &rOldText, const OUString &rNewText ); void EDITENG_DLLPUBLIC SvxPrepareAutoCorrect( OUString &rOldText, const OUString &rNewText );
@ -50,7 +48,8 @@ private:
friend class SvxHyphenWordDialog; friend class SvxHyphenWordDialog;
friend struct SvxHyphenWordDialog_Impl; friend struct SvxHyphenWordDialog_Impl;
VclPtr<vcl::Window> pWin; weld::Window* pWin;
std::unique_ptr<weld::WaitObject> xWait;
css::uno::Reference< css::uno::Reference<
css::uno::XInterface > xLast; // result of last spelling/hyphenation attempt css::uno::XInterface > xLast; // result of last spelling/hyphenation attempt
css::uno::Reference< css::uno::Reference<
@ -71,9 +70,9 @@ private:
void operator =(SvxSpellWrapper const &) = delete; void operator =(SvxSpellWrapper const &) = delete;
public: public:
SvxSpellWrapper( vcl::Window* pWn, SvxSpellWrapper( weld::Window* pWn,
const bool bStart, const bool bIsAllRight ); const bool bStart, const bool bIsAllRight );
SvxSpellWrapper( vcl::Window* pWn, SvxSpellWrapper( weld::Window* pWn,
css::uno::Reference< css::linguistic2::XHyphenator > const &xHyphenator, css::uno::Reference< css::linguistic2::XHyphenator > const &xHyphenator,
const bool bStart, const bool bOther ); const bool bStart, const bool bOther );

View File

@ -45,7 +45,7 @@ using namespace ::com::sun::star;
SwHyphWrapper::SwHyphWrapper( SwView* pVw, SwHyphWrapper::SwHyphWrapper( SwView* pVw,
uno::Reference< linguistic2::XHyphenator > const &rxHyph, uno::Reference< linguistic2::XHyphenator > const &rxHyph,
bool bStart, bool bOther, bool bSelect ) : bool bStart, bool bOther, bool bSelect ) :
SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ), SvxSpellWrapper( pVw->GetEditWin().GetFrameWeld(), rxHyph, bStart, bOther ),
pView( pVw ), pView( pVw ),
nPageCount( 0 ), nPageCount( 0 ),
nPageStart( 0 ), nPageStart( 0 ),