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  typedef std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> TableMap;
283  void DelAndMakeTableFrames();
284  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
285  explicit InsertedTablesManager(const SwDoc &rDoc);
286  private:
287  bool const mbHasRoot;
288  TableMap maTables;
289  };
290 
292  {
293  private:
294  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
296 
297  RedlineStack(RedlineStack const&) = delete;
298  RedlineStack& operator=(RedlineStack const&) = delete;
299 
300  public:
301  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
302  void MoveAttrs(const SwPosition& rPos);
303  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
304  bool close(const SwPosition& rPos, RedlineType eType);
305  void close(const SwPosition& rPos, RedlineType eType,
306  WW8TabDesc* pTabDesc );
307  void closeall(const SwPosition& rPos);
308  ~RedlineStack();
309  };
310 
312  {
313  private:
315  public:
316  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
317  void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
318  private:
320  };
321 
322  class SetEndIfOpen //Subclass from something ?
323  {
324  private:
326  public:
327  explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
328  void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
329  {
330  if (pEntry->bOpen)
331  pEntry->SetEndPos(mrPos);
332  }
333  private:
334  SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
335  };
336 
338  {
339  public:
340  bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
341  const;
342  };
343 
345  {
346  protected:
347  std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
348 
349  private:
350  WrtRedlineAuthor(WrtRedlineAuthor const&) = delete;
351  WrtRedlineAuthor& operator=(WrtRedlineAuthor const&) = delete;
352 
353  public:
354  WrtRedlineAuthor() = default;
355  virtual ~WrtRedlineAuthor() {}
356 
357  sal_uInt16 AddName( const OUString& rNm );
358  virtual void Write(Writer &rWrt) = 0;
359  };
360 
362  {
363  sal_Int32 mnEndPos;
364  sal_uInt16 mnScript;
365  rtl_TextEncoding meCharSet;
366  bool mbRTL;
367  CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
368  rtl_TextEncoding eCharSet, bool bRTL)
369  : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
370  mbRTL(bRTL)
371  {
372  }
373  };
374 
375  typedef std::vector<CharRunEntry> CharRuns;
376 
395  CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
396  }
397 }
398 
399 #endif
400 
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WrtRedlineAuthor & operator=(WrtRedlineAuthor const &)=delete
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:185
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
Dialog to specify the properties of date form field.
std::vector< OUString > maAuthors
Definition: msfilter.hxx:347
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
void MoveAttrs(const SwPosition &rPos)
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SwPosition & mrPos
Definition: msfilter.hxx:325
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:365
bool IsPreviousAM(OUString const &rParams, sal_Int32 nPos)
SetEndIfOpen(const SwPosition &rPos)
Definition: msfilter.hxx:327
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:294
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:301
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:316
CharRuns GetPseudoCharRuns(const SwTextNode &rTextNd)
Collect the ranges of Text which share.
void operator()(const std::unique_ptr< SwFltStackEntry > &pEntry) const
Definition: msfilter.hxx:328
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
unsigned char sal_uInt8
CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript, rtl_TextEncoding eCharSet, bool bRTL)
Definition: msfilter.hxx:367
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)
std::vector< CharRunEntry > CharRuns
Definition: msfilter.hxx:375
void SwapQuotesInField(OUString &rFormat)
Another function used by MSDateTimeFormatToSwFormat.
std::map< std::unique_ptr< InsertedTableListener >, SwNodeIndex * > TableMap
Definition: msfilter.hxx:282
sal_Int32 nPos
virtual void Write(Writer &rWrt)=0
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwCharFormat > > mpImpl
Definition: msfilter.hxx:206