LibreOffice Module xmloff (master)  1
txtimp.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_XMLOFF_TXTIMP_HXX
20 #define INCLUDED_XMLOFF_TXTIMP_HXX
21 
22 #include <sal/config.h>
23 #include <xmloff/dllapi.h>
24 #include <sal/types.h>
25 #include <rtl/ustring.hxx>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/uno/Sequence.hxx>
28 
29 #include <map>
30 #include <memory>
31 
33 
34 class XMLTextListsHelper;
35 class SvXMLImportContext;
36 class SvXMLTokenMap;
38 class SvXMLImport;
39 class SvXMLStylesContext;
42 class SvI18NMap;
43 template<class A> class XMLPropertyBackpatcher;
45 
46 namespace xmloff {
47  struct ParsedRDFaAttributes;
48 }
49 
50 namespace com::sun::star {
51 namespace text {
52  class XText;
53  class XTextCursor;
54  class XTextRange;
55  class XTextContent;
56  class XFormField;
57 }
58 namespace frame { class XModel; }
59 namespace container { class XNameContainer; class XIndexReplace; }
60 namespace beans { class XPropertySet; }
61 namespace xml::sax { class XAttributeList; }
62 namespace util { struct DateTime; }
63 }
64 
65 namespace rtl { template <class reference_type> class Reference; }
66 
68 {
96 };
97 
99 {
108 
116 
117  XML_TOK_TEXT_TOC_MARK, // index marks
126 
142 
143  XML_TOK_TEXT_AUTHOR_NAME, // author fields
145 
146  XML_TOK_TEXT_DATE, // date & time fields
148 
149  XML_TOK_TEXT_PAGE_NUMBER, // page number fields
151 
152  XML_TOK_TEXT_VARIABLE_SET, // variable fields
160 
161  XML_TOK_TEXT_DATABASE_DISPLAY, // database fields
166 
183 
184  XML_TOK_TEXT_PLACEHOLDER, // misc. fields
191  XML_TOK_TEXT_WORD_COUNT, // statistics/count fields
216 
217  // RDF metadata
220 
221  // misc
222  XML_TOK_TEXTP_CHANGE_START, // TEXTP avoids clash with SwXMLTextElemTokens
227 
232 
236 };
237 
239 {
253 };
254 
256 {
263 };
264 
266 {
271 };
272 
274 {
277 };
278 
280 {
306 };
307 
309 {
317 };
318 
320 {
327 };
329 {
338 };
339 
342 {
346  // see following NOTE!
347 };
348 
349 // NOTE: these values must be distinct from any in "enum VarType" because they
350 // are used as keys to SvI18NMap::Add()
351 #define XML_TEXT_RENAME_TYPE_FRAME 10
352 #define XML_TEXT_RENAME_TYPE_TABLE 20
353 
355 {
356 private:
357  XMLTextImportHelper(const XMLTextImportHelper&) = delete;
359 
360  struct Impl;
361  std::unique_ptr<Impl> m_xImpl;
364  std::shared_ptr<BackpatcherImpl> m_xBackpatcherImpl;
365  static std::shared_ptr<BackpatcherImpl> MakeBackpatcherImpl();
366 
367 protected:
368  virtual SvXMLImportContext *CreateTableChildContext(
369  SvXMLImport& rImport,
370  sal_uInt16 nPrefix, const OUString& rLocalName,
371  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
372 
373  // access, lazy initialization and destruction of backpatchers
374  // Code is implemented in XMLPropertyBackpatcher.cxx
375  inline XMLPropertyBackpatcher<sal_Int16>& GetFootnoteBP();
376  inline XMLPropertyBackpatcher<sal_Int16>& GetSequenceIdBP();
377  inline XMLPropertyBackpatcher< OUString> & GetSequenceNameBP();
378 
379 public:
380 
382  css::uno::Reference< css::frame::XModel > const& rModel,
383  SvXMLImport& rImport,
384  bool const bInsertMode = false, bool const bStylesOnlyMode = false,
385  bool const bProgress = false, bool const bBlockMode = false,
386  bool const bOrganizerMode = false);
387 
388  virtual ~XMLTextImportHelper() override;
389 
390  void dispose();
391 
392  void SetCursor(
393  const css::uno::Reference< css::text::XTextCursor >& rCursor );
394  void ResetCursor();
395 
396  void SetAutoStyles( SvXMLStylesContext *pStyles );
397 
399  SvXMLImport& rImport,
400  sal_uInt16 nPrefix, const OUString& rLocalName,
401  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
403 
404  SvXMLTokenMap const& GetTextElemTokenMap();
405  SvXMLTokenMap const& GetTextPElemTokenMap();
406  SvXMLTokenMap const& GetTextPAttrTokenMap();
407  SvXMLTokenMap const& GetTextFrameAttrTokenMap();
408  SvXMLTokenMap const& GetTextContourAttrTokenMap();
409  SvXMLTokenMap const& GetTextHyperlinkAttrTokenMap();
410 
411  const SvXMLTokenMap& GetTextNumberedParagraphAttrTokenMap();
412  const SvXMLTokenMap& GetTextListBlockAttrTokenMap();
413  const SvXMLTokenMap& GetTextListBlockElemTokenMap();
414 
415  css::uno::Reference< css::text::XText > & GetText();
416  css::uno::Reference< css::text::XTextCursor > & GetCursor();
417  css::uno::Reference< css::text::XTextRange > & GetCursorAsRange();
418 
419  bool IsInsertMode() const;
420  bool IsStylesOnlyMode() const;
421  bool IsBlockMode() const;
422  bool IsOrganizerMode() const;
423  bool IsProgress() const;
424 
425  OUString ConvertStarFonts( const OUString& rChars,
426  const OUString& rStyleName,
427  sal_uInt8& rFlags,
428  bool bPara,
429  SvXMLImport& rImport ) const;
430  // insert a string without special whitespace processing enabled
431  void InsertString( const OUString& rChars );
432  // insert a string with special whitespace processing enabled
433  void InsertString( const OUString& rChars,
434  bool& rIgnoreLeadingSpace );
435  // Delete current paragraph
436  void DeleteParagraph();
437 
438  void InsertControlCharacter( sal_Int16 nControl );
439  void InsertTextContent( css::uno::Reference< css::text::XTextContent > const & xContent);
440 
441  // Add parameter <bOutlineLevelAttrFound> (#i73509#)
442  // Add parameter <bSetListAttrs> in order to suppress the handling of the list attributes (#i80724#)
443  OUString SetStyleAndAttrs(
444  SvXMLImport const & rImport,
445  const css::uno::Reference< css::text::XTextCursor >& rCursor,
446  const OUString& rStyleName,
447  bool bPara,
448  bool bOutlineLevelAttrFound = false,
449  sal_Int8 nOutlineLevel = -1,
450  bool bSetListAttrs = true,
451  bool bOutlineContentVisible = true);
452 
457  // Adjust 2nd parameter (#i69629#)
458  void FindOutlineStyleName( OUString& rStyleName,
459  sal_Int8 nOutlineLevel );
460 
461  // Change method name to reflect change of data structure (#i69629#)
462  void AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
463  const OUString& rStyleName );
464 
465  void SetOutlineStyles( bool bSetEmpty );
466 
467  void SetHyperlink(
468  SvXMLImport const & rImport,
469  const css::uno::Reference< css::text::XTextCursor >& rCursor,
470  const OUString& rHRef,
471  const OUString& rName,
472  const OUString& rTargetFrameName,
473  const OUString& rStyleName,
474  const OUString& rVisitedStyleName,
475  XMLEventsImportContext* pEvents);
476  void SetRuby(
477  SvXMLImport const & rImport,
478  const css::uno::Reference< css::text::XTextCursor >& rCursor,
479  const OUString& rStyleName,
480  const OUString& rTextStyleName,
481  const OUString& rText );
482 
486  sal_Int32 GetDataStyleKey( const OUString& sStyleName,
487  bool* pIsSystemLanguage = nullptr );
488 
489  const SvxXMLListStyleContext *FindAutoListStyle(
490  const OUString& rName ) const;
491  XMLPropStyleContext *FindAutoFrameStyle(
492  const OUString& rName ) const;
493  XMLPropStyleContext* FindSectionStyle(
494  const OUString& rName ) const;
495  XMLPropStyleContext* FindPageMaster(
496  const OUString& rName ) const;
497  XMLPropStyleContext* FindDrawingPage(OUString const& rName) const;
498 
499  const css::uno::Reference< css::container::XNameContainer> & GetParaStyles() const;
500 
501  const css::uno::Reference< css::container::XNameContainer> & GetTextStyles() const;
502 
503  const css::uno::Reference< css::container::XNameContainer> &
504  GetNumberingStyles() const;
505 
506  const css::uno::Reference< css::container::XNameContainer> & GetFrameStyles() const;
507 
508  const css::uno::Reference< css::container::XNameContainer> & GetPageStyles() const;
509 
510  const css::uno::Reference< css::container::XNameContainer> & GetCellStyles() const;
511 
512  const css::uno::Reference< css::container::XIndexReplace > &
513  GetChapterNumbering() const;
514 
515  bool HasFrameByName( const OUString& rName ) const;
516 
517  bool IsDuplicateFrame(const OUString& sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const;
518  void StoreLastImportedFrameName(const OUString& rName);
519  void ClearLastImportedTextFrameName();
520 
521  void ConnectFrameChains( const OUString& rFrmName,
522  const OUString& rNextFrmName,
523  const css::uno::Reference< css::beans::XPropertySet >& rFrmPropSet );
524 
526  GetParaImportPropertySetMapper() const;
528  GetTextImportPropertySetMapper() const;
530  GetSectionImportPropertySetMapper() const;
532  GetRubyImportPropertySetMapper() const;
533 
534  static SvXMLImportPropertyMapper *CreateShapeExtPropMapper(SvXMLImport&);
535  static SvXMLImportPropertyMapper *CreateParaExtPropMapper(SvXMLImport&);
536  static SvXMLImportPropertyMapper* CreateParaDefaultExtPropMapper(SvXMLImport&);
537  static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&);
538  static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&);
539  static SvXMLImportPropertyMapper* CreateTableCellExtPropMapper(SvXMLImport&);
540  static SvXMLImportPropertyMapper* CreateDrawingPageExtPropMapper(SvXMLImport&);
541 
542  SvI18NMap& GetRenameMap();
543 
545  void InsertBookmarkStartRange(
546  const OUString & sName,
547  const css::uno::Reference< css::text::XTextRange> & rRange,
548  OUString const& i_rXmlId,
549  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > &
550  i_rpRDFaAttributes);
551 
553  bool FindAndRemoveBookmarkStartRange(
554  const OUString & sName,
555  css::uno::Reference< css::text::XTextRange> & o_rRange,
556  OUString & o_rXmlId,
557  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes);
558 
559  void pushFieldCtx( const OUString& name, const OUString& type );
560  css::uno::Reference<css::text::XFormField> popFieldCtx();
561  void addFieldParam( const OUString& name, const OUString& value );
562  void setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField);
563  OUString getCurrentFieldType();
564  bool hasCurrentFieldCtx() const;
565 
566 
569  // Code is implemented in XMLPropertyBackpatcher.cxx
570  void InsertFootnoteID(const OUString& sXMLId, sal_Int16 nAPIId);
571 
574  // Code is implemented in XMLPropertyBackpatcher.cxx
575  void ProcessFootnoteReference(
576  const OUString& sXMLId,
577  const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
578 
581  // Code is implemented in XMLPropertyBackpatcher.cxx
582  void InsertSequenceID(const OUString& sXMLId,
583  const OUString& sName,
584  sal_Int16 nAPIId);
585 
587  // Code is implemented in XMLPropertyBackpatcher.cxx
588  void ProcessSequenceReference(
589  const OUString& sXMLId,
590  const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
591 
592  bool IsInFrame() const;
593  virtual bool IsInHeaderFooter() const;
594 
595  virtual css::uno::Reference< css::beans::XPropertySet>
596  createAndInsertOLEObject( SvXMLImport& rImport,
597  const OUString& rHRef,
598  const OUString &rStyleName,
599  const OUString &rTblName,
600  sal_Int32 nWidth, sal_Int32 nHeight );
601 
602  virtual css::uno::Reference< css::beans::XPropertySet>
603  createAndInsertOOoLink( SvXMLImport& rImport,
604  const OUString& rHRef,
605  const OUString &rStyleName,
606  const OUString &rTblName,
607  sal_Int32 nWidth, sal_Int32 nHeight );
608 
609  virtual css::uno::Reference< css::beans::XPropertySet>
610  createAndInsertApplet(
611  const OUString &rName,
612  const OUString &rCode,
613  bool bMayScript,
614  const OUString& rHRef,
615  sal_Int32 nWidth, sal_Int32 nHeight );
616 
617  virtual css::uno::Reference< css::beans::XPropertySet>
618  createAndInsertPlugin(
619  const OUString &rMimeType,
620  const OUString& rHRef,
621  sal_Int32 nWidth, sal_Int32 nHeight );
622 
623  virtual css::uno::Reference< css::beans::XPropertySet>
624  createAndInsertFloatingFrame(
625  const OUString &rName,
626  const OUString &rHRef,
627  const OUString &rStyleName,
628  sal_Int32 nWidth, sal_Int32 nHeight );
629 
630  virtual void endAppletOrPlugin(
631  const css::uno::Reference< css::beans::XPropertySet> &rPropSet,
632  ::std::map < const OUString, OUString > &rParamMap );
633 
634  // applet helper methods
635  // implemented in sw/filter/xml/txtparai.hxx
636 
637  // redlining helper methods
638  // (to be implemented in sw/filter/xml/txtparai.hxx)
639 
640  virtual void RedlineAdd(
642  const OUString& rType,
644  const OUString& rId,
646  const OUString& rAuthor,
648  const OUString& rComment,
650  const css::util::DateTime& rDateTime,
652  bool bMergeLastParagraph);
653 
654  virtual css::uno::Reference< css::text::XTextCursor> RedlineCreateText(
656  css::uno::Reference< css::text::XTextCursor > & rOldCursor,
658  const OUString& rId);
659 
660  virtual void RedlineSetCursor(
662  const OUString& rId,
664  bool bStart,
666  bool bIsOutsideOfParagraph);
667 
668  virtual void RedlineAdjustStartNodeCursor();
669  virtual void SetShowChanges( bool bShowChanges );
670  virtual void SetRecordChanges( bool bRecordChanges );
671  virtual void SetChangesProtectionKey(
672  const css::uno::Sequence<sal_Int8> & rProtectionKey );
673 
675  OUString const & GetOpenRedlineId() const;
677  void SetOpenRedlineId( OUString const & rId);
679  void ResetOpenRedlineId();
680 
683  void SetInsideDeleteContext(bool const bNew);
686  bool IsInsideDeleteContext() const;
687 
688  SvXMLImport & GetXMLImport();
689 
690  XMLTextListsHelper & GetTextListHelper();
691 
692  // forwards to TextListHelper; these are used in many places
694  void PushListContext();
696  void PopListContext();
697 
698  void SetCellParaStyleDefault(OUString const& rNewValue);
699  OUString const& GetCellParaStyleDefault() const;
700 
701  void AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo);
702  void MapCrossRefHeadingFieldsHorribly();
703 
704  void setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition);
705  bool getBookmarkHidden(OUString const& bookmark) const;
706  const OUString& getBookmarkCondition(OUString const& bookmark) const;
707 
708 };
709 
710 #endif
711 
712 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
XMLTextHyperlinkAttrTokens
Definition: txtimp.hxx:308
This class maintains an OUString->sal_Int16 mapping for cases in which an XPropertySet needs to be fi...
SwXMLTextElemTokens
Definition: txtimp.hxx:67
std::unique_ptr< Impl > m_xImpl
Definition: txtimp.hxx:360
XMLTextFrameAttrTokens
Definition: txtimp.hxx:279
signed char sal_Int8
Reference
Definition: txtimp.hxx:330
XMLTextContourAttrTokens
Definition: txtimp.hxx:319
VarType
variable type (for XMLSetVarFieldImportContext)
Definition: txtimp.hxx:341
XMLTextPAttrTokens
Definition: txtimp.hxx:238
exports com.sun.star. container
exports com.sun.star. frame
std::shared_ptr< BackpatcherImpl > m_xBackpatcherImpl
Definition: txtimp.hxx:363
exports com.sun.star. text
class SAL_NO_VTABLE XPropertySet
XMLTextListBlockAttrTokens
Definition: txtimp.hxx:265
XMLTextNumberedParagraphAttrTokens
Definition: txtimp.hxx:255
void operator=(SimpleReferenceObject) SAL_DELETED_FUNCTION
XMLTextPElemTokens
Definition: txtimp.hxx:98
rtl::Reference< XMLImportContext > CreateTextChildContext(XMLImport &rImport, std::u16string_view rName, bool bTopLevel=false)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
exports com.sun.star. beans
unsigned char sal_uInt8
ww8::ParaStyles GetParaStyles(const SwDoc &rDoc)
Definition: txtimp.hxx:331
XMLTextType
Definition: txtimp.hxx:328
void dispose()
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
XMLTextListBlockElemTokens
Definition: txtimp.hxx:273