36 #include <com/sun/star/document/XFilter.hpp>
37 #include <com/sun/star/document/XImporter.hpp>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 class SwRTFReader :
public Reader
49 const OUString& rFileName)
override;
62 const uno::Reference<text::XTextRange> xInsertPosition
64 auto pSttNdIdx = std::make_shared<SwNodeIndex>(rDoc.
GetNodes());
69 *pSttNdIdx = pPos->nNode.GetIndex() - 1;
73 auto pSttNdIdx2 = std::make_shared<SwNodeIndex>(rDoc.
GetNodes());
74 *pSttNdIdx2 = pPos->nNode.GetIndex();
82 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(
84 uno::Reference<uno::XInterface> xInterface(
85 xMultiServiceFactory->createInstance(
"com.sun.star.comp.Writer.RtfFilter"),
88 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
89 uno::Reference<lang::XComponent> xDstDoc(pDocShell->GetModel(), uno::UNO_QUERY_THROW);
90 xImporter->setTargetDocument(xDstDoc);
92 const uno::Reference<text::XTextRange> xInsertTextRange
95 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
100 {
"TextInsertModeRange",
uno::Any(xInsertTextRange) } }));
104 xFilter->filter(aDescriptor);
106 catch (uno::Exception
const&)
115 if (pSttNdIdx->GetIndex())
123 && pSttNdIdx->GetIndex() + 1 == aNxtIdx.GetIndex())
127 if (aPam.GetPoint()->nNode == aNxtIdx)
129 aPam.GetPoint()->nNode = *pSttNdIdx;
130 aPam.GetPoint()->nContent.Assign(pTextNode, pTextNode->
GetText().getLength());
136 if (pTextNode->
GetText().getLength())
152 if (pSttNdIdx2->GetIndex())
160 && pSttNdIdx2->GetIndex() - 1 == aPrevIdx.GetIndex())
166 if (pTextNode->
GetText().getLength())
186 uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(
188 uno::Reference<uno::XInterface> xInterface(
189 xMultiServiceFactory->createInstance(
"com.sun.star.comp.Writer.RtfFilter"),
192 uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
193 uno::Reference<lang::XComponent> xDstDoc(xDocSh->
GetModel(), uno::UNO_QUERY_THROW);
194 xImporter->setTargetDocument(xDstDoc);
196 uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
203 xFilter->filter(aDescriptor);
Marks a position in the document model.
const OUString & GetText() const
SwDocShell * GetDocShell()
css::uno::Reference< css::frame::XModel > GetModel() const
SAL_DLLPUBLIC_EXPORT Reader * ImportRTF()
IDocumentContentOperations const & getIDocumentContentOperations() const
bool CanJoinNext(SwNodeIndex *pIdx=nullptr) const
Is it possible to join two nodes? In pIdx the second position can be returned.
virtual SwContentNode * JoinNext() override
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
static OUString Read(SvStream &rStream)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
PaM is Point and Mark: a selection of the document model.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
#define TOOLS_WARN_EXCEPTION(area, stream)
const SfxPoolItem * GetNoCondAttr(sal_uInt16 nWhich, bool bInParents) const
Obtains attribute that is not delivered via conditional style!
const SwPosition * GetPoint() const
bool CanJoinPrev(SwNodeIndex *pIdx=nullptr) const
Can we join two Nodes? We can return the 2nd position in pIdx.
virtual SwFormatColl * ChgFormatColl(SwFormatColl *) override
Marks a node in the document model.
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
SwTextNode is a paragraph in the document model.
Reference< XMultiServiceFactory > getProcessServiceFactory()
virtual ErrCode Read(SwDoc &, const OUString &rBaseURL, SwPaM &, const OUString &)=0
bool DoInitNew(SfxMedium *pMedium=nullptr)
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
SwMoveFnCollection const & fnMoveBackward
void CopyCollFormat(SwTextNode &rDestNd, bool bUndoForChgFormatColl=true)
Copy collection with all auto formats to dest-node.
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
#define ERR_SWG_READ_ERROR
SAL_DLLPUBLIC_EXPORT bool TestImportRTF(SvStream &rStream)
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
constexpr TypedWhichId< SfxStringItem > RES_PARATR_LIST_ID(RES_PARATR_LIST_BEGIN)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwTextFormatColl * GetTextColl() const