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 <set>
27 #include <map>
28 #include <vector>
29 #include <memory>
30 #include <swtypes.hxx>
31 #include "wwstyles.hxx"
32 #include <rtl/textenc.h>
33 #include <tools/gen.hxx>
34 #include <filter/msfilter/util.hxx>
35 #include "fltshell.hxx"
36 #include <redline.hxx>
37 #include <shellio.hxx>
38 #include <svl/zforlist.hxx>
39 
40 class SwDoc;
41 class SwPaM;
42 class SwTableNode;
43 class SwNodeIndex;
44 class SwNoTextNode;
45 class SwTextNode;
46 class WW8TabDesc;
47 
48 namespace myImplHelpers
49 {
50 template<class C> class StyleMapperImpl;
51 }
52 
53 class SwTextFormatColl;
54 class SwCharFormat;
55 
56 namespace sw
57 {
58  namespace ms
59  {
70  sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding);
71 
78  sal_uInt8 rtl_TextEncodingToWinCharsetRTF(OUString const& rFontName,
79  OUString const& rAltName, rtl_TextEncoding eTextEncoding);
80 
84  sal_uInt32 DateTime2DTTM( const DateTime& rDT );
85 
89  sal_uLong MSDateTimeFormatToSwFormat(OUString& rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang);
90 
91  /*Used to identify if the previous token is AM time field*/
92  bool IsPreviousAM(OUString const & rParams, sal_Int32 nPos);
93 
94  /*Used to identify if the next token is PM time field*/
95  bool IsNextPM(OUString const & rParams, sal_Int32 nPos);
96 
100  bool IsNotAM(OUString const & rParams, sal_Int32 nPos);
101 
105  void SwapQuotesInField(OUString &rFormat);
106 
107  }
108 
109  namespace util
110  {
112  typedef std::map<sal_uInt16, std::size_t> AuthorInfos;
113 
127 
149  {
150  private:
151  //I hate these things stupid pImpl things, but its warranted here
152  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwTextFormatColl> > mpImpl;
153  public:
154  explicit ParaStyleMapper(SwDoc &rDoc);
156 
161  typedef std::pair<SwTextFormatColl*, bool> StyleResult;
162 
182  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
183  };
184 
206  {
207  private:
208  //I hate these things stupid pImpl things, but its warranted here
209  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
210  public:
211  explicit CharStyleMapper(SwDoc &rDoc);
213 
218  typedef std::pair<SwCharFormat*, bool> StyleResult;
219 
239  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
240  };
241 
250  {
251  public:
252  OUString msPrimary;
253  OUString msSecondary;
254  explicit FontMapExport(const OUString &rFontDescription);
255  };
256 
258  {
259  public:
260  explicit InsertedTableClient(SwTableNode & rNode);
262  };
263 
281  {
282  public:
283  typedef std::map<InsertedTableClient *, SwNodeIndex *> TableMap;
284  void DelAndMakeTableFrames();
285  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
286  explicit InsertedTablesManager(const SwDoc &rDoc);
287  private:
288  bool const mbHasRoot;
289  TableMap maTables;
290  };
291 
293  {
294  private:
295  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
297 
298  RedlineStack(RedlineStack const&) = delete;
299  RedlineStack& operator=(RedlineStack const&) = delete;
300 
301  public:
302  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
303  void MoveAttrs(const SwPosition& rPos);
304  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
305  bool close(const SwPosition& rPos, RedlineType_t eType);
306  void close(const SwPosition& rPos, RedlineType_t eType,
307  WW8TabDesc* pTabDesc );
308  void closeall(const SwPosition& rPos);
309  ~RedlineStack();
310  };
311 
313  {
314  private:
316  public:
317  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
318  void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
319  private:
321  };
322 
323  class SetEndIfOpen //Subclass from something ?
324  {
325  private:
327  public:
328  explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
329  void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
330  {
331  if (pEntry->bOpen)
332  pEntry->SetEndPos(mrPos);
333  }
334  private:
335  SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
336  };
337 
339  {
340  public:
341  bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
342  const;
343  };
344 
346  {
347  protected:
348  std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
349 
350  private:
351  WrtRedlineAuthor(WrtRedlineAuthor const&) = delete;
352  WrtRedlineAuthor& operator=(WrtRedlineAuthor const&) = delete;
353 
354  public:
355  WrtRedlineAuthor() = default;
356  virtual ~WrtRedlineAuthor() {}
357 
358  sal_uInt16 AddName( const OUString& rNm );
359  virtual void Write(Writer &rWrt) = 0;
360  };
361 
363  {
364  sal_Int32 mnEndPos;
365  sal_uInt16 mnScript;
366  rtl_TextEncoding meCharSet;
367  bool mbRTL;
368  CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
369  rtl_TextEncoding eCharSet, bool bRTL)
370  : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
371  mbRTL(bRTL)
372  {
373  }
374  };
375 
376  typedef std::vector<CharRunEntry> CharRuns;
377 
396  CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
397  }
398 }
399 
400 #endif
401 
402 /* 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
InsertedTableClient(SwTableNode &rNode)
std::map< sal_uInt16, std::size_t > AuthorInfos
Redlining Authors, map word author key to writer author value.
Definition: msfilter.hxx:112
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 drop-down form field.
Definition: accframe.hxx:34
std::vector< OUString > maAuthors
Definition: msfilter.hxx:348
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:152
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:205
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:161
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:326
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:366
bool IsPreviousAM(OUString const &rParams, sal_Int32 nPos)
SetEndIfOpen(const SwPosition &rPos)
Definition: msfilter.hxx:328
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:295
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:280
sti
Definition: wwstyles.hxx:27
Marks a node in the document model.
Definition: ndindex.hxx:31
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:302
Find suitable names for exporting this font.
Definition: msfilter.hxx:249
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:148
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:317
CharRuns GetPseudoCharRuns(const SwTextNode &rTextNd)
Collect the ranges of Text which share.
void operator()(const std::unique_ptr< SwFltStackEntry > &pEntry) const
Definition: msfilter.hxx:329
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
sal_uInt16 RedlineType_t
unsigned char sal_uInt8
CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript, rtl_TextEncoding eCharSet, bool bRTL)
Definition: msfilter.hxx:368
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:283
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:218
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:376
void SwapQuotesInField(OUString &rFormat)
Another function used by MSDateTimeFormatToSwFormat.
sal_Int32 nPos
virtual void Write(Writer &rWrt)=0
bool close(const SwPosition &rPos, RedlineType_t eType)
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwCharFormat > > mpImpl
Definition: msfilter.hxx:209