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
35class SwDoc;
36class SwPaM;
37class SwTableNode;
38class SwNodeIndex;
39class SwNoTextNode;
40class SwTextNode;
41class WW8TabDesc;
42
44{
45template<class C> class StyleMapperImpl;
46}
47
49class SwCharFormat;
50
51namespace 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
178 StyleResult GetStyle(const OUString& rName, ww::sti eSti,
179 std::map<OUString, sal_Int32>& rCollisions);
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
240 StyleResult GetStyle(const OUString& rName, ww::sti eSti,
241 std::map<OUString, sal_Int32>& rCollisions);
242 };
243
252 {
253 public:
254 OUString msPrimary;
255 OUString msSecondary;
256 explicit FontMapExport(std::u16string_view rFontDescription);
257 };
258
260 {
262 public:
263 explicit InsertedTableListener(SwTableNode& rNode);
265 virtual void Notify(const SfxHint&) override;
266 };
267
285 {
286 public:
288 void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM);
289 explicit InsertedTablesManager(const SwDoc &rDoc);
290 private:
292 std::map<std::unique_ptr<InsertedTableListener>, SwPosition*> maTables;
293 };
294
295 void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos);
296
298 {
299 private:
300 std::vector<std::unique_ptr<SwFltStackEntry>> maStack;
302
303 RedlineStack(RedlineStack const&) = delete;
305
306 public:
307 explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
308 void MoveAttrsFieldmarkInserted(const SwPosition& rPos);
309 void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
310 bool close(const SwPosition& rPos, RedlineType eType);
311 void close(const SwPosition& rPos, RedlineType eType,
312 WW8TabDesc* pTabDesc );
313 void closeall(const SwPosition& rPos);
315 };
316
318 {
319 private:
321 public:
322 explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {}
324 void operator()(std::unique_ptr<SwFltStackEntry> & pEntry);
325 private:
327 };
328
329 class SetEndIfOpen //Subclass from something ?
330 {
331 private:
333 public:
334 explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
335 void operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const
336 {
337 if (pEntry->m_bOpen)
338 pEntry->SetEndPos(mrPos);
339 }
340 SetEndIfOpen(SetEndIfOpen const &) = default;
341 private:
343 };
344
346 {
347 public:
348 bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE)
349 const;
350 };
351
353 {
354 protected:
355 std::vector<OUString> maAuthors; // Array of Sw - Bookmarknames
356
357 private:
360
361 public:
362 WrtRedlineAuthor() = default;
363 virtual ~WrtRedlineAuthor() {}
364
365 sal_uInt16 AddName( const OUString& rNm );
366 virtual void Write(Writer &rWrt) = 0;
367 };
368
370 {
371 sal_Int32 mnEndPos;
372 sal_uInt16 mnScript;
373 rtl_TextEncoding meCharSet;
374 bool mbRTL;
375 CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript,
376 rtl_TextEncoding eCharSet, bool bRTL)
377 : mnEndPos(nEndPos), mnScript(nScript), meCharSet(eCharSet),
378 mbRTL(bRTL)
379 {
380 }
381 };
382
383 typedef std::vector<CharRunEntry> CharRuns;
384
403 CharRuns GetPseudoCharRuns(const SwTextNode& rTextNd);
404 }
405}
406
407#endif
408
409/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the style of a text portion.
Definition: charfmt.hxx:27
Definition: doc.hxx:197
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:30
Marks a node in the document model.
Definition: ndindex.hxx:31
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:203
StyleResult GetStyle(const OUString &rName, ww::sti eSti, std::map< OUString, sal_Int32 > &rCollisions)
Get the writer style which the word style should map to.
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
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwCharFormat > > mpImpl
Definition: msfilter.hxx:206
bool operator()(const std::unique_ptr< SwFltStackEntry > &pOneE, const std::unique_ptr< SwFltStackEntry > &pTwoE) const
Find suitable names for exporting this font.
Definition: msfilter.hxx:252
FontMapExport(std::u16string_view rFontDescription)
InsertedTableListener(SwTableNode &rNode)
virtual void Notify(const SfxHint &) override
Handle requirements for table formatting in insert->file mode.
Definition: msfilter.hxx:285
std::map< std::unique_ptr< InsertedTableListener >, SwPosition * > maTables
Definition: msfilter.hxx:292
void InsertTable(SwTableNode &rTableNode, SwPaM &rPaM)
InsertedTablesManager(const SwDoc &rDoc)
Knows which writer style a given word style should be imported as.
Definition: msfilter.hxx:141
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
std::unique_ptr<::myImplHelpers::StyleMapperImpl< SwTextFormatColl > > mpImpl
Definition: msfilter.hxx:144
StyleResult GetStyle(const OUString &rName, ww::sti eSti, std::map< OUString, sal_Int32 > &rCollisions)
Get the writer style which the word style should map to.
void closeall(const SwPosition &rPos)
RedlineStack(RedlineStack const &)=delete
void open(const SwPosition &rPos, const SfxPoolItem &rAttr)
void MoveAttrsFieldmarkInserted(const SwPosition &rPos)
RedlineStack & operator=(RedlineStack const &)=delete
std::vector< std::unique_ptr< SwFltStackEntry > > maStack
Definition: msfilter.hxx:300
RedlineStack(SwDoc &rDoc)
Definition: msfilter.hxx:307
bool close(const SwPosition &rPos, RedlineType eType)
const SwPosition & mrPos
Definition: msfilter.hxx:332
SetEndIfOpen & operator=(const SetEndIfOpen &)=delete
SetEndIfOpen(SetEndIfOpen const &)=default
SetEndIfOpen(const SwPosition &rPos)
Definition: msfilter.hxx:334
void operator()(const std::unique_ptr< SwFltStackEntry > &pEntry) const
Definition: msfilter.hxx:335
SetInDocAndDelete & operator=(const SetInDocAndDelete &)=delete
SetInDocAndDelete(SwDoc &rDoc)
Definition: msfilter.hxx:322
void operator()(std::unique_ptr< SwFltStackEntry > &pEntry)
SetInDocAndDelete(SetInDocAndDelete const &)=default
virtual void Write(Writer &rWrt)=0
WrtRedlineAuthor & operator=(WrtRedlineAuthor const &)=delete
sal_uInt16 AddName(const OUString &rNm)
std::vector< OUString > maAuthors
Definition: msfilter.hxx:355
WrtRedlineAuthor(WrtRedlineAuthor const &)=delete
RedlineType
sal_uInt16 nPos
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.
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.
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.
void SwapQuotesInField(OUString &rFormat)
Another function used by MSDateTimeFormatToSwFormat.
bool IsNotAM(std::u16string_view rParams, sal_Int32 nPos)
Used by MSDateTimeFormatToSwFormat to identify AM time fields.
bool IsPreviousAM(std::u16string_view rParams, sal_Int32 nPos)
bool IsNextPM(std::u16string_view rParams, sal_Int32 nPos)
CharRuns GetPseudoCharRuns(const SwTextNode &rTextNd)
Collect the ranges of Text which share.
std::vector< CharRunEntry > CharRuns
Definition: msfilter.hxx:383
void MoveAttrFieldmarkInserted(SwFltPosition &rMkPos, SwFltPosition &rPtPos, const SwPosition &rPos)
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.
Dialog to specify the properties of date form field.
sti
Definition: wwstyles.hxx:29
sal_uIntPtr sal_uLong
Marks a position in the document model.
Definition: pam.hxx:38
rtl_TextEncoding meCharSet
Definition: msfilter.hxx:373
CharRunEntry(sal_Int32 nEndPos, sal_uInt16 nScript, rtl_TextEncoding eCharSet, bool bRTL)
Definition: msfilter.hxx:375
tools::Long SwTwips
Definition: swtypes.hxx:51
unsigned char sal_uInt8