LibreOffice Module sw (master)  1
msfilter.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 
20 #ifndef INCLUDED_SW_SOURCE_FILTER_INC_MSFILTER_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_INC_MSFILTER_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cstddef>
26 #include <map>
27 #include <vector>
28 #include <memory>
29 #include <swtypes.hxx>
30 #include "wwstyles.hxx"
31 #include <rtl/textenc.h>
32 #include "fltshell.hxx"
33 #include <shellio.hxx>
34 #include <svl/zforlist.hxx>
35 #include <svl/listener.hxx>
36 
37 class SwDoc;
38 class SwPaM;
39 class SwTableNode;
40 class SwNodeIndex;
41 class SwNoTextNode;
42 class SwTextNode;
43 class WW8TabDesc;
44 
45 namespace myImplHelpers
46 {
47 template<class C> class StyleMapperImpl;
48 }
49 
50 class SwTextFormatColl;
51 class SwCharFormat;
52 
53 namespace sw
54 {
55  namespace ms
56  {
67  sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding);
68 
75  sal_uInt8 rtl_TextEncodingToWinCharsetRTF(OUString const& rFontName,
76  OUString const& rAltName, rtl_TextEncoding eTextEncoding);
77 
81  sal_uInt32 DateTime2DTTM( const DateTime& rDT );
82 
86  sal_uLong MSDateTimeFormatToSwFormat(OUString& rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang);
87 
88  /*Used to identify if the previous token is AM time field*/
89  bool IsPreviousAM(OUString const & rParams, sal_Int32 nPos);
90 
91  /*Used to identify if the next token is PM time field*/
92  bool IsNextPM(OUString const & rParams, sal_Int32 nPos);
93 
97  bool IsNotAM(OUString const & rParams, sal_Int32 nPos);
98 
102  void SwapQuotesInField(OUString &rFormat);
103 
104  }
105 
106  namespace util
107  {
109  typedef std::map<sal_uInt16, std::size_t> AuthorInfos;
110 
124 
146  {
147  private:
148  //I hate these things stupid pImpl things, but it's warranted here
149  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwTextFormatColl> > mpImpl;
150  public:
151  explicit ParaStyleMapper(SwDoc &rDoc);
153 
158  typedef std::pair<SwTextFormatColl*, bool> StyleResult;
159 
179  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
180  };
181 
203  {
204  private:
205  //I hate these things stupid pImpl things, but it's warranted here
206  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
207  public:
208  explicit CharStyleMapper(SwDoc &rDoc);
210 
215  typedef std::pair<SwCharFormat*, bool> StyleResult;
216 
236  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
237  };
238 
247  {
248  public:
249  OUString msPrimary;
250  OUString msSecondary;
251  explicit FontMapExport(const OUString &rFontDescription);
252  };
253 
255  {
257  public:
258  explicit InsertedTableListener(SwTableNode& rNode);
260  virtual void Notify(const SfxHint&) override;
261  };
262 
280  {
281  public:
282  void DelAndMakeTableFrames();
283  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
284  explicit InsertedTablesManager(const SwDoc &rDoc);
285  private:
286  bool mbHasRoot;
287  std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> maTables;
288  };
289 
291  {
292  private:
293  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
295 
296  RedlineStack(RedlineStack const&) = delete;
297  RedlineStack& operator=(RedlineStack const&) = delete;
298 
299  public:
300  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
301  void MoveAttrsFieldmarkInserted(const SwPosition& rPos);
302  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
303  bool close(const SwPosition& rPos, RedlineType eType);
304  void close(const SwPosition& rPos, RedlineType eType,
305  WW8TabDesc* pTabDesc );
306  void closeall(const SwPosition& rPos);
307  ~RedlineStack();
308  };
309 
311  {
312  private:
314  public:
315  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
316  void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
317  private:
319  };
320 
321  class SetEndIfOpen //Subclass from something ?
322  {
323  private:
325  public:
326  explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
327  void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
328  {
329  if (pEntry->bOpen)
330  pEntry->SetEndPos(mrPos);
331  }
332  private:
333  SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
334  };
335 
337  {
338  public:
339  bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
340  const;
341  };
342 
344  {
345  protected:
346  std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
347 
348  private:
349  WrtRedlineAuthor(WrtRedlineAuthor const&) = delete;
350  WrtRedlineAuthor& operator=(WrtRedlineAuthor const&) = delete;
351 
352  public:
353  WrtRedlineAuthor() = default;
354  virtual ~WrtRedlineAuthor() {}
355 
356  sal_uInt16 AddName( const OUString& rNm );
357  virtual void Write(Writer &rWrt) = 0;
358  };
359 
361  {
362  sal_Int32 mnEndPos;
363  sal_uInt16 mnScript;
364  rtl_TextEncoding meCharSet;
365  bool mbRTL;
366  CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
367  rtl_TextEncoding eCharSet, bool bRTL)
368  : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
369  mbRTL(bRTL)
370  {
371  }
372  };
373 
374  typedef std::vector<CharRunEntry> CharRuns;
375 
394  CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
395  }
396 }
397 
398 #endif
399 
400 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WrtRedlineAuthor & operator=(WrtRedlineAuthor const &)=delete
std::map< std::unique_ptr< InsertedTableListener >, SwNodeIndex * > maTables
Definition: msfilter.hxx:287
InsertedTablesManager(const SwDoc &rDoc)
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
void closeall(const SwPosition &rPos)
RedlineStack(RedlineStack const &)=delete
sal_uLong MSDateTimeFormatToSwFormat(OUString &rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang)
Convert from Word Date/Time field str to Writer's Date Time str.
bool operator()(const std::unique_ptr< SwFltStackEntry > &pOneE, const std::unique_ptr< SwFltStackEntry > &pTwoE) const
sal_uIntPtr sal_uLong
bool close(const SwPosition &rPos, RedlineType eType)
std::map< sal_uInt16, std::size_t > AuthorInfos
Redlining Authors, map word author key to writer author value.
Definition: msfilter.hxx:109
Definition: doc.hxx:184
bool IsNotAM(OUString const &rParams, sal_Int32 nPos)
Used by MSDateTimeFormatToSwFormat to identify AM time fields.
sal_uInt16 AddName(const OUString &rNm)
long SwTwips
Definition: swtypes.hxx:49
void MoveAttrsFieldmarkInserted(const SwPosition &rPos)
Dialog to specify the properties of date form field.
std::vector< OUString > maAuthors
Definition: msfilter.hxx:346
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:149
SetEndIfOpen & operator=(const SetEndIfOpen &)=delete
StyleResult GetStyle(const OUString &rName, ww::sti eSti)
Get the writer style which the word style should map to.
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:202
void open(const SwPosition &rPos, const SfxPoolItem &rAttr)
void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM)
std::pair< SwTextFormatColl *, bool > StyleResult
StyleResult StyleResult is a std::pair of a pointer to a style and a flag which is true if the style ...
Definition: msfilter.hxx:158
RedlineStack & operator=(RedlineStack const &)=delete
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SwPosition & mrPos
Definition: msfilter.hxx:324
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:364
bool IsPreviousAM(OUString const &rParams, sal_Int32 nPos)
SetEndIfOpen(const SwPosition &rPos)
Definition: msfilter.hxx:326
SwTwips MakeSafePositioningValue(SwTwips nIn)
Clips a value to MAX/MIN 16bit value to make it safe for use as a position value to give to writer...
sal_uInt8 rtl_TextEncodingToWinCharsetRTF(OUString const &rFontName, OUString const &rAltName, rtl_TextEncoding eTextEncoding)
MSOffice appears to set the charset of unicode fonts to MS 932.
bool IsNextPM(OUString const &rParams, sal_Int32 nPos)
std::vector< std::unique_ptr< SwFltStackEntry > > maStack
Definition: msfilter.hxx:293
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:279
sti
Definition: wwstyles.hxx:27
Marks a node in the document model.
Definition: ndindex.hxx:31
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:300
InsertedTableListener(SwTableNode &rNode)
Find suitable names for exporting this font.
Definition: msfilter.hxx:246
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:145
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:315
CharRuns GetPseudoCharRuns(const SwTextNode &rTextNd)
Collect the ranges of Text which share.
void operator()(const std::unique_ptr< SwFltStackEntry > &pEntry) const
Definition: msfilter.hxx:327
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
unsigned char sal_uInt8
CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript, rtl_TextEncoding eCharSet, bool bRTL)
Definition: msfilter.hxx:366
sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding)
MSOffice appears to set the charset of unicode fonts to MS 932.
sal_uInt32 DateTime2DTTM(const DateTime &rDT)
Convert from DTTM to Writer's DateTime.
std::pair< SwCharFormat *, bool > StyleResult
StyleResult StyleResult is a std::pair of a pointer to a style and a flag which is true if the style ...
Definition: msfilter.hxx:215
FontMapExport(const OUString &rFontDescription)
StyleResult GetStyle(const OUString &rName, ww::sti eSti)
Get the writer style which the word style should map to.
SetInDocAndDelete & operator=(const SetInDocAndDelete &)=delete
virtual void Notify(const SfxHint &) override
void operator()(std::unique_ptr< SwFltStackEntry > &pEntry)
RedlineType
std::vector< CharRunEntry > CharRuns
Definition: msfilter.hxx:374
void SwapQuotesInField(OUString &rFormat)
Another function used by MSDateTimeFormatToSwFormat.
virtual void Write(Writer &rWrt)=0
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwCharFormat > > mpImpl
Definition: msfilter.hxx:206
sal_uInt16 nPos