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 };
328 
330 {
337 };
339 {
348 };
349 
352 {
356  // see following NOTE!
357 };
358 
359 // NOTE: these values must be distinct from any in "enum VarType" because they
360 // are used as keys to SvI18NMap::Add()
361 #define XML_TEXT_RENAME_TYPE_FRAME 10
362 #define XML_TEXT_RENAME_TYPE_TABLE 20
363 
365 {
366 private:
367  XMLTextImportHelper(const XMLTextImportHelper&) = delete;
369 
370  struct Impl;
371  std::unique_ptr<Impl> m_xImpl;
374  std::shared_ptr<BackpatcherImpl> m_xBackpatcherImpl;
375  static std::shared_ptr<BackpatcherImpl> MakeBackpatcherImpl();
376 
377 protected:
378  virtual SvXMLImportContext *CreateTableChildContext(
379  SvXMLImport& rImport,
380  sal_uInt16 nPrefix, const OUString& rLocalName,
381  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
382 
383  // access, lazy initialization and destruction of backpatchers
384  // Code is implemented in XMLPropertyBackpatcher.cxx
385  inline XMLPropertyBackpatcher<sal_Int16>& GetFootnoteBP();
386  inline XMLPropertyBackpatcher<sal_Int16>& GetSequenceIdBP();
387  inline XMLPropertyBackpatcher< OUString> & GetSequenceNameBP();
388 
389 public:
390 
392  css::uno::Reference< css::frame::XModel > const& rModel,
393  SvXMLImport& rImport,
394  bool const bInsertMode = false, bool const bStylesOnlyMode = false,
395  bool const bProgress = false, bool const bBlockMode = false,
396  bool const bOrganizerMode = false);
397 
398  virtual ~XMLTextImportHelper() override;
399 
400  void dispose();
401 
402  void SetCursor(
403  const css::uno::Reference< css::text::XTextCursor >& rCursor );
404  void ResetCursor();
405 
406  void SetAutoStyles( SvXMLStylesContext *pStyles );
407 
409  SvXMLImport& rImport,
410  sal_uInt16 nPrefix, const OUString& rLocalName,
411  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
413 
414  SvXMLTokenMap const& GetTextElemTokenMap();
415  SvXMLTokenMap const& GetTextPElemTokenMap();
416  SvXMLTokenMap const& GetTextPAttrTokenMap();
417  SvXMLTokenMap const& GetTextFrameAttrTokenMap();
418  SvXMLTokenMap const& GetTextContourAttrTokenMap();
419  SvXMLTokenMap const& GetTextHyperlinkAttrTokenMap();
420 
421  const SvXMLTokenMap& GetTextNumberedParagraphAttrTokenMap();
422  const SvXMLTokenMap& GetTextListBlockAttrTokenMap();
423  const SvXMLTokenMap& GetTextListBlockElemTokenMap();
424  const SvXMLTokenMap& GetTextFieldAttrTokenMap(); // impl: txtfldi.cxx
425 
426  css::uno::Reference< css::text::XText > & GetText();
427  css::uno::Reference< css::text::XTextCursor > & GetCursor();
428  css::uno::Reference< css::text::XTextRange > & GetCursorAsRange();
429 
430  bool IsInsertMode() const;
431  bool IsStylesOnlyMode() const;
432  bool IsBlockMode() const;
433  bool IsOrganizerMode() const;
434  bool IsProgress() const;
435 
436  OUString ConvertStarFonts( const OUString& rChars,
437  const OUString& rStyleName,
438  sal_uInt8& rFlags,
439  bool bPara,
440  SvXMLImport& rImport ) const;
441  // insert a string without special whitespace processing enabled
442  void InsertString( const OUString& rChars );
443  // insert a string with special whitespace processing enabled
444  void InsertString( const OUString& rChars,
445  bool& rIgnoreLeadingSpace );
446  // Delete current paragraph
447  void DeleteParagraph();
448 
449  void InsertControlCharacter( sal_Int16 nControl );
450  void InsertTextContent( css::uno::Reference< css::text::XTextContent > const & xContent);
451 
452  // Add parameter <bOutlineLevelAttrFound> (#i73509#)
453  // Add parameter <bSetListAttrs> in order to suppress the handling of the list attributes (#i80724#)
454  OUString SetStyleAndAttrs(
455  SvXMLImport const & rImport,
456  const css::uno::Reference< css::text::XTextCursor >& rCursor,
457  const OUString& rStyleName,
458  bool bPara,
459  bool bOutlineLevelAttrFound = false,
460  sal_Int8 nOutlineLevel = -1,
461  bool bSetListAttrs = true,
462  bool bOutlineContentVisible = true);
463 
468  // Adjust 2nd parameter (#i69629#)
469  void FindOutlineStyleName( OUString& rStyleName,
470  sal_Int8 nOutlineLevel );
471 
472  // Change method name to reflect change of data structure (#i69629#)
473  void AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
474  const OUString& rStyleName );
475 
476  void SetOutlineStyles( bool bSetEmpty );
477 
478  void SetHyperlink(
479  SvXMLImport const & rImport,
480  const css::uno::Reference< css::text::XTextCursor >& rCursor,
481  const OUString& rHRef,
482  const OUString& rName,
483  const OUString& rTargetFrameName,
484  const OUString& rStyleName,
485  const OUString& rVisitedStyleName,
486  XMLEventsImportContext* pEvents);
487  void SetRuby(
488  SvXMLImport const & rImport,
489  const css::uno::Reference< css::text::XTextCursor >& rCursor,
490  const OUString& rStyleName,
491  const OUString& rTextStyleName,
492  const OUString& rText );
493 
497  sal_Int32 GetDataStyleKey( const OUString& sStyleName,
498  bool* pIsSystemLanguage = nullptr );
499 
500  const SvxXMLListStyleContext *FindAutoListStyle(
501  const OUString& rName ) const;
502  XMLPropStyleContext *FindAutoFrameStyle(
503  const OUString& rName ) const;
504  XMLPropStyleContext* FindSectionStyle(
505  const OUString& rName ) const;
506  XMLPropStyleContext* FindPageMaster(
507  const OUString& rName ) const;
508  XMLPropStyleContext* FindDrawingPage(OUString const& rName) const;
509 
510  const css::uno::Reference< css::container::XNameContainer> & GetParaStyles() const;
511 
512  const css::uno::Reference< css::container::XNameContainer> & GetTextStyles() const;
513 
514  const css::uno::Reference< css::container::XNameContainer> &
515  GetNumberingStyles() const;
516 
517  const css::uno::Reference< css::container::XNameContainer> & GetFrameStyles() const;
518 
519  const css::uno::Reference< css::container::XNameContainer> & GetPageStyles() const;
520 
521  const css::uno::Reference< css::container::XNameContainer> & GetCellStyles() const;
522 
523  const css::uno::Reference< css::container::XIndexReplace > &
524  GetChapterNumbering() const;
525 
526  bool HasFrameByName( const OUString& rName ) const;
527 
528  bool IsDuplicateFrame(const OUString& sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const;
529  void StoreLastImportedFrameName(const OUString& rName);
530  void ClearLastImportedTextFrameName();
531 
532  void ConnectFrameChains( const OUString& rFrmName,
533  const OUString& rNextFrmName,
534  const css::uno::Reference< css::beans::XPropertySet >& rFrmPropSet );
535 
537  GetParaImportPropertySetMapper() const;
539  GetTextImportPropertySetMapper() const;
541  GetSectionImportPropertySetMapper() const;
543  GetRubyImportPropertySetMapper() const;
544 
545  static SvXMLImportPropertyMapper *CreateShapeExtPropMapper(SvXMLImport&);
546  static SvXMLImportPropertyMapper *CreateParaExtPropMapper(SvXMLImport&);
547  static SvXMLImportPropertyMapper* CreateParaDefaultExtPropMapper(SvXMLImport&);
548  static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&);
549  static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&);
550  static SvXMLImportPropertyMapper* CreateTableCellExtPropMapper(SvXMLImport&);
551  static SvXMLImportPropertyMapper* CreateDrawingPageExtPropMapper(SvXMLImport&);
552 
553  SvI18NMap& GetRenameMap();
554 
556  void InsertBookmarkStartRange(
557  const OUString & sName,
558  const css::uno::Reference< css::text::XTextRange> & rRange,
559  OUString const& i_rXmlId,
560  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > &
561  i_rpRDFaAttributes);
562 
564  bool FindAndRemoveBookmarkStartRange(
565  const OUString & sName,
566  css::uno::Reference< css::text::XTextRange> & o_rRange,
567  OUString & o_rXmlId,
568  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes);
569 
570  void pushFieldCtx( const OUString& name, const OUString& type );
571  css::uno::Reference<css::text::XFormField> popFieldCtx();
572  void addFieldParam( const OUString& name, const OUString& value );
573  void setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField);
574  OUString getCurrentFieldType();
575  bool hasCurrentFieldCtx() const;
576 
577 
580  // Code is implemented in XMLPropertyBackpatcher.cxx
581  void InsertFootnoteID(const OUString& sXMLId, sal_Int16 nAPIId);
582 
585  // Code is implemented in XMLPropertyBackpatcher.cxx
586  void ProcessFootnoteReference(
587  const OUString& sXMLId,
588  const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
589 
592  // Code is implemented in XMLPropertyBackpatcher.cxx
593  void InsertSequenceID(const OUString& sXMLId,
594  const OUString& sName,
595  sal_Int16 nAPIId);
596 
598  // Code is implemented in XMLPropertyBackpatcher.cxx
599  void ProcessSequenceReference(
600  const OUString& sXMLId,
601  const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
602 
603  bool IsInFrame() const;
604  virtual bool IsInHeaderFooter() const;
605 
606  virtual css::uno::Reference< css::beans::XPropertySet>
607  createAndInsertOLEObject( SvXMLImport& rImport,
608  const OUString& rHRef,
609  const OUString &rStyleName,
610  const OUString &rTblName,
611  sal_Int32 nWidth, sal_Int32 nHeight );
612 
613  virtual css::uno::Reference< css::beans::XPropertySet>
614  createAndInsertOOoLink( SvXMLImport& rImport,
615  const OUString& rHRef,
616  const OUString &rStyleName,
617  const OUString &rTblName,
618  sal_Int32 nWidth, sal_Int32 nHeight );
619 
620  virtual css::uno::Reference< css::beans::XPropertySet>
621  createAndInsertApplet(
622  const OUString &rName,
623  const OUString &rCode,
624  bool bMayScript,
625  const OUString& rHRef,
626  sal_Int32 nWidth, sal_Int32 nHeight );
627 
628  virtual css::uno::Reference< css::beans::XPropertySet>
629  createAndInsertPlugin(
630  const OUString &rMimeType,
631  const OUString& rHRef,
632  sal_Int32 nWidth, sal_Int32 nHeight );
633 
634  virtual css::uno::Reference< css::beans::XPropertySet>
635  createAndInsertFloatingFrame(
636  const OUString &rName,
637  const OUString &rHRef,
638  const OUString &rStyleName,
639  sal_Int32 nWidth, sal_Int32 nHeight );
640 
641  virtual void endAppletOrPlugin(
642  const css::uno::Reference< css::beans::XPropertySet> &rPropSet,
643  ::std::map < const OUString, OUString > &rParamMap );
644 
645  // applet helper methods
646  // implemented in sw/filter/xml/txtparai.hxx
647 
648  // redlining helper methods
649  // (to be implemented in sw/filter/xml/txtparai.hxx)
650 
651  virtual void RedlineAdd(
653  const OUString& rType,
655  const OUString& rId,
657  const OUString& rAuthor,
659  const OUString& rComment,
661  const css::util::DateTime& rDateTime,
663  bool bMergeLastParagraph);
664 
665  virtual css::uno::Reference< css::text::XTextCursor> RedlineCreateText(
667  css::uno::Reference< css::text::XTextCursor > & rOldCursor,
669  const OUString& rId);
670 
671  virtual void RedlineSetCursor(
673  const OUString& rId,
675  bool bStart,
677  bool bIsOutsideOfParagraph);
678 
679  virtual void RedlineAdjustStartNodeCursor();
680  virtual void SetShowChanges( bool bShowChanges );
681  virtual void SetRecordChanges( bool bRecordChanges );
682  virtual void SetChangesProtectionKey(
683  const css::uno::Sequence<sal_Int8> & rProtectionKey );
684 
686  OUString const & GetOpenRedlineId() const;
688  void SetOpenRedlineId( OUString const & rId);
690  void ResetOpenRedlineId();
691 
694  void SetInsideDeleteContext(bool const bNew);
697  bool IsInsideDeleteContext() const;
698 
699  SvXMLImport & GetXMLImport();
700 
701  XMLTextListsHelper & GetTextListHelper();
702 
703  // forwards to TextListHelper; these are used in many places
705  void PushListContext();
707  void PopListContext();
708 
709  void SetCellParaStyleDefault(OUString const& rNewValue);
710  OUString const& GetCellParaStyleDefault() const;
711 
712  void AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo);
713  void MapCrossRefHeadingFieldsHorribly();
714 
715  void setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition);
716  bool getBookmarkHidden(OUString const& bookmark) const;
717  const OUString& getBookmarkCondition(OUString const& bookmark) const;
718 
719 };
720 
721 #endif
722 
723 /* 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:370
XMLTextFrameAttrTokens
Definition: txtimp.hxx:279
signed char sal_Int8
Reference
XMLTextPageMasterElemTokens
Definition: txtimp.hxx:319
Definition: txtimp.hxx:340
XMLTextContourAttrTokens
Definition: txtimp.hxx:329
VarType
variable type (for XMLSetVarFieldImportContext)
Definition: txtimp.hxx:351
XMLTextPAttrTokens
Definition: txtimp.hxx:238
exports com.sun.star. container
exports com.sun.star. frame
std::shared_ptr< BackpatcherImpl > m_xBackpatcherImpl
Definition: txtimp.hxx:373
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
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
exports com.sun.star. beans
rtl::Reference< XMLImportContext > CreateTextChildContext(XMLImport &rImport, const OUString &rName, bool bTopLevel=false)
unsigned char sal_uInt8
ww8::ParaStyles GetParaStyles(const SwDoc &rDoc)
Definition: txtimp.hxx:341
XMLTextType
Definition: txtimp.hxx:338
void dispose()
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
XMLTextListBlockElemTokens
Definition: txtimp.hxx:273