Kaydet (Commit) 430b3f4d authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#120423 dispatch against the correct Frame

Change-Id: I5ea2e5d7b79efbd2b14d0b528e5a5c3e44e643bc
Reviewed-on: https://gerrit.libreoffice.org/72284
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst f264b2ff
......@@ -168,7 +168,7 @@ void ChartController::executeDispatch_InsertSpecialCharacter()
aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) );
vcl::Window* pWin = GetChartWindow();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pWin ? pWin->GetFrameWeld() : nullptr, aSet, false));
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pWin ? pWin->GetFrameWeld() : nullptr, aSet, nullptr));
if( pDlg->Execute() == RET_OK )
{
const SfxItemSet* pSet = pDlg->GetOutputItemSet();
......
......@@ -31,22 +31,15 @@ using namespace css;
namespace comphelper {
bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArguments, const uno::Reference<css::frame::XDispatchResultListener>& aListener)
bool dispatchCommand(const OUString& rCommand, const uno::Reference<css::frame::XFrame>& rFrame, const css::uno::Sequence<css::beans::PropertyValue>& rArguments, const uno::Reference<css::frame::XDispatchResultListener>& rListener)
{
// Target where we will execute the .uno: command
uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
uno::Reference<frame::XFrame> xFrame(xDesktop->getActiveFrame());
if (!xFrame.is())
xFrame.set(xDesktop, uno::UNO_QUERY);
uno::Reference<frame::XDispatchProvider> xDispatchProvider(xFrame, uno::UNO_QUERY);
uno::Reference<frame::XDispatchProvider> xDispatchProvider(rFrame, uno::UNO_QUERY);
if (!xDispatchProvider.is())
return false;
util::URL aCommandURL;
aCommandURL.Complete = rCommand;
uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
uno::Reference<util::XURLTransformer> xParser = util::URLTransformer::create(xContext);
xParser->parseStrict(aCommandURL);
......@@ -57,13 +50,26 @@ bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::bea
// And do the work...
uno::Reference<frame::XNotifyingDispatch> xNotifyingDisp(xDisp, uno::UNO_QUERY);
if (xNotifyingDisp.is())
xNotifyingDisp->dispatchWithNotification(aCommandURL, rArguments, aListener);
xNotifyingDisp->dispatchWithNotification(aCommandURL, rArguments, rListener);
else
xDisp->dispatch(aCommandURL, rArguments);
return true;
}
bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArguments, const uno::Reference<css::frame::XDispatchResultListener>& rListener)
{
// Target where we will execute the .uno: command
uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
uno::Reference<frame::XFrame> xFrame(xDesktop->getActiveFrame());
if (!xFrame.is())
xFrame.set(xDesktop, uno::UNO_QUERY);
return dispatchCommand(rCommand, xFrame, rArguments, rListener);
}
} // namespace comphelper
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -51,11 +51,12 @@
using namespace css;
SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, bool bInsert)
SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet,
const css::uno::Reference<css::frame::XFrame>& rFrame)
: SfxDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog")
, m_xVirDev(VclPtr<VirtualDevice>::Create())
, isSearchMode(true)
, m_bHasInsert(bInsert)
, m_xFrame(rFrame)
, mxContext(comphelper::getProcessComponentContext())
, m_aRecentCharView{SvxCharView(m_xVirDev),
SvxCharView(m_xVirDev),
......@@ -90,7 +91,7 @@ SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet,
SvxCharView(m_xVirDev),
SvxCharView(m_xVirDev)}
, m_aShowChar(m_xVirDev)
, m_xOKBtn(bInsert ? m_xBuilder->weld_button("insert") : m_xBuilder->weld_button("ok"))
, m_xOKBtn(m_xFrame.is() ? m_xBuilder->weld_button("insert") : m_xBuilder->weld_button("ok"))
, m_xFontText(m_xBuilder->weld_label("fontft"))
, m_xFontLB(m_xBuilder->weld_combo_box("fontlb"))
, m_xSubsetText(m_xBuilder->weld_label("subsetft"))
......@@ -511,13 +512,15 @@ void SvxCharacterMap::init()
getFavCharacterList();
updateFavCharControl();
bool bHasInsert = m_xFrame.is();
for(int i = 0; i < 16; i++)
{
m_aRecentCharView[i].SetHasInsert(m_bHasInsert);
m_aRecentCharView[i].SetHasInsert(bHasInsert);
m_aRecentCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
m_aRecentCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, RecentClearClickHdl));
m_aRecentCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, RecentClearAllClickHdl));
m_aFavCharView[i].SetHasInsert(m_bHasInsert);
m_aFavCharView[i].SetHasInsert(bHasInsert);
m_aFavCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
m_aFavCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, FavClearClickHdl));
m_aFavCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl));
......@@ -607,7 +610,7 @@ void SvxCharacterMap::insertCharToDoc(const OUString& sGlyph)
if(sGlyph.isEmpty())
return;
if (m_bHasInsert) {
if (m_xFrame.is()) {
uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
uno::Sequence<beans::PropertyValue> aArgs(2);
......@@ -616,7 +619,7 @@ void SvxCharacterMap::insertCharToDoc(const OUString& sGlyph)
aArgs[1].Name = "FontName";
aArgs[1].Value <<= aFont.GetFamilyName();
comphelper::dispatchCommand(".uno:InsertSymbol", aArgs);
comphelper::dispatchCommand(".uno:InsertSymbol", m_xFrame, aArgs);
updateRecentCharacterList(sGlyph, aFont.GetFamilyName());
......
......@@ -1286,16 +1286,17 @@ VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxLineTabDialog(
return VclPtr<CuiAbstractTabController_Impl>::Create(std::make_unique<SvxLineTabDialog>(pParent, pAttr, pModel, pObj,bHasObj));
}
VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateCharMapDialog(weld::Window* pParent, const SfxItemSet& rAttr, bool bInsert)
VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateCharMapDialog(weld::Window* pParent, const SfxItemSet& rAttr,
const Reference< XFrame >& rDocumentFrame)
{
return VclPtr<AbstractSvxCharacterMapDialog_Impl>::Create(std::make_unique<SvxCharacterMap>(pParent, &rAttr, bInsert));
return VclPtr<AbstractSvxCharacterMapDialog_Impl>::Create(std::make_unique<SvxCharacterMap>(pParent, &rAttr, rDocumentFrame));
}
VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateEventConfigDialog(weld::Window* pParent,
const SfxItemSet& rAttr,
const Reference< XFrame >& _rxDocumentFrame)
const Reference< XFrame >& rDocumentFrame)
{
return VclPtr<CuiAbstractSingleTabController_Impl>::Create(std::make_unique<SfxMacroAssignDlg>(pParent, _rxDocumentFrame, rAttr));
return VclPtr<CuiAbstractSingleTabController_Impl>::Create(std::make_unique<SfxMacroAssignDlg>(pParent, rDocumentFrame, rAttr));
}
VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateSfxDialog(weld::Window* pParent,
......
......@@ -684,10 +684,10 @@ public:
sal_uInt32 nResId ) override;
virtual VclPtr<SfxAbstractDialog> CreateCharMapDialog(weld::Window* pParent,
const SfxItemSet& rAttr,
bool bInsert) override;
const css::uno::Reference< css::frame::XFrame >& rFrame) override;
virtual VclPtr<SfxAbstractDialog> CreateEventConfigDialog(weld::Window* pParent,
const SfxItemSet& rAttr,
const css::uno::Reference< css::frame::XFrame >& _rxFrame) override;
const css::uno::Reference< css::frame::XFrame >& rFrame) override;
virtual VclPtr<VclAbstractDialog> CreateFrameDialog(vcl::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame,
sal_uInt32 nResId,
const OUString& rParameter ) override;
......
......@@ -26,7 +26,7 @@ extern "C"
SAL_DLLPUBLIC_EXPORT bool GetSpecialCharsForEdit(vcl::Window const * i_pParent, const vcl::Font& i_rFont, OUString& o_rResult)
{
bool bRet = false;
SvxCharacterMap aDlg(i_pParent ? i_pParent->GetFrameWeld() : nullptr, nullptr, false);
SvxCharacterMap aDlg(i_pParent ? i_pParent->GetFrameWeld() : nullptr, nullptr, nullptr);
aDlg.DisableFontSelection();
aDlg.SetCharFont(i_rFont);
if (aDlg.run() == RET_OK)
......
......@@ -74,7 +74,7 @@ private:
vcl::Font aFont;
std::unique_ptr<const SubsetMap> pSubsetMap;
bool isSearchMode;
bool m_bHasInsert;
css::uno::Reference<css::frame::XFrame> m_xFrame;
std::deque<OUString> maRecentCharList;
std::deque<OUString> maRecentCharFontList;
std::deque<OUString> maFavCharList;
......@@ -136,7 +136,8 @@ private:
void selectCharByCode(Radix radix);
public:
SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, const bool bInsert=true);
SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet,
const css::uno::Reference<css::frame::XFrame>& rFrame);
virtual short run() override;
void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
......
......@@ -619,7 +619,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void)
int nSelEntryPos = m_xCheckLB->get_selected_index();
if (nSelEntryPos == REPLACE_BULLETS || nSelEntryPos == APPLY_NUMBERING)
{
SvxCharacterMap aMapDlg(GetDialogFrameWeld(), nullptr, false);
SvxCharacterMap aMapDlg(GetDialogFrameWeld(), nullptr, nullptr);
ImpUserData* pUserData = reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos).toInt64());
aMapDlg.SetCharFont(*pUserData->pFont);
aMapDlg.SetChar( (*pUserData->pString)[0] );
......@@ -1751,7 +1751,7 @@ IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void)
else if (&rBtn == m_xDblEndQuotePB.get())
nMode = DBL_END;
// start character selection dialog
SvxCharacterMap aMap(GetDialogFrameWeld(), nullptr, false);
SvxCharacterMap aMap(GetDialogFrameWeld(), nullptr, nullptr);
aMap.SetCharFont( OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT,
LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne ));
aMap.set_title(nMode < SGL_END ? CuiResId(RID_SVXSTR_STARTQUOTE) : CuiResId(RID_SVXSTR_ENDQUOTE));
......
......@@ -3115,7 +3115,7 @@ void SvxCharTwoLinesPage::Initialize()
void SvxCharTwoLinesPage::SelectCharacter(weld::TreeView* pBox)
{
bool bStart = pBox == m_xStartBracketLB.get();
SvxCharacterMap aDlg(GetFrameWeld(), nullptr, false);
SvxCharacterMap aDlg(GetFrameWeld(), nullptr, nullptr);
aDlg.DisableFontSelection();
if (aDlg.run() == RET_OK)
......
......@@ -1950,7 +1950,7 @@ IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl, weld::ToggleButton&
IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl, weld::Button&, void)
{
SvxCharacterMap aMap(GetDialogFrameWeld(), nullptr, false);
SvxCharacterMap aMap(GetDialogFrameWeld(), nullptr, nullptr);
sal_uInt16 nMask = 1;
const vcl::Font* pFmtFont = nullptr;
......
......@@ -15,7 +15,7 @@
#include <com/sun/star/uno/Reference.hxx>
namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }
namespace com { namespace sun { namespace star { namespace frame { class XDispatchResultListener; } } } }
namespace com { namespace sun { namespace star { namespace frame { class XDispatchResultListener; class XFrame; } } } }
namespace com { namespace sun { namespace star { namespace uno { template <typename > class Sequence; } } } }
namespace comphelper
......@@ -29,7 +29,12 @@ namespace comphelper
*/
COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
const css::uno::Reference<css::frame::XDispatchResultListener>& aListener = css::uno::Reference<css::frame::XDispatchResultListener>());
const css::uno::Reference<css::frame::XDispatchResultListener>& rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
const css::uno::Reference<css::frame::XFrame>& rFrame,
const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
const css::uno::Reference<css::frame::XDispatchResultListener>& rListener = css::uno::Reference<css::frame::XDispatchResultListener>());
}
......
......@@ -425,7 +425,8 @@ public:
const SfxItemSet& rAttr,
const SdrView* pView,
sal_uInt32 nResId )=0;
virtual VclPtr<SfxAbstractDialog> CreateCharMapDialog(weld::Window* pParent, const SfxItemSet& rAttr, bool bInsert) = 0;
virtual VclPtr<SfxAbstractDialog> CreateCharMapDialog(weld::Window* pParent, const SfxItemSet& rAttr,
const css::uno::Reference<css::frame::XFrame>& rFrame) = 0;
virtual VclPtr<SfxAbstractDialog> CreateEventConfigDialog(weld::Window* pParent, const SfxItemSet& rAttr,
const css::uno::Reference< css::frame::XFrame >& _rxFrame) = 0;
virtual VclPtr<AbstractSvxPostItDialog> CreateSvxPostItDialog(weld::Widget* pParent, const SfxItemSet& rCoreSet, bool bPrevNext = false) = 0;
......
......@@ -2470,8 +2470,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
SfxAllItemSet aSet( GetPool() );
aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, true));
SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame));
pDlg->Execute();
}
break;
......
......@@ -332,7 +332,8 @@ void ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
SfxAllItemSet aSet( rFrame.GetObjectShell()->GetPool() );
aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rFrame.GetWindow().GetFrameWeld(), aSet, true));
auto xFrame = rFrame.GetFrame().GetFrameInterface();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rFrame.GetWindow().GetFrameWeld(), aSet, xFrame));
pDlg->Execute();
}
......
......@@ -191,8 +191,9 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & rReq )
aSet.Put( *pFontItem );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
auto xFrame = mpViewShell ? mpViewShell->GetFrame()->GetFrame().GetFrameInterface() : nullptr;
ScopedVclPtr<SfxAbstractDialog> pDlg( pFact->CreateCharMapDialog(mpView->GetViewShell()->GetFrameWeld(), aSet,
true ) );
xFrame) );
// If a character is selected, it can be shown
// pDLg->SetFont( );
......
......@@ -104,7 +104,7 @@ IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl, weld::Button&, void)
aAllSet.Put( rFont );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(m_xDialog.get(), aAllSet, false));
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(m_xDialog.get(), aAllSet, nullptr));
if (RET_OK == pDlg->Execute())
{
const SfxStringItem* pItem = SfxItemSet::GetItem<SfxStringItem>(pDlg->GetOutputItemSet(), SID_CHARMAP, false);
......
......@@ -333,7 +333,7 @@ IMPL_LINK_NOARG(SwSortDlg, DelimCharHdl, weld::Button&, void)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAllItemSet aSet( rSh.GetAttrPool() );
aSet.Put( SfxInt32Item( SID_ATTR_CHAR, GetDelimChar() ) );
ScopedVclPtr<SfxAbstractDialog> pMap(pFact->CreateCharMapDialog(m_xDialog.get(), aSet, false));
ScopedVclPtr<SfxAbstractDialog> pMap(pFact->CreateCharMapDialog(m_xDialog.get(), aSet, nullptr));
if( RET_OK == pMap->Execute() )
{
const SfxInt32Item* pItem = SfxItemSet::GetItem<SfxInt32Item>(pMap->GetOutputItemSet(), SID_ATTR_CHAR, false);
......
......@@ -1757,7 +1757,8 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont->GetFamilyName() ) );
// If character is selected then it can be shown.
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rView.GetFrameWeld(), aAllSet, true));
auto xFrame = rView.GetViewFrame()->GetFrame().GetFrameInterface();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rView.GetFrameWeld(), aAllSet, xFrame));
pDlg->Execute();
return;
}
......
......@@ -729,7 +729,8 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
// If character is selected, it can be shown
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rView.GetFrameWeld(), aAllSet, true));
auto xFrame = rView.GetViewFrame()->GetFrame().GetFrameInterface();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rView.GetFrameWeld(), aAllSet, xFrame));
pDlg->Execute();
return;
}
......
......@@ -942,7 +942,8 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont->GetFamilyName() ) );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, true));
auto xFrame = GetView().GetViewFrame()->GetFrame().GetFrameInterface();
ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetView().GetFrameWeld(), aAllSet, xFrame));
pDlg->Execute();
return;
}
......
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