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

move backing component dnd support into the large thumbnail areas

of the backing window

Change-Id: Icf399a8834a25de43909769be08854134991885a
üst f9677116
...@@ -73,9 +73,6 @@ class BackingComp : public css::lang::XTypeProvider ...@@ -73,9 +73,6 @@ class BackingComp : public css::lang::XTypeProvider
/** the owner frame of this component. */ /** the owner frame of this component. */
css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::frame::XFrame > m_xFrame;
/** helper for drag&drop. */
css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > m_xDropTargetListener;
//______________________________________ //______________________________________
// interface // interface
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "backingwindow.hxx" #include "backingwindow.hxx"
#include <svtools/openfiledroptargetlistener.hxx>
#include <helpid.hrc> #include <helpid.hrc>
#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/NamedValue.hpp>
...@@ -31,7 +29,6 @@ ...@@ -31,7 +29,6 @@
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/Toolkit.hpp> #include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/XDataTransferProviderAccess.hpp> #include <com/sun/star/awt/XDataTransferProviderAccess.hpp>
#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
#include <com/sun/star/awt/KeyEvent.hpp> #include <com/sun/star/awt/KeyEvent.hpp>
#include <com/sun/star/awt/KeyModifier.hpp> #include <com/sun/star/awt/KeyModifier.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XLayoutManager.hpp>
...@@ -453,18 +450,6 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f ...@@ -453,18 +450,6 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f
// safe the frame reference // safe the frame reference
m_xFrame = xFrame; m_xFrame = xFrame;
// establish drag&drop mode
OpenFileDropTargetListener* pDropListener = new OpenFileDropTargetListener( m_xContext, m_xFrame);
m_xDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >(static_cast< ::cppu::OWeakObject* >(pDropListener), css::uno::UNO_QUERY);
css::uno::Reference< css::awt::XToolkit2 > xToolkit = css::awt::Toolkit::create( m_xContext );
css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xToolkit->getDropTarget(m_xWindow);
if (xDropTarget.is())
{
xDropTarget->addDropTargetListener(m_xDropTargetListener);
xDropTarget->setActive(sal_True);
}
// initialize the component and it's parent window // initialize the component and it's parent window
css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow(); css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow();
WorkWindow* pParent = (WorkWindow*)VCLUnoHelper::GetWindow(xParentWindow); WorkWindow* pParent = (WorkWindow*)VCLUnoHelper::GetWindow(xParentWindow);
...@@ -668,19 +653,6 @@ void SAL_CALL BackingComp::dispose() ...@@ -668,19 +653,6 @@ void SAL_CALL BackingComp::dispose()
xDispatch->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue>()); xDispatch->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue>());
} }
// deregister drag&drop helper
if (m_xDropTargetListener.is())
{
css::uno::Reference< css::awt::XToolkit2 > xToolkit = css::awt::Toolkit::create( m_xContext );
css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget = xToolkit->getDropTarget(m_xWindow);
if (xDropTarget.is())
{
xDropTarget->removeDropTargetListener(m_xDropTargetListener);
xDropTarget->setActive(sal_False);
}
m_xDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
}
// stop listening at the window // stop listening at the window
if (m_xWindow.is()) if (m_xWindow.is())
{ {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <unotools/dynamicmenuoptions.hxx> #include <unotools/dynamicmenuoptions.hxx>
#include <svtools/langhelp.hxx> #include <svtools/langhelp.hxx>
#include <svtools/openfiledroptargetlistener.hxx>
#include <svtools/colorcfg.hxx> #include <svtools/colorcfg.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
...@@ -127,6 +128,18 @@ BackingWindow::BackingWindow( Window* i_pParent ) : ...@@ -127,6 +128,18 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get( mpImpressTemplateThumbnails, "impress_templates"); get( mpImpressTemplateThumbnails, "impress_templates");
get( mpDrawTemplateThumbnails, "draw_templates"); get( mpDrawTemplateThumbnails, "draw_templates");
maDndWindows.push_back(mpAllRecentThumbnails);
maDndWindows.push_back(mpWriterRecentThumbnails);
maDndWindows.push_back(mpCalcRecentThumbnails);
maDndWindows.push_back(mpImpressRecentThumbnails);
maDndWindows.push_back(mpDrawRecentThumbnails);
maDndWindows.push_back(mpDatabaseRecentThumbnails);
maDndWindows.push_back(mpMathRecentThumbnails);
maDndWindows.push_back(mpWriterTemplateThumbnails);
maDndWindows.push_back(mpCalcTemplateThumbnails);
maDndWindows.push_back(mpImpressTemplateThumbnails);
maDndWindows.push_back(mpDrawTemplateThumbnails);
try try
{ {
mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW ); mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
...@@ -188,6 +201,25 @@ BackingWindow::~BackingWindow() ...@@ -188,6 +201,25 @@ BackingWindow::~BackingWindow()
mpCalcTemplateThumbnails ->setOpenTemplateHdl(Link()); mpCalcTemplateThumbnails ->setOpenTemplateHdl(Link());
mpImpressTemplateThumbnails ->setOpenTemplateHdl(Link()); mpImpressTemplateThumbnails ->setOpenTemplateHdl(Link());
mpDrawTemplateThumbnails ->setOpenTemplateHdl(Link()); mpDrawTemplateThumbnails ->setOpenTemplateHdl(Link());
// deregister drag&drop helper
if (mxDropTargetListener.is())
{
for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
aEnd = maDndWindows.end(); aI != aEnd; ++aI)
{
Window *pDndWin = *aI;
css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
pDndWin->GetDropTarget();
if (xDropTarget.is())
{
xDropTarget->removeDropTargetListener(mxDropTargetListener);
xDropTarget->setActive(false);
}
}
mxDropTargetListener = css::uno::Reference< css::datatransfer::dnd::XDropTargetListener >();
}
} }
IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent ) IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent )
...@@ -416,6 +448,22 @@ void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::s ...@@ -416,6 +448,22 @@ void BackingWindow::setOwningFrame( const com::sun::star::uno::Reference< com::s
mxFrame = xFrame; mxFrame = xFrame;
if( ! mbInitControls ) if( ! mbInitControls )
initControls(); initControls();
// establish drag&drop mode
mxDropTargetListener.set(new OpenFileDropTargetListener(mxContext, mxFrame));
for (std::vector<Window*>::iterator aI = maDndWindows.begin(),
aEnd = maDndWindows.end(); aI != aEnd; ++aI)
{
Window *pDndWin = *aI;
css::uno::Reference< css::datatransfer::dnd::XDropTarget > xDropTarget =
pDndWin->GetDropTarget();
if (xDropTarget.is())
{
xDropTarget->addDropTargetListener(mxDropTargetListener);
xDropTarget->setActive(true);
}
}
} }
void BackingWindow::Resize() void BackingWindow::Resize()
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <svtools/acceleratorexecute.hxx> #include <svtools/acceleratorexecute.hxx>
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XDesktop.hpp>
...@@ -50,6 +51,8 @@ class BackingWindow ...@@ -50,6 +51,8 @@ class BackingWindow
com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider > mxDesktopDispatchProvider; com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider > mxDesktopDispatchProvider;
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> mxFrame; com::sun::star::uno::Reference<com::sun::star::frame::XFrame> mxFrame;
com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2 > mxDesktop; com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2 > mxDesktop;
/** helper for drag&drop. */
com::sun::star::uno::Reference< com::sun::star::datatransfer::dnd::XDropTargetListener > mxDropTargetListener;
PushButton* mpOpenButton; PushButton* mpOpenButton;
PushButton* mpTemplateButton; PushButton* mpTemplateButton;
...@@ -97,6 +100,8 @@ class BackingWindow ...@@ -97,6 +100,8 @@ class BackingWindow
TemplateLocalView* mpImpressTemplateThumbnails; TemplateLocalView* mpImpressTemplateThumbnails;
TemplateLocalView* mpDrawTemplateThumbnails; TemplateLocalView* mpDrawTemplateThumbnails;
std::vector<Window*> maDndWindows;
Rectangle maStartCentButtons; Rectangle maStartCentButtons;
bool mbInitControls; bool mbInitControls;
......
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