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  {
121 
143  {
144  private:
145  //I hate these things stupid pImpl things, but it's warranted here
146  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwTextFormatColl> > mpImpl;
147  public:
148  explicit ParaStyleMapper(SwDoc &rDoc);
150 
155  typedef std::pair<SwTextFormatColl*, bool> StyleResult;
156 
176  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
177  };
178 
200  {
201  private:
202  //I hate these things stupid pImpl things, but it's warranted here
203  std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
204  public:
205  explicit CharStyleMapper(SwDoc &rDoc);
207 
212  typedef std::pair<SwCharFormat*, bool> StyleResult;
213 
233  StyleResult GetStyle(const OUString& rName, ww::sti eSti);
234  };
235 
244  {
245  public:
246  OUString msPrimary;
247  OUString msSecondary;
248  explicit FontMapExport(const OUString &rFontDescription);
249  };
250 
251  class InsertedTableListener final : public SvtListener
252  {
254  public:
255  explicit InsertedTableListener(SwTableNode& rNode);
257  virtual void Notify(const SfxHint&) override;
258  };
259 
277  {
278  public:
279  void DelAndMakeTableFrames();
280  void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
281  explicit InsertedTablesManager(const SwDoc &rDoc);
282  private:
283  bool mbHasRoot;
284  std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> maTables;
285  };
286 
287  void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos);
288 
290  {
291  private:
292  std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
294 
295  RedlineStack(RedlineStack const&) = delete;
296  RedlineStack& operator=(RedlineStack const&) = delete;
297 
298  public:
299  explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
300  void MoveAttrsFieldmarkInserted(const SwPosition& rPos);
301  void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
302  bool close(const SwPosition& rPos, RedlineType eType);
303  void close(const SwPosition& rPos, RedlineType eType,
304  WW8TabDesc* pTabDesc );
305  void closeall(const SwPosition& rPos);
306  ~RedlineStack();
307  };
308 
310  {
311  private:
313  public:
314  explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
315  SetInDocAndDelete(SetInDocAndDelete const &) = default;
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->m_bOpen)
330  pEntry->SetEndPos(mrPos);
331  }
332  SetEndIfOpen(SetEndIfOpen const &) = default;
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
std::map< std::unique_ptr< InsertedTableListener >, SwNodeIndex * > maTables
Definition: msfilter.hxx:284
InsertedTablesManager(const SwDoc &rDoc)
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
Marks a position in the document model.
Definition: pam.hxx:35
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
sal_uIntPtr sal_uLong
bool close(const SwPosition &rPos, RedlineType eType)
Definition: doc.hxx:188
bool IsNotAM(OUString const &rParams, sal_Int32 nPos)
Used by MSDateTimeFormatToSwFormat to identify AM time fields.
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:347
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:146
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:199
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:155
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:365
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:292
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:276
Marks a node in the document model.
Definition: ndindex.hxx:31
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:299
InsertedTableListener(SwTableNode &rNode)
Find suitable names for exporting this font.
Definition: msfilter.hxx:243
tools::Long SwTwips
Definition: swtypes.hxx:52
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:142
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:314
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: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:212
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:375
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:203
sal_uInt16 nPos
sti
Definition: wwstyles.hxx:27