24#include <com/sun/star/drawing/framework/XControllerManager.hpp>
25#include <com/sun/star/lang/IllegalArgumentException.hpp>
50using ::sd::framework::FrameworkHelper;
62 static bool CompareView (
const std::shared_ptr<ViewDescriptor>& rpDescriptor,
63 const Reference<XResource>& rxView)
64 {
return rpDescriptor->mxView.get() == rxView.get(); }
70 :
public ::std::vector<std::shared_ptr<ViewDescriptor> >
77 :
public ::std::vector<std::shared_ptr<ViewDescriptor> >
96 mpBase = rxController->GetViewShellBase();
145 OSL_ASSERT(rxView->mpViewShell.use_count() == 1);
151 const Reference<XResourceId>& rxViewId)
153 Reference<XResource> xView;
154 const bool bIsCenterPane (
158 Reference<XPane> xPane;
164 if (xPane.is() && bIsCenterPane)
179 if (pFrame !=
nullptr &&
mpBase!=
nullptr && pWindow!=
nullptr)
182 std::shared_ptr<ViewDescriptor> pDescriptor (
GetViewFromCache(rxViewId, xPane));
185 if (pDescriptor ==
nullptr)
187 pDescriptor =
CreateView(rxViewId, *pFrame, *pWindow, xPane, pFrameView, bIsCenterPane);
190 xView = pDescriptor->mxView;
206 throw lang::IllegalArgumentException();
208 if (!rxView.is() || !
mpBase)
211 ViewShellContainer::iterator iViewShell (
215 [&] (std::shared_ptr<ViewDescriptor>
const& pVD) {
216 return ViewDescriptor::CompareView(pVD, rxView);
220 throw lang::IllegalArgumentException();
223 std::shared_ptr<ViewShell> pViewShell ((*iViewShell)->mpViewShell);
225 if ((*iViewShell)->mxViewId->isBoundToURL(
241 Reference<drawing::XDrawSubController>());
244 if (pSfxViewShell !=
nullptr)
254 const Reference<XResourceId>& rxViewId,
257 const Reference<XPane>& rxPane,
259 const bool bIsCenterPane)
261 auto pDescriptor = std::make_shared<ViewDescriptor>();
268 pDescriptor->mxViewId = rxViewId;
270 if (pDescriptor->mpViewShell !=
nullptr)
272 pDescriptor->mpViewShell->Init(bIsCenterPane);
275 Reference<awt::XWindow> xWindow(rxPane->getWindow());
277 pDescriptor->mpViewShell,
284 xWindow->addWindowListener(wrapper);
285 if (pDescriptor->mpViewShell !=
nullptr)
287 pDescriptor->mpViewShell->Resize();
291 pDescriptor->mxView = wrapper.get();
298 const Reference<XResourceId>& rxViewId,
303 std::shared_ptr<ViewShell> pViewShell;
304 const OUString& rsViewURL (rxViewId->getResourceURL());
308 std::make_shared<DrawViewShell>(
313 pViewShell->GetContentWindow()->set_id(
"impress_win");
317 pViewShell = std::shared_ptr<GraphicViewShell>(
320 pViewShell->GetContentWindow()->set_id(
"draw_win");
325 std::make_shared<OutlineViewShell>(
330 pViewShell->GetContentWindow()->set_id(
"outline_win");
335 std::make_shared<DrawViewShell>(
340 pViewShell->GetContentWindow()->set_id(
"notes_win");
345 std::make_shared<DrawViewShell>(
350 pViewShell->GetContentWindow()->set_id(
"handout_win");
355 std::make_shared<PresentationViewShell>(
359 pViewShell->GetContentWindow()->set_id(
"presentation_win");
368 pViewShell->GetContentWindow()->set_id(
"slidesorter");
375 const std::shared_ptr<ViewDescriptor>& rpDescriptor,
378 bool bIsCacheable (!bDoNotCache &&
IsCacheable(rpDescriptor));
382 Reference<XRelocatableResource> xResource (rpDescriptor->mxView, UNO_QUERY);
389 bIsCacheable =
false;
391 bIsCacheable =
false;
395 bIsCacheable =
false;
402 rpDescriptor->mpViewShell->Shutdown ();
406 Reference<XComponent> xComponent (rpDescriptor->mxView, UNO_QUERY);
408 xComponent->dispose();
414 bool bIsCacheable (
false);
416 Reference<XRelocatableResource> xResource (rpDescriptor->mxView, UNO_QUERY);
419 static ::std::vector<Reference<XResourceId> > s_aCacheableResources = [&]()
421 ::std::vector<Reference<XResourceId> > tmp;
432 bIsCacheable = std::any_of(s_aCacheableResources.begin(), s_aCacheableResources.end(),
433 [&rpDescriptor](
const Reference<XResourceId>& rxId) { return rxId->compareTo(rpDescriptor->mxViewId) == 0; });
440 const Reference<XResourceId>& rxViewId,
441 const Reference<XPane>& rxPane)
443 std::shared_ptr<ViewDescriptor> pDescriptor;
447 [&rxViewId](
const ViewCache::value_type& rxEntry) { return rxEntry->mxViewId->compareTo(rxViewId) == 0; });
450 pDescriptor = *iEntry;
456 if (pDescriptor !=
nullptr)
458 bool bRelocationSuccessful (
false);
459 Reference<XRelocatableResource> xResource (pDescriptor->mxView, UNO_QUERY);
460 if (xResource.is() && rxPane.is())
462 if (xResource->relocateToAnchor(rxPane))
463 bRelocationSuccessful =
true;
466 if ( ! bRelocationSuccessful)
477 const std::shared_ptr<ViewDescriptor>& rpDescriptor)
484 rpDescriptor->mpViewShell->UIFeatureChanged();
489 rpDescriptor->mpViewShell->CreateSubController());
bool IsInPlaceActive() const
SfxViewShell * GetViewShell() const
void Resize(bool bForce=false)
void DisconnectAllClients()
SfxViewFrame & GetViewFrame() const
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
void SetSubController(const css::uno::Reference< css::drawing::XDrawSubController > &rxSubController)
Replace the currently used sub controller with the given one.
void Connect(sd::ViewShell *pViewSh)
void Disconnect(sd::ViewShell const *pViewSh)
View shell of the Draw application.
DrawController * GetDrawController() const
std::shared_ptr< ViewShellManager > const & GetViewShellManager() const
DrawDocShell * GetDocShell() const
Reference< XResource > mxView
Reference< XResourceId > mxViewId
static bool CompareView(const std::shared_ptr< ViewDescriptor > &rpDescriptor, const Reference< XResource > &rxView)
std::shared_ptr< sd::ViewShell > mpViewShell
virtual void disposing(std::unique_lock< std::mutex > &) override
std::unique_ptr< ViewShellContainer > mpViewShellContainer
std::shared_ptr< ViewCache > mpViewCache
std::shared_ptr< ViewDescriptor > CreateView(const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, SfxViewFrame &rFrame, vcl::Window &rWindow, const css::uno::Reference< css::drawing::framework::XPane > &rxPane, FrameView *pFrameView, const bool bIsCenterView)
css::uno::Reference< css::drawing::framework::XConfigurationController > mxConfigurationController
BasicViewFactory(const rtl::Reference<::sd::DrawController > &rxController)
void ReleaseView(const std::shared_ptr< ViewDescriptor > &rpDescriptor, bool bDoNotCache)
virtual css::uno::Reference< css::drawing::framework::XResource > SAL_CALL createResource(const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId) override
std::shared_ptr< ViewShell > CreateViewShell(const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, SfxViewFrame &rFrame, vcl::Window &rWindow, FrameView *pFrameView)
void ActivateCenterView(const std::shared_ptr< ViewDescriptor > &rpDescriptor)
virtual ~BasicViewFactory() override
bool IsCacheable(const std::shared_ptr< ViewDescriptor > &rpDescriptor)
virtual void SAL_CALL releaseResource(const css::uno::Reference< css::drawing::framework::XResource > &xView) override
std::shared_ptr< ViewDescriptor > GetViewFromCache(const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId, const css::uno::Reference< css::drawing::framework::XPane > &rxPane)
css::uno::Reference< css::drawing::framework::XPane > mxLocalPane
static css::uno::Reference< css::drawing::framework::XResourceId > CreateResourceId(const OUString &rsResourceURL)
Create a new XResourceId object for the given resource URL.
static const OUString msHandoutViewURL
static const OUString msCenterPaneURL
static const OUString msLeftDrawPaneURL
static const OUString msNotesViewURL
static const OUString msOutlineViewURL
static const OUString msPresentationViewURL
static const OUString msSlideSorterURL
static ::std::shared_ptr< FrameworkHelper > Instance(ViewShellBase &rBase)
Return the FrameworkHelper object that is associated with the given ViewShellBase.
static const OUString msLeftImpressPaneURL
static const OUString msDrawViewURL
static const OUString msImpressViewURL
A pane is a wrapper for a window and possibly for a tab bar (for view switching).
This class wraps ViewShell objects and makes them look like an XView.
static std::shared_ptr< SlideSorterViewShell > Create(SfxViewFrame *pFrame, ViewShellBase &rViewShellBase, vcl::Window *pParentWindow, FrameView *pFrameView)
std::shared_ptr< T > make_shared(Args &&... args)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
VclPtr< vcl::Window > mpWindow