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 <map>
26 #include <vector>
27 #include <memory>
28 #include <swtypes.hxx>
29 #include "wwstyles.hxx"
30 #include <rtl/textenc.h>
31 #include "fltshell.hxx"
32 #include <shellio.hxx>
33 #include <svl/listener.hxx>
34 
35 class SwDoc;
36 class SwPaM;
37 class SwTableNode;
38 class SwNodeIndex;
39 class SwNoTextNode;
40 class SwTextNode;
41 class WW8TabDesc;
42 
43 namespace myImplHelpers
44 {
45 template<class C> class StyleMapperImpl;
46 }
47 
48 class SwTextFormatColl;
49 class SwCharFormat;
50 
51 namespace sw
52 {
53  namespace ms
54  {
65  sal_uInt8 rtl_TextEncodingToWinCharset(rtl_TextEncoding eTextEncoding);
66 
73  sal_uInt8 rtl_TextEncodingToWinCharsetRTF(OUString const& rFontName,
74  OUString const& rAltName, rtl_TextEncoding eTextEncoding);
75 
79  sal_uInt32 DateTime2DTTM( const DateTime& rDT );
80 
84  sal_uLong MSDateTimeFormatToSwFormat(OUString& rParams, SvNumberFormatter *pFormatter, LanguageType &rLang, bool bHijri, LanguageType nDocLang);
85 
86  /*Used to identify if the previous token is AM time field*/
87  bool IsPreviousAM(std::u16string_view rParams, sal_Int32 nPos);
88 
89  /*Used to identify if the next token is PM time field*/
90  bool IsNextPM(std::u16string_view rParams, sal_Int32 nPos);
91 
95  bool IsNotAM(std::u16string_view rParams, sal_Int32 nPos);
96 
100  void SwapQuotesInField(OUString &rFormat);
101 
102  }
103 
104  namespace util
105  {
119 
141  {
142  private:
143  //I hate these things stupid pImpl things, but it's warranted here
144  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwTextFormatColl> > mpImpl;
145  public:
146  explicit ParaStyleMapper(SwDoc &rDoc);
148 
153  typedef std::pair<SwTextFormatColl*, bool> StyleResult;
154 
174  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
175  };
176 
198  {
199  private:
200  //I hate these things stupid pImpl things, but it's warranted here
201  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
202  public:
203  explicit CharStyleMapper(SwDoc &rDoc);
205 
210  typedef std::pair<SwCharFormat*, bool> StyleResult;
211 
231  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
232  };
233 
242  {
243  public:
244  OUString msPrimary;
245  OUString msSecondary;
246  explicit FontMapExport(std::u16string_view rFontDescription);
247  };
248 
249  class InsertedTableListener final : public SvtListener
250  {
252  public:
253  explicit InsertedTableListener(SwTableNode& rNode);
255  virtual void Notify(const SfxHint&) override;
256  };
257 
275  {
276  public:
277  void DelAndMakeTableFrames();
278  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
279  explicit InsertedTablesManager(const SwDoc &rDoc);
280  private:
281  bool mbHasRoot;
282  std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> maTables;
283  };
284 
285  void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos);
286 
288  {
289  private:
290  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
292 
293  RedlineStack(RedlineStack const&) = delete;
294  RedlineStack& operator=(RedlineStack const&) = delete;
295 
296  public:
297  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
298  void MoveAttrsFieldmarkInserted(const SwPosition& rPos);
299  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
300  bool close(const SwPosition& rPos, RedlineType eType);
301  void close(const SwPosition& rPos, RedlineType eType,
302  WW8TabDesc* pTabDesc );
303  void closeall(const SwPosition& rPos);
304  ~RedlineStack();
305  };
306 
308  {
309  private:
311  public:
312  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
313  SetInDocAndDelete(SetInDocAndDelete const &) = default;
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->m_bOpen)
328  pEntry->SetEndPos(mrPos);
329  }
330  SetEndIfOpen(SetEndIfOpen const &) = default;
331  private:
332  SetEndIfOpen& operator=(const SetEndIfOpen&) = delete;
333  };
334 
336  {
337  public:
338  bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
339  const;
340  };
341 
343  {
344  protected:
345  std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
346 
347  private:
348  WrtRedlineAuthor(WrtRedlineAuthor const&) = delete;
349  WrtRedlineAuthor& operator=(WrtRedlineAuthor const&) = delete;
350 
351  public:
352  WrtRedlineAuthor() = default;
353  virtual ~WrtRedlineAuthor() {}
354 
355  sal_uInt16 AddName( const OUString& rNm );
356  virtual void Write(Writer &rWrt) = 0;
357  };
358 
360  {
361  sal_Int32 mnEndPos;
362  sal_uInt16 mnScript;
363  rtl_TextEncoding meCharSet;
364  bool mbRTL;
365  CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
366  rtl_TextEncoding eCharSet, bool bRTL)
367  : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
368  mbRTL(bRTL)
369  {
370  }
371  };
372 
373  typedef std::vector<CharRunEntry> CharRuns;
374 
393  CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
394  }
395 }
396 
397 #endif
398 
399 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WrtRedlineAuthor & operator=(WrtRedlineAuthor const &)=delete
std::map< std::unique_ptr< InsertedTableListener >, SwNodeIndex * > maTables
Definition: msfilter.hxx:282
InsertedTablesManager(const SwDoc &rDoc)
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
Marks a position in the document model.
Definition: pam.hxx:36
void closeall(const SwPosition &rPos)
RedlineStack(RedlineStack const &)=delete
void MoveAttrFieldmarkInserted(SwFltPosition &rMkPos, SwFltPosition &rPtPos, const SwPosition &rPos)
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
bool IsNextPM(std::u16string_view rParams, sal_Int32 nPos)
sal_uIntPtr sal_uLong
bool close(const SwPosition &rPos, RedlineType eType)
Definition: doc.hxx:187
sal_uInt16 AddName(const OUString &rNm)
void MoveAttrsFieldmarkInserted(const SwPosition &rPos)
Dialog to specify the properties of date form field.
std::vector< OUString > maAuthors
Definition: msfilter.hxx:345
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:144
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:197
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:153
RedlineStack & operator=(RedlineStack const &)=delete
bool IsPreviousAM(std::u16string_view rParams, sal_Int32 nPos)
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
const SwPosition & mrPos
Definition: msfilter.hxx:322
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:363
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.
std::vector< std::unique_ptr< SwFltStackEntry > > maStack
Definition: msfilter.hxx:290
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:274
FontMapExport(std::u16string_view rFontDescription)
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:29
Marks a node in the document model.
Definition: ndindex.hxx:30
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:297
InsertedTableListener(SwTableNode &rNode)
Find suitable names for exporting this font.
Definition: msfilter.hxx:241
Represents the style of a text portion.
Definition: charfmt.hxx:26
tools::Long SwTwips
Definition: swtypes.hxx:51
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:140
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:312
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:365
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:210
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:373
bool IsNotAM(std::u16string_view rParams, sal_Int32 nPos)
Used by MSDateTimeFormatToSwFormat to identify AM time fields.
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:201
sal_uInt16 nPos
sti
Definition: wwstyles.hxx:27