25#include <editeng/editeng.hxx>
39#include <svx/svxids.hrc>
41#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
42#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
43#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
44#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
73OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc >
const& rFilterDescList )
75 OUStringBuffer aExtensions;
77 for (
const auto& rFilterDesc : rFilterDescList)
79 OUString sWildcard = rFilterDesc.second;
81 if ( aExtensions.indexOf( sWildcard ) == -1 )
83 if ( !aExtensions.isEmpty() )
84 aExtensions.append(
";");
85 aExtensions.append(sWildcard);
90 return aExtensions.makeStringAndClear();
93void lcl_AddFilter ( ::std::vector< FilterDesc >& rFilterDescList,
94 const std::shared_ptr<const SfxFilter>& pFilter )
97 rFilterDescList.emplace_back( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
111 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
118 xFunc->DoExecute(rReq);
125 ::std::vector< FilterDesc > aFilterVector;
126 ::std::vector< OUString > aOtherFilterVector;
134 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
137 Reference< XFilePicker > xFilePicker( aFileDialog.
GetFilePicker() );
138 Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
146 aOwnCont =
"simpress";
147 aOtherCont =
"sdraw";
151 aOtherCont =
"simpress";
157 if( xFilterManager.is() )
164 lcl_AddFilter( aFilterVector, pFilter );
168 pFilter = DrawDocShell::Factory().GetTemplateFilter();
170 pFilter = GraphicDocShell::Factory().GetTemplateFilter();
171 lcl_AddFilter( aFilterVector, pFilter );
175 lcl_AddFilter( aFilterVector, pFilter );
179 lcl_AddFilter( aFilterVector, pFilter );
182 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
183 lcl_AddFilter( aFilterVector, pFilter );
185 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60, SfxFilterFlags::TEMPLATEPATH );
186 lcl_AddFilter( aFilterVector, pFilter );
188 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
189 lcl_AddFilter( aFilterVector, pFilter );
191 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60, SfxFilterFlags::TEMPLATEPATH );
192 lcl_AddFilter( aFilterVector, pFilter );
194 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
195 lcl_AddFilter( aFilterVector, pFilter );
197 pFilter = aMatch.
GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW, SfxFilterFlags::TEMPLATEPATH );
198 lcl_AddFilter( aFilterVector, pFilter );
201 for(
const auto& rOtherFilter : aOtherFilterVector )
203 if( ( pFilter = rMatcher.
GetFilter4Mime( rOtherFilter ) ) !=
nullptr )
204 lcl_AddFilter( aFilterVector, pFilter );
208 OUString aAllSpec(
SdResId( STR_ALL_SUPPORTED_FORMATS ) );
209 OUString aExtensions = lcl_GetExtensionsList( aFilterVector );
210 OUString aGUIName = aAllSpec +
" (" + aExtensions +
")";
212 xFilterManager->appendFilter( aGUIName, aExtensions );
213 xFilterManager->setCurrentFilter( aAllSpec );
216 for(
const auto& rFilter : aFilterVector )
218 xFilterManager->appendFilter( rFilter.first, rFilter.second );
222 xFilterManager->appendFilter(
SdResId( STR_ALL_FILES ),
"*.*" );
224 catch (
const IllegalArgumentException&)
240 assert(pFileName &&
"must be present");
248 std::unique_ptr<SfxMedium> xMedium(
new SfxMedium(
aFile, StreamMode::READ | StreamMode::NOCREATE));
249 std::shared_ptr<const SfxFilter> pFilter;
254 bool bInserted =
false;
258 xMedium->SetFilter( pFilter );
263 if ( pFilter->GetServiceName() ==
"com.sun.star.presentation.PresentationDocument" ||
264 pFilter->GetServiceName() ==
"com.sun.star.drawing.DrawingDocument" )
279 bool bFound = ( ::std::find( aOtherFilterVector.begin(), aOtherFilterVector.end(), pFilter->GetMimeType() ) != aOtherFilterVector.end() );
307 VclMessageType::Warning, VclButtonsType::Ok,
SdResId(STR_READ_DATA_ERROR)));
321 sal_uInt16 nRet = pDlg->Execute();
329 std::vector<OUString> aBookmarkList = pDlg->GetList( 1 );
330 bool bLink = pDlg->IsLink();
336 if(
auto pOutlineView =
dynamic_cast<OutlineView *
>( pView ))
338 pPage = pOutlineView->GetActualPage();
346 sal_uInt16
nPos = 0xFFFF;
361 std::vector<OUString> aExchangeList;
362 std::vector<OUString> aObjectBookmarkList = pDlg->GetList( 2 );
366 if( !aBookmarkList.empty() || aObjectBookmarkList.empty() )
377 false,
nullptr,
true,
true,
false );
379 aBookmarkList.clear();
380 aExchangeList.clear();
388 nullptr,
nullptr,
false );
390 if( pDlg->IsRemoveUnnecessaryMasterPages() )
404 sal_uInt16 nRet = pDlg->Execute();
414 nFormat = EETextFormat::Rtf;
416 nFormat = EETextFormat::Html;
427 aOutliner.SetRefDevice(
SD_MOD()->GetVirtualRefDevice() );
435 aOutliner.SetPaperSize(pPage->
GetSize());
438 assert(pStream &&
"No InStream!");
443 if (nErr || aOutliner.GetEditEngine().GetText().isEmpty())
446 VclMessageType::Warning, VclButtonsType::Ok,
SdResId(STR_READ_DATA_ERROR)));
458 assert(pPage &&
"page not found");
468 aOutliner.GetParagraphCount() > 1 )
471 while ( aOutliner.GetParagraphCount() > 1 )
473 Paragraph* pPara = aOutliner.GetParagraph( 0 );
474 sal_uLong nLen = aOutliner.GetText( pPara ).getLength();
475 aOutliner.QuickDelete(
ESelection( 0, nLen, 1, 0 ) );
476 aOutliner.QuickInsertLineBreak(
ESelection( 0, nLen, 0, nLen ) );
492 pTO->SetOutlinerParaObject(std::move(pOPO));
501 Size aSize(aOutliner.CalcTextSize());
505 aSize =
mpWindow->LogicToPixel(aSize);
512 aSize =
mpWindow->PixelToLogic(aSize);
513 aPos =
mpWindow->PixelToLogic(aPos);
536 nFormat = EETextFormat::Rtf;
538 nFormat = EETextFormat::Html;
542 std::vector<Paragraph*> aSelList;
545 Paragraph* pPara = aSelList.empty() ? nullptr : *(aSelList.begin());
551 sal_Int32 nTargetPos = rDocliner.
GetAbsPos(pPara) + 1;
554 sal_uInt16 nPage = 0;
591 VclMessageType::Warning, VclButtonsType::Ok,
SdResId(STR_READ_DATA_ERROR)));
599 sal_uInt16 nNewPages = 0;
611 std::optional<SfxProgress> pProgress( std::in_place,
mpDocSh,
SdResId(STR_CREATE_PAGES), nNewPages);
612 pProgress->SetState( 0, 100 );
618 SdResId(STR_UNDO_INSERT_FILE), OUString(), 0, nViewShellId );
620 sal_Int32 nSourcePos = 0;
629 if (nSourcePos < nParaCount - 1 ||
630 !aOutliner.
GetText(pSourcePara).isEmpty())
632 rDocliner.
Insert( aOutliner.
GetText(pSourcePara), nTargetPos, nDepth );
633 OUString aStyleSheetName( pStyleSheet->
GetName() );
634 aStyleSheetName = aStyleSheetName.subView( 0, aStyleSheetName.getLength()-1 ) +
635 OUString::number( nDepth <= 0 ? 1 : nDepth+1 );
644 pProgress->SetState( nNewPages );
707 std::shared_ptr<const SfxFilter> pSearchFilter;
709 rFilterVector.clear();
711 if( ( pSearchFilter = rMatcher.
GetFilter4Mime(
"text/plain" )) !=
nullptr )
712 rFilterVector.push_back( pSearchFilter->GetMimeType() );
714 if( ( pSearchFilter = rMatcher.
GetFilter4Mime(
"application/rtf" ) ) !=
nullptr )
715 rFilterVector.push_back( pSearchFilter->GetMimeType() );
717 if( ( pSearchFilter = rMatcher.
GetFilter4Mime(
"text/html" ) ) !=
nullptr )
718 rFilterVector.push_back( pSearchFilter->GetMimeType() );
SfxApplication * SfxGetpApp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
void InsertText(const OUString &rNew, bool bSelect=false)
void CreateSelectionList(std::vector< Paragraph * > &aSelList)
Outliner * GetOutliner() const
static bool HasParaFlag(const Paragraph *pPara, ParaFlag nFlag)
void SetEndMovingHdl(const Link< Outliner *, void > &rLink)
OUString GetText(Paragraph const *pPara, sal_Int32 nParaCount=1) const
const EditEngine & GetEditEngine() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
const Link< DepthChangeHdlParam, void > & GetDepthChangedHdl() const
void SetPaperSize(const Size &rSize)
sal_Int16 GetDepth(sal_Int32 nPara) const
void SetStyleSheet(sal_Int32 nPara, SfxStyleSheet *pStyle)
const Link< ParagraphHdlParam, void > & GetParaInsertedHdl() const
OutlinerView * GetView(size_t nIndex) const
Paragraph * GetParent(Paragraph const *pParagraph) const
sal_Int32 GetAbsPos(Paragraph const *pPara) const
void SetStatusEventHdl(const Link< EditStatus &, void > &rLink)
SfxUndoManager & GetUndoManager()
void SetParaInsertedHdl(const Link< ParagraphHdlParam, void > &rLink)
void SetStyleSheetPool(SfxStyleSheetPool *pSPool)
void SetRefDevice(OutputDevice *pRefDev)
void SetParaRemovingHdl(const Link< ParagraphHdlParam, void > &rLink)
void SetBeginMovingHdl(const Link< Outliner *, void > &rLink)
ErrCode Read(SvStream &rInput, const OUString &rBaseURL, EETextFormat, SvKeyValueIterator *pHTTPHeaderAttrs=nullptr)
Paragraph * Insert(const OUString &rText, sal_Int32 nAbsPos=EE_PARA_APPEND, sal_Int16 nDepth=0)
const Link< ParagraphHdlParam, void > & GetParaRemovingHdl() const
const Link< Outliner *, void > & GetEndMovingHdl() const
void SetDepthChangedHdl(const Link< DepthChangeHdlParam, void > &rLink)
Link< EditStatus &, void > const & GetStatusEventHdl() const
const Link< Outliner *, void > & GetBeginMovingHdl() const
sal_Int32 GetParagraphCount() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
virtual VclPtr< AbstractSdInsertPagesObjsDlg > CreateSdInsertPagesObjsDlg(weld::Window *pParent, const SdDrawDocument *pDoc, SfxMedium *pSfxMedium, const OUString &rFileName)=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector< OUString > &rBookmarkList, std::vector< OUString > *pExchangeList, bool bLink, bool bReplace, sal_uInt16 nPgPos, bool bNoDialogs, ::sd::DrawDocShell *pBookmarkDocSh, bool bCopy, bool bMergeMasterPages, bool bPreservePageNames)
Insert pages into this document.
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
SAL_DLLPRIVATE bool InsertBookmarkAsObject(const std::vector< OUString > &rBookmarkList, const std::vector< OUString > &rExchangeList, ::sd::DrawDocShell *pBookmarkDocSh, Point const *pObjPos, bool bCalcObjCount)
SAL_DLLPRIVATE void RemoveUnnecessaryMasterPages(SdPage *pMaster=nullptr, bool bOnlyDuplicatePages=false, bool bUndo=true)
SAL_DLLPRIVATE DocumentType GetDocumentType() const
The main purpose of this class is searching and replacing as well as spelling of impress documents.
PageKind GetPageKind() const
SfxStyleSheet * GetStyleSheetForPresObj(PresObjKind eObjKind) const
virtual OUString GetLayoutName() const override
bool IsUndoEnabled() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
const SfxItemPool & GetItemPool() const
const Size & GetMaxObjSize() const
SfxStyleSheetBasePool * GetStyleSheetPool() const
SdrUndoFactory & GetSdrUndoFactory() const
SdrTextObj * GetTextEditObject() const
const OutlinerView * GetTextEditOutlinerView() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * GetPage() const
SdrPage & TRG_GetMasterPage() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoInsertObject(SdrObject &rObject, bool bOrdNumDirect=false)
SfxFilterMatcher & GetFilterMatcher()
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4ClipBoardId(SotClipboardFormatId nId, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4Extension(const OUString &rExt, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4Mime(const OUString &rMime, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
static std::shared_ptr< const SfxFilter > GetDefaultFilterFromFactory(const OUString &rServiceName)
OUString GetBaseURL(bool bForSaving=false)
void SetWaitCursor(bool bSet) const
SvKeyValueIterator * GetHeaderAttributes()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
ViewShellId GetViewShellId() const override
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static bool IsStorageFile(OUString const &rFileName)
sal_uInt64 Seek(sal_uInt64 nPos)
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual void DoExecute(SfxRequest &rReq) override
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
OUString aFile
chosen file name
FuInsertFile(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
void InsTextOrRTFinOlMode(SfxMedium *pMedium)
OUString aFilterName
chosen file filter
bool InsSDDinDrMode(SfxMedium *pMedium)
bool InsSDDinOlMode(SfxMedium *pMedium)
static void GetSupportedFilterVector(::std::vector< OUString > &rFilterVector)
void InsTextOrRTFinDrMode(SfxMedium *pMedium)
OUString aLayoutName
layout name of the currently inserted page
Base class for all functions.
VclPtr< ::sd::Window > mpWindow
Derivative of sd::View for the outline mode |* .
void FillOutliner()
creates outliner model from draw model
OutlinerView * GetViewByWindow(vcl::Window const *pWin) const
Return a pointer to the OutlinerView corresponding to the window.
void PrepareClose()
updates draw model with all changes from outliner model
Base class of the stacked shell hierarchy.
::sd::View * GetView() const
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
bool GetExchangeList(std::vector< OUString > &rExchangeList, std::vector< OUString > &rBookmarkList, const sal_uInt16 nType)
return parameter: pExchangeList == NULL -> all names are unique bNameOK == false -> cancel by user nT...
An SdWindow contains the actual working area of ViewShell.
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
void SetTitle(const OUString &rNewTitle)
OUString GetCurrentFilter() const
void SetContext(Context _eNewContext)
#define DBG_ASSERT(sCon, aError)
::std::pair< OUString, OUString > FilterDesc
constexpr OUStringLiteral SD_LT_SEPARATOR
OUString SdResId(TranslateId aId)