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 
36 class SwDoc;
37 class SwPaM;
38 class SwTableNode;
39 class SwNodeIndex;
40 class SwNoTextNode;
41 class SwTextNode;
42 class WW8TabDesc;
43 
44 namespace myImplHelpers
45 {
46 template<class C> class StyleMapperImpl;
47 }
48 
49 class SwTextFormatColl;
50 class SwCharFormat;
51 
52 namespace sw
53 {
54  namespace ms
55  {
66  sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding);
67 
74  sal_uInt8 rtl_TextEncodingToWinCharsetRTF(OUString const& rFontName,
75  OUString const& rAltName, rtl_TextEncoding eTextEncoding);
76 
80  sal_uInt32 DateTime2DTTM( const DateTime& rDT );
81 
85  sal_uLong MSDateTimeFormatToSwFormat(OUString& rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang);
86 
87  /*Used to identify if the previous token is AM time field*/
88  bool IsPreviousAM(OUString const & rParams, sal_Int32 nPos);
89 
90  /*Used to identify if the next token is PM time field*/
91  bool IsNextPM(OUString const & rParams, sal_Int32 nPos);
92 
96  bool IsNotAM(OUString const & rParams, sal_Int32 nPos);
97 
101  void SwapQuotesInField(OUString &rFormat);
102 
103  }
104 
105  namespace util
106  {
108  typedef std::map<sal_uInt16, std::size_t> AuthorInfos;
109 
123 
145  {
146  private:
147  //I hate these things stupid pImpl things, but its warranted here
148  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwTextFormatColl> > mpImpl;
149  public:
150  explicit ParaStyleMapper(SwDoc &rDoc);
152 
157  typedef std::pair<SwTextFormatColl*, bool> StyleResult;
158 
178  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
179  };
180 
202  {
203  private:
204  //I hate these things stupid pImpl things, but its warranted here
205  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
206  public:
207  explicit CharStyleMapper(SwDoc &rDoc);
209 
214  typedef std::pair<SwCharFormat*, bool> StyleResult;
215 
235  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
236  };
237 
246  {
247  public:
248  OUString msPrimary;
249  OUString msSecondary;
250  explicit FontMapExport(const OUString &rFontDescription);
251  };
252 
254  {
255  public:
256  explicit InsertedTableClient(SwTableNode & rNode);
258  };
259 
277  {
278  public:
279  typedef std::map<InsertedTableClient *, SwNodeIndex *> TableMap;
280  void DelAndMakeTableFrames();
281  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
282  explicit InsertedTablesManager(const SwDoc &rDoc);
283  private:
284  bool const mbHasRoot;
285  TableMap maTables;
286  };
287 
289  {
290  private:
291  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
293 
294  RedlineStack(RedlineStack const&) = delete;
295  RedlineStack& operator=(RedlineStack const&) = delete;
296 
297  public:
298  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
299  void MoveAttrs(const SwPosition& rPos);
300  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
301  bool close(const SwPosition& rPos, RedlineType eType);
302  void close(const SwPosition& rPos, RedlineType eType,
303  WW8TabDesc* pTabDesc );
304  void closeall(const SwPosition& rPos);
305  ~RedlineStack();
306  };
307 
309  {
310  private:
312  public:
313  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
314  void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
315  private:
317  };
318 
319  class SetEndIfOpen //Subclass from something ?
320  {
321  private:
323  public:
324  explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
325  void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
326  {
327  if (pEntry->bOpen)
328  pEntry->SetEndPos(mrPos);
329  }
330  private:
331  SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
332  };
333 
335  {
336  public:
337  bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
338  const;
339  };
340 
342  {
343  protected:
344  std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
345 
346  private:
347  WrtRedlineAuthor(WrtRedlineAuthor const&) = delete;
348  WrtRedlineAuthor& operator=(WrtRedlineAuthor const&) = delete;
349 
350  public:
351  WrtRedlineAuthor() = default;
352  virtual ~WrtRedlineAuthor() {}
353 
354  sal_uInt16 AddName( const OUString& rNm );
355  virtual void Write(Writer &rWrt) = 0;
356  };
357 
359  {
360  sal_Int32 mnEndPos;
361  sal_uInt16 mnScript;
362  rtl_TextEncoding meCharSet;
363  bool mbRTL;
364  CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
365  rtl_TextEncoding eCharSet, bool bRTL)
366  : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
367  mbRTL(bRTL)
368  {
369  }
370  };
371 
372  typedef std::vector<CharRunEntry> CharRuns;
373 
392  CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
393  }
394 }
395 
396 #endif
397 
398 /* 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)
InsertedTableClient(SwTableNode &rNode)
std::map< sal_uInt16, std::size_t > AuthorInfos
Redlining Authors, map word author key to writer author value.
Definition: msfilter.hxx:108
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.
Definition: accfrmobj.cxx:40
std::vector< OUString > maAuthors
Definition: msfilter.hxx:344
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:148
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:201
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:157
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:322
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:362
bool IsPreviousAM(OUString const &rParams, sal_Int32 nPos)
SetEndIfOpen(const SwPosition &rPos)
Definition: msfilter.hxx:324
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:291
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:276
sti
Definition: wwstyles.hxx:27
Marks a node in the document model.
Definition: ndindex.hxx:31
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:298
Find suitable names for exporting this font.
Definition: msfilter.hxx:245
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:144
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:313
CharRuns GetPseudoCharRuns(const SwTextNode &rTextNd)
Collect the ranges of Text which share.
void operator()(const std::unique_ptr< SwFltStackEntry > &pEntry) const
Definition: msfilter.hxx:325
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:364
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::map< InsertedTableClient *, SwNodeIndex * > TableMap
Definition: msfilter.hxx:279
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:214
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
void operator()(std::unique_ptr< SwFltStackEntry > &pEntry)
std::vector< CharRunEntry > CharRuns
Definition: msfilter.hxx:372
void SwapQuotesInField(OUString &rFormat)
Another function used by MSDateTimeFormatToSwFormat.
sal_Int32 nPos
virtual void Write(Writer &rWrt)=0
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwCharFormat > > mpImpl
Definition: msfilter.hxx:205