20#include <com/sun/star/drawing/GraphicExportFilter.hpp>
25#include <sfx2/sfxsids.hrc>
44#include <com/sun/star/beans/PropertyValue.hpp>
45#include <com/sun/star/beans/PropertyValues.hpp>
46#include <com/sun/star/lang/XComponent.hpp>
47#include <com/sun/star/view/XSelectionSupplier.hpp>
49#include <com/sun/star/task/XInteractionHandler.hpp>
50#include <com/sun/star/task/XInteractionRequest.hpp>
51#include <com/sun/star/drawing/GraphicFilterRequest.hpp>
61using namespace ::
sfx2;
65class SdGRFFilter_ImplInteractionHdl :
public ::cppu::WeakImplHelper< css::task::XInteractionHandler >
67 css::uno::Reference< css::task::XInteractionHandler > m_xInter;
72 explicit SdGRFFilter_ImplInteractionHdl( css::uno::Reference< css::task::XInteractionHandler > xInteraction ) :
73 m_xInter(
std::move( xInteraction )),
77 ErrCode const & GetErrorCode()
const {
return nFilterError; };
79 virtual void SAL_CALL handle(
const css::uno::Reference< css::task::XInteractionRequest >& )
override;
84void SdGRFFilter_ImplInteractionHdl::handle(
const css::uno::Reference< css::task::XInteractionRequest >& xRequest )
89 css::drawing::GraphicFilterRequest aErr;
90 if ( xRequest->getRequest() >>= aErr )
91 nFilterError =
ErrCode(aErr.ErrCode);
93 m_xInter->handle( xRequest );
117 pId = STR_IMPORT_GRFILTER_OPENERROR;
119 pId = STR_IMPORT_GRFILTER_IOERROR;
121 pId = STR_IMPORT_GRFILTER_FORMATERROR;
123 pId = STR_IMPORT_GRFILTER_VERSIONERROR;
125 pId = STR_IMPORT_GRFILTER_TOOBIG;
129 pId = STR_IMPORT_GRFILTER_FILTERERROR;
131 if (pId && pId == STR_IMPORT_GRFILTER_IOERROR)
136 VclMessageType::Warning, VclButtonsType::Ok, pId ?
SdResId(pId) : OUString()));
163 const auto nImages = aAnim.
Count();
164 for (
size_t i = 0;
i < nImages - 1; ++
i)
168 for (
size_t nPageIndex = 0; nPageIndex < nImages; ++nPageIndex)
191 MapMode(MapUnit::Map100thMM)));
200 double fGrfWH =
static_cast<double>(aGrfSize.
Width()) / aGrfSize.
Height();
201 double fWinWH =
static_cast<double>(aPagSize.
Width()) / aPagSize.
Height();
209 else if (fGrfWH > 0.F)
229 uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
230 uno::Reference< drawing::XGraphicExportFilter > xExporter = drawing::GraphicExportFilter::create( xContext );
253 uno::Reference< lang::XComponent > xSource( pPage->
getUnoPage(), uno::UNO_QUERY );
262 uno::Reference< task::XInteractionHandler > xInteractionHandler;
264 beans::PropertyValues aArgs;
267 static constexpr OUStringLiteral sFilterName(
u"FilterName" );
270 bool bFilterNameFound =
false;
271 for (
auto& rArg : asNonConstRange(aArgs) )
273 OUString& rStr = rArg.Name;
274 if ( rStr == sFilterName )
276 bFilterNameFound =
true;
277 rArg.Value <<= sShortName;
279 else if ( rStr ==
"InteractionHandler" )
281 uno::Reference< task::XInteractionHandler > xHdl;
282 if ( rArg.Value >>= xHdl )
284 xInteractionHandler =
new SdGRFFilter_ImplInteractionHdl( xHdl );
285 rArg.Value <<= xInteractionHandler;
289 if ( !bFilterNameFound )
291 sal_Int32
nCount = aArgs.getLength();
292 aArgs.realloc(
nCount + 1 );
293 auto pArgs = aArgs.getArray();
294 pArgs[
nCount ].Name = sFilterName;
295 pArgs[
nCount ].Value <<= sShortName;
300 &&
rSet.
Get( SID_SELECTION ).GetValue()
303 uno::Reference< view::XSelectionSupplier > xSelectionSupplier(
305 if ( xSelectionSupplier.is() )
307 uno::Any aSelection( xSelectionSupplier->getSelection() );
308 uno::Reference< lang::XComponent > xSelection;
309 if ( aSelection >>= xSelection )
310 xSource = xSelection;
313 xExporter->setSourceDocument( xSource );
314 bRet = xExporter->filter( aArgs );
315 if ( !bRet && xInteractionHandler.is() )
317 static_cast< SdGRFFilter_ImplInteractionHdl*
>( xInteractionHandler.get() )->GetErrorCode(),
const AnimationFrame & Get(sal_uInt16 nAnimation) const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
GfxLinkType GetType() const
sal_uInt16 GetExportFormatNumberForTypeName(std::u16string_view rType)
sal_uInt16 GetImportFormatNumberForTypeName(std::u16string_view rType)
static GraphicFilter & GetGraphicFilter()
OUString GetExportFormatShortName(sal_uInt16 nFormat)
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
const ErrCode & GetLastError() const
Animation GetAnimation() const
GfxLink GetGfxLink() const
MapMode GetPrefMapMode() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
void setX(tools::Long nX)
void setY(tools::Long nY)
void CreateFirstPages(SdDrawDocument const *pRefDocument=nullptr)
if the document does not contain at least one handout, one slide and one notes page with at least one...
SAL_DLLPRIVATE sal_uInt16 DuplicatePage(sal_uInt16 nPageNum)
This method acts as a simplified front end for the more complex <member>DuplicatePage()</member> meth...
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
::sd::DrawDocShell & mrDocShell
SdDrawDocument & mrDocument
SdGRFFilter(SfxMedium &rMedium, ::sd::DrawDocShell &rDocShell)
virtual ~SdGRFFilter() override
static void InsertSdrGrafObj(Graphic pGraphic, SdPage *pPage)
static void HandleGraphicFilterError(ErrCode nFilterError, ErrCode nStreamError)
sal_uInt16 GetPageCount() const
css::uno::Reference< css::uno::XInterface > const & getUnoPage()
sal_uInt16 GetPageNum() const
sal_Int32 GetUpperBorder() const
sal_Int32 GetRightBorder() const
sal_Int32 GetLeftBorder() const
SdrModel & getSdrModelFromSdrPage() const
sal_Int32 GetLowerBorder() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const std::shared_ptr< const SfxFilter > & GetFilter() const
const INetURLObject & GetURLObject() const
SfxItemSet & GetItemSet() const
css::uno::Reference< css::frame::XController > GetController() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sd::ViewShell * GetViewShell()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual SdPage * GetActualPage() override
PageKind GetPageKind() const
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
#define ERRCODE_IO_GENERAL
#define GRFILTER_FORMAT_NOTFOUND
#define ERRCODE_GRFILTER_OPENERROR
#define ERRCODE_GRFILTER_TOOBIG
#define ERRCODE_GRFILTER_FORMATERROR
#define ERRCODE_GRFILTER_IOERROR
#define ERRCODE_GRFILTER_VERSIONERROR
OUString SdResId(TranslateId aId)
SFX2_DLLPUBLIC void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &aSet, css::uno::Sequence< css::beans::PropertyValue > &seqArgs, const SfxSlot *pSlot=nullptr)