LibreOffice Module sw (master)  1
XMLRedlineImportHelper.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_SW_SOURCE_FILTER_XML_XMLREDLINEIMPORTHELPER_HXX
20 #define INCLUDED_SW_SOURCE_FILTER_XML_XMLREDLINEIMPORTHELPER_HXX
21 
22 #include <rtl/ustring.hxx>
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/uno/Sequence.h>
25 #include <com/sun/star/util/DateTime.hpp>
26 #include <redline.hxx>
27 
28 #include <map>
29 
30 class SvXMLImport;
31 class RedlineInfo;
32 class SwRedlineData;
33 class SwDoc;
34 namespace com { namespace sun { namespace star {
35  namespace text { class XTextCursor; }
36  namespace text { class XTextRange; }
37  namespace frame { class XModel; }
38 } } }
39 
40 typedef std::map< OUString, RedlineInfo* > RedlineMapType;
41 
43 {
45 
46  const OUString m_sInsertion;
47  const OUString m_sDeletion;
48  const OUString m_sFormatChange;
49 
51 
52  // if true, no redlines should be inserted into document
53  // (This typically happen when a document is loaded in 'insert'-mode.)
54  bool const m_bIgnoreRedlines;
55 
56  // save information for saving and reconstruction of the redline mode
57  css::uno::Reference<css::beans::XPropertySet> m_xModelPropertySet;
58  css::uno::Reference<css::beans::XPropertySet> m_xImportInfoPropertySet;
61  css::uno::Sequence<sal_Int8> m_aProtectionKey;
62 
63 public:
64 
66  SvXMLImport & rImport,
67  bool bIgnoreRedlines, // ignore redlines mode
68  // property sets of model + import info for saving + restoring the
69  // redline mode
70  const css::uno::Reference<css::beans::XPropertySet> & rModel,
71  const css::uno::Reference<css::beans::XPropertySet> & rImportInfoSet );
73 
74  // create a redline object
75  // (The redline will be inserted into the document after both start
76  // and end cursor has been set.)
77  void Add(
78  const OUString& rType, // redline type (insert, del,... )
79  const OUString& rId, // use to identify this redline
80  const OUString& rAuthor, // name of the author
81  const OUString& rComment, // redline comment
82  const css::util::DateTime& rDateTime, // date+time
83  bool bMergeLastParagraph); // merge last paragraph?
84 
85  // create a text section for the redline, and return an
86  // XText/XTextCursor that may be used to write into it.
87  css::uno::Reference<css::text::XTextCursor> CreateRedlineTextSection(
88  css::uno::Reference<css::text::XTextCursor> const & xOldCursor, // needed to get the document
89  const OUString& rId); // ID used to RedlineAdd() call
90 
91  // Set start or end position for a redline in the text body.
92  // Accepts XTextRange objects.
93  void SetCursor(
94  const OUString& rId, // ID used in RedlineAdd() call
95  bool bStart, // start or end Range
96  css::uno::Reference<css::text::XTextRange> const & rRange, // the actual XTextRange
97  // text range is (from an XML view) outside of a paragraph
98  // (i.e. before a table)
99  bool bIsOusideOfParagraph);
100 
107  const OUString& rId); // ID used in RedlineAdd() call
108 
109  // set redline mode: show changes
110  void SetShowChanges( bool bShowChanges );
111 
112  // set redline mode: record changes
113  void SetRecordChanges( bool bRecordChanges );
114 
115  // set redline protection key
116  void SetProtectionKey(const css::uno::Sequence<sal_Int8> & rKey );
117 
118 private:
119 
120  static inline bool IsReady(RedlineInfo* pRedline);
121 
122  void InsertIntoDocument(RedlineInfo* pRedline);
123 
125  RedlineInfo* pRedline, // RedlineInfo to be converted
126  SwDoc* pDoc); // document needed for Author-ID conversion
127 };
128 
129 #endif
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< sal_Int8 > m_aProtectionKey
static bool IsReady(RedlineInfo *pRedline)
XMLRedlineImportHelper(SvXMLImport &rImport, bool bIgnoreRedlines, const css::uno::Reference< css::beans::XPropertySet > &rModel, const css::uno::Reference< css::beans::XPropertySet > &rImportInfoSet)
Definition: doc.hxx:185
void SetCursor(const OUString &rId, bool bStart, css::uno::Reference< css::text::XTextRange > const &rRange, bool bIsOusideOfParagraph)
void SetRecordChanges(bool bRecordChanges)
void SetProtectionKey(const css::uno::Sequence< sal_Int8 > &rKey)
void SetShowChanges(bool bShowChanges)
css::uno::Reference< css::text::XTextCursor > CreateRedlineTextSection(css::uno::Reference< css::text::XTextCursor > const &xOldCursor, const OUString &rId)
css::uno::Reference< css::beans::XPropertySet > m_xImportInfoPropertySet
void AdjustStartNodeCursor(const OUString &rId)
Adjust the start (end) position for a redline that begins in a start node.
void Add(const OUString &rType, const OUString &rId, const OUString &rAuthor, const OUString &rComment, const css::util::DateTime &rDateTime, bool bMergeLastParagraph)
std::map< OUString, RedlineInfo * > RedlineMapType
css::uno::Reference< css::beans::XPropertySet > m_xModelPropertySet
SwRedlineData * ConvertRedline(RedlineInfo *pRedline, SwDoc *pDoc)
def text(shape, st)
void InsertIntoDocument(RedlineInfo *pRedline)