summaryrefslogtreecommitdiffstats
path: root/lotuswordpro/source
diff options
context:
space:
mode:
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r--lotuswordpro/source/filter/LotusWordProImportFilter.cxx294
-rw-r--r--lotuswordpro/source/filter/LotusWordProImportFilter.hxx78
-rw-r--r--lotuswordpro/source/filter/bencont.cxx331
-rw-r--r--lotuswordpro/source/filter/benlist.cxx112
-rw-r--r--lotuswordpro/source/filter/benname.cxx79
-rw-r--r--lotuswordpro/source/filter/benobj.cxx77
-rw-r--r--lotuswordpro/source/filter/bento.hxx378
-rw-r--r--lotuswordpro/source/filter/bentoid.hxx95
-rw-r--r--lotuswordpro/source/filter/benval.cxx137
-rw-r--r--lotuswordpro/source/filter/clone.hxx71
-rw-r--r--lotuswordpro/source/filter/explode.cxx509
-rw-r--r--lotuswordpro/source/filter/explode.hxx124
-rw-r--r--lotuswordpro/source/filter/first.hxx74
-rw-r--r--lotuswordpro/source/filter/localtime.cxx187
-rw-r--r--lotuswordpro/source/filter/lwp9reader.cxx217
-rw-r--r--lotuswordpro/source/filter/lwp9reader.hxx89
-rw-r--r--lotuswordpro/source/filter/lwparrowstyles.hxx103
-rw-r--r--lotuswordpro/source/filter/lwpatomholder.cxx108
-rw-r--r--lotuswordpro/source/filter/lwpbackgroundoverride.cxx23
-rw-r--r--lotuswordpro/source/filter/lwpbackgroundoverride.hxx97
-rw-r--r--lotuswordpro/source/filter/lwpbackgroundstuff.cxx164
-rw-r--r--lotuswordpro/source/filter/lwpbackgroundstuff.hxx97
-rw-r--r--lotuswordpro/source/filter/lwpbasetype.cxx93
-rw-r--r--lotuswordpro/source/filter/lwpbookmarkmgr.cxx107
-rw-r--r--lotuswordpro/source/filter/lwpborderstuff.cxx214
-rw-r--r--lotuswordpro/source/filter/lwpborderstuff.hxx115
-rw-r--r--lotuswordpro/source/filter/lwpbreaksoverride.cxx276
-rw-r--r--lotuswordpro/source/filter/lwpbreaksoverride.hxx236
-rw-r--r--lotuswordpro/source/filter/lwpbulletstylemgr.cxx308
-rw-r--r--lotuswordpro/source/filter/lwpbulletstylemgr.hxx115
-rw-r--r--lotuswordpro/source/filter/lwpcelllayout.cxx931
-rw-r--r--lotuswordpro/source/filter/lwpcelllayout.hxx209
-rw-r--r--lotuswordpro/source/filter/lwpchangemgr.cxx169
-rw-r--r--lotuswordpro/source/filter/lwpcharacterstyle.cxx173
-rw-r--r--lotuswordpro/source/filter/lwpcharacterstyle.hxx137
-rw-r--r--lotuswordpro/source/filter/lwpcharborderoverride.cxx108
-rw-r--r--lotuswordpro/source/filter/lwpcharborderoverride.hxx99
-rw-r--r--lotuswordpro/source/filter/lwpcharsetmgr.cxx112
-rw-r--r--lotuswordpro/source/filter/lwpcharsetmgr.hxx86
-rw-r--r--lotuswordpro/source/filter/lwpcolor.cxx135
-rw-r--r--lotuswordpro/source/filter/lwpcontent.cxx157
-rw-r--r--lotuswordpro/source/filter/lwpcontent.hxx155
-rw-r--r--lotuswordpro/source/filter/lwpdivinfo.cxx176
-rw-r--r--lotuswordpro/source/filter/lwpdivinfo.hxx152
-rw-r--r--lotuswordpro/source/filter/lwpdivopts.cxx136
-rw-r--r--lotuswordpro/source/filter/lwpdivopts.hxx118
-rw-r--r--lotuswordpro/source/filter/lwpdlvlist.cxx177
-rw-r--r--lotuswordpro/source/filter/lwpdlvlist.hxx168
-rw-r--r--lotuswordpro/source/filter/lwpdoc.cxx835
-rw-r--r--lotuswordpro/source/filter/lwpdoc.hxx209
-rw-r--r--lotuswordpro/source/filter/lwpdocdata.cxx324
-rw-r--r--lotuswordpro/source/filter/lwpdrawobj.cxx1488
-rw-r--r--lotuswordpro/source/filter/lwpdrawobj.hxx374
-rw-r--r--lotuswordpro/source/filter/lwpdropcapmgr.cxx67
-rw-r--r--lotuswordpro/source/filter/lwpfilehdr.cxx89
-rw-r--r--lotuswordpro/source/filter/lwpfilter.cxx213
-rw-r--r--lotuswordpro/source/filter/lwpfilter.hxx69
-rw-r--r--lotuswordpro/source/filter/lwpfnlayout.cxx367
-rw-r--r--lotuswordpro/source/filter/lwpfnlayout.hxx204
-rw-r--r--lotuswordpro/source/filter/lwpfont.cxx509
-rw-r--r--lotuswordpro/source/filter/lwpfootnote.cxx548
-rw-r--r--lotuswordpro/source/filter/lwpfootnote.hxx279
-rw-r--r--lotuswordpro/source/filter/lwpfoundry.cxx532
-rw-r--r--lotuswordpro/source/filter/lwpframelayout.cxx1263
-rw-r--r--lotuswordpro/source/filter/lwpframelayout.hxx248
-rw-r--r--lotuswordpro/source/filter/lwpfrib.cxx455
-rw-r--r--lotuswordpro/source/filter/lwpfribbreaks.cxx156
-rw-r--r--lotuswordpro/source/filter/lwpfribbreaks.hxx101
-rw-r--r--lotuswordpro/source/filter/lwpfribframe.cxx239
-rw-r--r--lotuswordpro/source/filter/lwpfribframe.hxx103
-rw-r--r--lotuswordpro/source/filter/lwpfribheader.hxx124
-rw-r--r--lotuswordpro/source/filter/lwpfribmark.cxx1426
-rw-r--r--lotuswordpro/source/filter/lwpfribmark.hxx156
-rw-r--r--lotuswordpro/source/filter/lwpfribptr.cxx596
-rw-r--r--lotuswordpro/source/filter/lwpfribptr.hxx98
-rw-r--r--lotuswordpro/source/filter/lwpfribsection.cxx452
-rw-r--r--lotuswordpro/source/filter/lwpfribsection.hxx126
-rw-r--r--lotuswordpro/source/filter/lwpfribtable.cxx173
-rw-r--r--lotuswordpro/source/filter/lwpfribtable.hxx79
-rw-r--r--lotuswordpro/source/filter/lwpfribtext.cxx424
-rw-r--r--lotuswordpro/source/filter/lwpfribtext.hxx211
-rw-r--r--lotuswordpro/source/filter/lwpglobalmgr.cxx133
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.cxx693
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.hxx131
-rw-r--r--lotuswordpro/source/filter/lwpholder.cxx122
-rw-r--r--lotuswordpro/source/filter/lwpholder.hxx136
-rw-r--r--lotuswordpro/source/filter/lwphyperlinkmgr.cxx68
-rw-r--r--lotuswordpro/source/filter/lwphyperlinkmgr.hxx83
-rw-r--r--lotuswordpro/source/filter/lwpidxmgr.cxx326
-rw-r--r--lotuswordpro/source/filter/lwplayout.cxx2119
-rw-r--r--lotuswordpro/source/filter/lwplayout.hxx512
-rw-r--r--lotuswordpro/source/filter/lwplayoutdef.hxx173
-rw-r--r--lotuswordpro/source/filter/lwplaypiece.cxx440
-rw-r--r--lotuswordpro/source/filter/lwplaypiece.hxx389
-rw-r--r--lotuswordpro/source/filter/lwplnopts.cxx96
-rw-r--r--lotuswordpro/source/filter/lwplnopts.hxx98
-rw-r--r--lotuswordpro/source/filter/lwpmargins.hxx108
-rw-r--r--lotuswordpro/source/filter/lwpmarker.cxx537
-rw-r--r--lotuswordpro/source/filter/lwpmarker.hxx265
-rw-r--r--lotuswordpro/source/filter/lwpnotes.cxx308
-rw-r--r--lotuswordpro/source/filter/lwpnotes.hxx158
-rw-r--r--lotuswordpro/source/filter/lwpnumberingoverride.cxx101
-rw-r--r--lotuswordpro/source/filter/lwpnumberingoverride.hxx104
-rw-r--r--lotuswordpro/source/filter/lwpnumericfmt.cxx466
-rw-r--r--lotuswordpro/source/filter/lwpnumericfmt.hxx305
-rw-r--r--lotuswordpro/source/filter/lwpobj.cxx108
-rw-r--r--lotuswordpro/source/filter/lwpobjfactory.cxx726
-rw-r--r--lotuswordpro/source/filter/lwpobjhdr.cxx200
-rw-r--r--lotuswordpro/source/filter/lwpobjid.cxx202
-rw-r--r--lotuswordpro/source/filter/lwpobjstrm.cxx369
-rw-r--r--lotuswordpro/source/filter/lwpoleobject.cxx254
-rw-r--r--lotuswordpro/source/filter/lwpoleobject.hxx127
-rw-r--r--lotuswordpro/source/filter/lwpoverride.cxx587
-rw-r--r--lotuswordpro/source/filter/lwppagehint.cxx122
-rw-r--r--lotuswordpro/source/filter/lwppagehint.hxx129
-rw-r--r--lotuswordpro/source/filter/lwppagelayout.cxx1080
-rw-r--r--lotuswordpro/source/filter/lwppagelayout.hxx164
-rw-r--r--lotuswordpro/source/filter/lwppara.cxx848
-rw-r--r--lotuswordpro/source/filter/lwppara.hxx361
-rw-r--r--lotuswordpro/source/filter/lwppara1.cxx573
-rw-r--r--lotuswordpro/source/filter/lwpparaborderoverride.cxx386
-rw-r--r--lotuswordpro/source/filter/lwpparaborderoverride.hxx283
-rw-r--r--lotuswordpro/source/filter/lwpparaproperty.cxx269
-rw-r--r--lotuswordpro/source/filter/lwpparaproperty.hxx272
-rw-r--r--lotuswordpro/source/filter/lwpparastyle.cxx745
-rw-r--r--lotuswordpro/source/filter/lwpparastyle.hxx124
-rw-r--r--lotuswordpro/source/filter/lwppiece.hxx223
-rw-r--r--lotuswordpro/source/filter/lwpproplist.cxx144
-rw-r--r--lotuswordpro/source/filter/lwpproplist.hxx99
-rw-r--r--lotuswordpro/source/filter/lwpprtinfo.cxx95
-rw-r--r--lotuswordpro/source/filter/lwpprtinfo.hxx79
-rw-r--r--lotuswordpro/source/filter/lwppttntbl.hxx146
-rw-r--r--lotuswordpro/source/filter/lwprowlayout.cxx499
-rw-r--r--lotuswordpro/source/filter/lwprowlayout.hxx131
-rw-r--r--lotuswordpro/source/filter/lwpsdwdrawheader.hxx366
-rw-r--r--lotuswordpro/source/filter/lwpsdwfileloader.cxx98
-rw-r--r--lotuswordpro/source/filter/lwpsdwfileloader.hxx85
-rw-r--r--lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx395
-rw-r--r--lotuswordpro/source/filter/lwpsdwgrouploaderv0102.hxx91
-rw-r--r--lotuswordpro/source/filter/lwpsdwrect.cxx176
-rw-r--r--lotuswordpro/source/filter/lwpsdwrect.hxx124
-rw-r--r--lotuswordpro/source/filter/lwpsection.cxx141
-rw-r--r--lotuswordpro/source/filter/lwpsection.hxx143
-rw-r--r--lotuswordpro/source/filter/lwpshadow.hxx109
-rw-r--r--lotuswordpro/source/filter/lwpsilverbullet.cxx452
-rw-r--r--lotuswordpro/source/filter/lwpsilverbullet.hxx159
-rw-r--r--lotuswordpro/source/filter/lwpsortopt.cxx86
-rw-r--r--lotuswordpro/source/filter/lwpsortopt.hxx101
-rw-r--r--lotuswordpro/source/filter/lwpstory.cxx476
-rw-r--r--lotuswordpro/source/filter/lwpstory.hxx158
-rw-r--r--lotuswordpro/source/filter/lwpstyledef.hxx258
-rw-r--r--lotuswordpro/source/filter/lwpsvstream.cxx119
-rw-r--r--lotuswordpro/source/filter/lwptable.cxx213
-rw-r--r--lotuswordpro/source/filter/lwptable.hxx187
-rw-r--r--lotuswordpro/source/filter/lwptablelayout.cxx1564
-rw-r--r--lotuswordpro/source/filter/lwptablelayout.hxx313
-rw-r--r--lotuswordpro/source/filter/lwptaboverride.cxx20
-rw-r--r--lotuswordpro/source/filter/lwptaboverride.hxx111
-rw-r--r--lotuswordpro/source/filter/lwptabrack.cxx134
-rw-r--r--lotuswordpro/source/filter/lwptabrack.hxx146
-rw-r--r--lotuswordpro/source/filter/lwptblcell.cxx246
-rw-r--r--lotuswordpro/source/filter/lwptblcell.hxx340
-rw-r--r--lotuswordpro/source/filter/lwptblformula.cxx575
-rw-r--r--lotuswordpro/source/filter/lwptblformula.hxx223
-rw-r--r--lotuswordpro/source/filter/lwptoc.cxx471
-rw-r--r--lotuswordpro/source/filter/lwptoc.hxx173
-rw-r--r--lotuswordpro/source/filter/lwptools.cxx850
-rw-r--r--lotuswordpro/source/filter/lwpuidoc.cxx128
-rw-r--r--lotuswordpro/source/filter/lwpuidoc.hxx159
-rw-r--r--lotuswordpro/source/filter/lwpusewhen.hxx169
-rw-r--r--lotuswordpro/source/filter/lwpusrdicts.cxx81
-rw-r--r--lotuswordpro/source/filter/lwpusrdicts.hxx77
-rw-r--r--lotuswordpro/source/filter/lwpverdocument.cxx106
-rw-r--r--lotuswordpro/source/filter/lwpverdocument.hxx84
-rw-r--r--lotuswordpro/source/filter/lwpvpointer.cxx83
-rw-r--r--lotuswordpro/source/filter/lwpvpointer.hxx82
-rw-r--r--lotuswordpro/source/filter/tocread.cxx520
-rw-r--r--lotuswordpro/source/filter/tocread.hxx99
-rw-r--r--lotuswordpro/source/filter/ut.hxx73
-rw-r--r--lotuswordpro/source/filter/utbenvs.cxx138
-rw-r--r--lotuswordpro/source/filter/utlist.cxx119
-rw-r--r--lotuswordpro/source/filter/utlist.hxx120
-rw-r--r--lotuswordpro/source/filter/xfilter/xfbase64.cxx133
-rw-r--r--lotuswordpro/source/filter/xfilter/xfbase64.hxx82
-rw-r--r--lotuswordpro/source/filter/xfilter/xfbgimage.cxx162
-rw-r--r--lotuswordpro/source/filter/xfilter/xfborders.cxx366
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcell.cxx197
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcellstyle.cxx245
-rw-r--r--lotuswordpro/source/filter/xfilter/xfchange.cxx148
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcolor.cxx88
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcolstyle.cxx86
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcolumns.cxx181
-rw-r--r--lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx94
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx175
-rw-r--r--lotuswordpro/source/filter/xfilter/xfcrossref.cxx100
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdate.cxx109
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdatestyle.cxx189
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdocfield.cxx234
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawareastyle.cxx95
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawareastyle.hxx143
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawline.cxx124
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawlinestyle.cxx117
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawobj.cxx130
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawpath.cxx155
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawpolygon.cxx99
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawpolyline.cxx128
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawrect.cxx77
-rw-r--r--lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx327
-rw-r--r--lotuswordpro/source/filter/xfilter/xfentry.cxx107
-rw-r--r--lotuswordpro/source/filter/xfilter/xffloatframe.cxx85
-rw-r--r--lotuswordpro/source/filter/xfilter/xffont.cxx315
-rw-r--r--lotuswordpro/source/filter/xfilter/xffontdecl.cxx68
-rw-r--r--lotuswordpro/source/filter/xfilter/xffontfactory.cxx78
-rw-r--r--lotuswordpro/source/filter/xfilter/xffontworkstyle.hxx121
-rw-r--r--lotuswordpro/source/filter/xfilter/xfframe.cxx202
-rw-r--r--lotuswordpro/source/filter/xfilter/xfframestyle.cxx199
-rw-r--r--lotuswordpro/source/filter/xfilter/xfglobal.cxx130
-rw-r--r--lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx166
-rw-r--r--lotuswordpro/source/filter/xfilter/xfimage.cxx147
-rw-r--r--lotuswordpro/source/filter/xfilter/xfimagestyle.cxx177
-rw-r--r--lotuswordpro/source/filter/xfilter/xfindex.cxx330
-rw-r--r--lotuswordpro/source/filter/xfilter/xflist.cxx96
-rw-r--r--lotuswordpro/source/filter/xfilter/xfliststyle.cxx290
-rw-r--r--lotuswordpro/source/filter/xfilter/xfmargins.cxx119
-rw-r--r--lotuswordpro/source/filter/xfilter/xfmasterpage.cxx86
-rw-r--r--lotuswordpro/source/filter/xfilter/xfnumberstyle.cxx356
-rw-r--r--lotuswordpro/source/filter/xfilter/xfofficemeta.cxx138
-rw-r--r--lotuswordpro/source/filter/xfilter/xfpagemaster.cxx265
-rw-r--r--lotuswordpro/source/filter/xfilter/xfparagraph.cxx96
-rw-r--r--lotuswordpro/source/filter/xfilter/xfparastyle.cxx461
-rw-r--r--lotuswordpro/source/filter/xfilter/xfrow.cxx135
-rw-r--r--lotuswordpro/source/filter/xfilter/xfrowstyle.cxx100
-rw-r--r--lotuswordpro/source/filter/xfilter/xfsaxattrlist.cxx82
-rw-r--r--lotuswordpro/source/filter/xfilter/xfsaxattrlist.hxx90
-rw-r--r--lotuswordpro/source/filter/xfilter/xfsaxstream.cxx122
-rw-r--r--lotuswordpro/source/filter/xfilter/xfsection.cxx96
-rw-r--r--lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx133
-rw-r--r--lotuswordpro/source/filter/xfilter/xfshadow.cxx116
-rw-r--r--lotuswordpro/source/filter/xfilter/xfstyle.cxx99
-rw-r--r--lotuswordpro/source/filter/xfilter/xfstylecont.cxx251
-rw-r--r--lotuswordpro/source/filter/xfilter/xfstylemanager.cxx375
-rw-r--r--lotuswordpro/source/filter/xfilter/xftable.cxx275
-rw-r--r--lotuswordpro/source/filter/xfilter/xftablestyle.cxx130
-rw-r--r--lotuswordpro/source/filter/xfilter/xftabstyle.cxx101
-rw-r--r--lotuswordpro/source/filter/xfilter/xftabstyle.hxx100
-rw-r--r--lotuswordpro/source/filter/xfilter/xftextboxstyle.cxx101
-rw-r--r--lotuswordpro/source/filter/xfilter/xftextcontent.cxx115
-rw-r--r--lotuswordpro/source/filter/xfilter/xftextspan.cxx150
-rw-r--r--lotuswordpro/source/filter/xfilter/xftextstyle.cxx126
-rw-r--r--lotuswordpro/source/filter/xfilter/xftimestyle.cxx150
-rw-r--r--lotuswordpro/source/filter/xfilter/xfutil.cxx391
251 files changed, 60454 insertions, 0 deletions
diff --git a/lotuswordpro/source/filter/LotusWordProImportFilter.cxx b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx
new file mode 100644
index 000000000..296561bcc
--- /dev/null
+++ b/lotuswordpro/source/filter/LotusWordProImportFilter.cxx
@@ -0,0 +1,294 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <sal/macros.h>
+#include <tools/stream.hxx>
+#include <ucbhelper/content.hxx>
+
+#include "LotusWordProImportFilter.hxx"
+#include "lwpfilter.hxx"
+
+#if OSL_DEBUG_LEVEL > 0
+#include <memory>
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
+
+#include <comphelper/oslfile2streamwrap.hxx>
+
+#include <cppuhelper/weak.hxx>
+
+#include <osl/file.hxx>
+#endif
+
+using namespace com::sun::star;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Any;
+using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::Exception;
+using com::sun::star::io::XInputStream;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::ucb::XCommandEnvironment;
+using com::sun::star::document::XImporter;
+using com::sun::star::xml::sax::XDocumentHandler;
+
+#if OSL_DEBUG_LEVEL > 0
+namespace
+{
+
+class DebugDocumentHandler final : public cppu::WeakImplHelper< XDocumentHandler >
+{
+public:
+ DebugDocumentHandler(const uno::Reference< XDocumentHandler >& handler, const uno::Reference< XDocumentHandler >& debug)
+ : m_handler(handler)
+ , m_debug(debug)
+ {
+ }
+
+ // XDocumentHandler
+
+ virtual void SAL_CALL
+ startDocument() override
+ {
+ m_handler->startDocument();
+ m_debug->startDocument();
+ }
+
+ virtual void SAL_CALL
+ endDocument() override
+ {
+ m_handler->endDocument();
+ m_debug->endDocument();
+ }
+
+ virtual void SAL_CALL
+ startElement(
+ const OUString& aName,
+ const uno::Reference< xml::sax::XAttributeList > & xAttribs) override
+ {
+ m_handler->startElement(aName, xAttribs);
+ m_debug->ignorableWhitespace(" "); // NOTE: needed for pretty-printing
+ m_debug->startElement(aName, xAttribs);
+ }
+
+ virtual void SAL_CALL
+ endElement(const OUString& aName) override
+ {
+ m_handler->endElement(aName);
+ m_debug->ignorableWhitespace(" "); // NOTE: needed for pretty-printing
+ m_debug->endElement(aName);
+ }
+
+ virtual void SAL_CALL
+ characters(const OUString& aChars) override
+ {
+ m_handler->characters(aChars);
+ m_debug->characters(aChars);
+ }
+
+ virtual void SAL_CALL
+ ignorableWhitespace(const OUString& aWhitespaces) override
+ {
+ m_handler->ignorableWhitespace(aWhitespaces);
+ m_debug->ignorableWhitespace(aWhitespaces);
+ }
+
+ virtual void SAL_CALL
+ processingInstruction(const OUString& aTarget, const OUString& aData) override
+ {
+ m_handler->processingInstruction(aTarget, aData);
+ m_debug->processingInstruction(aTarget, aData);
+ }
+
+ virtual void SAL_CALL
+ setDocumentLocator(const uno::Reference< xml::sax::XLocator >& xLocator) override
+ {
+ m_handler->setDocumentLocator(xLocator);
+ m_debug->setDocumentLocator(xLocator);
+ }
+
+ // XInterface
+
+ virtual uno::Any SAL_CALL queryInterface(const uno::Type & rType) override
+ {
+ uno::Any aIface = cppu::WeakImplHelper< XDocumentHandler >::queryInterface(rType);
+ // delegate all queries we cannot satisfy ourselves to the real handler
+ if (!aIface.has< uno::Reference< uno::XInterface > >())
+ aIface = m_handler->queryInterface(rType);
+ return aIface;
+ }
+
+private:
+ uno::Reference< XDocumentHandler > m_handler;
+ uno::Reference< XDocumentHandler > m_debug;
+};
+
+}
+#endif
+
+// W o r d P r o
+const sal_Int8 header[] = { 0x57, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f };
+
+bool LotusWordProImportFilter::importImpl( const Sequence< css::beans::PropertyValue >& aDescriptor )
+{
+ OUString sURL;
+ for (const PropertyValue& rValue : aDescriptor)
+ {
+ //Note, we should attempt to use InputStream here first!
+ if ( rValue.Name == "URL" )
+ rValue.Value >>= sURL;
+ }
+
+ SvFileStream inputStream( sURL, StreamMode::READ );
+ if (!inputStream.good())
+ return false;
+
+ // An XML import service: what we push sax messages to...
+ uno::Reference< XDocumentHandler > xInternalHandler(
+ mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.Writer.XMLImporter", mxContext ), UNO_QUERY );
+
+#if OSL_DEBUG_LEVEL > 0
+ std::unique_ptr<osl::File> pDebugFile;
+ const char* pDir = getenv("DBG_LWPIMPORT_DIR");
+ if (pDir)
+ {
+ OUString aStr(OStringToOUString(pDir, RTL_TEXTENCODING_UTF8));
+ OUString aFileURL;
+ osl_getFileURLFromSystemPath(aStr.pData, &aFileURL.pData);
+ pDebugFile = std::make_unique<osl::File>(aFileURL + "/lwpimport.xml");
+ if (pDebugFile->open(osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) != osl::File::E_None)
+ {
+ pDebugFile->open(osl_File_OpenFlag_Write);
+ pDebugFile->setSize(0);
+ }
+
+ uno::Reference< xml::sax::XWriter > xDebugWriter = xml::sax::Writer::create(mxContext);
+ uno::Reference< io::XOutputStream > xOutputStream(new comphelper::OSLOutputStreamWrapper(*pDebugFile));
+ xDebugWriter->setOutputStream(xOutputStream);
+
+ xInternalHandler.set(new DebugDocumentHandler(xInternalHandler, xDebugWriter));
+ }
+#endif
+
+ uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
+ if (xImporter.is())
+ xImporter->setTargetDocument(mxDoc);
+
+ return ( ReadWordproFile( inputStream, xInternalHandler) == 0 );
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportLWP(SvStream &rStream)
+{
+ uno::Reference< XDocumentHandler > xHandler;
+ return ReadWordproFile(rStream, xHandler) == 0;
+}
+
+sal_Bool SAL_CALL LotusWordProImportFilter::filter( const Sequence< css::beans::PropertyValue >& aDescriptor )
+{
+ return importImpl ( aDescriptor );
+}
+void SAL_CALL LotusWordProImportFilter::cancel( )
+{
+}
+
+// XImporter
+void SAL_CALL LotusWordProImportFilter::setTargetDocument( const uno::Reference< css::lang::XComponent >& xDoc )
+{
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL LotusWordProImportFilter::detect( css::uno::Sequence< PropertyValue >& Descriptor )
+{
+ OUString sTypeName( "writer_LotusWordPro_Document" );
+ OUString sURL;
+ uno::Reference < XInputStream > xInputStream;
+ for (const PropertyValue& rValue : std::as_const(Descriptor))
+ {
+ if ( rValue.Name == "TypeName" )
+ rValue.Value >>= sTypeName;
+ else if ( rValue.Name == "InputStream" )
+ rValue.Value >>= xInputStream;
+ else if ( rValue.Name == "URL" )
+ rValue.Value >>= sURL;
+ }
+
+ uno::Reference< css::ucb::XCommandEnvironment > xEnv;
+ if (!xInputStream.is())
+ {
+ try
+ {
+ ::ucbhelper::Content aContent(sURL, xEnv, mxContext);
+ xInputStream = aContent.openStream();
+ }
+ catch ( Exception& )
+ {
+ return OUString();
+ }
+
+ if (!xInputStream.is())
+ return OUString();
+ }
+
+ Sequence< ::sal_Int8 > aData;
+ sal_Int32 nLen = SAL_N_ELEMENTS( header );
+ if ( ( nLen != xInputStream->readBytes( aData, nLen ) )
+ || ( memcmp( static_cast<void const *>(header), static_cast<void const *>(aData.getConstArray()), nLen ) != 0 ) )
+ sTypeName.clear();
+
+ return sTypeName;
+}
+
+// XInitialization
+void SAL_CALL LotusWordProImportFilter::initialize( const Sequence< Any >& /*aArguments*/ )
+{
+}
+
+// XServiceInfo
+OUString SAL_CALL LotusWordProImportFilter::getImplementationName()
+{
+ return "com.sun.star.comp.Writer.LotusWordProImportFilter";
+}
+
+sal_Bool SAL_CALL LotusWordProImportFilter::supportsService(const OUString& rServiceName)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence<OUString> SAL_CALL LotusWordProImportFilter::getSupportedServiceNames()
+{
+ return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+LotusWordProImportFilter_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new LotusWordProImportFilter(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/LotusWordProImportFilter.hxx b/lotuswordpro/source/filter/LotusWordProImportFilter.hxx
new file mode 100644
index 000000000..e0843e040
--- /dev/null
+++ b/lotuswordpro/source/filter/LotusWordProImportFilter.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LOTUSWORDPROIMPORTFILTER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LOTUSWORDPROIMPORTFILTER_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase.hxx>
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class LotusWordProImportFilter final : public cppu::WeakImplHelper
+<
+ css::document::XFilter,
+ css::document::XImporter,
+ css::document::XExtendedFilterDetection,
+ css::lang::XInitialization,
+ css::lang::XServiceInfo
+>
+{
+ // oo.org declares
+ css::uno::Reference< css::uno::XComponentContext > mxContext;
+ css::uno::Reference< css::lang::XComponent > mxDoc;
+
+ /// @throws css::uno::RuntimeException
+ bool importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor );
+
+public:
+ explicit LotusWordProImportFilter( const css::uno::Reference< css::uno::XComponentContext > &rxContext)
+ : mxContext( rxContext )
+ {
+ }
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
+ virtual void SAL_CALL cancel( ) override;
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
+
+ //XExtendedFilterDetection
+ virtual OUString SAL_CALL detect( css::uno::Sequence< css::beans::PropertyValue >& Descriptor ) override;
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/bencont.cxx b/lotuswordpro/source/filter/bencont.cxx
new file mode 100644
index 000000000..b5648a64b
--- /dev/null
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "first.hxx"
+#include "tocread.hxx"
+#include <stdio.h>
+#include <algorithm>
+#include <osl/diagnose.h>
+
+namespace OpenStormBento
+{
+
+// String definitions
+const char gsBenMagicBytes[] = BEN_MAGIC_BYTES;
+
+/**
+* New bento container from file stream
+* @param pointer to length of bento file
+* @param pointer to pointer of Bento Container object
+* @return error code
+*/
+sal_uLong BenOpenContainer(LwpSvStream * pStream, std::unique_ptr<LtcBenContainer>* ppContainer)
+{
+ *ppContainer = nullptr;
+
+ if (nullptr == pStream)
+ {
+ return BenErr_ContainerWithNoObjects;
+ }
+
+ std::unique_ptr<LtcBenContainer> pContainer(new LtcBenContainer(pStream));
+ if (pContainer->Open() != BenErr_OK) // delete two inputs
+ {
+ return BenErr_InvalidTOC;
+ }
+
+ *ppContainer = std::move(pContainer);
+ return BenErr_OK;
+}
+
+LtcBenContainer::~LtcBenContainer()
+{
+}
+
+BenError
+LtcBenContainer::Open() // delete two inputs
+{
+ BenError Err;
+ CBenTOCReader TOCReader(this);
+ if ((Err = TOCReader.ReadLabelAndTOC()) != BenErr_OK)
+ {
+ return Err;
+ }
+ return BenErr_OK;
+}
+
+void
+LtcBenContainer::RegisterPropertyName(const char * sPropertyName,
+ CBenPropertyName ** ppPropertyName)
+{
+ CUtListElmt * pPrevNamedObjectListElmt;
+ CBenNamedObject * pNamedObject = FindNamedObject(&cNamedObjects,
+ sPropertyName, &pPrevNamedObjectListElmt);
+
+ if (pNamedObject != nullptr)
+ {
+ if (! pNamedObject->IsPropertyName())
+ return;
+ else *ppPropertyName = static_cast<CBenPropertyName *>(pNamedObject);
+ }
+ else
+ {
+ CUtListElmt * pPrevObject;
+ if (FindID(&cObjects, cNextAvailObjectID, &pPrevObject) != nullptr)
+ return;
+
+ *ppPropertyName = new CBenPropertyName(this, cNextAvailObjectID,
+ pPrevObject, sPropertyName, pPrevNamedObjectListElmt);
+ ++cNextAvailObjectID;
+ }
+}
+
+CBenObject *
+LtcBenContainer::GetNextObject(CBenObject const * pCurrObject)
+{
+ return static_cast<CBenObject *>(cObjects.GetNextOrNULL(pCurrObject));
+}
+
+CBenObject *
+LtcBenContainer::FindNextObjectWithProperty(CBenObject * pCurrObject,
+ BenObjectID PropertyID)
+{
+ while ((pCurrObject = GetNextObject(pCurrObject)) != nullptr)
+ if (pCurrObject->UseProperty(PropertyID) != nullptr)
+ return pCurrObject;
+
+ return nullptr;
+}
+
+/**
+* Construction
+* @param Bento file stream pointer
+* @return
+*/
+LtcBenContainer::LtcBenContainer(LwpSvStream * pStream)
+ : cNextAvailObjectID(0)
+{
+ cpStream = pStream;
+ pStream->Seek(STREAM_SEEK_TO_END);
+ m_ulLength = pStream->Tell();
+ pStream->Seek(STREAM_SEEK_TO_BEGIN);
+}
+
+/**
+* Read buffer for bento file with specified buffer
+* @param buffer pointer
+* @param buffer size
+* @param number of bytes read
+*/
+void LtcBenContainer::Read(void * pBuffer, size_t MaxSize,
+ size_t* pAmtRead)
+{
+ *pAmtRead = cpStream->Read(pBuffer, MaxSize);
+}
+/**
+* Read buffer from bento file with specified size
+* @param buffer pointer
+* @param number of bytes to be read
+* @return BenError
+*/
+BenError LtcBenContainer::ReadKnownSize(void * pBuffer, size_t Amt)
+{
+ size_t ulLength = cpStream->Read(pBuffer, Amt);
+ if (ulLength == Amt)
+ {
+ return BenErr_OK;
+ }
+ return BenErr_ReadPastEndOfContainer;
+}
+/**
+* Seek to position from the beginning of the bento file
+* @param position in container file from beginning
+*/
+void LtcBenContainer::SeekToPosition(BenContainerPos Pos)
+{
+ cpStream->Seek(Pos);
+}
+/**
+* Seek to position compare to end of bento file
+* @param position in container file from end
+*/
+void LtcBenContainer::SeekFromEnd(tools::Long Offset)
+{
+ cpStream->Seek(STREAM_SEEK_TO_END);
+ cpStream->SeekRel(Offset);
+}
+/**
+* Find the next value stream with property name
+* @param string of property name
+* @return next value stream pointer with the property names
+*/
+LtcUtBenValueStream * LtcBenContainer::FindNextValueStreamWithPropertyName(const char * sPropertyName)
+{
+ CBenPropertyName * pPropertyName(nullptr);
+ RegisterPropertyName(sPropertyName, &pPropertyName); // Get property name object
+
+ if (nullptr == pPropertyName)
+ return nullptr; // Property not exist
+
+ // Get current object
+ CBenObject * pObj =FindNextObjectWithProperty(nullptr, pPropertyName->GetID()); // Get next object with same property name
+ if (nullptr == pObj)
+ return nullptr;
+
+ CBenValue * pValue;
+ LtcUtBenValueStream * pValueStream;
+
+ pValue = pObj->UseValue(pPropertyName->GetID());
+
+ pValueStream = new LtcUtBenValueStream(pValue);
+
+ return pValueStream;
+}
+
+/**
+* Find the unique value stream with property name
+* @param string of property name
+* @return the only value stream pointer with the property names
+*/
+LtcUtBenValueStream * LtcBenContainer::FindValueStreamWithPropertyName(const char * sPropertyName)
+{
+ return FindNextValueStreamWithPropertyName(sPropertyName);
+}
+
+namespace
+{
+ void readDataInBlocks(SvStream& rSt, sal_uInt64 nDLen, std::vector<sal_uInt8>& rData)
+ {
+ //read data in blocks as it's more likely large values are simply broken
+ //and we'll run out of data before we need to realloc
+ for (sal_uInt64 i = 0; i < nDLen; i+= SAL_MAX_UINT16)
+ {
+ size_t nOldSize = rData.size();
+ size_t nBlock = std::min<size_t>(SAL_MAX_UINT16, nDLen - nOldSize);
+ rData.resize(nOldSize + nBlock);
+ size_t nReadBlock = rSt.ReadBytes(rData.data() + nOldSize, nBlock);
+ if (nBlock != nReadBlock)
+ {
+ rData.resize(nOldSize + nReadBlock);
+ break;
+ }
+ }
+ }
+}
+
+/**
+* Find hazily according to object ID
+* @param pObjectname - format as "GrXX,XXXXXXXX" wherein XX is high part of object ID, and XXXXXXXX is low part
+*/
+std::vector<sal_uInt8> LtcBenContainer::GetGraphicData(const char *pObjectName)
+{
+ std::vector<sal_uInt8> aData;
+ if (!pObjectName)
+ {
+ return aData;
+ }
+ // construct the string of property name
+ char sSName[64]="";
+ char sDName[64]="";
+
+ sprintf(sSName, "%s-S", pObjectName);
+ sprintf(sDName, "%s-D", pObjectName);
+
+ /* traverse the found properties and construct the stream vectors */
+ // get S&D's stream and merge them together
+ std::unique_ptr<SvStream> xS(FindValueStreamWithPropertyName(sSName));
+ std::unique_ptr<SvStream> xD(FindValueStreamWithPropertyName(sDName));
+
+ sal_uInt64 nDLen = 0;
+ if (xD)
+ {
+ nDLen = xD->TellEnd();
+ }
+ sal_uInt64 nSLen = 0;
+ if (xS)
+ {
+ nSLen = xS->TellEnd();
+ }
+
+ sal_uInt64 nLen = nDLen + nSLen;
+ OSL_ENSURE(nLen > 0, "expected a non-0 length");
+ // the 'D' stream is NULL or it has invalid length
+ if (nLen <= 0)
+ {
+ return aData;
+ }
+
+ if (xD)
+ {
+ readDataInBlocks(*xD, nDLen, aData);
+ xD.reset();
+ }
+ if (xS)
+ {
+ readDataInBlocks(*xS, nSLen, aData);
+ xS.reset();
+ }
+
+ return aData;
+}
+
+sal_uLong LtcBenContainer::remainingSize() const
+{
+ return m_ulLength - cpStream->Tell();
+}
+
+}// end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/benlist.cxx b/lotuswordpro/source/filter/benlist.cxx
new file mode 100644
index 000000000..1972254fe
--- /dev/null
+++ b/lotuswordpro/source/filter/benlist.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "first.hxx"
+namespace OpenStormBento
+{
+CBenNamedObject* FindNamedObject(CUtList* pList, std::string_view rName, CUtListElmt** ppPrev)
+{
+ CUtListElmt& rTerminating = pList->GetTerminating();
+ for (CUtListElmt* pCurr = pList->GetLast(); pCurr != &rTerminating; pCurr = pCurr->GetPrev())
+ {
+ CBenNamedObjectListElmt* pCurrNamedObjectListElmt
+ = static_cast<CBenNamedObjectListElmt*>(pCurr);
+
+ sal_Int32 Comp = rName.compare(pCurrNamedObjectListElmt->GetNamedObject()->GetName());
+
+ if (Comp == 0)
+ return pCurrNamedObjectListElmt->GetNamedObject();
+ else if (Comp < 0)
+ continue;
+ else
+ {
+ if (ppPrev != nullptr)
+ *ppPrev = pCurrNamedObjectListElmt;
+ return nullptr;
+ }
+ }
+
+ if (ppPrev != nullptr)
+ *ppPrev = &rTerminating;
+ return nullptr;
+}
+
+// Assume list is of BenIDListElmt list elements, sorted by ID
+CBenIDListElmt* FindID(CUtList* pList, BenObjectID ObjectID, CUtListElmt** ppPrev)
+{
+ CUtListElmt& rTerminating = pList->GetTerminating();
+ for (CUtListElmt* pCurr = pList->GetLast(); pCurr != &rTerminating; pCurr = pCurr->GetPrev())
+ {
+ CBenIDListElmt* pCurrIDListElmt = static_cast<CBenIDListElmt*>(pCurr);
+
+ if (ObjectID == pCurrIDListElmt->GetID())
+ return pCurrIDListElmt;
+ else if (ObjectID < pCurrIDListElmt->GetID())
+ continue;
+ else
+ {
+ if (ppPrev != nullptr)
+ *ppPrev = pCurrIDListElmt;
+ return nullptr;
+ }
+ }
+
+ if (ppPrev != nullptr)
+ *ppPrev = &rTerminating;
+ return nullptr;
+}
+} //end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/benname.cxx b/lotuswordpro/source/filter/benname.cxx
new file mode 100644
index 000000000..d65799ce2
--- /dev/null
+++ b/lotuswordpro/source/filter/benname.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "bento.hxx"
+
+namespace OpenStormBento
+{
+// changed to remove warning
+CBenNamedObject::CBenNamedObject(LtcBenContainer * pContainer,
+ BenObjectID ObjectID, CUtListElmt * pPrevObject, const OString& rName,
+ CUtListElmt * pPrevNamedObjectListElmt)
+ : CBenObject(pContainer, ObjectID, pPrevObject)
+ , csName(rName)
+ , cNameListElmt(pPrevNamedObjectListElmt)
+{
+ cNameListElmt.SetNamedObject(this);
+}
+
+bool CBenNamedObject::IsPropertyName()
+{ return false; }
+
+bool CBenPropertyName::IsPropertyName()
+{ return true; }
+
+} // end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/benobj.cxx b/lotuswordpro/source/filter/benobj.cxx
new file mode 100644
index 000000000..7a112407c
--- /dev/null
+++ b/lotuswordpro/source/filter/benobj.cxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "first.hxx"
+
+namespace OpenStormBento
+{
+CBenProperty* CBenObject::UseProperty(BenObjectID PropertyID)
+{
+ CUtListElmt* pPrev;
+ return static_cast<CBenProperty*>(FindID(&cProperties, PropertyID, &pPrev));
+}
+
+CBenValue* CBenObject::UseValue(BenObjectID PropertyID)
+{
+ CBenProperty* pProperty = UseProperty(PropertyID);
+ if (pProperty == nullptr)
+ return nullptr;
+ return &pProperty->UseValue();
+}
+
+} // end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/bento.hxx b/lotuswordpro/source/filter/bento.hxx
new file mode 100644
index 000000000..b506c525a
--- /dev/null
+++ b/lotuswordpro/source/filter/bento.hxx
@@ -0,0 +1,378 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_BENTO_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_BENTO_HXX
+
+#include <sal/config.h>
+
+#include <cstring>
+#include <memory>
+#include <vector>
+#include <lwpsvstream.hxx>
+
+#define BEN_CC __stdcall
+#ifdef COMP_BENTO
+#define BEN_EXPORT __declspec(dllexport)
+#else
+#define BEN_EXPORT
+#endif
+
+#include "utlist.hxx"
+#include <tools/stream.hxx>
+#include <tools/solar.h>
+
+namespace OpenStormBento
+{
+
+#define BEN_CURR_MAJOR_VERSION 2
+#define BEN_CURR_MINOR_VERSION 0
+#define BEN_MAGIC_BYTES_SIZE 8
+#define BEN_LABEL_SIZE 24
+
+#define BEN_MAGIC_BYTES "\xA4""CM""\xA5""Hdr""\xD7"
+
+enum BenError
+{
+ BenErr_OK = 0,
+ BenErr_NameConflict = 1,
+ BenErr_DuplicateObjectID = 2,
+ BenErr_UnknownBentoFormatVersion = 3,
+ BenErr_NamedObjectError = 4,
+ BenErr_NamedObjectIllegalValue = 5,
+ BenErr_InvalidTOC = 6,
+ BenErr_64BitOffsetNotSupported = 7,
+ BenErr_ReadPastEndOfTOC = 8,
+ BenErr_ContainerWithNoObjects = 9,
+ BenErr_ObjectWithNoProperties = 10,
+ BenErr_PropertyWithNoValues = 11,
+ BenErr_IllegalInMemoryTOC = 12,
+ BenErr_PropertyAlreadyExists = 13,
+ BenErr_UnexpectedEndOfFile = 14,
+ BenErr_InvalidWriteOffset = 15,
+ BenErr_InvalidImmediateWrite = 16,
+ BenErr_TOCSeedError = 17,
+ BenErr_ReadPastEndOfContainer = 18,
+ BenErr_DuplicateName = 19,
+ BenErr_BadReferencedList = 20,
+ BenErr_IllegalContinuedImmediate = 21,
+ BenErr_NotBentoContainer = 22,
+ BenErr_PropertyWithMoreThanOneValue = 23
+
+ // IMPORTANT - UtStream errors (UtErr_...) are also valid Bento
+ // errors. They have codes of 100 and higher. When, say, a Bento
+ // container open fails due to an access violation (somebody else, say,
+ // has it open exclusive), will get a UtErr code. If define own
+ // subclass of UtStream (custom handler), can define own error codes--
+ // those should start at 200
+};
+
+class LtcBenContainer;
+class CBenObject;
+class CBenProperty;
+class CBenValue;
+class CBenValueSegment;
+class CBenNamedObject;
+class CBenPropertyName;
+
+typedef sal_uInt8 BenByte;
+typedef sal_uInt16 BenWord;
+typedef sal_uInt32 BenDWord;
+
+typedef sal_uInt32 BenContainerPos;
+typedef sal_uInt32 BenObjectID;
+typedef sal_uInt32 BenGeneration;
+
+sal_uLong BenOpenContainer(LwpSvStream * pStream, std::unique_ptr<LtcBenContainer>* ppContainer);
+
+class CBenIDListElmt : public CUtListElmt
+{
+public: // Internal methods
+ CBenIDListElmt(BenObjectID ID, CUtListElmt * pPrev) : CUtListElmt(pPrev), cID(ID)
+ { }
+ explicit CBenIDListElmt(BenObjectID ID) : cID(ID) { }
+ BenObjectID GetID() const { return cID; }
+
+private: // Data
+ BenObjectID cID;
+};
+
+class CBenNamedObjectListElmt : public CUtListElmt
+{
+public: // Methods
+ // added to remove warning
+ explicit CBenNamedObjectListElmt(CUtListElmt * pPrev) : CUtListElmt(pPrev)
+ { cpNamedObject = nullptr; }
+ void SetNamedObject(CBenNamedObject * pObj)
+ {
+ cpNamedObject = pObj;
+ }
+
+ CBenNamedObject * GetNamedObject() { return cpNamedObject; }
+
+private: // Data
+ CBenNamedObject * cpNamedObject;
+};
+
+class LtcUtBenValueStream : public SvStream
+{
+public:
+ explicit LtcUtBenValueStream(CBenValue * pValue);
+ virtual ~LtcUtBenValueStream() override;
+
+public: // Overridden methods
+
+ /* added by */
+ sal_uLong GetSize() const { return m_ulValueLength; };
+protected: // Overridden methods
+
+ virtual std::size_t GetData(void* pData, std::size_t nSize) override;
+ virtual std::size_t PutData(const void* pData, std::size_t nSize) override;
+ virtual sal_uInt64 SeekPos( sal_uInt64 nPos ) override;
+ virtual void SetSize( sal_uInt64 nSize ) override;
+ virtual void FlushData() override;
+
+private: // Data
+ CBenValue * cpValue;
+ size_t cCurrentPosition;
+
+ sal_uLong m_ulValueLength; // Added by , sum of length of all sub-valuesegments
+};
+
+class LtcBenContainer
+{
+public:
+ BenError Open();
+ void RegisterPropertyName(const char * sPropertyName,
+ CBenPropertyName ** ppPropertyName);
+ // Pass NULL to begin iteration. Done when returns NULL.
+ // Objects are returned in order of increasing ID
+ CBenObject * GetNextObject(CBenObject const * pCurrObject);
+ CBenObject * FindNextObjectWithProperty(CBenObject * pCurrObject,
+ BenObjectID PropertyID);
+
+public: // Internal methods
+ explicit LtcBenContainer(LwpSvStream * pStream);
+ ~LtcBenContainer();
+
+ sal_uLong remainingSize() const;
+ void Read(void * pBuffer, size_t MaxSize,
+ size_t* pAmtRead);
+ BenError ReadKnownSize(void * pBuffer, size_t Amt);
+ void SeekToPosition(BenContainerPos Pos);
+ void SeekFromEnd(tools::Long Offset);
+
+ void SetNextAvailObjectID(BenObjectID ID) { cNextAvailObjectID = ID; }
+ CUtList& GetObjects() { return cObjects; }
+ CUtList& GetNamedObjects() { return cNamedObjects; }
+
+ LtcUtBenValueStream * FindNextValueStreamWithPropertyName(const char * sPropertyName);
+ LtcUtBenValueStream * FindValueStreamWithPropertyName(const char * sPropertyName);
+ std::vector<sal_uInt8> GetGraphicData(const char *pObjectName);
+
+ sal_uLong GetSize() const { return m_ulLength; }
+private: // Data
+ CUtOwningList cObjects;
+ CUtList cNamedObjects;
+ LwpSvStream * cpStream;
+ sal_uLong m_ulLength; // Added for TOCRead.cpp
+ BenObjectID cNextAvailObjectID; // for new object
+};
+
+class CBenObject : public CBenIDListElmt
+{
+public:
+ CBenProperty * UseProperty(BenObjectID PropertyID);
+ CBenValue * UseValue(BenObjectID PropertyID);
+ LtcBenContainer * GetContainer() { return cpContainer; }
+public: // Internal methods
+ CBenObject(LtcBenContainer * pContainer, BenObjectID ObjectID,
+ CUtListElmt * pPrev) : CBenIDListElmt(ObjectID, pPrev)
+ { cpContainer = pContainer; }
+ CUtList& GetProperties() { return cProperties; }
+
+private: // Data
+ LtcBenContainer * cpContainer;
+ CUtOwningList cProperties;
+};
+
+class CBenValue : public CBenIDListElmt
+{
+public:
+ size_t GetValueSize();
+ void ReadValueData(void * pBuffer,
+ size_t Offset, size_t MaxSize, size_t* pAmtRead);
+
+ CBenProperty * BEN_EXPORT GetProperty() { return cpProperty; }
+
+public: // Internal methods
+ // added to remove WARNING
+ explicit CBenValue(BenObjectID TypeID):CBenIDListElmt(TypeID)
+ {
+ cpProperty = nullptr;
+ }
+
+ void SetProperty(CBenProperty * pProperty)
+ {
+ cpProperty = pProperty;
+ }
+
+ inline CBenValueSegment * GetNextValueSegment(CBenValueSegment const *
+ pCurrValueSegment);
+ CUtList& GetValueSegments() { return cValueSegments; }
+
+private: // Data
+ CBenProperty * cpProperty;
+ CUtOwningList cValueSegments;
+};
+
+class CBenProperty : public CBenIDListElmt
+{
+public:
+ // In the Apple Bento, a property can have multiple values, each of a
+ // different type. But we never use it that way, so in this code a
+ // property has exactly one value
+
+ CBenValue& UseValue() { return cValue; }
+ CBenObject * GetBenObject() { return cpObject; }
+ LtcBenContainer * GetContainer() { return GetBenObject()->GetContainer(); }
+
+public: // Internal methods
+ // changed to remove WARNING here
+ CBenProperty(CBenObject * pObject, BenObjectID PropertyID,
+ BenObjectID TypeID, CUtListElmt * pPrevProperty) :
+ CBenIDListElmt(PropertyID, pPrevProperty), cValue(TypeID)
+ {
+ cpObject = pObject;
+ cValue.SetProperty(this);
+ }
+private: // Data
+ CBenObject * cpObject;
+ CBenValue cValue;
+};
+
+class CBenValueSegment : public CUtListElmt
+{
+public: // Internal methods
+ CBenValueSegment(CBenValue * pValue, BenContainerPos Pos,
+ size_t Size) : CUtListElmt(&pValue->GetValueSegments())
+ { cImmediate = false; cPos = Pos;
+ cSize = Size; }
+ CBenValueSegment(CBenValue * pValue, const void * pImmData,
+ unsigned short Size) : CUtListElmt(&pValue->GetValueSegments())
+ { cImmediate = true;
+ std::memcpy(cImmData, pImmData, Size); cSize = Size; }
+ bool IsImmediate() const { return cImmediate; }
+ BenContainerPos GetPosition() const { return cPos; }
+ size_t GetSize() const { return cSize; }
+ BenByte * GetImmediateData() { return cImmData; }
+
+private: // Data
+ bool cImmediate;
+ union
+ {
+ BenContainerPos cPos;
+ BenByte cImmData[4];
+ };
+ size_t cSize;
+};
+
+inline CBenValueSegment * CBenValue::GetNextValueSegment(CBenValueSegment const *
+ pCurrValueSegment)
+{ return static_cast<CBenValueSegment *>( cValueSegments.GetNextOrNULL(pCurrValueSegment) ); }
+
+
+class CBenNamedObject : public CBenObject
+{
+public: // Methods
+ virtual bool IsPropertyName();
+
+public: // Internal methods
+ CBenNamedObject(LtcBenContainer * pContainer, BenObjectID ObjectID,
+ CUtListElmt * pPrevObject, const OString& rName,
+ CUtListElmt * pPrevNamedObjectListElmt);
+
+ const OString& GetName() const { return csName; }
+
+private: // Data
+ OString csName;
+ CBenNamedObjectListElmt cNameListElmt;
+};
+
+class CBenPropertyName : public CBenNamedObject
+{
+public: // Internal methods
+ CBenPropertyName(LtcBenContainer * pContainer, BenObjectID ObjectID,
+ CUtListElmt * pPrevObject, const OString& rName,
+ CUtListElmt * pPrevNamedObjectListElmt) :
+ CBenNamedObject(pContainer, ObjectID, pPrevObject, rName,
+ pPrevNamedObjectListElmt) { ; }
+ virtual bool IsPropertyName() override;
+};
+
+class CBenTypeName : public CBenNamedObject
+{
+public: // Internal methods
+ CBenTypeName(LtcBenContainer * pContainer, BenObjectID ObjectID,
+ CUtListElmt * pPrevObject, const OString& rName,
+ CUtListElmt * pPrevNamedObjectListElmt) :
+ CBenNamedObject(pContainer, ObjectID, pPrevObject, rName,
+ pPrevNamedObjectListElmt) { ; }
+};
+
+} // end namespace OpenStormBento
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/bentoid.hxx b/lotuswordpro/source/filter/bentoid.hxx
new file mode 100644
index 000000000..cb3d9fb27
--- /dev/null
+++ b/lotuswordpro/source/filter/bentoid.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_BENTOID_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_BENTOID_HXX
+
+namespace OpenStormBento
+{
+#define BEN_OBJID_TOC 1 // TOC object ID
+#define BEN_PROPID_TOC_SEED 2 // TOC object starting seed
+#define BEN_TYPEID_TOC_TYPE 19 // TOC object property value type
+#define BEN_TYPEID_7_BIT_ASCII 21 // 7-bit ASCII
+#define BEN_PROPID_GLOBAL_TYPE_NAME 23 // Global type name
+#define BEN_PROPID_GLOBAL_PROPERTY_NAME 24 // Global property name
+#define BEN_PROPID_OBJ_REFERENCES 31 // Referenced objects from an object
+
+#define BEN_NEW_OBJECT 1 // object + property + type
+#define BEN_NEW_PROPERTY 2 // property + type
+#define BEN_NEW_TYPE 3 // type
+#define BEN_EXPLICIT_GEN 4 // generation
+
+#define BEN_SEGMENT_CODE_START 5
+#define BEN_OFFSET4_LEN4 5 // 4-byte offset + 4-byte length
+#define BEN_CONT_OFFSET4_LEN4 6 // continued 4-byte offset + 4-byte length
+#define BEN_OFFSET8_LEN4 7 // 8-byte offset + 4-byte length
+#define BEN_CONT_OFFSET8_LEN4 8 // continued 8-byte offset + 4-byte length
+#define BEN_IMMEDIATE0 9 // immediate (length = 0)
+#define BEN_IMMEDIATE1 10 // immediate (length = 1)
+#define BEN_IMMEDIATE2 11 // immediate (length = 2)
+#define BEN_IMMEDIATE3 12 // immediate (length = 3)
+#define BEN_IMMEDIATE4 13 // immediate (length = 4)
+#define BEN_CONT_IMMEDIATE4 14 // continued immediate (length = 4)
+#define BEN_SEGMENT_CODE_END 14
+
+#define BEN_REFERENCE_LIST_ID 15 // references recording object ID
+#define BEN_END_OF_BUFFER 24 // end of current buffer, go to next
+#define BEN_READ_PAST_END_OF_TOC 50 // Our code
+#define BEN_NOOP 0xFF
+
+} // end OpenStormBento namespace
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/benval.cxx b/lotuswordpro/source/filter/benval.cxx
new file mode 100644
index 000000000..ec60c8c0e
--- /dev/null
+++ b/lotuswordpro/source/filter/benval.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sal/config.h>
+
+#include <algorithm>
+#include <cstring>
+
+#include "bento.hxx"
+
+namespace OpenStormBento
+{
+
+size_t
+CBenValue::GetValueSize()
+{
+ size_t Size = 0;
+ CBenValueSegment * pCurr = nullptr;
+ while ((pCurr = GetNextValueSegment(pCurr)) != nullptr)
+ Size += pCurr->GetSize();
+ return Size;
+}
+
+void
+CBenValue::ReadValueData(void * pReadBuffer, size_t Offset,
+ size_t Amt, size_t* pAmtRead)
+{
+ size_t SegOffset = 0;
+ *pAmtRead = 0;
+ CBenValueSegment * pCurrSeg = nullptr;
+ LtcBenContainer * pContainer = GetProperty()->GetContainer();
+ BenByte* pBuffer = static_cast<BenByte*>(pReadBuffer);
+
+ /// pReadBuffer -- pointer to buffer of read result, allocated outside this function
+ /// Offset -- read buffer's start offset address, relative value in the whole value stream
+ /// Amt -- read buffer's size
+ /// pAmtRead -- return the actual read size
+
+ /// SegOffset -- current segment's start address offset, relative value in the whole value stream
+
+ while ((pCurrSeg = GetNextValueSegment(pCurrSeg)) != nullptr)
+ {
+ if (Amt == 0) /// whole buffer is full now, so return
+ return;
+
+ if (SegOffset <= Offset && Offset < SegOffset + pCurrSeg->GetSize()) /// begin at current segment
+ {
+ size_t OffsetIntoSeg = Offset - SegOffset; /// relative value in this value segment stream
+
+ size_t AmtThisSeg = std::min(Amt, pCurrSeg->GetSize() -
+ OffsetIntoSeg); /// size read in this segment, it's minimal value between Amt &
+ /// remain part from OffsetIntoSeg to the end of this segment
+
+ size_t AmtReadThisSeg; /// actual read size in this segment
+ if (pCurrSeg->IsImmediate())
+ {
+ std::memcpy(pBuffer, pCurrSeg->GetImmediateData() +
+ OffsetIntoSeg, AmtThisSeg);
+ AmtReadThisSeg = AmtThisSeg;
+ }
+ else
+ {
+ pContainer->SeekToPosition(pCurrSeg->GetPosition() +
+ OffsetIntoSeg);
+ pContainer->Read(pBuffer, AmtThisSeg, &AmtReadThisSeg);
+ }
+
+ *pAmtRead += AmtReadThisSeg;
+
+ if (AmtThisSeg != AmtReadThisSeg)
+ return;
+
+ pBuffer += AmtReadThisSeg;
+ Offset += AmtReadThisSeg;
+ Amt -= AmtReadThisSeg;
+ }
+
+ SegOffset += pCurrSeg->GetSize();
+ }
+}
+
+}//end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/clone.hxx b/lotuswordpro/source/filter/clone.hxx
new file mode 100644
index 000000000..fe4c64519
--- /dev/null
+++ b/lotuswordpro/source/filter/clone.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
+
+namespace detail
+{
+
+template<typename T>
+struct has_clone
+{
+ template<typename U, U x>
+ struct test;
+
+ typedef char yes;
+ typedef struct { char a[2]; } no;
+
+ template<typename U>
+ static yes& check_sig(U*, test<U* (U::*)() const, &U::clone>* = nullptr);
+ template<typename U>
+ static no& check_sig(...);
+
+ enum
+ {
+ value = sizeof(check_sig<T>(nullptr)) == sizeof(yes)
+ };
+};
+
+template<typename T, bool HasClone>
+struct cloner
+{
+ static T* clone(T* const other)
+ {
+ return new T(*other);
+ }
+};
+
+template<typename T>
+struct cloner<T, true>
+{
+ static T* clone(T* const other)
+ {
+ return other->clone();
+ }
+};
+
+}
+
+/** Creates a new copy of the passed object.
+ If other is 0, just returns 0. Otherwise, if other has function
+ named clone with signature T* (T::*)() const, the function is called.
+ Otherwise, copy constructor is used.
+
+ @returns 0 or newly allocated object
+ */
+template<typename T>
+T* clone(T* const other)
+{
+ return other ? ::detail::cloner<T, ::detail::has_clone<T>::value>::clone(other) : nullptr;
+}
+
+#endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/explode.cxx b/lotuswordpro/source/filter/explode.cxx
new file mode 100644
index 000000000..a001254d0
--- /dev/null
+++ b/lotuswordpro/source/filter/explode.cxx
@@ -0,0 +1,509 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "explode.hxx"
+#include <tools/stream.hxx>
+
+#include <algorithm>
+#include <assert.h>
+#include <math.h>
+
+ const char Tree1String[][32] = {
+ "101",
+ "11",
+ "100",
+ "011",
+ "0101",
+ "0100",
+ "0011",
+ "00101",
+ "00100",
+ "00011",
+ "00010",
+ "000011",
+ "000010",
+ "000001",
+ "0000001",
+ "0000000",
+ };
+
+ const char Tree2String[][32] = {
+ "11" ,
+ "1011" ,
+ "1010" ,
+ "10011" ,
+ "10010" ,
+ "10001" ,
+ "10000" ,
+ "011111" ,
+ "011110" ,
+ "011101" ,
+ "011100" ,
+ "011011" ,
+ "011010" ,
+ "011001" ,
+ "011000" ,
+ "010111" ,
+ "010110" ,
+ "010101" ,
+ "010100" ,
+ "010011" ,
+ "010010" ,
+ "010001" ,
+ "0100001" ,
+ "0100000" ,
+ "0011111" ,
+ "0011110" ,
+ "0011101" ,
+ "0011100" ,
+ "0011011" ,
+ "0011010" ,
+ "0011001" ,
+ "0011000" ,
+ "0010111" ,
+ "0010110" ,
+ "0010101" ,
+ "0010100" ,
+ "0010011" ,
+ "0010010" ,
+ "0010001" ,
+ "0010000" ,
+ "0001111" ,
+ "0001110" ,
+ "0001101" ,
+ "0001100" ,
+ "0001011" ,
+ "0001010" ,
+ "0001001" ,
+ "0001000" ,
+ "00001111",
+ "00001110",
+ "00001101",
+ "00001100",
+ "00001011",
+ "00001010",
+ "00001001",
+ "00001000",
+ "00000111",
+ "00000110",
+ "00000101",
+ "00000100",
+ "00000011",
+ "00000010",
+ "00000001",
+ "00000000",
+ };
+
+Decompression::Decompression(SvStream * pInStream, SvStream * pOutStream)
+ : m_pInStream(pInStream)
+ , m_pOutStream(pOutStream)
+ , m_nCurrent4Byte(0)
+ , m_nBitsLeft(0)
+ , m_pBuffer(m_Buffer)
+ , m_nBytesLeft(0)
+ , m_nOutputBufferPos(0)
+{
+ if (!m_pInStream || !m_pOutStream )
+ {
+ assert(false);
+ }
+ ConstructTree1();
+ ConstructTree2();
+ fillArray();
+}
+/**
+ * @descr read specified bits from input stream
+ * @argument iCount - number of bits to be read, less than 31
+ * @argument nBits - bits read
+ * @return 0 - read OK, otherwise error
+ */
+sal_uInt32 Decompression::ReadBits(sal_uInt16 iCount, sal_uInt32 & nBits)
+{
+ if ( (iCount == 0) || (iCount > 31 ) )
+ {
+ return 1;
+ }
+
+ /* load at least need bits into val */
+ sal_uInt32 val = m_nCurrent4Byte; /* bit accumulator */
+ while (m_nBitsLeft < iCount)
+ {
+ if (m_nBytesLeft == 0)
+ {
+ m_nBytesLeft = m_pInStream->ReadBytes(m_Buffer, CHUNK);
+ m_pBuffer = m_Buffer;
+ if (m_nBytesLeft == 0) return 1;
+ }
+ val |= static_cast<sal_uInt32>(*m_pBuffer++) << m_nBitsLeft; /* load eight bits */
+ m_nBytesLeft --;
+ m_nBitsLeft += 8;
+ }
+
+ /* drop need bits and update buffer, always zero to seven bits left */
+ m_nCurrent4Byte = val >> iCount;
+ m_nBitsLeft -= iCount;
+
+ /* return need bits, zeroing the bits above that */
+ nBits = val & ((1U << iCount) - 1);
+
+ return 0;
+}
+/**
+ * @descr decompress input and write output
+ * @return 0 - read OK, otherwise error
+ */
+sal_Int32 Decompression::explode()
+{
+ /* The first 2 bytes are parameters */
+ sal_uInt32 P1;
+ if (0 != ReadBits(8, P1))/* 0 or 1 */
+ return -1;
+
+ /* I think this means 0=binary and 1=ascii file, but in RESOURCEs I saw always 0 */
+ if (P1 >= 1) // changed per 's review comments
+ return -1;
+
+ sal_uInt32 P2;
+ if (0 != ReadBits(8, P2))
+ return -1;
+
+ /* must be 4,5 or 6 and it is a parameter for the decompression algorithm */
+ if (P2 < 4 || P2 > 6)
+ return -2;
+
+ m_nOutputBufferPos = 0;
+ /* Now, a bit stream follows, which is decoded as described below: */
+ /* The algorithm terminates as soon as it runs out of bits. */
+ while(true)
+ {
+ // read 1 bit (take bits from the lowest value (LSB) to the MSB i.e. bit 0, bit 1 etc ...)
+ sal_uInt32 iBit;
+ if (0 != ReadBits(1, iBit))
+ break;
+ if ( 0 == (iBit & 0x01) )
+ {
+ //if the bit is 0 read 8 bits and write it to the output as it is.
+ sal_uInt32 symbol;
+ if (0 != ReadBits(8, symbol))
+ break;
+ m_Output[m_nOutputBufferPos++] = static_cast<sal_uInt8>(symbol);
+ if (m_nOutputBufferPos == MAXWIN)
+ {
+ m_pOutStream->WriteBytes(m_Output, m_nOutputBufferPos);
+ m_nOutputBufferPos = 0;
+ }
+ continue;
+ }
+ // if the bit is 1 we have here a length/distance pair:
+ // -decode a number with Hufmman Tree #1; variable bit length, result is 0x00 .. 0x0F -> L1
+ sal_uInt32 L1 = Decode(m_Tree1.get());
+ sal_uInt32 Length;
+ if (L1 <= 7)
+ {
+ //if L1 <= 7:
+ // LENGTH = L1 + 2
+ Length = L1 + 2;
+ }
+ else
+ {
+ // if L1 > 7
+ // read more (L1-7) bits -> L2
+ // LENGTH = L2 + M[L1-7] + 2
+ sal_uInt32 L2;
+ if (0 != ReadBits(static_cast<sal_uInt16>(L1 - 7), L2))
+ break;
+ Length = L2 + 2 + m_iArrayOfM[L1 -7];
+ }
+ if (Length == 519)
+ {
+ // end of compressed data
+ break;
+ }
+
+ // - decode another number with Hufmann Tree #2 giving result 0x00..0x3F -> D1
+ sal_uInt32 D1 = Decode(m_Tree2.get());
+ sal_uInt32 D2;
+ if (Length == 2)
+ {
+ // if LENGTH == 2
+ // D1 = D1 << 2
+ // read 2 bits -> D2
+ D1 = D1 << 2;
+ if (0 != ReadBits(2, D2))
+ break;
+ }
+ else
+ {
+ // else
+ // D1 = D1 << P2 // the parameter 2
+ // read P2 bits -> D2
+ D1 = D1 << P2;
+ if (0 != ReadBits(static_cast<sal_uInt16>(P2), D2))
+ break;
+ }
+ // DISTANCE = (D1 | D2) + 1
+ sal_uInt32 distance = (D1 | D2) + 1;
+
+ // - now copy LENGTH bytes from (output_ptr-DISTANCE) to output_ptr
+ // write current buffer to output
+ m_pOutStream->WriteBytes(m_Output, m_nOutputBufferPos);
+ m_nOutputBufferPos = 0;
+
+ // remember current position
+ sal_uInt32 nOutputPos = m_pOutStream->Tell();
+ if (distance > nOutputPos)
+ return -3; // format error
+
+ m_pOutStream->FlushBuffer();
+ // point back to copy position and read bytes
+ m_pOutStream->SeekRel(-static_cast<tools::Long>(distance));
+ sal_uInt8 sTemp[MAXWIN];
+ sal_uInt32 nRead = std::min(distance, Length);
+ m_pOutStream->ReadBytes(sTemp, nRead);
+ if (nRead != Length)
+ {
+ // fill the buffer with read content repeatedly until full
+ for (sal_uInt32 i=nRead; i<Length; i++)
+ {
+ sTemp[i] = sTemp[i-nRead];
+ }
+ }
+
+ // restore output stream position
+ m_pOutStream->Seek(nOutputPos);
+
+ // write current buffer to output
+ m_pOutStream->WriteBytes(sTemp, Length);
+ }
+ return 0;
+}
+/**
+ * @descr bits to string
+ * @return
+ */
+void Decompression::ToString(sal_uInt32 nBits, char *pChar, sal_uInt32 nLen)
+{
+ sal_uInt32 nBit;
+ for (sal_uInt32 i=nLen; i > 0; i--)
+ {
+ nBit = (nBits >> (i -1) ) & 0x01;
+ pChar[nLen - i] = nBit ? '1':'0';
+ }
+ pChar[nLen] = '\0';
+}
+
+/**
+ * @descr decode tree 1 for length
+ * @return the decoded value
+ */
+sal_uInt32 Decompression::Decode(HuffmanTreeNode * pRoot)
+{
+ sal_uInt32 nRet(0);
+ sal_uInt32 nRead, nReadAlready;
+
+ if( 0 != ReadBits(1, nReadAlready))
+ return 0; // something wrong
+
+ for (sal_uInt16 i=2; i <= 8; i++)
+ {
+ if ( 0 != ReadBits(1, nRead))
+ return 0; // something wrong
+
+ nReadAlready = (nReadAlready << 1) | (nRead & 0x01);
+
+ char sCode[16];
+ ToString(nReadAlready, sCode, i);
+ nRet = pRoot->QueryValue(sCode);
+ if (nRet != 0xffffffff)
+ {
+ break;
+ }
+ }
+ return nRet;
+}
+/**
+ * @descr construct tree 1 for length
+ * @return
+ */
+void Decompression::ConstructTree1()
+{ // Huffman Tree #1
+ // The first huffman tree (the Section called Decompression algorithm HUFFMAN) contains the length values. It is described by the following table:
+ // value (hex) code (binary)
+ // 0 101
+ // 1 11
+ // 2 100
+ // 3 011
+ // 4 0101
+ // 5 0100
+ // 6 0011
+ // 7 0010 1
+ // 8 0010 0
+ // 9 0001 1
+ // a 0001 0
+ // b 0000 11
+ // c 0000 10
+ // d 0000 01
+ // e 0000 001
+ // f 0000 000
+ m_Tree1.reset( new HuffmanTreeNode());
+ for (sal_uInt32 i=0; i< 16; i++)
+ {
+ m_Tree1->InsertNode(i, Tree1String[i]);
+ }
+ /*
+ m_Tree1->InsertNode(0, "101");
+ m_Tree1->InsertNode(1, "11");
+ m_Tree1->InsertNode(2, "100");
+ m_Tree1->InsertNode(3, "011");
+ m_Tree1->InsertNode(4, "0101");
+ m_Tree1->InsertNode(5, "0100");
+ m_Tree1->InsertNode(6, "0011");
+ m_Tree1->InsertNode(7, "00101");
+ m_Tree1->InsertNode(8, "00100");
+ m_Tree1->InsertNode(9, "00011");
+ m_Tree1->InsertNode(10, "00010");
+ m_Tree1->InsertNode(11, "000011");
+ m_Tree1->InsertNode(12, "000010");
+ m_Tree1->InsertNode(13, "000001");
+ m_Tree1->InsertNode(14, "0000001");
+ m_Tree1->InsertNode(15, "0000000");
+ */
+}
+/**
+ * @descr construct tree 2 for distance
+ * @return
+ */
+void Decompression::ConstructTree2()
+{
+
+ m_Tree2.reset(new HuffmanTreeNode());
+ for (sal_uInt32 i=0; i< 64; i++)
+ {
+ m_Tree2->InsertNode(i, Tree2String[i]);
+ }
+ //where bits should be read from the left to the right.
+}
+/**
+ * @descr
+ * @return
+ */
+void Decompression::fillArray()
+{
+ m_iArrayOfM[0] = 7;
+ for (int i=1; i < 16; i++)
+ {
+ m_iArrayOfM[i] = m_iArrayOfM[i - 1]+ static_cast<sal_uInt32>(pow(2.0, i-1));//2
+ }
+}
+
+HuffmanTreeNode::HuffmanTreeNode(sal_uInt32 nValue):value(nValue)
+{
+}
+HuffmanTreeNode::~HuffmanTreeNode()
+{
+}
+
+HuffmanTreeNode * HuffmanTreeNode::InsertNode(sal_uInt32 nValue, const char * pInCode)
+{
+ HuffmanTreeNode *pNew = new HuffmanTreeNode(nValue);
+ std::string aCode(pInCode);
+
+ // query its parents
+ const char cLast = aCode.back();
+ aCode.pop_back();
+ HuffmanTreeNode * pParent = QueryNode(aCode.c_str());
+ if (!pParent)
+ {
+ pParent = InsertNode(0xffffffff, aCode.c_str());
+ }
+ if (cLast == '0')
+ pParent->left.reset(pNew);
+ else // (cChar == '1')
+ pParent->right.reset(pNew);
+
+ return pNew;
+}
+
+HuffmanTreeNode * HuffmanTreeNode::QueryNode(const char * pCode)
+{
+ sal_uInt32 nLen = strlen(pCode);
+
+ HuffmanTreeNode * pNode = this; // this is the root
+ for(sal_uInt32 i=0; i<nLen && pNode; i++)
+ {
+ char cChar= pCode[i];
+ if (cChar == '0')
+ {
+ pNode = pNode->left.get();
+ }
+ else // (cChar == '1')
+ {
+ pNode = pNode->right.get();
+ }
+ }
+ return pNode;
+}
+
+sal_uInt32 HuffmanTreeNode::QueryValue(const char * pCode)
+{
+ HuffmanTreeNode * pNode =QueryNode(pCode);
+ if (pNode)
+ return pNode->value;
+
+ return 0xffffffff;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/explode.hxx b/lotuswordpro/source/filter/explode.hxx
new file mode 100644
index 000000000..fb13a6f26
--- /dev/null
+++ b/lotuswordpro/source/filter/explode.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_EXPLODE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_EXPLODE_HXX
+
+#include <sal/types.h>
+#include <memory>
+
+class SvStream;
+
+class HuffmanTreeNode
+{
+ std::unique_ptr<HuffmanTreeNode> left;
+ std::unique_ptr<HuffmanTreeNode> right;
+ sal_uInt32 value;
+
+public:
+ explicit HuffmanTreeNode(sal_uInt32 value = 0xffffffff);
+ ~HuffmanTreeNode();
+ HuffmanTreeNode* InsertNode(sal_uInt32 nValue, const char* pInCode);
+ HuffmanTreeNode* QueryNode(const char* pCode);
+ sal_uInt32 QueryValue(const char* pCode);
+};
+
+/**
+ * @brief
+ * define the function type for input read, output write
+ */
+#define CHUNK 16384
+#define MAXWIN 4096 /* maximum window size */
+class Decompression
+{
+public:
+ Decompression(SvStream* pInStream, SvStream* pOutStream);
+ /**
+ * @brief
+ * decompress from instream to outstream
+ */
+ sal_Int32 explode();
+ sal_uInt32 ReadBits(sal_uInt16 iCount, sal_uInt32& nBits);
+ sal_uInt32 Decode(HuffmanTreeNode* pRoot);
+
+ /**
+ * @brief
+ * compressed/decompressed stream
+ */
+ SvStream* m_pInStream;
+ SvStream* m_pOutStream;
+
+ sal_uInt32 m_nCurrent4Byte; // bit buffer
+ sal_uInt32 m_nBitsLeft; // number of bits remained in bit buffer
+
+ sal_uInt8 m_Buffer[CHUNK]; // input byte buffer
+ sal_uInt8* m_pBuffer; // pointer to input buffer
+ sal_uInt32 m_nBytesLeft; // number of bytes remained in byte buffer
+
+ sal_uInt8 m_Output[MAXWIN]; // output byte buffer
+ sal_uInt32 m_nOutputBufferPos; // pointer to output buffer
+
+ sal_uInt32 m_iArrayOfM[16];
+
+ std::unique_ptr<HuffmanTreeNode> m_Tree1, m_Tree2;
+
+ void ConstructTree1();
+ void ConstructTree2();
+ void fillArray();
+ static void ToString(sal_uInt32 nBits, char* pChar, sal_uInt32 nLen);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/first.hxx b/lotuswordpro/source/filter/first.hxx
new file mode 100644
index 000000000..78b6181ff
--- /dev/null
+++ b/lotuswordpro/source/filter/first.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_FIRST_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_FIRST_HXX
+
+#include "bento.hxx"
+
+//#define ASSERT(cond) UT_ASSERT(cond)
+namespace OpenStormBento
+{
+// String constants
+extern const char gsBenMagicBytes[];
+
+CBenNamedObject* FindNamedObject(CUtList* pList, std::string_view rName, CUtListElmt** ppPrev);
+
+CBenIDListElmt* FindID(CUtList* pList, BenObjectID ObjectID, CUtListElmt** ppPrev);
+} // end namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/localtime.cxx b/lotuswordpro/source/filter/localtime.cxx
new file mode 100644
index 000000000..3974f2fe5
--- /dev/null
+++ b/lotuswordpro/source/filter/localtime.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <localtime.hxx>
+#include <limits.h>
+#include <unicode/timezone.h>
+#include <memory>
+
+const tools::Long DAY_SEC = 24 * 60 * 60;
+const tools::Long YEAR_SEC = 365 * DAY_SEC;
+const tools::Long FOURYEAR_SEC = 4 * YEAR_SEC + DAY_SEC;
+#ifndef LONG_MAX
+const long LONG_MAX = 2147483647;
+#endif
+//01-01-70 was a Thursday
+const tools::Long BASE_DOW = 4;
+
+bool LtgGmTime(tools::Long rtime, LtTm& rtm)
+{
+ if (rtime < 0)
+ {
+ return false;
+ }
+ //is-current-year-a-leap-year flag
+ int islpyr = 0;
+
+ tools::Long tmptim;
+ tools::Long caltim = rtime;
+ tmptim = static_cast<tools::Long>(caltim / FOURYEAR_SEC);
+ caltim -= tmptim * FOURYEAR_SEC;
+
+ //Determine which year of the interval
+
+ // 1970, 1974, 1978,...,etc.
+ tmptim = (tmptim * 4) + 70;
+
+ if (caltim >= YEAR_SEC)
+ {
+ //1971, 1975, 1979,...,etc.
+ tmptim++;
+ caltim -= YEAR_SEC;
+
+ if (caltim >= YEAR_SEC)
+ {
+ // 1972, 1976, 1980,...,etc.
+ tmptim++;
+ caltim -= YEAR_SEC;
+
+ //Note, it takes 366 days-worth of seconds to get past a leap year.
+ if (caltim >= (YEAR_SEC + DAY_SEC))
+ {
+ //1973, 1977, 1981,...,etc.
+ tmptim++;
+ caltim -= (YEAR_SEC + DAY_SEC);
+ }
+ else
+ {
+ //In a leap year after all, set the flag.
+ islpyr++;
+ }
+ }
+ }
+
+ //tmptim now holds the value for tm_year. caltim now holds the
+ //number of elapsed seconds since the beginning of that year.
+
+ rtm.tm_year = tmptim;
+
+ //Determine days since January 1 (0 - 365). This is the tm_yday value.
+ //Leave caltim with number of elapsed seconds in that day.
+
+ rtm.tm_yday = static_cast<tools::Long>(caltim / DAY_SEC);
+ caltim -= rtm.tm_yday * DAY_SEC;
+
+ //Determine months since January (0 - 11) and day of month (1 - 31)
+
+ tools::Long const* mdays;
+ if (islpyr)
+ {
+ static tools::Long const lpdays[]
+ = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+ mdays = lpdays;
+ }
+ else
+ {
+ static tools::Long const days[]
+ = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 };
+ mdays = days;
+ }
+
+ for (tmptim = 1; mdays[tmptim] < rtm.tm_yday; tmptim++)
+ ;
+
+ rtm.tm_mon = --tmptim;
+
+ rtm.tm_mday = rtm.tm_yday - mdays[tmptim];
+
+ //Determine days since Sunday (0 - 6)
+
+ rtm.tm_wday = (static_cast<tools::Long>(rtime / DAY_SEC) + BASE_DOW) % 7;
+
+ //Determine hours since midnight (0 - 23), minutes after the hour
+ //(0 - 59), and seconds after the minute (0 - 59).
+
+ rtm.tm_hour = static_cast<tools::Long>(caltim / 3600);
+ caltim -= rtm.tm_hour * 3600;
+
+ rtm.tm_min = static_cast<tools::Long>(caltim / 60);
+ rtm.tm_sec = static_cast<tools::Long>(caltim - (rtm.tm_min) * 60);
+
+ //adjust year & month
+ rtm.tm_year += 1900;
+ ++(rtm.tm_mon);
+
+ return true;
+};
+bool LtgLocalTime(tools::Long rtime, LtTm& rtm)
+{
+ if (rtime < 0)
+ {
+ return false;
+ }
+
+ if ((rtime > 3 * DAY_SEC) && (rtime < LONG_MAX - 3 * DAY_SEC))
+ {
+ std::unique_ptr<icu::TimeZone> pLocalZone(icu::TimeZone::createDefault());
+ tools::Long offset = (pLocalZone->getRawOffset()) / 1000;
+ pLocalZone.reset();
+ tools::Long ltime = rtime + offset;
+ return LtgGmTime(ltime, rtm);
+ }
+ return false;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx
new file mode 100644
index 000000000..7340adb04
--- /dev/null
+++ b/lotuswordpro/source/filter/lwp9reader.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "lwp9reader.hxx"
+#include <lwpglobalmgr.hxx>
+#include "lwparrowstyles.hxx"
+#include <lwpobjhdr.hxx>
+#include "lwpdoc.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <lwpdocdata.hxx>
+#include <lwpchangemgr.hxx>
+
+Lwp9Reader::Lwp9Reader(LwpSvStream* pInputStream, IXFStream* pStream)
+ : m_pDocStream(pInputStream)
+ , m_pStream(pStream)
+ , m_pObjMgr(nullptr)
+{
+}
+
+/**
+ * @descr The entrance of Word Pro 9 import filter.
+ **/
+bool Lwp9Reader::Read()
+{
+ bool bRet = true;
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(m_pDocStream);
+ try
+ {
+ m_pObjMgr = pGlobal->GetLwpObjFactory();
+
+ //Does not support Word Pro 96 and previous versions
+ if (ReadFileHeader() && LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ ReadIndex();
+ bRet = ParseDocument();
+ }
+ else
+ bRet = false;
+ }
+ catch (...)
+ {
+ LwpGlobalMgr::DeleteInstance();
+ throw;
+ }
+ LwpGlobalMgr::DeleteInstance();
+ return bRet;
+}
+
+/**
+ * @descr Read the LWP7 object.
+ */
+bool Lwp9Reader::ReadFileHeader()
+{
+ if (!m_pDocStream->CheckSeek(LwpSvStream::LWP_STREAM_BASE))
+ return false;
+
+ //Remember to initialize the LwpFileHeader::m_nFileRevision first.
+ LwpFileHeader::m_nFileRevision = 0;
+
+ LwpObjectHeader objHdr;
+ if (!objHdr.Read(*m_pDocStream))
+ return false;
+
+ sal_Int64 pos = m_pDocStream->Tell();
+ m_LwpFileHdr.Read(m_pDocStream);
+ return m_pDocStream->CheckSeek(pos + objHdr.GetSize());
+}
+
+/**
+ * @descr Read the index objects at the end of the WordProData stream
+ */
+void Lwp9Reader::ReadIndex()
+{
+ sal_Int64 oldpos = m_pDocStream->Tell();
+ sal_uInt32 rootoffset = m_LwpFileHdr.GetRootIndexOffset();
+ m_pDocStream->Seek(rootoffset + LwpSvStream::LWP_STREAM_BASE);
+ m_pObjMgr->ReadIndex(m_pDocStream);
+ m_pDocStream->Seek(oldpos);
+}
+
+/**
+ * @descr Parse all document content
+*/
+bool Lwp9Reader::ParseDocument()
+{
+ WriteDocHeader();
+
+ //Get root document
+ LwpDocument* doc = dynamic_cast<LwpDocument*>(m_LwpFileHdr.GetDocID().obj().get());
+
+ if (!doc)
+ return false;
+
+ //Parse Doc Data
+ LwpDocData* pDocData = dynamic_cast<LwpDocData*>(doc->GetDocData().obj().get());
+ if (pDocData != nullptr)
+ pDocData->Parse(m_pStream);
+
+ //Register Styles
+ RegisteArrowStyles();
+ doc->DoRegisterStyle();
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pXFStyleManager->ToXml(m_pStream);
+
+ //Parse document content
+ m_pStream->GetAttrList()->Clear();
+ m_pStream->StartElement("office:body");
+
+ //Parse change list
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ pChangeMgr->ConvertAllChange(m_pStream);
+
+ doc->Parse(m_pStream);
+ m_pStream->EndElement("office:body");
+
+ WriteDocEnd();
+ return true;
+}
+
+/**
+ * @descr Write xml document header
+ */
+void Lwp9Reader::WriteDocHeader()
+{
+ m_pStream->StartDocument();
+
+ IXFAttrList* pAttrList = m_pStream->GetAttrList();
+
+ pAttrList->AddAttribute("xmlns:office", "http://openoffice.org/2000/office");
+ pAttrList->AddAttribute("xmlns:style", "http://openoffice.org/2000/style");
+ pAttrList->AddAttribute("xmlns:text", "http://openoffice.org/2000/text");
+ pAttrList->AddAttribute("xmlns:table", "http://openoffice.org/2000/table");
+ pAttrList->AddAttribute("xmlns:draw", "http://openoffice.org/2000/drawing");
+
+ pAttrList->AddAttribute("xmlns:fo", "http://www.w3.org/1999/XSL/Format");
+ pAttrList->AddAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ pAttrList->AddAttribute("xmlns:number", "http://openoffice.org/2000/datastyle");
+ pAttrList->AddAttribute("xmlns:svg", "http://www.w3.org/2000/svg");
+ pAttrList->AddAttribute("xmlns:chart", "http://openoffice.org/2000/chart");
+
+ pAttrList->AddAttribute("xmlns:dr3d", "http://openoffice.org/2000/dr3d");
+ pAttrList->AddAttribute("xmlns:math", "http://www.w3.org/1998/Math/MathML");
+ pAttrList->AddAttribute("xmlns:form", "http://openoffice.org/2000/form");
+ pAttrList->AddAttribute("xmlns:script", "http://openoffice.org/2000/script");
+ pAttrList->AddAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
+
+ pAttrList->AddAttribute("xmlns:meta", "http://openoffice.org/2000/meta");
+ pAttrList->AddAttribute("office:class", "text");
+ pAttrList->AddAttribute("office:version", "1.0");
+
+ m_pStream->StartElement("office:document");
+ pAttrList->Clear();
+}
+/**
+ * @descr Write xml document end
+ */
+void Lwp9Reader::WriteDocEnd()
+{
+ m_pStream->EndElement("office:document");
+ m_pStream->EndDocument();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwp9reader.hxx b/lotuswordpro/source/filter/lwp9reader.hxx
new file mode 100644
index 000000000..4f17dcd54
--- /dev/null
+++ b/lotuswordpro/source/filter/lwp9reader.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWP9READER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWP9READER_HXX
+
+#include <config_lgpl.h>
+#include <lwpsvstream.hxx>
+#include <lwpfilehdr.hxx>
+#include <lwpobjfactory.hxx>
+#include <xfilter/ixfstream.hxx>
+
+/**
+ * @brief Reader framework class for Lotus Word Pro 9 file
+*/
+class Lwp9Reader final
+{
+public:
+ Lwp9Reader(LwpSvStream* InputStream, IXFStream* pStream);
+
+private:
+ LwpSvStream* m_pDocStream;
+ IXFStream* m_pStream;
+ LwpObjectFactory* m_pObjMgr;
+ LwpFileHeader m_LwpFileHdr; //LWP7 object
+ bool ReadFileHeader();
+ void ReadIndex();
+ bool ParseDocument();
+ void WriteDocHeader();
+ void WriteDocEnd();
+
+public:
+ bool Read();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwparrowstyles.hxx b/lotuswordpro/source/filter/lwparrowstyles.hxx
new file mode 100644
index 000000000..55b0a3b14
--- /dev/null
+++ b/lotuswordpro/source/filter/lwparrowstyles.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPARROWSTYLES_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPARROWSTYLES_HXX
+
+#include <xfilter/xfarrowstyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <lwpglobalmgr.hxx>
+
+/**
+ * @descr Register arrow styles that are not directly support by SODC.
+ * There are three kinds: reversed arrow, reversed concave arrow and reversed
+ * line arrow. This function should be called before the three arrows be used.
+ */
+void RegisteArrowStyles()
+{
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ if (!pXFStyleManager)
+ return;
+ //reversed arrow:
+ std::unique_ptr<XFArrowStyle> pArrowStyle100(new XFArrowStyle());
+ pArrowStyle100->SetArrowName("arrow100");
+ pArrowStyle100->SetViewbox("0 0 140 200");
+ pArrowStyle100->SetSVGPath("M0 180 L70 0 L140 180 L120 180 L70 30 L20 180 L0 180");
+ pXFStyleManager->AddStyle(std::move(pArrowStyle100));
+
+ //reversed arrow:
+ std::unique_ptr<XFArrowStyle> pArrowStyle1(new XFArrowStyle());
+ pArrowStyle1->SetArrowName("reverse arrow");
+ pArrowStyle1->SetViewbox("0 0 140 200");
+ pArrowStyle1->SetSVGPath("M0 0 L70 200 L140 0");
+ pXFStyleManager->AddStyle(std::move(pArrowStyle1));
+
+ //reversed concave arrow
+ std::unique_ptr<XFArrowStyle> pArrowStyle2(new XFArrowStyle());
+ pArrowStyle2->SetArrowName("reverse concave arrow");
+ pArrowStyle2->SetViewbox("0 0 140 200");
+ pArrowStyle2->SetSVGPath("M0 0 L80 200 L160 0 L80 100");
+ pXFStyleManager->AddStyle(std::move(pArrowStyle2));
+
+ //reversed line arrow
+ std::unique_ptr<XFArrowStyle> pArrowStyle3(new XFArrowStyle());
+ pArrowStyle3->SetArrowName("reverse line arrow");
+ pArrowStyle3->SetViewbox("0 0 140 200");
+ pArrowStyle3->SetSVGPath("M0 0 L70 200 L140 0L110 0 L70 160 L20 0 L0 0");
+ pXFStyleManager->AddStyle(std::move(pArrowStyle3));
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpatomholder.cxx b/lotuswordpro/source/filter/lwpatomholder.cxx
new file mode 100644
index 000000000..4976d815c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpatomholder.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpatomholder.hxx>
+#include <lwptools.hxx>
+#include <rtl/textenc.h>
+
+LwpAtomHolder::LwpAtomHolder()
+ : m_nAtom(0)
+ , m_nAssocAtom(0)
+{
+}
+
+/**
+ * @descr read atomholder from object stream
+ * the default encoding used in Word Pro is 1252
+*/
+void LwpAtomHolder::Read(LwpObjectStream* pStrm)
+{
+ //Referred to lwp: file40.cpp, QuickReadAtomHolder()
+
+ sal_uInt16 diskSize = pStrm->QuickReaduInt16();
+ sal_uInt16 len = pStrm->QuickReaduInt16();
+
+ if (len == 0 || diskSize < sizeof diskSize)
+ {
+ m_nAtom = BAD_ATOM;
+ m_nAssocAtom = BAD_ATOM;
+ return;
+ }
+ m_nAtom = m_nAssocAtom = len;
+
+ LwpTools::QuickReadUnicode(pStrm, m_String, diskSize - sizeof(diskSize),
+ RTL_TEXTENCODING_MS_1252);
+}
+/**
+ * @descr skip the atom holder in object stream
+*/
+void LwpAtomHolder::Skip(LwpObjectStream* pStrm)
+{
+ sal_uInt16 holdersize = pStrm->QuickReaduInt16();
+ pStrm->SeekRel(holdersize);
+ m_nAtom = m_nAssocAtom = BAD_ATOM;
+}
+/**
+ * @descr read path atom
+ * No use now for lwp filter, just skip the atom
+*/
+void LwpAtomHolder::ReadPathAtom(LwpObjectStream* pStrm)
+{
+ //Referred to lwp: file40.cpp, QuickReadPathAtom()
+ // TODO: Read the data. Now just skip it. The method to skip is same as above.
+ Skip(pStrm);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbackgroundoverride.cxx b/lotuswordpro/source/filter/lwpbackgroundoverride.cxx
new file mode 100644
index 000000000..4f3509dad
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbackgroundoverride.cxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "lwpbackgroundoverride.hxx"
+
+LwpBackgroundOverride::LwpBackgroundOverride(LwpBackgroundOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_aStuff(rOther.m_aStuff)
+{
+}
+
+LwpBackgroundOverride* LwpBackgroundOverride::clone() const
+{
+ return new LwpBackgroundOverride(*this);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbackgroundoverride.hxx b/lotuswordpro/source/filter/lwpbackgroundoverride.hxx
new file mode 100644
index 000000000..6044d7eff
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbackgroundoverride.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBACKGROUNDOVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBACKGROUNDOVERRIDE_HXX
+
+#include <lwpoverride.hxx>
+#include "lwpbackgroundstuff.hxx"
+
+class LwpObjectStream;
+class LwpBackgroundOverride : public LwpOverride
+{
+public:
+ LwpBackgroundOverride() {}
+
+ virtual LwpBackgroundOverride* clone() const override;
+
+public:
+ virtual void Read(LwpObjectStream* pStrm) override
+ {
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+
+ m_aStuff.Read(pStrm);
+ }
+
+ pStrm->SkipExtra();
+ }
+
+ const LwpColor& GetBackColor() const { return m_aStuff.m_aFillColor; }
+ LwpBackgroundStuff& GetBGStuff() { return m_aStuff; }
+
+protected:
+ LwpBackgroundOverride(LwpBackgroundOverride const& rOther);
+
+private:
+ LwpBackgroundOverride& operator=(LwpBackgroundOverride const& rOther) = delete;
+
+private:
+ LwpBackgroundStuff m_aStuff;
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
new file mode 100644
index 000000000..72cb9822c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype
+ * Implementation of class LwpBackgroundStuff.
+ */
+
+#include "lwpbackgroundstuff.hxx"
+#include "lwppttntbl.hxx"
+#include <xfilter/xfbgimage.hxx>
+
+#include <tools/stream.hxx>
+#include <vcl/dibtools.hxx>
+#include <vcl/BitmapTools.hxx>
+#include <svx/xbitmap.hxx>
+
+void LwpBackgroundStuff::Read(LwpObjectStream* pStrm)
+{
+ m_nID = pStrm->QuickReaduInt16();
+ m_aFillColor.Read(pStrm);
+ m_aPatternColor.Read(pStrm);
+ pStrm->SkipExtra();
+}
+
+void LwpBackgroundStuff::GetPattern(sal_uInt16 btPttnIndex, sal_uInt8 (&pPttnArray)[8])
+{
+ if (btPttnIndex > 71)
+ {
+ assert(false);
+ return;
+ }
+ assert((2 < btPttnIndex) && (btPttnIndex < 72));
+ const sal_uInt8* pTempArray = s_pLwpPatternTab[btPttnIndex];
+ for (sal_uInt8 i = 0; i < 8; i++)
+ {
+ pPttnArray[i] = pTempArray[7 - i];
+ }
+}
+
+LwpColor* LwpBackgroundStuff::GetFillColor()
+{
+ if (m_nID == BACK_PATTERN)
+ {
+ return &m_aPatternColor;
+ }
+
+ return &m_aFillColor;
+}
+
+std::unique_ptr<XFBGImage> LwpBackgroundStuff::GetFillPattern()
+{
+ // not pattern fill?
+ if (!IsPatternFill())
+ {
+ return std::unique_ptr<XFBGImage>();
+ }
+
+ // get pattern array from pattern table
+ sal_uInt8 aPttnArray[8];
+ GetPattern(m_nID, aPttnArray);
+
+ // create bitmap object from the pattern array
+ BitmapEx aBmp = vcl::bitmap::CreateFromData(aPttnArray, 8, 8, 1, vcl::PixelFormat::N1_BPP);
+
+ // create XOBitmap object from bitmap object
+ XOBitmap aXOBitmap(aBmp);
+ aXOBitmap.Bitmap2Array();
+
+ // set back/fore-ground colors
+ if (m_aFillColor.IsValidColor() && m_aPatternColor.IsValidColor())
+ {
+ Color aBackColor(static_cast<sal_uInt8>(m_aFillColor.GetRed()),
+ static_cast<sal_uInt8>(m_aFillColor.GetGreen()),
+ static_cast<sal_uInt8>(m_aFillColor.GetBlue()));
+ Color aForeColor(static_cast<sal_uInt8>(m_aPatternColor.GetRed()),
+ static_cast<sal_uInt8>(m_aPatternColor.GetGreen()),
+ static_cast<sal_uInt8>(m_aPatternColor.GetBlue()));
+
+ if (aXOBitmap.GetBackgroundColor() == COL_BLACK)
+ {
+ aXOBitmap.SetPixelColor(aBackColor);
+ aXOBitmap.SetBackgroundColor(aForeColor);
+ }
+ else
+ {
+ aXOBitmap.SetPixelColor(aForeColor);
+ aXOBitmap.SetBackgroundColor(aBackColor);
+ }
+ }
+
+ // transfer image data from XOBitmap->SvStream->BYTE-Array
+ SvMemoryStream aPicMemStream;
+ aXOBitmap.Array2Bitmap();
+ WriteDIB(aXOBitmap.GetBitmap(), aPicMemStream);
+ sal_uInt32 nSize = aPicMemStream.GetEndOfData();
+ std::unique_ptr<sal_uInt8[]> pImageBuff(new sal_uInt8[nSize]);
+ memcpy(pImageBuff.get(), aPicMemStream.GetData(), nSize);
+
+ // create XFBGImage object.
+ std::unique_ptr<XFBGImage> xXFBGImage(new XFBGImage);
+ xXFBGImage->SetImageData(pImageBuff.get(), nSize);
+
+ pImageBuff.reset();
+
+ xXFBGImage->SetRepeate();
+
+ return xXFBGImage;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.hxx b/lotuswordpro/source/filter/lwpbackgroundstuff.hxx
new file mode 100644
index 000000000..45881764d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Background object of Wordpro.
+************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBACKGROUNDSTUFF_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBACKGROUNDSTUFF_HXX
+#include <lwpcolor.hxx>
+#include "lwpstyledef.hxx"
+
+#include <memory>
+
+class XFBGImage;
+class LwpBackgroundStuff
+{
+public:
+ LwpBackgroundStuff()
+ : m_nID(0)
+ {
+ }
+
+private:
+ static void GetPattern(sal_uInt16 btPttnIndex, sal_uInt8 (&pPttnArray)[8]);
+
+public:
+ void Read(LwpObjectStream* pStrm);
+ LwpColor* GetFillColor();
+ std::unique_ptr<XFBGImage> GetFillPattern();
+
+ bool IsTransparent() const { return (m_nID == BACK_TRANSPARENT); }
+ bool IsPatternFill() const { return (m_nID > 2 && m_nID < 72); }
+
+ friend class LwpBackgroundOverride;
+
+private:
+ sal_uInt16 m_nID;
+ LwpColor m_aFillColor;
+ LwpColor m_aPatternColor;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbasetype.cxx b/lotuswordpro/source/filter/lwpbasetype.cxx
new file mode 100644
index 000000000..dfbe741ae
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbasetype.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpbasetype.hxx>
+/**
+ * @descr read PonoseNumber from object stream
+*/
+void LwpPanoseNumber::Read(LwpObjectStream* pStrm)
+{
+ m_nFamilyType = pStrm->QuickReaduInt8();
+ m_nSerifStyle = pStrm->QuickReaduInt8();
+ m_nWeight = pStrm->QuickReaduInt8();
+ m_nProportion = pStrm->QuickReaduInt8();
+ m_nContrast = pStrm->QuickReaduInt8();
+ m_nStrokeVariation = pStrm->QuickReaduInt8();
+ m_nArmStyle = pStrm->QuickReaduInt8();
+ m_nLetterform = pStrm->QuickReaduInt8();
+ m_nMidline = pStrm->QuickReaduInt8();
+ m_nXHeight = pStrm->QuickReaduInt8();
+}
+
+LwpPoint::LwpPoint() { Reset(); }
+
+/**
+ * @descr read point from object stream
+*/
+void LwpPoint::Read(LwpObjectStream* pStrm)
+{
+ m_nX = pStrm->QuickReadInt32();
+ m_nY = pStrm->QuickReadInt32();
+}
+/**
+ * @descr reset to zero
+*/
+void LwpPoint::Reset()
+{
+ m_nX = 0;
+ m_nY = 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbookmarkmgr.cxx b/lotuswordpro/source/filter/lwpbookmarkmgr.cxx
new file mode 100644
index 000000000..7e57cb59b
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbookmarkmgr.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpbookmarkmgr.hxx>
+
+void LwpBookmarkMgr::AddXFBookmarkStart(const OUString& sName, XFBookmarkStart* pMark)
+{
+ auto iter = m_MapStart.find(sName);
+ if (iter == m_MapStart.end()) //not find
+ {
+ m_MapStart[sName] = pMark;
+ }
+ else //have exist the same bookmark name
+ {
+ auto xFind = iter->second;
+ OUString totalName = xFind->GetDivision() + ":" + xFind->GetName();
+ xFind->SetName(totalName);
+ m_MapStart[totalName] = xFind;
+ m_MapStart[sName] = pMark;
+ }
+}
+void LwpBookmarkMgr::AddXFBookmarkEnd(const OUString& sName, XFBookmarkEnd* pMark)
+{
+ auto iter = m_MapEnd.find(sName);
+ if (iter == m_MapEnd.end()) //not find
+ {
+ m_MapEnd[sName] = pMark;
+ }
+ else //have exist the same bookmark name
+ {
+ auto xFind = iter->second;
+ OUString totalName = xFind->GetDivision() + ":" + xFind->GetName();
+ xFind->SetName(totalName);
+ m_MapEnd[totalName] = xFind;
+ m_MapEnd[sName] = pMark;
+ }
+}
+bool LwpBookmarkMgr::FindBookmark(const OUString& sName)
+{
+ auto iter = m_MapStart.find(sName);
+ return iter != m_MapStart.end();
+}
+
+LwpBookmarkMgr::LwpBookmarkMgr()
+{
+ m_MapStart.clear();
+ m_MapEnd.clear();
+}
+LwpBookmarkMgr::~LwpBookmarkMgr()
+{
+ m_MapStart.clear();
+ m_MapEnd.clear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpborderstuff.cxx b/lotuswordpro/source/filter/lwpborderstuff.cxx
new file mode 100644
index 000000000..d3aebcdab
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpborderstuff.cxx
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Border stuff of Wordpro.
+************************************************************************/
+#include "lwpborderstuff.hxx"
+#include "lwpstyledef.hxx"
+#include <lwpfilehdr.hxx>
+#include <lwptools.hxx>
+
+LwpBorderStuff::LwpBorderStuff()
+ : m_nSides(0), m_nValid(0),
+ m_nBorderGroupIDLeft(0),
+ m_nBorderGroupIDRight(0),
+ m_nBorderGroupIDTop(0),
+ m_nBorderGroupIDBottom(0),
+ m_nGroupIndent(0),
+ m_nWidthLeft(0),
+ m_nWidthTop(0),
+ m_nWidthRight(0),
+ m_nWidthBottom(0)
+{
+}
+
+void LwpBorderStuff::Read(LwpObjectStream *pStrm)
+{
+ m_nSides = pStrm->QuickReaduInt16();
+ if( m_nSides&LEFT )
+ {
+ m_nBorderGroupIDLeft = pStrm->QuickReaduInt16();
+ m_nWidthLeft = pStrm->QuickReadInt32();
+ m_aColorLeft.Read(pStrm);
+
+ if( LwpFileHeader::m_nFileRevision < 0x000b )
+ {
+ pStrm->SeekRel(8);
+ }
+ }
+
+ if( m_nSides&RIGHT )
+ {
+ m_nBorderGroupIDRight = pStrm->QuickReaduInt16();
+ m_nWidthRight = pStrm->QuickReadInt32();
+ m_aColorRight.Read(pStrm);
+
+ if( LwpFileHeader::m_nFileRevision < 0x000b )
+ {
+ pStrm->SeekRel(8);
+ }
+ }
+
+ if( m_nSides&TOP )
+ {
+ m_nBorderGroupIDTop = pStrm->QuickReaduInt16();
+ m_nWidthTop = pStrm->QuickReadInt32();
+ m_aColorTop.Read(pStrm);
+
+ if( LwpFileHeader::m_nFileRevision < 0x000b )
+ {
+ pStrm->SeekRel(8);
+ }
+ }
+
+ if( m_nSides&BOTTOM )
+ {
+ m_nBorderGroupIDBottom = pStrm->QuickReaduInt16();
+ m_nWidthBottom = pStrm->QuickReadInt32();
+ m_aColorBottom.Read(pStrm);
+
+ if( LwpFileHeader::m_nFileRevision < 0x000b )
+ {
+ pStrm->SeekRel(8);
+ }
+ }
+
+ m_nGroupIndent = pStrm->QuickReadInt32();
+ m_nValid = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x0010 )
+ return;
+
+ if( m_nBorderGroupIDLeft&EXTERNAL_ID )
+ {
+ m_nBorderGroupIDLeft = BGRP_SOLID;
+ }
+ if( m_nBorderGroupIDRight&EXTERNAL_ID )
+ {
+ m_nBorderGroupIDRight = BGRP_SOLID;
+ }
+ if( m_nBorderGroupIDTop&EXTERNAL_ID )
+ {
+ m_nBorderGroupIDTop = BGRP_SOLID;
+ }
+ if( m_nBorderGroupIDBottom&EXTERNAL_ID )
+ {
+ m_nBorderGroupIDBottom = BGRP_SOLID;
+ }
+}
+
+bool LwpBorderStuff::HasSide(sal_uInt16 side)
+{
+ return (m_nSides & side) != 0;
+}
+
+sal_uInt16 LwpBorderStuff::GetSideType(sal_uInt16 side)
+{
+ switch(side)
+ {
+ case LEFT:
+ return m_nBorderGroupIDLeft;
+ case RIGHT:
+ return m_nBorderGroupIDRight;
+ case TOP:
+ return m_nBorderGroupIDTop;
+ case BOTTOM:
+ return m_nBorderGroupIDBottom;
+ }
+ // FIXME: this is needed to avoid warning: control reaches end of non-void function
+ // a better solution would be to enum value for the parameter side
+ return 0;
+}
+
+LwpColor LwpBorderStuff::GetSideColor(sal_uInt16 side)
+{
+ switch(side)
+ {
+ case LEFT:
+ return m_aColorLeft;
+ case RIGHT:
+ return m_aColorRight;
+ case TOP:
+ return m_aColorTop;
+ case BOTTOM:
+ return m_aColorBottom;
+ }
+ // FIXME: this is needed to avoid warning: control reaches end of non-void function
+ // a better solution would be to enum value for the parameter side
+ return LwpColor();
+}
+
+float LwpBorderStuff::GetSideWidth(sal_uInt16 side)
+{
+ switch(side)
+ {
+ case LEFT:
+ return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthLeft));
+ case RIGHT:
+ return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthRight));
+ case TOP:
+ return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthTop));
+ case BOTTOM:
+ return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nWidthBottom));
+ }
+ // FIXME: this is needed to avoid warning: control reaches end of non-void function
+ // a better solution would be to enum value for the parameter side
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpborderstuff.hxx b/lotuswordpro/source/filter/lwpborderstuff.hxx
new file mode 100644
index 000000000..4a7da6ce2
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpborderstuff.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Border stuff of Wordpro.
+************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBORDERSTUFF_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBORDERSTUFF_HXX
+
+#include <lwpcolor.hxx>
+
+class LwpBorderStuff
+{
+public:
+ LwpBorderStuff();
+
+ enum BorderType
+ {
+ NOSIDE = 0,
+ LEFT = 1,
+ RIGHT = 2,
+ TOP = 4,
+ BOTTOM = 8,
+ ALLSIDE = 15,
+ TEMPORARY = 0xff00
+ };
+
+public:
+ void Read(LwpObjectStream *pStrm);
+
+ sal_uInt16 GetSide() const { return m_nSides; }
+ bool HasSide(sal_uInt16 side);
+ sal_uInt16 GetSideType(sal_uInt16 side);
+ LwpColor GetSideColor(sal_uInt16 side);
+ float GetSideWidth(sal_uInt16 side);
+ friend class LwpParaBorderOverride;
+private:
+ sal_uInt16 m_nSides;
+ sal_uInt16 m_nValid;
+
+ sal_uInt16 m_nBorderGroupIDLeft;
+ sal_uInt16 m_nBorderGroupIDRight;
+ sal_uInt16 m_nBorderGroupIDTop;
+ sal_uInt16 m_nBorderGroupIDBottom;
+
+ sal_Int32 m_nGroupIndent;
+
+ sal_Int32 m_nWidthLeft;
+ sal_Int32 m_nWidthTop;
+ sal_Int32 m_nWidthRight;
+ sal_Int32 m_nWidthBottom;
+
+ LwpColor m_aColorLeft;
+ LwpColor m_aColorRight;
+ LwpColor m_aColorTop;
+ LwpColor m_aColorBottom;
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbreaksoverride.cxx b/lotuswordpro/source/filter/lwpbreaksoverride.cxx
new file mode 100644
index 000000000..71b508f0e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbreaksoverride.cxx
@@ -0,0 +1,276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Breaks override of Wordpro.
+************************************************************************/
+#include <memory>
+
+#include "clone.hxx"
+#include "lwpbreaksoverride.hxx"
+#include <lwpobjstrm.hxx>
+#include <lwpatomholder.hxx>
+
+LwpBreaksOverride::LwpBreaksOverride()
+ : m_pNextStyle(new LwpAtomHolder)
+{
+}
+
+LwpBreaksOverride::LwpBreaksOverride(LwpBreaksOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_pNextStyle(::clone(rOther.m_pNextStyle.get()))
+{
+}
+
+LwpBreaksOverride::~LwpBreaksOverride() {}
+
+LwpBreaksOverride* LwpBreaksOverride::clone() const { return new LwpBreaksOverride(*this); }
+
+void LwpBreaksOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+
+ m_pNextStyle->Read(pStrm);
+ }
+
+ pStrm->SkipExtra();
+}
+
+void LwpBreaksOverride::Override(LwpBreaksOverride* pOther)
+{
+ if (m_nApply & BO_PAGEBEFORE)
+ {
+ if (IsPageBreakBeforeOverridden())
+ {
+ pOther->OverridePageBreakBefore(IsPageBreakBefore());
+ }
+ else
+ {
+ pOther->RevertPageBreakBefore();
+ }
+ }
+ if (m_nApply & BO_PAGEAFTER)
+ {
+ if (IsPageBreakAfterOverridden())
+ {
+ pOther->OverridePageBreakAfter(IsPageBreakAfter());
+ }
+ else
+ {
+ pOther->RevertPageBreakAfter();
+ }
+ }
+ if (m_nApply & BO_KEEPTOGETHER)
+ {
+ if (IsPageBreakWithinOverridden())
+ {
+ pOther->OverridePageBreakWithin(IsPageBreakWithin());
+ }
+ else
+ {
+ pOther->RevertPageBreakWithin();
+ }
+ }
+ if (m_nApply & BO_COLBEFORE)
+ {
+ if (IsColumnBreakBeforeOverridden())
+ {
+ pOther->OverrideColumnBreakBefore(IsColumnBreakBefore());
+ }
+ else
+ {
+ pOther->RevertColumnBreakBefore();
+ }
+ }
+ if (m_nApply & BO_COLAFTER)
+ {
+ if (IsColumnBreakAfterOverridden())
+ {
+ pOther->OverrideColumnBreakAfter(IsColumnBreakAfter());
+ }
+ else
+ {
+ pOther->RevertColumnBreakAfter();
+ }
+ }
+ if (m_nApply & BO_KEEPPREV)
+ {
+ if (IsKeepWithPreviousOverridden())
+ {
+ pOther->OverrideKeepWithPrevious(IsKeepWithPrevious());
+ }
+ else
+ {
+ pOther->RevertKeepWithPrevious();
+ }
+ }
+ if (m_nApply & BO_KEEPNEXT)
+ {
+ if (IsKeepWithNextOverridden())
+ {
+ pOther->OverrideKeepWithNext(IsKeepWithNext());
+ }
+ else
+ {
+ pOther->RevertKeepWithNext();
+ }
+ }
+ if (m_nApply & BO_USENEXTSTYLE)
+ {
+ if (IsUseNextStyleOverridden())
+ {
+ pOther->OverrideUseNextStyle(IsUseNextStyle());
+ }
+ else
+ {
+ pOther->RevertUseNextStyle();
+ }
+ }
+}
+
+void LwpBreaksOverride::OverridePageBreakBefore(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_PAGEBEFORE, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_PAGEBEFORE, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverridePageBreakAfter(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_PAGEAFTER, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_PAGEAFTER, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverridePageBreakWithin(bool bVal)
+{
+ // Note the flipped logic
+ if (!bVal)
+ {
+ LwpOverride::Override(BO_KEEPTOGETHER, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_KEEPTOGETHER, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverrideColumnBreakBefore(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_COLBEFORE, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_COLBEFORE, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverrideColumnBreakAfter(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_COLAFTER, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_COLAFTER, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverrideKeepWithNext(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_KEEPNEXT, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_KEEPNEXT, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverrideKeepWithPrevious(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_KEEPPREV, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_KEEPPREV, STATE_OFF);
+ }
+}
+void LwpBreaksOverride::OverrideUseNextStyle(bool bVal)
+{
+ if (bVal)
+ {
+ LwpOverride::Override(BO_USENEXTSTYLE, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_USENEXTSTYLE, STATE_OFF);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbreaksoverride.hxx b/lotuswordpro/source/filter/lwpbreaksoverride.hxx
new file mode 100644
index 000000000..e10e357dc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbreaksoverride.hxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Breaks override of Wordpro.
+************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBREAKSOVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBREAKSOVERRIDE_HXX
+
+#include <memory>
+#include <lwpoverride.hxx>
+
+class LwpObjectStream;
+class LwpAtomHolder;
+class LwpBreaksOverride final : public LwpOverride
+{
+public:
+ LwpBreaksOverride();
+ virtual ~LwpBreaksOverride() override;
+
+ virtual LwpBreaksOverride* clone() const override;
+
+ enum
+ {
+ BO_PAGEBEFORE = 0x01, // page break before this style
+ BO_PAGEAFTER = 0x02, // page break after this style
+ BO_KEEPTOGETHER = 0x04,
+ BO_COLBEFORE = 0x08, // col break before this style
+ BO_COLAFTER = 0x10, // col break after this style
+ BO_KEEPPREV = 0x20, // not with-PAGE BEF, COL BEF or WITHIN
+ BO_KEEPNEXT = 0x40, // not with-PAGE AFT, COL AFT or WITHIN
+ BO_USENEXTSTYLE = 0x80, // use next style name
+ BO_NEXTSTYLE = 0x100 // next style name
+ };
+
+public:
+ virtual void Read(LwpObjectStream* pStrm) override;
+
+ void Override(LwpBreaksOverride* pOther);
+
+ inline bool IsPageBreakBefore() const;
+ inline bool IsPageBreakAfter() const;
+ inline bool IsPageBreakWithin() const;
+ inline bool IsColumnBreakBefore() const;
+ inline bool IsColumnBreakAfter() const;
+ inline bool IsKeepWithNext() const;
+ inline bool IsKeepWithPrevious() const;
+ inline bool IsUseNextStyle() const;
+
+ inline bool IsPageBreakBeforeOverridden() const;
+ inline bool IsPageBreakAfterOverridden() const;
+ inline bool IsPageBreakWithinOverridden() const;
+ inline bool IsColumnBreakBeforeOverridden() const;
+ inline bool IsColumnBreakAfterOverridden() const;
+ inline bool IsKeepWithNextOverridden() const;
+ inline bool IsKeepWithPreviousOverridden() const;
+ inline bool IsUseNextStyleOverridden() const;
+
+ inline void RevertPageBreakBefore();
+ inline void RevertPageBreakAfter();
+ inline void RevertPageBreakWithin();
+ inline void RevertColumnBreakBefore();
+ inline void RevertColumnBreakAfter();
+ inline void RevertKeepWithNext();
+ inline void RevertKeepWithPrevious();
+ inline void RevertUseNextStyle();
+
+ void OverridePageBreakBefore(bool bVal);
+ void OverridePageBreakAfter(bool bVal);
+ void OverridePageBreakWithin(bool bVal);
+ void OverrideColumnBreakBefore(bool bVal);
+ void OverrideColumnBreakAfter(bool bVal);
+ void OverrideKeepWithNext(bool bVal);
+ void OverrideKeepWithPrevious(bool bVal);
+ void OverrideUseNextStyle(bool bVal);
+
+private:
+ LwpBreaksOverride(LwpBreaksOverride const& rOther);
+ LwpBreaksOverride& operator=(const LwpBreaksOverride& rOther) = delete;
+
+ std::unique_ptr<LwpAtomHolder> m_pNextStyle;
+};
+
+inline bool LwpBreaksOverride::IsPageBreakBefore() const
+{
+ return ((m_nValues & BO_PAGEBEFORE) != 0);
+}
+
+inline bool LwpBreaksOverride::IsPageBreakAfter() const
+{
+ return ((m_nValues & BO_PAGEAFTER) != 0);
+}
+inline bool LwpBreaksOverride::IsPageBreakWithin() const
+{
+ return ((m_nValues & BO_KEEPTOGETHER) != 0);
+}
+inline bool LwpBreaksOverride::IsColumnBreakBefore() const
+{
+ return ((m_nValues & BO_COLBEFORE) != 0);
+}
+inline bool LwpBreaksOverride::IsColumnBreakAfter() const
+{
+ return ((m_nValues & BO_COLAFTER) != 0);
+}
+inline bool LwpBreaksOverride::IsKeepWithNext() const { return ((m_nValues & BO_KEEPNEXT) != 0); }
+inline bool LwpBreaksOverride::IsKeepWithPrevious() const
+{
+ return ((m_nValues & BO_KEEPPREV) != 0);
+}
+inline bool LwpBreaksOverride::IsUseNextStyle() const
+{
+ return ((m_nValues & BO_USENEXTSTYLE) != 0);
+}
+
+inline bool LwpBreaksOverride::IsPageBreakBeforeOverridden() const
+{
+ return ((m_nOverride & BO_PAGEBEFORE) != 0);
+}
+inline bool LwpBreaksOverride::IsPageBreakAfterOverridden() const
+{
+ return ((m_nOverride & BO_PAGEAFTER) != 0);
+}
+inline bool LwpBreaksOverride::IsPageBreakWithinOverridden() const
+{
+ return ((m_nOverride & BO_KEEPTOGETHER) != 0);
+}
+inline bool LwpBreaksOverride::IsColumnBreakBeforeOverridden() const
+{
+ return ((m_nOverride & BO_COLBEFORE) != 0);
+}
+inline bool LwpBreaksOverride::IsColumnBreakAfterOverridden() const
+{
+ return ((m_nOverride & BO_COLAFTER) != 0);
+}
+inline bool LwpBreaksOverride::IsKeepWithNextOverridden() const
+{
+ return ((m_nOverride & BO_KEEPNEXT) != 0);
+}
+inline bool LwpBreaksOverride::IsKeepWithPreviousOverridden() const
+{
+ return ((m_nOverride & BO_KEEPPREV) != 0);
+}
+inline bool LwpBreaksOverride::IsUseNextStyleOverridden() const
+{
+ return ((m_nOverride & BO_USENEXTSTYLE) != 0);
+}
+
+inline void LwpBreaksOverride::RevertPageBreakBefore()
+{
+ LwpOverride::Override(BO_PAGEBEFORE, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertPageBreakAfter()
+{
+ LwpOverride::Override(BO_PAGEAFTER, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertPageBreakWithin()
+{
+ LwpOverride::Override(BO_KEEPTOGETHER, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertColumnBreakBefore()
+{
+ LwpOverride::Override(BO_COLBEFORE, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertColumnBreakAfter()
+{
+ LwpOverride::Override(BO_COLAFTER, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertKeepWithNext()
+{
+ LwpOverride::Override(BO_KEEPNEXT, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertKeepWithPrevious()
+{
+ LwpOverride::Override(BO_KEEPPREV, STATE_STYLE);
+}
+inline void LwpBreaksOverride::RevertUseNextStyle()
+{
+ LwpOverride::Override(BO_USENEXTSTYLE, STATE_STYLE);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
new file mode 100644
index 000000000..edb691071
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
@@ -0,0 +1,308 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpbulletstylemgr.hxx"
+#include "lwpfribheader.hxx"
+#include "lwppara.hxx"
+#include "lwpsilverbullet.hxx"
+#include <lwptools.hxx>
+#include "lwpparaproperty.hxx"
+#include <xfilter/xfliststyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xflist.hxx>
+#include <lwpglobalmgr.hxx>
+#include <xfilter/xflistitem.hxx>
+#include <sal/log.hxx>
+
+LwpBulletStyleMgr::LwpBulletStyleMgr()
+ : m_pFoundry(nullptr)
+ , m_bContinue(true)
+ , m_bIsBulletSkipped(false)
+{
+}
+
+LwpBulletStyleMgr::~LwpBulletStyleMgr()
+{
+ m_vIDsPairList.clear();
+ m_vStyleNameList.clear();
+}
+
+/**
+ * @short Register bullet style to style-list. The function only register the bullet and single customized numbering
+ * not including the numbering sequence.
+ * @param pPara pointer to the current paragraph which has a bullet/numbering.
+ * @param pBullOver pointer to the bulletoverride of current paragraph.
+ * @param pIndent pointer to the indentoverride of current paragraph.
+ */
+OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, const LwpBulletOverride* pBullOver,
+ LwpIndentOverride const * pIndent)
+{
+ if(!pPara || !pIndent || !pBullOver)
+ {
+ return OUString();
+ }
+
+ LwpSilverBullet* pSilverBullet = pPara->GetSilverBullet();
+ if (!pSilverBullet)
+ {
+ assert(false);
+ return OUString();
+ }
+
+ LwpPara* pBulletPara = pSilverBullet->GetBulletPara();
+ if (!pBulletPara)
+ {
+ SAL_WARN("lwp", "missing bullet para");
+ return OUString();
+ }
+
+ LwpParaProperty* pProp = pPara->GetProperty(PP_LOCAL_INDENT);
+ LwpObjectID aIndentID;
+ if (pProp)
+ {
+ LwpParaIndentProperty* pIndentProp = static_cast<LwpParaIndentProperty*>(pProp);
+ aIndentID = pIndentProp->GetIndentID();
+ }
+
+ LwpObjectID aBulletID = pBullOver->GetSilverBullet();
+ std::unique_ptr<LwpBulletOverride> pBulletOver(pBullOver->clone());
+
+ sal_uInt16 nNameIndex = 0;
+ for (auto const& vIDsPair : m_vIDsPairList)
+ {
+ if (vIDsPair.first->GetSilverBullet() == aBulletID && vIDsPair.second == aIndentID
+ && vIDsPair.first->IsRightAligned() == pBullOver->IsRightAligned())
+ {
+ return m_vStyleNameList[nNameIndex];
+ }
+ else
+ {
+ nNameIndex++;
+ }
+ }
+
+ m_vIDsPairList.emplace_back(std::move(pBulletOver), aIndentID);
+ OUString aStyleName;
+
+ LwpFribPtr& rBulletParaFribs = pBulletPara->GetFribs();
+ bool bIsNumbering = (rBulletParaFribs.HasFrib(FRIB_TAG_PARANUMBER) != nullptr);
+
+ enumXFAlignType eAlign = enumXFAlignStart;
+ if (pBullOver->IsRightAligned())
+ {
+ eAlign = enumXFAlignEnd;
+ }
+
+ std::unique_ptr<XFListStyle> pListStyle(new XFListStyle());
+ XFStyleManager* pXFStyleMgr = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+
+ if (!bIsNumbering)
+ {
+ for (sal_uInt8 nC = 1; nC < 11; nC++)
+ {
+ pListStyle->SetListBullet(nC, pSilverBullet->GetBulletChar(), pSilverBullet->GetBulletFontName(),
+ LwpSilverBullet::GetPrefix(), LwpSilverBullet::GetSuffix());
+
+ if (pIndent->GetMRest() > 0) /* note: used to be 0.001, no idea why */
+ {
+ pListStyle->SetListPosition(nC, 0.0,
+ LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMRest())), 0.0, eAlign);
+ }
+ else
+ {
+ pListStyle->SetListPosition(nC, 0.0,
+ 0.0, LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(pIndent->GetMFirst())), eAlign);
+ }
+ }
+
+ aStyleName = pXFStyleMgr->AddStyle(std::move(pListStyle)).m_pStyle->GetStyleName();
+ }
+ else
+ {
+ ParaNumbering aParaNumbering;
+ pBulletPara->GetParaNumber(1, &aParaNumbering);
+ LwpFribParaNumber* pParaNumber = aParaNumbering.pParaNumber;
+ if (pParaNumber)
+ {
+ for (sal_uInt8 nPos = 1; nPos < 10; nPos++)
+ {
+ if (pParaNumber->GetStyleID() != NUMCHAR_other)
+ {
+ OUString aPrefix;
+ XFNumFmt aFmt;
+ if (aParaNumbering.pPrefix)
+ {
+ aPrefix += aParaNumbering.pPrefix->GetText();
+ }
+
+ OUString aNumber = LwpSilverBullet::GetNumCharByStyleID(pParaNumber);
+ if (pParaNumber->GetStyleID() == NUMCHAR_01 || pParaNumber->GetStyleID() == NUMCHAR_Chinese4)
+ {
+ aPrefix += "0";
+ }
+ aFmt.SetPrefix(aPrefix);
+
+ aFmt.SetFormat(aNumber);
+
+ if (aParaNumbering.pSuffix)
+ {
+ aFmt.SetSuffix(aParaNumbering.pSuffix->GetText());
+ }
+
+ //set numbering format into the style-list.
+ pListStyle->SetListNumber(nPos, aFmt, pParaNumber->GetStart()+1);
+
+ }
+ else
+ {
+ OUString aPrefix, aSuffix;
+ if (aParaNumbering.pPrefix)
+ {
+ aPrefix = aParaNumbering.pPrefix->GetText();
+ }
+ if (aParaNumbering.pSuffix)
+ {
+ aSuffix = aParaNumbering.pSuffix->GetText();
+ }
+
+ pListStyle->SetListBullet(nPos, LwpSilverBullet::GetNumCharByStyleID(pParaNumber),
+ "Times New Roman", aPrefix, aSuffix);
+ }
+
+ pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
+ }
+ aStyleName = pXFStyleMgr->AddStyle(std::move(pListStyle)).m_pStyle->GetStyleName();
+ }
+ }
+
+ m_vStyleNameList.push_back(aStyleName);
+ return aStyleName;
+
+}
+
+//Create nested XFList and XFItems and then add it to XFContentContainer(pCont)
+//Return the inner XFItem created.
+rtl::Reference<XFContentContainer> LwpBulletStyleMgr::AddBulletList(
+ XFContentContainer* pCont, bool bIsOrdered,
+ const OUString& rStyleName, sal_Int16 nLevel, bool bIsBulletSkiped)
+{
+ assert(nLevel > 0);
+
+ m_bIsBulletSkipped = bIsBulletSkiped;
+
+ //todo: need judge here.
+ bool bContinue = m_bContinue;
+
+ rtl::Reference<XFList> prevList;
+ XFListItem* theItem;
+ XFListItem* InnerItem = nullptr;
+ for (sal_Int8 nC = nLevel - 1; nC >= 0; nC--)
+ {
+ rtl::Reference<XFList> theList(new XFList);
+ theItem = new XFListItem();
+ theList->Add(theItem);
+
+ if (bIsOrdered)
+ {
+ theList->SetOrdered(true);
+ }
+ else
+ {
+ bContinue = false;
+ theList->SetOrdered(false);
+ }
+
+ if (nC == nLevel - 1)
+ {
+ theList->SetContinueNumber(bContinue);
+ }
+ //Add the outer list to pCont
+ if (nC == 0 && pCont)
+ {
+ theList->SetStyleName(rStyleName);
+ theList->SetContinueNumber(bContinue);
+ pCont->Add(theList.get());
+ }
+
+ if ((nC == 0) && bIsBulletSkiped)
+ {
+ theList->SetContinueNumber(true);
+ }
+
+ if ((nC == nLevel - 1) && bIsBulletSkiped)
+ {
+ theItem->SetIsHeader();
+ }
+
+ if (nC == nLevel - 1)
+ {
+ InnerItem = theItem;
+ }
+
+ if (prevList)
+ {
+ theItem->Add(prevList.get());
+ }
+ prevList = theList;
+ }
+ return InnerItem;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.hxx b/lotuswordpro/source/filter/lwpbulletstylemgr.hxx
new file mode 100644
index 000000000..c4dd9d6c3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBULLETSTYLEMGR_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPBULLETSTYLEMGR_HXX
+
+#include <memory>
+
+#include <config_lgpl.h>
+#include <lwpfoundry.hxx>
+#include <lwpobjid.hxx>
+#include <utility>
+#include <xfilter/xfcontentcontainer.hxx>
+
+class XFList;
+class LwpPara;
+class LwpIndentOverride;
+class LwpBulletOverride;
+
+class LwpBulletStyleMgr final
+{
+public:
+ LwpBulletStyleMgr();
+ ~LwpBulletStyleMgr();
+ OUString RegisterBulletStyle(LwpPara* pPara, const LwpBulletOverride* pBullOver,
+ LwpIndentOverride const * pIndent);
+ inline void SetFoundry(LwpFoundry* pFoundry);
+ inline void SetContinueFlag(bool bFlag);
+ rtl::Reference<XFContentContainer> AddBulletList(XFContentContainer* pCont, bool bIsOrdered,
+ const OUString& rStyleName, sal_Int16 nLevel, bool bIsBulletSkiped);
+ inline void SetCurrentSilverBullet(const LwpObjectID& rNewID);
+
+private:
+ typedef std::pair<std::unique_ptr<LwpBulletOverride>, LwpObjectID> OverridePair;
+ std::vector <OUString> m_vStyleNameList;
+ std::vector <OverridePair> m_vIDsPairList;
+ LwpFoundry* m_pFoundry;
+ bool m_bContinue;
+ bool m_bIsBulletSkipped;
+ LwpObjectID m_aCurrentNumberingID;
+};
+
+inline void LwpBulletStyleMgr::SetFoundry(LwpFoundry* pFoundry)
+{
+ m_pFoundry = pFoundry;
+}
+inline void LwpBulletStyleMgr::SetContinueFlag(bool bFlag)
+{
+ m_bContinue = bFlag;
+}
+inline void LwpBulletStyleMgr::SetCurrentSilverBullet(const LwpObjectID& rNewID)
+{
+ m_aCurrentNumberingID = rNewID;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
new file mode 100644
index 000000000..cd5478e3f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -0,0 +1,931 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - cell layouts
+ */
+
+#include <memory>
+#include "lwpcelllayout.hxx"
+#include "lwpnumericfmt.hxx"
+#include "lwptable.hxx"
+#include "lwprowlayout.hxx"
+#include <lwpfilehdr.hxx>
+#include <lwpglobalmgr.hxx>
+
+#include <sal/log.hxx>
+#include <unotools/configmgr.hxx>
+
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfcell.hxx>
+#include <xfilter/xfcellstyle.hxx>
+#include <xfilter/xfcolstyle.hxx>
+
+LwpCellLayout::LwpCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpMiddleLayout(objHdr, pStrm)
+ , m_bConvertCell(false)
+ , crowid(0)
+ , ccolid(0)
+ , cType(LDT_NONE)
+{
+}
+
+LwpCellLayout::~LwpCellLayout()
+{}
+
+/**
+ * @short Get table layout pointer, if default cell layout, return NULL
+ * @param LwpTableLayout *
+ * @return
+ */
+LwpTableLayout * LwpCellLayout::GetTableLayout()
+{
+ LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(GetParent().obj().get());
+ if(!pRow)
+ {
+ return nullptr;
+ }
+ LwpTableLayout * pTableLayout = pRow->GetParentTableLayout();
+ return pTableLayout;
+}
+/**
+ * @short Get table pointer, if default cell layout, return NULL
+ * @param LwpTable *
+ * @return
+ */
+LwpTable * LwpCellLayout::GetTable()
+{
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if(!pTableLayout)
+ {
+ return nullptr;
+ }
+ LwpTable *pTable = pTableLayout->GetTable();
+ return pTable;
+}
+/**
+ * @short Set current cell layout to cell layout map
+ * @param
+ * @return
+ */
+void LwpCellLayout::SetCellMap()
+{
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (pTableLayout)
+ pTableLayout->SetWordProCellMap(crowid, ccolid, this);
+}
+/**
+ * @short Get actual width of this cell layout
+ * @param
+ * @return width (cm)
+ */
+double LwpCellLayout::GetActualWidth()
+{
+ //Get table layout
+ LwpTableLayout * pTableLayout = GetTableLayout();
+
+ if (pTableLayout == nullptr)
+ {
+ return GetGeometryWidth();
+ }
+
+ OUString strColStyle = pTableLayout->GetColumnWidth(ccolid);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFColStyle *pStyle = static_cast<XFColStyle *>(pXFStyleManager->FindStyle(strColStyle));
+ if(pStyle)
+ {
+ return pStyle->GetWidth();
+ }
+
+ return GetGeometryWidth();
+}
+
+/**
+ * @short Apply padding to cell style
+ * @param pCellStyle - pointer of XFCellStyle
+ * @return
+ */
+void LwpCellLayout::ApplyPadding(XFCellStyle *pCellStyle)
+{
+ double fLeft = GetMarginsValue(MARGIN_LEFT);
+ double fRight = GetMarginsValue(MARGIN_RIGHT);
+ double fTop = GetMarginsValue(MARGIN_TOP);
+ double fBottom = GetMarginsValue(MARGIN_BOTTOM);
+ pCellStyle->SetPadding(static_cast<float>(fLeft),static_cast<float>(fRight),static_cast<float>(fTop),static_cast<float>(fBottom));
+}
+/**
+ * @short Apply border to cell style according to cell position, default cell layout won't use this function
+ * @param
+ * @return pCellStyle - pointer of XFCellStyle
+ */
+void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
+{
+ // judge cell border type
+ LwpCellBorderType eType = GetCellBorderType(crowid, ccolid, GetTableLayout());
+
+ // get left cell and judge if neighbour border is different
+ std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+ if (!xBorders)
+ {
+ return;
+ }
+
+ switch (eType)
+ {
+ case enumNoBottomBorder:
+ xBorders->SetWidth(enumXFBorderBottom, 0);
+ break;
+ case enumNoLeftBorder:
+ xBorders->SetWidth(enumXFBorderLeft, 0);
+ break;
+ case enumNoLeftNoBottomBorder:
+ xBorders->SetWidth(enumXFBorderBottom, 0);
+ xBorders->SetWidth(enumXFBorderLeft, 0);
+ break;
+ case enumWholeBorder:
+ break;
+ default:
+ assert(false);
+ }
+ pCellStyle->SetBorders(xBorders.release());
+}
+/**
+ * @short Apply watermark to cell style
+ * @param pCellStyle - pointer of XFCellStyle
+ * @return
+ */
+void LwpCellLayout::ApplyWatermark(XFCellStyle *pCellStyle)
+{
+ std::unique_ptr<XFBGImage> xBGImage(GetXFBGImage());
+ if (xBGImage)
+ {
+ pCellStyle->SetBackImage(xBGImage);
+ }
+}
+
+/**
+ * @short Apply pattern fill to cell style
+ * @param pCellStyle - pointer of XFCellStyle
+ * @return
+ */
+void LwpCellLayout::ApplyPatternFill(XFCellStyle* pCellStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
+ if (xXFBGImage)
+ {
+ pCellStyle->SetBackImage(xXFBGImage);
+ }
+}
+
+/**
+ * @short Apply background to cell style
+ * @param pCellStyle - pointer of XFCellStyle
+ * @return
+ */
+void LwpCellLayout::ApplyBackGround(XFCellStyle* pCellStyle)
+{
+ if (IsPatternFill())
+ {
+ ApplyPatternFill(pCellStyle);
+ }
+ else
+ {
+ ApplyBackColor(pCellStyle);
+ }
+}
+/**
+ * @short Apply back color to cell style
+ * @param pCellStyle - pointer of XFCellStyle
+ * @return
+ */
+void LwpCellLayout::ApplyBackColor(XFCellStyle *pCellStyle)
+{
+ LwpColor* pColor = GetBackColor();
+ if(pColor && pColor->IsValidColor())
+ {
+ XFColor aXFColor(pColor->To24Color());
+ pCellStyle->SetBackColor(aXFColor);
+ }
+}
+/**
+ * @short register style of cell layout
+ * @param pCellStyle The style of the cell, which would be applied to the cell.
+ * @return
+ */
+void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
+{
+ LwpLayoutNumerics* pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(cLayNumerics.obj().get());
+ if (!pLayoutNumerics)
+ {
+ // if current layout doesn't have format, go to based on layout
+ LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(GetBasedOnStyle().get());
+ if (pCellLayout)
+ {
+ pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject().obj().get());
+ }
+ }
+
+ // apply format style
+ if (pLayoutNumerics)
+ {
+ XFStyle* pStyle = pLayoutNumerics->Convert();
+ if (pStyle)
+ {
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_NumfmtName = pXFStyleManager->AddStyle(std::unique_ptr<XFStyle>(pStyle)).m_pStyle->GetStyleName();
+ pCellStyle->SetDataStyle(m_NumfmtName);
+ }
+ }
+}
+/**
+ * @short get style name according to cell position, only table default cells use this function
+ * @param nRow - default cell position row number
+ * @param nCol - default cell position col number
+ * @return OUString - registered cell style name
+ */
+OUString const & LwpCellLayout::GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
+{
+ // judge cell border type
+ LwpCellBorderType eType = GetCellBorderType(nRow, nCol, pTableLayout);
+ return m_CellStyleNames[eType];
+}
+/**
+* Make the XFCell
+* @param aTableID - ID of the table which this cell belongs to
+* @param bIsTopRow - whether current cell is top row
+* @param bIsRightCol - whether current cell is the rightest column
+* @return XFCell*
+*/
+rtl::Reference<XFCell> LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
+{
+ // if cell layout is aTableID's default cell layout
+ // it can't have any content, bypass these code
+ LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
+ if (!pTable)
+ {
+ assert(false);
+ return nullptr;
+ }
+ rtl::Reference<XFCell> xXFCell(new XFCell);
+ OUString aStyleName = m_StyleName;
+
+ // if cell layout is aTableID's default cell layout
+ // we should adjust its style by current position
+ if (pTable->GetDefaultCellStyle() == GetObjectID())
+ {
+ aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout().get());
+ }
+
+ // content of cell
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj().get());
+ if (pStory)
+ {
+ pStory->XFConvert(xXFCell.get());
+ }
+
+ ApplyProtect(xXFCell.get(), aTableID);
+ xXFCell->SetStyleName(aStyleName);
+ return xXFCell;
+}
+
+LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
+{
+ LwpObjectID* pPreStoryID = GetPreviousCellStory();
+ if (pPreStoryID && !(pPreStoryID->IsNull()))
+ {
+ LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY).get());
+ if (!pPreStory)
+ {
+ SAL_WARN("lwp", "unexpected null VO_STORY");
+ return nullptr;
+ }
+ return dynamic_cast<LwpPara*>(pPreStory->GetLastPara().obj(VO_PARA).get());
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+/**
+ * @short Get previous cell which used for bullet inside cell
+ * @param
+ * @return LwpObjectID * - object ID of cell content story
+ */
+LwpObjectID * LwpCellLayout::GetPreviousCellStory()
+{
+ LwpTable *pTable = GetTable();
+ if (!pTable)
+ {
+ assert(false);
+ return nullptr;
+ }
+ sal_uInt16 nRow = crowid;
+ sal_uInt16 nCol = ccolid;
+
+ // if table is reset paragraph in columns, get cell on the top side of current cell
+ if (pTable->IsNumberDown())
+ {
+ if (nRow == 0)
+ {
+ return nullptr;
+ }
+ nRow -=1;
+ }
+ else
+ {
+ // if not, get cell on the left side of current cell
+ if (nCol == 0)
+ {
+ if (nRow == 0)
+ {
+ return nullptr;
+ }
+ else
+ {
+ nRow--;
+ nCol = pTable->GetColumn() - 1;
+ }
+ }
+ else
+ {
+ nCol -=1;
+ }
+ }
+
+ // get the object id pointer of previous cell story
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (!pTableLayout)
+ {
+ assert(false);
+ return nullptr;
+ }
+ return pTableLayout->SearchCellStoryMap(nRow, nCol);
+}
+
+/**
+ * @short judge border type by cell neighbour
+ * @param nRow
+ * @param nCol
+ * @param pTableLayout
+ * @return LwpCellBorderType
+ */
+LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
+{
+ if (!pTableLayout)
+ return enumWholeBorder;
+
+ // get left cell and judge if neighbour border is different
+ std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+ if (!xBorders)
+ {
+ return enumWholeBorder;
+ }
+ XFBorder& rLeftBorder = xBorders->GetLeft();
+ XFBorder& rBottomBorder = xBorders->GetBottom();
+ bool bNoLeftBorder = false;
+ bool bNoBottomBorder = false;
+
+ LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow, GetLeftColID(nCol), pTableLayout);
+ if (pLeftNeighbour)
+ {
+ std::unique_ptr<XFBorders> pNeighbourBorders = pLeftNeighbour->GetXFBorders();
+ if (pNeighbourBorders)
+ {
+ XFBorder& rRightBorder = pNeighbourBorders->GetRight();
+ if (rLeftBorder == rRightBorder)
+ {
+ // for these 2 types cell, left border should be ignored for sake of avoiding duplication border
+ // but if left border is different with right border of left cell
+ // we should not ignored it
+ bNoLeftBorder = true;
+ }
+ }
+
+ }
+
+ LwpCellLayout * pBelowNeighbour = GetCellByRowCol(GetBelowRowID(nRow), nCol, pTableLayout);
+ if (pBelowNeighbour) //&& (eType == enumRightNotLastCellBorder || eType == enumLeftNotLastCellBorder) )
+ {
+ std::unique_ptr<XFBorders> pBelowBorders = pBelowNeighbour->GetXFBorders();
+ if (pBelowBorders)
+ {
+ XFBorder& rTopBorder = pBelowBorders->GetTop();
+ if (rTopBorder == rBottomBorder)
+ {
+ // for these 2 types cell, bottom border should be ignored for sake of avoiding duplication border
+ // but if bottom border is different with right border of left cell
+ // we should not ignored it
+ bNoBottomBorder = true;
+ }
+ }
+ }
+
+ xBorders.reset();
+
+ if (bNoBottomBorder)
+ {
+ if (bNoLeftBorder)
+ {
+ return enumNoLeftNoBottomBorder;
+ }
+ return enumNoBottomBorder;
+ }
+ if (bNoLeftBorder)
+ {
+ return enumNoLeftBorder;
+ }
+ return enumWholeBorder;
+}
+
+/**
+ * @short Get neighbour cell by specifying ROW+COL
+ * @param nRow
+ * @param nCol
+ * @return LwpCellLayout *
+ */
+LwpCellLayout * LwpCellLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
+{
+ return pTableLayout->GetCellByRowCol(nRow, nCol);
+}
+/**
+ * @short Register table's default cell layout
+ * @param
+ * @return
+ */
+void LwpCellLayout::RegisterDefaultCell()
+{
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ for (sal_uInt16 eLoop = enumWholeBorder; eLoop < enumCellBorderTopLimit; eLoop++)
+ {
+ // register cell style
+ std::unique_ptr<XFCellStyle> xCellStyle(new XFCellStyle());
+
+ ApplyPadding(xCellStyle.get());
+ ApplyBackColor(xCellStyle.get());
+ ApplyWatermark(xCellStyle.get());
+ ApplyFmtStyle(xCellStyle.get());
+ xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
+
+ std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+ if (xBorders)
+ {
+ switch(eLoop)
+ {
+ case enumNoBottomBorder:
+
+ //| |
+
+ // remove bottom line
+ xBorders->SetWidth(enumXFBorderBottom, 0);
+ break;
+ case enumNoLeftNoBottomBorder:
+
+ // |
+
+ // remove left and bottom
+ xBorders->SetWidth(enumXFBorderLeft, 0);
+ xBorders->SetWidth(enumXFBorderBottom, 0);
+ break;
+ case enumWholeBorder:
+
+ //||
+
+ // nothing to remove
+ break;
+ case enumNoLeftBorder:
+
+ //| |
+
+ // remove left line
+ xBorders->SetWidth(enumXFBorderLeft, 0);
+ break;
+ default:
+ assert(false);
+ }
+ xCellStyle->SetBorders(xBorders.release());
+ }
+ m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
+ }
+}
+/**
+ * @short Register 4 types of cell style and register content styles
+ * @param
+ * @param
+ * @param
+ * @return
+ */
+void LwpCellLayout::RegisterStyle()
+{
+ rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout *>(GetParent().obj().get()));
+ if (!xParent.is() || xParent->GetLayoutType() != LWP_ROW_LAYOUT)
+ {
+ // default cell layout, we must register 4 styles for it
+ RegisterDefaultCell();
+ return;
+ }
+
+ // register cell style
+ std::unique_ptr<XFCellStyle> xCellStyle(new XFCellStyle);
+
+ ApplyPadding(xCellStyle.get());
+ ApplyBackGround(xCellStyle.get());
+ ApplyWatermark(xCellStyle.get());
+ ApplyFmtStyle(xCellStyle.get());
+ ApplyBorders(xCellStyle.get());
+
+ xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
+
+ // content object register styles
+ rtl::Reference<LwpObject> pObj = m_Content.obj();
+ if (pObj.is())
+ {
+ pObj->SetFoundry(m_pFoundry);
+ pObj->DoRegisterStyle();
+ }
+
+ //register child layout style
+ RegisterChildStyle();
+}
+/**
+ * @short Read cell layout
+ * @param
+ * @return
+ */
+void LwpCellLayout::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ LwpMiddleLayout::Read();
+
+ // before the layout hierarchy rework
+ if (LwpFileHeader::m_nFileRevision < 0x000b)
+ {
+ assert(false);
+ }
+ else
+ {
+ crowid = pStrm->QuickReaduInt16();
+ ccolid = static_cast<sal_uInt8>(pStrm->QuickReaduInt16()); // written as a lushort
+
+ sal_uInt16 type;
+
+ type = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+ cType = static_cast<LeaderDotType>(type);
+
+ cLayNumerics.ReadIndexed(pStrm);
+ cLayDiagonalLine.ReadIndexed(pStrm);
+
+ pStrm->SkipExtra();
+ }
+}
+
+/**
+* Apply protect attribute to cell of table
+* @param aTableID - ID of the table which the cell belongs to
+* @param
+* @return XFCell*
+*/
+void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
+{
+ bool bProtected = false;
+ // judge current cell
+ if (GetIsProtected())
+ {
+ bProtected = true;
+ }
+ else
+ {
+ // judge base on
+ LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(GetBasedOnStyle().get());
+ if (pBase && pBase->GetIsProtected())
+ {
+ bProtected = true;
+ }
+ else
+ {
+ // judge whole table
+ LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
+ rtl::Reference<LwpTableLayout> xTableLayout(pTable ? pTable->GetTableLayout() : nullptr);
+ LwpSuperTableLayout * pSuper = xTableLayout.is() ? xTableLayout->GetSuperTableLayout() : nullptr;
+ if (pSuper && pSuper->GetIsProtected())
+ {
+ bProtected = true;
+ }
+ }
+ }
+
+ pCell->SetProtect(bProtected);
+}
+
+LwpConnectedCellLayout::LwpConnectedCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpCellLayout(objHdr, pStrm)
+ , cnumrows(0)
+ , cnumcols(0)
+ , m_nRealrowspan(0)
+ , m_nRealcolspan(0)
+{
+}
+
+LwpConnectedCellLayout::~LwpConnectedCellLayout()
+{}
+/**
+ * @short Set current connected cell layout to cell layout map
+ * @param pCellLayoutMap - cell layout map reference
+ * @return
+ */
+void LwpConnectedCellLayout::SetCellMap()
+{
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (!pTableLayout)
+ return;
+
+ sal_uInt16 nRowSpan = m_nRealrowspan;
+
+ for (sal_uInt16 iLoop = 0; iLoop < nRowSpan; iLoop ++)
+ {
+ for (sal_uInt16 jLoop = 0; jLoop < cnumcols; jLoop ++)
+ pTableLayout->SetWordProCellMap(iLoop + crowid, jLoop + ccolid, this);
+ }
+}
+
+/**
+ * @short judge border type by cell neighbour
+ * @param nRow
+ * @param nCol
+ * @param pTableLayout
+ * @return LwpCellBorderType
+ */
+LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
+{
+ if (!pTableLayout)
+ throw std::runtime_error("missing table layout");
+
+ sal_uInt16 nRowSpan = m_nRealrowspan;
+
+ // get left cell and judge if neighbour border is different
+ std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+ if( !xBorders)
+ {
+ return enumWholeBorder;
+ }
+ XFBorder& rLeftBorder = xBorders->GetLeft();
+ XFBorder& rBottomBorder = xBorders->GetBottom();
+ bool bNoLeftBorder = true;
+ bool bNoBottomBorder = true;
+
+ if (nCol == 0)
+ {
+ bNoLeftBorder = false;
+ }
+ else
+ {
+ for (sal_uInt16 iLoop=0; iLoop < nRowSpan; iLoop++)
+ {
+ LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow+iLoop, GetLeftColID(nCol), pTableLayout);
+ if (pLeftNeighbour)
+ {
+ std::unique_ptr<XFBorders> pNeighbourBorders(pLeftNeighbour->GetXFBorders());
+ if (pNeighbourBorders)
+ {
+ XFBorder& rRightBorder = pNeighbourBorders->GetRight();
+ if (rLeftBorder != rRightBorder)
+ {
+ // if left border is different with right border of left cell
+ // we should not ignored it
+ bNoLeftBorder = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ LwpTable* pTable = pTableLayout->GetTable();
+ if (!pTable)
+ throw std::runtime_error("missing table");
+
+ if ( (nRow + nRowSpan) == pTable->GetRow())
+ {
+ bNoBottomBorder = false;
+ }
+ else
+ {
+ for (sal_uInt16 iLoop = 0; iLoop < cnumcols; iLoop ++)
+ {
+ LwpCellLayout * pBelowNeighbour = GetCellByRowCol(nRow + nRowSpan, nCol+iLoop, pTableLayout);
+ if (pBelowNeighbour)
+ {
+ std::unique_ptr<XFBorders> pBelowBorders(pBelowNeighbour->GetXFBorders());
+ if (pBelowBorders)
+ {
+ XFBorder& rTopBorder = pBelowBorders->GetTop();
+ if (rTopBorder != rBottomBorder)
+ {
+ // if bottom border is different with right border of left cell
+ // we should not ignored it
+ bNoBottomBorder = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ xBorders.reset();
+
+ if (bNoBottomBorder)
+ {
+ if (bNoLeftBorder)
+ {
+ return enumNoLeftNoBottomBorder;
+ }
+ return enumNoBottomBorder;
+ }
+ if (bNoLeftBorder)
+ {
+ return enumNoLeftBorder;
+ }
+ return enumWholeBorder;
+}
+/**
+ * @short Read connected cell layout
+ * @param
+ * @return
+ */
+void LwpConnectedCellLayout::Read()
+{
+ LwpCellLayout::Read();
+
+ cnumrows = m_pObjStrm->QuickReaduInt16();
+ sal_uInt16 numcols = m_pObjStrm->QuickReaduInt16(); // written as a lushort
+ cnumcols = static_cast<sal_uInt8>(numcols);
+
+ m_nRealrowspan = cnumrows;
+ if (utl::ConfigManager::IsFuzzing())
+ m_nRealrowspan = std::min<sal_uInt16>(m_nRealrowspan, 128);
+ m_nRealcolspan = cnumcols;
+
+ m_pObjStrm->SkipExtra();
+}
+
+rtl::Reference<XFCell> LwpConnectedCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
+{
+ rtl::Reference<XFCell> xXFCell = LwpCellLayout::ConvertCell(aTableID, nRow, nCol);
+ xXFCell->SetColumnSpaned(cnumcols);
+ return xXFCell;
+}
+
+/**
+ * @short parse connected cell layout
+ * @param pOutputStream - output stream
+ * @return
+ */
+void LwpConnectedCellLayout::Parse(IXFStream* /*pOutputStream*/)
+{
+}
+
+LwpHiddenCellLayout::LwpHiddenCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpCellLayout(objHdr, pStrm)
+{}
+
+LwpHiddenCellLayout::~LwpHiddenCellLayout()
+{}
+/**
+ * @short Set current hidden cell layout to cell layout map
+ * @param
+ * @return
+ */
+void LwpHiddenCellLayout::SetCellMap()
+{
+}
+/**
+ * @short Read hidden cell layout
+ * @param
+ * @return
+ */
+void LwpHiddenCellLayout::Read()
+{
+ LwpCellLayout::Read();
+
+ cconnectedlayout.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+
+}
+/**
+ * @short Convert hidden cell layout
+ * @param aTableID - Object ID of table
+ * @return XFCell * - pointer to converted cell
+ */
+
+rtl::Reference<XFCell> LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
+{
+ if (!cconnectedlayout.obj().is())
+ return nullptr;
+ LwpConnectedCellLayout* pConnCell = dynamic_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj().get());
+
+ if (!pConnCell || nRow < (pConnCell->GetNumrows()+pConnCell->GetRowID()))
+ return nullptr;
+ // if the hidden cell should be displayed for limit of SODC
+ // use the default cell layout
+ rtl::Reference<XFCell> xXFCell;
+ LwpTable *pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
+ if (pTable)
+ {
+ LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle().obj().get());
+ if (pDefault)
+ {
+ xXFCell = pDefault->DoConvertCell(aTableID, nRow, nCol);
+ }
+ else
+ {
+ xXFCell = pConnCell->DoConvertCell(aTableID, nRow, nCol);
+ }
+ xXFCell->SetColumnSpaned(pConnCell->GetNumcols());
+ }
+ else
+ {
+ assert(false);
+ }
+ return xXFCell;
+}
+/**
+ * @short parse hidden cell layout
+ * @param pOutputStream - output stream
+ * @return
+ */
+ void LwpHiddenCellLayout::Parse(IXFStream* /*pOutputStream*/)
+{
+}
+
+LwpParallelColumnsBlock::LwpParallelColumnsBlock(LwpObjectHeader const &objHdr, LwpSvStream* pStrm):LwpCellLayout(objHdr, pStrm)
+{}
+
+LwpParallelColumnsBlock::~LwpParallelColumnsBlock()
+{}
+
+void LwpParallelColumnsBlock::Read()
+{
+ LwpCellLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcelllayout.hxx b/lotuswordpro/source/filter/lwpcelllayout.hxx
new file mode 100644
index 000000000..e6a313070
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcelllayout.hxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - cell layouts
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCELLLAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCELLLAYOUT_HXX
+
+#include "lwplayout.hxx"
+#include <xfilter/xfcell.hxx>
+
+typedef enum
+{
+ enumWholeBorder = 0,
+ enumNoLeftBorder,
+ enumNoBottomBorder,
+ enumNoLeftNoBottomBorder,
+ enumCellBorderTopLimit = 4,
+} LwpCellBorderType;
+
+class XFCell;
+class XFCellStyle;
+class LwpCellList;
+class LwpTable;
+class LwpTableLayout;
+/**
+ * @brief
+ * VO_CELLLAYOUT object
+ */
+class LwpCellLayout : public LwpMiddleLayout
+{
+public:
+ LwpCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpCellLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_CELL_LAYOUT;}
+ rtl::Reference<XFCell> DoConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
+ {
+ if (m_bConvertCell)
+ throw std::runtime_error("recursion in page divisions");
+ m_bConvertCell = true;
+ rtl::Reference<XFCell> aRet = ConvertCell(aTableID, nRow, nCol);
+ m_bConvertCell = false;
+ return aRet;
+ }
+ sal_uInt16 GetRowID() const {return crowid;}
+ sal_uInt8 GetColID() const {return ccolid;}
+ void RegisterStyle() override;
+ LwpObjectID& GetNumericsObject() {return cLayNumerics;}
+ LwpObjectID * GetPreviousCellStory();
+ virtual LwpPara* GetLastParaOfPreviousStory() override;
+ LwpTableLayout * GetTableLayout();
+ virtual void SetCellMap();
+ double GetActualWidth();
+ const OUString& GetNumfmtName() const {return m_NumfmtName;}
+protected:
+ void Read() override;
+ LwpTable * GetTable();
+ void ApplyPadding(XFCellStyle* pCellStyle);
+ void ApplyBorders(XFCellStyle* pCellStyle);
+ void ApplyPatternFill(XFCellStyle* pCellStyle);
+ void ApplyBackGround(XFCellStyle* pCellStyle);
+ void ApplyBackColor(XFCellStyle* pCellStyle);
+ void ApplyWatermark(XFCellStyle* pCellStyle);
+ void ApplyProtect(XFCell * pCell, LwpObjectID aTableID);
+ void ApplyFmtStyle(XFCellStyle *pCellStyle);
+ OUString const & GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout);
+ void RegisterDefaultCell();
+ virtual LwpCellBorderType GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout);
+ virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol);
+ static LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout);
+ static sal_uInt16 GetLeftColID(sal_uInt16 nCol){return nCol - 1; };
+ virtual sal_uInt16 GetBelowRowID(sal_uInt16 nRow){return nRow + 1; };
+
+ bool m_bConvertCell;
+ sal_uInt16 crowid;
+ sal_uInt8 ccolid;
+ LwpObjectID cLayNumerics;
+ LwpObjectID cLayDiagonalLine;
+
+ enum LeaderDotType
+ {
+ LDT_NONE = 0,
+ LDT_DOTS = 1,
+ LDT_DASHES = 2,
+ LDT_UNDERSCORES = 3
+ };
+ LeaderDotType cType;
+ OUString m_CellStyleNames[enumCellBorderTopLimit];
+
+ OUString m_NumfmtName;//Add to support number color
+};
+
+/**
+ * @brief
+ * VO_HIDDENCELLLAYOUT object
+ */
+class LwpHiddenCellLayout final : public LwpCellLayout
+{
+public:
+ LwpHiddenCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpHiddenCellLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_HIDDEN_CELL_LAYOUT;}
+ virtual void Parse(IXFStream* pOutputStream) override;
+ void RegisterStyle() override {}
+ virtual void SetCellMap() override;
+private:
+ void Read() override;
+ virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override;
+ LwpObjectID cconnectedlayout;
+};
+
+/**
+ * @brief
+ * VO_CONNECTEDCELLLAYOUT object
+ */
+class LwpConnectedCellLayout : public LwpCellLayout
+{
+public:
+ LwpConnectedCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpConnectedCellLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_CONNECTED_CELL_LAYOUT;}
+ virtual void Parse(IXFStream* pOutputStream) override;
+ sal_uInt16 GetNumrows() const {return m_nRealrowspan;}
+ sal_uInt8 GetNumcols() const {return m_nRealcolspan;}
+ virtual void SetCellMap() override;
+ void SetNumrows(sal_uInt16 nVal){m_nRealrowspan = nVal;}
+protected:
+ void Read() override;
+ virtual sal_uInt16 GetBelowRowID(sal_uInt16 nRow) override {return nRow + m_nRealrowspan; };
+ virtual LwpCellBorderType GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout) override;
+ virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override;
+ sal_uInt16 cnumrows;
+ sal_uInt8 cnumcols;
+ sal_uInt16 m_nRealrowspan;
+ sal_uInt8 m_nRealcolspan;
+};
+/**
+ * @brief
+ * VO_PCOLBLOCK object
+ */
+
+class LwpParallelColumnsBlock : public LwpCellLayout
+{
+public:
+ LwpParallelColumnsBlock(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpParallelColumnsBlock() override;
+protected:
+ void Read() override;
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpchangemgr.cxx b/lotuswordpro/source/filter/lwpchangemgr.cxx
new file mode 100644
index 000000000..ee8c8f8dd
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpchangemgr.cxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpchangemgr.hxx>
+#include <rtl/ustring.hxx>
+#include <lwpfrib.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+LwpChangeMgr::LwpChangeMgr()
+{
+ m_nCounter = 0;
+ m_DocFribMap.clear();
+ m_HeadFootFribMap.clear();
+ m_pFribMap = &m_DocFribMap;
+ m_ChangeList.clear();
+}
+
+LwpChangeMgr::~LwpChangeMgr()
+{
+ m_pFribMap = nullptr;
+ m_DocFribMap.clear();
+ m_HeadFootFribMap.clear();
+ m_ChangeList.clear();
+}
+
+void LwpChangeMgr::AddChangeFrib(LwpFrib* pFrib)
+{
+ m_nCounter++;
+ OUString sID = "ct" + OUString::number(m_nCounter);
+ m_pFribMap->insert(std::pair<LwpFrib*, OUString>(pFrib, sID));
+ pFrib->Register(m_pFribMap);
+}
+
+OUString LwpChangeMgr::GetChangeID(LwpFrib* pFrib)
+{
+ auto iter = m_pFribMap->find(pFrib);
+ if (iter == m_pFribMap->end())
+ return OUString();
+ else
+ return iter->second;
+}
+
+void LwpChangeMgr::ConvertAllChange(IXFStream* pStream)
+{
+ for (auto const& docFrib : m_DocFribMap)
+ {
+ if (docFrib.first->GetRevisionType() == LwpFrib::REV_INSERT)
+ {
+ XFChangeInsert* pInsert = new XFChangeInsert;
+ pInsert->SetChangeID(docFrib.second);
+ pInsert->SetEditor(docFrib.first->GetEditor());
+ m_ChangeList.push_back(pInsert);
+ }
+ else if (docFrib.first->GetRevisionType() == LwpFrib::REV_DELETE)
+ {
+ XFChangeDelete* pDelete = new XFChangeDelete;
+ pDelete->SetChangeID(docFrib.second);
+ pDelete->SetEditor(docFrib.first->GetEditor());
+ m_ChangeList.push_back(pDelete);
+ }
+ }
+
+ pStream->GetAttrList()->Clear();
+ if (m_ChangeList.empty())
+ return;
+ // Add for disable change tracking
+ pStream->GetAttrList()->AddAttribute("text:track-changes", "false");
+ pStream->StartElement("text:tracked-changes");
+ for (auto const& elem : m_ChangeList)
+ elem->ToXml(pStream);
+
+ pStream->EndElement("text:tracked-changes");
+
+ m_ChangeList.clear();
+}
+void LwpChangeMgr::SetHeadFootFribMap(bool bFlag)
+{
+ if (bFlag)
+ m_pFribMap = &m_HeadFootFribMap;
+ else
+ {
+ m_HeadFootFribMap.clear();
+ m_pFribMap = &m_DocFribMap;
+ }
+}
+
+void LwpChangeMgr::SetHeadFootChange(XFContentContainer* pCont)
+{
+ XFChangeList* pChangeList = new XFChangeList;
+
+ for (auto const& headFootFrib : m_HeadFootFribMap)
+ {
+ if (headFootFrib.first->GetRevisionType() == LwpFrib::REV_INSERT)
+ {
+ XFChangeInsert* pInsert = new XFChangeInsert;
+ pInsert->SetChangeID(headFootFrib.second);
+ pInsert->SetEditor(headFootFrib.first->GetEditor());
+ pChangeList->Add(pInsert);
+ }
+ else if (headFootFrib.first->GetRevisionType() == LwpFrib::REV_DELETE)
+ {
+ XFChangeDelete* pDelete = new XFChangeDelete;
+ pDelete->SetChangeID(headFootFrib.second);
+ pDelete->SetEditor(headFootFrib.first->GetEditor());
+ pChangeList->Add(pDelete);
+ }
+ }
+
+ pCont->Add(pChangeList);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharacterstyle.cxx b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
new file mode 100644
index 000000000..9ed15cdd6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpcharacterstyle.hxx"
+#include <lwpfilehdr.hxx>
+#include <lwpoverride.hxx>
+#include <lwpatomholder.hxx>
+#include <lwpfont.hxx>
+#include <lwpfoundry.hxx>
+#include "lwpcharborderoverride.hxx"
+#include <xfilter/xffont.hxx>
+#include <xfilter/xftextstyle.hxx>
+
+/*class LwpTextStyle*/
+LwpTextStyle::LwpTextStyle(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFPVList(objHdr, pStrm)
+ , m_nFontID(0)
+ , m_nFinalFontID(0)
+ , m_nCSFlags(0)
+ , m_nUseCount(0)
+ , m_nStyleDefinition(0)
+ , m_nKey(0)
+{
+}
+
+void LwpTextStyle::Read()
+{
+ LwpDLNFPVList::Read();
+ ReadCommon();
+}
+
+LwpTextStyle::~LwpTextStyle() {}
+
+void LwpTextStyle::ReadCommon()
+{
+ m_nFontID = m_pObjStrm->QuickReaduInt32();
+ m_nFinalFontID = m_pObjStrm->QuickReaduInt32();
+ m_nCSFlags = m_pObjStrm->QuickReaduInt16();
+ m_nUseCount = m_pObjStrm->QuickReaduInt32();
+
+ m_aDescription.Read(m_pObjStrm.get());
+
+ m_aLangOverride.Read(m_pObjStrm.get());
+ m_aTxtAttrOverride.Read(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ m_aCharacterBorderOverride.Read(m_pObjStrm.get());
+ m_aAmikakeOverride.Read(m_pObjStrm.get());
+ }
+ else
+ {
+ m_CharacterBorder.ReadIndexed(m_pObjStrm.get());
+ m_Amikake.ReadIndexed(m_pObjStrm.get());
+ }
+ sal_uInt16 nCount = 6;
+ if (LwpFileHeader::m_nFileRevision > 0x0005)
+ nCount = m_pObjStrm->QuickReaduInt16();
+
+ m_FaceStyle.ReadIndexed(m_pObjStrm.get());
+
+ if (nCount > 1)
+ {
+ m_SizeStyle.ReadIndexed(m_pObjStrm.get());
+ m_AttributeStyle.ReadIndexed(m_pObjStrm.get());
+ m_FontStyle.ReadIndexed(m_pObjStrm.get());
+ m_CharacterBorderStyle.ReadIndexed(m_pObjStrm.get());
+ m_AmikakeStyle.ReadIndexed(m_pObjStrm.get());
+ }
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ m_nStyleDefinition = m_pObjStrm->QuickReaduInt32();
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ m_nKey = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+ }
+ }
+}
+
+void LwpTextStyle::RegisterStyle()
+{
+ if (!m_pFoundry)
+ {
+ assert(false);
+ return;
+ }
+
+ std::unique_ptr<XFTextStyle> pStyle(new XFTextStyle());
+
+ //Set name
+ OUString styleName = GetName().str();
+ pStyle->SetStyleName(styleName);
+
+ //Create font
+ LwpFontManager& rFontMgr = m_pFoundry->GetFontManager();
+ rtl::Reference<XFFont> pFont = rFontMgr.CreateFont(m_nFinalFontID);
+ pStyle->SetFont(pFont);
+
+ //Set other properties if needed
+
+ //Add style
+ LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
+ pStyleMgr->AddStyle(GetObjectID(), std::move(pStyle));
+}
+
+/*class LwpCharacterStyle*/
+LwpCharacterStyle::LwpCharacterStyle(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTextStyle(objHdr, pStrm)
+{
+}
+
+void LwpCharacterStyle::Read() { LwpTextStyle::Read(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharacterstyle.hxx b/lotuswordpro/source/filter/lwpcharacterstyle.hxx
new file mode 100644
index 000000000..53cb0ae20
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharacterstyle.hxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARACTERSTYLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARACTERSTYLE_HXX
+
+#include "lwpdlvlist.hxx"
+#include <lwpoverride.hxx>
+#include "lwpcharborderoverride.hxx"
+
+class LwpAtomHolder;
+class LwpTextLanguageOverride;
+class LwpTextAttributeOverride;
+class LwpCharacterBorderOverride;
+class LwpAmikakeOverride;
+
+class LwpTextStyle : public LwpDLNFPVList
+{
+public:
+ LwpTextStyle(LwpObjectHeader const & objHdr, LwpSvStream* pStrm);
+
+ virtual ~LwpTextStyle() override;
+
+ inline sal_uInt32 GetFinalFontID() const;
+
+ virtual void RegisterStyle() override;
+
+protected:
+ void ReadCommon();
+ void Read() override;
+
+protected:
+
+ sal_uInt32 m_nFontID;
+ sal_uInt32 m_nFinalFontID;
+ sal_uInt16 m_nCSFlags;
+ sal_uInt32 m_nUseCount;
+
+ LwpAtomHolder m_aDescription;
+ LwpTextLanguageOverride m_aLangOverride;
+ LwpTextAttributeOverride m_aTxtAttrOverride;
+
+ LwpCharacterBorderOverride m_aCharacterBorderOverride;
+ LwpAmikakeOverride m_aAmikakeOverride;
+
+ LwpObjectID m_CharacterBorder;
+ LwpObjectID m_Amikake;
+ LwpObjectID m_FaceStyle;
+
+ LwpObjectID m_SizeStyle;
+ LwpObjectID m_AttributeStyle;
+ LwpObjectID m_FontStyle;
+ LwpObjectID m_CharacterBorderStyle;
+ LwpObjectID m_AmikakeStyle;
+
+ sal_uInt32 m_nStyleDefinition;
+// sal_uInt16 m_nBasedOnCount;
+ sal_uInt16 m_nKey;
+
+};
+
+inline sal_uInt32 LwpTextStyle::GetFinalFontID() const
+{
+ return m_nFinalFontID;
+}
+
+class LwpCharacterStyle : public LwpTextStyle
+{
+public:
+ LwpCharacterStyle(LwpObjectHeader const & objHdr, LwpSvStream* pStrm);
+
+ void Read() override;
+
+private:
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharborderoverride.cxx b/lotuswordpro/source/filter/lwpcharborderoverride.cxx
new file mode 100644
index 000000000..acca8e238
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharborderoverride.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+
+#include "clone.hxx"
+#include "lwpcharborderoverride.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwpmargins.hxx"
+
+LwpCharacterBorderOverride::LwpCharacterBorderOverride()
+ : m_pBorderStuff(new LwpBorderStuff)
+ , m_pMargins(new LwpMargins)
+ , m_nAboveWidth(0)
+ , m_nBelowWidth(0)
+{
+}
+
+LwpCharacterBorderOverride::LwpCharacterBorderOverride(LwpCharacterBorderOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nAboveWidth(rOther.m_nAboveWidth)
+ , m_nBelowWidth(rOther.m_nBelowWidth)
+{
+ std::unique_ptr<LwpBorderStuff> pBorderStuff(::clone(rOther.m_pBorderStuff.get()));
+ std::unique_ptr<LwpMargins> pMargins(::clone(rOther.m_pMargins.get()));
+ m_pBorderStuff = std::move(pBorderStuff);
+ m_pMargins = std::move(pMargins);
+}
+
+LwpCharacterBorderOverride::~LwpCharacterBorderOverride() {}
+
+LwpCharacterBorderOverride* LwpCharacterBorderOverride::clone() const
+{
+ return new LwpCharacterBorderOverride(*this);
+}
+
+void LwpCharacterBorderOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_pBorderStuff->Read(pStrm);
+ m_pMargins->Read(pStrm);
+ m_nAboveWidth = pStrm->QuickReaduInt32();
+ m_nBelowWidth = pStrm->QuickReaduInt32();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharborderoverride.hxx b/lotuswordpro/source/filter/lwpcharborderoverride.hxx
new file mode 100644
index 000000000..cc135f05b
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharborderoverride.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARBORDEROVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARBORDEROVERRIDE_HXX
+
+#include <lwpoverride.hxx>
+
+class LwpBorderStuff;
+class LwpMargins;
+class LwpCharacterBorderOverride final : public LwpOverride
+{
+public:
+ LwpCharacterBorderOverride();
+
+ virtual ~LwpCharacterBorderOverride() override;
+
+ virtual LwpCharacterBorderOverride* clone() const override;
+
+ void Read(LwpObjectStream* pStrm) override;
+
+private:
+ LwpCharacterBorderOverride(LwpCharacterBorderOverride const& rOther);
+ LwpCharacterBorderOverride& operator=(LwpCharacterBorderOverride const& rOther) = delete;
+
+ std::unique_ptr<LwpBorderStuff> m_pBorderStuff;
+ std::unique_ptr<LwpMargins> m_pMargins;
+ sal_Int32 m_nAboveWidth;
+ sal_Int32 m_nBelowWidth;
+
+ enum
+ {
+ PBO_STUFF = 0x01,
+ PBO_MARGINS = 0x04,
+ PBO_ABOVE = 0x40,
+ PBO_BELOW = 0x80
+ };
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharsetmgr.cxx b/lotuswordpro/source/filter/lwpcharsetmgr.cxx
new file mode 100644
index 000000000..493be11f9
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharsetmgr.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+#include "lwpcharsetmgr.hxx"
+//Added for SS migration
+#include <rtl/textenc.h>
+
+LwpCharSetMgr* LwpCharSetMgr::Instance = nullptr;
+
+LwpCharSetMgr* LwpCharSetMgr::GetInstance()
+{
+ if (Instance == nullptr)
+ Instance = new LwpCharSetMgr;
+ return Instance;
+}
+
+void LwpCharSetMgr::SetCodePageMap()
+{ //sal_uInt16 wordproCode,rtl_TextEncoding encoding, tmp hardcoding, 1-18
+ /* m_CodePageMap[256] =
+ m_CodePageMap[259] =
+ m_CodePageMap[819] =
+ m_CodePageMap[921] =*/
+ m_CodePageMap[437] = RTL_TEXTENCODING_ASCII_US;
+ m_CodePageMap[850] = RTL_TEXTENCODING_IBM_850;
+ //m_CodePageMap[851] = RTL_TEXTENCODING_IBM_851;
+ m_CodePageMap[852] = RTL_TEXTENCODING_IBM_852;
+ m_CodePageMap[857] = RTL_TEXTENCODING_IBM_857;
+ m_CodePageMap[860] = RTL_TEXTENCODING_IBM_860;
+ m_CodePageMap[863] = RTL_TEXTENCODING_IBM_863;
+ m_CodePageMap[865] = RTL_TEXTENCODING_IBM_865;
+ m_CodePageMap[866] = RTL_TEXTENCODING_IBM_866;
+ m_CodePageMap[869] = RTL_TEXTENCODING_IBM_869;
+ m_CodePageMap[874] = RTL_TEXTENCODING_MS_874; //thai
+ m_CodePageMap[932] = RTL_TEXTENCODING_MS_932; //japanese
+ m_CodePageMap[936] = RTL_TEXTENCODING_MS_936; //chinese simple
+ m_CodePageMap[949] = RTL_TEXTENCODING_MS_949; //korean
+ m_CodePageMap[950] = RTL_TEXTENCODING_BIG5; //chinese traditional
+ m_CodePageMap[1250] = RTL_TEXTENCODING_MS_1250; //Central European
+ m_CodePageMap[1252] = RTL_TEXTENCODING_MS_1252;
+ m_CodePageMap[1251] = RTL_TEXTENCODING_MS_1251; //ukrainian belarusian macedonian russian
+ m_CodePageMap[1253] = RTL_TEXTENCODING_MS_1253; //greek
+ m_CodePageMap[1254] = RTL_TEXTENCODING_MS_1254; //Turkish
+ m_CodePageMap[1255] = RTL_TEXTENCODING_MS_1255; //hebrew
+ m_CodePageMap[1256] = RTL_TEXTENCODING_MS_1256; //arabic
+ m_CodePageMap[1257] = RTL_TEXTENCODING_MS_1257; //estonian
+}
+
+rtl_TextEncoding LwpCharSetMgr::GetTextCharEncoding(sal_uInt16 wordproCode)
+{
+ std::map<sal_uInt16, rtl_TextEncoding>::iterator pos = m_CodePageMap.find(wordproCode);
+ if (pos != m_CodePageMap.end())
+ return m_CodePageMap[wordproCode];
+ return GetTextCharEncoding();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcharsetmgr.hxx b/lotuswordpro/source/filter/lwpcharsetmgr.hxx
new file mode 100644
index 000000000..c48e37c6a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcharsetmgr.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARSETMGR_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCHARSETMGR_HXX
+
+#include <rtl/textenc.h>
+#include <map>
+
+class LwpCharSetMgr
+{
+public:
+ LwpCharSetMgr() { SetCodePageMap(); }
+ static LwpCharSetMgr* GetInstance();
+ void SetCodePageMap();
+ rtl_TextEncoding GetTextCharEncoding(sal_uInt16 wordproCode);
+ static rtl_TextEncoding GetTextCharEncoding()
+ {
+ return RTL_TEXTENCODING_MS_1252; //here should be a default value,1252 or get from platform, 1-18
+ }
+
+private:
+ std::map<sal_uInt16, rtl_TextEncoding> m_CodePageMap;
+ static LwpCharSetMgr* Instance;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcolor.cxx b/lotuswordpro/source/filter/lwpcolor.cxx
new file mode 100644
index 000000000..14f580368
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcolor.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpcolor.hxx>
+
+/**
+ * @descr return the BGR format
+*/
+sal_uInt32 LwpColor::To24Color()
+{
+ return ((m_nRed >> 8) | (m_nGreen & 0xFF00) | static_cast<sal_uInt32>((m_nBlue & 0xFF00) << 8));
+}
+
+/**
+ * @descr read color and then resolve the RGB values
+*/
+void LwpColor::Read(LwpObjectStream* pStrm)
+{
+ m_nRed = pStrm->QuickReaduInt16();
+ m_nGreen = pStrm->QuickReaduInt16();
+ m_nBlue = pStrm->QuickReaduInt16();
+ m_nExtra = pStrm->QuickReaduInt16();
+
+ // resolve RGB values per the extra bytes
+ switch (m_nExtra)
+ {
+ case AGLRGB_RGB:
+ break;
+ case AGLRGB_RED:
+ m_nRed = 0xFFFF;
+ m_nGreen = 0x0000;
+ m_nBlue = 0x0000;
+ break;
+ case AGLRGB_GREEN:
+ m_nRed = 0x0000;
+ m_nGreen = 0xFFFF;
+ m_nBlue = 0x0000;
+ break;
+ case AGLRGB_BLUE:
+ m_nRed = 0x0000;
+ m_nGreen = 0x0000;
+ m_nBlue = 0xFFFF;
+ break;
+ case AGLRGB_BLACK:
+ m_nRed = 0x0000;
+ m_nGreen = 0x0000;
+ m_nBlue = 0x0000;
+ break;
+ case AGLRGB_WHITE:
+ m_nRed = 0xFFFF;
+ m_nGreen = 0xFFFF;
+ m_nBlue = 0xFFFF;
+ break;
+ case AGLRGB_GRAY:
+ m_nRed = 0x8080;
+ m_nGreen = 0x8080;
+ m_nBlue = 0x8080;
+ break;
+ case AGLRGB_LTGRAY:
+ m_nRed = 0xC0C0;
+ m_nGreen = 0xC0C0;
+ m_nBlue = 0xC0C0;
+ break;
+ case AGLRGB_DKGRAY:
+ m_nRed = 0x4040;
+ m_nGreen = 0x4040;
+ m_nBlue = 0x4040;
+ break;
+ case AGLRGB_INVALID:
+ case AGLRGB_TRANSPARENT:
+ default:
+ m_nRed = 0;
+ m_nGreen = 0;
+ m_nBlue = 0;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcontent.cxx b/lotuswordpro/source/filter/lwpcontent.cxx
new file mode 100644
index 000000000..1c00a9e91
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcontent.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpcontent.hxx"
+#include <lwpfilehdr.hxx>
+
+LwpHeadContent::LwpHeadContent(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+{
+}
+
+void LwpHeadContent::Read()
+{
+ LwpContent::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+LwpContent::LwpContent(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFVList(objHdr, pStrm)
+ , m_nFlags(0)
+{
+}
+
+void LwpContent::Read()
+{
+ LwpDLNFVList::Read();
+
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ m_LayoutsWithMe.Read(pStrm);
+ m_nFlags = pStrm->QuickReaduInt16();
+ m_nFlags &= ~(CF_CHANGED | CF_DISABLEVALUECHECKING);
+ //LwpAtomHolder ClassName;
+ //ClassName.Read(pStrm);
+ m_ClassName.Read(pStrm);
+
+ if (LwpFileHeader::m_nFileRevision >= 0x0006)
+ {
+ //SkipID.ReadIndexed(pStrm);
+ //SkipID.ReadIndexed(pStrm);
+ m_NextEnumerated.ReadIndexed(pStrm);
+ m_PreviousEnumerated.ReadIndexed(pStrm);
+ }
+
+ if (LwpFileHeader::m_nFileRevision >= 0x0007)
+ {
+ LwpObjectID SkipID;
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ SkipID.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+ }
+ else
+ {
+ sal_uInt8 HasNotify = pStrm->QuickReaduInt8();
+ if (HasNotify)
+ {
+ SkipID.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+ }
+ }
+ }
+
+ pStrm->SkipExtra();
+}
+
+rtl::Reference<LwpVirtualLayout> LwpContent::GetLayout(LwpVirtualLayout const* pStartLayout)
+{
+ return m_LayoutsWithMe.GetLayout(pStartLayout);
+}
+
+bool LwpContent::HasNonEmbeddedLayouts()
+{
+ rtl::Reference<LwpVirtualLayout> xLayout;
+ while (true)
+ {
+ xLayout = GetLayout(xLayout.get());
+ if (!xLayout.is())
+ break;
+ if (!xLayout->NoContentReference())
+ return true;
+ }
+ return false;
+}
+
+bool LwpContent::IsStyleContent()
+{
+ rtl::Reference<LwpVirtualLayout> xLayout;
+ while (true)
+ {
+ xLayout = GetLayout(xLayout.get());
+ if (!xLayout.is())
+ break;
+ if (xLayout->IsStyleLayout())
+ return true;
+ }
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpcontent.hxx b/lotuswordpro/source/filter/lwpcontent.hxx
new file mode 100644
index 000000000..7fc976d98
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpcontent.hxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * LwpContent, LwpHeadContent: base class for Word Pro content object
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCONTENT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPCONTENT_HXX
+
+#include <config_lgpl.h>
+#include <lwpobj.hxx>
+#include <lwpatomholder.hxx>
+#include "lwplayout.hxx"
+
+/**
+ * @brief
+ * Base class of all Lwp content objects
+ */
+class LwpContent : public LwpDLNFVList
+{
+public:
+ LwpContent(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+private:
+ LwpAssociatedLayouts m_LayoutsWithMe;
+ sal_uInt16 m_nFlags;
+ LwpAtomHolder m_ClassName;
+ LwpObjectID m_NextEnumerated;
+ LwpObjectID m_PreviousEnumerated;
+ /* Flag bits */
+ enum
+ {
+ CF_CHANGED = 0x0001,
+ CF_MODIFIED = 0x0004,
+ CF_LOCAL = 0x0008,
+ CF_INFOOTNOTE = 0x0010,
+ CF_METACHANGED = 0x0020,
+ CF_PRIVATE = 0x0040,
+ CF_DEACTIVATED = 0x0080,
+ CF_VALUECHANGED = 0x0100,
+ CF_DISABLEVALUECHECKING = 0x0200,
+ CF_DONTNOTIFYDOCUMENT = 0x0400, // for numeric formatting
+ CF_ISOVERRIDE = 0x0800,
+ CF_ISBULLET = 0x1000,
+ CF_CONTINUEDON = 0x2000,
+ CF_CONTINUEDFROM = 0x4000,
+
+ // Bits that should be transferred when we duplicate a content
+ CF_COPYMASK = (CF_MODIFIED | CF_PRIVATE)
+ };
+protected:
+ void Read() override;
+public:
+ inline LwpAssociatedLayouts& GetLayoutsWithMe();
+ rtl::Reference<LwpVirtualLayout> GetLayout(LwpVirtualLayout const * pStartLayout);
+ inline bool IsActive() const;
+ virtual bool IsTable();
+ inline OUString const & GetClassName() const;
+ inline LwpContent* GetNextEnumerated();
+ bool HasNonEmbeddedLayouts();
+ bool IsStyleContent();
+};
+
+LwpAssociatedLayouts& LwpContent::GetLayoutsWithMe()
+{
+ return m_LayoutsWithMe;
+}
+
+inline bool LwpContent::IsActive() const
+{
+ return !(m_nFlags & CF_DEACTIVATED);
+}
+
+inline bool LwpContent::IsTable()
+{
+ return false;
+}
+
+inline OUString const & LwpContent::GetClassName() const
+{
+ return m_ClassName.str();
+}
+
+inline LwpContent* LwpContent::GetNextEnumerated()
+{
+ return dynamic_cast<LwpContent*>(m_NextEnumerated.obj().get());
+}
+/**
+ * @brief
+ * Head object of content list
+ */
+class LwpHeadContent : public LwpContent
+{
+public:
+ LwpHeadContent(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+protected:
+ void Read() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdivinfo.cxx b/lotuswordpro/source/filter/lwpdivinfo.cxx
new file mode 100644
index 000000000..0ad20d618
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdivinfo.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpdivinfo.hxx"
+#include "lwpdoc.hxx"
+#include <lwpobjstrm.hxx>
+#include <lwpfilehdr.hxx>
+#include "lwpholder.hxx"
+#include "lwppagehint.hxx"
+#include <sal/log.hxx>
+
+LwpDivInfo::LwpDivInfo(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+ , m_nFlags(0)
+ , m_nPageNoStyle(0)
+{
+}
+
+LwpDivInfo::~LwpDivInfo() {}
+
+void LwpDivInfo::Read()
+{
+ SkipFront();
+ m_ParentID.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ m_pObjStrm->SkipExtra();
+ }
+ m_Name.Read(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ m_pObjStrm->SkipExtra();
+ }
+
+ m_LayoutID.ReadIndexed(m_pObjStrm.get());
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ if (LwpFileHeader::m_nFileRevision < 0x0010) // In 98, graphic links count too
+ {
+ if ((m_nFlags & DI_ANYOLEDDELINKS) == 0)
+ m_nFlags &= ~DI_KNOWIFANYOLEDDELINKS;
+ }
+
+ m_ExternalName.Read(m_pObjStrm.get());
+ m_ExternalType.Read(m_pObjStrm.get());
+ m_ClassName.Read(m_pObjStrm.get());
+ m_InitialLayoutID.ReadIndexed(m_pObjStrm.get());
+
+ m_nPageNoStyle = m_pObjStrm->QuickReaduInt16();
+ m_TabColor.Read(m_pObjStrm.get());
+
+ // read filler page stuff
+ m_FillerPageTextID.ReadIndexed(m_pObjStrm.get());
+
+ // read external file object stuff
+ sal_uInt16 type = m_pObjStrm->QuickReaduInt16();
+ //cpExternalFile = LNULL;
+
+ SAL_WARN_IF(type != 0, "lwp", "should be 0");
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpDivInfo::SkipFront()
+{
+ LwpObjectID toSkip;
+
+ toSkip.ReadIndexed(m_pObjStrm.get()); // skip ListNext;
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ m_pObjStrm->SkipExtra();
+ }
+ toSkip.ReadIndexed(m_pObjStrm.get()); // skip ListPrevious;
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ m_pObjStrm->SkipExtra();
+ }
+ toSkip.ReadIndexed(m_pObjStrm.get()); // skip Head;
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ toSkip.ReadIndexed(m_pObjStrm.get()); //skip tail
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpDivInfo::GetNumberOfPages(sal_uInt16& nPageno)
+{
+ if (IsGotoable())
+ {
+ if (IsOleDivision())
+ {
+ //not support now
+ return;
+ }
+ else
+ {
+ nPageno += GetMaxNumberOfPages();
+ }
+ }
+}
+
+sal_uInt16 LwpDivInfo::GetMaxNumberOfPages() const
+{
+ LwpDocument* pDiv = dynamic_cast<LwpDocument*>(m_ParentID.obj().get());
+ if (!pDiv)
+ return 0;
+ LwpDLVListHeadTailHolder* pHeadTail
+ = dynamic_cast<LwpDLVListHeadTailHolder*>(pDiv->GetPageHintsID().obj().get());
+ if (pHeadTail)
+ {
+ LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail().obj().get());
+ if (pPageHint && !pPageHint->GetPageLayoutID().IsNull())
+ {
+ return pPageHint->GetPageNumber();
+ }
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdivinfo.hxx b/lotuswordpro/source/filter/lwpdivinfo.hxx
new file mode 100644
index 000000000..f2acb447a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdivinfo.hxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDIVINFO_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDIVINFO_HXX
+
+#include <config_lgpl.h>
+
+#include <lwpobj.hxx>
+#include <lwpobjid.hxx>
+#include <lwpatomholder.hxx>
+#include <lwpcolor.hxx>
+
+#define STR_OleDivisionClassName "OLEDivision"
+
+class LwpDivInfo : public LwpObject
+{
+public:
+ LwpDivInfo(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ LwpObjectID& GetInitialLayoutID() { return m_InitialLayoutID; }
+ LwpObjectID& GetFillerPageTextID() { return m_FillerPageTextID; }
+ OUString const& GetDivName() const { return m_Name.str(); }
+
+ OUString const& GetClassName() const { return m_ClassName.str(); }
+ inline bool HasContents() const;
+ inline bool IsOleDivision() const;
+ inline bool IsScrollable() const;
+ inline bool IsGotoable() const;
+ void GetNumberOfPages(sal_uInt16& nPageno);
+ sal_uInt16 GetMaxNumberOfPages() const;
+
+protected:
+ void Read() override;
+
+private:
+ virtual ~LwpDivInfo() override;
+
+ LwpObjectID m_ParentID;
+ LwpAtomHolder m_Name;
+ LwpObjectID m_LayoutID;
+ sal_uInt16 m_nFlags;
+ LwpAtomHolder m_ExternalName;
+ LwpAtomHolder m_ExternalType;
+ LwpAtomHolder m_ClassName;
+ LwpObjectID m_InitialLayoutID;
+ //pCDLVOListHeadHolder cPresInfo;
+
+ sal_uInt16 m_nPageNoStyle;
+ LwpColor m_TabColor;
+ LwpObjectID m_FillerPageTextID;
+
+ enum
+ {
+ DI_SCROLLABLE = 0x01,
+ DI_HASCONTENTS = 0x02,
+ DI_EXPANDED = 0x04,
+ DI_SHOWSTAB = 0x08,
+
+ DI_MUDPUPPY = 0x10,
+ DI_NOTDELETABLE = 0x20,
+ DI_BEGINGROUP = 0x40,
+ DI_GROUP = 0x80,
+
+ DI_ENDGROUP = 0x100,
+ DI_SUPPRESS_FILLER_PAGE_HEADERS = 0x200,
+ DI_EXTERNALFILE = 0x400,
+ DI_FIXED = 0x800,
+
+ DI_KNOWIFANYOLEDDELINKS = 0x1000,
+ DI_ANYOLEDDELINKS = 0x2000
+ };
+
+ void SkipFront();
+};
+
+inline bool LwpDivInfo::HasContents() const { return (m_nFlags & DI_HASCONTENTS) != 0; }
+
+inline bool LwpDivInfo::IsOleDivision() const
+{
+ OUString strClassName = GetClassName();
+ if (strClassName == STR_OleDivisionClassName)
+ return true;
+ return false;
+}
+
+inline bool LwpDivInfo::IsScrollable() const { return (m_nFlags & DI_SCROLLABLE) != 0; }
+
+inline bool LwpDivInfo::IsGotoable() const
+{
+ return HasContents() && (IsScrollable() || IsOleDivision());
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdivopts.cxx b/lotuswordpro/source/filter/lwpdivopts.cxx
new file mode 100644
index 000000000..990239547
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdivopts.cxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpdivopts.hxx"
+#include <lwpfilehdr.hxx>
+
+LwpHyphenOptions::LwpHyphenOptions()
+ : m_nFlags(0)
+ , m_nZoneBefore(0)
+ , m_nZoneAfter(0)
+ , m_nMaxLines(0)
+{
+}
+
+void LwpHyphenOptions::Read(LwpObjectStream *pStrm)
+{
+ m_nFlags = pStrm->QuickReaduInt16();
+ m_nZoneBefore = pStrm->QuickReaduInt16();
+ m_nZoneAfter = pStrm->QuickReaduInt16();
+ m_nMaxLines = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+
+LwpTextLanguage::LwpTextLanguage()
+ : m_nLanguage(0)
+{
+}
+
+void LwpTextLanguage::Read(LwpObjectStream *pStrm)
+{
+ m_nLanguage = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+
+ if( LwpFileHeader::m_nFileRevision <= 0x0a)
+ m_nLanguage = ConvertFrom96(m_nLanguage);
+}
+
+sal_uInt16 LwpTextLanguage::ConvertFrom96(sal_uInt16 orgLang)
+{
+ // Reading a Word Pro 96 into Word Pro 97
+ switch (orgLang)
+ {
+ case 0x2809U: // AMI_MEDICAL 96
+ orgLang = 0x8409U; //0x8409U 97
+ break;
+ case 0x2C09U: // AMI_BRMEDICAL 96
+ orgLang = 0x8809U; // 0x8809U 97
+ break;
+ case 0x3409U: // AMI_BRITISHMEDIZE 96
+ orgLang = 0x8C09U; // 0x8C09U 97
+ break;
+ case 0x3009U: // AMI_BRITISHIZE 96
+ orgLang = 0x1009U; // 0x1009U 97
+ break;
+ case 0x819U: // AMI_RUSSIANIO 96
+ orgLang = 0x8419U; // 0x8419U 97
+ break;
+ }
+ return orgLang;
+}
+
+LwpDivisionOptions::LwpDivisionOptions(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+ , m_nOptionFlag(0)
+{
+}
+
+LwpDivisionOptions::~LwpDivisionOptions()
+{}
+
+void LwpDivisionOptions::Read()
+{
+ m_HyphOpts.Read(m_pObjStrm.get());
+ m_nOptionFlag = m_pObjStrm->QuickReaduInt16();
+ m_Lang.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdivopts.hxx b/lotuswordpro/source/filter/lwpdivopts.hxx
new file mode 100644
index 000000000..cfcd33858
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdivopts.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDIVOPTS_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDIVOPTS_HXX
+
+#include <config_lgpl.h>
+
+#include <lwpobj.hxx>
+
+class LwpHyphenOptions
+{
+public:
+ LwpHyphenOptions();
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nZoneBefore;
+ sal_uInt16 m_nZoneAfter;
+ sal_uInt16 m_nMaxLines;
+};
+
+/*
+Text language.
+This class which holds identifiers for language and dialect.
+DESCRIPTION You can mark text as being a certain language. When we spell
+ check or grammar check we'll use this info to determine which dictionary
+ to use.
+ The only reserved value is 0, which means "default language". The
+ default language is specified by the document.
+*/
+class LwpTextLanguage
+{
+public:
+ LwpTextLanguage();
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ static sal_uInt16 ConvertFrom96(sal_uInt16 orgLang);
+ sal_uInt16 m_nLanguage;
+};
+
+class LwpDivisionOptions : public LwpObject
+{
+public:
+ LwpDivisionOptions(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+
+protected:
+ void Read() override;
+
+private:
+ virtual ~LwpDivisionOptions() override;
+
+ LwpHyphenOptions m_HyphOpts;
+ sal_uInt16 m_nOptionFlag;
+ LwpTextLanguage m_Lang;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdlvlist.cxx b/lotuswordpro/source/filter/lwpdlvlist.cxx
new file mode 100644
index 000000000..79a43a38c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdlvlist.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * list class implementation
+ ************************************************************************/
+
+#include "lwpdlvlist.hxx"
+#include <lwpfilehdr.hxx>
+#include "lwpproplist.hxx"
+
+LwpDLVList::LwpDLVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+{
+}
+/**
+ * @descr Read LwpDLVList data from object stream
+ **/
+void LwpDLVList::Read()
+{
+ LwpObjectStream* pObjStrm = m_pObjStrm.get();
+ m_ListNext.ReadIndexed(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ pObjStrm->SkipExtra();
+
+ m_ListPrevious.ReadIndexed(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ pObjStrm->SkipExtra();
+}
+LwpDLNFVList::LwpDLNFVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+{
+}
+/**
+ * @descr Read LwpDLNFVList data from object stream
+ **/
+void LwpDLNFVList::Read()
+{
+ LwpDLVList::Read();
+
+ LwpObjectStream* pObjStrm = m_pObjStrm.get();
+
+ m_ChildHead.ReadIndexed(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006 || !m_ChildHead.IsNull())
+ m_ChildTail.ReadIndexed(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ pObjStrm->SkipExtra();
+
+ m_Parent.ReadIndexed(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ pObjStrm->SkipExtra();
+
+ ReadName(pObjStrm);
+}
+/**
+ * @descr Read name of LwpDLNFVList from object stream
+ **/
+void LwpDLNFVList::ReadName(LwpObjectStream* pObjStrm)
+{
+ m_Name.Read(pObjStrm);
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ pObjStrm->SkipExtra();
+}
+/**
+ * @descr ctor of LwpDLNFPVList from object stream
+ * Note that m_bHasProperties is initialized to true
+ **/
+LwpDLNFPVList::LwpDLNFPVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFVList(objHdr, pStrm)
+ , m_bHasProperties(true)
+{
+}
+/**
+ * @descr Read name of LwpDLNFVList from object stream
+ **/
+void LwpDLNFPVList::Read()
+{
+ LwpDLNFVList::Read();
+
+ LwpObjectStream* pObjStrm = m_pObjStrm.get();
+ ReadPropertyList(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+/**
+ * @descr Read property list
+ **/
+void LwpDLNFPVList::ReadPropertyList(LwpObjectStream* pObjStrm)
+{
+ if (LwpFileHeader::m_nFileRevision >= 0x0000B)
+ {
+ m_bHasProperties = pObjStrm->QuickReaduInt8() != 0;
+ if (m_bHasProperties)
+ {
+ m_pPropList.reset(new LwpPropList);
+ m_pPropList->Read(pObjStrm);
+ }
+ }
+}
+/**
+ * @descr release property list
+ **/
+LwpDLNFPVList::~LwpDLNFPVList() {}
+
+/**
+ * @descr Read head id and tail id
+ **/
+void LwpDLVListHeadTail::Read(LwpObjectStream* pObjStrm)
+{
+ m_ListHead.ReadIndexed(pObjStrm);
+ if ((LwpFileHeader::m_nFileRevision < 0x0006) || !m_ListHead.IsNull())
+ {
+ m_ListTail.ReadIndexed(pObjStrm);
+ }
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ {
+ pObjStrm->SkipExtra();
+ }
+}
+/**
+ * @descr Read head id
+ **/
+void LwpDLVListHead::Read(LwpObjectStream* pObjStrm) { m_objHead.ReadIndexed(pObjStrm); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdlvlist.hxx b/lotuswordpro/source/filter/lwpdlvlist.hxx
new file mode 100644
index 000000000..0c93818cb
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdlvlist.hxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * list related class
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDLVLIST_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDLVLIST_HXX
+
+#include <lwpatomholder.hxx>
+#include <lwpobj.hxx>
+#include <memory>
+
+/**
+ * @brief Double Linked Virtual List
+ */
+class LwpDLVList : public LwpObject
+{
+public:
+ LwpDLVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ LwpObjectID& GetNext() { return m_ListNext; }
+ LwpObjectID& GetPrevious() { return m_ListPrevious; }
+
+protected:
+ virtual ~LwpDLVList() override {}
+ void Read() override;
+
+private:
+ LwpObjectID m_ListPrevious;
+ LwpObjectID m_ListNext;
+};
+
+/**
+ * @brief Double Linked Named Family Virtual List
+ */
+class LwpDLNFVList : public LwpDLVList
+{
+public:
+ LwpDLNFVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+
+protected:
+ virtual ~LwpDLNFVList() override {}
+
+ LwpObjectID m_ChildHead;
+ LwpObjectID m_ChildTail;
+ LwpObjectID m_Parent;
+ LwpAtomHolder m_Name;
+
+protected:
+ void Read() override;
+ void ReadName(LwpObjectStream* pObjStrm);
+
+public:
+ LwpAtomHolder& GetName() { return m_Name; }
+ LwpObjectID& GetChildHead() { return m_ChildHead; }
+ LwpObjectID& GetChildTail() { return m_ChildTail; }
+ LwpObjectID& GetParent() { return m_Parent; }
+};
+
+class LwpPropList;
+/**
+ * @brief Double Linked Named Family Properties Virtual List
+*/
+class LwpDLNFPVList : public LwpDLNFVList
+{
+public:
+ LwpDLNFPVList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpDLNFPVList() override;
+ LwpPropList* GetPropList() { return m_pPropList.get(); }
+
+protected:
+ void Read() override;
+ void ReadPropertyList(LwpObjectStream* pObjStrm);
+
+private:
+ bool m_bHasProperties;
+ std::unique_ptr<LwpPropList> m_pPropList;
+};
+
+/**
+ * @brief Double Linked Virtual List Head Tail
+*/
+class LwpDLVListHeadTail
+{
+public:
+ LwpDLVListHeadTail() {}
+ void Read(LwpObjectStream* pObjStrm);
+
+private:
+ LwpObjectID m_ListHead;
+ LwpObjectID m_ListTail;
+
+public:
+ LwpObjectID& GetHead() { return m_ListHead; }
+ LwpObjectID& GetTail() { return m_ListTail; }
+};
+
+/**
+ * @brief Double Linked Virtual List Head
+*/
+class LwpDLVListHead
+{
+public:
+ LwpDLVListHead() {}
+ void Read(LwpObjectStream* pObjStrm);
+ LwpObjectID& GetFirst() { return m_objHead; }
+
+private:
+ LwpObjectID m_objHead; //LwpDLVList
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
new file mode 100644
index 000000000..b6955b489
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -0,0 +1,835 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpglobalmgr.hxx>
+#include "lwpcharacterstyle.hxx"
+#include "lwpdoc.hxx"
+#include "lwpfootnote.hxx"
+#include "lwppagehint.hxx"
+#include "lwpdivinfo.hxx"
+#include "lwpholder.hxx"
+#include "lwpstory.hxx"
+#include "lwpsilverbullet.hxx"
+#include "lwpsortopt.hxx"
+#include "lwplayout.hxx"
+#include "lwppagelayout.hxx"
+#include "lwpuidoc.hxx"
+#include "lwpusrdicts.hxx"
+#include "lwpprtinfo.hxx"
+#include "lwpverdocument.hxx"
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <o3tl/sorted_vector.hxx>
+
+LwpDocument::LwpDocument(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFPVList(objHdr, pStrm)
+ , m_bGettingFirstDivisionWithContentsThatIsNotOLE(false)
+ , m_bGettingPreviousDivisionWithContents(false)
+ , m_bGettingGetLastDivisionWithContents(false)
+ , m_nFlags(0)
+ , m_nPersistentFlags(0)
+{
+}
+
+LwpDocument::~LwpDocument() {}
+/**
+ * @descr Read VO_Document from object stream
+ **/
+void LwpDocument::Read()
+{
+ LwpDLNFPVList::Read();
+
+ ReadPlug();
+
+ m_nPersistentFlags = m_pObjStrm->QuickReaduInt32();
+
+ //Skip the SortOption and UIDocument
+ {
+ LwpSortOption aDocSort(m_pObjStrm.get());
+ LwpUIDocument aUIDoc(m_pObjStrm.get());
+ }
+
+ m_xLnOpts.reset(new LwpLineNumberOptions(m_pObjStrm.get()));
+
+ //Skip LwpUserDictFiles
+ {
+ LwpUserDictFiles aUsrDicts(m_pObjStrm.get());
+ }
+
+ if (!IsChildDoc())
+ {
+ //Skip LwpPrinterInfo
+ LwpPrinterInfo aPrtInfo(m_pObjStrm.get());
+ }
+
+ m_xOwnedFoundry.reset(new LwpFoundry(m_pObjStrm.get(), this));
+
+ m_DivOpts.ReadIndexed(m_pObjStrm.get());
+
+ if (!IsChildDoc())
+ {
+ m_FootnoteOpts.ReadIndexed(m_pObjStrm.get());
+ m_DocData.ReadIndexed(m_pObjStrm.get());
+ }
+ else
+ {
+ //Skip the docdata used in old version
+ LwpObjectID dummyDocData;
+ dummyDocData.ReadIndexed(m_pObjStrm.get());
+ }
+ m_DivInfo.ReadIndexed(m_pObjStrm.get());
+ m_Epoch.Read(m_pObjStrm.get());
+ m_WYSIWYGPageHints.ReadIndexed(m_pObjStrm.get());
+ m_VerDoc.ReadIndexed(m_pObjStrm.get());
+ m_STXInfo.ReadIndexed(m_pObjStrm.get());
+}
+
+/**
+ * @descr Read plug related data from m_pObjStram
+ **/
+void LwpDocument::ReadPlug()
+{
+ m_DocSockID.ReadIndexed(m_pObjStrm.get());
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Parse obj to IXFStream
+ **/
+void LwpDocument::Parse(IXFStream* pOutputStream)
+{
+ //check the name and skip script division
+ if (!IsSkippedDivision())
+ {
+ //the frames which anchor are to page must output before other contents
+ ParseFrameInPage(pOutputStream);
+ ParseDocContent(pOutputStream);
+ }
+
+ rtl::Reference<LwpObject> pDocSock = GetSocket().obj(VO_DOCSOCK);
+ if (pDocSock.is())
+ {
+ pDocSock->DoParse(pOutputStream);
+ }
+}
+
+bool LwpDocument::IsSkippedDivision()
+{
+ OUString sDivName;
+ bool ret = false;
+ LwpDivInfo* pDiv = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj(VO_DIVISIONINFO).get());
+ if (pDiv == nullptr)
+ return true;
+ sDivName = pDiv->GetDivName();
+ if (!sDivName.isEmpty() && !pDiv->IsGotoable()) //including toa,scripts division
+ return true;
+ //skip endnote division
+ OUString strClassName = pDiv->GetClassName();
+ if ((strClassName == STR_DivisionEndnote) || (strClassName == STR_DivisionGroupEndnote)
+ || (strClassName == STR_DocumentEndnote))
+ {
+ LwpPageLayout* pPageLayout
+ = dynamic_cast<LwpPageLayout*>(pDiv->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
+ if (pPageLayout)
+ {
+ LwpStory* pStory
+ = dynamic_cast<LwpStory*>(pPageLayout->GetContent().obj(VO_STORY).get());
+ if (pStory)
+ {
+ //This judgement maybe have problem. If there is only one para in the story,
+ //this endnote division has no other contents except endnote table.
+ LwpObjectID& rFirst = pStory->GetFirstPara();
+ LwpObjectID& rLast = pStory->GetLastPara();
+ if (rFirst == rLast)
+ ret = true;
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * @descr Register all styles in this division
+ */
+void LwpDocument::RegisterStyle()
+{
+ RegisterDefaultParaStyles();
+ RegisterGraphicsStyles();
+ RegisterBulletStyles();
+
+ RegisterTextStyles();
+ RegisterLayoutStyles();
+ RegisterStylesInPara();
+
+ RegisterLinenumberStyles();
+ RegisterFootnoteStyles();
+
+ //Register styles in other document connected with this document: next doc, children doc
+ rtl::Reference<LwpObject> pDocSock = GetSocket().obj();
+ if (pDocSock.is())
+ {
+ pDocSock->DoRegisterStyle();
+ }
+}
+/**
+ * @descr Register all named para styles
+ */
+void LwpDocument::RegisterTextStyles()
+{
+ //Register all text styles: para styles, character styles
+ LwpDLVListHeadHolder* pTextStyleHolder
+ = m_xOwnedFoundry
+ ? dynamic_cast<LwpDLVListHeadHolder*>(m_xOwnedFoundry->GetTextStyleHead().obj().get())
+ : nullptr;
+ if (pTextStyleHolder)
+ {
+ LwpTextStyle* pTextStyle
+ = dynamic_cast<LwpTextStyle*>(pTextStyleHolder->GetHeadID().obj().get());
+ while (pTextStyle)
+ {
+ if (pTextStyle->GetFoundry())
+ throw std::runtime_error("loop in register text style");
+ pTextStyle->SetFoundry(m_xOwnedFoundry.get());
+ pTextStyle->RegisterStyle();
+ pTextStyle = dynamic_cast<LwpTextStyle*>(pTextStyle->GetNext().obj().get());
+ }
+ }
+ ChangeStyleName(); //for click here block
+}
+/**
+ * @descr Register all layouts styles (page master and master page)
+ * All para styles used in master page (header and footer) are registered and then showed
+ */
+void LwpDocument::RegisterLayoutStyles()
+{
+ if (m_xOwnedFoundry)
+ {
+ //Register all layout styles, before register all styles in para
+ m_xOwnedFoundry->RegisterAllLayouts();
+ }
+
+ //set initial pagelayout in story for parsing pagelayout
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj(VO_DIVISIONINFO).get());
+ if (!pDivInfo)
+ return;
+
+ LwpPageLayout* pPageLayout
+ = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
+ if (pPageLayout)
+ {
+ //In Ole division, the content of pagelayout is VO_OLEOBJECT
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent().obj(VO_STORY).get());
+ if (pStory)
+ {
+ //add all the pagelayout in order into the pagelayout list;
+ pStory->SortPageLayout();
+ pStory->SetCurrentLayout(pPageLayout);
+ }
+ }
+}
+/**
+ * @descr Register all styles used in para
+ */
+void LwpDocument::RegisterStylesInPara()
+{
+ //Register all automatic styles in para
+ rtl::Reference<LwpHeadContent> xContent(
+ m_xOwnedFoundry ? dynamic_cast<LwpHeadContent*>(
+ m_xOwnedFoundry->GetContentManager().GetContentList().obj().get())
+ : nullptr);
+ if (!xContent.is())
+ return;
+
+ rtl::Reference<LwpStory> xStory(
+ dynamic_cast<LwpStory*>(xContent->GetChildHead().obj(VO_STORY).get()));
+ o3tl::sorted_vector<LwpStory*> aSeen;
+ while (xStory.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xStory.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ //Register the child para
+ xStory->SetFoundry(m_xOwnedFoundry.get());
+ xStory->DoRegisterStyle();
+ xStory.set(dynamic_cast<LwpStory*>(xStory->GetNext().obj(VO_STORY).get()));
+ }
+}
+/**
+ * @descr Register all bullet styles used in this division
+ */
+void LwpDocument::RegisterBulletStyles()
+{
+ if (!m_xOwnedFoundry)
+ return;
+ //Register bullet styles
+ LwpDLVListHeadHolder* pBulletHead = dynamic_cast<LwpDLVListHeadHolder*>(
+ m_xOwnedFoundry->GetBulletManagerID().obj(VO_HEADHOLDER).get());
+ if (!pBulletHead)
+ return;
+ LwpSilverBullet* pBullet = dynamic_cast<LwpSilverBullet*>(pBulletHead->GetHeadID().obj().get());
+ o3tl::sorted_vector<LwpSilverBullet*> aSeen;
+ while (pBullet)
+ {
+ bool bAlreadySeen = !aSeen.insert(pBullet).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ pBullet->SetFoundry(m_xOwnedFoundry.get());
+ pBullet->RegisterStyle();
+ pBullet = dynamic_cast<LwpSilverBullet*>(pBullet->GetNext().obj().get());
+ }
+}
+/**
+ * @descr Register all styles used in VO_Graphic
+ */
+void LwpDocument::RegisterGraphicsStyles()
+{
+ if (!m_xOwnedFoundry)
+ return;
+ //Register all graphics styles, the first object should register the next;
+ rtl::Reference<LwpObject> pGraphic = m_xOwnedFoundry->GetGraphicListHead().obj(VO_GRAPHIC);
+ if (!pGraphic.is())
+ return;
+ pGraphic->SetFoundry(m_xOwnedFoundry.get());
+ pGraphic->DoRegisterStyle();
+}
+/**
+ * @descr Register line number styles
+ */
+void LwpDocument::RegisterLinenumberStyles()
+{
+ if (!m_xLnOpts)
+ return;
+ m_xLnOpts->RegisterStyle();
+}
+
+/**
+* @descr Register footnote/endnote configuration for the entire document
+*/
+void LwpDocument::RegisterFootnoteStyles()
+{
+ //Register footnote and endnote configuration for the entire document
+ if (!m_FootnoteOpts.IsNull())
+ {
+ LwpFootnoteOptions* pFootnoteOpts
+ = dynamic_cast<LwpFootnoteOptions*>(m_FootnoteOpts.obj().get());
+ if (pFootnoteOpts)
+ {
+ pFootnoteOpts->SetMasterPage("Endnote");
+ pFootnoteOpts->RegisterStyle();
+ }
+ }
+ //Register endnote page style for endnote configuration, use the last division that has endnote for the endnote page style
+ //This page style must register after its division default styles have registered
+ LwpDocument* pEndnoteDiv = GetLastDivisionThatHasEndnote();
+ if (this != pEndnoteDiv)
+ return;
+
+ LwpDLVListHeadTailHolder* pHeadTail
+ = dynamic_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID().obj().get());
+ if (!pHeadTail)
+ return;
+
+ LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail().obj().get());
+ if (pPageHint && !pPageHint->GetPageLayoutID().IsNull())
+ {
+ LwpPageLayout* pPageLayout
+ = dynamic_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID().obj().get());
+ if (pPageLayout)
+ {
+ pPageLayout->SetFoundry(GetFoundry());
+ pPageLayout->RegisterEndnoteStyle();
+ }
+ }
+}
+
+/**
+* @descr Register default para styles
+*/
+void LwpDocument::RegisterDefaultParaStyles()
+{
+ if (IsChildDoc())
+ return;
+
+ //Get First Division
+ //LwpDocument* pFirstDoc = GetFirstDivision();
+ LwpDocument* pFirstDoc = GetFirstDivisionWithContentsThatIsNotOLE();
+ if (pFirstDoc)
+ {
+ LwpVerDocument* pVerDoc = dynamic_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc().obj().get());
+ if (pVerDoc)
+ {
+ pVerDoc->RegisterStyle();
+ }
+ }
+}
+
+/**
+ * @descr Parse content in this division to IXFStream
+ * LwpDocument->LwpDivInfo->LwpPageLayout.Parse()
+ */
+void LwpDocument::ParseDocContent(IXFStream* pOutputStream)
+{
+ //Parse content in PageLayout
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj().get());
+ if (pDivInfo == nullptr)
+ return;
+
+ rtl::Reference<LwpObject> pLayoutObj = pDivInfo->GetInitialLayoutID().obj();
+ if (!pLayoutObj.is())
+ {
+ //master document not supported now.
+ return;
+ }
+ pLayoutObj->SetFoundry(m_xOwnedFoundry.get());
+ pLayoutObj->DoParse(pOutputStream);
+}
+
+/**
+ * @descr Get the footnoteoptions from the root document
+ */
+LwpObjectID* LwpDocument::GetValidFootnoteOpts()
+{
+ LwpDocument* pRoot = GetRootDocument();
+ if (pRoot)
+ {
+ return &pRoot->GetFootnoteOpts();
+ }
+ return nullptr;
+}
+
+/**
+ * @descr Get the endnote type
+ */
+sal_uInt16 LwpDocument::GetEndnoteType()
+{
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
+ if (!pDivInfo)
+ return FN_DONTCARE;
+ OUString strClassName = pDivInfo->GetClassName();
+ if (strClassName == STR_DivisionEndnote)
+ return FN_DIVISION_SEPARATE;
+ if (strClassName == STR_DivisionGroupEndnote)
+ return FN_DIVISIONGROUP_SEPARATE;
+ if (strClassName == STR_DocumentEndnote)
+ return FN_DOCUMENT_SEPARATE;
+ return FN_DONTCARE;
+}
+/**
+ * @descr Get previous division
+ */
+LwpDocument* LwpDocument::GetPreviousDivision()
+{
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket().obj().get());
+ if (pDocSock)
+ {
+ return dynamic_cast<LwpDocument*>(pDocSock->GetPrevious().obj().get());
+ }
+ return nullptr;
+}
+/**
+ * @descr Get next division
+ */
+LwpDocument* LwpDocument::GetNextDivision()
+{
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket().obj().get());
+ if (pDocSock)
+ {
+ return dynamic_cast<LwpDocument*>(pDocSock->GetNext().obj().get());
+ }
+ return nullptr;
+}
+/**
+ * @descr Get parent division
+ */
+LwpDocument* LwpDocument::GetParentDivision()
+{
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket().obj().get());
+ if (pDocSock)
+ {
+ return dynamic_cast<LwpDocument*>(pDocSock->GetParent().obj().get());
+ }
+ return nullptr;
+}
+/**
+ * @descr Get previous division in group, copy from lwp source code
+ */
+LwpDocument* LwpDocument::GetPreviousInGroup()
+{
+ LwpDocument* pPrev = nullptr;
+
+ for (pPrev = GetPreviousDivision(); pPrev; pPrev = pPrev->GetPreviousDivision())
+ {
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pPrev->GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents())
+ return pPrev;
+ }
+ return nullptr;
+}
+/**
+ * @descr Get previous division in group, copy from lwp source code
+ */
+LwpDocument* LwpDocument::GetNextInGroup()
+{
+ LwpDocument* pNext = nullptr;
+
+ for (pNext = GetNextDivision(); pNext; pNext = pNext->GetNextDivision())
+ {
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents())
+ return pNext;
+ }
+
+ return nullptr;
+}
+/**
+ * @descr Get previous division which has contents, copy from lwp source code
+ */
+LwpDocument* LwpDocument::GetPreviousDivisionWithContents()
+{
+ if (m_bGettingPreviousDivisionWithContents)
+ throw std::runtime_error("recursion in page divisions");
+ m_bGettingPreviousDivisionWithContents = true;
+ LwpDocument* pRet = nullptr;
+
+ if (GetPreviousDivision())
+ pRet = GetPreviousDivision()->GetLastDivisionWithContents();
+ if (!pRet && GetParentDivision())
+ pRet = GetParentDivision()->GetPreviousDivisionWithContents();
+
+ m_bGettingPreviousDivisionWithContents = false;
+ return pRet;
+}
+
+/**
+* @descr Get last division which has contents, copy from lwp source code
+*/
+LwpDocument* LwpDocument::GetLastDivisionWithContents()
+{
+ if (m_bGettingGetLastDivisionWithContents)
+ throw std::runtime_error("recursion in page divisions");
+ m_bGettingGetLastDivisionWithContents = true;
+ LwpDocument* pRet = nullptr;
+
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents())
+ pRet = this;
+
+ if (!pRet)
+ {
+ LwpDocument* pDivision = GetLastDivision();
+
+ o3tl::sorted_vector<LwpDocument*> aSeen;
+ while (pDivision && pDivision != this)
+ {
+ bool bAlreadySeen = !aSeen.insert(pDivision).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ LwpDocument* pContentDivision = pDivision->GetLastDivisionWithContents();
+ if (pContentDivision)
+ {
+ pRet = pContentDivision;
+ break;
+ }
+ pDivision = pDivision->GetPreviousDivision();
+ }
+ }
+
+ m_bGettingGetLastDivisionWithContents = false;
+ return pRet;
+}
+/**
+ * @descr Get last division in group which has contents, copy from lwp source code
+ */
+LwpDocument* LwpDocument::GetLastInGroupWithContents()
+{
+ LwpDocument* pLast = nullptr;
+ LwpDocument* pNext = this;
+
+ while (pNext)
+ {
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pNext->GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents())
+ pLast = pNext;
+ pNext = pNext->GetNextInGroup();
+ }
+ if (pLast)
+ return pLast;
+ return nullptr;
+}
+/**
+ * @descr Get last division
+ */
+LwpDocument* LwpDocument::GetLastDivision()
+{
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket().obj().get());
+ if (pDocSock)
+ return dynamic_cast<LwpDocument*>(pDocSock->GetChildTail().obj().get());
+ return nullptr;
+}
+
+/**
+ * @descr Get first division
+ */
+LwpDocument* LwpDocument::GetFirstDivision()
+{
+ LwpDocSock* pDocSock = dynamic_cast<LwpDocSock*>(GetSocket().obj().get());
+ if (pDocSock)
+ return dynamic_cast<LwpDocument*>(pDocSock->GetChildHead().obj().get());
+ return nullptr;
+}
+
+/**
+ * @descr Get root document
+ */
+LwpDocument* LwpDocument::GetRootDocument()
+{
+ LwpDocument* pRoot = this;
+ o3tl::sorted_vector<LwpDocument*> aSeen;
+ while (pRoot)
+ {
+ bool bAlreadySeen = !aSeen.insert(pRoot).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if (!pRoot->IsChildDoc())
+ return pRoot;
+ pRoot = pRoot->GetParentDivision();
+ }
+ return nullptr;
+}
+/**
+ * @descr Get first division with contents that is not ole, copy from lwp-source code
+ */
+LwpDocument* LwpDocument::ImplGetFirstDivisionWithContentsThatIsNotOLE()
+{
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents() && !pDivInfo->IsOleDivision())
+ return this;
+
+ LwpDocument* pDivision = GetFirstDivision();
+ o3tl::sorted_vector<LwpDocument*> aSeen;
+ while (pDivision)
+ {
+ bool bAlreadySeen = !aSeen.insert(pDivision).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ LwpDocument* pContentDivision = pDivision->GetFirstDivisionWithContentsThatIsNotOLE();
+ if (pContentDivision)
+ return pContentDivision;
+ pDivision = pDivision->GetNextDivision();
+ }
+ return nullptr;
+}
+/**
+ * @descr Get last division that has endnote
+ */
+LwpDocument* LwpDocument::GetLastDivisionThatHasEndnote()
+{
+ LwpDocument* pRoot = GetRootDocument();
+ LwpDocument* pLastDoc = pRoot ? pRoot->GetLastDivisionWithContents() : nullptr;
+ o3tl::sorted_vector<LwpDocument*> aSeen;
+ while (pLastDoc)
+ {
+ bool bAlreadySeen = !aSeen.insert(pLastDoc).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if (pLastDoc->GetEnSuperTableLayout().is())
+ return pLastDoc;
+ pLastDoc = pLastDoc->GetPreviousDivisionWithContents();
+ }
+ return nullptr;
+}
+/**
+ * @descr Get endnote supertable layout, every division has only one endnote supertable layout.
+ */
+rtl::Reference<LwpVirtualLayout> LwpDocument::GetEnSuperTableLayout()
+{
+ LwpHeadLayout* pHeadLayout
+ = dynamic_cast<LwpHeadLayout*>(GetFoundry()->GetLayout().obj().get());
+ if (pHeadLayout)
+ {
+ return pHeadLayout->FindEnSuperTableLayout();
+ }
+ return rtl::Reference<LwpVirtualLayout>();
+}
+
+/**
+ * @descr Get the numbers of page before pEndDivision, copy from lwp source code
+ */
+bool LwpDocument::GetNumberOfPages(LwpDocument* pEndDivision, sal_uInt16& nCount)
+{
+ if (this == pEndDivision)
+ return true;
+
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(m_DivInfo.obj().get());
+ if (pDivInfo)
+ {
+ pDivInfo->GetNumberOfPages(nCount);
+ }
+
+ LwpDocument* pDivision = GetFirstDivision();
+ while (pDivision)
+ {
+ if (pDivision->GetNumberOfPages(pEndDivision, nCount))
+ return true;
+ pDivision = pDivision->GetNextDivision();
+ }
+ return false;
+}
+/**
+ * @descr Get the numbers of page before current division
+ */
+sal_uInt16 LwpDocument::GetNumberOfPagesBefore()
+{
+ sal_uInt16 nPageNumber = 0;
+ LwpDocument* pRoot = GetRootDocument();
+ if (pRoot)
+ pRoot->GetNumberOfPages(this, nPageNumber);
+ return nPageNumber;
+}
+
+/**
+ * @descr Parse the frame which anchor is to page before parse other contents,
+ * This method is called when the document is root document.
+ */
+void LwpDocument::ParseFrameInPage(IXFStream* pOutputStream)
+{
+ if (IsChildDoc())
+ return;
+
+ rtl::Reference<XFContentContainer> xXFContainer(new XFContentContainer);
+ XFConvertFrameInPage(xXFContainer.get());
+ xXFContainer->ToXml(pOutputStream);
+}
+
+/**
+ * @descr Parse the frame which anchor is to page in the entire document
+ */
+void LwpDocument::XFConvertFrameInPage(XFContentContainer* pCont)
+{
+ LwpDocument* pDivision = GetFirstDivision();
+
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
+ if (pDivInfo)
+ {
+ LwpPageLayout* pPageLayout
+ = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj().get());
+ if (pPageLayout)
+ {
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent().obj().get());
+ if (pStory)
+ pStory->XFConvertFrameInPage(pCont);
+ }
+ }
+ while (pDivision)
+ {
+ pDivision->XFConvertFrameInPage(pCont);
+ pDivision = pDivision->GetNextDivision();
+ }
+}
+/**
+ * @descr change click here to placeholder
+ */
+void LwpDocument::ChangeStyleName()
+{
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFTextStyle* pStyle = dynamic_cast<XFTextStyle*>(pXFStyleManager->FindStyle(u"ClickHere"));
+ if (pStyle)
+ {
+ pStyle->SetStyleName("Placeholder");
+ }
+}
+LwpDocSock::LwpDocSock(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFVList(objHdr, pStrm)
+{
+}
+
+/**
+ * @descr read VO_DOCSOCK from file
+ */
+void LwpDocSock::Read()
+{
+ LwpDLNFVList::Read();
+ m_Doc.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+/**
+ * @descr register styles in documents plugged
+ */
+void LwpDocSock::RegisterStyle()
+{
+ rtl::Reference<LwpObject> pDoc = GetNext().obj();
+ if (pDoc.is())
+ pDoc->DoRegisterStyle();
+
+ pDoc = GetChildHead().obj();
+ if (pDoc.is())
+ pDoc->DoRegisterStyle();
+}
+/**
+ * @descr parse contents of documents plugged
+ */
+void LwpDocSock::Parse(IXFStream* pOutputStream)
+{
+ rtl::Reference<LwpObject> pDoc = GetChildHead().obj();
+ if (pDoc.is())
+ pDoc->DoParse(pOutputStream);
+
+ pDoc = GetNext().obj();
+ if (pDoc.is())
+ pDoc->DoParse(pOutputStream);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx
new file mode 100644
index 000000000..155e5f855
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdoc.hxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * LwpDocument header file
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDOC_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDOC_HXX
+
+#include <config_lgpl.h>
+#include "lwplnopts.hxx"
+#include "lwpdlvlist.hxx"
+#include <lwpfoundry.hxx>
+
+class IXFStream;
+class LwpVirtualLayout;
+/**
+ * @brief Document object, represent document and division
+*/
+class LwpDocument : public LwpDLNFPVList
+{
+public:
+ LwpDocument(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpDocument() override;
+
+private:
+ std::unique_ptr<LwpFoundry> m_xOwnedFoundry;
+ bool m_bGettingFirstDivisionWithContentsThatIsNotOLE;
+ bool m_bGettingPreviousDivisionWithContents;
+ bool m_bGettingGetLastDivisionWithContents;
+
+ //Data members in file format
+ LwpObjectID m_DocSockID;
+ sal_uInt16 m_nFlags;
+ sal_uInt32 m_nPersistentFlags;
+ enum
+ {
+ DOC_PROTECTED = 0x00000004UL,
+ DOC_CHILDDOC = 0x00000800UL
+ };
+
+ std::unique_ptr<LwpLineNumberOptions> m_xLnOpts;
+
+ LwpObjectID m_DivOpts;
+ LwpObjectID m_FootnoteOpts;
+ LwpObjectID m_DocData;
+ LwpObjectID m_DivInfo;
+ LwpAtomHolder m_Epoch;
+
+ LwpObjectID m_WYSIWYGPageHints;
+ LwpObjectID m_VerDoc;
+ LwpObjectID m_STXInfo;
+
+protected:
+ void Read() override;
+ void ReadPlug();
+ void ParseDocContent(IXFStream* pOutputStream);
+ void RegisterTextStyles();
+ void RegisterLayoutStyles();
+
+ void RegisterStylesInPara();
+ void RegisterBulletStyles();
+ void RegisterGraphicsStyles();
+ void RegisterLinenumberStyles();
+ void RegisterFootnoteStyles();
+ void RegisterDefaultParaStyles();
+
+public:
+ void Parse(IXFStream* pOutputStream) override;
+ void RegisterStyle() override;
+
+ inline bool IsChildDoc() const;
+ inline bool GetHonorProtection() const;
+ inline LwpObjectID& GetDocData();
+ inline LwpObjectID& GetSocket();
+
+ inline LwpFoundry* GetFoundry();
+ inline LwpObjectID& GetDivInfoID();
+ inline LwpObjectID& GetPageHintsID();
+ inline LwpObjectID& GetFootnoteOpts();
+ inline LwpObjectID& GetVerDoc();
+ LwpObjectID* GetValidFootnoteOpts();
+
+ sal_uInt16 GetEndnoteType();
+ LwpDocument* GetPreviousDivision();
+ LwpDocument* GetNextDivision();
+ LwpDocument* GetParentDivision();
+ LwpDocument* GetPreviousInGroup();
+
+ LwpDocument* GetNextInGroup();
+ LwpDocument* GetPreviousDivisionWithContents();
+ LwpDocument* GetLastDivisionWithContents();
+ LwpDocument* GetLastInGroupWithContents();
+ LwpDocument* GetRootDocument();
+ LwpDocument* GetFirstDivisionWithContentsThatIsNotOLE()
+ {
+ if (m_bGettingFirstDivisionWithContentsThatIsNotOLE)
+ throw std::runtime_error("recursion in page divisions");
+ m_bGettingFirstDivisionWithContentsThatIsNotOLE = true;
+ LwpDocument* pRet = ImplGetFirstDivisionWithContentsThatIsNotOLE();
+ m_bGettingFirstDivisionWithContentsThatIsNotOLE = false;
+ return pRet;
+ }
+ LwpDocument* GetLastDivisionThatHasEndnote();
+
+ LwpDocument* GetLastDivision();
+ LwpDocument* GetFirstDivision();
+ rtl::Reference<LwpVirtualLayout> GetEnSuperTableLayout();
+ bool GetNumberOfPages(LwpDocument* pEndDivision, sal_uInt16& nCount);
+
+ sal_uInt16 GetNumberOfPagesBefore();
+ void ParseFrameInPage(IXFStream* pOutputStream);
+
+private:
+ LwpDocument* ImplGetFirstDivisionWithContentsThatIsNotOLE();
+ void XFConvertFrameInPage(XFContentContainer* pCont);
+ static void ChangeStyleName();
+ bool IsSkippedDivision();
+};
+
+inline bool LwpDocument::IsChildDoc() const { return (m_nPersistentFlags & DOC_CHILDDOC) != 0; }
+inline bool LwpDocument::GetHonorProtection() const
+{
+ return (m_nPersistentFlags & DOC_PROTECTED) != 0;
+}
+inline LwpObjectID& LwpDocument::GetSocket() { return m_DocSockID; }
+inline LwpFoundry* LwpDocument::GetFoundry() { return m_xOwnedFoundry.get(); }
+inline LwpObjectID& LwpDocument::GetDivInfoID() { return m_DivInfo; }
+inline LwpObjectID& LwpDocument::GetPageHintsID() { return m_WYSIWYGPageHints; }
+inline LwpObjectID& LwpDocument::GetFootnoteOpts() { return m_FootnoteOpts; }
+inline LwpObjectID& LwpDocument::GetDocData() { return m_DocData; }
+inline LwpObjectID& LwpDocument::GetVerDoc() { return m_VerDoc; }
+
+/**
+ * @brief DocumentSock object, divisions are embedded by document socket object
+*/
+class LwpDocSock : public LwpDLNFVList
+{
+public:
+ LwpDocSock(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+
+private:
+ LwpObjectID m_Doc;
+
+protected:
+ void Read() override;
+
+public:
+ void RegisterStyle() override;
+ void Parse(IXFStream* pOutputStream) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdocdata.cxx b/lotuswordpro/source/filter/lwpdocdata.cxx
new file mode 100644
index 000000000..55eecfcbb
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdocdata.cxx
@@ -0,0 +1,324 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <memory>
+#include <lwpdocdata.hxx>
+#include <xfilter/xfofficemeta.hxx>
+#include <localtime.hxx>
+#include <lwpfilehdr.hxx>
+#include <lwpglobalmgr.hxx>
+
+LwpDocData::LwpDocData(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ :LwpObject(objHdr, pStrm)//m_pEditorAttrList(0)
+{}
+
+LwpDocData::~LwpDocData()
+{
+}
+
+void LwpDocData::Read()
+{
+ //XFDateTime
+
+ //doc options
+ //cOptionFlag
+ m_DocOptions.nOptionFlag = m_pObjStrm->QuickReaduInt16();
+ //cEncrypt1Password
+ m_DocOptions.encrypt1password.Read(m_pObjStrm.get());
+ //cEncrypt2Password
+ m_DocOptions.encrypt2password.Read(m_pObjStrm.get());
+ //cCharacterSet
+ m_DocOptions.characterSet.Read(m_pObjStrm.get());
+ //cGrammerSet
+ m_DocOptions.grammerSet.Read(m_pObjStrm.get());
+ //cShowMarginMarks
+ m_DocOptions.nMarginMarks = m_pObjStrm->QuickReaduInt16();
+ //cMarginMarksLocation
+ m_DocOptions.nMarginMarksLocation = m_pObjStrm->QuickReaduInt16();
+ //cMarginMarksChar
+ m_DocOptions.nMarginMarksChar = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+
+ //doc info
+ //cDescription
+ m_DocInfo.description.Read(m_pObjStrm.get());
+ //cKeyWord
+ m_DocInfo.keywords.Read(m_pObjStrm.get());
+ //cCreatedBy
+ m_DocInfo.createdBy.Read(m_pObjStrm.get());
+ //cCreationTime
+ m_DocInfo.nCreationTime = m_pObjStrm->QuickReadInt32();
+ LtgLocalTime(m_DocInfo.nCreationTime,m_nCreationTime);
+ //cLastRevisionTime
+ m_DocInfo.nLastRevisionTime = m_pObjStrm->QuickReadInt32();
+ LtgLocalTime(m_DocInfo.nLastRevisionTime,m_nLastRevisionTime);
+ //cTotalEditTime
+ m_DocInfo.nTotalEditTime = m_pObjStrm->QuickReadInt32();
+
+ m_nTotalEditTime.tm_hour = m_DocInfo.nTotalEditTime / 60;
+ m_nTotalEditTime.tm_min = m_DocInfo.nTotalEditTime % 60;
+ m_nTotalEditTime.tm_sec = 0;
+ //cpVerDocInfo
+ m_DocInfo.cpVerDocInfo.ReadIndexed(m_pObjStrm.get());
+
+ //EditorList
+ m_DocInfo.nNumEditedBy = m_pObjStrm->QuickReaduInt16();
+ std::unique_ptr<LwpAtomHolder[]> pCDLNList(new LwpAtomHolder[m_DocInfo.nNumEditedBy]);
+ std::unique_ptr<LwpAtomHolder[]> pEditorList(new LwpAtomHolder[m_DocInfo.nNumEditedBy]);
+ sal_uInt16 i = 0;
+ for ( i = 0; i < m_DocInfo.nNumEditedBy; i++)
+ {
+ //CDLNList
+ pCDLNList[i].Read(m_pObjStrm.get()); //cName
+ m_pObjStrm->SkipExtra();
+ //CEditedBy
+ pEditorList[i].Read(m_pObjStrm.get()); //cName
+ m_pObjStrm->SkipExtra();
+ }
+
+ m_pObjStrm->SkipExtra();
+
+ pCDLNList.reset();
+ pEditorList.reset();
+
+ //doc control
+ //cGreeting
+ m_DocControl.cGreeting.Read(m_pObjStrm.get());
+ //cFlags
+ m_DocControl.nFlags = m_pObjStrm->QuickReaduInt16();
+
+ //cDocControlProtection
+ m_DocControl.nDocControlProtection = m_pObjStrm->QuickReaduInt16();
+ //Len
+ m_DocControl.nLen1 = m_pObjStrm->QuickReaduInt16();
+ //skip doc control password string
+ m_pObjStrm->SeekRel(m_DocControl.nLen1);
+
+ //cFileProtection
+ m_DocControl.nFileProtection = m_pObjStrm->QuickReaduInt16();
+ //Len
+ m_DocControl.nLen2 = m_pObjStrm->QuickReaduInt16();
+ //skip file password string
+ m_pObjStrm->SeekRel(m_DocControl.nLen2);
+
+ //cAutoVersioning
+ m_DocControl.nAutoVersioning = m_pObjStrm->QuickReaduInt16();
+ //cDocControlOnlyEditor
+ m_DocControl.cDocControlOnlyEditor.Read(m_pObjStrm.get());
+ //cEditorVerification
+ m_DocControl.nEditorVerification = m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->SkipExtra();
+
+ //editor list
+ //numeditors
+ sal_uInt16 numeditors = m_pObjStrm->QuickReaduInt16();
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+
+ for (i = 0;i<numeditors;i++)
+ {
+ std::unique_ptr<LwpEditorAttr> xEditorAttr(new LwpEditorAttr);
+ //cName
+ xEditorAttr->cName.Read(m_pObjStrm.get());
+ //cInitials
+ xEditorAttr->cInitials.Read(m_pObjStrm.get());
+ //cHiLite
+ xEditorAttr->cHiLiteColor.Read(m_pObjStrm.get());
+
+ //cID
+ xEditorAttr->nID = m_pObjStrm->QuickReaduInt16();
+
+ //cInsFontOver
+ //CFontAttributeOverride --cAttrBits
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrOverrideBits
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrOverrideBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrApplyBits
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrApplyBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrOverrideBits2
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrOverrideBits2 = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cAttrApplyBits2
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrApplyBits2 = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cCase
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cCase = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cUnder
+ xEditorAttr->cInsFontOver.cFontAttributeOverride.cUnder = m_pObjStrm->QuickReaduInt8();
+ m_pObjStrm->SkipExtra();
+ //CFontDescriptionOverrideBase--cOverrideBits
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cOverrideBits = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cApplyBits
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cApplyBits = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cPointSize
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cPointSize = m_pObjStrm->QuickReadInt32();
+ //CFontDescriptionOverrideBase--cOverstrike
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cOverstrike = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cTightness
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cTightness = m_pObjStrm->QuickReaduInt16();
+ //CFontDescriptionOverrideBase--cColor
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cColor.Read(m_pObjStrm.get());
+
+ //CFontDescriptionOverrideBase--cBackgroundColor
+ xEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cBackgroundColor.Read(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+ //cFaceName
+ xEditorAttr->cInsFontOver.cFaceName.Read(m_pObjStrm.get());
+ //cAltFaceName
+ xEditorAttr->cInsFontOver.cAltFaceName.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+
+ //cDelFontOver
+ //CFontAttributeOverride --cAttrBits
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrOverrideBits
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrOverrideBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrApplyBits
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrApplyBits = m_pObjStrm->QuickReaduInt16();
+ //CFontAttributeOverride --cAttrOverrideBits2
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrOverrideBits2 = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cAttrApplyBits2
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrApplyBits2 = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cCase
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cCase = m_pObjStrm->QuickReaduInt8();
+ //CFontAttributeOverride --cUnder
+ xEditorAttr->cDelFontOver.cFontAttributeOverride.cUnder = m_pObjStrm->QuickReaduInt8();
+ m_pObjStrm->SkipExtra();
+ //CFontDescriptionOverrideBase--cOverrideBits
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cOverrideBits = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cApplyBits
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cApplyBits = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cPointSize
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cPointSize = m_pObjStrm->QuickReadInt32();
+ //CFontDescriptionOverrideBase--cOverstrike
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cOverstrike = m_pObjStrm->QuickReaduInt8();
+ //CFontDescriptionOverrideBase--cTightness
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cTightness = m_pObjStrm->QuickReaduInt16();
+ //CFontDescriptionOverrideBase--cColor
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cColor.Read(m_pObjStrm.get());
+
+ //CFontDescriptionOverrideBase--cBackgroundColor
+ xEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cBackgroundColor.Read(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+ //cFaceName
+ xEditorAttr->cDelFontOver.cFaceName.Read(m_pObjStrm.get());
+ //cAltFaceName
+ xEditorAttr->cDelFontOver.cAltFaceName.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+
+ //cAbilities
+ xEditorAttr->nAbilities = m_pObjStrm->QuickReaduInt16();
+ //cLocks
+ xEditorAttr->nLocks = m_pObjStrm->QuickReaduInt16();
+ //cSuggestions
+ xEditorAttr->nSuggestions = m_pObjStrm->QuickReaduInt16();
+
+ //cDelTextAttr
+ //m_pEditorAttrList[i].cDelTextAttr.Read(m_pObjStrm);
+ if (m_pObjStrm->QuickReadBool())
+ {
+ xEditorAttr->cDelTextAttr.cOverride.cValues = m_pObjStrm->QuickReaduInt16();
+ xEditorAttr->cDelTextAttr.cOverride.cOverride = m_pObjStrm->QuickReaduInt16();
+ xEditorAttr->cDelTextAttr.cOverride.cApply = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+ xEditorAttr->cDelTextAttr.cHideLevels = m_pObjStrm->QuickReaduInt16();
+
+ if (LwpFileHeader::m_nFileRevision>= 0x000b)
+ {
+ xEditorAttr->cDelTextAttr.cBaselineOffset = m_pObjStrm->QuickReadInt32();
+ }
+ else
+ {
+ xEditorAttr->cDelTextAttr.cBaselineOffset = 0;
+ }
+ }
+ m_pObjStrm->SkipExtra();
+
+ m_pObjStrm->SkipExtra();
+
+ sal_uInt16 nID = xEditorAttr->nID;
+ pGlobal->SetEditorAttrMap(nID, xEditorAttr.release());
+ }
+}
+OUString LwpDocData::DateTimeToOUString(LtTm const & dt)
+{
+ OUString aResult = OUString::number(dt.tm_year) + "-" + OUString::number(dt.tm_mon) + "-" + OUString::number(dt.tm_mday) +
+ "T" + OUString::number(dt.tm_hour) + ":" + OUString::number(dt.tm_min) + ":" + OUString::number(dt.tm_sec) + ".0";
+
+ return aResult;
+}
+OUString LwpDocData::TimeToOUString(LtTm const & dt)
+{
+ //PT3H43M44S
+ OUString aResult = "PT" + OUString::number(dt.tm_hour) + "H" + OUString::number(dt.tm_min) + "M" + OUString::number(dt.tm_sec) + "S";
+
+ return aResult;
+}
+void LwpDocData::Parse(IXFStream *pOutputStream)
+{
+ //<!DOCTYPE office:document-meta PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
+ //<office:document-meta xmlns:office="http://openoffice.org/2000/office" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0">
+ //</office:document-meta>
+ XFOfficeMeta xfMeta;
+ xfMeta.SetCreator(m_DocInfo.createdBy.str());
+ xfMeta.SetDescription(m_DocInfo.description.str());
+ xfMeta.SetKeywords(m_DocInfo.keywords.str());
+ xfMeta.SetCreationTime(DateTimeToOUString(m_nCreationTime));
+ xfMeta.SetLastTime(DateTimeToOUString(m_nLastRevisionTime));
+ xfMeta.SetEditTime(TimeToOUString(m_nTotalEditTime));
+ xfMeta.ToXml(pOutputStream);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
new file mode 100644
index 000000000..5b704c1d5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -0,0 +1,1488 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * Implementation file of LwpDrawObjects and associated class like LwpDrawGroup, LwpDrawRectangle
+ * and so on.
+ */
+#include <osl/thread.h>
+#include <lwpglobalmgr.hxx>
+#include "lwpdrawobj.hxx"
+#include <lwptools.hxx>
+#include <tools/stream.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <xfilter/xfframe.hxx>
+
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfdrawstyle.hxx>
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xfimagestyle.hxx>
+#include <xfilter/xftextboxstyle.hxx>
+#include <xfilter/xfparagraph.hxx>
+#include <xfilter/xffont.hxx>
+
+#include <xfilter/xfdrawrect.hxx>
+#include <xfilter/xfdrawpath.hxx>
+#include <xfilter/xfdrawline.hxx>
+#include <xfilter/xfdrawpolygon.hxx>
+#include <xfilter/xfimage.hxx>
+
+#include "lwpcharsetmgr.hxx"
+#include "lwpsdwrect.hxx"
+
+/**
+ * @descr Constructor of class LwpDrawObj
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawObj::LwpDrawObj(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+ : m_eType(OT_UNDEFINED)
+ , m_pStream(pStream)
+ , m_pTransData(pTransData)
+{
+ ReadObjHeaderRecord();
+}
+
+/**
+ * @descr read the header record data of lwp-sdw-object
+ */
+void LwpDrawObj::ReadObjHeaderRecord()
+{
+ //flags
+ m_pStream->SeekRel(1);
+
+ //record Length
+ m_pStream->ReadUInt16( m_aObjHeader.nRecLen );
+
+ //boundrect
+ m_pStream->ReadInt16( m_aObjHeader.nLeft );
+ m_pStream->ReadInt16( m_aObjHeader.nTop );
+ m_pStream->ReadInt16( m_aObjHeader.nRight );
+ m_pStream->ReadInt16( m_aObjHeader.nBottom );
+
+ //nextObj, prevObj
+ m_pStream->SeekRel(4);
+}
+
+/**
+ * @descr read the style of closed lwp-sdw-object like: rectangle, ellipse and so on.
+ */
+void LwpDrawObj::ReadClosedObjStyle()
+{
+ if ((m_eType != OT_POLYGON) && (m_eType != OT_TEXTART))
+ {
+ m_pStream->SeekRel(8);
+ }
+
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.nLineWidth );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.nLineStyle );
+
+ // pen color
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aPenColor.nR );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aPenColor.nG );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aPenColor.nB );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aPenColor.unused );
+
+ // foreground color
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aForeColor.nR );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aForeColor.nG );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aForeColor.nB );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aForeColor.unused );
+
+ // background color
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aBackColor.nR );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aBackColor.nG );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aBackColor.nB );
+ m_pStream->ReadUChar( m_aClosedObjStyleRec.aBackColor.unused );
+
+ // fill style
+ m_pStream->ReadUInt16( m_aClosedObjStyleRec.nFillType );
+ m_pStream->ReadBytes(m_aClosedObjStyleRec.pFillPattern,
+ sizeof(m_aClosedObjStyleRec.pFillPattern));
+}
+
+/**
+ * @descr set fill style of drawing objects
+ * @param pStyle pointer of the drawing xfstyle.
+ */
+void LwpDrawObj::SetFillStyle(XFDrawStyle* pStyle)
+{
+ if (!pStyle)
+ {
+ assert(false);
+ return;
+ }
+
+ XFColor aForeColor(m_aClosedObjStyleRec.aForeColor.nR,
+ m_aClosedObjStyleRec.aForeColor.nG, m_aClosedObjStyleRec.aForeColor.nB);
+ XFColor aBackColor(m_aClosedObjStyleRec.aBackColor.nR,
+ m_aClosedObjStyleRec.aBackColor.nG, m_aClosedObjStyleRec.aBackColor.nB);
+
+ switch (m_aClosedObjStyleRec.nFillType)
+ {
+ default: //fall through!
+ case FT_TRANSPARENT:
+ {
+ // set fill style : none
+ break;
+ }
+ case FT_SOLID:
+ {
+ pStyle->SetAreaColor(aForeColor);
+ break;
+ }
+ case FT_HORZHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 0, 0.12, aForeColor);
+ break;
+ }
+ case FT_VERTHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 90, 0.12, aForeColor);
+ break;
+ }
+ case FT_FDIAGHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 135, 0.09, aForeColor);
+ break;
+ }
+ case FT_BDIAGHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 45, 0.09, aForeColor);
+ break;
+ }
+ case FT_CROSSHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineCrossed, 0, 0.12, aForeColor);
+ break;
+ }
+ case FT_DIAGCROSSHATCH:
+ {
+ pStyle->SetAreaColor(aBackColor);
+ pStyle->SetAreaLineStyle(enumXFAreaLineCrossed, 45, 0.095, aForeColor);
+ break;
+ }
+ }
+}
+
+/**
+ * @descr set line/border style of drawing objects.
+ * @param pStyle pointer of the drawing xfstyle.
+ * @param nWidth width of line/border.
+ * @param nLineStyle flag of line/border style: none, dot or solid.
+ * @param rColor color of line/border.
+ */
+void LwpDrawObj::SetLineStyle(XFDrawStyle* pStyle, sal_uInt8 nWidth, sal_uInt8 nLineStyle,
+ const SdwColor& rColor)
+{
+ if (!pStyle)
+ {
+ assert(false);
+ return;
+ }
+ if (nWidth == 0)
+ {
+ nLineStyle = LS_NULL;
+ }
+
+ if (nLineStyle == LS_NULL)
+ {
+ // set stroke:none
+ return;
+ }
+
+ if (nLineStyle == LS_DOT)
+ {
+ pStyle->SetLineDashStyle(enumXFLineDash, 0.05, 0.05, 0.05);
+ }
+
+ // line width
+ double fWidth = static_cast<double>(nWidth)/TWIPS_PER_CM;
+
+ // line color
+ XFColor aXFColor(rColor.nR, rColor.nG, rColor.nB);
+
+ pStyle->SetLineStyle(fWidth, aXFColor);
+}
+
+/**
+ * @descr set position of a drawing object in the frame.
+ * @param pObj pointer of the xf-drawing object
+ */
+void LwpDrawObj::SetPosition(XFFrame* pObj)
+{
+ double fOffsetX = 0.00, fOffsetY = 0.00;
+ double fScaleX = 1.00, fScaleY = 1.00;
+ if (m_pTransData)
+ {
+ fOffsetX = m_pTransData->fOffsetX;
+ fOffsetY = m_pTransData->fOffsetY;
+ fScaleX = m_pTransData->fScaleX;
+ fScaleY = m_pTransData->fScaleY;
+ }
+
+ pObj->SetPosition(static_cast<double>(m_aObjHeader.nLeft)/TWIPS_PER_CM * fScaleX+ fOffsetX,
+ static_cast<double>(m_aObjHeader.nTop)/TWIPS_PER_CM * fScaleY + fOffsetY,
+ static_cast<double>(m_aObjHeader.nRight-m_aObjHeader.nLeft)/TWIPS_PER_CM * fScaleX,
+ static_cast<double>(m_aObjHeader.nBottom-m_aObjHeader.nTop)/TWIPS_PER_CM * fScaleY);
+}
+
+/**
+ * @descr set arrowhead of a xf-drawing object. only opened drawing objects can be assigned arrowheads
+ * @param pOpenedObjStyle the xf-drawing object which will be set arrowhead.
+ * @param nArrowFlag arrowhead flags of the object.
+ */
+void LwpDrawObj::SetArrowHead(XFDrawStyle* pOpenedObjStyle, sal_uInt8 nArrowFlag, sal_uInt8 nLineWidth)
+{
+ // no arrowhead
+ if (!nArrowFlag)
+ {
+ return;
+ }
+
+ if (!pOpenedObjStyle)
+ {
+ assert(false);
+ return;
+ }
+
+ // arrowhead flag of an object's start side
+ sal_uInt8 nLeftArrow = nArrowFlag & 0x0F;
+
+ // arrowhead flag of an object's end side
+ sal_uInt8 nRightArrow = (nArrowFlag & 0xF0) >> 4;
+
+ double fWidth_inch = static_cast<double>(nLineWidth)/TWIPS_PER_CM;
+ double fArrowSize_inch = fWidth_inch + 0.08;
+ double fArrowSize = fArrowSize_inch * CM_PER_INCH;
+
+ if (nLeftArrow)
+ {
+ pOpenedObjStyle->SetArrowStart( GetArrowName(nLeftArrow), fArrowSize);
+ }
+ if (nRightArrow)
+ {
+ pOpenedObjStyle->SetArrowEnd( GetArrowName(nRightArrow), fArrowSize);
+ }
+
+}
+
+/**
+ * @descr get arrow style name according to the flag.
+ * @param nArrowStyle style of the arrowhead.
+ * @return nWhichSide style name of the arrowhead.
+ */
+OUString LwpDrawObj::GetArrowName(sal_uInt8 nArrowStyle)
+{
+ // style name of arrowhead
+ OUString aArrowName;
+
+ switch(nArrowStyle)
+ {
+ default:
+ case AH_ARROW_FULLARROW:
+ aArrowName = "Symmetric arrow";
+ break;
+ case AH_ARROW_HALFARROW:
+ aArrowName = "Arrow concave";
+ break;
+ case AH_ARROW_LINEARROW:
+ aArrowName = "arrow100";
+ break;
+ case AH_ARROW_INVFULLARROW:
+ aArrowName = "reverse arrow";
+ break;
+ case AH_ARROW_INVHALFARROW:
+ aArrowName = "reverse concave arrow";
+ break;
+ case AH_ARROW_INVLINEARROW:
+ aArrowName = "reverse line arrow";
+ break;
+ case AH_ARROW_TEE:
+ aArrowName = "Dimension lines";
+ break;
+ case AH_ARROW_SQUARE:
+ aArrowName = "Square";
+ break;
+ case AH_ARROW_CIRCLE:
+ aArrowName = "Circle";
+ break;
+ }
+
+ return aArrowName;
+}
+
+/**
+ * @descr template method of creating drawing object from Lwp-Model to XF-Model
+ * @return pointer of the drawing object of XF-Model.
+ */
+rtl::Reference<XFFrame> LwpDrawObj::CreateXFDrawObject()
+{
+ // read records
+ Read();
+
+ // register style
+ OUString aStyleName = RegisterStyle();
+
+ // create XF-Objects
+ rtl::Reference<XFFrame> xXFObj;
+ if (m_pTransData
+ && FABS(m_pTransData->fOffsetX - m_pTransData->fLeftMargin) < THRESHOLD
+ && FABS(m_pTransData->fOffsetY - m_pTransData->fTopMargin) < THRESHOLD
+ && FABS(m_pTransData->fScaleX - 1.0) < THRESHOLD
+ && FABS(m_pTransData->fScaleY - 1.0) < THRESHOLD)
+ {
+ xXFObj = CreateStandardDrawObj(aStyleName);
+ }
+ else
+ {
+ xXFObj = CreateDrawObj(aStyleName);
+ }
+
+ // set anchor type
+ if (xXFObj)
+ {
+ xXFObj->SetAnchorType(enumXFAnchorFrame);
+ }
+
+ return xXFObj;
+}
+
+/**
+ * @descr Constructor of class LwpDrawLine
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawLine::LwpDrawLine(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+: LwpDrawObj(pStream, pTransData)
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawLine
+ */
+void LwpDrawLine::Read()
+{
+ m_pStream->ReadInt16( m_aLineRec.nStartX );
+ m_pStream->ReadInt16( m_aLineRec.nStartY );
+ m_pStream->ReadInt16( m_aLineRec.nEndX );
+ m_pStream->ReadInt16( m_aLineRec.nEndY );
+ m_pStream->ReadUChar( m_aLineRec.nLineWidth );
+ m_pStream->ReadUChar( m_aLineRec.nLineEnd );
+ m_pStream->ReadUChar( m_aLineRec.nLineStyle );
+
+ m_pStream->ReadUChar( m_aLineRec.aPenColor.nR );
+ m_pStream->ReadUChar( m_aLineRec.aPenColor.nG );
+ m_pStream->ReadUChar( m_aLineRec.aPenColor.nB );
+ m_pStream->ReadUChar( m_aLineRec.aPenColor.unused );
+}
+
+OUString LwpDrawLine::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle( new XFDrawStyle() );
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aLineRec.nLineWidth, m_aLineRec.nLineStyle, m_aLineRec.aPenColor);
+
+ // set arrow head
+ SetArrowHead(pStyle.get(), m_aLineRec.nLineEnd, m_aLineRec.nLineWidth);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawLine::CreateDrawObj(const OUString& rStyleName )
+{
+ rtl::Reference<XFDrawPath> xLine(new XFDrawPath());
+ xLine->MoveTo(XFPoint(static_cast<double>(m_aLineRec.nStartX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aLineRec.nStartY)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ xLine->LineTo(XFPoint(static_cast<double>(m_aLineRec.nEndX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aLineRec.nEndY)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ SetPosition(xLine.get());
+
+ xLine->SetStyleName(rStyleName);
+
+ return xLine;
+}
+
+rtl::Reference<XFFrame> LwpDrawLine::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ rtl::Reference<XFDrawLine> xLine(new XFDrawLine());
+ xLine->SetStartPoint(static_cast<double>(m_aLineRec.nStartX)/TWIPS_PER_CM,static_cast<double>(m_aLineRec.nStartY)/TWIPS_PER_CM);
+ xLine->SetEndPoint(static_cast<double>(m_aLineRec.nEndX)/TWIPS_PER_CM,static_cast<double>(m_aLineRec.nEndY)/TWIPS_PER_CM);
+
+ xLine->SetStyleName(rStyleName);
+ return xLine;
+}
+
+/**
+ * @descr Constructor of class LwpDrawPolyLine
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawPolyLine::LwpDrawPolyLine(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+: LwpDrawObj(pStream, pTransData)
+{
+}
+LwpDrawPolyLine::~LwpDrawPolyLine()
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawPolyLine
+ */
+void LwpDrawPolyLine::Read()
+{
+ m_pStream->ReadUChar( m_aPolyLineRec.nLineWidth );
+ m_pStream->ReadUChar( m_aPolyLineRec.nLineEnd );
+ m_pStream->ReadUChar( m_aPolyLineRec.nLineStyle );
+ m_pStream->ReadUChar( m_aPolyLineRec.aPenColor.nR );
+ m_pStream->ReadUChar( m_aPolyLineRec.aPenColor.nG );
+ m_pStream->ReadUChar( m_aPolyLineRec.aPenColor.nB );
+ m_pStream->ReadUChar( m_aPolyLineRec.aPenColor.unused );
+ m_pStream->ReadUInt16( m_aPolyLineRec.nNumPoints );
+
+ if (!m_pStream->good() || m_aPolyLineRec.nNumPoints > m_pStream->remainingSize() / 4)
+ throw BadRead();
+
+ m_pVector.reset( new SdwPoint[m_aPolyLineRec.nNumPoints] );
+
+ for (sal_uInt16 nC = 0; nC < m_aPolyLineRec.nNumPoints; nC++)
+ {
+ m_pStream->ReadInt16( m_pVector[nC].x );
+ m_pStream->ReadInt16( m_pVector[nC].y );
+ }
+}
+
+OUString LwpDrawPolyLine::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aPolyLineRec.nLineWidth, m_aPolyLineRec.nLineStyle,
+ m_aPolyLineRec.aPenColor);
+
+ // set arrow head
+ SetArrowHead(pStyle.get(), m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawPolyLine::CreateDrawObj(const OUString& rStyleName )
+{
+ rtl::Reference<XFDrawPath> xPolyline(new XFDrawPath());
+ xPolyline->MoveTo(XFPoint(static_cast<double>(m_pVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_pVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ for (sal_uInt16 nC = 1; nC < m_aPolyLineRec.nNumPoints; nC++)
+ {
+ xPolyline->LineTo(XFPoint(static_cast<double>(m_pVector[nC].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_pVector[nC].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ }
+ SetPosition(xPolyline.get());
+
+ xPolyline->SetStyleName(rStyleName);
+
+ return xPolyline;
+}
+
+rtl::Reference<XFFrame> LwpDrawPolyLine::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ rtl::Reference<XFDrawPolyline> xPolyline(new XFDrawPolyline());
+ for (sal_uInt16 nC = 0; nC < m_aPolyLineRec.nNumPoints; nC++)
+ {
+ xPolyline->AddPoint(static_cast<double>(m_pVector[nC].x)/TWIPS_PER_CM,
+ static_cast<double>(m_pVector[nC].y)/TWIPS_PER_CM);
+ }
+
+ xPolyline->SetStyleName(rStyleName);
+
+ return xPolyline;
+}
+
+/**
+ * @descr Constructor of class LwpDrawPolygon
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawPolygon::LwpDrawPolygon(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+ : LwpDrawObj(pStream, pTransData)
+ , m_nNumPoints(0)
+{
+}
+
+LwpDrawPolygon::~LwpDrawPolygon()
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawPolygon
+ */
+void LwpDrawPolygon::Read()
+{
+ ReadClosedObjStyle();
+ m_pStream->ReadUInt16( m_nNumPoints );
+
+ if (!m_pStream->good() || m_nNumPoints > m_pStream->remainingSize() / 4)
+ throw BadRead();
+
+ m_pVector.reset( new SdwPoint[m_nNumPoints] );
+
+ for (sal_uInt16 nC = 0; nC < m_nNumPoints; nC++)
+ {
+ m_pStream->ReadInt16( m_pVector[nC].x );
+ m_pStream->ReadInt16( m_pVector[nC].y );
+ }
+}
+
+OUString LwpDrawPolygon::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+ m_aClosedObjStyleRec.aPenColor);
+
+ // set fill style
+ SetFillStyle(pStyle.get());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawPolygon::CreateDrawObj(const OUString& rStyleName)
+{
+ rtl::Reference<XFDrawPath> xPolygon(new XFDrawPath());
+ xPolygon->MoveTo(XFPoint(static_cast<double>(m_pVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_pVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ for (sal_uInt16 nC = 1; nC < m_nNumPoints; nC++)
+ {
+ xPolygon->LineTo(XFPoint(static_cast<double>(m_pVector[nC].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_pVector[nC].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ }
+ xPolygon->ClosePath();
+ SetPosition(xPolygon.get());
+ xPolygon->SetStyleName(rStyleName);
+
+ return xPolygon;
+}
+
+rtl::Reference<XFFrame> LwpDrawPolygon::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ rtl::Reference<XFDrawPolygon> xPolygon(new XFDrawPolygon());
+ for (sal_uInt16 nC = 0; nC < m_nNumPoints; nC++)
+ {
+ xPolygon->AddPoint(static_cast<double>(m_pVector[nC].x)/TWIPS_PER_CM,
+ static_cast<double>(m_pVector[nC].y)/TWIPS_PER_CM);
+ }
+
+ xPolygon->SetStyleName(rStyleName);
+
+ return xPolygon;
+}
+
+/**
+ * @descr Constructor of class LwpDrawRectangle
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawRectangle::LwpDrawRectangle(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+ : LwpDrawObj(pStream, pTransData)
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawRectangle
+ */
+void LwpDrawRectangle::Read()
+{
+ ReadClosedObjStyle();
+
+ sal_uInt8 nPointsCount;
+ if (m_eType == OT_RNDRECT)
+ {
+ nPointsCount = 16;
+ m_pStream->SeekRel(4); // corner points
+ }
+ else
+ {
+ nPointsCount = 4;
+ }
+
+ for (sal_uInt8 nC = 0; nC < nPointsCount; nC++)
+ {
+ m_pStream->ReadInt16( m_aVector[nC].x );
+ m_pStream->ReadInt16( m_aVector[nC].y );
+ }
+}
+
+OUString LwpDrawRectangle::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+ m_aClosedObjStyleRec.aPenColor);
+
+ // set fill style
+ SetFillStyle(pStyle.get());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawRectangle::CreateDrawObj(const OUString& rStyleName)
+{
+ if (m_eType == OT_RNDRECT)
+ {
+ return CreateRoundedRect(rStyleName);
+ }
+ else
+ {
+ rtl::Reference<XFDrawPath> xRect(new XFDrawPath());
+ xRect->MoveTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ for (sal_uInt8 nC = 1; nC < 4; nC++)
+ {
+ xRect->LineTo(XFPoint(static_cast<double>(m_aVector[nC].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nC].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ }
+ xRect->LineTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ xRect->ClosePath();
+ SetPosition(xRect.get());
+
+ xRect->SetStyleName(rStyleName);
+
+ return xRect;
+ }
+}
+
+XFFrame* LwpDrawRectangle::CreateRoundedRect(const OUString& rStyleName)
+{
+ XFDrawPath* pRoundedRect = new XFDrawPath();
+ pRoundedRect->MoveTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+
+ sal_uInt8 nPtIndex = 1;
+ for (sal_uInt8 nC = 0; nC < 7; nC++)
+ {
+ if (nC%2 == 0)
+ {
+ XFPoint aCtrl1(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+ XFPoint aCtrl2(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+ XFPoint aDest(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+
+ pRoundedRect->CurveTo(aDest, aCtrl1, aCtrl2);
+ }
+ else
+ {
+ XFPoint aDest(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+
+ pRoundedRect->LineTo(aDest);
+ }
+ }
+
+ pRoundedRect->LineTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ pRoundedRect->ClosePath();
+ SetPosition(pRoundedRect);
+
+ pRoundedRect->SetStyleName(rStyleName);
+
+ return pRoundedRect;
+}
+
+rtl::Reference<XFFrame> LwpDrawRectangle::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ if (m_eType == OT_RNDRECT)
+ {
+ return CreateRoundedRect(rStyleName);
+ }
+ else
+ {
+ rtl::Reference<XFDrawRect> xRect(new XFDrawRect());
+ double fStartX, fStartY, fWidth, fHeight;
+ double fRotAngle = 0.0;
+ SdwRectangle aSdwRect;
+ tools::Rectangle aOriginalRect;
+ Point aPt0, aPt1, aPt2, aPt3;
+
+ aPt0.setX(m_aVector[0].x); aPt0.setY(m_aVector[0].y);
+ aPt1.setX(m_aVector[1].x); aPt1.setY(m_aVector[1].y);
+ aPt2.setX(m_aVector[2].x); aPt2.setY(m_aVector[2].y);
+ aPt3.setX(m_aVector[3].x); aPt3.setY(m_aVector[3].y);
+
+ aSdwRect = SdwRectangle(aPt0, aPt1, aPt2, aPt3);
+ if (aSdwRect.IsRectRotated())
+ {
+ aOriginalRect = aSdwRect.GetOriginalRect();
+ fRotAngle = aSdwRect.GetRotationAngle();
+ }
+ else
+ {
+ aOriginalRect = tools::Rectangle(aPt0, aPt2);
+ }
+
+ fStartX = aOriginalRect.Left();
+ fStartY = aOriginalRect.Top();
+ fWidth = aOriginalRect.GetWidth();
+ fHeight = aOriginalRect.GetHeight();
+
+ xRect->SetStartPoint(XFPoint(fStartX/TWIPS_PER_CM + m_pTransData->fOffsetX,
+ fStartY/TWIPS_PER_CM + m_pTransData->fOffsetY));
+ xRect->SetSize(fWidth/TWIPS_PER_CM, fHeight/TWIPS_PER_CM);
+
+ if (aSdwRect.IsRectRotated())
+ {
+ xRect->SetRotate( basegfx::rad2deg(fRotAngle) );// aXFCenter);
+ }
+
+ xRect->SetStyleName(rStyleName);
+
+ return xRect;
+ }
+}
+
+/**
+ * @descr Constructor of class LwpDrawEllipse
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawEllipse::LwpDrawEllipse(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+: LwpDrawObj(pStream, pTransData)
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawEllipse
+ */
+void LwpDrawEllipse::Read()
+{
+ ReadClosedObjStyle();
+
+ for (SdwPoint & nC : m_aVector)
+ {
+ m_pStream->ReadInt16( nC.x );
+ m_pStream->ReadInt16( nC.y );
+ }
+}
+
+OUString LwpDrawEllipse::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+ m_aClosedObjStyleRec.aPenColor);
+
+ // set fill style
+ SetFillStyle(pStyle.get());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawEllipse::CreateDrawObj(const OUString& rStyleName )
+{
+ rtl::Reference<XFDrawPath> xEllipse(new XFDrawPath());
+ xEllipse->MoveTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ sal_uInt8 nPtIndex = 1;
+ for (sal_uInt8 nC = 0; nC < 4; nC++)
+ {
+ XFPoint aCtrl1(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+ XFPoint aCtrl2(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+ XFPoint aDest(static_cast<double>(m_aVector[nPtIndex].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[nPtIndex].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ nPtIndex++;
+
+ xEllipse->CurveTo(aDest, aCtrl1, aCtrl2);
+ }
+ xEllipse->ClosePath();
+ SetPosition(xEllipse.get());
+
+ xEllipse->SetStyleName(rStyleName);
+
+ return xEllipse;
+}
+
+rtl::Reference<XFFrame> LwpDrawEllipse::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ return CreateDrawObj(rStyleName);
+}
+
+/**
+ * @descr Constructor of class LwpDrawArc
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawArc::LwpDrawArc(SvStream * pStream, DrawingOffsetAndScale* pTransData)
+: LwpDrawObj(pStream, pTransData)
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawArc
+ */
+void LwpDrawArc::Read()
+{
+ m_pStream->SeekRel(16);// arcRect, startPt, endPt
+
+ m_pStream->ReadUChar( m_aArcRec.nLineWidth );
+ m_pStream->ReadUChar( m_aArcRec.nLineStyle );
+ m_pStream->ReadUChar( m_aArcRec.aPenColor.nR );
+ m_pStream->ReadUChar( m_aArcRec.aPenColor.nG );
+ m_pStream->ReadUChar( m_aArcRec.aPenColor.nB );
+ m_pStream->ReadUChar( m_aArcRec.aPenColor.unused );
+ m_pStream->ReadUChar( m_aArcRec.nLineEnd );
+
+ for (SdwPoint & nC : m_aVector)
+ {
+ m_pStream->ReadInt16( nC.x );
+ m_pStream->ReadInt16( nC.y );
+ }
+}
+
+OUString LwpDrawArc::RegisterStyle()
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ // set line style
+ SetLineStyle(pStyle.get(), m_aArcRec.nLineWidth, m_aArcRec.nLineStyle,
+ m_aArcRec.aPenColor);
+
+ // set arrow head
+ SetArrowHead(pStyle.get(), m_aArcRec.nLineEnd, m_aArcRec.nLineWidth);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawArc::CreateDrawObj(const OUString& rStyleName )
+{
+ rtl::Reference<XFDrawPath> xArc(new XFDrawPath());
+ xArc->MoveTo(XFPoint(static_cast<double>(m_aVector[0].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[0].y)/TWIPS_PER_CM * m_pTransData->fScaleY));
+ XFPoint aDest(static_cast<double>(m_aVector[3].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[3].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ XFPoint aCtl1(static_cast<double>(m_aVector[1].x)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[1].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ XFPoint aCtl2(static_cast<double>(m_aVector[2].x)/TWIPS_PER_CM* m_pTransData->fScaleX,
+ static_cast<double>(m_aVector[2].y)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ xArc->CurveTo(aDest, aCtl1, aCtl2);
+
+ SetPosition(xArc.get());
+
+ xArc->SetStyleName(rStyleName);
+
+ return xArc;
+}
+
+rtl::Reference<XFFrame> LwpDrawArc::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ return CreateDrawObj(rStyleName);
+}
+
+/**
+ * @descr Constructor of class LwpDrawTextBox
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawTextBox::LwpDrawTextBox(SvStream* pStream) : LwpDrawObj(pStream)
+{
+}
+
+LwpDrawTextBox::~LwpDrawTextBox()
+{
+ if (m_aTextRec.pTextString)
+ {
+ delete [] m_aTextRec.pTextString;
+ m_aTextRec.pTextString = nullptr;
+ }
+}
+
+void LwpDrawTextBox::SetFontStyle(rtl::Reference<XFFont> const & pFont, SdwTextBoxRecord const * pRec)
+{
+ // color
+ XFColor aXFColor(pRec->aTextColor.nR, pRec->aTextColor.nG,
+ pRec->aTextColor.nB);
+ pFont->SetColor(aXFColor);
+ //size
+ pFont->SetFontSize(pRec->nTextSize/20);
+ // bold
+ pFont->SetBold((pRec->nTextAttrs & TA_BOLD) != 0);
+ // italic
+ pFont->SetItalic((pRec->nTextAttrs & TA_ITALIC) != 0);
+ // strike-through
+ if (pRec->nTextAttrs & TA_STRIKETHRU)
+ {
+ pFont->SetCrossout(enumXFCrossoutSignel);
+ }
+ else
+ {
+ pFont->SetCrossout(enumXFCrossoutNone);
+ }
+ // underline
+ if (pRec->nTextAttrs & TA_UNDERLINE)
+ {
+ pFont->SetUnderline(enumXFUnderlineSingle);
+ }
+ else if (pRec->nTextAttrs & TA_WORDUNDERLINE)
+ {
+ pFont->SetUnderline(enumXFUnderlineSingle, true);
+ }
+ else if (pRec->nTextAttrs & TA_DOUBLEUNDER)
+ {
+ pFont->SetUnderline(enumXFUnderlineDouble);
+ }
+ else
+ {
+ pFont->SetUnderline(enumXFUnderlineNone);
+ }
+ // small-caps
+ if (pRec->nTextAttrs & TA_SMALLCAPS)
+ {
+ pFont->SetTransform(enumXFTransformSmallCaps);
+ }
+}
+
+/**
+ * @descr reading function of class LwpDrawTextBox
+ */
+void LwpDrawTextBox::Read()
+{
+ m_pStream->ReadInt16( m_aVector.x );
+ m_pStream->ReadInt16( m_aVector.y );
+ m_pStream->ReadInt16( m_aTextRec.nTextWidth );
+
+ if (m_aTextRec.nTextWidth == 0)
+ m_aTextRec.nTextWidth = 1;
+
+ m_pStream->ReadInt16( m_aTextRec.nTextHeight );
+ m_pStream->ReadBytes(m_aTextRec.tmpTextFaceName, DRAW_FACESIZE);
+ m_aTextRec.tmpTextFaceName[DRAW_FACESIZE - 1] = 0;
+ m_pStream->SeekRel(1);// PitchAndFamily
+
+ m_pStream->ReadInt16( m_aTextRec.nTextSize );
+
+ if (m_aTextRec.nTextSize < 0)
+ m_aTextRec.nTextSize = -m_aTextRec.nTextSize;
+
+ //color
+ m_pStream->ReadUChar( m_aTextRec.aTextColor.nR );
+ m_pStream->ReadUChar( m_aTextRec.aTextColor.nG );
+ m_pStream->ReadUChar( m_aTextRec.aTextColor.nB );
+ m_pStream->ReadUChar( m_aTextRec.aTextColor.unused );
+
+ m_pStream->ReadUInt16( m_aTextRec.nTextAttrs );
+ m_pStream->ReadUInt16( m_aTextRec.nTextCharacterSet );
+ m_pStream->ReadInt16( m_aTextRec.nTextRotation );
+ m_pStream->ReadInt16( m_aTextRec.nTextExtraSpacing );
+
+ if (!m_pStream->good())
+ throw BadRead();
+
+ // some draw files in version 1.2 have an extra byte following '\0'.
+ // can't rely on that, so read in the whole string into memory.
+
+ // the 71 is the fixed length before text content in textbox record
+ sal_Int16 TextLength = m_aObjHeader.nRecLen - 71;
+ if (TextLength < 0)
+ throw BadRead();
+ m_aTextRec.pTextString = new sal_uInt8[TextLength];
+ if (m_pStream->ReadBytes(m_aTextRec.pTextString, TextLength) != o3tl::make_unsigned(TextLength))
+ throw BadRead();
+}
+
+OUString LwpDrawTextBox::RegisterStyle()
+{
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+
+ // font style
+ // the pFont need to be deleted myself?
+ rtl::Reference<XFFont> pFont = new XFFont();
+
+ OUString aFontName(reinterpret_cast<char*>(m_aTextRec.tmpTextFaceName),
+ strlen(reinterpret_cast<char*>(m_aTextRec.tmpTextFaceName)), RTL_TEXTENCODING_MS_1252);
+ pFont->SetFontName(aFontName);
+
+ SetFontStyle(pFont, &m_aTextRec);
+
+ pStyle->SetFont(pFont);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName )
+{
+ rtl::Reference<XFFrame> xTextBox(new XFFrame(true));
+
+ sal_Int16 TextLength = m_aObjHeader.nRecLen - 71;
+ rtl_TextEncoding aEncoding;
+ if (!m_aTextRec.nTextCharacterSet)
+ {
+ aEncoding = osl_getThreadTextEncoding();
+ }
+ else
+ {
+ // temporary code, need to create Encoding from the value of nTextCharacterSet
+ aEncoding = LwpCharSetMgr::GetTextCharEncoding();
+ }
+
+ if (TextLength < 2)
+ throw BadRead();
+
+ XFParagraph* pXFPara = new XFParagraph();
+ pXFPara->Add(OUString(reinterpret_cast<char*>(m_aTextRec.pTextString), (TextLength-2), aEncoding));
+ pXFPara->SetStyleName(rStyleName);
+
+ xTextBox->Add(pXFPara);
+ SetPosition(xTextBox.get());
+
+ std::unique_ptr<XFTextBoxStyle> pBoxStyle(new XFTextBoxStyle());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ OUString sName = pXFStyleManager->AddStyle(std::move(pBoxStyle)).m_pStyle->GetStyleName();
+ xTextBox->SetStyleName(sName);
+
+ return xTextBox;
+}
+
+rtl::Reference<XFFrame> LwpDrawTextBox::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ return CreateDrawObj(rStyleName);
+}
+
+/**
+ * @descr Constructor of class LwpDrawTextBox
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawTextArt::LwpDrawTextArt(SvStream* pStream, DrawingOffsetAndScale* pTransData)
+: LwpDrawObj(pStream, pTransData)
+{
+}
+
+LwpDrawTextArt::~LwpDrawTextArt()
+{
+ m_aTextArtRec.aPath[0].aPts.clear();
+ m_aTextArtRec.aPath[1].aPts.clear();
+ if (m_aTextArtRec.pTextString)
+ {
+ delete [] m_aTextArtRec.pTextString;
+ m_aTextArtRec.pTextString = nullptr;
+ }
+
+}
+
+void LwpDrawTextArt::CreateFWPath(XFDrawPath* pPath)
+{
+ sal_Int16 nX, nY;
+ nX = (m_aTextArtRec.aPath[0].aPts[0].x + m_aTextArtRec.aPath[1].aPts[0].x) / 2;
+ nY = (m_aTextArtRec.aPath[0].aPts[0].y + m_aTextArtRec.aPath[1].aPts[0].y) / 2;
+ XFPoint aStart(static_cast<double>(nX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(nY)/TWIPS_PER_CM * m_pTransData->fScaleY);
+ pPath->MoveTo(aStart);
+
+ sal_uInt8 nPtIndex = 1;
+ for (sal_uInt16 nC = 1; nC <= m_aTextArtRec.aPath[0].n; nC++)
+ {
+ nX = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).x + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).x) / 2;
+ nY = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).y + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).y) / 2;
+ XFPoint aCtrl1(static_cast<double>(nX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(nY)/TWIPS_PER_CM * m_pTransData->fScaleY);
+
+ nPtIndex++;
+ nX = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).x + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).x) / 2;
+ nY = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).y + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).y) / 2;
+ XFPoint aCtrl2(static_cast<double>(nX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(nY)/TWIPS_PER_CM * m_pTransData->fScaleY);
+
+ nPtIndex++;
+ nX = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).x + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).x) / 2;
+ nY = (m_aTextArtRec.aPath[0].aPts.at(nPtIndex).y + m_aTextArtRec.aPath[1].aPts.at(nPtIndex).y) / 2;
+ XFPoint aDest(static_cast<double>(nX)/TWIPS_PER_CM * m_pTransData->fScaleX,
+ static_cast<double>(nY)/TWIPS_PER_CM * m_pTransData->fScaleY);
+
+ pPath->CurveTo(aDest, aCtrl1, aCtrl2);
+ }
+}
+
+void LwpDrawTextArt::Read()
+{
+ for (SdwPoint & nC : m_aVector)
+ {
+ m_pStream->ReadInt16( nC.x );
+ m_pStream->ReadInt16( nC.y );
+ }
+
+ ReadClosedObjStyle();
+ m_aTextArtRec.aTextColor = m_aClosedObjStyleRec.aForeColor;
+
+ m_pStream->ReadUChar( m_aTextArtRec.nIndex );
+ m_pStream->ReadInt16( m_aTextArtRec.nRotation );
+
+ sal_uInt16 nPointNumber;
+ m_pStream->ReadUInt16( nPointNumber );
+
+ size_t nPoints = nPointNumber*3+1;
+ if (!m_pStream->good() || nPoints > m_pStream->remainingSize() / 4)
+ throw BadRead();
+
+ m_aTextArtRec.aPath[0].n = nPointNumber;
+ m_aTextArtRec.aPath[0].aPts.resize(nPoints);
+ for (size_t nPt = 0; nPt < nPoints; ++nPt)
+ {
+ sal_Int16 nX, nY;
+ m_pStream->ReadInt16( nX );
+ m_pStream->ReadInt16( nY );
+ m_aTextArtRec.aPath[0].aPts[nPt].x = nX;
+ m_aTextArtRec.aPath[0].aPts[nPt].y = nY;
+ }
+
+ m_pStream->ReadUInt16( nPointNumber );
+
+ nPoints = nPointNumber*3+1;
+ if (!m_pStream->good() || nPoints > m_pStream->remainingSize() / 4)
+ throw BadRead();
+
+ m_aTextArtRec.aPath[1].n = nPointNumber;
+ m_aTextArtRec.aPath[1].aPts.resize(nPoints);
+ for (size_t nPt = 0; nPt < nPoints; ++nPt)
+ {
+ sal_Int16 nX, nY;
+ m_pStream->ReadInt16( nX );
+ m_pStream->ReadInt16( nY );
+ m_aTextArtRec.aPath[1].aPts[nPt].x = nX;
+ m_aTextArtRec.aPath[1].aPts[nPt].y = nY;
+ }
+
+ m_pStream->SeekRel(1);
+
+ m_pStream->ReadBytes(m_aTextArtRec.tmpTextFaceName, DRAW_FACESIZE);
+ m_aTextArtRec.tmpTextFaceName[DRAW_FACESIZE - 1] = 0;
+ m_pStream->SeekRel(1);// PitchAndFamily
+
+ m_pStream->ReadInt16( m_aTextArtRec.nTextSize );
+
+ if (m_aTextArtRec.nTextSize < 0)
+ m_aTextArtRec.nTextSize = -m_aTextArtRec.nTextSize;
+
+ m_pStream->ReadUInt16( m_aTextArtRec.nTextAttrs );
+ m_pStream->ReadUInt16( m_aTextArtRec.nTextCharacterSet );
+ m_aTextArtRec.nTextRotation = 0;
+ m_pStream->ReadInt16( m_aTextArtRec.nTextExtraSpacing );
+
+ const sal_uInt16 nTextArtFixedLength = 105;
+ m_aTextArtRec.nTextLen = m_aObjHeader.nRecLen - nTextArtFixedLength
+ - (m_aTextArtRec.aPath[0].n*3 + 1)*4
+ - (m_aTextArtRec.aPath[1].n*3 + 1)*4;
+
+
+ if (!m_pStream->good())
+ throw BadRead();
+ if (m_aTextArtRec.nTextLen > m_pStream->remainingSize())
+ throw BadRead();
+ if (m_aTextArtRec.nTextLen < 1)
+ throw BadRead();
+
+ m_aTextArtRec.pTextString = new sal_uInt8 [m_aTextArtRec.nTextLen];
+ m_pStream->ReadBytes(m_aTextArtRec.pTextString, m_aTextArtRec.nTextLen);
+ m_aTextArtRec.pTextString[m_aTextArtRec.nTextLen-1] = 0;
+
+}
+
+OUString LwpDrawTextArt::RegisterStyle()
+{
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+
+ // font style
+ // the pFont need to be deleted myself?
+ rtl::Reference<XFFont> pFont = new XFFont();
+
+ OUString aFontName(reinterpret_cast<char*>(m_aTextArtRec.tmpTextFaceName),
+ strlen(reinterpret_cast<char*>(m_aTextArtRec.tmpTextFaceName)), RTL_TEXTENCODING_MS_1252);
+ pFont->SetFontName(aFontName);
+
+ LwpDrawTextBox::SetFontStyle(pFont, &m_aTextArtRec);
+
+ pStyle->SetFont(pFont);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName)
+{
+ std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
+
+ rtl::Reference<XFFrame> xRetObj(new XFDrawPath());
+ XFDrawPath* pFWPath = static_cast<XFDrawPath*>(xRetObj.get());
+ CreateFWPath(pFWPath);
+ pStyle->SetFontWorkStyle(enumXFFWSlantY, enumXFFWAdjustAutosize);
+
+ SetPosition(xRetObj.get());
+
+ rtl_TextEncoding aEncoding;
+ if (!m_aTextArtRec.nTextCharacterSet)
+ {
+ aEncoding = osl_getThreadTextEncoding();
+ }
+ else
+ {
+ // temporary code, need to create Encoding from the value of nTextCharacterSet
+ aEncoding = LwpCharSetMgr::GetTextCharEncoding();
+ }
+
+ XFParagraph* pXFPara = new XFParagraph();
+ pXFPara->Add(OUString(reinterpret_cast<char*>(m_aTextArtRec.pTextString), (m_aTextArtRec.nTextLen-1), aEncoding));
+ pXFPara->SetStyleName(rStyleName);
+ xRetObj->Add(pXFPara);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ xRetObj->SetStyleName(pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName());
+
+ return xRetObj;
+}
+
+rtl::Reference<XFFrame> LwpDrawTextArt::CreateStandardDrawObj(const OUString& rStyleName )
+{
+ return CreateDrawObj(rStyleName);
+}
+
+/**
+ * @descr Constructor of class LwpDrawMetafile
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawMetafile::LwpDrawMetafile(SvStream* pStream) : LwpDrawObj(pStream)
+{
+}
+
+/**
+ * @descr reading function of class LwpDrawMetafile
+ */
+void LwpDrawMetafile::Read()
+{
+ m_pStream->SeekRel(m_aObjHeader.nRecLen -16);
+}
+
+/**
+ * @descr Constructor of class LwpDrawBitmap
+ * @param pStream The memory stream which contains the lwp-sdw draw objects
+ */
+LwpDrawBitmap::LwpDrawBitmap(SvStream* pStream) : LwpDrawObj(pStream)
+{
+}
+
+LwpDrawBitmap::~LwpDrawBitmap()
+{
+}
+
+static bool IsValid(const BmpInfoHeader2& rHeader)
+{
+ if (rHeader.nPlanes != 1)
+ return false;
+
+ if (rHeader.nBitCount != 0 && rHeader.nBitCount != 1 &&
+ rHeader.nBitCount != 4 && rHeader.nBitCount != 8 &&
+ rHeader.nBitCount != 16 && rHeader.nBitCount != 24 &&
+ rHeader.nBitCount != 32)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @descr reading function of class LwpDrawBitmap
+ */
+void LwpDrawBitmap::Read()
+{
+ m_pStream->ReadUInt16( m_aBmpRec.nTranslation );
+ m_pStream->ReadUInt16( m_aBmpRec.nRotation );
+
+ // 20 == length of draw-specific fields.
+ if (m_aObjHeader.nRecLen < 20)
+ throw BadRead();
+
+ sal_uInt64 nBmpPos = m_pStream->Tell();
+ sal_uInt64 nBmpLen =
+ std::min<sal_uInt64>(m_aObjHeader.nRecLen - 20, m_pStream->remainingSize());
+
+ BmpInfoHeader2 aInfoHeader2;
+ m_pStream->ReadUInt32( aInfoHeader2.nHeaderLen );
+
+ if (!m_pStream->good() || nBmpLen < aInfoHeader2.nHeaderLen)
+ throw BadRead();
+
+ sal_uInt32 N;
+ sal_uInt32 rgbTableSize;
+
+ if (aInfoHeader2.nHeaderLen == sizeof(BmpInfoHeader))
+ {
+ sal_uInt16 nTmp;
+
+ m_pStream->ReadUInt16( nTmp );
+ aInfoHeader2.nWidth = nTmp;
+ m_pStream->ReadUInt16( nTmp );
+ aInfoHeader2.nHeight = nTmp;
+ m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
+ m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
+
+ if (!m_pStream->good() || !IsValid(aInfoHeader2))
+ throw BadRead();
+
+ N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
+ if (N >= 16)
+ {
+ rgbTableSize = 0;
+ }
+ else
+ {
+ rgbTableSize = 3 * (1 << N);
+ }
+ }
+ else if (aInfoHeader2.nHeaderLen >= sizeof(BmpInfoHeader2))
+ {
+ m_pStream->ReadUInt32( aInfoHeader2.nWidth );
+ m_pStream->ReadUInt32( aInfoHeader2.nHeight );
+ m_pStream->ReadUInt16( aInfoHeader2.nPlanes );
+ m_pStream->ReadUInt16( aInfoHeader2.nBitCount );
+
+ if (!m_pStream->good() || !IsValid(aInfoHeader2))
+ throw BadRead();
+
+ N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
+ if (N >= 16)
+ {
+ rgbTableSize = 0;
+ }
+ else
+ {
+ rgbTableSize = 4 * (1 << N);
+ }
+ }
+ else
+ {
+ throw BadRead();
+ }
+
+ m_aBmpRec.nFileSize = static_cast<sal_uInt32>(nBmpLen + 14);
+ m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
+
+ sal_uInt32 nOffBits = 14 + aInfoHeader2.nHeaderLen + rgbTableSize;
+ m_pImageData[0] = 'B';
+ m_pImageData[1] = 'M';
+ m_pImageData[2] = static_cast<sal_uInt8>(m_aBmpRec.nFileSize);
+ m_pImageData[3] = static_cast<sal_uInt8>(m_aBmpRec.nFileSize >> 8);
+ m_pImageData[4] = static_cast<sal_uInt8>(m_aBmpRec.nFileSize >> 16);
+ m_pImageData[5] = static_cast<sal_uInt8>(m_aBmpRec.nFileSize >> 24);
+ m_pImageData[6] = 0;
+ m_pImageData[7] = 0;
+ m_pImageData[8] = 0;
+ m_pImageData[9] = 0;
+ m_pImageData[10] = static_cast<sal_uInt8>(nOffBits);
+ m_pImageData[11] = static_cast<sal_uInt8>(nOffBits >> 8);
+ m_pImageData[12] = static_cast<sal_uInt8>(nOffBits >> 16);
+ m_pImageData[13] = static_cast<sal_uInt8>(nOffBits >> 24);
+
+ sal_uInt8* pPicData = m_pImageData.get();
+
+ m_pStream->Seek(nBmpPos);
+ if (nBmpLen != m_pStream->ReadBytes(pPicData + 14, nBmpLen))
+ throw BadRead();
+}
+
+OUString LwpDrawBitmap::RegisterStyle()
+{
+ std::unique_ptr<XFImageStyle> pBmpStyle(new XFImageStyle());
+ pBmpStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelFrame);
+ pBmpStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->AddStyle(std::move(pBmpStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFFrame> LwpDrawBitmap::CreateDrawObj(const OUString& rStyleName)
+{
+ rtl::Reference<XFImage> xImage(new XFImage());
+ xImage->SetImageData(m_pImageData.get(), m_aBmpRec.nFileSize);
+ SetPosition(xImage.get());
+
+ xImage->SetStyleName(rStyleName);
+
+ return xImage;
+}
+
+rtl::Reference<XFFrame> LwpDrawBitmap::CreateStandardDrawObj(const OUString& rStyleName)
+{
+ return CreateDrawObj(rStyleName);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdrawobj.hxx b/lotuswordpro/source/filter/lwpdrawobj.hxx
new file mode 100644
index 000000000..6c1b9273f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdrawobj.hxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * The file declares the LwpDrawObjects and associated class like LwpDrawGroup, LwpDrawRectangle
+ * and so on.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+
+#include "lwpsdwdrawheader.hxx"
+
+#include <memory>
+
+class SvStream;
+class XFFrame;
+class XFDrawStyle;
+
+/**
+ * @brief
+ * Lwp-base-draw object.
+ */
+class LwpDrawObj
+{
+protected:
+ DrawObjectType m_eType;
+ SvStream* m_pStream;
+ SdwDrawObjHeader m_aObjHeader;
+ SdwClosedObjStyleRec m_aClosedObjStyleRec;
+ DrawingOffsetAndScale* m_pTransData;
+
+public:
+ LwpDrawObj(SvStream* pStream, DrawingOffsetAndScale* pTransData = nullptr);
+ virtual ~LwpDrawObj() {}
+
+private:
+ void ReadObjHeaderRecord();
+
+protected:
+ void ReadClosedObjStyle();
+ void SetFillStyle(XFDrawStyle* pStyle);
+ static void SetLineStyle(XFDrawStyle* pStyle, sal_uInt8 nWidth, sal_uInt8 nLineStyle,
+ const SdwColor& rColor);
+ void SetPosition(XFFrame* pObj);
+ static void SetArrowHead(XFDrawStyle* pOpenedObjStyle, sal_uInt8 nArrowFlag, sal_uInt8 nLineWidth);
+ static OUString GetArrowName(sal_uInt8 nArrowStyle);
+
+protected:
+ /**
+ * @descr read out the record of a draw object.
+ */
+ virtual void Read() = 0;
+
+ /**
+ * @descr register styles of a draw object according to the saved records data.
+ * @return the style name which has been registered.
+ */
+ virtual OUString RegisterStyle() = 0;
+
+ /**
+ * @descr create XF-draw object and assign the style name to it.
+ * @param style name.
+ * @return pointer of the created XF-draw object.
+ */
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) = 0;
+
+ /**
+ * @descr create XF-draw object and assign the style name to it.
+ * @param style name.
+ * @return pointer of the created XF-draw object.
+ */
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) = 0;
+
+public:
+ /**
+ * @descr create a completed XF-draw object(read data, register styles and create XF-draw object)
+ * @return pointer of the created completed XF-draw object.
+ */
+ rtl::Reference<XFFrame> CreateXFDrawObject();
+
+ /**
+ * @param type of the object.
+ * @descr set the type to the draw object.
+ */
+ void SetObjectType(DrawObjectType eType) { m_eType = eType; }
+};
+
+/**
+ * @brief
+ * Lwp-draw-group object.
+ */
+class LwpDrawGroup : public LwpDrawObj
+{
+public:
+ explicit LwpDrawGroup(SvStream* pStream) : LwpDrawObj(pStream) {}
+
+protected:
+ virtual void Read() override {}
+ virtual OUString RegisterStyle() override
+ {
+ return OUString();
+ }
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& /*rStyleName*/) override { return nullptr; }
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& /*rStyleName*/) override { return nullptr; }
+};
+
+/**
+ * @brief
+ * Lwp-draw-line object.
+ */
+class LwpDrawLine : public LwpDrawObj
+{
+private:
+ SdwLineRecord m_aLineRec;
+
+public:
+ LwpDrawLine(SvStream * pStream, DrawingOffsetAndScale* pTransData);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-polyline object.
+ */
+class LwpDrawPolyLine : public LwpDrawObj
+{
+private:
+ SdwPolyLineRecord m_aPolyLineRec;
+ std::unique_ptr<SdwPoint[]> m_pVector;
+
+public:
+ LwpDrawPolyLine(SvStream * pStream, DrawingOffsetAndScale* pTransData);
+ virtual ~LwpDrawPolyLine() override;
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+ /**
+ * @brief
+ * Lwp-draw-polygon object.
+ */
+class LwpDrawPolygon : public LwpDrawObj
+{
+private:
+ sal_uInt16 m_nNumPoints;
+ std::unique_ptr<SdwPoint[]> m_pVector;
+
+public:
+ LwpDrawPolygon(SvStream * pStream, DrawingOffsetAndScale* pTransData);
+ virtual ~LwpDrawPolygon() override;
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-rectangle(rounded-corner rectangle) object.
+ */
+class LwpDrawRectangle : public LwpDrawObj
+{
+private:
+ SdwPoint m_aVector[16];
+
+public:
+ LwpDrawRectangle(SvStream* pStream, DrawingOffsetAndScale* pTransData);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+
+private:
+ XFFrame* CreateRoundedRect(const OUString& rStyleName);
+};
+
+/**
+ * @brief
+ * Lwp-draw-ellipse object.
+ */
+class LwpDrawEllipse : public LwpDrawObj
+{
+private:
+ SdwPoint m_aVector[13];
+
+public:
+ LwpDrawEllipse(SvStream * pStream, DrawingOffsetAndScale* pTransData);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-arc object.
+ */
+class LwpDrawArc : public LwpDrawObj
+{
+private:
+ SdwArcRecord m_aArcRec;
+ SdwPoint m_aVector[4];
+
+public:
+ LwpDrawArc(SvStream * pStream, DrawingOffsetAndScale* pTransData);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-textbox object.
+ */
+class XFFont;
+class LwpDrawTextBox : public LwpDrawObj
+{
+private:
+ SdwTextBoxRecord m_aTextRec;
+ SdwPoint m_aVector;
+
+public:
+ explicit LwpDrawTextBox(SvStream* pStream);
+ virtual ~LwpDrawTextBox() override;
+ static void SetFontStyle(rtl::Reference<XFFont> const & pFont, SdwTextBoxRecord const * pRec);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-curved-text object.
+ */
+class XFDrawPath;
+class LwpDrawTextArt : public LwpDrawObj
+{
+private:
+ SdwTextArt m_aTextArtRec;
+ SdwPoint m_aVector[4];
+
+private:
+ void CreateFWPath(XFDrawPath* pPath);
+
+public:
+ LwpDrawTextArt(SvStream* pStream, DrawingOffsetAndScale* pTransData);
+ virtual ~LwpDrawTextArt() override;
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/**
+ * @brief
+ * Lwp-draw-metafile object.
+ */
+class LwpDrawMetafile : public LwpDrawObj
+{
+public:
+ explicit LwpDrawMetafile(SvStream* pStream);
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override
+ {
+ return OUString();
+ }
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& /*rStyleName*/) override {return nullptr;}
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& /*rStyleName*/) override {return nullptr;}
+};
+
+/**
+ * @brief
+ * Lwp-draw-bitmap object.
+ */
+class LwpDrawBitmap : public LwpDrawObj
+{
+private:
+ SdwBmpRecord m_aBmpRec;
+ std::unique_ptr<sal_uInt8[]> m_pImageData;
+public:
+ explicit LwpDrawBitmap(SvStream* pStream);
+ virtual ~LwpDrawBitmap() override;
+
+protected:
+ virtual void Read() override;
+ virtual OUString RegisterStyle() override;
+ virtual rtl::Reference<XFFrame> CreateDrawObj(const OUString& rStyleName) override;
+ virtual rtl::Reference<XFFrame> CreateStandardDrawObj(const OUString& rStyleName) override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpdropcapmgr.cxx b/lotuswordpro/source/filter/lwpdropcapmgr.cxx
new file mode 100644
index 000000000..b8fb591de
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpdropcapmgr.cxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpdropcapmgr.hxx>
+
+LwpDropcapMgr::LwpDropcapMgr() { m_pXFPara = nullptr; }
+
+void LwpDropcapMgr::SetXFPara(XFParagraph* pXFPara) { m_pXFPara = pXFPara; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfilehdr.cxx b/lotuswordpro/source/filter/lwpfilehdr.cxx
new file mode 100644
index 000000000..f5c7ae89c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfilehdr.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpfilehdr.hxx>
+#include <lwpdefs.hxx>
+
+//Word Pro 96: 0x0a,
+sal_uInt16 LwpFileHeader::m_nFileRevision = 0;
+
+LwpFileHeader::LwpFileHeader()
+ : m_nAppRevision(0)
+ , m_nAppReleaseNo(0)
+ , m_nRequiredAppRevision(0)
+ , m_nRequiredFileRevision(0)
+ , m_nRootIndexOffset(0)
+{
+}
+/**
+ * @descr read file header object from svstream
+ */
+void LwpFileHeader::Read(LwpSvStream* pStrm)
+{
+ pStrm->ReadUInt16(m_nAppRevision);
+ pStrm->ReadUInt16(m_nFileRevision);
+ pStrm->ReadUInt16(m_nAppReleaseNo);
+ pStrm->ReadUInt16(m_nRequiredAppRevision);
+ pStrm->ReadUInt16(m_nRequiredFileRevision);
+ m_cDocumentID.Read(pStrm);
+ if (m_nFileRevision < 0x000B)
+ m_nRootIndexOffset = BAD_OFFSET;
+ else
+ {
+ pStrm->ReadUInt32(m_nRootIndexOffset);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfilter.cxx b/lotuswordpro/source/filter/lwpfilter.cxx
new file mode 100644
index 000000000..e8ba358ae
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfilter.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Circle object.
+ ************************************************************************/
+#include "lwpfilter.hxx"
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/xfsaxstream.hxx>
+#include "lwp9reader.hxx"
+#include <lwpsvstream.hxx>
+
+#include <tools/stream.hxx>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+
+#include <memory>
+
+using namespace ::cppu;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+
+/**
+ * @descr decompressed small file
+ * @param pCompressed - real file stream
+ * @param pDecompressed - file decompressed, create inside, caller should delete it
+ * @return success - sal_True, fail - sal_False
+ */
+#include "bento.hxx"
+using namespace OpenStormBento;
+#include "explode.hxx"
+static bool Decompress(SvStream* pCompressed, SvStream*& pOutDecompressed)
+{
+ pCompressed->Seek(0);
+ std::unique_ptr<SvMemoryStream> aDecompressed(new SvMemoryStream(4096, 4096));
+ unsigned char buffer[512];
+ pCompressed->ReadBytes(buffer, 16);
+ aDecompressed->WriteBytes(buffer, 16);
+
+ LwpSvStream aLwpStream(pCompressed);
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
+ {
+ sal_uLong ulRet = BenOpenContainer(&aLwpStream, &pBentoContainer);
+ if (ulRet != BenErr_OK)
+ return false;
+ }
+
+ std::unique_ptr<LtcUtBenValueStream> aWordProData(
+ pBentoContainer->FindValueStreamWithPropertyName("WordProData"));
+
+ if (!aWordProData)
+ return false;
+
+ // decompressing
+ Decompression decompress(aWordProData.get(), aDecompressed.get());
+ if (0 != decompress.explode())
+ return false;
+
+ sal_uInt32 nPos = aWordProData->GetSize();
+ nPos += 0x10;
+
+ pCompressed->Seek(nPos);
+ while (sal_uInt32 iRead = pCompressed->ReadBytes(buffer, 512))
+ aDecompressed->WriteBytes(buffer, iRead);
+
+ // disable stream growing past its current size
+ aDecompressed->SetResizeOffset(0);
+
+ //transfer ownership of aDecompressed's ptr
+ pOutDecompressed = aDecompressed.release();
+ return true;
+}
+
+/**
+ * @descr Get LwpSvStream, if small file, both compressed/decompressed stream
+ * Otherwise, only normal stream
+ * @param pStream - real file stream
+ * @param LwpSvStream * , created inside, deleted outside
+ * @param sal_Bool, sal_True -
+ */
+static bool GetLwpSvStream(SvStream* pStream, LwpSvStream*& pLwpSvStream)
+{
+ SvStream* pDecompressed = nullptr;
+
+ pStream->Seek(0x10);
+ sal_uInt32 nTag(0);
+ pStream->ReadUInt32(nTag);
+ if (nTag != 0x3750574c) // "LWP7"
+ {
+ // small file, needs decompression
+ if (!Decompress(pStream, pDecompressed))
+ {
+ pLwpSvStream = nullptr;
+ return true;
+ }
+ pStream->Seek(0);
+ pDecompressed->Seek(0);
+ }
+
+ pLwpSvStream = nullptr;
+ bool bCompressed = false;
+ if (pDecompressed)
+ {
+ LwpSvStream* pOriginalLwpSvStream = new LwpSvStream(pStream);
+ pLwpSvStream = new LwpSvStream(pDecompressed, pOriginalLwpSvStream);
+ bCompressed = true;
+ }
+ else
+ {
+ pLwpSvStream = new LwpSvStream(pStream);
+ }
+ return bCompressed;
+}
+int ReadWordproFile(SvStream& rStream,
+ uno::Reference<css::xml::sax::XDocumentHandler> const& xHandler)
+{
+ int nRet = 0;
+ try
+ {
+ LwpSvStream* pRawLwpSvStream = nullptr;
+ std::unique_ptr<LwpSvStream> aLwpSvStream;
+ std::unique_ptr<LwpSvStream> aCompressedLwpSvStream;
+ std::unique_ptr<SvStream> aDecompressed;
+ if (GetLwpSvStream(&rStream, pRawLwpSvStream) && pRawLwpSvStream)
+ {
+ SvStream* pDecompressed = pRawLwpSvStream->GetStream();
+ if (pDecompressed)
+ {
+ aDecompressed.reset(pDecompressed);
+ aCompressedLwpSvStream.reset(pRawLwpSvStream->GetCompressedStream());
+ }
+ }
+
+ if (!pRawLwpSvStream)
+ {
+ // nothing returned, fail when uncompressing
+ return 1;
+ }
+
+ aLwpSvStream.reset(pRawLwpSvStream);
+
+ XFSaxStream aStrm(xHandler);
+ Lwp9Reader reader(aLwpSvStream.get(), &aStrm);
+ //Reset all static objects,because this function may be called many times.
+ XFGlobalReset();
+ const bool bOk = reader.Read();
+ if (!bOk)
+ nRet = 1;
+ }
+ catch (...)
+ {
+ return 1;
+ }
+ return nRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfilter.hxx b/lotuswordpro/source/filter/lwpfilter.hxx
new file mode 100644
index 000000000..c10ca24b0
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfilter.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFILTER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFILTER_HXX
+
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+class SvStream;
+
+//test code
+int ReadWordproFile(SvStream& rStream,
+ css::uno::Reference<css::xml::sax::XDocumentHandler> const& XDoc);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfnlayout.cxx b/lotuswordpro/source/filter/lwpfnlayout.cxx
new file mode 100644
index 000000000..b91b86a3d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfnlayout.cxx
@@ -0,0 +1,367 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - footnote layouts
+ */
+
+#include "lwpfnlayout.hxx"
+#include <o3tl/sorted_vector.hxx>
+
+LwpFootnoteLayout::LwpFootnoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTableLayout(objHdr, pStrm)
+{
+}
+
+LwpFootnoteLayout::~LwpFootnoteLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpFootnoteLayout::Read()
+{
+ LwpTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFootnoteLayout::RegisterStyle() {}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFootnoteLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpFnRowLayout::LwpFnRowLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpRowLayout(objHdr, pStrm)
+{
+}
+
+LwpFnRowLayout::~LwpFnRowLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpFnRowLayout::Read()
+{
+ LwpRowLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register footnote/endnote contents style
+ */
+void LwpFnRowLayout::RegisterStyle()
+{
+ // register cells' style
+ LwpObjectID* pCellID = &GetChildHead();
+ LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(pCellID->obj().get());
+
+ o3tl::sorted_vector<LwpCellLayout*> aSeen;
+ while (pCellLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pCellLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ pCellLayout->SetFoundry(m_pFoundry);
+ pCellLayout->RegisterStyle();
+ pCellID = &pCellLayout->GetNext();
+ pCellLayout = dynamic_cast<LwpCellLayout*>(pCellID->obj().get());
+ }
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFnRowLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpFnCellLayout::LwpFnCellLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpCellLayout(objHdr, pStrm)
+{
+}
+
+LwpFnCellLayout::~LwpFnCellLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpFnCellLayout::Read()
+{
+ LwpCellLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register footnote/endnote contents style
+ */
+void LwpFnCellLayout::RegisterStyle()
+{
+ // content object register styles
+ rtl::Reference<LwpObject> pObj = m_Content.obj();
+ if (pObj.is())
+ {
+ pObj->SetFoundry(m_pFoundry);
+ pObj->DoRegisterStyle();
+ }
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFnCellLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpEndnoteLayout::LwpEndnoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTableLayout(objHdr, pStrm)
+{
+}
+
+LwpEndnoteLayout::~LwpEndnoteLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpEndnoteLayout::Read()
+{
+ LwpTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register footnote/endnote contents style
+ */
+void LwpEndnoteLayout::RegisterStyle()
+{
+ // register style of rows
+ LwpObjectID* pRowID = &GetChildHead();
+ LwpRowLayout* pRowLayout = dynamic_cast<LwpRowLayout*>(pRowID->obj().get());
+ while (pRowLayout)
+ {
+ pRowLayout->SetFoundry(m_pFoundry);
+ pRowLayout->RegisterStyle();
+
+ pRowID = &pRowLayout->GetNext();
+ pRowLayout = dynamic_cast<LwpRowLayout*>(pRowID->obj().get());
+ }
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpEndnoteLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpEnSuperTableLayout::LwpEnSuperTableLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpSuperTableLayout(objHdr, pStrm)
+{
+}
+
+LwpEnSuperTableLayout::~LwpEnSuperTableLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpEnSuperTableLayout::Read()
+{
+ LwpSuperTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpEnSuperTableLayout::RegisterStyle()
+{
+ // if this layout is style of real table entry
+ LwpVirtualLayout* pTableLayout = GetMainTableLayout();
+ if (pTableLayout != nullptr)
+ {
+ pTableLayout->SetFoundry(m_pFoundry);
+ pTableLayout->DoRegisterStyle();
+ }
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpEnSuperTableLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/**
+ * @short Get child endnote layout
+ * @return pointer to endnote layout
+ */
+LwpVirtualLayout* LwpEnSuperTableLayout::GetMainTableLayout()
+{
+ LwpObjectID* pID = &GetChildTail();
+
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (!pID->IsNull())
+ {
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pID->obj().get());
+ if (!pLayout)
+ break;
+ bool bAlreadySeen = !aSeen.insert(pLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if (pLayout->GetLayoutType() == LWP_ENDNOTE_LAYOUT)
+ return pLayout;
+ pID = &pLayout->GetPrevious();
+ }
+
+ return nullptr;
+}
+
+LwpFnSuperTableLayout::LwpFnSuperTableLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpEnSuperTableLayout(objHdr, pStrm)
+{
+}
+
+LwpFnSuperTableLayout::~LwpFnSuperTableLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpFnSuperTableLayout::Read()
+{
+ LwpEnSuperTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFnSuperTableLayout::RegisterStyle() {}
+
+/**
+ * @descr Do nothing
+ */
+void LwpFnSuperTableLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/**
+ * @short Get child footnote layout
+ * @return pointer to footnote layout
+ */
+LwpVirtualLayout* LwpFnSuperTableLayout::GetMainTableLayout()
+{
+ LwpObjectID* pID = &GetChildTail();
+
+ while (pID && !pID->IsNull())
+ {
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pID->obj().get());
+ if (!pLayout)
+ {
+ break;
+ }
+ if (pLayout->GetLayoutType() == LWP_FOOTNOTE_LAYOUT)
+ {
+ return pLayout;
+ }
+ pID = &pLayout->GetPrevious();
+ }
+
+ return nullptr;
+}
+
+LwpContFromLayout::LwpContFromLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+{
+}
+
+LwpContFromLayout::~LwpContFromLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpContFromLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpContFromLayout::RegisterStyle() {}
+
+/**
+ * @descr Do nothing
+ */
+void LwpContFromLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpContOnLayout::LwpContOnLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+{
+}
+
+LwpContOnLayout::~LwpContOnLayout() {}
+
+/**
+ * @descr Read object info
+ */
+void LwpContOnLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Do nothing
+ */
+void LwpContOnLayout::RegisterStyle() {}
+
+/**
+ * @descr Do nothing
+ */
+void LwpContOnLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfnlayout.hxx b/lotuswordpro/source/filter/lwpfnlayout.hxx
new file mode 100644
index 000000000..d95a93bfd
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfnlayout.hxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - footnote layouts
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFNLAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFNLAYOUT_HXX
+
+#include "lwptablelayout.hxx"
+#include "lwprowlayout.hxx"
+
+/**
+ * @brief VO_FOOTNOTELAYOUT object
+ *
+*/
+class LwpFootnoteLayout : public LwpTableLayout
+{
+public:
+ LwpFootnoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFootnoteLayout() override;
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FOOTNOTE_LAYOUT; }
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_FNROWLAYOUT object
+ *
+*/
+class LwpFnRowLayout : public LwpRowLayout
+{
+public:
+ LwpFnRowLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFnRowLayout() override;
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FOOTNOTE_ROW_LAYOUT; }
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_FNCELLLAYOUT object
+ *
+*/
+class LwpFnCellLayout : public LwpCellLayout
+{
+public:
+ LwpFnCellLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFnCellLayout() override;
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FOOTNOTE_CELL_LAYOUT; }
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_ENDNOTELAYOUT object
+ *
+*/
+class LwpEndnoteLayout : public LwpTableLayout
+{
+public:
+ LwpEndnoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpEndnoteLayout() override;
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_ENDNOTE_LAYOUT; }
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_ENSUPERTABLELAYOUT object
+ *
+*/
+class LwpEnSuperTableLayout : public LwpSuperTableLayout
+{
+public:
+ LwpEnSuperTableLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpEnSuperTableLayout() override;
+ void RegisterStyle() override;
+ void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_ENDNOTE_SUPERTABLE_LAYOUT; }
+ virtual LwpVirtualLayout* GetMainTableLayout();
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_FNSUPERTABLELAYOUT object
+ *
+*/
+class LwpFnSuperTableLayout : public LwpEnSuperTableLayout
+{
+public:
+ LwpFnSuperTableLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFnSuperTableLayout() override;
+ void RegisterStyle() override;
+ void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FOOTNOTE_SUPERTABLE_LAYOUT; }
+ virtual LwpVirtualLayout* GetMainTableLayout() override;
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_CONTFROMLAYOUT object
+ *
+*/
+class LwpContFromLayout : public LwpPlacableLayout
+{
+public:
+ LwpContFromLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpContFromLayout() override;
+ void RegisterStyle() override;
+ void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_CONTONLAYOUT object
+ *
+*/
+class LwpContOnLayout : public LwpPlacableLayout
+{
+public:
+ LwpContOnLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpContOnLayout() override;
+ void RegisterStyle() override;
+ void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
new file mode 100644
index 000000000..92a4d76dc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -0,0 +1,509 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpglobalmgr.hxx>
+#include <lwpfont.hxx>
+#include <lwpbasetype.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfdefs.hxx>
+#include <xfilter/xfcolor.hxx>
+#include <sal/log.hxx>
+
+void LwpFontAttrEntry::Read(LwpObjectStream *pStrm)
+{
+ m_nAttrBits = pStrm->QuickReaduInt16();
+ m_nAttrOverrideBits = pStrm->QuickReaduInt16();
+ m_nAttrApplyBits = pStrm->QuickReaduInt16();
+ m_nAttrOverrideBits2 = pStrm->QuickReaduInt8();
+ m_nAttrApplyBits2 = pStrm->QuickReaduInt8();
+ m_nCase = pStrm->QuickReaduInt8();
+ m_nUnder = pStrm->QuickReaduInt8();
+ pStrm->SkipExtra();
+}
+
+void LwpFontAttrEntry::Override( rtl::Reference<XFFont> const & pFont )
+{
+ if (IsBoldOverridden())
+ pFont->SetBold(Is(BOLD));
+
+ if (IsItalicOverridden())
+ pFont->SetItalic(Is(ITALIC));
+
+ if (IsStrikeThruOverridden())
+ {
+ if(Is(STRIKETHRU))
+ {
+ pFont->SetCrossout(enumXFCrossoutSignel);
+ }
+ else
+ {
+ pFont->SetCrossout(enumXFCrossoutNone);
+ }
+ }
+
+ if (IsSuperOverridden())
+ {
+ if(Is(SUPERSCRIPT))
+ pFont->SetPosition();
+ }
+
+ if (IsSubOverridden())
+ {
+ if(Is(SUBSCRIPT))
+ pFont->SetPosition(false);
+ }
+
+ if (IsUnderlineOverridden())
+ {
+ switch(m_nUnder)
+ {
+ case UNDER_SINGLE:
+ pFont->SetUnderline(enumXFUnderlineSingle);
+ break;
+ case UNDER_DOUBLE:
+ pFont->SetUnderline(enumXFUnderlineDouble);
+ break;
+ case UNDER_WORD_SINGLE:
+ pFont->SetUnderline(enumXFUnderlineSingle, true);
+ break;
+ case UNDER_WORD_DOUBLE:
+ pFont->SetUnderline(enumXFUnderlineSingle, true);
+ break;
+ case UNDER_DONTCARE: //fall through
+ case UNDER_OFF: //fall through
+ case UNDER_STYLE: //fall through
+ default:
+ break;
+ //do nothing;
+ }
+ }
+
+ if (IsCaseOverridden())
+ {
+ switch(m_nCase)
+ {
+ case CASE_UPPER:
+ pFont->SetTransform(enumXFTransformUpper);
+ break;
+ case CASE_LOWER:
+ pFont->SetTransform(enumXFTransformLower);
+ break;
+ case CASE_NORMAL:
+ pFont->SetTransform(enumXFTransformNone);
+ break;
+ case CASE_INITCAPS:
+ pFont->SetTransform(enumXFTransformCapitalize);
+ break;
+ case CASE_STYLE: //fall through
+ case CASE_DONTCARE: //fall through
+ default:
+ //do nothing
+ ;
+ }
+ }
+
+ //Please note that, put the SmallCaps setting after the case setting,
+ //for SmallCaps has higher priority than LowerCase but low
+ if (IsSmallCapsOverridden())
+ {
+ if( pFont->GetTransform()!=enumXFTransformUpper ) //SmallCaps should not override upper case
+ {
+ if(Is(SMALLCAPS))
+ pFont->SetTransform(enumXFTransformSmallCaps);
+ }
+ }
+
+ // TODO: tightness
+ //if (IsTightnessOverridden())
+ // pFont->SetTightness(cTightness);*/
+}
+
+bool LwpFontAttrEntry::Is(sal_uInt16 Attr)
+{
+ return (0 != (m_nAttrBits & Attr));
+}
+
+bool LwpFontAttrEntry::IsBoldOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & BOLD));
+}
+
+bool LwpFontAttrEntry::IsItalicOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & ITALIC));
+}
+bool LwpFontAttrEntry::IsStrikeThruOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & STRIKETHRU));
+}
+bool LwpFontAttrEntry::IsSmallCapsOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & SMALLCAPS));
+}
+bool LwpFontAttrEntry::IsSuperOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & SUPERSCRIPT));
+
+}
+bool LwpFontAttrEntry::IsSubOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits & SUBSCRIPT));
+
+}
+
+bool LwpFontAttrEntry::IsUnderlineOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits2 & UNDER));
+}
+bool LwpFontAttrEntry::IsCaseOverridden() const
+{
+ return (0 != (m_nAttrOverrideBits2 & CASE));
+}
+
+void LwpFontTableEntry::Read(LwpObjectStream *pStrm)
+{
+ m_WindowsFaceName.Read(pStrm);
+
+ // use the m_WindowsFaceName to set the m_FaceName temporarily
+ m_FaceName = m_WindowsFaceName;
+
+ //Skip the panoseNumber
+ //m_PanoseNumber.Read(pStrm);
+ LwpPanoseNumber thePanoseToSkip;
+ thePanoseToSkip.Read(pStrm);
+
+ pStrm->SkipExtra();
+
+ RegisterFontDecl();
+}
+
+OUString const & LwpFontTableEntry::GetFaceName() const
+{
+ return m_WindowsFaceName.str();
+}
+
+void LwpFontTableEntry::RegisterFontDecl()
+{
+ if(m_FaceName.str().isEmpty()) return;
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFFontDecl aFontDecl1( m_FaceName.str(), m_FaceName.str() );
+ pXFStyleManager->AddFontDecl(aFontDecl1);
+}
+
+LwpFontTable::LwpFontTable()
+ : m_nCount(0)
+{}
+
+void LwpFontTable::Read(LwpObjectStream *pStrm)
+{
+ m_pFontEntries = nullptr;
+ m_nCount = pStrm->QuickReaduInt16();
+ if(m_nCount>0)
+ {
+ m_pFontEntries.reset( new LwpFontTableEntry[m_nCount] );
+ for(sal_uInt16 i=0; i<m_nCount; i++)
+ {
+ m_pFontEntries[i].Read(pStrm);
+ }
+ }
+ pStrm->SkipExtra();
+}
+
+OUString LwpFontTable::GetFaceName(sal_uInt16 index) //index: start from 1
+{
+ SAL_WARN_IF(index > m_nCount || index <= 0, "lwp", "bad font index");
+ return (index <= m_nCount && index > 0) ? m_pFontEntries[index-1].GetFaceName() : OUString();
+}
+
+LwpFontTable::~LwpFontTable()
+{
+}
+
+void LwpFontNameEntry::Read(LwpObjectStream *pStrm)
+{
+ //Read CFontDescriptionOverrideBase
+ m_nOverrideBits = pStrm->QuickReaduInt8();
+ m_nApplyBits = pStrm->QuickReaduInt8();
+ m_nPointSize = pStrm->QuickReaduInt32();
+ m_nOverstrike = pStrm->QuickReaduInt16();
+ m_nTightness = pStrm->QuickReaduInt16();
+ m_Color.Read(pStrm);
+ m_BackColor.Read(pStrm);
+ pStrm->SkipExtra();
+
+ //Read data of LwpFontNameEntry
+ m_nFaceName = pStrm->QuickReaduInt16();
+ m_nAltFaceName = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+
+void LwpFontNameEntry::Override(rtl::Reference<XFFont> const & pFont)
+{
+ if (IsPointSizeOverridden())
+ pFont->SetFontSize(static_cast<sal_uInt8>(m_nPointSize/65536L));
+
+ if (IsColorOverridden() && m_Color.IsValidColor())
+ {
+ XFColor aColor(m_Color.To24Color());
+ pFont->SetColor(aColor);
+ }
+
+ if (IsBackgroundColorOverridden() )
+ {
+ if (m_BackColor.IsValidColor())
+ {
+ XFColor aColor(m_BackColor.To24Color());
+ pFont->SetBackColor( aColor );
+ }
+ else if (m_BackColor.IsTransparent())
+ {
+ pFont->SetBackColorTransparent();
+ }
+ }
+
+ // TODO: tightness
+ //if (IsTightnessOverridden())
+ // pFont->SetTightness(cTightness);
+}
+
+bool LwpFontNameEntry::IsFaceNameOverridden() const
+{
+ return (0 != (m_nOverrideBits & FACENAME));
+}
+
+bool LwpFontNameEntry::IsAltFaceNameOverridden() const
+{
+ return (0 != (m_nOverrideBits & ALTFACENAME));
+}
+
+bool LwpFontNameEntry::IsPointSizeOverridden() const
+{
+ return (0 != (m_nOverrideBits & POINTSIZE));
+}
+
+bool LwpFontNameEntry::IsColorOverridden() const
+{
+ return (0 != (m_nOverrideBits & COLOR));
+}
+
+bool LwpFontNameEntry::IsBackgroundColorOverridden() const
+{
+ return (0 != (m_nOverrideBits & BKCOLOR));
+}
+
+//TODO
+//sal_Bool LwpFontNameEntry::IsTightnessOverridden()
+//{
+// return (0 != (m_nOverrideBits & TIGHTNESS));
+//}
+
+//sal_Bool LwpFontNameEntry::IsAnythingOverridden()
+//{
+// return (0 != (m_nOverrideBits & ALL_BITS));
+//}
+
+LwpFontNameManager::LwpFontNameManager()
+ : m_nCount(0)
+{}
+
+LwpFontNameManager::~LwpFontNameManager()
+{
+}
+
+void LwpFontNameManager::Read(LwpObjectStream *pStrm)
+{
+ m_nCount = pStrm->QuickReaduInt16();
+ if(m_nCount>0)
+ {
+ m_pFontNames.reset( new LwpFontNameEntry[m_nCount] );
+ for(sal_uInt16 i=0; i<m_nCount; i++)
+ {
+ m_pFontNames[i].Read(pStrm);
+ }
+ }
+ m_FontTbl.Read(pStrm);
+ pStrm->SkipExtra();
+}
+
+void LwpFontNameManager::Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont)
+ //index: start from 1
+{
+ if (index > m_nCount || index < 1)
+ return ;
+
+ m_pFontNames[index-1].Override(pFont);
+ if(m_pFontNames[index-1].IsFaceNameOverridden())
+ pFont->SetFontName(m_FontTbl.GetFaceName(m_pFontNames[index-1].GetFaceID()));
+ if(m_pFontNames[index-1].IsAltFaceNameOverridden())
+ pFont->SetFontNameAsia(m_FontTbl.GetFaceName(m_pFontNames[index-1].GetAltFaceID()));
+}
+
+OUString LwpFontNameManager::GetNameByIndex(sal_uInt16 index)
+ //index: start from 1
+{
+ if (index > m_nCount || index < 1)
+ return OUString();
+
+ sal_uInt16 nameindex = m_pFontNames[index-1].GetFaceID();
+ return m_FontTbl.GetFaceName(nameindex);
+}
+
+void LwpFontAttrManager::Read(LwpObjectStream *pStrm)
+{
+ m_nCount = pStrm->QuickReaduInt16();
+ m_pFontAttrs.reset( new LwpFontAttrEntry[m_nCount] );
+
+ for(sal_uInt16 i=0; i<m_nCount; i++)
+ {
+ m_pFontAttrs[i].Read(pStrm);
+ }
+ pStrm->SkipExtra();
+}
+
+void LwpFontAttrManager::Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont)
+ //index: start from 1
+{
+ if (index > m_nCount || index < 1)
+ return ;
+
+ m_pFontAttrs[index-1].Override(pFont);
+}
+
+LwpFontAttrManager::~LwpFontAttrManager()
+{
+}
+
+void LwpFontManager::Read(LwpObjectStream *pStrm)
+{
+ m_FNMgr.Read(pStrm);
+ m_AttrMgr.Read(pStrm);
+ pStrm->SkipExtra();
+
+}
+
+/*
+VO_PARASTYLE call this method to add its style to XFStyleManager based on the fontID
+1. Construct the text style based on the fontID
+2. Add the style to XFStyleManager, and return the <office:styles> style name
+3. Add it to LwpParaStyleMap.
+Note: A temporary method for only font support phase. The next AddStyle should be used later.
+// To be replaced by LwpStyleManager::AddStyle() and the following CreateFont()
+*/
+/*void LwpFontManager::AddStyle(LwpObjectID styleObjID, sal_uInt32 fontID, OUString styleName)
+{
+ XFTextStyle* pStyle = new XFTextStyle(); //to be deleted by XFStyleManager
+ AddStyle(styleObjID, fontID, styleName, pStyle);
+}*/
+
+/*
+VO_PARASTYLE/VO_CHARACTERSTYLE call this method to add its style to XFStyleManager based on the fontID
+1. Construct the text style based on the fontID
+2. Add the style to XFStyleManager, and return the <office:styles> style name
+3. Add it to LwpParaStyleMap.
+Prerequisite: pStyle has been created and the paragraph properties has been set to it.
+//To be replaced by LwpStyleManager::AddStyle() and the following CreateFont()
+*/
+/*void LwpFontManager::AddStyle(LwpObjectID styleObjID, sal_uInt32 fontID, OUString styleName, XFTextStyle* pStyle)
+{
+ assert(pStyle);
+ XFFont* pFont = CreateFont(fontID);
+ pStyle->SetFont(pFont);
+ pStyle->SetStyleName(styleName);
+ XFStyleManager::AddStyle(pStyle);
+ m_StyleList.emplace( styleObjID, styleName));
+}*/
+
+/*
+Create XFFont based on the fotID
+*/
+rtl::Reference<XFFont> LwpFontManager::CreateFont(sal_uInt32 fontID)
+{
+ rtl::Reference<XFFont> pFont = new XFFont();
+ m_FNMgr.Override(GetFontNameIndex(fontID), pFont);
+ m_AttrMgr.Override(GetFontAttrIndex(fontID), pFont);
+ return pFont;
+}
+
+/*
+Called XFFont based on the override result of two font ids.
+Refer to CFontManager::OverrideID
+*/
+//OUString LwpFontManager::GetOverrideStyle(sal_uInt32 fontID, sal_uInt32 overID)
+rtl::Reference<XFFont> LwpFontManager::CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID)
+{
+ rtl::Reference<XFFont> pFont = new XFFont(); //To be deleted by XFFontFactory
+ if(fontID)
+ {
+ Override(fontID, pFont);
+ }
+ if(overID)
+ {
+ Override(overID, pFont);
+ }
+ return pFont;
+}
+
+void LwpFontManager::Override(sal_uInt32 fontID, rtl::Reference<XFFont> const & pFont)
+{
+ m_FNMgr.Override(GetFontNameIndex(fontID), pFont);
+ m_AttrMgr.Override(GetFontAttrIndex(fontID), pFont);
+}
+
+OUString LwpFontManager::GetNameByID(sal_uInt32 fontID)
+{
+ return m_FNMgr.GetNameByIndex(GetFontNameIndex(fontID));//use font id for bullet?
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
new file mode 100644
index 000000000..5bbfa0321
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -0,0 +1,548 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <memory>
+#include "lwpfootnote.hxx"
+#include <xfilter/xffootnote.hxx>
+#include <xfilter/xfendnote.hxx>
+#include <xfilter/xffootnoteconfig.hxx>
+#include <xfilter/xfendnoteconfig.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftextspan.hxx>
+#include "lwppara.hxx"
+#include "lwpdoc.hxx"
+#include "lwpfnlayout.hxx"
+#include <lwpglobalmgr.hxx>
+
+LwpFribFootnote::LwpFribFootnote(LwpPara* pPara)
+ : LwpFrib(pPara)
+{
+}
+
+/**
+ * @descr read footnote frib information
+ */
+void LwpFribFootnote::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_Footnote.ReadIndexed(pObjStrm);
+}
+
+/**
+ * @descr Register footnote style by calling LwpFootnote::RegisterStyle()
+ */
+void LwpFribFootnote::RegisterNewStyle()
+{
+ LwpFootnote* pFootnote = GetFootnote();
+ if (pFootnote)
+ {
+ //register footnote number font style
+ LwpFrib::RegisterStyle(m_pPara->GetFoundry());
+ //register footnote content style
+ pFootnote->SetFoundry(m_pPara->GetFoundry());
+ pFootnote->RegisterStyle();
+ }
+}
+
+/**
+ * @descr Parse footnote by calling LwpFootnote::XFConvert()
+ */
+void LwpFribFootnote::XFConvert(XFContentContainer* pCont)
+{
+ LwpFootnote* pFootnote = GetFootnote();
+ if (!pFootnote)
+ return;
+
+ rtl::Reference<XFContentContainer> xContent;
+ if (pFootnote->GetType() == FN_FOOTNOTE)
+ {
+ xContent.set(new XFFootNote);
+ }
+ else
+ {
+ xContent.set(new XFEndNote);
+ }
+ pFootnote->XFConvert(xContent.get());
+ if (m_ModFlag)
+ {
+ //set footnote number font style
+ rtl::Reference<XFTextSpan> xSpan(new XFTextSpan);
+ xSpan->SetStyleName(GetStyleName());
+ //add the xffootnote into the content container
+ xSpan->Add(xContent.get());
+ pCont->Add(xSpan.get());
+ }
+ else
+ {
+ pCont->Add(xContent.get());
+ }
+}
+
+/**
+ * @descr Get foonote object
+ */
+LwpFootnote* LwpFribFootnote::GetFootnote()
+{
+ return dynamic_cast<LwpFootnote*>(m_Footnote.obj().get());
+}
+
+LwpFootnote::LwpFootnote(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpOrderedObject(objHdr, pStrm)
+ , m_nType(0)
+ , m_nRow(0)
+{
+}
+
+LwpFootnote::~LwpFootnote() {}
+
+/**
+ * @descr Read foonote object
+ */
+void LwpFootnote::Read()
+{
+ LwpOrderedObject::Read();
+ m_nType = m_pObjStrm->QuickReaduInt16();
+ m_nRow = m_pObjStrm->QuickReaduInt16();
+ m_Content.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register footnote style
+ */
+void LwpFootnote::RegisterStyle()
+{
+ //Only register footnote contents style,
+ //Endnote contents style registers in LwpEnSuperTableLayout::RegisterStyle
+ if (m_nType == FN_FOOTNOTE)
+ {
+ LwpContent* pContent = FindFootnoteContent();
+ if (pContent)
+ {
+ pContent->SetFoundry(m_pFoundry);
+ pContent->DoRegisterStyle();
+ }
+ }
+}
+
+/**
+ * @descr Parse footnote
+ */
+void LwpFootnote::XFConvert(XFContentContainer* pCont)
+{
+ LwpContent* pContent = FindFootnoteContent();
+ if (pContent)
+ {
+ pContent->DoXFConvert(pCont);
+ }
+}
+
+/**
+ * @descr Get endnote cell layout which contains current endnote content
+ */
+LwpCellLayout* LwpFootnote::GetCellLayout()
+{
+ LwpEnSuperTableLayout* pEnSuperLayout = FindFootnoteTableLayout();
+ if (pEnSuperLayout)
+ {
+ LwpTableLayout* pTableLayout
+ = dynamic_cast<LwpTableLayout*>(pEnSuperLayout->GetMainTableLayout());
+ if (pTableLayout)
+ {
+ LwpRowLayout* pRowLayout = pTableLayout->GetRowLayout(m_nRow);
+ if (pRowLayout)
+ {
+ return dynamic_cast<LwpCellLayout*>(pRowLayout->GetChildHead().obj().get());
+ }
+ }
+ }
+ return nullptr;
+}
+
+/**
+ * @descr Get division which footnote table contains current footnote content, copy from lwp source code
+ */
+LwpDocument* LwpFootnote::GetFootnoteTableDivision()
+{
+ if (!m_pFoundry)
+ return nullptr;
+
+ LwpDocument* pPrev = nullptr;
+ LwpDocument* pDivision = nullptr;
+ LwpDocument* pFootnoteDivision = nullptr;
+
+ // Make sure the footnote does belong to some division
+ // The division might not have a DivisionInfo if it's being Destruct()ed
+ pPrev = m_pFoundry->GetDocument();
+ pFootnoteDivision = pPrev;
+ if (!pPrev || pPrev->GetDivInfoID().IsNull())
+ return nullptr;
+
+ switch (m_nType)
+ {
+ case FN_FOOTNOTE:
+ {
+ // Footnotes always use the source division
+ return pFootnoteDivision;
+ }
+ case FN_DIVISION:
+ {
+ // Start with the footnote's division
+ pDivision = pPrev;
+ break;
+ }
+ case FN_DIVISION_SEPARATE:
+ {
+ // It had better be the next division
+ pDivision = pPrev->GetNextDivision();
+ break;
+ }
+ case FN_DIVISIONGROUP:
+ case FN_DIVISIONGROUP_SEPARATE:
+ {
+ pDivision = pPrev->GetLastInGroupWithContents();
+ break;
+ }
+ case FN_DOCUMENT:
+ case FN_DOCUMENT_SEPARATE:
+ {
+ pDivision = pFootnoteDivision->GetRootDocument();
+ if (pDivision)
+ pDivision = pDivision->GetLastDivisionWithContents();
+ break;
+ }
+ }
+
+ // Make sure we're using the proper endnote division, if it's separate
+ if (m_nType & FN_MASK_SEPARATE)
+ pDivision = GetEndnoteDivision(pDivision);
+ // Don't use a division that's specifically for endnotes
+ else
+ {
+ while (pDivision)
+ {
+ if (pDivision->GetEndnoteType() == FN_DONTCARE)
+ break;
+ if (m_nType == FN_DIVISIONGROUP)
+ pDivision = pDivision->GetPreviousInGroup();
+ else
+ pDivision = pDivision->GetPreviousDivisionWithContents();
+ }
+ }
+ if (pDivision)
+ return pDivision;
+ return nullptr;
+}
+
+/**
+ * @descr Get division which endnote table contains current endnote content, copy from lwp source code
+ */
+LwpDocument* LwpFootnote::GetEndnoteDivision(LwpDocument* pPossible)
+{
+ LwpDocument* pDivision = pPossible;
+ sal_uInt16 nDivType;
+
+ // In case we have multiple endnote divisions, walk backwards until
+ // we find one.
+ while (pDivision)
+ {
+ // Do we already have the right division?
+ nDivType = pDivision->GetEndnoteType();
+ if (nDivType == m_nType)
+ return pDivision;
+ // When we hit the first non-endnote division, stop looking.
+ // -- SDC 10/8/96
+ if (nDivType == FN_DONTCARE)
+ break;
+ pDivision = pDivision->GetPreviousDivision();
+ }
+ return nullptr;
+}
+
+/**
+ * @descr Get footnote table class name
+ */
+OUString LwpFootnote::GetTableClass() const
+{
+ OUString strClassName;
+ switch (GetType() & FN_MASK_BASE)
+ {
+ case FN_BASE_FOOTNOTE:
+ {
+ strClassName = STR_DivisionFootnote;
+ break;
+ }
+ case FN_BASE_DOCUMENT:
+ {
+ strClassName = STR_DocumentEndnote;
+ break;
+ }
+ case FN_BASE_DIVISION:
+ {
+ strClassName = STR_DivisionEndnote;
+ break;
+ }
+ case FN_BASE_DIVISIONGROUP:
+ {
+ strClassName = STR_DivisionGroupEndnote;
+ break;
+ }
+ }
+ return strClassName;
+}
+
+/**
+ * @descr Find footnote tablelayout, copy from lwp source code
+ */
+LwpEnSuperTableLayout* LwpFootnote::FindFootnoteTableLayout()
+{
+ LwpDocument* pDivision = GetFootnoteTableDivision();
+ if (!pDivision)
+ return nullptr;
+
+ LwpFoundry* pFoundry = pDivision->GetFoundry();
+ OUString strClassName = GetTableClass();
+ if (strClassName.isEmpty())
+ return nullptr;
+
+ LwpContent* pContent = nullptr;
+
+ while ((pContent = pFoundry->EnumContents(pContent)) != nullptr)
+ if (pContent->IsTable() && (strClassName == pContent->GetClassName())
+ && pContent->IsActive() && pContent->GetLayout(nullptr).is())
+ {
+ // Found it!
+ return static_cast<LwpEnSuperTableLayout*>(
+ static_cast<LwpTable*>(pContent)->GetSuperTableLayout());
+ }
+
+ return nullptr;
+}
+
+/**
+ * @descr Find footnote contents
+ */
+LwpContent* LwpFootnote::FindFootnoteContent()
+{
+ LwpContent* pContent = dynamic_cast<LwpContent*>(m_Content.obj().get());
+ //if the content has layout, the content has footnote contents;
+ //or looking for the celllayout and return the footnote contents.
+ if (pContent && pContent->GetLayout(nullptr).is())
+ return pContent;
+
+ LwpCellLayout* pCellLayout = GetCellLayout();
+ if (pCellLayout)
+ {
+ pContent = dynamic_cast<LwpContent*>(pCellLayout->GetContent().obj().get());
+ }
+
+ return pContent;
+}
+
+LwpFootnoteTable::LwpFootnoteTable(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTable(objHdr, pStrm)
+{
+}
+
+void LwpFootnoteTable::Read()
+{
+ LwpTable::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Read footnote number options information
+ */
+void LwpFootnoteNumberOptions::Read(LwpObjectStream* pObjStrm)
+{
+ m_nFlag = pObjStrm->QuickReaduInt16();
+ m_nStartingNumber = pObjStrm->QuickReaduInt16();
+ m_LeadingText.Read(pObjStrm);
+ m_TrailingText.Read(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Read footnote separator options information
+ */
+void LwpFootnoteSeparatorOptions::Read(LwpObjectStream* pObjStrm)
+{
+ m_nFlag = pObjStrm->QuickReaduInt16();
+ m_nLength = pObjStrm->QuickReaduInt32();
+ m_nIndent = pObjStrm->QuickReaduInt32();
+ m_nAbove = pObjStrm->QuickReaduInt32();
+ m_nBelow = pObjStrm->QuickReaduInt32();
+ m_BorderStuff.Read(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+LwpFootnoteOptions::LwpFootnoteOptions(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+ , m_nFlag(0)
+{
+}
+
+LwpFootnoteOptions::~LwpFootnoteOptions() {}
+
+/**
+ * @descr Register footnote options object
+ */
+void LwpFootnoteOptions::Read()
+{
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ m_FootnoteNumbering.Read(m_pObjStrm.get());
+ m_EndnoteDivisionNumbering.Read(m_pObjStrm.get());
+ m_EndnoteDivisionGroupNumbering.Read(m_pObjStrm.get());
+ m_EndnoteDocNumbering.Read(m_pObjStrm.get());
+ m_FootnoteSeparator.Read(m_pObjStrm.get());
+ m_FootnoteContinuedSeparator.Read(m_pObjStrm.get());
+ m_ContinuedOnMessage.Read(m_pObjStrm.get());
+ m_ContinuedFromMessage.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register footnote options style
+ */
+void LwpFootnoteOptions::RegisterStyle()
+{
+ RegisterFootnoteStyle();
+ RegisterEndnoteStyle();
+}
+
+/**
+ * @descr Register footnote configuration information
+ */
+void LwpFootnoteOptions::RegisterFootnoteStyle()
+{
+ std::unique_ptr<XFFootnoteConfig> xFootnoteConfig(new XFFootnoteConfig);
+ xFootnoteConfig->SetStartValue(m_FootnoteNumbering.GetStartingNumber() - 1);
+ xFootnoteConfig->SetNumPrefix(m_FootnoteNumbering.GetLeadingText());
+ xFootnoteConfig->SetNumSuffix(m_FootnoteNumbering.GetTrailingText());
+ if (m_FootnoteNumbering.GetReset() == LwpFootnoteNumberOptions::RESET_PAGE)
+ {
+ xFootnoteConfig->SetRestartOnPage();
+ }
+ if (GetContinuedFrom())
+ {
+ xFootnoteConfig->SetMessageFrom(GetContinuedFromMessage());
+ }
+ if (GetContinuedOn())
+ {
+ xFootnoteConfig->SetMessageOn(GetContinuedOnMessage());
+ }
+
+ xFootnoteConfig->SetMasterPage(m_strMasterPage);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pXFStyleManager->SetFootnoteConfig(xFootnoteConfig.release());
+}
+
+/**
+ * @descr Register endnote configuration information
+ */
+void LwpFootnoteOptions::RegisterEndnoteStyle()
+{
+ std::unique_ptr<XFEndnoteConfig> xEndnoteConfig(new XFEndnoteConfig);
+ xEndnoteConfig->SetStartValue(m_EndnoteDocNumbering.GetStartingNumber() - 1);
+ OUString message = m_EndnoteDocNumbering.GetLeadingText();
+ if (message.isEmpty())
+ {
+ message = "["; //default prefix
+ }
+ xEndnoteConfig->SetNumPrefix(message);
+ message = m_EndnoteDocNumbering.GetTrailingText();
+ if (message.isEmpty())
+ {
+ message = "]"; //default suffix
+ }
+ xEndnoteConfig->SetNumSuffix(message);
+ if (m_EndnoteDocNumbering.GetReset() == LwpFootnoteNumberOptions::RESET_PAGE)
+ {
+ xEndnoteConfig->SetRestartOnPage();
+ }
+
+ xEndnoteConfig->SetMasterPage(m_strMasterPage);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pXFStyleManager->SetEndnoteConfig(xEndnoteConfig.release());
+}
+
+/**
+ * @descr Get continue on message
+ */
+OUString LwpFootnoteOptions::GetContinuedOnMessage() const
+{
+ if (m_ContinuedOnMessage.HasValue())
+ {
+ return m_ContinuedOnMessage.str();
+ }
+ // else return default message
+ return STRID_FOOTCONTINUEDON;
+}
+
+/**
+ * @descr Get continue from message
+ */
+OUString LwpFootnoteOptions::GetContinuedFromMessage() const
+{
+ if (m_ContinuedFromMessage.HasValue())
+ {
+ return m_ContinuedFromMessage.str();
+ }
+ // else return default message
+ return STRID_FOOTCONTINUEDFROM;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfootnote.hxx b/lotuswordpro/source/filter/lwpfootnote.hxx
new file mode 100644
index 000000000..b1743df94
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfootnote.hxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * footnote
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFOOTNOTE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFOOTNOTE_HXX
+
+#include <lwpfrib.hxx>
+#include <lwpobj.hxx>
+#include "lwpsection.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwptable.hxx"
+
+// Footnote types are built up from these numbers
+#define FN_MASK_ENDNOTE 0x80
+#define FN_MASK_SEPARATE 0x40
+#define FN_MASK_DEACTIVATED 0x20
+#define FN_MASK_BASE (0x0f | FN_MASK_ENDNOTE)
+#define FN_BASE_DONTCARE 0
+#define FN_BASE_FOOTNOTE 1
+#define FN_BASE_DIVISION (2 | FN_MASK_ENDNOTE)
+#define FN_BASE_DIVISIONGROUP (3 | FN_MASK_ENDNOTE)
+#define FN_BASE_DOCUMENT (4 | FN_MASK_ENDNOTE)
+
+// Here are the real footnote types
+#define FN_DONTCARE (FN_BASE_DONTCARE)
+#define FN_FOOTNOTE (FN_BASE_FOOTNOTE)
+#define FN_DIVISION (FN_BASE_DIVISION)
+#define FN_DIVISION_SEPARATE (FN_BASE_DIVISION | FN_MASK_SEPARATE)
+#define FN_DIVISIONGROUP (FN_BASE_DIVISIONGROUP)
+#define FN_DIVISIONGROUP_SEPARATE (FN_BASE_DIVISIONGROUP | FN_MASK_SEPARATE)
+#define FN_DOCUMENT (FN_BASE_DOCUMENT)
+#define FN_DOCUMENT_SEPARATE (FN_BASE_DOCUMENT | FN_MASK_SEPARATE)
+inline constexpr OUStringLiteral STRID_FOOTCONTINUEDFROM = u"Continued from previous page...";
+inline constexpr OUStringLiteral STRID_FOOTCONTINUEDON = u"Continued on next page...";
+//Footnote table types, the string may have to do with local language
+inline constexpr OUStringLiteral STR_DivisionFootnote = u"DivisionFootnote";
+inline constexpr OUStringLiteral STR_DivisionEndnote = u"DivisionEndnote";
+inline constexpr OUStringLiteral STR_DivisionGroupEndnote = u"DivisionGroupEndnote";
+inline constexpr OUStringLiteral STR_DocumentEndnote = u"DocumentEndnote";
+
+/**
+ * @brief Footnote frib object
+*/
+class LwpFootnote;
+class LwpFribFootnote: public LwpFrib
+{
+
+public:
+ explicit LwpFribFootnote(LwpPara* pPara );
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void RegisterNewStyle();
+ void XFConvert(XFContentContainer* pCont);
+ LwpFootnote* GetFootnote();
+
+private:
+ LwpObjectID m_Footnote;
+};
+
+/**
+ * @brief VO_FOOTNOTE object
+*/
+class LwpEnSuperTableLayout;
+class LwpCellLayout;
+class LwpDocument;
+class LwpTable;
+class LwpFootnote : public LwpOrderedObject
+{
+public:
+ LwpFootnote(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFootnote() override;
+ void RegisterStyle() override;
+ void XFConvert(XFContentContainer * pCont) override;
+protected:
+ void Read() override;
+private:
+ sal_uInt16 m_nType;
+ sal_uInt16 m_nRow;
+ LwpObjectID m_Content;
+public:
+ sal_uInt16 GetType() const { return m_nType;}
+private:
+ LwpCellLayout* GetCellLayout();
+ LwpDocument* GetFootnoteTableDivision();
+ LwpDocument* GetEndnoteDivision(LwpDocument* pPossible);
+ LwpEnSuperTableLayout* FindFootnoteTableLayout();
+ LwpContent* FindFootnoteContent();
+ OUString GetTableClass() const;
+};
+
+/**
+ * @brief VO_FOOTNOTETABLE object
+*/
+class LwpFootnoteTable : public LwpTable
+{
+public:
+ LwpFootnoteTable(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief footnote number options information
+*/
+class LwpFootnoteNumberOptions
+{
+public:
+ LwpFootnoteNumberOptions()
+ : m_nFlag(0)
+ , m_nStartingNumber(0)
+ {}
+
+ void Read(LwpObjectStream* pObjStrm);
+private:
+ sal_uInt16 m_nFlag;
+ sal_uInt16 m_nStartingNumber;
+ LwpAtomHolder m_LeadingText;
+ LwpAtomHolder m_TrailingText;
+public:
+ enum // for flag
+ {
+ RESET_DOCUMENT = 0x00, // i.e., never reset the numbering
+ RESET_PAGE = 0x01,
+ RESET_DIVISION = 0x02,
+ RESET_DIVISIONGROUP = 0x04,
+ RESET_MASK = (RESET_PAGE | RESET_DIVISION | RESET_DIVISIONGROUP |
+ RESET_DOCUMENT),
+ SUPERSCRIPT_REFERENCE = 0x10
+ };
+public:
+ sal_uInt16 GetStartingNumber() const { return m_nStartingNumber;}
+ OUString const & GetLeadingText() const { return m_LeadingText.str();}
+ OUString const & GetTrailingText() const { return m_TrailingText.str();}
+ sal_uInt16 GetReset() const { return static_cast<sal_uInt16>(m_nFlag & RESET_MASK);}
+};
+
+/**
+ * @brief footnote separator options information
+*/
+class LwpFootnoteSeparatorOptions
+{
+public:
+ LwpFootnoteSeparatorOptions()
+ : m_nFlag(0)
+ , m_nLength(0)
+ , m_nIndent(0)
+ , m_nAbove(0)
+ , m_nBelow(0)
+ {}
+
+ void Read(LwpObjectStream* pObjStrm);
+private:
+ sal_uInt16 m_nFlag;
+ sal_uInt32 m_nLength;
+ sal_uInt32 m_nIndent;
+ sal_uInt32 m_nAbove;
+ sal_uInt32 m_nBelow;
+ LwpBorderStuff m_BorderStuff;
+public:
+ enum // for flag
+ {
+ HAS_SEPARATOR = 0x01,
+ CUSTOM_LENGTH = 0x02
+ };
+ sal_uInt32 GetLength() const { return m_nLength;}
+ sal_uInt32 GetIndent() const { return m_nIndent;}
+ sal_uInt32 GetAbove() const { return m_nAbove;}
+ sal_uInt32 GetBelow() const { return m_nBelow;}
+ bool HasCustomLength() const { return (m_nFlag & CUSTOM_LENGTH) != 0;}
+ bool HasSeparator() const { return (m_nFlag & HAS_SEPARATOR) != 0;}
+ float GetTopBorderWidth(){ return m_BorderStuff.GetSideWidth(LwpBorderStuff::TOP);}
+ LwpColor GetTopBorderColor(){ return m_BorderStuff.GetSideColor(LwpBorderStuff::TOP);}
+};
+
+/**
+ * @brief VO_FOOTNOTEOPTS object
+*/
+class LwpFootnoteOptions final : public LwpObject
+{
+public:
+ LwpFootnoteOptions(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ void RegisterStyle() override;
+private:
+ void Read() override;
+ void RegisterFootnoteStyle();
+ void RegisterEndnoteStyle();
+ virtual ~LwpFootnoteOptions() override;
+
+ sal_uInt16 m_nFlag;
+ LwpFootnoteNumberOptions m_FootnoteNumbering;
+ LwpFootnoteNumberOptions m_EndnoteDivisionNumbering;
+ LwpFootnoteNumberOptions m_EndnoteDivisionGroupNumbering;
+ LwpFootnoteNumberOptions m_EndnoteDocNumbering;
+ LwpFootnoteSeparatorOptions m_FootnoteSeparator;
+ LwpFootnoteSeparatorOptions m_FootnoteContinuedSeparator;
+ LwpAtomHolder m_ContinuedOnMessage;
+ LwpAtomHolder m_ContinuedFromMessage;
+ OUString m_strMasterPage;
+ enum
+ {
+ FO_REPEAT = 0x0001,
+ FO_CONTINUEFROM = 0x0002,
+ FO_CONTINUEON = 0x0004,
+ FO_ON_CENTER = 0x0008,
+ FO_ON_RIGHT = 0x0010,
+ FO_ON_ALIGNMASK = FO_ON_CENTER | FO_ON_RIGHT,
+ FO_FROM_CENTER = 0x0020,
+ FO_FROM_RIGHT = 0x0040,
+ FO_FROM_ALIGNMASK = FO_FROM_CENTER | FO_FROM_RIGHT
+ };
+
+public:
+ LwpFootnoteSeparatorOptions& GetFootnoteSeparator(){ return m_FootnoteSeparator;}
+ bool GetContinuedFrom() const { return ((m_nFlag & FO_CONTINUEFROM) != 0);}
+ bool GetContinuedOn() const { return ((m_nFlag & FO_CONTINUEON) != 0);}
+ OUString GetContinuedOnMessage() const;
+ OUString GetContinuedFromMessage() const;
+ void SetMasterPage(const OUString& strMasterPage){ m_strMasterPage = strMasterPage;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
new file mode 100644
index 000000000..07a5c872a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -0,0 +1,532 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpfoundry.hxx>
+#include <lwpfilehdr.hxx>
+#include "lwpdoc.hxx"
+#include "lwpmarker.hxx"
+#include "lwpholder.hxx"
+#include "lwpbulletstylemgr.hxx"
+#include "lwpcontent.hxx"
+#include "lwpvpointer.hxx"
+#include "lwpsection.hxx"
+#include "lwpcharacterstyle.hxx"
+#include <lwpglobalmgr.hxx>
+#include <lwpobjtags.hxx>
+#include <xfilter/xfstylemanager.hxx>
+
+#include <osl/diagnose.h>
+
+LwpFoundry::LwpFoundry(LwpObjectStream *pStrm, LwpDocument* pDoc)
+ : m_pDoc(pDoc)
+ , m_bRegisteredAll(false)
+{
+ Read(pStrm);
+ m_xDropcapMgr.reset(new LwpDropcapMgr);
+ m_xBulletStyleMgr.reset(new LwpBulletStyleMgr);
+ m_xBulletStyleMgr->SetFoundry(this);
+}
+
+LwpFoundry::~LwpFoundry()
+{
+}
+
+void LwpFoundry::Read(LwpObjectStream *pStrm)
+{
+ if (!m_pDoc->IsChildDoc())
+ {
+ LwpVersionManager::Read(pStrm);
+ }
+ m_ObjMgr.Read(pStrm);
+
+ m_MarkerHead.ReadIndexed(pStrm);
+ m_FootnoteMgr.ReadIndexed(pStrm);
+
+ m_NumMgr.Read(pStrm);
+ m_BulMgr.Read(pStrm);
+
+ m_SectionList.Read(pStrm);
+ m_Layout.ReadIndexed(pStrm);
+
+ ReadStyles(pStrm);
+
+ m_BookMarkHead.ReadIndexed(pStrm);
+ m_DdeLinkHead.ReadIndexed(pStrm);
+ m_DirtBagHead.ReadIndexed(pStrm);
+ m_NamedOutlineSeqHead.ReadIndexed(pStrm);
+
+ m_EnumLayoutHead.ReadIndexed(pStrm);
+ m_EnumLayoutTail.ReadIndexed(pStrm);
+ m_NamedObjects.ReadIndexed(pStrm);
+
+ m_nLastClickHere = pStrm->QuickReaduInt32();
+ m_SmartTextMgr.ReadIndexed(pStrm);
+
+ m_ContentMgr.Read(pStrm);
+ m_FontMgr.Read(pStrm);
+
+ if (!m_pDoc->IsChildDoc() && LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_xPieceMgr.reset(new LwpPieceManager);
+ m_xPieceMgr->Read(pStrm);
+ }
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_DftDropCapStyle.ReadIndexed(pStrm);
+ }
+ if( LwpFileHeader::m_nFileRevision >= 0x000F)
+ {
+ m_DftHeaderStyle.ReadIndexed(pStrm);
+ m_DftFooterStyle.ReadIndexed(pStrm);
+ }
+ pStrm->SkipExtra();
+
+ m_xStyleMgr.reset(new LwpStyleManager);
+ m_xStyleMgr->SetFoundry(this);
+}
+
+void LwpFoundry::ReadStyles(LwpObjectStream *pStrm)
+{
+ m_TextStyle.ReadIndexed(pStrm);
+ m_DefaultTextStyle.ReadIndexed(pStrm);
+ m_DefaultClickStyle.ReadIndexed(pStrm);
+ m_PageStyle.ReadIndexed(pStrm);
+ m_FrameStyle.ReadIndexed(pStrm);
+
+ m_TableStyle.ReadIndexed(pStrm);
+ m_CellStyle.ReadIndexed(pStrm);
+ m_DftFrameStyle.ReadIndexed(pStrm);
+ m_DftPageStyle.ReadIndexed(pStrm);
+ m_DftTableStyle.ReadIndexed(pStrm);
+
+ m_DftCellStyle.ReadIndexed(pStrm);
+ m_DftColumnStyle.ReadIndexed(pStrm);
+ m_DftLeftColumnStyle.ReadIndexed(pStrm);
+ m_DftRighColumnStyle.ReadIndexed(pStrm);
+
+}
+
+void LwpFoundry::RegisterAllLayouts()
+{
+ if (m_bRegisteredAll)
+ {
+ OSL_FAIL("recursive LwpFoundry::RegisterAllLayouts!");
+ return;
+ }
+
+ m_bRegisteredAll = true;
+
+ //Register CellStyle
+ rtl::Reference<LwpObject> pStyle = m_CellStyle.obj();
+ if( pStyle.is() )
+ {
+ pStyle->SetFoundry(this);
+ pStyle->DoRegisterStyle();
+ }
+
+ //register content page layout list: Layout
+ pStyle = m_Layout.obj();
+ if( pStyle.is() )
+ {
+ pStyle->SetFoundry(this);
+ pStyle->DoRegisterStyle();
+ }
+
+ //Register page style layout list: PageStyle, such as "Default Page"
+ pStyle = m_PageStyle.obj();
+ if( pStyle.is() )
+ {
+ pStyle->SetFoundry(this);
+ pStyle->DoRegisterStyle();
+ }
+
+ //Register FrameStyle
+ pStyle = m_FrameStyle.obj();
+ if( pStyle.is() )
+ {
+ pStyle->SetFoundry(this);
+ pStyle->DoRegisterStyle();
+ }
+
+}
+
+LwpBookMark* LwpFoundry::GetBookMark(LwpObjectID objMarker)
+{
+ LwpDLVListHeadHolder* pHeadHolder= dynamic_cast
+ <LwpDLVListHeadHolder*>(m_BookMarkHead.obj().get());
+
+ if (!pHeadHolder)
+ return nullptr;
+
+ LwpObjectID* pObjID = &pHeadHolder->GetHeadID();
+ LwpBookMark* pBookMark = dynamic_cast<LwpBookMark*>(pObjID->obj().get());
+
+ while (pBookMark)
+ {
+ if (pBookMark->IsRightMarker(objMarker))
+ return pBookMark;
+ pObjID = &pBookMark->GetNext();
+ pBookMark = dynamic_cast<LwpBookMark*>(pObjID->obj().get());
+ }
+ return nullptr;
+}
+
+/**
+* @descr: Get next content
+*
+*/
+LwpContent* LwpFoundry::EnumContents(LwpContent * pContent)
+{
+ return GetContentManager().EnumContents(pContent);
+}
+
+/**
+* @descr: Get next section
+*
+*/
+LwpSection* LwpFoundry::EnumSections(LwpSection * pSection)
+{
+ return static_cast<LwpSection*>(m_SectionList.Enumerate(pSection));
+}
+
+/**
+* @descr: Get default text style id
+*
+*/
+LwpObjectID * LwpFoundry::GetDefaultTextStyle()
+{
+ LwpVersionedPointer * pPointer = dynamic_cast<LwpVersionedPointer *>(m_DefaultTextStyle.obj().get());
+ if (!pPointer)
+ return nullptr;
+
+ return &pPointer->GetPointer();
+}
+
+/**
+* @descr: Get paragraph style object id according to its style name
+*
+*/
+LwpObjectID * LwpFoundry::FindParaStyleByName(std::u16string_view name)
+{
+ LwpDLVListHeadHolder* pParaStyleHolder = dynamic_cast<LwpDLVListHeadHolder*>(GetTextStyleHead().obj().get());
+ if(pParaStyleHolder)
+ {
+ LwpTextStyle* pParaStyle = dynamic_cast<LwpTextStyle*> (pParaStyleHolder->GetHeadID().obj().get());
+ while(pParaStyle)
+ {
+ OUString strName = pParaStyle->GetName().str();
+ if(strName == name)
+ return &pParaStyle->GetObjectID();
+ pParaStyle = dynamic_cast<LwpTextStyle*>(pParaStyle->GetNext().obj().get());
+ }
+ }
+
+ return nullptr;
+}
+
+/**
+* @descr: Get style name registered according the original style name
+*
+*/
+OUString LwpFoundry::FindActualStyleName(const OUString& name)
+{
+ LwpObjectID* pID = FindParaStyleByName(name);
+ if(pID)
+ {
+ IXFStyle* pStyle = GetStyleManager()->GetStyle(*pID);
+ if(pStyle)
+ {
+ return pStyle->GetStyleName();
+ }
+ }
+
+ return name;
+}
+
+void LwpVersionManager::Read(LwpObjectStream *pStrm)
+{
+ // TODO: skip the data for prototype
+ Skip(pStrm);
+}
+
+void LwpVersionManager::Skip(LwpObjectStream *pStrm)
+{
+ pStrm->QuickReaduInt32();
+ sal_uInt16 Count = pStrm->QuickReaduInt16();
+
+ while(Count--)
+ {
+ sal_uInt32 tag = pStrm->QuickReaduInt32();
+ switch(tag)
+ {
+ case TAG_USER_VERSION:
+ // TODO: skip the CUserVersionControl
+ pStrm->SeekRel(pStrm->QuickReaduInt16());
+ break;
+
+ default:
+ pStrm->SeekRel(pStrm->QuickReaduInt16());
+ pStrm->SkipExtra();
+ break;
+ }
+ }
+ pStrm->SkipExtra();
+}
+
+void LwpObjectManager::Read(LwpObjectStream *pStrm)
+{
+
+ LwpObjectID dummy;
+ dummy.Read(pStrm);
+ // TODO: judge if we need to set the cDelta by the dummy id
+
+ m_Division.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+}
+
+void LwpNumberManager::Read(LwpObjectStream *pStrm)
+{
+ m_TableRange.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+}
+
+void LwpBulletManager::Read(LwpObjectStream *pStrm)
+{
+ m_Head.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+}
+
+void LwpContentManager::Read(LwpObjectStream *pStrm)
+{
+ m_ContentList.ReadIndexed(pStrm);
+
+ // TODO: to judge the file revision
+
+ m_EnumHead.ReadIndexed(pStrm);
+ m_EnumTail.ReadIndexed(pStrm);
+
+ m_OleObjCount.ReadIndexed(pStrm);
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_GrapHead.ReadIndexed(pStrm);
+ m_GrapTail.ReadIndexed(pStrm);
+ m_OleHead.ReadIndexed(pStrm);
+ m_OleTail.ReadIndexed(pStrm);
+ }
+
+ pStrm->SkipExtra();
+}
+
+/**
+* @descr: Get next content
+*
+*/
+LwpContent* LwpContentManager::EnumContents(LwpContent* pContent)
+{
+ if(pContent)
+ return pContent->GetNextEnumerated();
+ LwpVersionedPointer* pPointer = dynamic_cast<LwpVersionedPointer*>(m_EnumHead.obj().get());
+ return pPointer ? dynamic_cast<LwpContent*>(pPointer->GetPointer().obj().get()) : nullptr;
+}
+
+void LwpPieceManager::Read(LwpObjectStream *pStrm)
+{
+ m_GeometryPieceList.ReadIndexed(pStrm);
+ m_ScalePieceList.ReadIndexed(pStrm);
+ m_MarginsPieceList.ReadIndexed(pStrm);
+ m_ColumnsPieceList.ReadIndexed(pStrm);
+ m_BorderStuffPieceList.ReadIndexed(pStrm);
+
+ m_GutterStuffPieceList.ReadIndexed(pStrm);
+ m_BackgroundStuffPieceList.ReadIndexed(pStrm);
+ m_JoinStuffPieceList.ReadIndexed(pStrm);
+ m_ShadowPieceList.ReadIndexed(pStrm);
+ m_NumericsPieceList.ReadIndexed(pStrm);
+
+ m_RelativityPieceList.ReadIndexed(pStrm);
+ m_AlignmentPieceList.ReadIndexed(pStrm);
+ m_IndentPieceList.ReadIndexed(pStrm);
+ m_ParaBorderPieceList.ReadIndexed(pStrm);
+ m_SpacingPieceList.ReadIndexed(pStrm);
+
+ m_BreaksPieceList.ReadIndexed(pStrm);
+ m_NumberingPieceList.ReadIndexed(pStrm);
+ m_TabPieceList.ReadIndexed(pStrm);
+ m_CharacterBorderPieceList.ReadIndexed(pStrm);
+ m_AmikakePieceList.ReadIndexed(pStrm);
+
+ if(pStrm->CheckExtra())
+ {
+ m_ParaBackgroundPieceList.ReadIndexed(pStrm);
+ m_ExternalBorderStuffPieceList.ReadIndexed(pStrm);
+ m_ExternalJoinStuffPieceList.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+ }
+}
+
+void LwpOrderedObjectManager::Read(LwpObjectStream *pStrm)
+{
+ m_Head.ReadIndexed(pStrm);
+}
+
+/**
+* @descr: Get next orderedobject, copy from lwp source code
+*
+*/
+LwpOrderedObject* LwpOrderedObjectManager::Enumerate(LwpOrderedObject * pLast)
+{
+ // If Last has a next, return it.
+ if(pLast && !pLast->GetNext().IsNull())
+ return dynamic_cast<LwpOrderedObject*>(pLast->GetNext().obj().get());
+
+ LwpListList* pList = nullptr;
+ if(pLast)
+ {
+ // We're at the end of Last's list (not list's list).
+ // Start with the next active list
+ pList = dynamic_cast<LwpListList*>(pLast->GetListList().obj().get());
+ pList= GetNextActiveListList(pList);
+ }
+ else
+ {
+ // Start with the first active ListList
+ pList = GetNextActiveListList(nullptr);
+ }
+
+ if(pList)
+ {
+ return dynamic_cast<LwpOrderedObject*>(pList->GetHead().obj().get());
+ }
+
+ return nullptr;
+}
+
+/**
+* @descr: Get next listlist object, copy from lwp source code
+*
+*/
+LwpListList* LwpOrderedObjectManager::GetNextActiveListList(LwpListList * pLast)
+{
+ LwpListList* pList = nullptr;
+ if(pLast)
+ pList = dynamic_cast<LwpListList*>(pLast->GetNext().obj().get());
+ else
+ {
+ LwpDLVListHeadHolder* pHeadHolder= dynamic_cast<LwpDLVListHeadHolder*>(m_Head.obj().get());
+ if(pHeadHolder)
+ {
+ pList = dynamic_cast<LwpListList*>(pHeadHolder->GetHeadID().obj().get());
+ }
+ }
+
+ while(pList)
+ {
+ LwpContent* pContent = dynamic_cast<LwpContent*>(pList->GetObject().obj().get());
+ if (pContent && pContent->HasNonEmbeddedLayouts() && !pContent->IsStyleContent())
+ return pList;
+ pList = dynamic_cast<LwpListList*>(pList->GetNext().obj().get());
+ }
+ return nullptr;
+}
+
+LwpStyleManager::LwpStyleManager()
+ : m_pFoundry(nullptr)
+{
+}
+
+LwpStyleManager::~LwpStyleManager()
+{
+ m_StyleList.clear();
+}
+
+/*
+VO_PARASTYLE/VO_CHARACTERSTYLE call this method to add its created style to XFStyleManager
+1. Add the style to XFStyleManager, and return the <office:styles> style name
+2. Add it to LwpParaStyleMap.
+Prerequisite: pStyle has been created and all properties has been set to it.
+Return the XFStyle* added by XFStyleManager
+*/
+void LwpStyleManager::AddStyle(LwpObjectID styleObjID, std::unique_ptr<IXFStyle> pNewStyle)
+{
+ assert(pNewStyle);
+ //pStyle may change if same style is found in XFStyleManager
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ auto pStyle = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle;
+ m_StyleList.emplace(styleObjID, pStyle);
+}
+
+/*
+Called by VO_PARA or other objects to get style name based on the Style object ID
+1) Get style from LwpParaStyleMap based on the LwpObjectID of VO_PARASTYLE.
+Prerequisite: VO_PARASTYLE/VO_CHARACTERSTYLE should call AddStyle first.
+Return empty string if no style found.
+*/
+IXFStyle* LwpStyleManager::GetStyle(const LwpObjectID &styleObjID)
+{
+ LwpStyleMap::const_iterator it = m_StyleList.find(styleObjID);
+ if (it != m_StyleList.end()) {
+ return((*it).second);
+ }
+ return nullptr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
new file mode 100644
index 000000000..7c983b01a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -0,0 +1,1263 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * the class for VO_FrameLayout
+ ************************************************************************/
+
+#include <memory>
+#include <lwpfilehdr.hxx>
+#include "lwpcelllayout.hxx"
+#include "lwpframelayout.hxx"
+#include "lwppara.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xffloatframe.hxx>
+#include <xfilter/xfrubystyle.hxx>
+#include "lwpoleobject.hxx"
+#include <lwpglobalmgr.hxx>
+
+LwpFrame::LwpFrame(LwpPlacableLayout* pLayout)
+ : m_pLayout(pLayout)
+{
+}
+
+LwpFrame::~LwpFrame() {}
+/**
+* @descr: parse frame
+* @param: register frame style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::RegisterStyle(std::unique_ptr<XFFrameStyle>& rFrameStyle)
+{
+ ApplyWrapType(rFrameStyle.get());
+ ApplyMargins(rFrameStyle.get());
+ ApplyPadding(rFrameStyle.get());
+ ApplyBorders(rFrameStyle.get());
+ ApplyColumns(rFrameStyle.get());
+ ApplyShadow(rFrameStyle.get());
+ ApplyBackGround(rFrameStyle.get());
+ ApplyWatermark(rFrameStyle.get());
+ ApplyProtect(rFrameStyle.get());
+ ApplyTextDir(rFrameStyle.get());
+ ApplyPosType(rFrameStyle.get());
+
+ rFrameStyle->SetStyleName(m_pLayout->GetName().str());
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(rFrameStyle)).m_pStyle->GetStyleName();
+ m_pLayout->SetStyleName(m_StyleName);
+}
+
+/**
+* @descr: parse frame and set frame properties
+* @param: pXFFrame - XFFrame object
+* @param: nPageNo - the page number that the frame anchors
+*
+*/
+void LwpFrame::Parse(XFFrame* pXFFrame, sal_Int32 nPageNo)
+{
+ //set the frame style name
+ pXFFrame->SetStyleName(m_StyleName);
+
+ //SetAnchorType and position,if it's page anchor,set the page number.
+ ParseAnchorType(pXFFrame);
+ if (nPageNo > 0)
+ {
+ pXFFrame->SetAnchorPage(nPageNo);
+ }
+
+ //Set frame Name
+ OUString aFrameName = m_pLayout->GetName().str();
+ if (!aFrameName.isEmpty())
+ {
+ //cause the bug of SODC, the linkframe name can not be "Frame1", so I change the frame name
+ /*if(aFrameName.equals("Frame1"))
+ {
+ aFrameName = "Frame1_COPY";
+ }
+ pXFFrame->SetName(aFrameName);*/
+ pXFFrame->SetName(m_StyleName);
+ }
+
+ LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
+ //Set frame Width and height
+ if (pLayoutGeo)
+ {
+ double fWidth = m_pLayout->GetWidth();
+ double fHeight = m_pLayout->GetHeight();
+
+ pXFFrame->SetWidth(fWidth);
+ pXFFrame->SetHeight(fHeight);
+
+ //Get content obj;
+ /*LwpObject* pObj =*/m_pLayout->GetContent().obj();
+ if (m_pLayout->IsGroupHead() && (m_pLayout->IsMinimumHeight()))
+ {
+ //process grouplayout height. there is problems now
+ pXFFrame->SetHeight(fHeight);
+ }
+ /*
+ else if(m_pLayout->IsFitGraphic() && pObj && pObj->GetTag() == VO_GRAPHIC)
+ {
+ //If is graphic, get original size and set it;
+ LwpGraphicObject* pGrpObj = static_cast<LwpGraphicObject*>(pObj);
+ long nHeight =0, nWidth =0;
+ pGrpObj->GetGrafOrgSize(nWidth, nHeight);
+ //add margins to the width and height;
+ fWidth = (double)nWidth/TWIPS_PER_CM + m_pLayout->GetMarginsValue(MARGIN_LEFT) + m_pLayout->GetMarginsValue(MARGIN_RIGHT);
+ fHeight = (double)nHeight/TWIPS_PER_CM + m_pLayout->GetMarginsValue(MARGIN_TOP) + m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
+ pXFFrame->SetWidth(fWidth);
+ pXFFrame->SetHeight(fHeight);
+ }
+ */
+ else if (m_pLayout->IsAutoGrow())
+ {
+ pXFFrame->SetMinHeight(fHeight);
+ }
+ }
+
+ if (m_pLayout->IsFrame())
+ {
+ //Set frame link. Only frame layout has this feature
+ LwpFrameLayout* pLayout = static_cast<LwpFrameLayout*>(m_pLayout);
+ pXFFrame->SetNextLink(pLayout->GetNextLinkName());
+ }
+}
+/**
+* @descr: parse frame relative to page, frame or cell
+* @param: pCont - content container which contains the frame
+*
+*/
+void LwpFrame::XFConvert(XFContentContainer* pCont)
+{
+ // parse the frame which anchor to page
+ rtl::Reference<LwpVirtualLayout> xParent = m_pLayout->GetParentLayout();
+ if (!xParent.is())
+ throw std::runtime_error("missing Parent Layout");
+ if (xParent->IsPage() && xParent->GetParentLayout().is()
+ && xParent->GetParentLayout()->IsPage())
+ {
+ //for mirror page, problems exist if the parent layout is header or footer layout,
+ xParent = xParent->GetParentLayout();
+ }
+ if (m_pLayout->IsAnchorPage() && xParent->IsPage())
+ {
+ //get parent layout
+ if (m_pLayout->IsUseOnPage())
+ {
+ sal_Int32 nPageNo = xParent->GetPageNumber(m_pLayout->GetUsePage());
+ if (nPageNo > 0)
+ m_pLayout->XFConvertFrame(pCont, nPageNo);
+ }
+ else if (m_pLayout->IsUseOnAllPages())
+ {
+ sal_Int32 nFirst = xParent->GetPageNumber(FIRST_LAYOUTPAGENO);
+ sal_Int32 nLast = xParent->GetPageNumber(LAST_LAYOUTPAGENO);
+ if (nLast > 0)
+ m_pLayout->XFConvertFrame(pCont, nFirst, nLast, true);
+ }
+ else if (m_pLayout->IsUseOnAllOddPages() || m_pLayout->IsUseOnAllEvenPages())
+ {
+ sal_Int32 nFirst = xParent->GetPageNumber(FIRST_LAYOUTPAGENO);
+ sal_Int32 nLast = xParent->GetPageNumber(LAST_LAYOUTPAGENO);
+ if (nLast > 0)
+ {
+ sal_uInt16 first = static_cast<sal_uInt16>(nFirst);
+ if ((m_pLayout->IsUseOnAllOddPages() && !LwpTools::IsOddNumber(first))
+ || (m_pLayout->IsUseOnAllEvenPages() && !LwpTools::IsEvenNumber(first)))
+ nFirst++;
+ if (nFirst <= nLast)
+ {
+ m_pLayout->XFConvertFrame(pCont, nFirst, nLast);
+ }
+ }
+ }
+ }
+ else
+ {
+ m_pLayout->XFConvertFrame(pCont);
+ }
+}
+/**
+* @descr: set frame wrap type style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyWrapType(XFFrameStyle* pFrameStyle)
+{
+ enumXFWrap eWrap = enumXFWrapNone;
+ switch (m_pLayout->GetWrapType())
+ {
+ case LwpPlacableLayout::LAY_WRAP_AROUND: //fall through
+ case LwpPlacableLayout::LAY_WRAP_IRREG_BIGGEST:
+ {
+ //In SODC, if Optimal wrap type is used and the distance between the frame object
+ //and page margins is less than 2cm, the text is not wrapped. While there is no this feature in Word Pro
+ //So the optimal wrap type is translated to left side or right side wrap type according to the distance
+ //between the frame object and page margins
+
+ eWrap = enumXFWrapBest;
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ LwpMiddleLayout* pParent = dynamic_cast<LwpMiddleLayout*>(xContainer.get());
+ if (pParent)
+ {
+ if (IsLeftWider())
+ eWrap = enumXFWrapLeft;
+ else
+ eWrap = enumXFWrapRight;
+ }
+ break;
+ }
+ case LwpPlacableLayout::LAY_NO_WRAP_BESIDE:
+ {
+ eWrap = enumXFWrapNone;
+ break;
+ }
+ case LwpPlacableLayout::LAY_NO_WRAP_AROUND:
+ {
+ eWrap = enumXFWrapRunThrough;
+ if (!m_pLayout->GetBackColor() && !m_pLayout->GetWaterMarkLayout().is())
+ {
+ //pFrameStyle->SetBackGround(sal_True);
+ XFColor aXFColor(0xffffff); //white color
+ pFrameStyle->SetBackColor(aXFColor);
+ pFrameStyle->SetTransparency(100); //transparency
+ }
+ break;
+ }
+ case LwpPlacableLayout::LAY_WRAP_LEFT: //fall through
+ case LwpPlacableLayout::LAY_WRAP_IRREG_LEFT:
+ {
+ eWrap = enumXFWrapLeft;
+ break;
+ }
+ case LwpPlacableLayout::LAY_WRAP_RIGHT: //fall through
+ case LwpPlacableLayout::LAY_WRAP_IRREG_RIGHT:
+ {
+ eWrap = enumXFWrapRight;
+ break;
+ }
+ case LwpPlacableLayout::LAY_WRAP_BOTH: //fall through
+ case LwpPlacableLayout::LAY_WRAP_IRREG_BOTH:
+ {
+ eWrap = enumXFWrapParallel;
+ break;
+ }
+ default:
+ break;
+ }
+
+ //If it is the type of with para above, wrap type is enumXFWrapNone
+ if (m_pLayout->GetRelativeType() == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
+ {
+ eWrap = enumXFWrapNone;
+ }
+
+ pFrameStyle->SetWrapType(eWrap);
+}
+/**
+* @descr: set frame margins style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyMargins(XFFrameStyle* pFrameStyle)
+{
+ double fLeft = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
+ double fRight = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
+ double fTop = m_pLayout->GetExtMarginsValue(MARGIN_TOP);
+ double fBottom = m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM);
+ pFrameStyle->SetMargins(fLeft, fRight, fTop, fBottom);
+}
+/**
+* @descr: set padding border style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyPadding(XFFrameStyle* pFrameStyle)
+{
+ double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT);
+ double fRight = m_pLayout->GetMarginsValue(MARGIN_RIGHT);
+ double fTop = m_pLayout->GetMarginsValue(MARGIN_TOP);
+ double fBottom = m_pLayout->GetMarginsValue(MARGIN_BOTTOM);
+ pFrameStyle->SetPadding(fLeft, fRight, fTop, fBottom);
+}
+/**
+* @descr: set frame border style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyBorders(XFFrameStyle* pFrameStyle)
+{
+ std::unique_ptr<XFBorders> pBordres = m_pLayout->GetXFBorders();
+ if (pBordres)
+ {
+ pFrameStyle->SetBorders(std::move(pBordres));
+ }
+}
+/**
+* @descr: set frame columns style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyColumns(XFFrameStyle* pFrameStyle)
+{
+ XFColumns* pColumns = m_pLayout->GetXFColumns();
+ if (pColumns)
+ {
+ pFrameStyle->SetColumns(pColumns);
+ }
+}
+/**
+* @descr: set frame shadow style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyShadow(XFFrameStyle* pFrameStyle)
+{
+ XFShadow* pXFShadow = m_pLayout->GetXFShadow();
+ if (pXFShadow)
+ {
+ pFrameStyle->SetShadow(pXFShadow);
+ }
+}
+/**
+* @descr: set frame back color style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyBackColor(XFFrameStyle* pFrameStyle)
+{
+ LwpColor* pColor = m_pLayout->GetBackColor();
+ if (pColor)
+ {
+ XFColor aXFColor(pColor->To24Color());
+ pFrameStyle->SetBackColor(aXFColor);
+ }
+}
+/**
+* @descr: set frame protect style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyProtect(XFFrameStyle* pFrameStyle)
+{
+ if (m_pLayout->GetIsProtected())
+ {
+ pFrameStyle->SetProtect(true, true, true);
+ }
+}
+/**
+* @descr: set frame text direction style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyTextDir(XFFrameStyle* pFrameStyle)
+{
+ pFrameStyle->SetTextDir(m_pLayout->GetTextDirection());
+}
+/**
+* @descr: set frame position type style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyPosType(XFFrameStyle* pFrameStyle)
+{
+ enumXFFrameXPos eXPos = enumXFFrameXPosCenter;
+ enumXFFrameXRel eXRel = enumXFFrameXRelPara;
+ enumXFFrameYPos eYPos = enumXFFrameYPosMiddle;
+ enumXFFrameYRel eYRel = enumXFFrameYRelPara;
+ sal_uInt8 nType = m_pLayout->GetRelativeType();
+ switch (nType)
+ {
+ case LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE: //fall through
+ case LwpLayoutRelativityGuts::LAY_CONTENT_RELATIVE:
+ {
+ //anchor to page, frame and cell
+ eXPos = enumXFFrameXPosFromLeft;
+ eXRel = enumXFFrameXRelPage;
+ //set vertical position
+ if (m_pLayout->IsAnchorPage()) //in page
+ {
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ if (xContainer.is() && (xContainer->IsHeader() || xContainer->IsFooter()))
+ {
+ //Only anchor to para, the frame can display in header and footer of each page
+ eYPos = enumXFFrameYPosFromTop; //from top
+ eYRel = enumXFFrameYRelPara; //from margin
+ }
+ else
+ {
+ eYPos = enumXFFrameYPosFromTop;
+ eYRel = enumXFFrameYRelPage;
+ }
+ }
+ if (m_pLayout->IsAnchorFrame()) //in frame
+ {
+ eYPos = enumXFFrameYPosFromTop;
+ eYRel = enumXFFrameYRelPage;
+ }
+ if (m_pLayout->IsAnchorCell())
+ {
+ //SODC has no this type, simulate this feature
+ eYPos = enumXFFrameYPosFromTop; //from top
+ eYRel = enumXFFrameYRelPara; //from margin
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE: //same page as text
+ {
+ eXPos = enumXFFrameXPosFromLeft;
+ eXRel = enumXFFrameXRelPage;
+ //set vertical position
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ if (xContainer.is() && xContainer->IsPage()) //in page
+ {
+ //eYPos = enumXFFrameYPosFromTop;
+ //eYRel = enumXFFrameYRelPage;
+ eYPos = enumXFFrameYPosBelow;
+ eYRel = enumXFFrameYRelChar;
+ }
+ else if (xContainer.is() && xContainer->IsFrame()) //in frame
+ {
+ eYPos = enumXFFrameYPosFromTop;
+ eYRel = enumXFFrameYRelPage;
+ }
+ else
+ {
+ eYPos = enumXFFrameYPosFromTop; //from top
+ eYRel = enumXFFrameYRelPara; //from margin
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE: //in text
+ {
+ eXPos = enumXFFrameXPosFromLeft; //need not be set
+ eXRel = enumXFFrameXRelParaContent; //need not be set
+ eYPos = enumXFFrameYPosTop; //should be from top
+ eYRel = enumXFFrameYRelBaseLine;
+ sal_Int32 nOffset = m_pLayout->GetBaseLineOffset();
+ if (nOffset > 0)
+ {
+ eYPos = enumXFFrameYPosFromTop;
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE: //with para above
+ {
+ eXPos = enumXFFrameXPosFromLeft;
+ eXRel = enumXFFrameXRelParaContent;
+ //eYPos = enumXFFrameYPosTop;
+ eYPos = enumXFFrameYPosBottom;
+ eYRel = enumXFFrameYRelParaContent;
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL: //in text - vertical
+ {
+ eXPos = enumXFFrameXPosFromLeft;
+ eXRel = enumXFFrameXRelPage;
+ eYPos = enumXFFrameYPosFromTop; //should be below position
+ eYRel = enumXFFrameYRelChar;
+ break;
+ }
+ default:
+ break;
+ }
+
+ pFrameStyle->SetXPosType(eXPos, eXRel);
+ pFrameStyle->SetYPosType(eYPos, eYRel);
+}
+/**
+* @descr: set frame watermark style
+* @param: pFrameStyle - Frame Style object
+*
+*/
+void LwpFrame::ApplyWatermark(XFFrameStyle* pFrameStyle)
+{
+ std::unique_ptr<XFBGImage> xBGImage(m_pLayout->GetXFBGImage());
+ if (xBGImage)
+ {
+ pFrameStyle->SetBackImage(xBGImage);
+ //set watermark transparent
+ rtl::Reference<LwpVirtualLayout> xWaterMarkLayout(m_pLayout->GetWaterMarkLayout());
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xWaterMarkLayout.get());
+ LwpBackgroundStuff* pBackgroundStuff = pLay ? pLay->GetBackgroundStuff() : nullptr;
+ if (pBackgroundStuff && !pBackgroundStuff->IsTransparent())
+ {
+ pFrameStyle->SetTransparency(100);
+ }
+ }
+}
+
+/**
+ * @short Apply pattern fill to frame style
+ * @param pFrameStyle - pointer of XFFrameStyle
+ * @return
+ */
+void LwpFrame::ApplyPatternFill(XFFrameStyle* pFrameStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(m_pLayout->GetFillPattern());
+ if (xXFBGImage)
+ {
+ pFrameStyle->SetBackImage(xXFBGImage);
+ }
+}
+
+/**
+ * @short Apply background to frame style
+ * @param pFrameStyle - pointer of XFFrameStyle
+ * @return
+ */
+void LwpFrame::ApplyBackGround(XFFrameStyle* pFrameStyle)
+{
+ if (!m_pLayout)
+ {
+ return;
+ }
+
+ if (m_pLayout->IsPatternFill())
+ {
+ ApplyPatternFill(pFrameStyle);
+ }
+ else
+ {
+ ApplyBackColor(pFrameStyle);
+ }
+}
+
+/**
+* @descr: set frame size, anchor type, anchored page number
+* @param: pXFFrame - XFFrame object
+*
+*/
+void LwpFrame::ParseAnchorType(XFFrame* pXFFrame)
+{
+ //set position
+ double fXOffset = 0;
+ double fYOffset = 0;
+ //set anchor type
+ enumXFAnchor eAnchor = enumXFAnchorNone;
+
+ LwpLayoutGeometry* pLayoutGeo = m_pLayout->GetGeometry();
+ if (pLayoutGeo)
+ {
+ LwpPoint aPoint = pLayoutGeo->GetOrigin();
+ fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
+ fYOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetY());
+ }
+ //set anchor type
+ eAnchor = enumXFAnchorNone;
+ sal_uInt8 nType = m_pLayout->GetRelativeType();
+ switch (nType)
+ {
+ case LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE: //fall through
+ case LwpLayoutRelativityGuts::LAY_CONTENT_RELATIVE:
+ {
+ //anchor to page, frame and cell
+ if (m_pLayout->IsAnchorPage()) //in page
+ {
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ if (xContainer.is() && (xContainer->IsHeader() || xContainer->IsFooter()))
+ {
+ eAnchor = enumXFAnchorPara;
+ fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
+ }
+ else
+ eAnchor = enumXFAnchorPage;
+ }
+ if (m_pLayout->IsAnchorFrame()) //in frame
+ {
+ eAnchor = enumXFAnchorFrame;
+ }
+ if (m_pLayout->IsAnchorCell()) //in cell
+ {
+ //eAnchor = enumXFAnchorChar;
+ eAnchor = enumXFAnchorPara;
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ LwpMiddleLayout* pContainer = dynamic_cast<LwpMiddleLayout*>(xContainer.get());
+ if (pContainer)
+ {
+ fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
+ }
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE: //same page as text
+ {
+ eAnchor = enumXFAnchorChar;
+ rtl::Reference<LwpVirtualLayout> xContainer(m_pLayout->GetContainerLayout());
+ if (xContainer.is() && xContainer->IsPage()) //in page
+ {
+ //eAnchor = enumXFAnchorPage;
+ eAnchor = enumXFAnchorChar; // to character
+ }
+ else if (xContainer.is() && xContainer->IsFrame()) //in frame
+ {
+ eAnchor = enumXFAnchorFrame;
+ }
+ else if (xContainer.is() && xContainer->IsCell()) //in cell
+ {
+ //eAnchor = enumXFAnchorChar;
+ eAnchor = enumXFAnchorPara;
+ fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
+ }
+ else if (xContainer.is()
+ && (xContainer->IsHeader() || xContainer->IsFooter())) //in header or footer
+ {
+ eAnchor = enumXFAnchorPara;
+ fYOffset -= xContainer->GetMarginsValue(MARGIN_TOP);
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE: //in text
+ {
+ eAnchor = enumXFAnchorAsChar;
+ sal_Int32 nOffset = m_pLayout->GetBaseLineOffset();
+ if (nOffset > 0 && pLayoutGeo)
+ {
+ //experiential value
+ fYOffset = -(m_pLayout->GetGeometryHeight()
+ + 2 * m_pLayout->GetExtMarginsValue(MARGIN_BOTTOM)
+ - LwpTools::ConvertFromUnitsToMetric(nOffset));
+ }
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE: //with para above
+ {
+ eAnchor = enumXFAnchorPara;
+ break;
+ }
+ case LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL: //in text - vertical
+ {
+ eAnchor = enumXFAnchorChar;
+ //set vertical position
+ double offset = 0;
+
+ //because of the different feature between Word Pro and SODC, I simulate the vertical base offset
+ //between anchor and frame origin using the font height.
+ rtl::Reference<XFFont> pFont = m_pLayout->GetFont();
+ if (pFont.is())
+ {
+ offset = static_cast<double>(pFont->GetFontSize()) * CM_PER_INCH / POINTS_PER_INCH;
+ }
+ fYOffset = offset - fYOffset;
+ break;
+ }
+ default:
+ break;
+ }
+
+ pXFFrame->SetX(fXOffset);
+ pXFFrame->SetY(fYOffset);
+ pXFFrame->SetAnchorPage(0);
+ pXFFrame->SetAnchorType(eAnchor);
+}
+
+/**
+ * @descr Calculate the distance between the frame object and the page margins.
+ * And determine which side(left or right) is wider
+ */
+bool LwpFrame::IsLeftWider()
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(m_pLayout->GetContainerLayout());
+ LwpVirtualLayout* pParent = xLayout.get();
+ if (!pParent)
+ return false;
+ LwpPoint aPoint = m_pLayout->GetOrigin();
+ double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
+ double fWidth = m_pLayout->GetWidth();
+ double fWrapLeft = m_pLayout->GetExtMarginsValue(MARGIN_LEFT);
+ double fWrapRight = m_pLayout->GetExtMarginsValue(MARGIN_RIGHT);
+
+ //LwpPoint aParentPoint = pParent->GetOrigin();
+ //double fParentXOffset = LwpTools::ConvertFromUnitsToMetric(aParentPoint.GetX());
+ double fParentWidth = pParent->GetWidth();
+ if (pParent->IsCell())
+ {
+ //Get actual width of this cell layout
+ fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
+ }
+ double fParentMarginLeft = pParent->GetMarginsValue(MARGIN_LEFT);
+ double fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
+
+ double fLeft = fXOffset - fWrapLeft - fParentMarginLeft;
+ double fRight = fParentWidth - fParentMarginRight - (fXOffset + fWidth + fWrapRight);
+ if (fLeft > fRight)
+ return true;
+ return false;
+}
+
+LwpFrameLink::LwpFrameLink() {}
+
+/**
+ * @descr frame link information
+ *
+ */
+void LwpFrameLink::Read(LwpObjectStream* pStrm)
+{
+ m_PreviousLayout.ReadIndexed(pStrm);
+ m_NextLayout.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+}
+
+LwpFrameLayout::LwpFrameLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+ , m_bGettingMaxWidth(false)
+{
+}
+
+LwpFrameLayout::~LwpFrameLayout() {}
+
+/**
+ * @descr read frame layout object
+ *
+ */
+void LwpFrameLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ if (LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ if (m_pObjStrm->QuickReaduInt16())
+ {
+ m_Link.Read(m_pObjStrm.get());
+ }
+ }
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr create a xfframe and add into content container
+ * @param: pCont - content container that contains the frame.
+ *
+ */
+void LwpFrameLayout::XFConvert(XFContentContainer* pCont)
+{
+ if (!m_pFrame)
+ return;
+
+ //parse the frame which anchor to paragraph
+ if (IsRelativeAnchored())
+ {
+ XFConvertFrame(pCont);
+ }
+ else
+ {
+ m_pFrame->XFConvert(pCont);
+ }
+}
+/**
+ * @descr create a xfframe and add into content container, called by XFConvert
+ * @param: pCont - content container that contains the frame.
+ * @param: nPageNo - the page number that the frame anchors
+ *
+ */
+void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd,
+ bool bAll)
+{
+ if (!m_pFrame)
+ return;
+
+ rtl::Reference<XFFrame> xXFFrame;
+ if (nEnd < nStart)
+ {
+ xXFFrame.set(new XFFrame);
+ }
+ else
+ {
+ xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
+ }
+
+ m_pFrame->Parse(xXFFrame.get(), nStart);
+ //if it is a link frame, parse contents only once
+ if (!HasPreviousLinkLayout())
+ {
+ rtl::Reference<LwpObject> content = m_Content.obj();
+ if (content.is())
+ {
+ content->DoXFConvert(xXFFrame.get());
+ //set frame size according to ole size
+ ApplyGraphicSize(xXFFrame.get());
+ }
+ }
+ pCont->Add(xXFFrame.get());
+}
+/**
+ * @descr register frame style
+ *
+ */
+void LwpFrameLayout::RegisterStyle()
+{
+ //if it is for water mark, don't register style
+ if (IsForWaterMark())
+ return;
+
+ if (m_pFrame)
+ return;
+
+ //register frame style
+ std::unique_ptr<XFFrameStyle> xFrameStyle(new XFFrameStyle);
+ m_pFrame.reset(new LwpFrame(this));
+ m_pFrame->RegisterStyle(xFrameStyle);
+
+ //register content style
+ rtl::Reference<LwpObject> content = m_Content.obj();
+ if (content.is())
+ {
+ content->SetFoundry(m_pFoundry);
+ content->DoRegisterStyle();
+ }
+
+ //register child frame style
+ RegisterChildStyle();
+}
+
+/**
+ * @descr get the name of the frame that current frame links
+ *
+ */
+OUString LwpFrameLayout::GetNextLinkName()
+{
+ OUString aName;
+ LwpObjectID& rObjectID = m_Link.GetNextLayout();
+ if (!rObjectID.IsNull())
+ {
+ LwpLayout* pLayout = dynamic_cast<LwpLayout*>(rObjectID.obj().get());
+ if (pLayout)
+ {
+ LwpAtomHolder& rHolder = pLayout->GetName();
+ aName = rHolder.str();
+ //for division name conflict
+ if (!pLayout->GetStyleName().isEmpty())
+ aName = pLayout->GetStyleName();
+ }
+ }
+ return aName;
+}
+/**
+ * @descr whether current frame is linked by other frame
+ *
+ */
+bool LwpFrameLayout::HasPreviousLinkLayout()
+{
+ LwpObjectID& rObjectID = m_Link.GetPreviousLayout();
+ return !rObjectID.IsNull();
+}
+/**
+ * @descr whether current frame is for water mark. Problem maybe exists by this method, must be tracking
+ *
+ */
+bool LwpFrameLayout::IsForWaterMark()
+{
+ if (m_nBuoyancy >= LAY_BUOYLAYER)
+ {
+ if (m_Content.IsNull())
+ return false;
+ rtl::Reference<LwpObject> content = m_Content.obj();
+ if (!content.is())
+ return false;
+ if (content->GetTag() == VO_GRAPHIC)
+ return true;
+ }
+ return false;
+}
+
+/**
+ * @descr Get frame width
+ *
+ */
+double LwpFrameLayout::GetWidth()
+{
+ double fWidth = LwpMiddleLayout::GetWidth();
+ if (IsInlineToMargin() && IsAutoGrowWidth())
+ {
+ //for text field entry when choosing maximize field length
+ fWidth = GetMaxWidth();
+ }
+ return fWidth;
+}
+
+/**
+ * @descr Get frame width when the text field chooses maximize field length
+ *
+ */
+double LwpFrameLayout::GetMaxWidth()
+{
+ if (m_bGettingMaxWidth)
+ throw std::runtime_error("recursive GetMaxWidth");
+
+ m_bGettingMaxWidth = true;
+ double fActualWidth = 0;
+ rtl::Reference<LwpVirtualLayout> xLayout(GetContainerLayout());
+ LwpMiddleLayout* pParent = dynamic_cast<LwpMiddleLayout*>(xLayout.get());
+ if (pParent)
+ {
+ LwpPoint aPoint = GetOrigin();
+ double fXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
+ double fWrapRight = GetExtMarginsValue(MARGIN_RIGHT);
+
+ //Get parent layout width
+ double fParentWidth = pParent->GetWidth();
+ if (pParent->IsCell())
+ {
+ //Get actual width of this cell layout
+ fParentWidth = static_cast<LwpCellLayout*>(pParent)->GetActualWidth();
+ }
+
+ double fParentMarginRight = 0;
+ sal_uInt8 nType = GetRelativeType();
+ if (nType == LwpLayoutRelativityGuts::LAY_INLINE
+ || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
+ {
+ fParentMarginRight = pParent->GetMarginsValue(MARGIN_RIGHT);
+ }
+
+ fActualWidth = fParentWidth - fXOffset - fParentMarginRight - fWrapRight;
+ }
+
+ m_bGettingMaxWidth = false;
+ return fActualWidth;
+}
+
+/**
+ * @descr Set frame size according to graphic size
+ *
+ */
+void LwpFrameLayout::ApplyGraphicSize(XFFrame* pXFFrame)
+{
+ rtl::Reference<LwpObject> content = m_Content.obj();
+ if (!(content.is() && (content->GetTag() == VO_GRAPHIC || content->GetTag() == VO_OLEOBJECT)))
+ return;
+
+ LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content.get());
+ //Get frame geometry size
+ double fWidth = 0;
+ double fHeight = 0;
+ pGraOle->GetGrafScaledSize(fWidth, fHeight);
+ if (IsFitGraphic())
+ {
+ //graphic scaled sze
+ fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
+ fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
+ }
+ else if (IsAutoGrowDown() || IsAutoGrowUp())
+ {
+ fWidth = GetWidth();
+ fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
+ }
+ else if (IsAutoGrowLeft() || IsAutoGrowRight())
+ {
+ fHeight = GetHeight();
+ fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
+ }
+ else
+ {
+ fWidth = GetWidth();
+ fHeight = GetHeight();
+ }
+ pXFFrame->SetWidth(fWidth);
+ pXFFrame->SetHeight(fHeight);
+}
+
+LwpGroupLayout::LwpGroupLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+{
+}
+
+LwpGroupLayout::~LwpGroupLayout() {}
+/**
+ * @descr read group layout object
+ *
+ */
+void LwpGroupLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+/**
+ * @descr register group frame style
+ *
+ */
+void LwpGroupLayout::RegisterStyle()
+{
+ if (m_pFrame)
+ return;
+
+ //register frame style
+ std::unique_ptr<XFFrameStyle> xFrameStyle(new XFFrameStyle);
+ m_pFrame.reset(new LwpFrame(this));
+ m_pFrame->RegisterStyle(xFrameStyle);
+
+ //register child frame style
+ RegisterChildStyle();
+}
+/**
+ * @descr create a xfframe and add into content container
+ * @param: pCont - content container that contains the frame.
+ *
+ */
+void LwpGroupLayout::XFConvert(XFContentContainer* pCont)
+{
+ if (!m_pFrame)
+ return;
+
+ //parse the frame which anchor to paragraph
+ if (IsRelativeAnchored())
+ {
+ XFConvertFrame(pCont);
+ }
+ else
+ {
+ m_pFrame->XFConvert(pCont);
+ }
+}
+/**
+ * @descr create a xfframe and add into content container, called by XFConvert
+ * @param: pCont - content container that contains the frame.
+ * @param: nPageNo - the page number that the frame anchors
+ *
+ */
+void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd,
+ bool bAll)
+{
+ if (!m_pFrame)
+ return;
+
+ rtl::Reference<XFFrame> xXFFrame;
+ if (nEnd < nStart)
+ {
+ xXFFrame.set(new XFFrame);
+ }
+ else
+ {
+ xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
+ }
+
+ m_pFrame->Parse(xXFFrame.get(), nStart);
+
+ //add child frame into group
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
+
+ while (pLayout && pLayout != this)
+ {
+ pLayout->DoXFConvert(xXFFrame.get());
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
+ }
+
+ pCont->Add(xXFFrame.get());
+}
+
+LwpGroupFrame::LwpGroupFrame(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+{
+}
+
+LwpGroupFrame::~LwpGroupFrame() {}
+
+void LwpGroupFrame::Read()
+{
+ LwpContent::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpGroupFrame::RegisterStyle() {}
+
+void LwpGroupFrame::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpDropcapLayout::LwpDropcapLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpFrameLayout(objHdr, pStrm)
+ , m_nLines(3)
+ , m_nChars(1)
+{
+}
+
+void LwpDropcapLayout::Read()
+{
+ LwpFrameLayout::Read();
+ m_nLines = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SeekRel(1);
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpDropcapLayout::Parse(IXFStream* pOutputStream)
+{
+ LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
+ if (!pStory)
+ return;
+ rtl::Reference<LwpObject> pPara = pStory->GetFirstPara().obj(VO_PARA);
+ if (pPara.is())
+ {
+ pPara->SetFoundry(m_pFoundry);
+ pPara->DoParse(pOutputStream);
+ }
+}
+
+void LwpDropcapLayout::XFConvert(XFContentContainer* pCont)
+{
+ LwpStory* pStory = static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
+ if (pStory)
+ {
+ pStory->SetFoundry(m_pFoundry);
+ pStory->XFConvert(pCont);
+ }
+}
+
+void LwpDropcapLayout::RegisterStyle(LwpFoundry* pFoundry)
+{
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
+ if (pStory)
+ {
+ pStory->SetDropcapFlag(true);
+ pStory->SetFoundry(pFoundry);
+ LwpPara* pPara = dynamic_cast<LwpPara*>(pStory->GetFirstPara().obj().get());
+ while (pPara)
+ {
+ pPara->SetFoundry(pFoundry);
+ pPara->RegisterStyle();
+ pPara = dynamic_cast<LwpPara*>(pPara->GetNext().obj().get());
+ }
+ }
+}
+
+/**
+ * @descr do nothing
+ *
+ */
+void LwpDropcapLayout::RegisterStyle() {}
+
+LwpRubyLayout::LwpRubyLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpFrameLayout(objHdr, pStrm)
+ , m_nPlacement(0)
+ , m_nAlignment(0)
+ , m_nStateFlag(0)
+ , m_nXOffset(0)
+ , m_nYOffset(0)
+{
+}
+
+void LwpRubyLayout::Read()
+{
+ LwpFrameLayout::Read();
+ m_nPlacement = m_pObjStrm->QuickReaduInt8();
+ m_nAlignment = m_pObjStrm->QuickReaduInt8();
+ m_nStateFlag = m_pObjStrm->QuickReaduInt16();
+ m_nXOffset = m_pObjStrm->QuickReadInt32();
+ m_nYOffset = m_pObjStrm->QuickReadInt32();
+ m_objRubyMarker.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+LwpRubyMarker* LwpRubyLayout::GetMarker()
+{
+ return static_cast<LwpRubyMarker*>(m_objRubyMarker.obj(VO_RUBYMARKER).get());
+}
+
+LwpStory* LwpRubyLayout::GetContentStory()
+{
+ return static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
+}
+
+void LwpRubyLayout::ConvertContentText()
+{
+ LwpStory* pStory = GetContentStory();
+ LwpRubyMarker* pMarker = GetMarker();
+ if (pStory && pMarker)
+ pMarker->SetRubyText(pStory->GetContentText(true));
+}
+
+void LwpRubyLayout::RegisterStyle()
+{
+ LwpRubyMarker* pMarker = GetMarker();
+ if (!pMarker)
+ throw std::runtime_error("missing Ruby Marker");
+
+ std::unique_ptr<XFRubyStyle> xRubyStyle(new XFRubyStyle);
+
+ enumXFRubyPosition eType = enumXFRubyLeft;
+ if (m_nAlignment == LEFT)
+ {
+ eType = enumXFRubyLeft;
+ }
+ else if (m_nAlignment == RIGHT)
+ {
+ eType = enumXFRubyRight;
+ }
+ else if (m_nAlignment == CENTER)
+ {
+ eType = enumXFRubyCenter;
+ }
+ xRubyStyle->SetAlignment(eType);
+
+ eType = enumXFRubyTop;
+ if (m_nPlacement == TOP)
+ {
+ eType = enumXFRubyTop;
+ }
+ else if (m_nPlacement == BOTTOM)
+ {
+ eType = enumXFRubyBottom;
+ }
+ xRubyStyle->SetPosition(eType);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ OUString rubyStyle = pXFStyleManager->AddStyle(std::move(xRubyStyle)).m_pStyle->GetStyleName();
+ pMarker->SetRubyStyleName(rubyStyle);
+
+ LwpStory* pStory = GetContentStory();
+ pStory->SetFoundry(m_pFoundry);
+ OUString textStyle = pStory->RegisterFirstFribStyle();
+ pMarker->SetTextStyleName(textStyle);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpframelayout.hxx b/lotuswordpro/source/filter/lwpframelayout.hxx
new file mode 100644
index 000000000..351be2cc6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpframelayout.hxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * the class for VO_FrameLayout
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRAMELAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRAMELAYOUT_HXX
+
+#include <memory>
+#include "lwplayout.hxx"
+#include "lwpstory.hxx"
+#include "lwpmarker.hxx"
+#include <xfilter/xfframestyle.hxx>
+#include <xfilter/xfframe.hxx>
+
+/**
+ * @brief For register frame style and parse frame
+ *
+ */
+
+class LwpFrame
+{
+public:
+ explicit LwpFrame(LwpPlacableLayout* pLayout);
+ ~LwpFrame();
+ void RegisterStyle(std::unique_ptr<XFFrameStyle>& rFrameStyle);
+ void Parse(XFFrame* pXFFrame, sal_Int32 nPageNo);
+ void XFConvert(XFContentContainer* pCont);
+
+private:
+ void ApplyWrapType(XFFrameStyle* pFrameStyle);
+ void ApplyMargins(XFFrameStyle* pFrameStyle);
+ void ApplyPadding(XFFrameStyle* pFrameStyle);
+ void ApplyBorders(XFFrameStyle* pFrameStyle);
+ void ApplyColumns(XFFrameStyle* pFrameStyle);
+ void ApplyShadow(XFFrameStyle* pFrameStyle);
+ void ApplyBackColor(XFFrameStyle* pFrameStyle);
+ void ApplyProtect(XFFrameStyle* pFrameStyle);
+ void ApplyTextDir(XFFrameStyle* pFrameStyle);
+ void ApplyPosType(XFFrameStyle* pFrameStyle);
+ void ApplyWatermark(XFFrameStyle* pFrameStyle);
+ void ApplyPatternFill(XFFrameStyle* pFrameStyle);
+ void ApplyBackGround(XFFrameStyle* pFrameStyle);
+ void ParseAnchorType(XFFrame* pXFFrame);
+ bool IsLeftWider();
+
+private:
+ LwpPlacableLayout* m_pLayout;
+ OUString m_StyleName;
+};
+
+/**
+ * @brief Frame link information
+ *
+ */
+class LwpFrameLink
+{
+public:
+ LwpFrameLink();
+ void Read(LwpObjectStream* pStrm);
+ LwpObjectID& GetNextLayout() { return m_NextLayout; }
+ LwpObjectID& GetPreviousLayout() { return m_PreviousLayout; }
+
+private:
+ LwpObjectID m_PreviousLayout;
+ LwpObjectID m_NextLayout;
+};
+
+/**
+ * @brief VO_FRAMELAYOUT object
+ *
+ */
+class LwpFrameLayout : public LwpPlacableLayout
+{
+public:
+ LwpFrameLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFrameLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FRAME_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ void XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart = 0, sal_Int32 nEnd = 0,
+ bool bAll = false) override;
+ OUString GetNextLinkName();
+ bool HasPreviousLinkLayout();
+ bool IsForWaterMark() override;
+ double GetWidth() override;
+ void ApplyGraphicSize(XFFrame* pXFFrame);
+
+protected:
+ void Read() override;
+
+private:
+ double GetMaxWidth();
+
+private:
+ LwpFrameLink m_Link;
+ std::unique_ptr<LwpFrame> m_pFrame;
+ bool m_bGettingMaxWidth;
+};
+
+/**
+ * @brief VO_GROUPLAYOUT object , information for frame group layout
+ *
+ */
+class LwpGroupLayout : public LwpPlacableLayout
+{
+public:
+ LwpGroupLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpGroupLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_GROUP_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ void XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart = 0, sal_Int32 nEnd = 0,
+ bool bAll = false) override;
+
+protected:
+ void Read() override;
+
+private:
+ std::unique_ptr<LwpFrame> m_pFrame;
+};
+
+/**
+ * @brief VO_GROUPFRAME object , information for frame group contents
+ *
+ */
+class LwpGroupFrame : public LwpContent
+{
+public:
+ LwpGroupFrame(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpGroupFrame() override;
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+
+class LwpStory;
+class LwpFoundry;
+class LwpDropcapLayout : public LwpFrameLayout
+{
+public:
+ LwpDropcapLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_DROPCAP_LAYOUT; }
+ virtual void Parse(IXFStream* pOutputStream) override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ sal_uInt16 GetLines() const { return m_nLines; }
+ void SetChars(sal_uInt32 nChars) { m_nChars += nChars; }
+ sal_uInt32 GetChars() const { return m_nChars; }
+ void RegisterStyle(LwpFoundry* pFoundry);
+ void RegisterStyle() override;
+
+protected:
+ void Read() override;
+
+private:
+ sal_uInt16 m_nLines;
+ sal_uInt32 m_nChars;
+};
+
+class LwpRubyLayout : public LwpFrameLayout
+{
+public:
+ LwpRubyLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ LwpRubyMarker* GetMarker();
+ void ConvertContentText();
+ LwpStory* GetContentStory();
+ void RegisterStyle() override;
+ enum
+ {
+ LEFT = 4,
+ RIGHT = 5,
+ CENTER = 2,
+ TOP = 1,
+ BOTTOM = 3
+ };
+
+protected:
+ void Read() override;
+
+private:
+ sal_uInt8 m_nPlacement;
+ sal_uInt8 m_nAlignment;
+ sal_uInt16 m_nStateFlag;
+ sal_Int32 m_nXOffset;
+ sal_Int32 m_nYOffset;
+ LwpObjectID m_objRubyMarker;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
new file mode 100644
index 000000000..fb4c47ebd
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -0,0 +1,455 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+#include <lwpfrib.hxx>
+#include "lwphyperlinkmgr.hxx"
+#include <xfilter/xfhyperlink.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftextspan.hxx>
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xftextcontent.hxx>
+#include "lwpfribheader.hxx"
+#include "lwpfribtext.hxx"
+#include "lwpfribtable.hxx"
+#include "lwpfribbreaks.hxx"
+#include "lwpfribframe.hxx"
+#include "lwpfribsection.hxx"
+#include "lwpcharacterstyle.hxx"
+#include "lwpfootnote.hxx"
+#include "lwpnotes.hxx"
+#include "lwpfribmark.hxx"
+#include <lwpglobalmgr.hxx>
+
+#include <osl/diagnose.h>
+
+LwpFrib::LwpFrib(LwpPara* pPara)
+ : m_pFribMap(nullptr)
+ , m_pPara(pPara)
+ , m_pNext(nullptr)
+ , m_nFribType(0)
+ , m_ModFlag(false)
+ , m_nRevisionType(0)
+ , m_bRevisionFlag(false)
+ , m_nEditor(0)
+{
+}
+
+LwpFrib::~LwpFrib() { Deregister(); }
+
+LwpFrib* LwpFrib::CreateFrib(LwpPara* pPara, LwpObjectStream* pObjStrm, sal_uInt8 fribtag,
+ sal_uInt8 editID)
+{
+ //Read Modifier
+ std::unique_ptr<ModifierInfo> xModInfo;
+ if (fribtag & FRIB_TAG_MODIFIER)
+ {
+ xModInfo.reset(new ModifierInfo);
+ xModInfo->CodePage = 0;
+ xModInfo->FontID = 0;
+ xModInfo->RevisionType = 0;
+ xModInfo->RevisionFlag = false;
+ xModInfo->HasCharStyle = false;
+ xModInfo->HasLangOverride = false;
+ xModInfo->HasHighlight = false;
+ ReadModifiers(pObjStrm, xModInfo.get());
+ }
+
+ //Read frib data
+ std::unique_ptr<LwpFrib> newFrib;
+ sal_uInt16 friblen = pObjStrm->QuickReaduInt16();
+ sal_uInt8 fribtype = fribtag & ~FRIB_TAG_TYPEMASK;
+ switch (fribtype)
+ {
+ case FRIB_TAG_INVALID: //fall through
+ case FRIB_TAG_EOP: //fall through
+ default:
+ newFrib.reset(new LwpFrib(pPara));
+ break;
+ case FRIB_TAG_TEXT:
+ {
+ newFrib.reset(new LwpFribText(pPara, (fribtag & FRIB_TAG_NOUNICODE) != 0));
+ break;
+ }
+ case FRIB_TAG_TABLE:
+ newFrib.reset(new LwpFribTable(pPara));
+ break;
+ case FRIB_TAG_TAB:
+ newFrib.reset(new LwpFribTab(pPara));
+ break;
+ case FRIB_TAG_PAGEBREAK:
+ newFrib.reset(new LwpFribPageBreak(pPara));
+ break;
+ case FRIB_TAG_FRAME:
+ newFrib.reset(new LwpFribFrame(pPara));
+ break;
+ case FRIB_TAG_FOOTNOTE:
+ newFrib.reset(new LwpFribFootnote(pPara));
+ break;
+ case FRIB_TAG_COLBREAK:
+ newFrib.reset(new LwpFribColumnBreak(pPara));
+ break;
+ case FRIB_TAG_LINEBREAK:
+ newFrib.reset(new LwpFribLineBreak(pPara));
+ break;
+ case FRIB_TAG_HARDSPACE:
+ newFrib.reset(new LwpFribHardSpace(pPara));
+ break;
+ case FRIB_TAG_SOFTHYPHEN:
+ newFrib.reset(new LwpFribSoftHyphen(pPara));
+ break;
+ case FRIB_TAG_PARANUMBER:
+ newFrib.reset(new LwpFribParaNumber(pPara));
+ break;
+ case FRIB_TAG_UNICODE: //fall through
+ case FRIB_TAG_UNICODE2: //fall through
+ case FRIB_TAG_UNICODE3: //fall through
+ newFrib.reset(new LwpFribUnicode(pPara));
+ break;
+ case FRIB_TAG_NOTE:
+ newFrib.reset(new LwpFribNote(pPara));
+ break;
+ case FRIB_TAG_SECTION:
+ newFrib.reset(new LwpFribSection(pPara));
+ break;
+ case FRIB_TAG_PAGENUMBER:
+ newFrib.reset(new LwpFribPageNumber(pPara));
+ break;
+ case FRIB_TAG_DOCVAR:
+ newFrib.reset(new LwpFribDocVar(pPara));
+ break;
+ case FRIB_TAG_BOOKMARK:
+ newFrib.reset(new LwpFribBookMark(pPara));
+ break;
+ case FRIB_TAG_FIELD:
+ newFrib.reset(new LwpFribField(pPara));
+ break;
+ case FRIB_TAG_CHBLOCK:
+ newFrib.reset(new LwpFribCHBlock(pPara));
+ break;
+ case FRIB_TAG_RUBYMARKER:
+ newFrib.reset(new LwpFribRubyMarker(pPara));
+ break;
+ case FRIB_TAG_RUBYFRAME:
+ newFrib.reset(new LwpFribRubyFrame(pPara));
+ break;
+ }
+
+ //Do not know why the fribTag judgment is necessary, to be checked with
+ if (fribtag & FRIB_TAG_MODIFIER)
+ {
+ newFrib->SetModifiers(xModInfo.release());
+ }
+
+ newFrib->m_nFribType = fribtype;
+ newFrib->m_nEditor = editID;
+ newFrib->Read(pObjStrm, friblen);
+ return newFrib.release();
+}
+
+void LwpFrib::Read(LwpObjectStream* pObjStrm, sal_uInt16 len) { pObjStrm->SeekRel(len); }
+
+void LwpFrib::SetModifiers(ModifierInfo* pModifiers)
+{
+ if (pModifiers)
+ {
+ m_pModifiers.reset(pModifiers);
+ m_ModFlag = true;
+ if (pModifiers->RevisionFlag)
+ {
+ m_bRevisionFlag = true;
+ m_nRevisionType = pModifiers->RevisionType;
+ }
+ }
+}
+
+void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
+{
+ if (!m_pModifiers)
+ return;
+ if (!m_pModifiers->FontID && !m_pModifiers->HasCharStyle && !m_pModifiers->HasHighlight)
+ {
+ m_ModFlag = false;
+ return;
+ }
+ //we only read four modifiers, in these modifiers,CodePage and LangOverride are not styles,
+ //so we can only handle fontid and charstyle, if others, we should not reg style
+ //note by ,1-27
+ rtl::Reference<XFFont> pFont;
+ XFTextStyle* pStyle = nullptr;
+ m_StyleName.clear();
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFTextStyle* pNamedStyle = nullptr;
+ if (m_pModifiers->HasCharStyle && pFoundry)
+ {
+ pNamedStyle = dynamic_cast<XFTextStyle*>(
+ pFoundry->GetStyleManager()->GetStyle(m_pModifiers->CharStyleID));
+ }
+ if (pNamedStyle)
+ {
+ LwpCharacterStyle* pCharStyle = nullptr;
+ if (m_pModifiers->FontID && pFoundry)
+ pCharStyle = dynamic_cast<LwpCharacterStyle*>(m_pModifiers->CharStyleID.obj().get());
+ if (pCharStyle)
+ {
+ std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
+ *pNewStyle = *pNamedStyle;
+
+ pNewStyle->SetStyleName("");
+ pFont = pFoundry->GetFontManager().CreateOverrideFont(pCharStyle->GetFinalFontID(),
+ m_pModifiers->FontID);
+ pNewStyle->SetFont(pFont);
+ IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(std::move(pNewStyle));
+ m_StyleName = aNewStyle.m_pStyle->GetStyleName();
+ pStyle = dynamic_cast<XFTextStyle*>(aNewStyle.m_pStyle);
+ if (aNewStyle.m_bOrigDeleted)
+ pStyle = nullptr;
+ }
+ else
+ m_StyleName = pNamedStyle->GetStyleName();
+ }
+ else
+ {
+ if (m_pModifiers->FontID && pFoundry)
+ {
+ std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
+ pFont = pFoundry->GetFontManager().CreateFont(m_pModifiers->FontID);
+ pNewStyle->SetFont(pFont);
+ IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(std::move(pNewStyle));
+ m_StyleName = aNewStyle.m_pStyle->GetStyleName();
+ pStyle = dynamic_cast<XFTextStyle*>(aNewStyle.m_pStyle);
+ if (aNewStyle.m_bOrigDeleted)
+ pStyle = nullptr;
+ }
+ }
+
+ if (!m_pModifiers->HasHighlight)
+ return;
+
+ XFColor aColor = GetHighlightColor(); //right yellow
+ if (pStyle) //change the style directly
+ pStyle->GetFont()->SetBackColor(aColor);
+ else //register a new style
+ {
+ std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
+
+ if (!m_StyleName.isEmpty())
+ {
+ XFTextStyle* pOldStyle = pXFStyleManager->FindTextStyle(m_StyleName);
+ *pNewStyle = *pOldStyle;
+ pNewStyle->GetFont()->SetBackColor(aColor);
+ }
+ else
+ {
+ pFont = new XFFont;
+ pFont->SetBackColor(aColor);
+ pNewStyle->SetFont(pFont);
+ }
+ m_StyleName = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName();
+ }
+}
+
+void LwpFrib::ReadModifiers(LwpObjectStream* pObjStrm, ModifierInfo* pModInfo)
+{
+ for (;;)
+ {
+ bool bFailure;
+
+ // Get the modifier type
+ sal_uInt8 Modifier = pObjStrm->QuickReaduInt8(&bFailure);
+ if (bFailure)
+ break;
+
+ // Stop when we hit the last modifier
+ if (Modifier == FRIB_MTAG_NONE)
+ break;
+
+ // Get the modifier length
+ sal_uInt8 len = pObjStrm->QuickReaduInt8(&bFailure);
+ if (bFailure)
+ break;
+
+ switch (Modifier)
+ {
+ case FRIB_MTAG_FONT:
+ if (len != sizeof(pModInfo->FontID))
+ {
+ OSL_FAIL("FRIB_MTAG_FONT entry wrong size");
+ pObjStrm->SeekRel(len);
+ }
+ else
+ pModInfo->FontID = pObjStrm->QuickReaduInt32();
+ break;
+ case FRIB_MTAG_CHARSTYLE:
+ pModInfo->HasCharStyle = true;
+ pModInfo->CharStyleID.ReadIndexed(pObjStrm);
+ break;
+ case FRIB_MTAG_LANGUAGE:
+ pModInfo->HasLangOverride = true;
+ pModInfo->Language.Read(pObjStrm);
+ break;
+ case FRIB_MTAG_CODEPAGE:
+ if (len != sizeof(pModInfo->CodePage))
+ {
+ OSL_FAIL("FRIB_MTAG_CODEPAGE entry wrong size");
+ pObjStrm->SeekRel(len);
+ }
+ else
+ pModInfo->CodePage = pObjStrm->QuickReaduInt16();
+ break;
+ case FRIB_MTAG_ATTRIBUTE:
+ pModInfo->aTxtAttrOverride.Read(pObjStrm);
+ if (pModInfo->aTxtAttrOverride.IsHighlight())
+ pModInfo->HasHighlight = true;
+ break;
+ case FRIB_MTAG_REVISION:
+ pModInfo->RevisionType = pObjStrm->QuickReaduInt8();
+ pModInfo->RevisionFlag = true;
+ break;
+ default:
+ pObjStrm->SeekRel(len);
+ break;
+ }
+ // TODO: read the modifier data
+ }
+}
+
+/**
+* @descr: Whether there are other fribs following current frib.
+* @return: True if having following fribs, or false.
+*/
+bool LwpFrib::HasNextFrib() { return GetNext() && GetNext()->GetType() != FRIB_TAG_EOP; }
+
+void LwpFrib::ConvertChars(XFContentContainer* pXFPara, const OUString& text)
+{
+ if (m_ModFlag)
+ {
+ OUString strStyleName = GetStyleName();
+ XFTextSpan* pSpan = new XFTextSpan(text, strStyleName);
+ pXFPara->Add(pSpan);
+ }
+ else
+ {
+ XFTextContent* pSpan = new XFTextContent();
+ pSpan->SetText(text);
+ pXFPara->Add(pSpan);
+ }
+}
+
+void LwpFrib::ConvertHyperLink(XFContentContainer* pXFPara, const LwpHyperlinkMgr* pHyperlink,
+ const OUString& text)
+{
+ XFHyperlink* pHyper = new XFHyperlink;
+ pHyper->SetHRef(pHyperlink->GetHyperlink());
+ pHyper->SetText(text);
+ pHyper->SetStyleName(GetStyleName());
+ pXFPara->Add(pHyper);
+}
+
+/**
+* @descr: Get the current frib font style
+* @return: XFFont pointer
+*/
+rtl::Reference<XFFont> LwpFrib::GetFont()
+{
+ rtl::Reference<XFFont> pFont;
+ if (m_pModifiers && m_pModifiers->FontID)
+ {
+ LwpFoundry* pFoundry = m_pPara->GetFoundry();
+ if (pFoundry)
+ pFont = pFoundry->GetFontManager().CreateFont(m_pModifiers->FontID);
+ }
+ else
+ {
+ XFParaStyle* pXFParaStyle = m_pPara->GetXFParaStyle();
+ pFont = pXFParaStyle->GetFont();
+ }
+ return pFont;
+}
+
+OUString LwpFrib::GetEditor()
+{
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ return pGlobal->GetEditorName(m_nEditor);
+}
+
+XFColor LwpFrib::GetHighlightColor()
+{
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ return pGlobal->GetHighlightColor(m_nEditor);
+}
+
+void LwpFrib::Register(std::map<LwpFrib*, OUString>* pFribMap)
+{
+ if (m_pFribMap)
+ throw std::runtime_error("registered already");
+ m_pFribMap = pFribMap;
+}
+
+void LwpFrib::Deregister()
+{
+ if (m_pFribMap)
+ {
+ m_pFribMap->erase(this);
+ m_pFribMap = nullptr;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribbreaks.cxx b/lotuswordpro/source/filter/lwpfribbreaks.cxx
new file mode 100644
index 000000000..52dd3e8ae
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribbreaks.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpfribbreaks.hxx"
+#include "lwpfribheader.hxx"
+#include "lwppagelayout.hxx"
+#include "lwpstory.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <lwpglobalmgr.hxx>
+
+void LwpFribColumnBreak::RegisterBreakStyle(LwpPara* pPara)
+{
+ // XFParaStyle* pBaseStyle = static_cast<XFParaStyle*>(pFoundry->GetStyleManager()->GetStyle(styleID));
+ XFParaStyle* pBaseStyle = pPara->GetXFParaStyle();
+ if (pBaseStyle == nullptr)
+ return;
+ // m_StyleName = pBaseStyle->GetStyleName();
+
+ std::unique_ptr<XFParaStyle> pOverStyle(new XFParaStyle);
+ *pOverStyle = *pBaseStyle;
+ pOverStyle->SetStyleName("");
+
+ //New code
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pPara->GetStoryID().obj().get());
+ LwpPageLayout* pCurLayout = pStory ? pStory->GetCurrentLayout() : nullptr;
+ if (pCurLayout && (pCurLayout->GetNumCols() == 1))
+
+ {
+ // if (!GetNext() || GetNext()->GetType()==FRIB_TAG_EOP)
+ pOverStyle->SetBreaks(enumXFBreakBefPage);
+ // else
+ // pOverStyle->SetBreaks(enumXFBreakBefPage);
+ }
+ else
+ {
+ if (!GetNext() || GetNext()->GetType() == FRIB_TAG_EOP)
+ pOverStyle->SetBreaks(enumXFBreakAftColumn);
+ else
+ pOverStyle->SetBreaks(enumXFBreakBefColumn);
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(pOverStyle)).m_pStyle->GetStyleName();
+}
+
+LwpFribPageBreak::LwpFribPageBreak(LwpPara* pPara)
+ : LwpFrib(pPara)
+ , m_bLastFrib(false)
+{
+}
+
+LwpFribPageBreak::~LwpFribPageBreak() {}
+
+void LwpFribPageBreak::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_Layout.ReadIndexed(pObjStrm);
+}
+
+void LwpFribPageBreak::RegisterBreakStyle(LwpPara* pPara)
+{
+ XFParaStyle* pBaseStyle = pPara->GetXFParaStyle();
+ if (pBaseStyle == nullptr)
+ return;
+
+ LwpPageLayout* pLayout = dynamic_cast<LwpPageLayout*>(m_Layout.obj().get());
+ if (pLayout)
+ {
+ m_pMasterPage.reset(new LwpMasterPage(pPara, pLayout));
+ m_pMasterPage->RegisterMasterPage(this);
+ return;
+ }
+
+ std::unique_ptr<XFParaStyle> pOverStyle(new XFParaStyle);
+ *pOverStyle = *pBaseStyle;
+ pOverStyle->SetStyleName("");
+ pOverStyle->SetMasterPage(pBaseStyle->GetMasterPage());
+
+ if (!GetNext() || GetNext()->GetType() == FRIB_TAG_EOP)
+ m_bLastFrib = true;
+ else
+ m_bLastFrib = false;
+
+ if (m_bLastFrib)
+ pOverStyle->SetBreaks(enumXFBreakAftPage);
+ else
+ pOverStyle->SetBreaks(enumXFBreakBefPage);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(pOverStyle)).m_pStyle->GetStyleName();
+}
+
+void LwpFribPageBreak::ParseLayout()
+{
+ if (m_pMasterPage)
+ {
+ m_pMasterPage->ParseSection(this);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribbreaks.hxx b/lotuswordpro/source/filter/lwpfribbreaks.hxx
new file mode 100644
index 000000000..e54ffbf6a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribbreaks.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBBREAKS_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBBREAKS_HXX
+
+#include <lwpfrib.hxx>
+#include "lwppara.hxx"
+#include "lwpfribsection.hxx"
+
+class LwpFribPageBreak: public LwpFrib
+{
+public:
+ explicit LwpFribPageBreak( LwpPara* pPara );
+ virtual ~LwpFribPageBreak() override;
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void RegisterBreakStyle(LwpPara* pPara);
+ void ParseLayout();
+ LwpObjectID& GetLayout() { return m_Layout;}
+ bool IsLastFrib() const {return m_bLastFrib;}
+
+private:
+ LwpObjectID m_Layout;
+ bool m_bLastFrib;
+
+ std::unique_ptr<LwpMasterPage> m_pMasterPage;
+};
+
+class LwpFribLineBreak: public LwpFrib
+{
+public:
+ explicit LwpFribLineBreak( LwpPara* pPara ) : LwpFrib(pPara){}
+};
+
+class LwpFribColumnBreak: public LwpFrib
+{
+public:
+ explicit LwpFribColumnBreak( LwpPara* pPara ) : LwpFrib(pPara){}
+ void RegisterBreakStyle(LwpPara* pPara);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
new file mode 100644
index 000000000..ad494d429
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -0,0 +1,239 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - footnote
+ */
+
+#include "lwpfribframe.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <lwpglobalmgr.hxx>
+#include <xfilter/xfchange.hxx>
+/**
+ * @short: Read frame frib
+ */
+void LwpFribFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objLayout.ReadIndexed(pObjStrm);
+}
+
+/**
+* @descr: Get the layout object which the frib points to
+*
+*/
+rtl::Reference<LwpObject> LwpFribFrame::GetLayout() const { return m_objLayout.obj(); }
+
+/**
+* @descr: register frame style
+* @param: pFoundry - current foundry pointer
+*
+*/
+void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
+{
+ rtl::Reference<LwpObject> pObject = m_objLayout.obj();
+
+ if (pObject.is() && pObject->GetTag() == VO_DROPCAPLAYOUT)
+ {
+ LwpDropcapLayout* pLayout = dynamic_cast<LwpDropcapLayout*>(pObject.get());
+ if (!pLayout)
+ return;
+ pLayout->RegisterStyle(pFoundry);
+ }
+ else
+ {
+ //register frame style
+ LwpPlacableLayout* pLayout = dynamic_cast<LwpPlacableLayout*>(pObject.get());
+ if (!pLayout)
+ return;
+ pLayout->SetFoundry(pFoundry);
+ pLayout->DoRegisterStyle();
+
+ //register next frib text style
+ sal_uInt8 nType = pLayout->GetRelativeType();
+ if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType && HasNextFrib())
+ {
+ XFParaStyle* pOldStyle = m_pPara->GetXFParaStyle();
+ if (pOldStyle->GetMasterPage().isEmpty())
+ m_StyleName = pOldStyle->GetStyleName();
+ else
+ {
+ std::unique_ptr<XFParaStyle> pParaStyle(new XFParaStyle);
+ *pParaStyle = *pOldStyle;
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName
+ = pXFStyleManager->AddStyle(std::move(pParaStyle)).m_pStyle->GetStyleName();
+ }
+ }
+ //remember the current paragraph font size which will be used in parsing frame
+ pLayout->SetFont(GetFont());
+ }
+}
+void LwpFribFrame::SetParaDropcap(LwpPara* pPara)
+{
+ rtl::Reference<LwpObject> pObject = m_objLayout.obj();
+
+ if (pObject.is() && pObject->GetTag() == VO_DROPCAPLAYOUT)
+ {
+ pPara->SetParaDropcap(true);
+ pPara->SetDropcapLayout(dynamic_cast<LwpDropcapLayout*>(pObject.get()));
+ }
+ else
+ pPara->SetParaDropcap(false);
+}
+
+/**
+* @descr: convert frame
+*
+*/
+void LwpFribFrame::XFConvert(XFContentContainer* pCont)
+{
+ XFContentContainer* pXFContentContainer = pCont;
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetLayout().get());
+ if (!pLayout)
+ return;
+ sal_uInt8 nType = pLayout->GetRelativeType();
+ if (LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
+ {
+ rtl::Reference<LwpVirtualLayout> xContainerLayout(pLayout->GetContainerLayout());
+ if (xContainerLayout.is() && xContainerLayout->IsFrame())
+ {
+ //same page as text and in frame
+ pXFContentContainer = m_pPara->GetXFContainer();
+ }
+ else if (xContainerLayout.is() && xContainerLayout->IsCell())
+ {
+ //same page as text and in cell, get the first xfpara
+ rtl::Reference<XFContent> first(pCont->FindFirstContent(enumXFContentPara));
+ XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
+ if (pXFFirtPara)
+ pXFContentContainer = pXFFirtPara;
+ }
+ }
+ OUString sChangeID;
+ if (m_bRevisionFlag)
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ sChangeID = pChangeMgr->GetChangeID(this);
+ if (!sChangeID.isEmpty())
+ {
+ XFChangeStart* pChangeStart = new XFChangeStart;
+ pChangeStart->SetChangeID(sChangeID);
+ pXFContentContainer->Add(pChangeStart);
+ }
+ }
+
+ pLayout->DoXFConvert(pXFContentContainer);
+
+ if (m_bRevisionFlag)
+ {
+ if (!sChangeID.isEmpty())
+ {
+ XFChangeEnd* pChangeEnd = new XFChangeEnd;
+ pChangeEnd->SetChangeID(sChangeID);
+ pXFContentContainer->Add(pChangeEnd);
+ }
+ }
+
+ if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType && HasNextFrib())
+ {
+ XFParagraph* pXFPara = new XFParagraph();
+ pXFPara->SetStyleName(m_StyleName);
+ m_pPara->AddXFContent(pXFPara);
+ m_pPara->GetFribs().SetXFPara(pXFPara);
+ }
+}
+
+/**
+ * @descr: Read Ruby frame
+ *
+ */
+void LwpFribRubyFrame::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objLayout.ReadIndexed(pObjStrm);
+}
+/**
+ * @descr: Register Ruby frame style
+ *
+ */
+void LwpFribRubyFrame::RegisterStyle(LwpFoundry* pFoundry)
+{
+ LwpRubyLayout* pLayout = GetLayout();
+ if (pLayout)
+ {
+ pLayout->SetFoundry(pFoundry);
+ pLayout->RegisterStyle();
+ }
+}
+/**
+ * @descr: convert Ruby frame
+ *
+ */
+void LwpFribRubyFrame::XFConvert()
+{
+ LwpRubyLayout* pLayout = GetLayout();
+ if (pLayout)
+ {
+ pLayout->ConvertContentText();
+ }
+}
+
+LwpRubyLayout* LwpFribRubyFrame::GetLayout()
+{
+ return dynamic_cast<LwpRubyLayout*>(m_objLayout.obj().get());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribframe.hxx b/lotuswordpro/source/filter/lwpfribframe.hxx
new file mode 100644
index 000000000..1b4e26bce
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribframe.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - footnote
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBFRAME_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBFRAME_HXX
+
+#include <lwpfrib.hxx>
+#include "lwppara.hxx"
+#include "lwpframelayout.hxx"
+
+class LwpFribFrame : public LwpFrib
+{
+public:
+ explicit LwpFribFrame(LwpPara* pPara)
+ : LwpFrib(pPara)
+ {
+ }
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ rtl::Reference<LwpObject> GetLayout() const;
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+ void SetParaDropcap(LwpPara* pPara);
+ void XFConvert(XFContentContainer* pCont);
+
+private:
+ LwpObjectID m_objLayout;
+};
+
+class LwpFribRubyFrame : public LwpFrib
+{
+public:
+ explicit LwpFribRubyFrame(LwpPara* pPara)
+ : LwpFrib(pPara)
+ {
+ }
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ LwpRubyLayout* GetLayout();
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+ void XFConvert();
+
+private:
+ LwpObjectID m_objLayout;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribheader.hxx b/lotuswordpro/source/filter/lwpfribheader.hxx
new file mode 100644
index 000000000..9740b047d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribheader.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBHEADER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBHEADER_HXX
+
+#define FRIB_TAG_NOUNICODE 0x40 // Don't translate text to/from Unicode
+#define FRIB_TAG_MODIFIER 0x80 // This frib has a modifier on it
+#define FRIB_TAG_TYPEMASK (FRIB_TAG_NOUNICODE | FRIB_TAG_MODIFIER)
+
+#define FRIB_TAG_ELVIS 0 // "EOP dammit" tag
+
+#define FRIB_MTAG_NONE 0
+#define FRIB_MTAG_FONT 1
+#define FRIB_MTAG_REVISION 2
+#define FRIB_MTAG_CHARSTYLE 3
+#define FRIB_MTAG_ATTRIBUTE 4
+#define FRIB_MTAG_LANGUAGE 5
+#define FRIB_MTAG_CODEPAGE 8
+
+#define FT_MAXIMUM 30
+
+/* Registration definitions */
+enum
+{
+ FS_RIGHTSIDE = 0x00,
+ FS_LEFTSIDE = 0x10
+};
+/* Mode definitions */
+enum
+{
+ FS_REGISTERSELF = 0x20,
+ FS_READING = 0x40
+};
+
+enum
+{
+ FRIB_TAG_INVALID, // FT_INVALID
+ FRIB_TAG_EOP, // FT_EOP
+ FRIB_TAG_TEXT, // FT_TEXT
+ FRIB_TAG_TABLE, // FT_TABLE
+ FRIB_TAG_TAB, // FT_TAB
+ FRIB_TAG_PAGEBREAK, // FT_PAGEBREAK
+ FRIB_TAG_FRAME, // FT_FRAME
+ FRIB_TAG_FOOTNOTE, // FT_FOOTNOTE
+ FRIB_TAG_COLBREAK, // FT_COLBREAK
+ FRIB_TAG_LINEBREAK, // FT_LINEBREAK
+ FRIB_TAG_HARDSPACE, // FT_HARDSPACE
+ FRIB_TAG_SOFTHYPHEN, // FT_SOFTHYPHEN
+ FRIB_TAG_PARANUMBER, // FT_PARANUMBER
+ FRIB_TAG_UNICODE, // FT_UNICODE
+ FRIB_TAG_UNICODE2, // FT_UNICODE
+ FRIB_TAG_UNICODE3, // FT_UNICODE
+ FRIB_TAG_SEPARATOR, // FT_SEPARATOR
+ FRIB_TAG_SECTION, // FT_SECTION
+ FRIB_TAG_TOMBSTONE, // FT_TOMBSTONE
+ FRIB_TAG_SPECIALTAB, // FT_SPECIALTAB
+ FRIB_TAG_PAGENUMBER, // FT_PAGENUMBER
+ FRIB_TAG_NOTE, // FT_NOTE
+ FRIB_TAG_DOCVAR, // FT_DOCVAR
+ FRIB_TAG_BOOKMARK, // FT_BOOKMARK
+ FRIB_TAG_DDE, // FT_DDE
+ FRIB_TAG_FIELD, // FT_FIELD
+ FRIB_TAG_CHBLOCK, // FT_CHBLOCK
+ FRIB_TAG_FLOWBREAK, // FT_FLOWBREAK
+ FRIB_TAG_RUBYMARKER, // FT_RUBYMARKER
+ FRIB_TAG_RUBYFRAME // FT_RUBYFRAME
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx
new file mode 100644
index 000000000..f29d4f4c3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribmark.cxx
@@ -0,0 +1,1426 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpfribmark.hxx"
+#include <lwptools.hxx>
+#include <lwpglobalmgr.hxx>
+#include "lwpdoc.hxx"
+#include "lwpdivinfo.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftextspan.hxx>
+#include <xfilter/xfbookmark.hxx>
+#include <xfilter/xfentry.hxx>
+#include <xfilter/xftextcontent.hxx>
+#include <xfilter/xfcrossref.hxx>
+#include <xfilter/xfdocfield.hxx>
+#include <xfilter/xfdatestyle.hxx>
+#include <xfilter/xftimestyle.hxx>
+#include <xfilter/xfdate.hxx>
+#include <xfilter/xfruby.hxx>
+#include <lwpchangemgr.hxx>
+#include <xfilter/xfchange.hxx>
+
+/**
+ * @short: Read hyperlink frib and Click here block
+ */
+void LwpFribCHBlock::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objMarker.ReadIndexed(pObjStrm);
+ m_nType = pObjStrm->QuickReaduInt8();
+}
+
+void LwpFribCHBlock::XFConvert(XFContentContainer* pXFPara, LwpStory* pStory)
+{
+ sal_uInt8 type = GetType();
+ if (!pStory)
+ return;
+ LwpCHBlkMarker* pMarker = dynamic_cast<LwpCHBlkMarker*>(m_objMarker.obj().get());
+
+ if (!pMarker)
+ return;
+ sal_uInt16 nAction = pMarker->GetAction();
+ if (nAction == LwpCHBlkMarker::CLICKHERE_CHBEHAVIORINTERNETLINK) //hyperlink
+ {
+ LwpHyperlinkMgr* pHyperlink = pStory->GetHyperlinkMgr();
+ if (type == MARKER_START)
+ {
+ if (pHyperlink)
+ {
+ pHyperlink->SetHyperlinkFlag(true);
+ pHyperlink->SetHyperlink(pMarker->GetNamedProperty(u"URL"));
+ }
+ }
+ else if (type == MARKER_END) //or none
+ {
+ pHyperlink->SetHyperlinkFlag(false);
+ }
+ }
+ else //click here block
+ {
+ pMarker->ConvertCHBlock(pXFPara, type);
+ }
+}
+/**
+ * @short: register bookmark frib
+ */
+void LwpFribBookMark::RegisterStyle(LwpFoundry* pFoundry)
+{
+ OUString name;
+ LwpBookMark* pBook = pFoundry ? pFoundry->GetBookMark(GetMarkerID()) : nullptr;
+ if (pBook)
+ name = pBook->GetName();
+
+ OUString sDivision;
+ LwpDocument* pDoc = pFoundry ? pFoundry->GetDocument() : nullptr;
+ if (pDoc)
+ {
+ LwpObjectID& rID = pDoc->GetDivInfoID();
+ if (!rID.IsNull())
+ {
+ LwpDivInfo* pDivInvo = dynamic_cast<LwpDivInfo*>(rID.obj(VO_DIVISIONINFO).get());
+ if (pDivInvo)
+ sDivision = pDivInvo->GetDivName();
+ }
+ }
+
+ sal_uInt8 type = GetType();
+
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpBookmarkMgr* pMarkMgr = pGlobal->GetLwpBookmarkMgr();
+ if (type == MARKER_START)
+ {
+ rtl::Reference<XFBookmarkStart> xMarkStart(new XFBookmarkStart);
+ xMarkStart->SetDivision(sDivision);
+ xMarkStart->SetName(name);
+ pMarkMgr->AddXFBookmarkStart(name, xMarkStart.get()); //add to map
+ m_xStart = xMarkStart;
+ }
+ else if (type == MARKER_END)
+ {
+ rtl::Reference<XFBookmarkEnd> xMarkEnd(new XFBookmarkEnd);
+ xMarkEnd->SetDivision(sDivision);
+ xMarkEnd->SetName(name);
+ pMarkMgr->AddXFBookmarkEnd(name, xMarkEnd.get()); //add to map
+ m_xEnd = xMarkEnd;
+ }
+}
+
+LwpFribBookMark::LwpFribBookMark(LwpPara* pPara)
+ : LwpFrib(pPara)
+ , m_nType(0)
+{
+}
+
+/**
+ * @short: Read bookmark frib
+ */
+void LwpFribBookMark::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objMarker.ReadIndexed(pObjStrm);
+ m_nType = pObjStrm->QuickReaduInt8();
+}
+/**
+ * @short: convert bookmark frib
+ */
+void LwpFribBookMark::XFConvert(XFContentContainer* pXFPara)
+{
+ sal_uInt8 type = GetType();
+
+ if (type == MARKER_START && m_xStart)
+ {
+ pXFPara->Add(m_xStart.get());
+ }
+ else if (type == MARKER_END && m_xEnd)
+ {
+ pXFPara->Add(m_xEnd.get());
+ }
+}
+
+/**
+ * @short: Read index entry frib
+ */
+LwpFribField::LwpFribField(LwpPara* pPara)
+ : LwpFrib(pPara)
+ , m_nType(0)
+ , m_TimeStyle("")
+ , m_nSubType(0)
+ , m_sFormula("")
+ , m_nCrossRefType(0)
+ , m_nDateTimeType(0)
+ , m_nDocPowerType(0)
+{
+}
+
+void LwpFribField::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objMarker.ReadIndexed(pObjStrm);
+ m_nType = pObjStrm->QuickReaduInt8();
+}
+
+LwpFieldMark* LwpFribField::GetMarker()
+{
+ return dynamic_cast<LwpFieldMark*>(m_objMarker.obj().get());
+}
+
+void LwpFribField::XFConvert(XFContentContainer* pXFPara)
+{
+ LwpFieldMark* pFieldMark = GetMarker();
+ if (!pFieldMark)
+ return;
+
+ sal_uInt8 type = GetType();
+ sal_uInt16 fieldType = pFieldMark->GetFieldType();
+
+ OUString sChangeID;
+ if (pFieldMark->GetRevisionFlag())
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ sChangeID = pChangeMgr->GetChangeID(pFieldMark->GetStartFrib());
+ }
+
+ CheckFieldType(pFieldMark);
+ //end marker
+ if (type == MARKER_END)
+ {
+ if (!pFieldMark->GetStart())
+ return;
+ if (pFieldMark->IsFormulaInsert())
+ {
+ XFTextContent* pSpan = new XFTextContent();
+ pSpan->SetText(">");
+ pXFPara->Add(pSpan);
+ }
+ if (fieldType == LwpFieldMark::FLD_FIELD)
+ {
+ if (m_nSubType == SUBFIELD_DATETIME)
+ {
+ ConvertDateTimeEnd(pXFPara, pFieldMark);
+ }
+ else if (m_nSubType == SUBFIELD_CROSSREF)
+ {
+ ConvertCrossRefEnd(pXFPara, pFieldMark);
+ }
+ else if (m_nSubType == SUBFIELD_DOCPOWER)
+ {
+ ConvertDocFieldEnd(pXFPara, pFieldMark);
+ }
+ }
+ if (pFieldMark->GetRevisionFlag() && !sChangeID.isEmpty())
+ {
+ XFChangeEnd* pChangeEnd = new XFChangeEnd;
+ pChangeEnd->SetChangeID(sChangeID);
+ pXFPara->Add(pChangeEnd);
+ }
+
+ return;
+ }
+
+ //start marker
+ if (pFieldMark->GetRevisionFlag() && !sChangeID.isEmpty())
+ {
+ XFChangeStart* pChangeStart = new XFChangeStart;
+ pChangeStart->SetChangeID(sChangeID);
+ pXFPara->Add(pChangeStart);
+ }
+
+ if (fieldType == LwpFieldMark::FLD_INDEX)
+ {
+ OUString sKey1, sKey2;
+ pFieldMark->ParseIndex(sKey1, sKey2);
+ if (!sKey1.isEmpty())
+ {
+ XFEntry* pEntry = new XFEntry;
+ pEntry->SetEntryType(enumXFEntryAlphabetical);
+ pEntry->SetKey(sKey1, sKey2);
+ pXFPara->Add(pEntry);
+ }
+ }
+ else if (fieldType == LwpFieldMark::FLD_TOC)
+ {
+ OUString sLevel, sText;
+ pFieldMark->ParseTOC(sLevel, sText);
+ if (!sLevel.isEmpty() && !sText.isEmpty())
+ {
+ XFEntry* pEntry = new XFEntry;
+ pEntry->SetEntryType(enumXFEntryTOC);
+ pEntry->SetStringValue(sText);
+ pEntry->SetOutlineLevel(sLevel.toInt32());
+ pXFPara->Add(pEntry);
+ }
+ }
+ else if (fieldType == LwpFieldMark::FLD_FIELD)
+ {
+ sal_uInt8 nDatetype;
+ OUString sFormula;
+ /*sal_Bool bIsDateTime =*/pFieldMark->IsDateTimeField(nDatetype, sFormula);
+
+ if (m_nSubType == SUBFIELD_DATETIME) //date time
+ {
+ ConvertDateTimeStart(pXFPara, pFieldMark);
+ }
+ else if (m_nSubType == SUBFIELD_CROSSREF) //cross ref
+ {
+ ConvertCrossRefStart(pXFPara, pFieldMark);
+ }
+ else if (m_nSubType == SUBFIELD_DOCPOWER)
+ {
+ ConvertDocFieldStart(pXFPara, pFieldMark);
+ }
+ }
+
+ if (pFieldMark->IsFormulaInsert())
+ {
+ XFTextContent* pSpan = new XFTextContent();
+ pSpan->SetText("<");
+ pXFPara->Add(pSpan);
+ }
+
+ pFieldMark->SetStart(true);
+}
+
+void LwpFribField::RegisterStyle(LwpFoundry* pFoundry)
+{
+ LwpFrib::RegisterStyle(pFoundry);
+ LwpFieldMark* pFieldMark = GetMarker();
+ if (!pFieldMark)
+ return;
+
+ sal_uInt8 type = GetType();
+ sal_uInt16 fieldType = pFieldMark->GetFieldType();
+
+ if (type == MARKER_START && fieldType == LwpFieldMark::FLD_FIELD)
+ {
+ RegisterTimeField(pFieldMark);
+ }
+
+ if (type == MARKER_START && m_bRevisionFlag)
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ pChangeMgr->AddChangeFrib(this);
+ pFieldMark->SetStartFrib(this);
+ pFieldMark->SetRevisionFlag(true);
+ }
+}
+
+void LwpFribField::RegisterTimeField(const LwpFieldMark* pFieldMark)
+{
+ OUString sFormula
+ = pFieldMark->GetFormula(); //now bookmark maybe not all register to bookmarkmgr,
+ if (sFormula == "TotalEditingTime") //so check field type now is not correct.
+ RegisterTotalTimeStyle();
+ else
+ {
+ sal_Int32 index = sFormula.indexOf(0x20); //space
+ if (index < 0)
+ return;
+
+ std::u16string_view tag = sFormula.subView(0, index);
+ if (tag == u"Now()" || tag == u"CreateDate" || tag == u"EditDate")
+ RegisterDateTimeStyle(sFormula.copy(index + 1));
+ }
+}
+
+void LwpFribField::RegisterTotalTimeStyle()
+{
+ std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle); //use the default format
+ pTimeStyle->SetTruncate(false);
+ pTimeStyle->AddMinute();
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
+}
+
+void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
+{
+ std::unique_ptr<XFDateStyle> pDateStyle;
+ std::unique_ptr<XFTimeStyle> pTimeStyle;
+ //DATE
+ if (sFormula.getLength() < 2)
+ return;
+ if (sFormula[1] == 'F')
+ {
+ if (sFormula == "%FLSystemShortDate")
+ {
+ pDateStyle = LwpTools::GetSystemDateStyle(false);
+ }
+ else if (sFormula == "%FLSystemLongDate")
+ {
+ pDateStyle = LwpTools::GetSystemDateStyle(true);
+ }
+ else if (sFormula == "%FLISODate1" || sFormula == "%FLYYYY/MM/DD")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay();
+ }
+ else if (sFormula == "%FLISODate2" || sFormula == "%FLYYYY/MM/DD HH:mm:SS")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddHour();
+ pDateStyle->AddText(":");
+ pDateStyle->AddMinute();
+ pDateStyle->AddText(":");
+ pDateStyle->AddSecond();
+ }
+ else if (sFormula == "%FLM/D/YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLMonth D, YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWeekday, Month D, YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLMn D, YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWday, Mn D, YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLMn D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLWeekday, Mn D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLMn D, YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLM/D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLM/YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLMn YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLWeekday")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ }
+ else if (sFormula == "%FLWday")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay(false);
+ }
+ else if (sFormula == "%FLMonth")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(true, true);
+ }
+ else if (sFormula == "%FLMn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLD")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLM")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ }
+ else if (sFormula == "%FLYYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear(false);
+ }
+ //chinese version begin
+ else if (sFormula == "%FLYY/M/D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear(false);
+ pDateStyle->AddText("-");
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("-");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLYYYY Month D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLWeekday, YYYY Month D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(",");
+ pDateStyle->AddYear();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLYYYY Mn D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLWday, YYYY Mn D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay(false);
+ pDateStyle->AddText(",");
+ pDateStyle->AddYear();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ //next 2 are the same with english version
+ else if (sFormula == "%FLYY Mn D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLYY/M")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("-");
+ pDateStyle->AddMonth(false);
+ }
+ else if (sFormula == "%FLYY Mn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLeeeeoa" || sFormula == "%FLffffooaa" || sFormula == "%FLEEEEOA")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ OUString sText;
+ pDateStyle->AddYear();
+ sText = OUString(u'\x5e74');
+ pDateStyle->AddText(sText);
+ pDateStyle->AddMonth(false);
+ sText = OUString(u'\x6708');
+ pDateStyle->AddText(sText);
+ pDateStyle->AddMonthDay(false);
+ sText = OUString(u'\x65e5');
+ pDateStyle->AddText(sText);
+ }
+ else if (sFormula == "%FLoa" || sFormula == "%FLooaa" || sFormula == "%FLOA")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ OUString sText;
+ pDateStyle->AddMonth(false);
+ sText = OUString(u'\x6708');
+ pDateStyle->AddText(sText);
+ pDateStyle->AddMonthDay(false);
+ sText = OUString(u'\x65e5');
+ pDateStyle->AddText(sText);
+ }
+ else if (sFormula == "%FLYYYY/M/D" || sFormula == "%FLGGGG/od/ad")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText("-");
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("-");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%FLYY.M.D")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear(false);
+ pDateStyle->AddText(".");
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText(".");
+ pDateStyle->AddMonthDay(false);
+ }
+ //chinese version end
+ //other version begin
+ else if (sFormula == "%FLWeekday, Month DD, YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLYYYY/MM/DD")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLD/M/YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLD Month YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLDD Month YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWeekday, D Month YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWeekday, DD Month YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLD Mn YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWday, D Mn YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLWday, DD Mn YYYY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%FLD Mn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLDD Mn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLWeekday, D Mn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLWeekday, DD Mn")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ }
+ else if (sFormula == "%FLD Mn YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLDD Mn YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(false, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLD/M")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth(false);
+ }
+ else if (sFormula == "%FLDD/MM")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth();
+ }
+ else if (sFormula == "%FLDD/MM/YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear(false);
+ }
+ else if (sFormula == "%FLMM/YY")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear(false);
+ }
+ //other version end
+ //TIME
+ else if (sFormula == "%FLSystemTime")
+ {
+ pTimeStyle = LwpTools::GetSystemTimeStyle();
+ }
+ else if (sFormula == "%FLISOTime1" || sFormula == "%FLH:mm:SS")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddSecond();
+ }
+ else if (sFormula == "%FLH:mm ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLH:mm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ }
+ else if (sFormula == "%FLH:mm:SS ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddSecond();
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLH:mm:SS")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddSecond();
+ }
+ else if (sFormula == "%FLH ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLH")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ }
+ else if (sFormula == "%FLmm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddMinute();
+ }
+ else if (sFormula == "%FLSS")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddSecond();
+ }
+ else if (sFormula == "%FLampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->SetAmPm(true);
+ }
+ //chinese version begin
+ else if (sFormula == "%FLjF" || sFormula == "%FLJFF" || sFormula == "%FLjjF"
+ || sFormula == "%FLJJFF ")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ OUString sText;
+ sText = OUString(u'\x70b9');
+ pTimeStyle->AddText(sText);
+ pTimeStyle->AddMinute(false);
+ sText = OUString(u'\x5206');
+ pTimeStyle->AddText(sText);
+ }
+ else if (sFormula == "%FLjjjF" || sFormula == "%FLJJJFF")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->SetAmPm(true);
+ pTimeStyle->AddHour(false);
+ OUString sText;
+ sText = OUString(u'\x70b9');
+ pTimeStyle->AddText(sText);
+ pTimeStyle->AddMinute(false);
+ sText = OUString(u'\x5206');
+ pTimeStyle->AddText(sText);
+ }
+ //chinese version end
+ //other version begin
+ else if (sFormula == "%FLHH:mm ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLHH ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLHH:mm:SS ampm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddSecond();
+ pTimeStyle->AddText(" ");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%FLHH:mm")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ }
+ else if (sFormula == "%FLHH:mm:SS")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddSecond();
+ }
+ //other version end
+ }
+ else if (sFormula[1] == 'D')
+ {
+ if (sFormula == "%Da")
+ {
+ pDateStyle = LwpTools::GetSystemDateStyle(false);
+ }
+ else if (sFormula == "%DB" || sFormula == "%Db")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%Dc" || sFormula == "%DC")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%Dd" || sFormula == "%DD")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(", ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(", ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%DE" || sFormula == "%De")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%Df" || sFormula == "%DF")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddWeekDay();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%Dg")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%Dh")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%Di" || sFormula == "%DI")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(".");
+ pDateStyle->AddMonth(true, true);
+ }
+ else if (sFormula == "%Dj" || sFormula == "%DJ")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay(false);
+ pDateStyle->AddText(".");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%Dk" || sFormula == "%DK")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddYear();
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(" ");
+ pDateStyle->AddMonthDay(false);
+ }
+ else if (sFormula == "%DL" || sFormula == "%Dl")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonth(true, true);
+ pDateStyle->AddText(",");
+ pDateStyle->AddYear();
+ }
+ else if (sFormula == "%Dm")
+ {
+ pDateStyle.reset(new XFDateStyle);
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear();
+ }
+ }
+ else if (sFormula[1] == 'T')
+ {
+ if (sFormula == "%T1")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ }
+ else if (sFormula == "%T2" || sFormula == "%T6" || sFormula == "%T4" || sFormula == "%T8")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour(false);
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->SetAmPm(true);
+ }
+ else if (sFormula == "%T3" || sFormula == "%T7" || sFormula == "%T5" || sFormula == "%T9")
+ {
+ pTimeStyle.reset(new XFTimeStyle);
+ pTimeStyle->AddHour();
+ pTimeStyle->AddText(":");
+ pTimeStyle->AddMinute();
+ pTimeStyle->AddText(":");
+ pTimeStyle->SetAmPm(true);
+ }
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ if (pDateStyle)
+ m_TimeStyle = pXFStyleManager->AddStyle(std::move(pDateStyle)).m_pStyle->GetStyleName();
+ if (pTimeStyle)
+ m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
+}
+
+void LwpFribField::CheckFieldType(LwpFieldMark* pFieldMark)
+{
+ sal_uInt8 nType;
+ OUString sFormula;
+ if (pFieldMark->IsDateTimeField(nType, sFormula))
+ {
+ m_nDateTimeType = nType;
+ m_sFormula = sFormula;
+ m_nSubType = SUBFIELD_DATETIME;
+ }
+ else if (pFieldMark->IsCrossRefField(nType, sFormula))
+ {
+ m_nCrossRefType = nType;
+ m_sFormula = sFormula;
+ m_nSubType = SUBFIELD_CROSSREF;
+ }
+ else if (pFieldMark->IsDocPowerField(nType, sFormula))
+ {
+ m_nDocPowerType = nType;
+ m_nSubType = SUBFIELD_DOCPOWER;
+ }
+ else
+ {
+ m_nSubType = SUBFIELD_INVALID;
+ }
+}
+
+void LwpFribField::ConvertDocFieldStart(XFContentContainer* pXFPara, LwpFieldMark* pFieldMark)
+{
+ XFContent* pContent = nullptr;
+ switch (m_nDocPowerType)
+ {
+ case LwpFieldMark::DOC_DESCRIPTION:
+ {
+ pContent = new XFDescriptionStart;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMPAGES:
+ {
+ pContent = new XFPageCountStart;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMWORDS:
+ {
+ pContent = new XFWordCountStart;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMCHARS:
+ {
+ pContent = new XFCharCountStart;
+ break;
+ }
+ }
+ if (!pContent)
+ return;
+
+ if (m_ModFlag) //(m_pModifiers)
+ {
+ XFTextSpanStart* pSpan = new XFTextSpanStart;
+ pSpan->SetStyleName(GetStyleName());
+ pSpan->Add(pContent);
+ pXFPara->Add(pSpan);
+ pFieldMark->SetStyleFlag(true);
+ }
+ else
+ pXFPara->Add(pContent);
+}
+
+void LwpFribField::ConvertDocFieldEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark)
+{
+ XFContent* pContent = nullptr;
+ switch (m_nDocPowerType)
+ {
+ case LwpFieldMark::DOC_DESCRIPTION:
+ {
+ pContent = new XFDescriptionEnd;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMPAGES:
+ {
+ pContent = new XFPageCountEnd;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMWORDS:
+ {
+ pContent = new XFWordCountEnd;
+ break;
+ }
+ case LwpFieldMark::DOC_NUMCHARS:
+ {
+ pContent = new XFCharCountEnd;
+ break;
+ }
+ }
+ if (pContent)
+ {
+ if (pFieldMark->GetStyleFlag())
+ {
+ XFTextSpanEnd* pSpan = new XFTextSpanEnd;
+ pSpan->Add(pContent);
+ pXFPara->Add(pSpan);
+ }
+ else
+ pXFPara->Add(pContent);
+ }
+}
+
+void LwpFribField::ConvertDateTimeStart(XFContentContainer* pXFPara, LwpFieldMark* pFieldMark)
+{
+ XFContent* pContent = nullptr;
+ switch (m_nDateTimeType)
+ {
+ case LwpFieldMark::DATETIME_NOW:
+ {
+ pContent = new XFDateStart;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case LwpFieldMark::DATETIME_CREATE:
+ {
+ pContent = new XFCreateTimeStart;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case LwpFieldMark::DATETIME_LASTEDIT:
+ {
+ pContent = new XFLastEditTimeStart;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case LwpFieldMark::DATETIME_TOTALTIME:
+ {
+ pContent = new XFTotalEditTimeStart;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ default:
+ break;
+ }
+ if (!pContent)
+ return;
+
+ if (m_ModFlag)
+ {
+ XFTextSpanStart* pSpan = new XFTextSpanStart;
+ pSpan->SetStyleName(GetStyleName());
+ pSpan->Add(pContent);
+ pXFPara->Add(pSpan);
+ pFieldMark->SetStyleFlag(true);
+ }
+ else
+ pXFPara->Add(pContent);
+}
+
+void LwpFribField::ConvertDateTimeEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark)
+{
+ XFContent* pContent = nullptr;
+ switch (m_nDateTimeType)
+ {
+ case LwpFieldMark::DATETIME_NOW:
+ {
+ pContent = new XFDateEnd;
+ break;
+ }
+ case LwpFieldMark::DATETIME_CREATE:
+ {
+ pContent = new XFCreateTimeEnd;
+ break;
+ }
+ case LwpFieldMark::DATETIME_LASTEDIT:
+ {
+ pContent = new XFLastEditTimeEnd;
+ break;
+ }
+ case LwpFieldMark::DATETIME_TOTALTIME:
+ {
+ pContent = new XFTotalEditTimeEnd;
+ break;
+ }
+ }
+ if (pContent)
+ {
+ if (pFieldMark->GetStyleFlag())
+ {
+ XFTextSpanEnd* pSpan = new XFTextSpanEnd;
+ pSpan->Add(pContent);
+ pXFPara->Add(pSpan);
+ }
+ else
+ pXFPara->Add(pContent);
+ }
+}
+
+void LwpFribField::ConvertCrossRefStart(XFContentContainer* pXFPara, LwpFieldMark* pFieldMark)
+{
+ XFCrossRefStart* pRef = new XFCrossRefStart;
+ pRef->SetRefType(m_nCrossRefType);
+ pRef->SetMarkName(m_sFormula);
+ // pFieldMark->SetStart(sal_True);//for some unusual cases
+ if (m_ModFlag)
+ {
+ XFTextSpanStart* pSpan = new XFTextSpanStart;
+ pSpan->SetStyleName(GetStyleName());
+ pSpan->Add(pRef);
+ pXFPara->Add(pSpan);
+ pFieldMark->SetStyleFlag(true);
+ }
+ else
+ pXFPara->Add(pRef);
+}
+
+void LwpFribField::ConvertCrossRefEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark)
+{
+ XFCrossRefEnd* pRef = new XFCrossRefEnd;
+ if (pFieldMark->GetStyleFlag())
+ {
+ XFTextSpanEnd* pSpan = new XFTextSpanEnd;
+ pSpan->Add(pRef);
+ pXFPara->Add(pSpan);
+ }
+ else
+ pXFPara->Add(pRef);
+}
+
+LwpFribRubyMarker::LwpFribRubyMarker(LwpPara* pPara)
+ : LwpFrib(pPara)
+ , m_nType(0)
+{
+}
+
+void LwpFribRubyMarker::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objMarker.ReadIndexed(pObjStrm);
+ m_nType = pObjStrm->QuickReaduInt8();
+}
+
+void LwpFribRubyMarker::XFConvert(XFContentContainer* pXFPara)
+{
+ sal_uInt8 type = GetType();
+ LwpRubyMarker* pMarker = dynamic_cast<LwpRubyMarker*>(m_objMarker.obj(VO_RUBYMARKER).get());
+
+ if (type == MARKER_START)
+ {
+ XFRubyStart* pRubyStart = new XFRubyStart;
+ if (pMarker)
+ {
+ pRubyStart->SetStyleName(pMarker->GetRubyStyleName());
+ }
+ pXFPara->Add(pRubyStart);
+ }
+ else if (type == MARKER_END)
+ {
+ XFRubyEnd* pRubyEnd = new XFRubyEnd;
+ if (pMarker)
+ {
+ pRubyEnd->SetText(pMarker->GetRubyText());
+ pRubyEnd->SetStyleName(pMarker->GetTextStyleName());
+ }
+ pXFPara->Add(pRubyEnd);
+ }
+}
+
+void LwpFribRubyMarker::RegisterStyle(LwpFoundry* /*pFoundry*/) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribmark.hxx b/lotuswordpro/source/filter/lwpfribmark.hxx
new file mode 100644
index 000000000..0f47b204a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribmark.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBMARK_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBMARK_HXX
+
+#include <lwpfrib.hxx>
+#include "lwpstory.hxx"
+#include "lwpmarker.hxx"
+#include <xfilter/xfbookmark.hxx>
+
+class LwpFribCHBlock : public LwpFrib
+{
+public:
+ explicit LwpFribCHBlock( LwpPara* pPara )
+ : LwpFrib(pPara)
+ , m_nType(0)
+ {}
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ enum{MARKER_START=1,MARKER_END,MARKER_NONE};
+ void XFConvert(XFContentContainer* pXFPara,LwpStory* pStory);
+private:
+ sal_uInt8 m_nType;
+ LwpObjectID m_objMarker;
+};
+
+class LwpFribBookMark : public LwpFrib
+{
+public:
+ explicit LwpFribBookMark( LwpPara* pPara );
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ const LwpObjectID& GetMarkerID() const {return m_objMarker;}
+ sal_uInt8 GetType() const {return m_nType;}
+ enum{MARKER_START=1,MARKER_END,MARKER_NONE};
+ void XFConvert(XFContentContainer* pXFPara);
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+private:
+ sal_uInt8 m_nType;
+ LwpObjectID m_objMarker;
+ rtl::Reference<XFBookmarkStart> m_xStart;
+ rtl::Reference<XFBookmarkEnd> m_xEnd;
+};
+
+class LwpFribField : public LwpFrib
+{
+public:
+ explicit LwpFribField( LwpPara* pPara );
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ LwpFieldMark* GetMarker();
+ sal_uInt8 GetType() const {return m_nType;}
+ enum{MARKER_START=1,MARKER_END,MARKER_NONE};
+ void XFConvert(XFContentContainer* pXFPara);
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+ enum{
+ SUBFIELD_INVALID = 0,
+ SUBFIELD_DATETIME = 1,
+ SUBFIELD_CROSSREF = 2,
+ SUBFIELD_DOCPOWER = 3,
+ };
+private:
+ sal_uInt8 m_nType;
+ LwpObjectID m_objMarker;
+ OUString m_TimeStyle;
+
+ sal_uInt8 m_nSubType;//datetime/crossref/other
+ OUString m_sFormula;
+
+ sal_uInt8 m_nCrossRefType;
+ sal_uInt8 m_nDateTimeType;
+ sal_uInt8 m_nDocPowerType;
+
+ void RegisterTimeField(const LwpFieldMark* pFieldMark);
+ void RegisterDateTimeStyle(const OUString& sFormula);
+ void RegisterTotalTimeStyle();
+ void CheckFieldType(LwpFieldMark* pFieldMark);
+ void ConvertDocFieldStart(XFContentContainer* pXFPara,LwpFieldMark* pFieldMark);
+ void ConvertDocFieldEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark);
+ void ConvertDateTimeStart(XFContentContainer* pXFPara,LwpFieldMark* pFieldMark);
+ void ConvertDateTimeEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark);
+ static void ConvertCrossRefEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark);
+ void ConvertCrossRefStart(XFContentContainer* pXFPara,LwpFieldMark* pFieldMark);
+};
+
+class LwpFribRubyMarker : public LwpFrib
+{
+public:
+ explicit LwpFribRubyMarker( LwpPara* pPara );
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ enum{MARKER_START=1,MARKER_END,MARKER_NONE};
+ void XFConvert(XFContentContainer* pXFPara);
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+private:
+ sal_uInt8 m_nType;
+ LwpObjectID m_objMarker;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribptr.cxx b/lotuswordpro/source/filter/lwpfribptr.cxx
new file mode 100644
index 000000000..01089461d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribptr.cxx
@@ -0,0 +1,596 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpfribptr.hxx"
+
+#include "lwpfribheader.hxx"
+#include "lwpfribtext.hxx"
+#include "lwppara.hxx"
+#include "lwpstory.hxx"
+#include <xfilter/xftextspan.hxx>
+#include <xfilter/xftabstop.hxx>
+#include <xfilter/xflinebreak.hxx>
+#include "lwpfribsection.hxx"
+#include "lwpsection.hxx"
+#include "lwpfribbreaks.hxx"
+#include "lwpfribframe.hxx"
+#include "lwpfribtable.hxx"
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include "lwphyperlinkmgr.hxx"
+#include "lwpfootnote.hxx"
+#include "lwpnotes.hxx"
+#include "lwpfribmark.hxx"
+#include <xfilter/xfchange.hxx>
+#include <lwpchangemgr.hxx>
+#include <lwpglobalmgr.hxx>
+#include <lwpdropcapmgr.hxx>
+
+LwpFribPtr::LwpFribPtr()
+ : m_pFribs(nullptr)
+ , m_pPara(nullptr)
+{
+}
+
+LwpFribPtr::~LwpFribPtr()
+{
+ for (LwpFrib* pCurFrib = m_pFribs; pCurFrib;)
+ {
+ LwpFrib* pNextFrib = pCurFrib -> GetNext();
+ delete pCurFrib;
+ pCurFrib = pNextFrib;
+ }
+}
+
+void LwpFribPtr::ReadPara(LwpObjectStream* pObjStrm)
+{
+ LwpFrib* pCurFrib = m_pFribs = nullptr;
+ for(;;)
+ {
+ // Get the frib type
+ sal_uInt8 FribTag = pObjStrm->QuickReaduInt8();
+
+ sal_uInt8 FribType = FribTag & ~FRIB_TAG_TYPEMASK;
+
+ // Stop when we hit Elvis
+ if (FribType == FRIB_TAG_ELVIS)
+ break;
+
+ // skip the editor ID
+ //pObjStrm->SeekRel(sizeof(sal_uInt8));
+ sal_uInt8 FribEditor = pObjStrm->QuickReaduInt8();
+ if( FribType != FT_MAXIMUM )
+ {
+ LwpFrib* pFrib = LwpFrib::CreateFrib( m_pPara, pObjStrm, FribTag,FribEditor);
+ if(!m_pFribs)
+ {
+ m_pFribs = pFrib;
+ }
+ if(pCurFrib)
+ {
+ pCurFrib->SetNext(pFrib);
+ }
+ else//first frib in the para
+ {
+ if (pFrib->GetType() == FRIB_TAG_TEXT)
+ {
+ LwpFribText* pText = static_cast<LwpFribText*>(pFrib);
+ if (pFrib->GetModifiers())
+ m_pPara->SetFirstFrib(pText->GetText(),pText->GetModifiers()->FontID);
+ else
+ m_pPara->SetFirstFrib(pText->GetText(),0);
+ }
+ }
+ pCurFrib = pFrib;
+ }
+ }
+}
+
+void LwpFribPtr::XFConvert()
+{
+ LwpFrib* pFrib = m_pFribs;
+ while(pFrib)
+ {
+ sal_uInt8 nFribType = pFrib->GetType();
+ bool bRevisionFlag = pFrib->GetRevisionFlag();
+ OUString sChangeID;
+ if (bRevisionFlag)
+ {
+ if ( nFribType!= FRIB_TAG_TABLE && nFribType != FRIB_TAG_FIELD
+ && nFribType != FRIB_TAG_FRAME)
+ {
+ //sal_uInt8 nRevisionType = pFrib->GetRevisionType();
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ sChangeID = pChangeMgr->GetChangeID(pFrib);
+ if (!sChangeID.isEmpty())
+ {
+ rtl::Reference<XFChangeStart> xChangeStart(new XFChangeStart);
+ xChangeStart->SetChangeID(sChangeID);
+ m_pXFPara->Add(xChangeStart.get());
+ }
+ }
+ }
+
+ switch(nFribType)
+ {
+ case FRIB_TAG_TEXT:
+ {
+ LwpFribText* textFrib= static_cast<LwpFribText*>(pFrib);
+ textFrib->XFConvert(m_pXFPara.get(),m_pPara->GetStory());
+ }
+ break;
+ case FRIB_TAG_TAB:
+ {
+ LwpFribTab* tabFrib = static_cast<LwpFribTab*>(pFrib);
+ if (pFrib->m_ModFlag)
+ {
+ rtl::Reference<XFTextSpan> xSpan(new XFTextSpan);
+ xSpan->SetStyleName(tabFrib->GetStyleName());
+ rtl::Reference<XFTabStop> xTab(new XFTabStop);
+ xSpan->Add(xTab.get());
+ m_pXFPara->Add(xSpan.get());
+ }
+ else
+ {
+ rtl::Reference<XFTabStop> xTab(new XFTabStop);
+ m_pXFPara->Add(xTab.get());
+ }
+ break;
+ }
+ case FRIB_TAG_SECTION:
+ {
+ LwpFribSection* pSectionFrib = static_cast<LwpFribSection*>(pFrib);
+ pSectionFrib->ParseSection();
+ break;
+ }
+
+ case FRIB_TAG_PAGEBREAK:
+ {
+ LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
+ LwpPageLayout* pLayout = dynamic_cast<LwpPageLayout*>(pPageBreak->GetLayout().obj().get());
+ if(pLayout)
+ {
+ pPageBreak->ParseLayout();
+ }
+ else
+ {
+ if (pPageBreak->IsLastFrib())
+ {
+ m_pXFPara->SetStyleName( pPageBreak->GetStyleName() );
+ }
+ else
+ {
+ //parse pagebreak
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(pFrib->GetStyleName());
+ SetXFPara(xPara.get());
+ m_pPara->AddXFContent(xPara.get());
+ }
+ }
+ break;
+ }
+ case FRIB_TAG_COLBREAK:
+ {
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(pFrib->GetStyleName());
+ SetXFPara(xPara.get());
+ m_pPara->AddXFContent(xPara.get());
+ break;
+ }
+ case FRIB_TAG_LINEBREAK:
+ {
+ rtl::Reference<XFLineBreak> xLineBreak(new XFLineBreak);
+ m_pXFPara->Add(xLineBreak.get());
+ break;
+ }
+ case FRIB_TAG_UNICODE: //fall through
+ case FRIB_TAG_UNICODE2: //fall through
+ case FRIB_TAG_UNICODE3: //fall through
+ {
+ LwpFribUnicode* unicodeFrib= static_cast<LwpFribUnicode*>(pFrib);
+ unicodeFrib->XFConvert(m_pXFPara.get(), m_pPara->GetStory());
+ }
+ break;
+ case FRIB_TAG_HARDSPACE:
+ {
+ OUString sHardSpace(u'\x00a0');
+ LwpStory *pStory = m_pPara->GetStory();
+ LwpHyperlinkMgr* pHyperlink = pStory ? pStory->GetHyperlinkMgr() : nullptr;
+ if (pHyperlink && pHyperlink->GetHyperlinkFlag())
+ pFrib->ConvertHyperLink(m_pXFPara.get(), pHyperlink,sHardSpace);
+ else
+ pFrib->ConvertChars(m_pXFPara.get(), sHardSpace);
+ }
+ break;
+ case FRIB_TAG_SOFTHYPHEN:
+ pFrib->ConvertChars(m_pXFPara.get(), u"\x00ad");
+ break;
+ case FRIB_TAG_FRAME:
+ {
+ LwpFribFrame* frameFrib= static_cast<LwpFribFrame*>(pFrib);
+ rtl::Reference<LwpObject> pLayout = frameFrib->GetLayout();
+ if (pLayout.is() && pLayout->GetTag() == VO_DROPCAPLAYOUT)
+ {
+ LwpFoundry* pFoundry = m_pPara->GetFoundry();
+ LwpDropcapMgr* pMgr = pFoundry ? pFoundry->GetDropcapMgr() : nullptr;
+ if (pMgr)
+ pMgr->SetXFPara(m_pXFPara.get());
+ }
+ frameFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_CHBLOCK:
+ {
+ LwpFribCHBlock* chbFrib = static_cast<LwpFribCHBlock*>(pFrib);
+ chbFrib->XFConvert(m_pXFPara.get(),m_pPara->GetStory());
+ }
+ break;
+ case FRIB_TAG_TABLE:
+ {
+ LwpFribTable* tableFrib = static_cast<LwpFribTable*>(pFrib);
+ //tableFrib->XFConvert(m_pPara->GetXFContainer());
+ tableFrib->XFConvert(m_pXFPara.get());
+ }
+ break;
+ case FRIB_TAG_BOOKMARK:
+ {
+ LwpFribBookMark* bookmarkFrib = static_cast<LwpFribBookMark*>(pFrib);
+ bookmarkFrib->XFConvert(m_pXFPara.get());
+ }
+ break;
+ case FRIB_TAG_FOOTNOTE:
+ {
+ LwpFribFootnote* pFootnoteFrib = static_cast<LwpFribFootnote*>(pFrib);
+ pFootnoteFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_FIELD:
+ {
+ LwpFribField* fieldFrib = static_cast<LwpFribField*>(pFrib);
+ fieldFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_NOTE:
+ {
+ LwpFribNote* pNoteFrib = static_cast<LwpFribNote*>(pFrib);
+ pNoteFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_PAGENUMBER:
+ {
+ LwpFribPageNumber* pagenumFrib = static_cast<LwpFribPageNumber*>(pFrib);
+ pagenumFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_DOCVAR:
+ {
+ LwpFribDocVar* docFrib = static_cast<LwpFribDocVar*>(pFrib);
+ docFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_RUBYMARKER:
+ {
+ LwpFribRubyMarker* rubyFrib = static_cast<LwpFribRubyMarker*>(pFrib);
+ rubyFrib->XFConvert(m_pXFPara.get());
+ break;
+ }
+ case FRIB_TAG_RUBYFRAME:
+ {
+ LwpFribRubyFrame* rubyfrmeFrib = static_cast<LwpFribRubyFrame*>(pFrib);
+ rubyfrmeFrib->XFConvert();
+ break;
+ }
+ default :
+ break;
+ }
+
+ if (bRevisionFlag )//&& pFrib->GetRevisionType() == LwpFrib::REV_INSERT)
+ {
+ if (nFribType!= FRIB_TAG_TABLE && nFribType != FRIB_TAG_FIELD
+ && nFribType != FRIB_TAG_FRAME)
+ {
+ if (!sChangeID.isEmpty())
+ {
+ rtl::Reference<XFChangeEnd> xChangeEnd(new XFChangeEnd);
+ xChangeEnd->SetChangeID(sChangeID);
+ m_pXFPara->Add(xChangeEnd.get());
+ }
+ }
+ }
+ pFrib = pFrib->GetNext();
+ }
+
+}
+
+/**************************************************************************
+ * @descr: Whether has a frib which type is nType
+**************************************************************************/
+LwpFrib* LwpFribPtr::HasFrib(sal_uInt8 nType)
+{
+ LwpFrib* pFrib = m_pFribs;
+ while(pFrib)
+ {
+ if(pFrib->GetType()==nType)
+ {
+ return pFrib;
+ }
+ pFrib = pFrib->GetNext();
+ }
+ return nullptr;
+}
+
+void LwpFribPtr::GatherAllText()
+{
+ LwpFrib* pFrib = m_pFribs;
+ while(pFrib)
+ {
+ switch(pFrib->GetType())
+ {
+ case FRIB_TAG_TEXT:
+ {
+ OUString sText = static_cast<LwpFribText*>(pFrib)->GetText();
+ m_pPara->SetAllText(sText);
+ break;
+ }
+ case FRIB_TAG_UNICODE: //fall through
+ case FRIB_TAG_UNICODE2: //fall through
+ case FRIB_TAG_UNICODE3: //fall through :
+ {
+ OUString sText = static_cast<LwpFribText*>(pFrib)->GetText();
+ m_pPara->SetAllText(sText);
+ break;
+ }
+ default :
+ break;
+ }
+ pFrib = pFrib->GetNext();
+ }
+}
+
+void LwpFribPtr::RegisterStyle()
+{
+ LwpFrib* pFrib = m_pFribs;
+ while(pFrib)
+ {
+ switch(pFrib->GetType())
+ {
+ case FRIB_TAG_TEXT:
+ {
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ OUString sText = static_cast<LwpFribText*>(pFrib)->GetText();
+ ProcessDropcap(m_pPara->GetStory(), pFrib,sText.getLength());
+ break;
+ }
+ case FRIB_TAG_TAB:
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ case FRIB_TAG_SECTION:
+ {
+ //section registerstyle here;
+ LwpFribSection* pSectionFrib = static_cast<LwpFribSection*>(pFrib);
+ pSectionFrib->RegisterSectionStyle();
+ //for bullet
+ pSectionFrib->SetSectionName();
+ }
+ break;
+ case FRIB_TAG_PAGEBREAK:
+ {
+ LwpFribPageBreak* breakFrib = static_cast<LwpFribPageBreak*>(pFrib);
+ breakFrib->RegisterBreakStyle(m_pPara);
+ }
+ break;
+ case FRIB_TAG_COLBREAK:
+ {
+ LwpFribColumnBreak* breakFrib = static_cast<LwpFribColumnBreak*>(pFrib);
+ breakFrib->RegisterBreakStyle(m_pPara);
+ }
+ break;
+ case FRIB_TAG_UNICODE: //fall through
+ case FRIB_TAG_UNICODE2: //fall through
+ case FRIB_TAG_UNICODE3: //fall through :
+ {
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ OUString sText = static_cast<LwpFribUnicode*>(pFrib)->GetText();
+ ProcessDropcap(m_pPara->GetStory(), pFrib,sText.getLength());
+ break;
+ }
+ case FRIB_TAG_HARDSPACE:
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ ProcessDropcap(m_pPara->GetStory(),pFrib,1);
+ break;
+ case FRIB_TAG_SOFTHYPHEN:
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ case FRIB_TAG_FRAME:
+ {
+ LwpFribFrame* frameFrib = static_cast<LwpFribFrame*>(pFrib);
+ frameFrib->SetParaDropcap(m_pPara);
+ frameFrib->RegisterStyle(m_pPara->GetFoundry());
+ //register framelayout style, ,03/09/2005
+ //frameFrib->GetLayout()->RegisterStyle();
+ }
+ break;
+ case FRIB_TAG_CHBLOCK:
+ break;
+ case FRIB_TAG_TABLE:
+ {
+ LwpFribTable* tableFrib = static_cast<LwpFribTable*>(pFrib);
+ tableFrib->RegisterNewStyle();
+ }
+ break;
+ case FRIB_TAG_FOOTNOTE:
+ {
+ LwpFribFootnote* pFribFootnote = static_cast<LwpFribFootnote*>(pFrib);
+ pFribFootnote->RegisterNewStyle();
+ }
+ break;
+ case FRIB_TAG_NOTE:
+ {
+ LwpFribNote* pNoteFrib = static_cast<LwpFribNote*>(pFrib);
+ pNoteFrib->RegisterNewStyle();
+ break;
+ }
+ case FRIB_TAG_PAGENUMBER:
+ {
+ pFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ }
+ case FRIB_TAG_DOCVAR:
+ {
+ LwpFribDocVar* docFrib = static_cast<LwpFribDocVar*>(pFrib);
+ docFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ }
+ case FRIB_TAG_FIELD:
+ {
+ LwpFribField* fieldFrib = static_cast<LwpFribField*>(pFrib);
+ fieldFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ }
+ case FRIB_TAG_BOOKMARK:
+ {
+ LwpFribBookMark* bookmarkFrib = static_cast<LwpFribBookMark*>(pFrib);
+ bookmarkFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ }
+ case FRIB_TAG_RUBYFRAME:
+ {
+ LwpFribRubyFrame* rubyfrmeFrib = static_cast<LwpFribRubyFrame*>(pFrib);
+ rubyfrmeFrib->RegisterStyle(m_pPara->GetFoundry());
+ break;
+ }
+ default :
+ break;
+ }
+ if (pFrib->GetRevisionFlag() && pFrib->GetType()!= FRIB_TAG_FIELD)
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ pChangeMgr->AddChangeFrib(pFrib);
+ }
+
+ pFrib = pFrib->GetNext();
+ }
+}
+
+void LwpFribPtr::ProcessDropcap(LwpStory* pStory, const LwpFrib* pFrib,sal_uInt32 nLen)
+{
+ if (pStory && pStory->GetDropcapFlag())
+ {
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFTextStyle* pFribStyle = pXFStyleManager->FindTextStyle(pFrib->GetStyleName());
+ pFribStyle->GetFont()->SetFontSize(0);
+
+ LwpDropcapLayout* pObj = dynamic_cast<LwpDropcapLayout*>(pStory->GetLayoutsWithMe().GetOnlyLayout().obj().get());
+ if (pObj)
+ pObj->SetChars(nLen);
+ }
+}
+/**
+ * @descr: If the position of pPreLayout is earlier than pNextLayout, return true, or return false, default return true
+ *
+*/
+bool LwpFribPtr::ComparePagePosition(LwpVirtualLayout const * pPreLayout, LwpVirtualLayout const * pNextLayout)
+{
+ if(!pPreLayout || !pNextLayout)
+ return true;
+
+ LwpFrib* pFrib = m_pFribs;
+ LwpVirtualLayout* pLayout = nullptr;
+ while(pFrib)
+ {
+ switch(pFrib->GetType())
+ {
+ case FRIB_TAG_SECTION:
+ {
+ LwpFribSection* pSectionFrib = static_cast<LwpFribSection*>(pFrib);
+ LwpSection* pSection = pSectionFrib->GetSection();
+ if(pSection)
+ {
+ pLayout = pSection->GetPageLayout();
+ }
+
+ break;
+ }
+ case FRIB_TAG_PAGEBREAK:
+ {
+ LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
+ pLayout = dynamic_cast<LwpVirtualLayout*>(pPageBreak->GetLayout().obj().get());
+ break;
+ }
+ default:
+ break;
+ }
+
+ if(pLayout)
+ {
+ if(pPreLayout == pLayout)
+ return true;
+ if(pNextLayout == pLayout)
+ return false;
+ }
+ pFrib = pFrib->GetNext();
+ }
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribptr.hxx b/lotuswordpro/source/filter/lwpfribptr.hxx
new file mode 100644
index 000000000..5014d2b25
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribptr.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBPTR_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBPTR_HXX
+
+#include <lwpobjstrm.hxx>
+#include <lwpfrib.hxx>
+#include "lwpstory.hxx"
+#include <xfilter/xfparagraph.hxx>
+
+class LwpPara;
+class LwpFribPtr
+{
+public:
+ LwpFribPtr();
+ ~LwpFribPtr();
+ void ReadPara(LwpObjectStream* pObjStrm);
+
+private:
+ LwpFrib* m_pFribs;
+ rtl::Reference<XFParagraph> m_pXFPara; //Current XFPara used for frib parsing
+ LwpPara* m_pPara; //for get foundry
+ static void ProcessDropcap(LwpStory* pStory, const LwpFrib* pFrib, sal_uInt32 nLen);
+
+public:
+ void XFConvert();
+ void SetXFPara(XFParagraph* Para) { m_pXFPara = Para; }
+ XFParagraph* GetXFPara() { return m_pXFPara.get(); }
+ void SetPara(LwpPara* para) { m_pPara = para; }
+ void RegisterStyle();
+ LwpFrib* GetFribs() { return m_pFribs; }
+ LwpFrib* HasFrib(sal_uInt8 nType);
+ bool ComparePagePosition(LwpVirtualLayout const* pPreLayout,
+ LwpVirtualLayout const* pNextLayout);
+ void GatherAllText();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
new file mode 100644
index 000000000..a65763f38
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -0,0 +1,452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * the class for section frib and process section and page layout
+ ************************************************************************/
+
+#include "lwpfribsection.hxx"
+#include "lwpstory.hxx"
+#include "lwpsection.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfsectionstyle.hxx>
+#include <xfilter/xfsection.hxx>
+#include <xfilter/xfindex.hxx>
+#include "lwpfribptr.hxx"
+#include <lwpglobalmgr.hxx>
+
+LwpFribSection::LwpFribSection(LwpPara* pPara)
+ : LwpFrib(pPara)
+{
+}
+
+LwpFribSection::~LwpFribSection() {}
+
+/**
+ * @descr: Read section frib information
+ *
+ */
+void LwpFribSection::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_Section.ReadIndexed(pObjStrm);
+}
+
+/**
+ * @descr: Get section pointer
+ *
+ */
+LwpSection* LwpFribSection::GetSection()
+{
+ return dynamic_cast<LwpSection*>(m_Section.obj().get());
+}
+
+/**
+ * @descr: Register section style
+ *
+ */
+void LwpFribSection::RegisterSectionStyle()
+{
+ LwpPageLayout* pLayout = GetPageLayout();
+ if (pLayout)
+ {
+ m_pMasterPage.reset(new LwpMasterPage(m_pPara, pLayout));
+ m_pMasterPage->RegisterMasterPage(this);
+ }
+}
+
+/**
+ * @descr: Register section style
+ *
+ */
+void LwpFribSection::SetSectionName()
+{
+ LwpSection* pSection = GetSection();
+ if (!pSection)
+ return;
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ if (!pStory)
+ return;
+ pStory->SetSectionName(pSection->GetSectionName());
+}
+
+/**
+ * @descr: Get page layout that current section points
+ *
+ */
+LwpPageLayout* LwpFribSection::GetPageLayout()
+{
+ if (LwpSection* pSection = GetSection())
+ return pSection->GetPageLayout();
+ return nullptr;
+}
+
+/**
+ * @descr: XFConvert section
+ *
+ */
+void LwpFribSection::ParseSection()
+{
+ LwpPageLayout* pLayout = GetPageLayout();
+ if (pLayout)
+ {
+ // StartWithinColume not support now
+ LwpLayout::UseWhenType eSectionType = pLayout->GetUseWhenType();
+ if (eSectionType == LwpLayout::StartWithinColume)
+ {
+ return;
+ }
+ if (m_pMasterPage)
+ {
+ m_pMasterPage->ParseSection(this);
+ }
+ }
+ else if (LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get()))
+ {
+ rtl::Reference<LwpObject> xObj(m_Section.obj());
+ if (xObj.is() && xObj->GetTag() == VO_INDEXSECTION)
+ {
+ //create a new section and add it to container
+ XFIndex* pIndex = new XFIndex;
+ pIndex->SetIndexType(enumXFIndexAlphabetical);
+ SetDefaultAlphaIndex(pIndex);
+
+ pStory->AddXFContent(pIndex);
+ m_pPara->SetXFContainer(pIndex);
+ }
+ else
+ {
+ XFContentContainer* pContent = pStory->GetXFContent();
+ m_pPara->SetXFContainer(pContent);
+ }
+ }
+}
+
+void LwpFribSection::SetDefaultAlphaIndex(XFIndex* pXFIndex)
+{
+ LwpFoundry* pFoundry = m_pPara->GetFoundry();
+ OUString styleName = pFoundry->FindActualStyleName("Separator");
+
+ LwpIndexSection* pIndexSection = dynamic_cast<LwpIndexSection*>(m_Section.obj().get());
+ XFIndexTemplate* pTemplateSep = new XFIndexTemplate();
+ if (pIndexSection && pIndexSection->IsFormatSeparator())
+ {
+ pXFIndex->SetSeparator(true);
+ pTemplateSep->AddEntry(enumXFIndexTemplateText, "");
+ }
+ //pXFIndex->AddTemplate("separator","Separator",pTemplateSep);
+ pXFIndex->AddTemplate("separator", styleName, pTemplateSep);
+
+ styleName = pFoundry->FindActualStyleName("Primary");
+
+ XFIndexTemplate* pTemplate1 = new XFIndexTemplate();
+ pTemplate1->AddEntry(enumXFIndexTemplateText, "");
+ pTemplate1->AddEntry(enumXFIndexTemplateTab, "");
+ pTemplate1->AddEntry(enumXFIndexTemplatePage, "");
+ //pXFIndex->AddTemplate(OUString::number(1),"Primary",pTemplate1);
+ pXFIndex->AddTemplate(OUString::number(1), styleName, pTemplate1);
+
+ XFIndexTemplate* pTemplate2 = new XFIndexTemplate();
+ pTemplate2->AddEntry(enumXFIndexTemplateText, "");
+ pTemplate2->AddEntry(enumXFIndexTemplateTab, "");
+ pTemplate2->AddEntry(enumXFIndexTemplatePage, "");
+ XFIndexTemplate* pTemplate3 = new XFIndexTemplate();
+ pTemplate3->AddEntry(enumXFIndexTemplateText, "");
+ pTemplate3->AddEntry(enumXFIndexTemplateTab, "");
+ pTemplate3->AddEntry(enumXFIndexTemplatePage, "");
+
+ if (pIndexSection && pIndexSection->IsFormatRunin())
+ {
+ //pXFIndex->AddTemplate(OUString::number(2),"Primary",pTemplate2);
+ //pXFIndex->AddTemplate(OUString::number(3),"Primary",pTemplate3);
+ pXFIndex->AddTemplate(OUString::number(2), styleName, pTemplate2);
+ pXFIndex->AddTemplate(OUString::number(3), styleName, pTemplate3);
+ }
+ else
+ {
+ //pXFIndex->AddTemplate(OUString::number(2),"Secondary",pTemplate2);
+ //pXFIndex->AddTemplate(OUString::number(3),"Secondary",pTemplate3);
+ styleName = pFoundry->FindActualStyleName("Secondary");
+ pXFIndex->AddTemplate(OUString::number(2), styleName, pTemplate2);
+ pXFIndex->AddTemplate(OUString::number(3), styleName, pTemplate3);
+ }
+}
+
+LwpMasterPage::LwpMasterPage(LwpPara* pPara, LwpPageLayout* pLayout)
+ : m_bNewSection(false)
+ , m_pPara(pPara)
+ , m_pLayout(pLayout)
+{
+}
+
+/**
+ * @descr: Register master page style for para style and register section style if necessary
+ *
+ */
+void LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
+{
+ //if there is no other frib after current frib, register master page in starting para of next page
+ LwpStory* pStory = nullptr;
+ if (IsNextPageType() && (!pFrib->HasNextFrib()))
+ pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+
+ if (pStory)
+ {
+ pStory->SetCurrentLayout(m_pLayout);
+ RegisterFillerPageStyle();
+ return;
+ }
+
+ m_bNewSection = false;
+ //sal_Bool bSectionColumns = sal_False;
+
+ std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
+ *xOverStyle = *(m_pPara->GetXFParaStyle());
+ xOverStyle->SetStyleName("");
+
+ LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
+ switch (eUserType)
+ {
+ case LwpLayout::StartWithinColume: //not support now
+ {
+ m_bNewSection = false;
+ break;
+ }
+ case LwpLayout::StartWithinPage:
+ {
+ m_bNewSection = true;
+ //bSectionColumns = sal_True;
+ break;
+ }
+ case LwpLayout::StartOnNextPage: //fall through
+ case LwpLayout::StartOnOddPage: //fall through
+ case LwpLayout::StartOnEvenPage:
+ {
+ pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ if (pStory)
+ {
+ pStory->SetCurrentLayout(m_pLayout);
+ //get odd page layout when the current pagelayout is mirror
+ m_pLayout = pStory->GetCurrentLayout();
+ m_bNewSection = IsNeedSection();
+ //bSectionColumns = m_bNewSection;
+ xOverStyle->SetMasterPage(m_pLayout->GetStyleName());
+ RegisterFillerPageStyle();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ //register tab style;
+ pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ if (!pStory)
+ return;
+
+ pStory->SetTabLayout(m_pLayout);
+ m_pPara->RegisterTabStyle(xOverStyle.get());
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+ //register section style here
+ if (!m_bNewSection)
+ return;
+
+ std::unique_ptr<XFSectionStyle> pSectStyle(new XFSectionStyle());
+ //set margin
+ pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ LwpPageLayout* pCurrentLayout = pStory ? pStory->GetCurrentLayout() : nullptr;
+ if (pCurrentLayout)
+ {
+ double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT)
+ - pCurrentLayout->GetMarginsValue(MARGIN_LEFT);
+ double fRight = m_pLayout->GetMarginsValue(MARGIN_RIGHT)
+ - pCurrentLayout->GetMarginsValue(MARGIN_RIGHT);
+ pSectStyle->SetMarginLeft(fLeft);
+ pSectStyle->SetMarginRight(fRight);
+ }
+
+ XFColumns* pColumns = m_pLayout->GetXFColumns();
+ if (pColumns)
+ {
+ pSectStyle->SetColumns(pColumns);
+ }
+ m_SectionStyleName = pXFStyleManager->AddStyle(std::move(pSectStyle)).m_pStyle->GetStyleName();
+}
+
+/**
+ * @descr: Whether it needs to create a new section
+ *
+ */
+bool LwpMasterPage::IsNeedSection()
+{
+ bool bNewSection = false;
+ //get story
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ //if pagelayout is modified, register the pagelayout
+ if (pStory && pStory->IsPMModified())
+ {
+ bNewSection = pStory->IsNeedSection();
+ }
+ return bNewSection;
+}
+
+/**
+ * @descr: Create XFSection if necessary
+ *
+ */
+XFSection* LwpMasterPage::CreateXFSection()
+{
+ if (m_bNewSection)
+ {
+ //new a section
+ XFSection* pXFSection = new XFSection();
+ pXFSection->SetStyleName(m_SectionStyleName);
+ return pXFSection;
+ }
+ return nullptr;
+}
+
+/**
+ * @descr: Parse section
+ *
+ */
+void LwpMasterPage::ParseSection(LwpFrib* pFrib)
+{
+ LwpFribPtr& rFribPtr = m_pPara->GetFribs();
+ //XFParagraph * pXFPara = rFribPtr.GetXFPara();
+
+ //parse fillerpage text
+ if (m_pLayout->HasFillerPageText(m_pPara->GetFoundry()))
+ {
+ XFParagraph* pPara = new XFParagraph();
+ pPara->SetStyleName(m_FillerPageStyleName);
+ m_pPara->AddXFContent(pPara);
+ rFribPtr.SetXFPara(pPara);
+
+ m_pLayout->ConvertFillerPageText(m_pPara->GetXFContainer());
+ }
+ //create a new section and add it to container
+ XFContentContainer* pContent = CreateXFSection();
+ if (pContent)
+ {
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ //delete the additional blank para
+ XFParagraph* pCurrPara = rFribPtr.GetXFPara();
+ if (!pCurrPara->HasContents())
+ {
+ XFContentContainer* pCurrContainer = m_pPara->GetXFContainer();
+ if (pFrib->HasNextFrib() && (pCurrContainer->GetLastContent() == pCurrPara))
+ {
+ pCurrContainer->RemoveLastContent();
+ }
+ }
+ if (pStory)
+ pStory->AddXFContent(pContent);
+ }
+ else
+ {
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
+ pContent = pStory ? pStory->GetXFContent() : nullptr;
+ }
+ if (pContent)
+ {
+ m_pPara->SetXFContainer(pContent);
+ }
+ //out put the contents after the section frib in the same para.
+ if (pFrib->HasNextFrib())
+ {
+ XFParagraph* pNextPara = new XFParagraph();
+ pNextPara->SetStyleName(m_StyleName);
+ m_pPara->AddXFContent(pNextPara);
+ rFribPtr.SetXFPara(pNextPara);
+ }
+}
+
+/**
+ * @descr: Register filler page text style
+ *
+ */
+void LwpMasterPage::RegisterFillerPageStyle()
+{
+ LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
+ if (eUserType != LwpLayout::StartOnOddPage && eUserType != LwpLayout::StartOnEvenPage)
+ return;
+
+ if (m_pLayout->HasFillerPageText(m_pPara->GetFoundry()))
+ {
+ std::unique_ptr<XFParaStyle> pPagebreakStyle(new XFParaStyle);
+ *pPagebreakStyle = *(m_pPara->GetXFParaStyle());
+ pPagebreakStyle->SetStyleName("");
+ pPagebreakStyle->SetBreaks(enumXFBreakAftPage);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_FillerPageStyleName
+ = pXFStyleManager->AddStyle(std::move(pPagebreakStyle)).m_pStyle->GetStyleName();
+ }
+}
+
+/**
+ * @descr: Whether the layout is next page type
+ *
+ */
+bool LwpMasterPage::IsNextPageType()
+{
+ LwpLayout::UseWhenType eUserType = m_pLayout->GetUseWhenType();
+ return eUserType == LwpLayout::StartOnNextPage || eUserType == LwpLayout::StartOnOddPage
+ || eUserType == LwpLayout::StartOnEvenPage;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribsection.hxx b/lotuswordpro/source/filter/lwpfribsection.hxx
new file mode 100644
index 000000000..0f1da0ff6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribsection.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * the class for section frib and process section and page layout
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBSECTION_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBSECTION_HXX
+
+#include <lwpfrib.hxx>
+#include "lwppara.hxx"
+
+/**
+ * @brief Process page layout for inserting pagelayout or section
+ *
+ */
+class LwpMasterPage
+{
+public:
+ LwpMasterPage(LwpPara* pPara, LwpPageLayout* pLayout);
+
+public:
+ //for page layout register and parse
+ void RegisterMasterPage(LwpFrib* pFrib);
+ void RegisterFillerPageStyle();
+ void ParseSection(LwpFrib* pFrib);
+ XFSection* CreateXFSection();
+
+ bool IsNextPageType();
+
+private:
+ bool IsNeedSection();
+
+private:
+ bool m_bNewSection;
+ OUString m_FillerPageStyleName;
+ OUString m_SectionStyleName;
+ OUString m_StyleName; //master page style name
+
+ LwpPara* m_pPara;
+ LwpPageLayout* m_pLayout;
+};
+
+/**
+ * @brief FRIB_TAB_SECTION object
+ *
+ */
+class LwpSection;
+class XFIndex;
+class LwpFribSection : public LwpFrib
+{
+public:
+ explicit LwpFribSection(LwpPara* pPara);
+ virtual ~LwpFribSection() override;
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ LwpSection* GetSection();
+ void RegisterSectionStyle();
+ void ParseSection();
+ void SetSectionName();
+
+ LwpPageLayout* GetPageLayout();
+
+private:
+ void SetDefaultAlphaIndex(XFIndex* pXFIndex);
+
+private:
+ LwpObjectID m_Section;
+ std::unique_ptr<LwpMasterPage> m_pMasterPage;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx
new file mode 100644
index 000000000..d94f2f845
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribtable.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "lwpfribtable.hxx"
+#include "lwppara.hxx"
+#include "lwptablelayout.hxx"
+#include <lwpchangemgr.hxx>
+#include <lwpglobalmgr.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfchange.hxx>
+
+/**
+ * @short: Read table frib
+ */
+void LwpFribTable::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_objTable.ReadIndexed(pObjStrm);
+}
+
+LwpSuperTableLayout* LwpFribTable::GetSuperTable()
+{
+ return dynamic_cast<LwpSuperTableLayout*>(m_objTable.obj().get());
+}
+
+void LwpFribTable::RegisterNewStyle()
+{
+ LwpSuperTableLayout* pSuper = GetSuperTable();
+ if (pSuper)
+ pSuper->RegisterNewStyle();
+ XFParaStyle* pOldStyle = m_pPara->GetXFParaStyle();
+ if (HasNextFrib())
+ {
+ if (pOldStyle->GetMasterPage().isEmpty())
+ m_StyleName = pOldStyle->GetStyleName();
+ else
+ {
+ std::unique_ptr<XFParaStyle> xParaStyle(new XFParaStyle);
+ *xParaStyle = *pOldStyle;
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xParaStyle)).m_pStyle->GetStyleName();
+ }
+ }
+}
+
+void LwpFribTable::XFConvert(XFContentContainer* pCont)
+{
+ XFContentContainer* pXFContentContainer = pCont;
+ LwpSuperTableLayout* pSuper = GetSuperTable();
+ if (!pSuper)
+ return;
+ sal_uInt8 nType = pSuper->GetRelativeType();
+ rtl::Reference<LwpVirtualLayout> xContainer(pSuper->GetContainerLayout());
+ if (!xContainer.is())
+ return;
+ if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType && !xContainer->IsCell())
+ {
+ pXFContentContainer = m_pPara->GetXFContainer();
+ //delete the additional blank para
+ XFParagraph* pCurrPara = m_pPara->GetFribs().GetXFPara();
+ if (pXFContentContainer && !pCurrPara->HasContents())
+ {
+ if (pXFContentContainer->GetLastContent() == pCurrPara)
+ {
+ pXFContentContainer->RemoveLastContent();
+ }
+ }
+ }
+ else if (LwpLayoutRelativityGuts::LAY_PARA_RELATIVE == nType)
+ {
+ //same page as text and in frame
+ if (xContainer->IsFrame())
+ {
+ pXFContentContainer = m_pPara->GetXFContainer();
+ }
+ else if (xContainer->IsCell())
+ {
+ //same page as text and in cell, get the first xfpara
+ rtl::Reference<XFContent> first(pCont->FindFirstContent(enumXFContentPara));
+ XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
+ if (pXFFirtPara)
+ pXFContentContainer = pXFFirtPara;
+ }
+ }
+ OUString sChangeID;
+ if (m_bRevisionFlag)
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ sChangeID = pChangeMgr->GetChangeID(this);
+ if (!sChangeID.isEmpty() && pXFContentContainer)
+ {
+ rtl::Reference<XFChangeStart> xChangeStart(new XFChangeStart);
+ xChangeStart->SetChangeID(sChangeID);
+ pXFContentContainer->Add(xChangeStart.get());
+ }
+ }
+
+ if (pXFContentContainer)
+ pSuper->XFConvert(pXFContentContainer);
+
+ if (m_bRevisionFlag)
+ {
+ if (!sChangeID.isEmpty() && pXFContentContainer)
+ {
+ rtl::Reference<XFChangeEnd> xChangeEnd(new XFChangeEnd);
+ xChangeEnd->SetChangeID(sChangeID);
+ pXFContentContainer->Add(xChangeEnd.get());
+ }
+ }
+
+ if (LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType && HasNextFrib())
+ {
+ rtl::Reference<XFParagraph> xXFPara(new XFParagraph);
+ xXFPara->SetStyleName(m_StyleName);
+ m_pPara->AddXFContent(xXFPara.get());
+ m_pPara->GetFribs().SetXFPara(xXFPara.get());
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribtable.hxx b/lotuswordpro/source/filter/lwpfribtable.hxx
new file mode 100644
index 000000000..82eb91cb6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribtable.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBTABLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBTABLE_HXX
+
+#include <lwpfrib.hxx>
+
+class LwpSuperTableLayout;
+class LwpFribTable : public LwpFrib
+{
+public:
+ explicit LwpFribTable(LwpPara* pPara)
+ : LwpFrib(pPara)
+ {
+ }
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ LwpSuperTableLayout* GetSuperTable();
+ void RegisterNewStyle();
+ void XFConvert(XFContentContainer* pCont);
+
+private:
+ LwpObjectID m_objTable;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribtext.cxx b/lotuswordpro/source/filter/lwpfribtext.cxx
new file mode 100644
index 000000000..b48050be6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribtext.cxx
@@ -0,0 +1,424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpglobalmgr.hxx>
+#include "lwpfribtext.hxx"
+#include "lwpcharsetmgr.hxx"
+#include "lwphyperlinkmgr.hxx"
+#include <lwptools.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftextspan.hxx>
+#include <xfilter/xfpagenumber.hxx>
+#include <xfilter/xfdocfield.hxx>
+#include <xfilter/xfdatestyle.hxx>
+#include <xfilter/xftimestyle.hxx>
+#include <xfilter/xfpagecount.hxx>
+
+LwpFribText::LwpFribText( LwpPara *pPara, bool bNoUnicode )
+ : LwpFrib(pPara), m_bNoUnicode(bNoUnicode)
+{}
+
+void LwpFribText::Read(LwpObjectStream* pObjStrm, sal_uInt16 len)
+{
+ if( len<1 )
+ return;
+
+ rtl_TextEncoding rEncode;
+ if(m_bNoUnicode)
+ {
+ rEncode = RTL_TEXTENCODING_ISO_8859_1;
+ }
+ else
+ {
+ if (m_pModifiers && m_pModifiers->CodePage)
+ rEncode = LwpCharSetMgr::GetInstance()->
+ GetTextCharEncoding(m_pModifiers->CodePage);
+ else
+ rEncode = LwpCharSetMgr::GetTextCharEncoding();
+ }
+ LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
+}
+
+void LwpFribText::XFConvert(XFContentContainer* pXFPara,LwpStory* pStory)
+{
+ if (!pStory)
+ return;
+ LwpHyperlinkMgr* pHyperlink = pStory->GetHyperlinkMgr();
+ if (pHyperlink->GetHyperlinkFlag())
+ LwpFrib::ConvertHyperLink(pXFPara,pHyperlink,GetText());
+ else
+ LwpFrib::ConvertChars(pXFPara,GetText());
+}
+
+/**
+ * @short: Reading mothed of paranumber frib.
+ * @param: pObjStrm wordpro object stream.
+ * @param: len length of the frib
+ */
+void LwpFribParaNumber::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_nStyleID = pObjStrm->QuickReaduInt16();
+ m_nNumberChar = pObjStrm->QuickReaduInt16();
+ m_nLevel = pObjStrm->QuickReaduInt16();
+ m_nStart = pObjStrm->QuickReaduInt16();
+}
+
+/**
+ * @short: default constructor of LwpFribDocVar
+ */
+LwpFribDocVar::LwpFribDocVar(LwpPara* pPara)
+ : LwpFrib(pPara), m_nType(0)
+{
+}
+/**
+ * @short: destructor of LwpFribDocVar
+ */
+LwpFribDocVar::~LwpFribDocVar()
+{
+}
+/**
+ * @short: Reading mothed of document variable frib.
+ * @param: pObjStrm wordpro object stream.
+ * @param: len length of the frib
+ */
+void LwpFribDocVar::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_nType = pObjStrm->QuickReaduInt16();
+ m_aName.Read(pObjStrm);
+}
+
+/**
+ * @short: register style for doc field (text style,date style)
+ */
+void LwpFribDocVar::RegisterStyle(LwpFoundry* pFoundry)
+{
+ LwpFrib::RegisterStyle(pFoundry);
+
+ switch(m_nType)
+ {
+ case DATECREATED:
+ case DATELASTREVISION:
+ {
+ RegisterDefaultTimeStyle();
+ }
+ break;
+ case TOTALEDITTIME:
+ RegisterTotalTimeStyle();
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * @short: register default time style for doc field
+ */
+void LwpFribDocVar::RegisterDefaultTimeStyle()
+{
+ std::unique_ptr<XFDateStyle> pDateStyle(new XFDateStyle);//use the default format
+
+ pDateStyle->AddMonth();
+ pDateStyle->AddText("/");
+ pDateStyle->AddMonthDay();
+ pDateStyle->AddText("/");
+ pDateStyle->AddYear();
+ pDateStyle->AddText(",");
+ pDateStyle->AddHour();
+ pDateStyle->AddText(":");
+ pDateStyle->AddMinute();
+ pDateStyle->AddText(":");
+ pDateStyle->AddSecond();
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_TimeStyle = pXFStyleManager->AddStyle(std::move(pDateStyle)).m_pStyle->GetStyleName();
+}
+void LwpFribDocVar::RegisterTotalTimeStyle()
+{
+ std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);//use the default format
+ pTimeStyle->SetTruncate(false);
+ pTimeStyle->AddMinute();
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
+}
+
+/**
+ * @short: convert the doc info field
+ */
+void LwpFribDocVar::XFConvert(XFContentContainer* pXFPara)
+{
+ XFContent* pContent=nullptr;
+ switch(m_nType)
+ {
+ case FILENAME:
+ {
+ pContent = new XFFileName;
+ static_cast<XFFileName*>(pContent)->SetType("FileName");
+ break;
+ }
+ case PATH:
+ {
+ pContent = new XFFileName;
+ static_cast<XFFileName*>(pContent)->SetType("Path");
+ break;
+ }
+ case DESCRIPTION:
+ pContent = new XFDescription;
+ break;
+ case DATECREATED:
+ {
+ pContent = new XFCreateTime;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case DATELASTREVISION:
+ {
+ pContent = new XFLastEditTime;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case NUMPAGES:
+ pContent = new XFPageCount;
+ break;
+ case NUMWORDS:
+ pContent = new XFWordCount;
+ break;
+ case NUMCHARS:
+ pContent = new XFCharCount;
+ break;
+ case TOTALEDITTIME:
+ {
+ pContent = new XFTotalEditTime;
+ pContent->SetStyleName(m_TimeStyle);
+ break;
+ }
+ case KEYWORDS:
+ pContent = new XFKeywords;
+ break;
+ case CREATEDBY:
+ pContent = new XFInitialCreator;
+ break;
+ case DOCSIZE:
+/* pContent = new XFAnnotation;
+ XFTextContent* pSpan = new XFTextContent();
+ pSpan->SetText("Document Size is Here");
+ XFParagraph* pPara = new XFParagraph;
+ pPara->Add(pSpan);
+ static_cast<XFAnnotation*>(pContent)->Add(pPara);
+ break;
+*/
+ LwpFrib::ConvertChars(pXFPara,"<Document Size>");
+ return;
+ case SMARTMASTER:
+ LwpFrib::ConvertChars(pXFPara,"<Smart master>");
+ return;
+ case DIVISIONNAME:
+ LwpFrib::ConvertChars(pXFPara,"<Division name>");
+ return;
+ case SECTIONNAME:
+ LwpFrib::ConvertChars(pXFPara,"<Section name>");
+ return;
+ case VERSIONCREATEBY:
+ LwpFrib::ConvertChars(pXFPara,"<Version Creat by>");
+ return;
+ case VERSIONCREATEDATE:
+ LwpFrib::ConvertChars(pXFPara,"<Version Creat date>");
+ return;
+ case VERSIONOTHEREDITORS:
+ LwpFrib::ConvertChars(pXFPara,"<Version other Editors>");
+ return;
+ case VERSIONNAME:
+ LwpFrib::ConvertChars(pXFPara,"<Version Name>");
+ return;
+ case VERSIONNUMBER:
+ LwpFrib::ConvertChars(pXFPara,"<Version Numbers>");
+ return;
+ case ALLVERSIONNAME:
+ LwpFrib::ConvertChars(pXFPara,"<All Version Name>");
+ return;
+ case VERSIONREMARK:
+ LwpFrib::ConvertChars(pXFPara,"<Version Remark>");
+ return;
+ case DOCUMENTCATEGORY:
+ LwpFrib::ConvertChars(pXFPara,"<Document Category>");
+ return;
+ case VERSIONLASTDATE:
+ LwpFrib::ConvertChars(pXFPara,"<Version Last Modify Date>");
+ return;
+ case VERSIONLASTEDITOR:
+ LwpFrib::ConvertChars(pXFPara,"<Version Last Editor>");
+ return;
+ case LASTEDIT:
+ LwpFrib::ConvertChars(pXFPara,"<Last Editor>");
+ return;
+ case OTHEREDITORS:
+ LwpFrib::ConvertChars(pXFPara,"<Other Editors>");
+ return;
+ case NUMOFREVISION:
+ LwpFrib::ConvertChars(pXFPara,"<Number of Revision>");
+ return;
+ default:
+ return;
+ }
+ if (m_ModFlag)//(m_pModifiers)
+ {
+ XFTextSpan *pSpan = new XFTextSpan;
+ pSpan->SetStyleName(GetStyleName());
+ pSpan->Add(pContent);
+ pXFPara->Add(pSpan);
+ }
+ else
+ pXFPara->Add(pContent);
+
+}
+/**
+ * @short: Read unicode
+ */
+void LwpFribUnicode::Read(LwpObjectStream* pObjStrm, sal_uInt16 len)
+{
+ if(len>1)
+ {
+ rtl_TextEncoding rEncode;
+
+ if (m_pModifiers && m_pModifiers->CodePage)
+ rEncode = LwpCharSetMgr::GetInstance()->
+ GetTextCharEncoding(m_pModifiers->CodePage);
+ else
+ rEncode = LwpCharSetMgr::GetTextCharEncoding();
+
+ LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
+
+ }
+ else
+ pObjStrm->SeekRel(len);
+}
+
+void LwpFribUnicode::XFConvert(XFContentContainer* pXFPara,LwpStory* pStory)
+{
+ if (!pStory)
+ return;
+ LwpHyperlinkMgr* pHyperlink = pStory->GetHyperlinkMgr();
+ if (pHyperlink->GetHyperlinkFlag())
+ LwpFrib::ConvertHyperLink(pXFPara,pHyperlink,GetText());
+ else
+ LwpFrib::ConvertChars(pXFPara,GetText());
+}
+
+/**
+ * @short: Read page number
+ */
+void LwpFribPageNumber::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_nNumStyle = pObjStrm->QuickReaduInt16();
+ m_aBefText.Read(pObjStrm);
+ m_aAfterText.Read(pObjStrm);
+ m_nStartNum = pObjStrm->QuickReaduInt16();
+ m_nStartOnPage = pObjStrm->QuickReaduInt16();
+ m_nFlag = pObjStrm->QuickReaduInt16();
+}
+
+void LwpFribPageNumber::XFConvert(XFContentContainer* pXFPara)
+{
+ if (m_nNumStyle == 0x0)
+ return;
+ XFPageNumber* pNum = new XFPageNumber;
+// pNum->SetSelect("current");
+ switch(m_nNumStyle)
+ {
+ case 0x01:
+ pNum->SetNumFmt("1");
+ break;
+ case 0x02:
+ pNum->SetNumFmt("A");
+ break;
+ case 0x03:
+ pNum->SetNumFmt("a");
+ break;
+ case 0x04:
+ pNum->SetNumFmt("I");
+ break;
+ case 0x05:
+ pNum->SetNumFmt("i");
+ break;
+ }
+ OUString styleName = GetStyleName();
+ if (!m_aBefText.str().isEmpty())
+ {
+ OUString textStr = m_aBefText.str();
+ XFTextSpan *pBef = new XFTextSpan(textStr,styleName);
+ pXFPara->Add(pBef);
+ }
+ if (m_ModFlag)//(m_pModifiers)
+ {
+ XFTextSpan *pSpan = new XFTextSpan;
+ pSpan->SetStyleName(styleName);
+ pSpan->Add(pNum);
+ pXFPara->Add(pSpan);
+ }
+ else
+ pXFPara->Add(pNum);
+ if (!m_aAfterText.str().isEmpty())
+ {
+ OUString textStr = m_aAfterText.str();
+ XFTextSpan *pAfter = new XFTextSpan(textStr,styleName);
+ pXFPara->Add(pAfter);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpfribtext.hxx b/lotuswordpro/source/filter/lwpfribtext.hxx
new file mode 100644
index 000000000..cc1c5b83c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpfribtext.hxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBTEXT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPFRIBTEXT_HXX
+
+#include <lwpfrib.hxx>
+#include "lwpstory.hxx"
+class LwpFribText : public LwpFrib
+{
+public:
+ LwpFribText( LwpPara* pPara, bool bNoUnicode);
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void XFConvert(XFContentContainer* pXFPara,LwpStory* pStory);
+private:
+ OUString m_Content;
+ bool m_bNoUnicode;
+public:
+ const OUString& GetText() const {return m_Content;}
+};
+
+class LwpFribHardSpace : public LwpFrib
+{
+public:
+ explicit LwpFribHardSpace( LwpPara* pPara ) : LwpFrib(pPara){}
+};
+
+class LwpFribSoftHyphen : public LwpFrib
+{
+public:
+ explicit LwpFribSoftHyphen( LwpPara* pPara ) : LwpFrib(pPara){}
+};
+
+class LwpFribParaNumber : public LwpFrib
+{
+public:
+ explicit LwpFribParaNumber( LwpPara* pPara ) : LwpFrib(pPara),
+ m_nStyleID(0), m_nNumberChar(0), m_nLevel(1), m_nStart(0){}
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+
+ inline sal_uInt16 GetStyleID() const;
+
+ inline sal_uInt16 GetNumberChar() const;
+
+ inline sal_uInt16 GetStart() const;
+
+private:
+ sal_uInt16 m_nStyleID;
+ sal_uInt16 m_nNumberChar;
+ sal_uInt16 m_nLevel;
+ sal_uInt16 m_nStart;
+};
+inline sal_uInt16 LwpFribParaNumber::GetStyleID() const
+{
+ return m_nStyleID;
+}
+inline sal_uInt16 LwpFribParaNumber::GetNumberChar() const
+{
+ return m_nNumberChar;
+}
+inline sal_uInt16 LwpFribParaNumber::GetStart() const
+{
+ return m_nStart;
+}
+
+class LwpFribDocVar : public LwpFrib
+{
+public:
+ explicit LwpFribDocVar( LwpPara* pPara );
+
+ virtual ~LwpFribDocVar() override;
+
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+
+ void RegisterStyle(LwpFoundry* pFoundry) override;
+
+ void XFConvert(XFContentContainer* pXFPara);
+
+ enum {
+ FILENAME = 0x02,
+ PATH = 0x03,
+ SMARTMASTER = 0x04,
+ DESCRIPTION = 0x05,
+ DATECREATED = 0x06,
+ DATELASTREVISION = 0x07,
+ TOTALEDITTIME = 0x08,
+ NUMPAGES= 0x09,
+ NUMWORDS= 0x0a,
+ NUMCHARS = 0x0b,
+ DOCSIZE = 0x0c,
+ DIVISIONNAME = 0x0d,
+ SECTIONNAME = 0x0e,
+ VERSIONCREATEBY = 0x0f,
+ VERSIONCREATEDATE = 0x10,
+ VERSIONOTHEREDITORS = 0x11,
+ VERSIONNAME = 0x12,
+ VERSIONNUMBER = 0x13,
+ ALLVERSIONNAME = 0x14,
+ VERSIONREMARK = 0x15,
+ DOCUMENTCATEGORY = 0x16,
+ VERSIONLASTDATE = 0x17,
+ VERSIONLASTEDITOR = 0x18,
+ KEYWORDS = 0x19,
+ CREATEDBY = 0x1a,
+ LASTEDIT = 0x1b,
+ OTHEREDITORS = 0x1c,
+ NUMOFREVISION = 0x1d,
+ };
+
+private:
+ sal_uInt16 m_nType;
+ LwpAtomHolder m_aName;
+ OUString m_TimeStyle;
+ void RegisterDefaultTimeStyle();
+ void RegisterTotalTimeStyle();
+};
+
+class LwpFribTab : public LwpFrib
+{
+public:
+ explicit LwpFribTab( LwpPara* pPara ) : LwpFrib(pPara){}
+};
+
+class LwpFribUnicode: public LwpFrib
+{
+public:
+ explicit LwpFribUnicode( LwpPara* pPara ) : LwpFrib(pPara){}
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void XFConvert(XFContentContainer* pXFPara,LwpStory* pStory);
+private:
+ OUString m_Content;
+public:
+ const OUString& GetText() const {return m_Content;}
+};
+
+class LwpFribPageNumber : public LwpFrib
+{
+public:
+ explicit LwpFribPageNumber(LwpPara* pPara) : LwpFrib(pPara),
+ m_nNumStyle(0), m_nStartNum(1), m_nStartOnPage(1), m_nFlag(0){}
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void XFConvert(XFContentContainer* pXFPara);
+private:
+ sal_uInt16 m_nNumStyle;
+ LwpAtomHolder m_aBefText;
+ LwpAtomHolder m_aAfterText;
+ sal_uInt16 m_nStartNum;
+ sal_uInt16 m_nStartOnPage;
+ sal_uInt16 m_nFlag;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpglobalmgr.cxx b/lotuswordpro/source/filter/lwpglobalmgr.cxx
new file mode 100644
index 000000000..e286553fb
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpglobalmgr.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpglobalmgr.hxx>
+#include <osl/thread.hxx>
+std::map<sal_uInt32, LwpGlobalMgr*> LwpGlobalMgr::m_ThreadMap;
+LwpGlobalMgr::LwpGlobalMgr(LwpSvStream* pSvStream)
+{
+ if (pSvStream)
+ m_pObjFactory.reset(new LwpObjectFactory(pSvStream));
+ m_pBookmarkMgr.reset(new LwpBookmarkMgr);
+ m_pChangeMgr.reset(new LwpChangeMgr);
+ m_pXFFontFactory.reset(new XFFontFactory);
+ m_pXFStyleManager.reset(new XFStyleManager);
+}
+
+LwpGlobalMgr::~LwpGlobalMgr()
+{
+ m_pObjFactory.reset();
+ m_pBookmarkMgr.reset();
+ m_pChangeMgr.reset();
+ m_pXFFontFactory.reset();
+ m_pXFStyleManager.reset();
+ m_EditorAttrMap.clear();
+}
+
+LwpGlobalMgr* LwpGlobalMgr::GetInstance(LwpSvStream* pSvStream)
+{
+ sal_uInt32 nThreadID = osl::Thread::getCurrentIdentifier();
+ auto iter = m_ThreadMap.find(nThreadID);
+ if (iter == m_ThreadMap.end())
+ {
+ LwpGlobalMgr* pInstance = new LwpGlobalMgr(pSvStream);
+ m_ThreadMap[nThreadID] = pInstance;
+ return pInstance;
+ }
+ else
+ return iter->second;
+}
+
+void LwpGlobalMgr::DeleteInstance()
+{
+ sal_uInt32 nThreadID = osl::Thread::getCurrentIdentifier();
+ auto iter = m_ThreadMap.find(nThreadID);
+ if (iter != m_ThreadMap.end())
+ {
+ delete iter->second;
+ iter->second = nullptr;
+ m_ThreadMap.erase(iter);
+ }
+}
+
+void LwpGlobalMgr::SetEditorAttrMap(sal_uInt16 nID, LwpEditorAttr* pAttr)
+{
+ m_EditorAttrMap[nID].reset(pAttr);
+}
+
+OUString LwpGlobalMgr::GetEditorName(sal_uInt8 nID)
+{
+ auto iter = m_EditorAttrMap.find(nID);
+ if (iter != m_EditorAttrMap.end())
+ return iter->second->cName.str();
+ return OUString();
+}
+
+XFColor LwpGlobalMgr::GetHighlightColor(sal_uInt8 nID)
+{
+ auto iter = m_EditorAttrMap.find(nID);
+ if (iter != m_EditorAttrMap.end())
+ {
+ LwpColor aLwpColor = iter->second->cHiLiteColor;
+ XFColor aColor(aLwpColor.GetRed(), aLwpColor.GetGreen(), aLwpColor.GetBlue());
+ return aColor;
+ }
+ else
+ {
+ XFColor aColor(255, 255, 0); //yellow
+ return aColor;
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
new file mode 100644
index 000000000..76c8aa76c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -0,0 +1,693 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**
+ * @file
+ * For LWP filter architecture prototype
+*/
+#include <stdio.h>
+
+#include <memory>
+
+#include <lwpfilehdr.hxx>
+#include "lwpgrfobj.hxx"
+#include "lwpsdwfileloader.hxx"
+#include "bento.hxx"
+
+#include <lwpglobalmgr.hxx>
+#include <o3tl/numeric.hxx>
+#include "lwpframelayout.hxx"
+
+#include <xfilter/xfframe.hxx>
+#include <xfilter/xfimage.hxx>
+#include <xfilter/xfimagestyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfparagraph.hxx>
+#include <xfilter/xfannotation.hxx>
+
+//For chart
+#include <string.h>
+
+#include <osl/thread.h>
+#include <sal/log.hxx>
+
+#define EF_NONE 0x0000
+#define EF_ODMA 0x0002
+
+LwpGraphicObject::LwpGraphicObject(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpGraphicOleObject(objHdr, pStrm)
+ , m_nCachedBaseLine(0)
+ , m_bIsLinked(0)
+ , m_bCompressed(0)
+{
+}
+
+LwpGraphicObject::~LwpGraphicObject()
+{
+}
+
+void LwpGraphicObject::Read()
+{
+ LwpGraphicOleObject::Read();
+ m_pObjStrm->QuickReaduInt16(); //disksize
+ sal_uInt16 strsize = m_pObjStrm->QuickReaduInt16();
+ if (strsize<AFID_MAX_FILE_FORMAT_SIZE)
+ {
+ m_pObjStrm->QuickRead(m_sDataFormat,strsize);
+ m_sDataFormat[strsize] = '\0';
+ }
+ sal_uInt32 nServerContextSize = m_pObjStrm->QuickReaduInt32();
+ if (nServerContextSize > 0)
+ {
+ sal_uInt16 nMaxPossibleSize = m_pObjStrm->remainingSize();
+
+ if (nServerContextSize > nMaxPossibleSize)
+ {
+ SAL_WARN("lwp", "stream too short for claimed no of records");
+ nServerContextSize = nMaxPossibleSize;
+ }
+
+ std::vector<unsigned char> aServerContext(nServerContextSize);
+ m_pObjStrm->QuickRead(aServerContext.data(), static_cast<sal_uInt16>(nServerContextSize));
+ if (nServerContextSize > 44)
+ {
+ m_aIPData.nBrightness = aServerContext[14];
+ m_aIPData.nContrast = aServerContext[19];
+ m_aIPData.nEdgeEnhancement = aServerContext[24];
+ m_aIPData.nSmoothing = aServerContext[29];
+ m_aIPData.bInvertImage = (aServerContext[34] == 0x01);
+ m_aIPData.bAutoContrast = (aServerContext[44] == 0x00);
+ }
+ }
+ m_pObjStrm->QuickReaduInt16(); //disksize
+ strsize = m_pObjStrm->QuickReaduInt16();
+ if (strsize<AFID_MAX_FILE_FORMAT_SIZE)
+ {
+ m_pObjStrm->QuickRead(m_sServerContextFormat,strsize);
+ m_sServerContextFormat[strsize] = '\0';
+ }
+ if (nServerContextSize == 0)
+ {
+ if (strcmp(reinterpret_cast<char *>(m_sServerContextFormat), ".cht") == 0 &&
+ strcmp(reinterpret_cast<char *>(m_sDataFormat), ".sdw") == 0)
+ {
+ strcpy(reinterpret_cast<char *>(m_sServerContextFormat), ".lch");
+ strcpy(reinterpret_cast<char *>(m_sDataFormat), ".lch");
+ }
+ }
+ m_nCachedBaseLine = m_pObjStrm->QuickReadInt32();
+ m_bIsLinked = m_pObjStrm->QuickReadInt16();
+
+ if (m_bIsLinked)
+ {
+ m_LinkedFilePath = m_pObjStrm->QuickReadStringPtr();
+
+ sal_uInt32 nFilterContextSize = m_pObjStrm->QuickReaduInt32();
+ if (nFilterContextSize > 0)
+ {
+ sal_uInt16 nMaxPossibleSize = m_pObjStrm->remainingSize();
+
+ if (nFilterContextSize > nMaxPossibleSize)
+ {
+ SAL_WARN("lwp", "stream too short for claimed no of records");
+ nFilterContextSize = nMaxPossibleSize;
+ }
+
+ std::vector<unsigned char> aFilterContext(nFilterContextSize);
+ m_pObjStrm->QuickRead(aFilterContext.data(), static_cast<sal_uInt16>(nFilterContextSize));
+ }
+ if (LwpFileHeader::m_nFileRevision >= 0x000b)
+ {
+
+ // read external file object stuff
+ sal_uInt16 type = m_pObjStrm->QuickReaduInt16();
+ if ((EF_ODMA != type) && (EF_NONE != type)) // don't know about this
+ {
+ sal_uInt32 size = m_pObjStrm->QuickReaduInt32();
+ m_pObjStrm->SeekRel(static_cast<sal_uInt16>(size));
+ }
+ // else no external file object
+ }
+ }
+
+ if (LwpFileHeader::m_nFileRevision >= 0x000b)
+ {
+ m_bCompressed = m_pObjStrm->QuickReadInt16();
+ m_Cache.LinkedFileSize = m_pObjStrm->QuickReaduInt32();
+ m_Cache.LinkedFileTime = m_pObjStrm->QuickReaduInt32();
+ m_Cache.Width = m_pObjStrm->QuickReadInt32();
+ m_Cache.Height = m_pObjStrm->QuickReadInt32();
+ }
+
+ if(LwpFileHeader::m_nFileRevision >= 0x000c)
+ {
+ m_WatermarkName = m_pObjStrm->QuickReadStringPtr();
+ }
+}
+
+void LwpGraphicObject::XFConvert (XFContentContainer* pCont)
+{
+ if (m_sServerContextFormat[1]=='s'&&m_sServerContextFormat[2]=='d'&&m_sServerContextFormat[3]=='w')
+ {
+ for (auto const& vXFDrawObject : m_vXFDrawObjects)
+ {
+ pCont->Add(vXFDrawObject.get());
+ }
+ }
+ else if (IsGrafFormatValid() && !m_vXFDrawObjects.empty())
+ {
+ XFImage* pImage = static_cast<XFImage*>(m_vXFDrawObjects.front().get());
+
+ if (m_bIsLinked)
+ {
+ OUString fileURL = LwpTools::convertToFileUrl(OUStringToOString(m_LinkedFilePath, osl_getThreadTextEncoding()));
+ pImage->SetFileURL(fileURL);
+ }
+ else
+ {
+ std::vector<sal_uInt8> aGrafData = GetRawGrafData();
+ pImage->SetImageData(aGrafData.data(), aGrafData.size());
+ }
+
+ pCont->Add(pImage);
+ }
+ else if(m_sServerContextFormat[1]=='t'&&m_sServerContextFormat[2]=='e'&&m_sServerContextFormat[3]=='x')
+ {
+ XFConvertEquation(pCont);
+ }
+}
+
+/**
+ * @descr judge if the graphic format is what we can support: bmp, jpg, wmf, gif, tgf(tif). other format will be filtered to
+ * these formats by Word Pro.
+ * @return sal_True if yes sal_False if not.
+ */
+bool LwpGraphicObject::IsGrafFormatValid() const
+{
+ return (m_sServerContextFormat[1]=='b'&& m_sServerContextFormat[2]=='m' && m_sServerContextFormat[3]=='p')
+ || (m_sServerContextFormat[1]=='j' && m_sServerContextFormat[2]=='p' && m_sServerContextFormat[3]=='g')
+ || (m_sServerContextFormat[1]=='w' && m_sServerContextFormat[2]=='m' && m_sServerContextFormat[3]=='f')
+ || (m_sServerContextFormat[1]=='g' && m_sServerContextFormat[2]=='i' && m_sServerContextFormat[3]=='f')
+ || (m_sServerContextFormat[1]=='t' && m_sServerContextFormat[2]=='g' && m_sServerContextFormat[3]=='f')
+ || (m_sServerContextFormat[1]=='p' && m_sServerContextFormat[2]=='n' && m_sServerContextFormat[3]=='g')
+ || (m_sServerContextFormat[1]=='e' && m_sServerContextFormat[2]=='p' && m_sServerContextFormat[3]=='s');
+}
+
+/**
+ * @descr create drawing object and image object.
+ */
+void LwpGraphicObject::RegisterStyle()
+{
+ if (m_sServerContextFormat[1]=='s'&&m_sServerContextFormat[2]=='d'&&m_sServerContextFormat[3]=='w')
+ {
+ CreateDrawObjects();
+ }
+ // test codes for importing pictures
+ else if(IsGrafFormatValid())
+ {
+ CreateGrafObject();
+ }
+
+ if (m_sServerContextFormat[1]=='l'&&m_sServerContextFormat[2]=='c'&&m_sServerContextFormat[3]=='h')
+ {
+ rtl::Reference<LwpVirtualLayout> xMyLayout(GetLayout(nullptr));
+ if (xMyLayout.is() && xMyLayout->IsFrame())
+ {
+ std::unique_ptr<XFFrameStyle> pXFFrameStyle(new XFFrameStyle());
+ pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
+ pXFFrameStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelPara);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_strStyleName = pXFStyleManager->AddStyle(std::move(pXFFrameStyle)).m_pStyle->GetStyleName();
+ }
+ }
+
+}
+
+/**
+ * @descr create drawing object.
+ */
+void LwpGraphicObject::CreateDrawObjects()
+{
+ // if small file, use the compressed stream for BENTO
+ LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
+
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return;
+
+ // get graphic object's bento object name
+ LwpObjectID& rMyID = GetObjectID();
+ std::string aGrfObjName;
+ GetBentoNamebyID(rMyID, aGrfObjName);
+
+ // get bento stream by the name
+ std::vector<sal_uInt8> aData = pBentoContainer->GetGraphicData(aGrfObjName.c_str());
+ if (!aData.empty())
+ {
+ SvMemoryStream aDrawObjStream(aData.data(), aData.size(), StreamMode::READ);
+
+ LwpSdwFileLoader fileLoader(&aDrawObjStream, this);
+ fileLoader.CreateDrawObjects(&m_vXFDrawObjects);
+ }
+}
+
+/**
+ * @descr create drawing object.
+ */
+void LwpGraphicObject::GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName)
+{
+ sal_uInt16 nHigh = rMyID.GetHigh();
+ sal_uInt32 nLow = rMyID.GetLow();
+ char pTempStr[32];
+ rName = std::string("Gr");
+ sprintf(pTempStr, "%X,%" SAL_PRIXUINT32, nHigh, nLow);
+ rName.append(pTempStr);
+}
+
+/**
+ * @descr get the image data read from bento stream according to the VO_GRAPHIC ID.
+ * @return the image data.
+ */
+std::vector<sal_uInt8> LwpGraphicObject::GetRawGrafData()
+{
+ std::vector<sal_uInt8> aGrafData;
+
+ // create graphic object
+ // if small file, use the compressed stream for BENTO
+ LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
+
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
+ {
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return aGrafData;
+ }
+
+ // get graphic object's bento object name
+ LwpObjectID& rMyID = GetObjectID();
+ std::string aGrfObjName;
+ GetBentoNamebyID(rMyID, aGrfObjName);
+
+ // get bento stream by the name and read image data
+ return pBentoContainer->GetGraphicData(aGrfObjName.c_str());
+}
+
+/**
+ * @descr get the image data (only -D data) read from bento stream according to the VO_GRAPHIC ID.
+ * @param pGrafData the array to store the image data. the pointer need to be deleted outside.
+ * @return the length of the image data.
+ */
+sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData)
+{
+ // create graphic object
+ // if small file, use the compressed stream for BENTO
+ LwpSvStream* pStream = m_pStrm->GetCompressedStream() ? m_pStrm->GetCompressedStream(): m_pStrm;
+
+ std::unique_ptr<OpenStormBento::LtcBenContainer> pBentoContainer;
+ sal_uLong ulRet = OpenStormBento::BenOpenContainer(pStream, &pBentoContainer);
+ if (ulRet != OpenStormBento::BenErr_OK)
+ return 0;
+
+ SvStream* pGrafStream = nullptr;
+
+ // get graphic object's bento object name
+ LwpObjectID& rMyID = GetObjectID();
+ std::string aGrfObjName;
+ GetBentoNamebyID(rMyID, aGrfObjName);
+
+ char sDName[64]="";
+ sprintf(sDName, "%s-D", aGrfObjName.c_str());
+
+ // get bento stream by the name
+ pGrafStream = pBentoContainer->FindValueStreamWithPropertyName(sDName);
+
+ std::unique_ptr<SvMemoryStream> pMemGrafStream(static_cast<SvMemoryStream*>(pGrafStream));
+
+ if (pMemGrafStream)
+ {
+ // read image data
+ sal_uInt32 nDataLen = pGrafStream->TellEnd();
+
+ pGrafData.reset(new sal_uInt8 [nDataLen]);
+ pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen);
+
+ return nDataLen;
+ }
+
+ return 0;
+}
+
+/**
+ * @descr create xf-image object and save it in the container: m_vXFDrawObjects.
+ */
+void LwpGraphicObject::CreateGrafObject()
+{
+ rtl::Reference<XFImage> pImage = new XFImage();
+
+ // set image processing styles
+ std::unique_ptr<XFImageStyle> xImageStyle(new XFImageStyle);
+ if (m_sServerContextFormat[1]!='w' || m_sServerContextFormat[2]!='m' || m_sServerContextFormat[3]!='f')
+ {
+ if (m_aIPData.nBrightness != 50)
+ {
+ sal_Int32 nSODCBrightness = static_cast<sal_Int32>(m_aIPData.nBrightness)*2 - 100;
+ xImageStyle->SetBrightness(nSODCBrightness);
+ }
+ if (m_aIPData.nContrast != 50)
+ {
+ sal_Int32 nSODCContrast = static_cast<sal_Int32>(80 - static_cast<double>(m_aIPData.nContrast)*1.6);
+ xImageStyle->SetContrast(nSODCContrast);
+ }
+ }
+
+ // set scale and crop styles
+ LwpAssociatedLayouts& rLayoutWithMe = GetLayoutsWithMe();
+ LwpFrameLayout* pMyFrameLayout =
+ static_cast<LwpFrameLayout*>(rLayoutWithMe.GetOnlyLayout().obj(VO_FRAMELAYOUT).get());
+ if (pMyFrameLayout)
+ {
+ LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
+ LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
+
+ // original image size
+ double fOrgGrafWidth = static_cast<double>(m_Cache.Width)/TWIPS_PER_CM;
+ double fOrgGrafHeight = static_cast<double>(m_Cache.Height)/TWIPS_PER_CM;
+
+ // get margin values
+ double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
+ double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT);
+ double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
+ double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
+
+ if (pMyScale && pFrameGeo)
+ {
+ if (fOrgGrafHeight == 0.0 || fOrgGrafWidth == 0.0)
+ throw o3tl::divide_by_zero();
+
+ // frame size
+ double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
+ double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
+
+ // calculate the displayed size of the frame
+ double fDisFrameWidth = fFrameWidth - (fLeftMargin+fRightMargin);
+ double fDisFrameHeight = fFrameHeight - (fTopMargin+fBottomMargin);
+
+ // scaled image size
+ double fSclGrafWidth = fOrgGrafWidth;
+ double fSclGrafHeight = fOrgGrafHeight;
+
+ // get scale mode
+ sal_uInt16 nScalemode = pMyScale->GetScaleMode();
+ if (nScalemode & LwpLayoutScale::CUSTOM)
+ {
+ fSclGrafWidth = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
+ fSclGrafHeight = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
+ }
+ else if (nScalemode & LwpLayoutScale::PERCENTAGE)
+ {
+ double fScalePercentage = static_cast<double>(pMyScale->GetScalePercentage()) / 1000;
+ fSclGrafWidth = fScalePercentage * fOrgGrafWidth;
+ fSclGrafHeight = fScalePercentage * fOrgGrafHeight;
+ }
+ else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
+ {
+ if (pMyFrameLayout->IsFitGraphic())
+ {
+ fSclGrafWidth = fOrgGrafWidth;
+ fSclGrafHeight = fOrgGrafHeight;
+ }
+ else if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
+ {
+ if (fDisFrameHeight == 0.0)
+ throw o3tl::divide_by_zero();
+ if (fOrgGrafWidth/fOrgGrafHeight >= fDisFrameWidth/fDisFrameHeight)
+ {
+ fSclGrafWidth = fDisFrameWidth;
+ fSclGrafHeight = (fDisFrameWidth/fOrgGrafWidth) * fOrgGrafHeight;
+ }
+ else
+ {
+ fSclGrafHeight = fDisFrameHeight;
+ fSclGrafWidth = (fDisFrameHeight/fOrgGrafHeight) * fOrgGrafWidth;
+ }
+ }
+ else
+ {
+ fSclGrafWidth = fDisFrameWidth;
+ fSclGrafHeight = fDisFrameHeight;
+ }
+ }
+
+ // scaled ratio
+ double fXRatio = fSclGrafWidth / fOrgGrafWidth;
+ double fYRatio = fSclGrafHeight / fOrgGrafHeight;
+
+ // set image to scaled size.
+ pImage->SetWidth(fSclGrafWidth);
+ pImage->SetHeight(fSclGrafHeight);
+
+ // placement:centered or tiled. tiled style is not supported so it's processed together with centered.
+ if (pMyFrameLayout->GetScaleCenter() || pMyFrameLayout->GetScaleTile())
+ {
+ // set center alignment
+ xImageStyle->SetXPosType(enumXFFrameXPosCenter, enumXFFrameXRelFrame);
+ xImageStyle->SetYPosType(enumXFFrameYPosMiddle, enumXFFrameYRelFrame);
+
+ // need horizontal crop?
+ double fClipWidth = 0;
+ double fClipHeight = 0;
+ bool sal_bCropped = false;
+ if (fSclGrafWidth > fDisFrameWidth)
+ {
+ if (fXRatio == 0.0)
+ throw o3tl::divide_by_zero();
+ fClipWidth = (fSclGrafWidth-fDisFrameWidth ) / 2 / fXRatio;
+ sal_bCropped = true;
+ }
+
+ // need vertical crop?
+ if (fSclGrafHeight > fDisFrameHeight)
+ {
+ if (fYRatio == 0.0)
+ throw o3tl::divide_by_zero();
+ fClipHeight = (fSclGrafHeight-fDisFrameHeight ) / 2 / fYRatio;
+ sal_bCropped = true;
+ }
+
+ if (sal_bCropped)
+ {
+ xImageStyle->SetClip(fClipWidth, fClipWidth, fClipHeight, fClipHeight);
+ pImage->SetWidth(fDisFrameWidth);
+ pImage->SetHeight(fDisFrameHeight);
+ }
+ }
+ // placement:automatic
+ else
+ {
+ // set left-top alignment
+ xImageStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelFrame);
+ xImageStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
+
+ // get image position offset
+ LwpPoint& rOffset = pMyScale->GetOffset();
+ double fOffsetX = LwpTools::ConvertFromUnitsToMetric(rOffset.GetX());
+ double fOffsetY = LwpTools::ConvertFromUnitsToMetric(rOffset.GetY());
+
+ struct LwpRect
+ {
+ double fLeft;
+ double fRight;
+ double fTop;
+ double fBottom;
+
+ LwpRect()
+ {
+ fLeft = 0.00;
+ fRight = 0.00;
+ fTop = 0.00;
+ fBottom = 0.00;
+ }
+ LwpRect(double fL, double fR, double fT, double fB)
+ {
+ fLeft = fL;
+ fRight = fR;
+ fTop = fT;
+ fBottom = fB;
+ }
+ };
+ LwpRect aFrameRect(-fOffsetX, (fDisFrameWidth-fOffsetX), (-fOffsetY), (fDisFrameHeight-fOffsetY));
+ LwpRect aImageRect(0, fSclGrafWidth, 0, fSclGrafHeight);
+
+ if (aFrameRect.fRight <= aImageRect.fLeft || aFrameRect.fLeft >= aImageRect.fRight
+ ||aFrameRect.fBottom <= aImageRect.fTop|| aFrameRect.fTop >= aImageRect.fBottom)
+ {
+ // display blank
+ }
+ else// need cropped
+ {
+ // horizontal crop
+ LwpRect aCropRect;
+ if (aFrameRect.fLeft > aImageRect.fLeft)
+ {
+ aCropRect.fLeft = (aFrameRect.fLeft - aImageRect.fLeft) / fXRatio;
+ }
+
+ if (aFrameRect.fRight < aImageRect.fRight)
+ {
+ aCropRect.fRight = (aImageRect.fRight - aFrameRect.fRight) / fXRatio;
+ }
+
+ // vertical crop
+ if (aFrameRect.fTop > aImageRect.fTop)
+ {
+ aCropRect.fTop = (aFrameRect.fTop - aImageRect.fTop) / fYRatio;
+ }
+ if (aFrameRect.fBottom < aImageRect.fBottom)
+ {
+ aCropRect.fBottom = (aImageRect.fBottom - aFrameRect.fBottom) / fYRatio;
+ }
+
+ xImageStyle->SetClip(aCropRect.fLeft, aCropRect.fRight, aCropRect.fTop, aCropRect.fBottom);
+ double fPicWidth = fSclGrafWidth - (aCropRect.fLeft+aCropRect.fRight)*fXRatio;
+ double fPicHeight = fSclGrafHeight- (aCropRect.fTop+aCropRect.fBottom)*fYRatio;
+ double fX = fOffsetX > 0 ? fOffsetX : 0.00;
+ double fY = fOffsetY > 0 ? fOffsetY : 0.00;
+ pImage->SetPosition((fX+fLeftMargin), (fY+fTopMargin), fPicWidth, fPicHeight);
+ }
+ }
+ }
+ }
+
+ // set style for the image
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pImage->SetStyleName(pXFStyleManager->AddStyle(std::move(xImageStyle)).m_pStyle->GetStyleName());
+
+ // set anchor to frame
+ pImage->SetAnchorType(enumXFAnchorFrame);
+
+ // set object name
+ LwpAtomHolder& rHolder = GetName();
+ if ( !rHolder.str().isEmpty() )
+ {
+ pImage->SetName(rHolder.str());
+ }
+
+ // insert image object into array
+ m_vXFDrawObjects.emplace_back(pImage.get());
+
+}
+
+/**
+ * @descr Reserve the equation text in a note in the context.
+ */
+void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont)
+{
+ std::unique_ptr<sal_uInt8[]> pGrafData;
+ sal_uInt32 nDataLen = GetGrafData(pGrafData);
+ if(!pGrafData)
+ return;
+
+ //convert equation
+ XFParagraph* pXFPara = new XFParagraph;
+ pXFPara->Add("Formula:");
+ //add notes
+ XFAnnotation* pXFNote = new XFAnnotation;
+ //add equation to comment notes
+ XFParagraph* pXFNotePara = new XFParagraph;
+ //equation header text: Times New Roman,
+ // 18,12,0,0,0,0,0.
+ // .TCIformat{2}
+ //total head length = 45
+ bool bOk = true;
+ sal_uInt32 nBegin = 45;
+ sal_uInt32 nEnd = 0;
+ if (nDataLen >= 1)
+ nEnd = nDataLen - 1;
+ else
+ bOk = false;
+
+ if (bOk && pGrafData[nEnd] == '$' && nEnd > 0 && pGrafData[nEnd-1] != '\\')
+ {
+ //equation body is contained by '$';
+ nBegin++;
+ nEnd--;
+ }
+
+ bOk &= nEnd >= nBegin;
+ if (bOk)
+ {
+ std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
+ for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
+ {
+ pEquData[nIndex] = pGrafData[nBegin + nIndex];
+ }
+ pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
+ }
+ pXFNote->Add(pXFNotePara);
+
+ pXFPara->Add(pXFNote);
+ pCont->Add(pXFPara);
+}
+
+void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight)
+{
+ // original image size
+ rWidth = static_cast<double>(m_Cache.Width)/TWIPS_PER_CM;
+ rHeight = static_cast<double>(m_Cache.Height)/TWIPS_PER_CM;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpgrfobj.hxx b/lotuswordpro/source/filter/lwpgrfobj.hxx
new file mode 100644
index 000000000..5c05bf218
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpgrfobj.hxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPGRFOBJ_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPGRFOBJ_HXX
+
+#include <sal/types.h>
+#include <config_lgpl.h>
+
+#include "lwpoleobject.hxx"
+
+struct ImageProcessingData
+{
+ sal_uInt8 nBrightness;
+ sal_uInt8 nContrast;
+ sal_uInt8 nEdgeEnhancement;
+ sal_uInt8 nSmoothing;
+ bool bAutoContrast;
+ bool bInvertImage;
+
+ ImageProcessingData()
+ : nBrightness(50),
+ nContrast(50),
+ nEdgeEnhancement(0),
+ nSmoothing(0),
+ bAutoContrast(false),
+ bInvertImage(false)
+ {
+ }
+};
+
+class XFFrame;
+class LwpGraphicObject : public LwpGraphicOleObject
+{
+public:
+ LwpGraphicObject(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpGraphicObject() override;
+private:
+ unsigned char m_sDataFormat[AFID_MAX_FILE_FORMAT_SIZE] = {};
+ unsigned char m_sServerContextFormat[AFID_MAX_CONTEXT_FORMAT_SIZE] = {};
+ sal_Int32 m_nCachedBaseLine;
+ sal_Int16 m_bIsLinked;
+ AFID_CACHE m_Cache;
+ sal_Int16 m_bCompressed;
+ OUString m_WatermarkName;
+ OUString m_LinkedFilePath;
+
+ ImageProcessingData m_aIPData;
+
+ void XFConvertEquation(XFContentContainer* pCont);
+
+ bool IsGrafFormatValid() const;
+ std::vector< rtl::Reference<XFFrame> > m_vXFDrawObjects;
+
+public:
+ void Read() override;
+ virtual void XFConvert (XFContentContainer* pCont) override;
+ void RegisterStyle() override;
+
+ void CreateDrawObjects();
+ void CreateGrafObject();
+ static void GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName);
+ std::vector<sal_uInt8> GetRawGrafData();
+ sal_uInt32 GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData);
+ void GetGrafOrgSize(tools::Long& rWidth, tools::Long& rHeight) { rWidth = m_Cache.Width; rHeight = m_Cache.Height; }
+ void GetGrafOrgSize(double& rWidth, double& rHeight) override;
+
+ sal_Int16 IsLinked() const { return m_bIsLinked;}
+ const OUString& GetLinkedFilePath() const { return m_LinkedFilePath;}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpholder.cxx b/lotuswordpro/source/filter/lwpholder.cxx
new file mode 100644
index 000000000..3b0d4dee3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpholder.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpholder.hxx"
+#include <lwpfilehdr.hxx>
+
+LwpDLVListHeadHolder::LwpDLVListHeadHolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+{
+}
+/**
+ * @descr read LwpDLVListHeadHolder from object stream
+*/
+void LwpDLVListHeadHolder::Read()
+{
+ m_DLVHead.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+LwpDLVListHeadTailHolder::LwpDLVListHeadTailHolder(LwpObjectHeader const& objHdr,
+ LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+{
+}
+/**
+ * @descr read LwpDLVListHeadTailHolder from object stream
+*/
+void LwpDLVListHeadTailHolder::Read()
+{
+ m_HeadTail.Read(m_pObjStrm.get());
+ //m_pObjStrm->SkipExtra();
+}
+
+LwpObjectHolder::LwpObjectHolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+{
+}
+/**
+ * @descr read LwpObjectHolder from object stream
+*/
+void LwpObjectHolder::Read()
+{
+ LwpDLVList::Read();
+
+ m_Object.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ m_pObjStrm->SkipExtra();
+}
+
+LwpListList::LwpListList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObjectHolder(objHdr, pStrm)
+{
+}
+/**
+ * @descr read LwpListList from object stream
+*/
+void LwpListList::Read()
+{
+ LwpObjectHolder::Read();
+
+ m_HeadTail.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpholder.hxx b/lotuswordpro/source/filter/lwpholder.hxx
new file mode 100644
index 000000000..a98234f10
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpholder.hxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * kinds of holder classes header file
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPHOLDER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPHOLDER_HXX
+
+#include <lwpobj.hxx>
+#include "lwpdlvlist.hxx"
+/**
+ * @brief VO_HEADHOLDER, LwpDLVListHeadHolder,
+ * contains an id to the head of LwpDLVList
+*/
+class LwpDLVListHeadHolder : public LwpObject
+{
+public:
+ LwpDLVListHeadHolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ LwpObjectID& GetHeadID() { return m_DLVHead; }
+
+private:
+ virtual ~LwpDLVListHeadHolder() override {}
+
+ LwpObjectID m_DLVHead;
+};
+/**
+ * @brief VO_HEADTAILHOLDER, LwpDLVListHeadTailHolder,
+ * contains a LwpDLVListHeadTail (Head and tail id)
+*/
+class LwpDLVListHeadTailHolder final : public LwpObject
+{
+public:
+ LwpDLVListHeadTailHolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ LwpObjectID& GetHead() { return m_HeadTail.GetHead(); }
+ LwpObjectID& GetTail() { return m_HeadTail.GetTail(); }
+
+private:
+ virtual ~LwpDLVListHeadTailHolder() override {}
+
+ LwpDLVListHeadTail m_HeadTail;
+};
+/**
+ * @brief LwpObjectHolder, which is LwpDLVList, contains an id to an object
+ * VO_OBJECTHOLDER
+*/
+class LwpObjectHolder : public LwpDLVList
+{
+public:
+ LwpObjectHolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ LwpObjectID& GetObject() { return m_Object; }
+
+protected:
+ virtual ~LwpObjectHolder() override {}
+
+private:
+ LwpObjectID m_Object;
+};
+
+/**
+ * @brief VO_LISTLIST object in .lwp file
+ *
+ */
+class LwpListList final : public LwpObjectHolder
+{
+public:
+ LwpListList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ LwpObjectID& GetHead() { return m_HeadTail.GetHead(); }
+
+private:
+ virtual ~LwpListList() override {}
+
+ LwpDLVListHeadTail m_HeadTail;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwphyperlinkmgr.cxx b/lotuswordpro/source/filter/lwphyperlinkmgr.cxx
new file mode 100644
index 000000000..4e76b498b
--- /dev/null
+++ b/lotuswordpro/source/filter/lwphyperlinkmgr.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwphyperlinkmgr.hxx"
+
+LwpHyperlinkMgr::LwpHyperlinkMgr() { m_bIsHyperlink = false; }
+
+LwpHyperlinkMgr::~LwpHyperlinkMgr() {}
+
+void LwpHyperlinkMgr::SetHyperlink(const OUString& hyperlink) { m_Hyperlink = hyperlink; }
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwphyperlinkmgr.hxx b/lotuswordpro/source/filter/lwphyperlinkmgr.hxx
new file mode 100644
index 000000000..5eab1cc92
--- /dev/null
+++ b/lotuswordpro/source/filter/lwphyperlinkmgr.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPHYPERLINKMGR_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPHYPERLINKMGR_HXX
+
+#include <rtl/ustring.hxx>
+
+class LwpHyperlinkMgr
+{
+public:
+ LwpHyperlinkMgr();
+ ~LwpHyperlinkMgr();
+ void SetHyperlinkFlag(bool bFlag) { m_bIsHyperlink = bFlag; }
+ bool GetHyperlinkFlag() const { return m_bIsHyperlink; }
+ void SetHyperlink(const OUString& hyperlink);
+ const OUString& GetHyperlink() const { return m_Hyperlink; }
+
+private:
+ OUString m_Hyperlink;
+ bool m_bIsHyperlink;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
new file mode 100644
index 000000000..e9f34bf95
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -0,0 +1,326 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**********************************************************************************************************************
+ * @file
+ * index manager implementation
+ * Three record types are related with index information, and two ways are used.
+* 1. VO_ROOTOBJINDEX works with one or more VO_LEAFOBJINDEX records to
+* provide the map of all object ids and their offsets.
+* VO_ROOTOBJINDEX includes k (object id, offset) and timetable which is used to map index to actual low id
+ * 2. VO_ROOTLEAFOBJINDEX is used when the file is so small that the number of objects is less than 256(?)
+ * VO_ROOTLEAFOBJINDEX contains directly the (object id, offset) map and time table.
+
+**********************************************************************************************************************/
+
+#include <lwpidxmgr.hxx>
+#include <lwpobjhdr.hxx>
+#include <lwptools.hxx>
+#include <memory>
+
+const sal_uInt8 LwpIndexManager::MAXOBJECTIDS = 255;
+
+LwpIndexManager::LwpIndexManager()
+ : m_nKeyCount(0)
+ , m_nLeafCount(0)
+{
+ m_TempVec.resize( LwpIndexManager::MAXOBJECTIDS );
+
+}
+
+/**
+ * @descr Read all index records, VO_ROOTLEAFOBJINDEX, VO_ROOTOBJINDEX, VO_LEAFOBJINDEX
+ */
+void LwpIndexManager::Read(LwpSvStream* pStrm)
+{
+ //Read index obj
+ LwpObjectHeader ObjHdr;
+ if (!ObjHdr.Read(*pStrm))
+ throw BadRead();
+ std::unique_ptr<LwpObjectStream> xObjStrm(new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(ObjHdr.GetSize())));
+
+ if( ObjHdr.GetTag() == VO_ROOTLEAFOBJINDEX )
+ {
+ ReadLeafData(xObjStrm.get());
+ ReadTimeTable(xObjStrm.get());
+ xObjStrm.reset();
+ }
+ else
+ {
+ ReadRootData(xObjStrm.get());
+ xObjStrm.reset();
+
+ for (sal_uInt16 k = 0; k < m_nLeafCount; k++)
+ {
+ //Read leaf
+ sal_Int64 nPos = m_ChildIndex[k]+LwpSvStream::LWP_STREAM_BASE;
+ if (!pStrm->CheckSeek(nPos))
+ throw BadSeek();
+
+ //Old Code
+ //ReadLeafIndex(pStrm);
+ //New Code
+ ReadObjIndex( pStrm );
+
+ //Read object in root, these objects are between the leaf objects
+ if(k!=m_nLeafCount-1)
+ {
+ m_ObjectKeys.push_back(m_RootObjs[k]);
+ m_nKeyCount ++;
+ }
+ }
+ m_RootObjs.clear();
+ }
+}
+
+/**
+ * @descr Read data in VO_ROOTOBJINDEX
+ */
+void LwpIndexManager::ReadRootData(LwpObjectStream* pObjStrm)
+{
+
+ sal_uInt16 KeyCount = pObjStrm->QuickReaduInt16();
+ m_nLeafCount = KeyCount ? KeyCount + 1 : 0;
+
+ if (m_nLeafCount > SAL_N_ELEMENTS(m_ChildIndex))
+ throw std::range_error("corrupt RootData");
+
+ if (KeyCount)
+ {
+ //read object keys
+ LwpKey akey;
+ akey.id.Read(pObjStrm);
+ m_RootObjs.push_back(akey);
+
+ sal_uInt16 k = 0;
+
+ for (k = 1; k < KeyCount; k++)
+ {
+ akey.id.ReadCompressed(pObjStrm, m_RootObjs[k-1].id);
+ m_RootObjs.push_back(akey);
+ }
+
+ for (k = 0; k < KeyCount; k++)
+ m_RootObjs[k].offset = pObjStrm->QuickReaduInt32();
+
+ //read leaf index offset
+ for (k = 0; k < m_nLeafCount; k++)
+ m_ChildIndex[k] = pObjStrm->QuickReaduInt32();
+ }
+
+ ReadTimeTable(pObjStrm);
+
+}
+
+//Add new method to handle ObjIndex data
+/**
+ * @descr Read data in VO_OBJINDEX
+ */
+void LwpIndexManager::ReadObjIndexData(LwpObjectStream* pObjStrm)
+{
+ sal_uInt16 KeyCount = pObjStrm->QuickReaduInt16();
+ sal_uInt16 LeafCount = KeyCount + 1;
+
+ std::vector<LwpKey> vObjIndexs;
+
+ if (KeyCount)
+ {
+ LwpKey akey;
+ akey.id.Read(pObjStrm);
+ vObjIndexs.push_back(akey);
+
+ sal_uInt16 k = 0;
+
+ for (k = 1; k < KeyCount; k++)
+ {
+ akey.id.ReadCompressed(pObjStrm, vObjIndexs[k-1].id);
+ vObjIndexs.push_back(akey);
+ }
+
+ for (k = 0; k < KeyCount; k++)
+ vObjIndexs[k].offset = pObjStrm->QuickReaduInt32();
+
+ for (k = 0; k < LeafCount; k++)
+ m_TempVec.at(k) = pObjStrm->QuickReaduInt32();
+ }
+
+ for( sal_uInt16 j=0; j<LeafCount; j++ )
+ {
+ sal_Int64 nPos = m_TempVec.at(j) + LwpSvStream::LWP_STREAM_BASE;
+ sal_Int64 nActualPos = pObjStrm->GetStream()->Seek(nPos);
+
+ if (nPos != nActualPos)
+ throw BadSeek();
+
+ ReadLeafIndex(pObjStrm->GetStream());
+
+ if(j!=LeafCount-1)
+ {
+ m_ObjectKeys.push_back(vObjIndexs[j]);
+
+ m_nKeyCount ++;
+ }
+ }
+
+ vObjIndexs.clear();
+ m_TempVec.clear();
+}
+
+/**
+ * @descr Read VO_OBJINDEX
+ */
+void LwpIndexManager::ReadObjIndex( LwpSvStream *pStrm )
+{
+ LwpObjectHeader ObjHdr;
+ if (!ObjHdr.Read(*pStrm))
+ throw BadRead();
+ LwpObjectStream aObjStrm(pStrm, ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(ObjHdr.GetSize()) );
+
+ if( sal_uInt32(VO_OBJINDEX) == ObjHdr.GetTag() )
+ {
+ ReadObjIndexData( &aObjStrm );
+ }
+ else if( sal_uInt32(VO_LEAFOBJINDEX) == ObjHdr.GetTag() )
+ {
+ ReadLeafData( &aObjStrm );
+ }
+}
+
+/**
+ * @descr Read VO_LEAFOBJINDEX
+ */
+void LwpIndexManager::ReadLeafIndex( LwpSvStream *pStrm )
+{
+ LwpObjectHeader ObjHdr;
+ if (!ObjHdr.Read(*pStrm))
+ throw BadRead();
+ LwpObjectStream aObjStrm( pStrm, ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(ObjHdr.GetSize()) );
+
+ ReadLeafData(&aObjStrm);
+}
+/**
+ * @descr Read data in VO_LEAFOBJINDEX
+ */
+void LwpIndexManager::ReadLeafData( LwpObjectStream *pObjStrm )
+{
+ sal_uInt16 KeyCount = pObjStrm->QuickReaduInt16();
+
+ if(KeyCount)
+ {
+ LwpKey akey;
+ //read object keys: id & offset
+ akey.id.Read(pObjStrm);
+ m_ObjectKeys.push_back(akey);
+
+ for (sal_uInt16 k = 1; k < KeyCount; k++)
+ {
+ akey.id.ReadCompressed(pObjStrm, m_ObjectKeys.at(m_nKeyCount+k-1).id);
+ m_ObjectKeys.push_back(akey);
+ }
+
+ for (sal_uInt16 j = 0; j < KeyCount; j++)
+ m_ObjectKeys.at(m_nKeyCount+j).offset = pObjStrm->QuickReaduInt32();
+ }
+ m_nKeyCount += KeyCount;
+}
+/**
+ * @descr Read time table in VO_ROOTLEAFOBJINDEX and VO_ROOTOBJINDEX
+ */
+void LwpIndexManager::ReadTimeTable(LwpObjectStream *pObjStrm)
+{
+ sal_uInt16 nTimeCount = pObjStrm->QuickReaduInt16();
+
+ for(sal_uInt16 i=0; i<nTimeCount; ++i)
+ {
+ sal_uInt32 atime = pObjStrm->QuickReaduInt32();
+ m_TimeTable.push_back(atime);
+ }
+}
+/**
+ * @descr get object offset per the object id
+ */
+sal_uInt32 LwpIndexManager::GetObjOffset( LwpObjectID objid )
+{
+
+ //sal_uInt16 L, U, M;
+ sal_uInt32 L, U, M;
+
+ L = 0;
+ U = m_nKeyCount;
+ while (L != U)
+ {
+ M = (L + U) >> 1;
+
+ if (objid.GetLow() > m_ObjectKeys[M].id.GetLow())
+ L = M + 1;
+ else if (objid.GetLow() < m_ObjectKeys[M].id.GetLow())
+ U = M;
+ else if (objid.GetHigh() > m_ObjectKeys[M].id.GetHigh())
+ L = M + 1;
+ else if (objid.GetHigh() < m_ObjectKeys[M].id.GetHigh())
+ U = M;
+ else
+ {
+ return(m_ObjectKeys[M].offset);
+ }
+ }
+ return BAD_OFFSET;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
new file mode 100644
index 000000000..6405e2277
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -0,0 +1,2119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+#include "lwplayout.hxx"
+#include "lwpusewhen.hxx"
+#include <lwptools.hxx>
+#include "lwplaypiece.hxx"
+#include <xfilter/xfcolumns.hxx>
+#include "lwpstory.hxx"
+#include "lwpparastyle.hxx"
+#include "lwpholder.hxx"
+#include "lwpdoc.hxx"
+#include "lwpgrfobj.hxx"
+#include <lwpfilehdr.hxx>
+#include <osl/thread.h>
+#include <sal/log.hxx>
+#include <o3tl/sorted_vector.hxx>
+
+LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFPVList(objHdr, pStrm)
+ , m_bGettingHonorProtection(false)
+ , m_bGettingMarginsSameAsParent(false)
+ , m_bGettingHasProtection(false)
+ , m_bGettingIsProtected(false)
+ , m_bGettingIsAutoGrowDown(false)
+ , m_bGettingMarginsValue(false)
+ , m_bGettingExtMarginsValue(false)
+ , m_bGettingUsePrinterSettings(false)
+ , m_bGettingScaleCenter(false)
+ , m_bGettingBorderStuff(false)
+ , m_bGettingUseWhen(false)
+ , m_bGettingStyleLayout(false)
+ , m_bGettingAutoGrowUp(false)
+ , m_nAttributes(0)
+ , m_nAttributes2(0)
+ , m_nAttributes3(0)
+ , m_nOverrideFlag(0)
+ , m_nDirection(0)
+ , m_nEditorID(0)
+{
+}
+
+void LwpVirtualLayout::Read()
+{
+ LwpDLNFPVList::Read();
+
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+ m_nAttributes = pStrm->QuickReaduInt32();
+ m_nAttributes2 = pStrm->QuickReaduInt32();
+ m_nAttributes3 = pStrm->QuickReaduInt32();
+ m_nOverrideFlag = pStrm->QuickReaduInt32();
+ m_nDirection = pStrm->QuickReaduInt16();
+
+ //Note that two bytes is read into m_nEditorID instead of one byte.
+ m_nEditorID = pStrm->QuickReaduInt16();
+
+ m_NextEnumerated.ReadIndexed(pStrm);
+ m_PreviousEnumerated.ReadIndexed(pStrm);
+
+ pStrm->SkipExtra();
+}
+
+bool LwpVirtualLayout::MarginsSameAsParent()
+{
+ return (m_nAttributes2 & STYLE2_MARGINSSAMEASPARENT) != 0;
+}
+
+/**
+* @descr: Get the gap between columns
+*
+*/
+double LwpVirtualLayout::GetColGap(sal_uInt16 /*nIndex*/)
+{
+ //return DEFAULTGAPSIZE;
+ //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
+ return LwpTools::ConvertToMetric(0.17);
+}
+
+/**
+* @descr: Whether it is honoring protection
+*
+*/
+bool LwpVirtualLayout::HonorProtection()
+{
+ if (!(m_nAttributes2 & STYLE2_HONORPROTECTION))
+ return false;
+
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ return xParent->GetHonorProtection();
+ }
+
+ if (m_pFoundry) //is null now
+ {
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ if (pDoc && pDoc->GetRootDocument())
+ return pDoc->GetRootDocument()->GetHonorProtection();
+ }
+
+ return true;
+}
+
+/**
+* @descr: Whether it is protected
+*
+*/
+bool LwpVirtualLayout::IsProtected()
+{
+ bool bProtected = (m_nAttributes & STYLE_PROTECTED) != 0;
+
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ if (xParent->GetHonorProtection() && (xParent->GetHasProtection() || bProtected))
+ {
+ return true;
+ }
+ }
+ else if (m_pFoundry) //is null now
+ {
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ if (pDoc)
+ {
+ if (pDoc->GetHonorProtection() && bProtected)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/**
+* @descr: Whether it has protection
+*
+*/
+bool LwpVirtualLayout::HasProtection()
+{
+ if (m_nAttributes & STYLE_PROTECTED)
+ return true;
+
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ return xParent->GetHasProtection();
+ }
+
+ return false;
+}
+
+/**
+* @descr: Whether it is a mirror layout
+*
+*/
+bool LwpVirtualLayout::IsComplex() const { return (m_nAttributes & STYLE_COMPLEX) != 0; }
+
+/**
+* @descr: Get usewhen pointer
+*
+*/
+LwpUseWhen* LwpVirtualLayout::GetUseWhen()
+{
+ if (m_bGettingUseWhen)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingUseWhen = true;
+
+ LwpUseWhen* pRet = nullptr;
+
+ /*
+ If we have a parent, and I'm not a page layout,
+ use my parents information.
+ */
+ if (GetLayoutType() != LWP_PAGE_LAYOUT)
+ {
+ //get parent
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader() && (xParent->GetLayoutType() != LWP_PAGE_LAYOUT))
+ pRet = xParent->GetUseWhen();
+ }
+
+ if (!pRet)
+ pRet = VirtualGetUseWhen();
+
+ m_bGettingUseWhen = false;
+
+ return pRet;
+}
+/**
+ * @descr: Whether this layout is page layout or not
+*/
+bool LwpVirtualLayout::IsPage() { return (GetLayoutType() == LWP_PAGE_LAYOUT); }
+/**
+ * @descr: Whether this layout is header layout or not
+*/
+bool LwpVirtualLayout::IsHeader() { return (GetLayoutType() == LWP_HEADER_LAYOUT); }
+/**
+ * @descr: Whether this layout is footer layout or not
+*/
+bool LwpVirtualLayout::IsFooter() { return (GetLayoutType() == LWP_FOOTER_LAYOUT); }
+/**
+ * @descr: Whether this layout is frame layout or not
+*/
+bool LwpVirtualLayout::IsFrame() { return (GetLayoutType() == LWP_FRAME_LAYOUT); }
+
+/**
+ * @descr: Whether this layout is cell layout or not
+*/
+bool LwpVirtualLayout::IsCell()
+{
+ return (GetLayoutType() == LWP_CELL_LAYOUT || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
+ || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT);
+}
+/**
+ * @descr: Whether this layout is supertable layout or not
+*/
+bool LwpVirtualLayout::IsSuperTable() { return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT); }
+/**
+ * @descr: Whether this layout is group layout or not
+*/
+bool LwpVirtualLayout::IsGroupHead() { return (GetLayoutType() == LWP_GROUP_LAYOUT); }
+/**
+ * @descr: get the relative type
+*/
+sal_uInt8 LwpVirtualLayout::GetRelativeType()
+{
+ return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE;
+}
+/**
+ * @descr: whether it is relative anchored layout
+*/
+bool LwpVirtualLayout::IsRelativeAnchored()
+{
+ sal_uInt8 nType;
+
+ nType = GetRelativeType();
+ return (nType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE)
+ || (nType == LwpLayoutRelativityGuts::LAY_INLINE)
+ || (nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
+ || (nType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL);
+}
+/**
+ * @descr: whether it is MinimumHeight layout
+*/
+bool LwpVirtualLayout::IsMinimumHeight() const
+{
+ return ((m_nAttributes3 & STYLE3_MINHEIGHTVALID) != 0);
+}
+
+/**
+* @descr: Get parent layout
+*
+*/
+rtl::Reference<LwpVirtualLayout> LwpVirtualLayout::GetParentLayout()
+{
+ return rtl::Reference<LwpVirtualLayout>(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+}
+
+/**
+* @descr: Register child layout style
+*
+*/
+void LwpVirtualLayout::RegisterChildStyle()
+{
+ //Register all children styles
+ rtl::Reference<LwpVirtualLayout> xLayout(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ while (xLayout.is())
+ {
+ xLayout->SetFoundry(m_pFoundry);
+ xLayout->DoRegisterStyle();
+ xLayout.set(dynamic_cast<LwpVirtualLayout*>(xLayout->GetNext().obj().get()));
+ }
+}
+
+bool LwpVirtualLayout::NoContentReference()
+{
+ return (m_nAttributes2 & STYLE2_NOCONTENTREFERENCE) != 0;
+}
+
+bool LwpVirtualLayout::IsStyleLayout()
+{
+ if (m_bGettingStyleLayout)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingStyleLayout = true;
+
+ bool bRet = false;
+ if (m_nAttributes3 & STYLE3_STYLELAYOUT)
+ bRet = true;
+ else
+ {
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is())
+ bRet = xParent->IsStyleLayout();
+ }
+
+ m_bGettingStyleLayout = false;
+ return bRet;
+}
+
+/**
+* @descr: Find child layout by layout type
+*
+*/
+LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
+{
+ LwpObjectID* pID = &GetChildHead();
+ LwpVirtualLayout* pPrevLayout = nullptr;
+
+ while (pID && !pID->IsNull())
+ {
+ LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pID->obj().get());
+ if (!pLayout)
+ break;
+
+ if (pPrevLayout && pLayout == pPrevLayout)
+ {
+ SAL_WARN("lwp", "loop in layout");
+ break;
+ }
+
+ pPrevLayout = pLayout;
+
+ if (pLayout->GetLayoutType() == eType)
+ return pLayout;
+
+ pID = &pLayout->GetNext();
+ }
+
+ return nullptr;
+}
+
+/**
+* @descr: Whether the size of layout is fit the graphic
+*
+*/
+bool LwpVirtualLayout::IsFitGraphic()
+{
+ return IsAutoGrowRight() && !IsAutoGrowLeft() && GetIsAutoGrowDown();
+}
+
+/**
+* @descr: Whether the width of layout is auto grow
+*
+*/
+bool LwpVirtualLayout::IsAutoGrowWidth() { return IsAutoGrowLeft() || IsAutoGrowRight(); }
+
+/**
+* @descr: Determine whether the layout width is to margin
+*
+*/
+bool LwpVirtualLayout::IsInlineToMargin() const
+{
+ return (m_nAttributes3 & STYLE3_INLINETOMARGIN) != 0;
+}
+
+void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
+{
+ m_OnlyLayout.ReadIndexed(pStrm);
+ m_Layouts.Read(pStrm);
+ pStrm->SkipExtra();
+}
+
+/**
+* @descr: Looking for the layout which follows the pStartLayout
+* @param: pStartLayout - the layout which is used for looking for its following layout
+*/
+rtl::Reference<LwpVirtualLayout>
+LwpAssociatedLayouts::GetLayout(LwpVirtualLayout const* pStartLayout)
+{
+ if (!pStartLayout && !m_OnlyLayout.IsNull())
+ /* Looking for the first layout and there's only one layout in the list.*/
+ return rtl::Reference<LwpVirtualLayout>(
+ dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj().get()));
+
+ rtl::Reference<LwpObjectHolder> xObjHolder(
+ dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead().obj().get()));
+ if (xObjHolder.is())
+ {
+ rtl::Reference<LwpVirtualLayout> xLayout(
+ dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
+ if (!pStartLayout)
+ return xLayout;
+
+ while (xObjHolder.is() && pStartLayout != xLayout.get())
+ {
+ xObjHolder.set(dynamic_cast<LwpObjectHolder*>(xObjHolder->GetNext().obj().get()));
+ if (xObjHolder.is())
+ {
+ xLayout.set(dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
+ }
+ }
+
+ if (xObjHolder.is())
+ {
+ xObjHolder.set(dynamic_cast<LwpObjectHolder*>(xObjHolder->GetNext().obj().get()));
+ if (xObjHolder.is())
+ {
+ xLayout.set(dynamic_cast<LwpVirtualLayout*>(xObjHolder->GetObject().obj().get()));
+ return xLayout;
+ }
+ }
+ }
+
+ return rtl::Reference<LwpVirtualLayout>();
+}
+
+LwpHeadLayout::LwpHeadLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpVirtualLayout(objHdr, pStrm)
+{
+}
+
+void LwpHeadLayout::Read()
+{
+ LwpVirtualLayout::Read();
+ //For PermissiveLayout
+ m_pObjStrm->SkipExtra();
+ //For me
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpHeadLayout::RegisterStyle()
+{
+ //Register all children styles
+ rtl::Reference<LwpVirtualLayout> xLayout(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xLayout.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xLayout.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ xLayout->SetFoundry(m_pFoundry);
+ //if the layout is relative to para, the layout will be registered in para
+ if (!xLayout->IsRelativeAnchored())
+ xLayout->DoRegisterStyle();
+ rtl::Reference<LwpVirtualLayout> xNext(
+ dynamic_cast<LwpVirtualLayout*>(xLayout->GetNext().obj().get()));
+ xLayout = xNext;
+ }
+}
+
+/**
+ * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
+ * @return pointer to endnote supertable layout
+ */
+rtl::Reference<LwpVirtualLayout> LwpHeadLayout::FindEnSuperTableLayout()
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(xLayout.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if (xLayout->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT)
+ {
+ return xLayout;
+ }
+ xLayout.set(dynamic_cast<LwpVirtualLayout*>(xLayout->GetNext().obj().get()));
+ }
+ return rtl::Reference<LwpVirtualLayout>();
+}
+
+LwpLayoutStyle::LwpLayoutStyle()
+ : m_nStyleDefinition(0)
+ , m_pDescription(new LwpAtomHolder)
+ , m_nKey(0)
+{
+}
+
+LwpLayoutStyle::~LwpLayoutStyle() {}
+
+void LwpLayoutStyle::Read(LwpObjectStream* pStrm)
+{
+ m_nStyleDefinition = pStrm->QuickReaduInt32();
+ m_pDescription->Read(pStrm);
+ if (pStrm->CheckExtra())
+ {
+ m_nKey = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+ }
+}
+
+LwpLayoutMisc::LwpLayoutMisc()
+ : m_nGridDistance(0)
+ , m_nGridType(0)
+{
+}
+
+LwpLayoutMisc::~LwpLayoutMisc() {}
+
+void LwpLayoutMisc::Read(LwpObjectStream* pStrm)
+{
+ m_nGridType = pStrm->QuickReaduInt16();
+ m_nGridDistance = pStrm->QuickReadInt32();
+ m_aContentStyle.Read(pStrm);
+ pStrm->SkipExtra();
+}
+
+LwpMiddleLayout::LwpMiddleLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpVirtualLayout(objHdr, pStrm)
+ , m_bGettingGeometry(false)
+ , m_bGettingBackgroundStuff(false)
+{
+}
+
+LwpMiddleLayout::~LwpMiddleLayout() {}
+
+void LwpMiddleLayout::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ LwpVirtualLayout::Read();
+
+ //skip CLiteLayout data;
+ LwpAtomHolder ContentClass;
+ ContentClass.Read(pStrm);
+ pStrm->SkipExtra();
+
+ // before layout hierarchy rework
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ return;
+
+ m_Content.ReadIndexed(pStrm);
+
+ // 01/20/2005
+ m_BasedOnStyle.ReadIndexed(pStrm);
+ m_TabPiece.ReadIndexed(pStrm);
+
+ sal_uInt8 nWhatsItGot = pStrm->QuickReaduInt8();
+
+ if (nWhatsItGot & DISK_GOT_STYLE_STUFF)
+ {
+ m_aStyleStuff.Read(pStrm);
+ }
+ if (nWhatsItGot & DISK_GOT_MISC_STUFF)
+ {
+ m_aMiscStuff.Read(pStrm);
+ }
+
+ m_LayGeometry.ReadIndexed(pStrm);
+ m_LayScale.ReadIndexed(pStrm);
+ m_LayMargins.ReadIndexed(pStrm);
+ m_LayBorderStuff.ReadIndexed(pStrm);
+ m_LayBackgroundStuff.ReadIndexed(pStrm);
+
+ if (pStrm->CheckExtra())
+ {
+ m_LayExtBorderStuff.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+ }
+}
+
+rtl::Reference<LwpObject> LwpMiddleLayout::GetBasedOnStyle() const
+{
+ rtl::Reference<LwpObject> xRet(m_BasedOnStyle.obj());
+ if (xRet.get() == this)
+ {
+ SAL_WARN("lwp", "style based on itself");
+ return rtl::Reference<LwpObject>();
+ }
+ return xRet;
+}
+
+/**
+* @descr: Get the geometry of current layout
+*
+*/
+LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
+{
+ if (m_bGettingGeometry)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingGeometry = true;
+
+ LwpLayoutGeometry* pRet = nullptr;
+ if (!m_LayGeometry.IsNull())
+ {
+ pRet = dynamic_cast<LwpLayoutGeometry*>(m_LayGeometry.obj().get());
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ pRet = pLay->GetGeometry();
+ }
+ }
+
+ m_bGettingGeometry = false;
+ return pRet;
+}
+
+/**
+* @descr: Get layout height, measured by "cm"
+*
+*/
+double LwpMiddleLayout::GetGeometryHeight()
+{
+ LwpLayoutGeometry* pGeo = GetGeometry();
+ if (pGeo)
+ {
+ return LwpTools::ConvertFromUnitsToMetric(pGeo->GetHeight());
+ }
+ else
+ return -1;
+}
+
+/**
+* @descr: Get layout width, measured by "cm"
+*
+*/
+double LwpMiddleLayout::GetGeometryWidth()
+{
+ LwpLayoutGeometry* pGeo = GetGeometry();
+ if (pGeo)
+ {
+ return LwpTools::ConvertFromUnitsToMetric(pGeo->GetWidth());
+ }
+ else
+ return -1;
+}
+
+/**
+* @descr: Whether the margins is same as parent layout
+*
+*/
+bool LwpMiddleLayout::MarginsSameAsParent()
+{
+ if (m_nOverrideFlag & OVER_MARGINS)
+ {
+ return LwpVirtualLayout::MarginsSameAsParent();
+ }
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(xBase.get()))
+ {
+ pLay->GetMarginsSameAsParent();
+ }
+ return LwpVirtualLayout::MarginsSameAsParent();
+}
+
+/**
+* @descr: Get margin
+* @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
+*/
+double LwpMiddleLayout::MarginsValue(sal_uInt8 nWhichSide)
+{
+ double fValue = 0;
+ if ((nWhichSide == MARGIN_LEFT) || (nWhichSide == MARGIN_RIGHT))
+ {
+ if (GetMarginsSameAsParent())
+ {
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ fValue = xParent->GetMarginsValue(nWhichSide);
+ return fValue;
+ }
+ }
+ }
+
+ if (m_nOverrideFlag & OVER_MARGINS)
+ {
+ LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*>(m_LayMargins.obj().get());
+ if (pMar1)
+ {
+ fValue = pMar1->GetMargins().GetMarginsValue(nWhichSide);
+ return fValue;
+ }
+ }
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(xBase.get());
+ if (pStyle)
+ {
+ fValue = pStyle->GetMarginsValue(nWhichSide);
+ return fValue;
+ }
+ return LwpVirtualLayout::MarginsValue(nWhichSide);
+}
+/**
+ * @descr: Get extmargin value
+ * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
+ * @param:
+ * @return:
+*/
+double LwpMiddleLayout::ExtMarginsValue(sal_uInt8 nWhichSide)
+{
+ double fValue = 0;
+ if (m_nOverrideFlag & OVER_MARGINS)
+ {
+ LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*>(m_LayMargins.obj().get());
+ if (pMar1)
+ {
+ fValue = pMar1->GetExtMargins().GetMarginsValue(nWhichSide);
+ return fValue;
+ }
+ }
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(GetBasedOnStyle().get());
+ if (pStyle)
+ {
+ fValue = pStyle->GetExtMarginsValue(nWhichSide);
+ return fValue;
+ }
+ return LwpVirtualLayout::ExtMarginsValue(nWhichSide);
+}
+/**
+ * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
+*/
+LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
+{
+ if (m_bGettingBorderStuff)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingBorderStuff = true;
+
+ LwpBorderStuff* pRet = nullptr;
+
+ if (m_nOverrideFlag & OVER_BORDERS)
+ {
+ LwpLayoutBorder* pLayoutBorder
+ = dynamic_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj().get());
+ pRet = pLayoutBorder ? &pLayoutBorder->GetBorderStuff() : nullptr;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ pRet = pLay->GetBorderStuff();
+ }
+ }
+
+ m_bGettingBorderStuff = false;
+ return pRet;
+}
+
+/**
+ * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
+*/
+LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
+{
+ if (m_bGettingBackgroundStuff)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingBackgroundStuff = true;
+
+ LwpBackgroundStuff* pRet = nullptr;
+
+ if (m_nOverrideFlag & OVER_BACKGROUND)
+ {
+ LwpLayoutBackground* pLayoutBackground
+ = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj().get());
+ pRet = pLayoutBackground ? &pLayoutBackground->GetBackgoudStuff() : nullptr;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ pRet = pLay->GetBackgroundStuff();
+ }
+ }
+
+ m_bGettingBackgroundStuff = false;
+ return pRet;
+}
+
+/**
+ * @descr: create xfborder.
+*/
+std::unique_ptr<XFBorders> LwpMiddleLayout::GetXFBorders()
+{
+ LwpBorderStuff* pBorderStuff = GetBorderStuff();
+ if (pBorderStuff && pBorderStuff->GetSide() != 0)
+ {
+ //copy from lwpparastyle.
+ std::unique_ptr<XFBorders> xXFBorders(new XFBorders);
+ // apply 4 borders respectively
+ LwpBorderStuff::BorderType const pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
+ LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
+
+ for (LwpBorderStuff::BorderType nC : pType)
+ {
+ if (pBorderStuff->HasSide(nC))
+ {
+ LwpParaStyle::ApplySubBorder(pBorderStuff, nC, xXFBorders.get());
+ }
+ }
+ return xXFBorders;
+ }
+ return nullptr;
+}
+
+/**
+ * @descr: Get text direction settings.
+*/
+enumXFTextDir LwpMiddleLayout::GetTextDirection()
+{
+ enumXFTextDir eTextDir = enumXFTextDirNone;
+ sal_uInt8 nDirection = GetContentOrientation();
+ switch (nDirection)
+ {
+ case TEXT_ORIENT_LRTB:
+ {
+ eTextDir = enumXFTextDirLR_TB;
+ break;
+ }
+ case TEXT_ORIENT_TBRL:
+ {
+ eTextDir = enumXFTextDirTB_RL;
+ break;
+ }
+ case TEXT_ORIENT_RLBT: // not supported now
+ {
+ eTextDir = enumXFTextDirNone;
+ break;
+ }
+ case TEXT_ORIENT_BTLR: // not supported now
+ {
+ eTextDir = enumXFTextDirNone;
+ break;
+ }
+ default:
+ break;
+ }
+ return eTextDir;
+}
+/**
+ * @descr: Get background color.
+*/
+LwpColor* LwpMiddleLayout::GetBackColor()
+{
+ LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
+ if (pBackgroundStuff && !pBackgroundStuff->IsTransparent())
+ {
+ LwpColor* pColor = pBackgroundStuff->GetFillColor();
+ if (pColor->IsValidColor())
+ {
+ return pColor;
+ }
+ }
+ return nullptr;
+}
+
+/**
+ * @descr: Add back color settings into xfpagemaster.
+*/
+LwpTabOverride* LwpMiddleLayout::GetTabOverride()
+{
+ if (m_nAttributes & OVER_TABS)
+ {
+ if (!m_TabPiece.IsNull())
+ {
+ LwpTabPiece* pPiece = dynamic_cast<LwpTabPiece*>(m_TabPiece.obj().get());
+ return static_cast<LwpTabOverride*>(pPiece ? pPiece->GetOverride() : nullptr);
+ }
+ return nullptr;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->GetTabOverride();
+ }
+ }
+ return nullptr;
+}
+
+/**
+ * @descr: Layscale for graphic & watermark
+*/
+sal_uInt16 LwpMiddleLayout::GetScaleMode()
+{
+ if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is() && GetLayoutScale())
+ return GetLayoutScale()->GetScaleMode();
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (xBase.is())
+ return dynamic_cast<LwpMiddleLayout&>(*xBase).GetScaleMode();
+ else
+ return (LwpLayoutScale::FIT_IN_FRAME | LwpLayoutScale::MAINTAIN_ASPECT_RATIO);
+}
+
+sal_uInt16 LwpMiddleLayout::GetScaleTile()
+{
+ if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is() && GetLayoutScale())
+ return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED) ? 1 : 0;
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (xBase.is())
+ return dynamic_cast<LwpMiddleLayout&>(*xBase).GetScaleTile();
+ else
+ return 0;
+}
+
+sal_uInt16 LwpMiddleLayout::GetScaleCenter()
+{
+ if (m_bGettingScaleCenter)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingScaleCenter = true;
+
+ sal_uInt16 nRet = 0;
+
+ if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj().is() && GetLayoutScale())
+ {
+ nRet = (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED) ? 1 : 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (xBase.is())
+ nRet = dynamic_cast<LwpMiddleLayout&>(*xBase).GetScaleCenter();
+ }
+
+ m_bGettingScaleCenter = false;
+ return nRet;
+}
+
+bool LwpMiddleLayout::CanSizeRight()
+{
+ sal_uInt8 RelType = GetRelativeType();
+
+ return !(RelType == LwpLayoutRelativityGuts::LAY_INLINE
+ || RelType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
+ || RelType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL);
+}
+sal_Int32 LwpMiddleLayout::GetMinimumWidth()
+{
+ if (((m_nAttributes3 & STYLE3_WIDTHVALID) != 0) && GetGeometry())
+ {
+ return GetGeometry()->GetWidth();
+ }
+ else if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return DetermineWidth();
+ }
+ return 0;
+}
+sal_Int32 LwpMiddleLayout::DetermineWidth()
+{
+ if (IsSizeRightToContent())
+ {
+ assert(false);
+ }
+ else if (IsSizeRightToContainer())
+ {
+ assert(false);
+ }
+ else if (LwpLayoutGeometry* pGeo = GetGeometry())
+ {
+ m_nAttributes3 |= STYLE3_WIDTHVALID;
+ return pGeo->GetWidth();
+ }
+ return 0;
+}
+bool LwpMiddleLayout::IsSizeRightToContainer()
+{
+ if (!CanSizeRight())
+ return false;
+
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection & ((LAY_USEDIRECTION | LAY_AUTOSIZE | LAY_TOCONTAINER) << SHIFT_RIGHT))
+ == ((LAY_USEDIRECTION | LAY_TOCONTAINER | LAY_AUTOSIZE) << SHIFT_RIGHT);
+ }
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (xBase.is())
+ {
+ LwpMiddleLayout* pLayout = dynamic_cast<LwpMiddleLayout*>(xBase.get());
+ return pLayout && pLayout->IsSizeRightToContainer();
+ }
+ else
+ return false;
+}
+bool LwpMiddleLayout::IsSizeRightToContent()
+{
+ if (!CanSizeRight())
+ return false;
+
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection & ((LAY_USEDIRECTION | LAY_AUTOSIZE | LAY_TOCONTAINER) << SHIFT_RIGHT))
+ == ((LAY_USEDIRECTION | LAY_AUTOSIZE) << SHIFT_RIGHT);
+ }
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (xBase.is())
+ {
+ LwpMiddleLayout* pLayout = dynamic_cast<LwpMiddleLayout*>(xBase.get());
+ return pLayout && pLayout->IsSizeRightToContent();
+ }
+ else
+ return false;
+}
+
+/**
+* @descr: Get layout height
+*
+*/
+double LwpMiddleLayout::GetHeight() { return GetGeometryHeight(); }
+
+/**
+* @descr: Get layout height
+*
+*/
+double LwpMiddleLayout::GetWidth() { return GetGeometryWidth(); }
+/**
+* @descr: Get layout origin point
+*
+*/
+LwpPoint LwpMiddleLayout::GetOrigin()
+{
+ LwpLayoutGeometry* pGeo = GetGeometry();
+ if (pGeo)
+ {
+ sal_uInt8 nType = GetRelativeType();
+ if (nType == LwpLayoutRelativityGuts::LAY_INLINE
+ || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
+ {
+ return pGeo->GetAbsoluteOrigin();
+ }
+ else
+ return pGeo->GetOrigin();
+ }
+
+ return LwpPoint();
+}
+
+/**
+* @descr: Whether the fill is pattern fill or not
+* @return: True if yes, false if not.
+*/
+bool LwpMiddleLayout::IsPatternFill()
+{
+ LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
+ if (pBackgroundStuff)
+ {
+ return pBackgroundStuff->IsPatternFill();
+ }
+
+ return false;
+}
+
+/**
+* @descr: Get the fill pattern style. Data are saved in a XFBGImage object
+* @return: the fill pattern style.
+*/
+std::unique_ptr<XFBGImage> LwpMiddleLayout::GetFillPattern()
+{
+ LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
+ if (pBackgroundStuff)
+ {
+ return pBackgroundStuff->GetFillPattern();
+ }
+
+ return std::unique_ptr<XFBGImage>();
+}
+
+/**
+* @descr: Whether the height and width of layout is auto grow
+*
+*/
+bool LwpMiddleLayout::IsAutoGrow()
+{
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection
+ & ((LAY_AUTOGROW << SHIFT_UP) | (LAY_AUTOGROW << SHIFT_DOWN)
+ | (LAY_AUTOGROW << SHIFT_RIGHT) | (LAY_AUTOGROW << SHIFT_LEFT)))
+ != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->IsAutoGrow();
+ }
+ }
+ return LwpVirtualLayout::IsAutoGrow();
+}
+
+/**
+* @descr: Whether the height of layout is auto grow down
+*
+*/
+bool LwpMiddleLayout::IsAutoGrowDown()
+{
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection & (LAY_AUTOGROW << SHIFT_DOWN)) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->GetIsAutoGrowDown();
+ }
+ }
+ return LwpVirtualLayout::IsAutoGrowDown();
+}
+
+/**
+* @descr: Whether the height of layout is auto grow up
+*
+*/
+bool LwpMiddleLayout::IsAutoGrowUp()
+{
+ if (m_bGettingAutoGrowUp)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingAutoGrowUp = true;
+
+ bool bRet;
+
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ bRet = (m_nDirection & (LAY_AUTOGROW << SHIFT_UP)) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ bRet = pLay->IsAutoGrowUp();
+ else
+ bRet = LwpVirtualLayout::IsAutoGrowUp();
+ }
+
+ m_bGettingAutoGrowUp = false;
+ return bRet;
+}
+
+/**
+* @descr: Whether the height of layout is auto grow down
+*
+*/
+bool LwpMiddleLayout::IsAutoGrowLeft()
+{
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection & (LAY_AUTOGROW << SHIFT_LEFT)) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->IsAutoGrowLeft();
+ }
+ }
+ return LwpVirtualLayout::IsAutoGrowLeft();
+}
+
+/**
+* @descr: Whether the height of layout is auto grow down
+*
+*/
+bool LwpMiddleLayout::IsAutoGrowRight()
+{
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ return (m_nDirection & (LAY_AUTOGROW << SHIFT_RIGHT)) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->IsAutoGrowRight();
+ }
+ }
+ return LwpVirtualLayout::IsAutoGrowRight();
+}
+
+/**
+* @descr: Get contents orientation
+*
+*/
+sal_uInt8 LwpMiddleLayout::GetContentOrientation()
+{
+ //content orientation in Graphic objects and OLE objects not supported now
+ if ((m_nOverrideFlag & OVER_ROTATION) && !m_LayGeometry.IsNull())
+ {
+ LwpLayoutGeometry* pLayGeometry
+ = dynamic_cast<LwpLayoutGeometry*>(m_LayGeometry.obj().get());
+ if (pLayGeometry)
+ return pLayGeometry->GetContentOrientation();
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->GetContentOrientation();
+ }
+ }
+ return LwpVirtualLayout::GetContentOrientation();
+}
+
+/**
+* @descr: Whether it is honoring protection
+*
+*/
+bool LwpMiddleLayout::HonorProtection()
+{
+ if (m_nOverrideFlag & OVER_MISC)
+ {
+ if (!(m_nAttributes2 & STYLE2_HONORPROTECTION))
+ return false;
+
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ return xParent->GetHonorProtection();
+ }
+
+ if (m_pFoundry) //is null now
+ {
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ if (pDoc)
+ {
+ return pDoc->GetHonorProtection();
+ }
+ }
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ return pLay->GetHonorProtection();
+ }
+ }
+
+ return LwpVirtualLayout::HonorProtection();
+}
+
+/**
+* @descr: Whether it is protected
+*
+*/
+bool LwpMiddleLayout::IsProtected()
+{
+ bool bProtected = false;
+ if (m_nOverrideFlag & OVER_MISC)
+ {
+ bProtected = (m_nAttributes & STYLE_PROTECTED) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ bProtected = pLay->GetIsProtected();
+ }
+ else
+ bProtected = LwpVirtualLayout::IsProtected();
+ }
+
+ rtl::Reference<LwpVirtualLayout> xParent(
+ dynamic_cast<LwpVirtualLayout*>(GetParent().obj().get()));
+ if (xParent.is() && !xParent->IsHeader())
+ {
+ /* If a parent's protected then none of its children can be accessed. */
+ if (xParent->GetIsProtected())
+ return true;
+
+ if (xParent->GetHonorProtection())
+ return bProtected;
+
+ /* If our parent isn't honoring protection then we aren't protected. */
+ return false;
+ }
+ if (m_pFoundry) //is null now
+ {
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ if (pDoc)
+ {
+ if (pDoc->GetHonorProtection())
+ return bProtected;
+
+ /* If the document isn't honoring protection then we aren't protected.*/
+ return false;
+ }
+ }
+
+ return bProtected;
+}
+
+/**
+* @descr: Get watermark layout
+*
+*/
+rtl::Reference<LwpVirtualLayout> LwpMiddleLayout::GetWaterMarkLayout()
+{
+ rtl::Reference<LwpVirtualLayout> xLay(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xLay.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xLay.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if (xLay->IsForWaterMark())
+ {
+ return xLay;
+ }
+ rtl::Reference<LwpVirtualLayout> xNext(
+ dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
+ xLay = xNext;
+ }
+ return rtl::Reference<LwpVirtualLayout>();
+}
+
+/**
+* @descr: Create and return xfbgimage object for watermark
+*
+*/
+std::unique_ptr<XFBGImage> LwpMiddleLayout::GetXFBGImage()
+{
+ std::unique_ptr<XFBGImage> xXFBGImage;
+
+ rtl::Reference<LwpVirtualLayout> xWaterMarkLayout(GetWaterMarkLayout());
+ LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xWaterMarkLayout.get());
+ if (pLay)
+ {
+ //test BGImage
+ LwpGraphicObject* pGrfObj = dynamic_cast<LwpGraphicObject*>(pLay->GetContent().obj().get());
+ if (pGrfObj)
+ {
+ xXFBGImage.reset(new XFBGImage);
+ if (pGrfObj->IsLinked())
+ {
+ //set file link
+ OUString linkedfilepath = pGrfObj->GetLinkedFilePath();
+ OUString fileURL = LwpTools::convertToFileUrl(
+ OUStringToOString(linkedfilepath, osl_getThreadTextEncoding()));
+ xXFBGImage->SetFileLink(fileURL);
+ }
+ else
+ {
+ std::vector<sal_uInt8> aGrafData = pGrfObj->GetRawGrafData();
+ xXFBGImage->SetImageData(aGrafData.data(), aGrafData.size());
+ }
+
+ //automatic, top left
+ xXFBGImage->SetPosition(enumXFAlignStart, enumXFAlignTop);
+ if (pLay->GetScaleCenter())
+ {
+ //center
+ xXFBGImage->SetPosition();
+ }
+ else if (pLay->GetScaleTile())
+ {
+ //tile
+ xXFBGImage->SetRepeate();
+ }
+ //fit type, area type
+ if ((pLay->GetScaleMode() & LwpLayoutScale::FIT_IN_FRAME) != 0)
+ {
+ if ((pLay->GetScaleMode() & LwpLayoutScale::MAINTAIN_ASPECT_RATIO) == 0)
+ {
+ xXFBGImage->SetStretch();
+ }
+ }
+ }
+ }
+ return xXFBGImage;
+}
+
+/**
+* @descr: Whether the page uses the printer setting
+*
+*/
+bool LwpMiddleLayout::GetUsePrinterSettings()
+{
+ if (m_bGettingUsePrinterSettings)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingUsePrinterSettings = true;
+
+ bool bRet = false;
+
+ if (m_nOverrideFlag & OVER_SIZE)
+ {
+ bRet = (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*>(xBase.get()))
+ {
+ bRet = pLay->GetUsePrinterSettings();
+ }
+ }
+
+ m_bGettingUsePrinterSettings = false;
+ return bRet;
+}
+
+//Check whether there are contents in the layout
+bool LwpMiddleLayout::HasContent()
+{
+ rtl::Reference<LwpObject> content = m_Content.obj();
+ return content.is();
+}
+
+LwpLayout::LwpLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpMiddleLayout(objHdr, pStrm)
+ , m_bGettingShadow(false)
+ , m_bGettingNumCols(false)
+{
+}
+
+LwpLayout::~LwpLayout() {}
+
+void LwpLayout::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ LwpMiddleLayout::Read();
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ // read PreRevBLayout...
+ }
+ else
+ {
+ sal_uInt16 nSimple = pStrm->QuickReaduInt16();
+
+ if (!nSimple)
+ {
+ m_aUseWhen.Read(pStrm);
+
+ sal_uInt8 nFlag = pStrm->QuickReaduInt8();
+ if (nFlag)
+ m_Position.ReadIndexed(pStrm);
+ }
+
+ m_LayColumns.ReadIndexed(pStrm);
+ m_LayGutterStuff.ReadIndexed(pStrm);
+ m_LayJoinStuff.ReadIndexed(pStrm);
+ m_LayShadow.ReadIndexed(pStrm);
+
+ if (pStrm->CheckExtra())
+ {
+ m_LayExtJoinStuff.ReadIndexed(pStrm);
+ pStrm->SkipExtra();
+ }
+ }
+}
+
+/**
+* @descr: Get columns number
+*
+*/
+sal_uInt16 LwpLayout::GetNumCols()
+{
+ if (m_bGettingNumCols)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingNumCols = true;
+
+ sal_uInt16 nRet = 0;
+ LwpLayoutColumns* pLayColumns = (m_nOverrideFlag & OVER_COLUMNS)
+ ? dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj().get())
+ : nullptr;
+ if (pLayColumns)
+ {
+ nRet = pLayColumns->GetNumCols();
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(xBase.get());
+ nRet = pStyle ? pStyle->GetNumCols() : LwpVirtualLayout::GetNumCols();
+ }
+ m_bGettingNumCols = false;
+ return nRet;
+}
+
+/**
+* @descr: Get gap between columns
+* @param: the order of column
+*/
+double LwpLayout::GetColGap(sal_uInt16 nIndex)
+{
+ if ((m_nOverrideFlag & OVER_COLUMNS) || (m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
+ {
+ LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj().get());
+ if (pLayColumns)
+ {
+ return pLayColumns->GetColGap(nIndex);
+ }
+ }
+
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*>(xBase.get());
+ if (pStyle)
+ {
+ return pStyle->GetColGap(nIndex);
+ }
+
+ return LwpVirtualLayout::GetColGap(nIndex);
+}
+
+/**
+* @descr: Create and return XFColumns object
+*
+*/
+XFColumns* LwpLayout::GetXFColumns()
+{
+ //if there is only one column, do not need insert columns
+ sal_uInt16 nCols = GetNumCols();
+ if (nCols == 1)
+ {
+ return nullptr;
+ }
+
+ std::unique_ptr<XFColumns> xColumns(new XFColumns);
+ //set XFColumnSep
+ std::unique_ptr<XFColumnSep> xColumnSep(GetColumnSep());
+ if (xColumnSep)
+ {
+ xColumns->SetSeparator(*xColumnSep);
+ }
+
+ //set column count and column gap
+ xColumns->SetCount(nCols);
+ double fGap = GetColGap(0);
+ xColumns->SetGap(fGap);
+
+ //set xfcolumn
+ for (sal_uInt16 nIndex = 0; nIndex < nCols; nIndex++)
+ {
+ XFColumn aColumn;
+ sal_Int32 nWidth = 8305 / nCols; //relative width
+ aColumn.SetRelWidth(nWidth);
+
+ //the left and right margins is 0;
+ double nGap = GetColGap(nIndex) / 2;
+ aColumn.SetMargins(nGap, nGap);
+ if (nIndex == 0)
+ {
+ aColumn.SetMargins(0, nGap);
+ }
+ if (nIndex == (nCols - 1))
+ {
+ aColumn.SetMargins(nGap, 0);
+ }
+ xColumns->AddColumn(aColumn);
+ }
+
+ return xColumns.release();
+}
+
+/**
+* @descr: Create and return XFColumnSep object
+*
+*/
+XFColumnSep* LwpLayout::GetColumnSep()
+{
+ //Get LwpLayoutGutters
+ LwpLayoutGutters* pLayoutGutters
+ = dynamic_cast<LwpLayoutGutters*>(m_LayGutterStuff.obj().get());
+ if (!pLayoutGutters)
+ {
+ return nullptr;
+ }
+
+ LwpBorderStuff& rBorderStuff = pLayoutGutters->GetBorderStuff();
+
+ LwpBorderStuff::BorderType eType = LwpBorderStuff::LEFT;
+ LwpColor aColor = rBorderStuff.GetSideColor(eType);
+ double fWidth = rBorderStuff.GetSideWidth(eType);
+ //sal_uInt16 nType = rBorderStuff->GetSideType(eType);
+
+ XFColumnSep* pColumnSep = new XFColumnSep();
+ XFColor aXFColor(aColor.To24Color());
+ pColumnSep->SetColor(aXFColor);
+ pColumnSep->SetWidth(fWidth);
+ pColumnSep->SetRelHeight(100);
+ pColumnSep->SetVerticalAlign(enumXFAlignTop);
+
+ return pColumnSep;
+}
+
+/**
+* @descr: Get use when type
+*
+*/
+LwpLayout::UseWhenType LwpLayout::GetUseWhenType()
+{
+ UseWhenType eType = StartWithinPage;
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ {
+ if (pUseWhen->IsStartOnThisHF())
+ {
+ eType = StartWithinColume;
+ }
+ else if (pUseWhen->IsStartOnThisPage())
+ {
+ eType = StartWithinPage;
+ }
+ else if (pUseWhen->IsStartOnNextPage())
+ {
+ eType = StartOnNextPage;
+ }
+ else if (pUseWhen->IsStartOnNextOddPage())
+ {
+ eType = StartOnOddPage;
+ }
+ else if (pUseWhen->IsStartOnNextEvenPage())
+ {
+ eType = StartOnEvenPage;
+ }
+ }
+ else
+ {
+ eType = StartOnNextPage;
+ }
+ return eType;
+}
+
+/**
+* @descr: Get use page
+*
+*/
+sal_uInt16 LwpLayout::GetUsePage()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ return pUseWhen->GetUsePage();
+ else
+ return 0;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->GetUsePage();
+ }
+ }
+ return 0;
+}
+
+/**
+* @descr: Get usewhen pointer
+*
+*/
+LwpUseWhen* LwpLayout::VirtualGetUseWhen()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ return &m_aUseWhen;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->VirtualGetUseWhen();
+ }
+ }
+ return LwpVirtualLayout::VirtualGetUseWhen();
+}
+
+/**
+* @descr: Whether it is use on all pages
+*
+*/
+bool LwpLayout::IsUseOnAllPages()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ return pUseWhen->IsUseOnAllPages();
+ else
+ return false;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->IsUseOnAllPages();
+ }
+ }
+ return LwpVirtualLayout::IsUseOnAllPages();
+}
+
+/**
+* @descr: Whether it is use on all even pages
+*
+*/
+bool LwpLayout::IsUseOnAllEvenPages()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ return pUseWhen->IsUseOnAllEvenPages();
+ else
+ return false;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->IsUseOnAllEvenPages();
+ }
+ }
+ return LwpVirtualLayout::IsUseOnAllEvenPages();
+}
+
+/**
+* @descr: Whether it is use on all odd pages
+*
+*/
+bool LwpLayout::IsUseOnAllOddPages()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ return pUseWhen->IsUseOnAllOddPages();
+ else
+ return false;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->IsUseOnAllOddPages();
+ }
+ }
+ return LwpVirtualLayout::IsUseOnAllOddPages();
+}
+
+/**
+* @descr: Whether it is use on current page
+*
+*/
+bool LwpLayout::IsUseOnPage()
+{
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (pUseWhen)
+ return pUseWhen->IsUseOnPage();
+ else
+ return false;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ return pLay->IsUseOnPage();
+ }
+ }
+ return LwpVirtualLayout::IsUseOnPage();
+}
+
+/**
+ * @descr: Get the LwpShadow object according to m_LayShadow id.
+*/
+LwpShadow* LwpLayout::GetShadow()
+{
+ if (m_bGettingShadow)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingShadow = true;
+ LwpShadow* pRet = nullptr;
+ if (m_nOverrideFlag & OVER_SHADOW)
+ {
+ LwpLayoutShadow* pLayoutShadow = dynamic_cast<LwpLayoutShadow*>(m_LayShadow.obj().get());
+ pRet = pLayoutShadow ? &pLayoutShadow->GetShadow() : nullptr;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpLayout* pLay = dynamic_cast<LwpLayout*>(xBase.get()))
+ {
+ pRet = pLay->GetShadow();
+ }
+ }
+ m_bGettingShadow = false;
+ return pRet;
+}
+
+/**
+ * @descr: create xfshadow
+*/
+XFShadow* LwpLayout::GetXFShadow()
+{
+ LwpShadow* pShadow = GetShadow();
+ if (!pShadow)
+ return nullptr;
+ LwpColor color = pShadow->GetColor();
+ double offsetX = pShadow->GetOffsetX();
+ double offsetY = pShadow->GetOffsetY();
+
+ if (!offsetX || !offsetY || !color.IsValidColor())
+ return nullptr;
+ XFShadow* pXFShadow = new XFShadow();
+ enumXFShadowPos eXFShadowPos = enumXFShadowLeftTop;
+ double fOffset = 0;
+
+ bool left = false;
+ bool top = false;
+ if (offsetX < 0)
+ left = true;
+ if (offsetY < 0)
+ top = true;
+ if (left)
+ {
+ fOffset = -offsetX;
+ if (top)
+ eXFShadowPos = enumXFShadowLeftTop;
+ else
+ eXFShadowPos = enumXFShadowLeftBottom;
+ }
+ else
+ {
+ fOffset = offsetX;
+ if (top)
+ eXFShadowPos = enumXFShadowRightTop;
+ else
+ eXFShadowPos = enumXFShadowRightBottom;
+ }
+
+ pXFShadow->SetPosition(eXFShadowPos);
+ pXFShadow->SetOffset(fOffset);
+ pXFShadow->SetColor(XFColor(color.To24Color()));
+
+ return pXFShadow;
+}
+
+/**
+ * @descr get the layout that containers the current frame layout
+ *
+ */
+rtl::Reference<LwpVirtualLayout> LwpLayout::GetContainerLayout()
+{
+ if (IsRelativeAnchored())
+ {
+ //get position
+ LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition().obj().get());
+ if (pPara)
+ {
+ LwpStory* pStory = pPara->GetStory();
+ return pStory ? pStory->GetTabLayout() : nullptr;
+ }
+ }
+ return GetParentLayout();
+}
+
+LwpPlacableLayout::LwpPlacableLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpLayout(objHdr, pStrm)
+ , m_bGettingWrapType(false)
+ , m_bGettingLayoutRelativity(false)
+ , m_nWrapType(0)
+ , m_nBuoyancy(0)
+ , m_nBaseLineOffset(0)
+{
+}
+
+LwpPlacableLayout::~LwpPlacableLayout() {}
+
+void LwpPlacableLayout::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+ LwpLayout::Read();
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ assert(false);
+ }
+ else
+ {
+ sal_uInt16 simple = pStrm->QuickReaduInt16();
+ if (!simple)
+ {
+ m_nWrapType = pStrm->QuickReaduInt8();
+ m_nBuoyancy = pStrm->QuickReaduInt8();
+ m_nBaseLineOffset = pStrm->QuickReadInt32();
+ m_Script.Read(pStrm);
+ }
+ else
+ {
+ m_nWrapType = LAY_WRAP_AROUND;
+ m_nBuoyancy = LAY_BUOYNEUTRAL;
+ m_nBaseLineOffset = 0;
+ }
+ m_LayRelativity.ReadIndexed(pStrm);
+ if (pStrm->CheckExtra())
+ {
+ sal_uInt16 count = pStrm->QuickReaduInt16();
+ if (count)
+ {
+ // temporarily added by to avoid assertion
+ while (count)
+ {
+ LwpPoint aPoint;
+ aPoint.Read(pStrm);
+ count--;
+ }
+ }
+ pStrm->SkipExtra();
+ }
+ }
+}
+/**
+ * @descr: get wrap type
+*/
+sal_uInt8 LwpPlacableLayout::GetWrapType()
+{
+ if (m_bGettingWrapType)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingWrapType = true;
+ sal_uInt8 nWrapType = LAY_WRAP_AROUND;
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ nWrapType = m_nWrapType;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(xBase.get()))
+ {
+ nWrapType = pLay->GetWrapType();
+ }
+ }
+ m_bGettingWrapType = false;
+ return nWrapType;
+}
+/**
+ * @descr: get LayoutRelativity
+*/
+LwpLayoutRelativity* LwpPlacableLayout::GetRelativityPiece()
+{
+ if (m_bGettingLayoutRelativity)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingLayoutRelativity = true;
+ LwpLayoutRelativity* pRet = nullptr;
+ if (!m_LayRelativity.IsNull())
+ {
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ pRet = dynamic_cast<LwpLayoutRelativity*>(m_LayRelativity.obj().get());
+ }
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(xBase.get()))
+ {
+ pRet = pLay->GetRelativityPiece();
+ }
+ }
+ m_bGettingLayoutRelativity = false;
+ return pRet;
+}
+/**
+* @descr: Get relative type
+*
+*/
+sal_uInt8 LwpPlacableLayout::GetRelativeType()
+{
+ LwpLayoutRelativity* pLayRel = GetRelativityPiece();
+ if (pLayRel)
+ {
+ return pLayRel->GetRelGuts().GetRelativeType();
+ }
+ return LwpVirtualLayout::GetRelativeType();
+}
+/**
+* @descr: Get offset from the baseline
+*
+*/
+sal_Int32 LwpPlacableLayout::GetBaseLineOffset()
+{
+ /* The baseline is only valid if this is flow-with-text */
+ if (GetRelativeType() != LwpLayoutRelativityGuts::LAY_INLINE)
+ {
+ return 0;
+ }
+
+ // First, ask our content if it has a baseline, ignore now
+ /*
+ if (Content && Content->GetBaseLineOffset(&Baseline))
+ return Baseline;
+ */
+
+ if (m_nOverrideFlag & OVER_PLACEMENT)
+ {
+ return m_nBaseLineOffset;
+ }
+ else
+ {
+ rtl::Reference<LwpObject> xBase(GetBasedOnStyle());
+ if (LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*>(xBase.get()))
+ {
+ return pLay->GetBaseLineOffset();
+ }
+ }
+ return 0;
+}
+/**
+* @descr: whether the parent layout is page layout
+*
+*/
+bool LwpPlacableLayout::IsAnchorPage()
+{
+ if (IsRelativeAnchored())
+ return false;
+
+ rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
+ return xLayout.is() && (xLayout->IsPage() || xLayout->IsHeader() || xLayout->IsFooter());
+}
+/**
+* @descr: whether the parent layout is frame layout
+*
+*/
+bool LwpPlacableLayout::IsAnchorFrame()
+{
+ if (IsRelativeAnchored())
+ return false;
+
+ rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
+ return xLayout.is() && (xLayout->IsFrame() || xLayout->IsGroupHead());
+}
+/**
+* @descr: whether the parent layout is cell layout
+*
+*/
+bool LwpPlacableLayout::IsAnchorCell()
+{
+ if (IsRelativeAnchored())
+ return false;
+
+ rtl::Reference<LwpVirtualLayout> xLayout = GetParentLayout();
+ return xLayout.is() && xLayout->IsCell();
+}
+
+/**
+* @descr: Set font style for setting position of frame
+*
+*/
+void LwpPlacableLayout::SetFont(rtl::Reference<XFFont> const& pFont) { m_pFont = pFont; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
new file mode 100644
index 000000000..9ac89fddc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -0,0 +1,512 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
+
+#include <memory>
+#include <sal/config.h>
+#include <config_lgpl.h>
+
+#include <rtl/ref.hxx>
+
+#include <lwpobj.hxx>
+#include <lwpobjhdr.hxx>
+#include <lwpobjstrm.hxx>
+#include <lwpobjid.hxx>
+#include "lwpdlvlist.hxx"
+
+#include "lwplayoutdef.hxx"
+#include <xfilter/xfdefs.hxx>
+#include <xfilter/xffont.hxx>
+#include <xfilter/xfpagemaster.hxx>
+#include <xfilter/xfcolumns.hxx>
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xfbgimage.hxx>
+#include "lwpusewhen.hxx"
+#include "lwplaypiece.hxx"
+
+
+#define FIRST_LAYOUTPAGENO 0x0001
+#define LAST_LAYOUTPAGENO 0xffff
+
+#define LAY_BUOYNEUTRAL 0x02
+#define LAY_BUOYLAYER 0x80
+
+class LwpPara;
+class LwpVirtualLayout : public LwpDLNFPVList
+{
+public:
+ LwpVirtualLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual sal_uInt16 GetNumCols(){return 1;}
+ virtual double GetColGap(sal_uInt16 nIndex);
+ virtual bool IsAutoGrow(){ return false;}
+ virtual bool IsAutoGrowUp(){ return false;}
+ virtual bool IsAutoGrowLeft(){ return false;}
+ virtual bool IsAutoGrowRight(){ return false;}
+ bool IsFitGraphic();
+ bool IsAutoGrowWidth();
+ bool IsInlineToMargin() const;
+ virtual sal_uInt8 GetContentOrientation(){ return TEXT_ORIENT_LRTB;}
+ bool GetHonorProtection()
+ {
+ if (m_bGettingHonorProtection)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingHonorProtection = true;
+ bool bRet = HonorProtection();
+ m_bGettingHonorProtection = false;
+ return bRet;
+ }
+ bool GetMarginsSameAsParent()
+ {
+ if (m_bGettingMarginsSameAsParent)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingMarginsSameAsParent = true;
+ bool bRet = MarginsSameAsParent();
+ m_bGettingMarginsSameAsParent = false;
+ return bRet;
+ }
+ bool GetIsProtected()
+ {
+ if (m_bGettingIsProtected)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingIsProtected = true;
+ bool bRet = IsProtected();
+ m_bGettingIsProtected = false;
+ return bRet;
+ }
+ bool GetIsAutoGrowDown()
+ {
+ if (m_bGettingIsAutoGrowDown)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingIsAutoGrowDown = true;
+ bool bRet = IsAutoGrowDown();
+ m_bGettingIsAutoGrowDown = false;
+ return bRet;
+ }
+ bool GetHasProtection()
+ {
+ if (m_bGettingHasProtection)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingHasProtection = true;
+ bool bRet = HasProtection();
+ m_bGettingHasProtection = false;
+ return bRet;
+ }
+ double GetMarginsValue(sal_uInt8 nWhichSide)
+ {
+ if (m_bGettingMarginsValue)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingMarginsValue = true;
+ auto fRet = MarginsValue(nWhichSide);
+ m_bGettingMarginsValue = false;
+ return fRet;
+ }
+ double GetExtMarginsValue(sal_uInt8 nWhichSide)
+ {
+ if (m_bGettingExtMarginsValue)
+ throw std::runtime_error("recursion in layout");
+ m_bGettingExtMarginsValue = true;
+ auto fRet = ExtMarginsValue(nWhichSide);
+ m_bGettingExtMarginsValue = false;
+ return fRet;
+ }
+ const OUString& GetStyleName() const { return m_StyleName;}
+ bool IsComplex() const;
+ virtual bool IsAnchorPage(){ return false;}
+ virtual bool IsAnchorFrame(){ return false;}
+ virtual bool IsAnchorCell(){ return false;}
+ bool IsPage();
+ bool IsHeader();
+ bool IsFooter();
+ bool IsFrame();
+ bool IsCell();
+ bool IsSuperTable();
+ bool IsGroupHead();
+ virtual sal_uInt8 GetRelativeType();
+ bool IsRelativeAnchored();
+ LwpUseWhen* GetUseWhen();
+ virtual LwpUseWhen* VirtualGetUseWhen(){ return nullptr;}
+ virtual bool IsUseOnAllPages(){ return false;}
+ virtual bool IsUseOnAllEvenPages(){ return false;}
+ virtual bool IsUseOnAllOddPages(){ return false;}
+ virtual bool IsUseOnPage(){ return false;}
+ virtual sal_Int32 GetPageNumber(sal_uInt16 /*nLayoutNumber*/) { return -1;}
+ bool IsMinimumHeight() const;
+ virtual bool IsForWaterMark(){ return false;}
+ virtual LwpPara* GetLastParaOfPreviousStory() { return nullptr; }
+ rtl::Reference<LwpVirtualLayout> GetParentLayout();
+ virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() { return rtl::Reference<LwpVirtualLayout>(); }
+ void RegisterChildStyle();
+ bool NoContentReference();
+ bool IsStyleLayout();
+ enumXFAlignType GetVerticalAlignmentType() const
+ {
+ if (m_nAttributes & STYLE_CENTEREDVERTICALLY)
+ {
+ return enumXFAlignMiddle;
+ }
+ else if (m_nAttributes & STYLE_BOTTOMALIGNED)
+ {
+ return enumXFAlignBottom;
+ }
+ return enumXFAlignTop;
+ };
+ void SetStyleName(const OUString & str){ m_StyleName = str;}
+ virtual double GetWidth(){return -1;}
+
+ //Check whether there are contents in the layout
+ virtual bool HasContent(){return false;}
+ //End by
+protected:
+ void Read() override;
+ bool HasProtection();
+ virtual bool HonorProtection();
+ virtual bool IsProtected();
+ virtual bool IsAutoGrowDown(){ return false;}
+ virtual double MarginsValue(sal_uInt8 /*nWhichSide*/){return 0;}
+ virtual double ExtMarginsValue(sal_uInt8 /*nWhichSide*/){return 0;}
+ virtual bool MarginsSameAsParent();
+protected:
+ bool m_bGettingHonorProtection;
+ bool m_bGettingMarginsSameAsParent;
+ bool m_bGettingHasProtection;
+ bool m_bGettingIsProtected;
+ bool m_bGettingIsAutoGrowDown;
+ bool m_bGettingMarginsValue;
+ bool m_bGettingExtMarginsValue;
+ bool m_bGettingUsePrinterSettings;
+ bool m_bGettingScaleCenter;
+ bool m_bGettingBorderStuff;
+ bool m_bGettingUseWhen;
+ bool m_bGettingStyleLayout;
+ bool m_bGettingAutoGrowUp;
+ sal_uInt32 m_nAttributes;
+ sal_uInt32 m_nAttributes2;
+ sal_uInt32 m_nAttributes3;
+ sal_uInt32 m_nOverrideFlag;
+ sal_uInt16 m_nDirection;
+ sal_uInt16 m_nEditorID;
+ LwpObjectID m_NextEnumerated;
+ LwpObjectID m_PreviousEnumerated;
+ OUString m_StyleName;
+ enum LWP_LAYOUT_TYPE
+ {
+ LWP_VIRTUAL_LAYOUT,
+ LWP_HEAD_LAYOUT,
+ LWP_PAGE_LAYOUT,
+ LWP_HEADER_LAYOUT,
+ LWP_FOOTER_LAYOUT,
+ LWP_FRAME_LAYOUT,
+ LWP_SUPERTABLE_LAYOUT,
+ LWP_TABLE_LAYOUT,
+ LWP_ROW_LAYOUT,
+ LWP_COLUMN_LAYOUT,
+ LWP_CELL_LAYOUT,
+ LWP_CONNECTED_CELL_LAYOUT,
+ LWP_HIDDEN_CELL_LAYOUT,
+ LWP_TABLE_HEADING_LAYOUT,
+ LWP_ROW_HEADING_LAYOUT,
+ LWP_DROPCAP_LAYOUT,
+ LWP_GROUP_LAYOUT,
+ LWP_TOC_SUPERTABLE_LAYOUT,
+ LWP_FOOTNOTE_LAYOUT,
+ LWP_FOOTNOTE_ROW_LAYOUT,
+ LWP_FOOTNOTE_CELL_LAYOUT,
+ LWP_ENDNOTE_LAYOUT,
+ LWP_ENDNOTE_SUPERTABLE_LAYOUT,
+ LWP_FOOTNOTE_SUPERTABLE_LAYOUT,
+ LWP_NOTE_LAYOUT,
+ LWP_NOTEHEADER_LAYOUT,
+ LWP_NOTETEXT_LAYOUT,
+ LWP_VIEWPORT_LAYOUT
+ };
+ enum LayoutDirection
+ {
+ LAY_USEDIRECTION = 0x01,
+ LAY_AUTOGROW = 0x02,
+ LAY_AUTOSIZE = 0x04,
+ LAY_TOCONTAINER = 0x08,
+ LAY_DIRALLBITS = 0x0f
+ };
+ enum {SHIFT_UP = 0, SHIFT_DOWN = 4, SHIFT_LEFT = 8, SHIFT_RIGHT =12};
+public:
+ virtual LWP_LAYOUT_TYPE GetLayoutType () { return LWP_VIRTUAL_LAYOUT;}
+ LwpVirtualLayout* FindChildByType(LWP_LAYOUT_TYPE eType);
+};
+
+class LwpAssociatedLayouts final
+{
+public:
+ LwpAssociatedLayouts(){}
+ void Read(LwpObjectStream* pStrm);
+ LwpObjectID& GetOnlyLayout() { return m_OnlyLayout;}
+ rtl::Reference<LwpVirtualLayout> GetLayout(LwpVirtualLayout const * pStartLayout);
+private:
+ LwpObjectID m_OnlyLayout; //LwpVirtualLayout
+ LwpDLVListHeadTail m_Layouts;
+};
+
+class LwpHeadLayout : public LwpVirtualLayout
+{
+public:
+ LwpHeadLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ void RegisterStyle() override;
+ rtl::Reference<LwpVirtualLayout> FindEnSuperTableLayout();
+protected:
+ void Read() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_HEAD_LAYOUT;}
+};
+
+class LwpLayoutStyle final
+{
+public:
+ LwpLayoutStyle();
+ ~LwpLayoutStyle();
+ void Read(LwpObjectStream* pStrm);
+private:
+ sal_uInt32 m_nStyleDefinition;
+ std::unique_ptr<LwpAtomHolder> m_pDescription;
+ sal_uInt16 m_nKey;
+};
+
+class LwpLayoutMisc final
+{
+public:
+ LwpLayoutMisc();
+ ~LwpLayoutMisc();
+ void Read(LwpObjectStream* pStrm);
+private:
+ sal_Int32 m_nGridDistance;
+ sal_uInt16 m_nGridType;
+ LwpAtomHolder m_aContentStyle;
+};
+
+class LwpMiddleLayout : public LwpVirtualLayout
+{
+public:
+ LwpMiddleLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
+ virtual ~LwpMiddleLayout() override;
+ double GetGeometryHeight();
+ double GetGeometryWidth();
+ LwpBorderStuff* GetBorderStuff();
+ LwpBackgroundStuff* GetBackgroundStuff();
+ LwpLayoutGeometry* GetGeometry();
+ enumXFTextDir GetTextDirection();
+ std::unique_ptr<XFBorders> GetXFBorders();
+ LwpColor* GetBackColor();
+ virtual bool IsAutoGrow() override;
+ virtual bool IsAutoGrowUp() override;
+ virtual bool IsAutoGrowLeft() override;
+ virtual bool IsAutoGrowRight() override;
+ virtual sal_uInt8 GetContentOrientation() override;
+ virtual bool HonorProtection() override;
+ virtual bool IsProtected() override;
+ rtl::Reference<LwpVirtualLayout> GetWaterMarkLayout();
+ std::unique_ptr<XFBGImage> GetXFBGImage();
+ bool GetUsePrinterSettings();
+
+ LwpLayoutScale* GetLayoutScale(){return dynamic_cast<LwpLayoutScale*>(m_LayScale.obj().get());}
+ sal_uInt16 GetScaleMode();
+ sal_uInt16 GetScaleTile();
+ sal_uInt16 GetScaleCenter();
+
+ bool CanSizeRight();
+ virtual double GetWidth() override;
+ sal_Int32 GetMinimumWidth();
+ bool IsSizeRightToContent();
+ bool IsSizeRightToContainer();
+ sal_Int32 DetermineWidth();
+ virtual double GetHeight();
+ LwpPoint GetOrigin();
+
+ bool IsPatternFill();
+ std::unique_ptr<XFBGImage> GetFillPattern();
+
+ //Check whether there are contents in the layout
+ virtual bool HasContent() override;
+
+protected:
+ void Read() override;
+ virtual bool MarginsSameAsParent() override;
+ virtual double MarginsValue(sal_uInt8 nWhichSide) override;
+ virtual double ExtMarginsValue(sal_uInt8 nWhichSide) override;
+ virtual bool IsAutoGrowDown() override;
+private:
+ LwpObjectID m_BasedOnStyle;
+protected:
+ enum
+ {
+ DISK_GOT_STYLE_STUFF = 0x01,
+ DISK_GOT_MISC_STUFF = 0x02
+ };
+
+ LwpObjectID m_Content;
+ rtl::Reference<LwpObject> GetBasedOnStyle() const;
+ LwpObjectID m_TabPiece;
+ LwpLayoutStyle m_aStyleStuff;
+ LwpLayoutMisc m_aMiscStuff;
+ LwpObjectID m_LayGeometry;
+ LwpObjectID m_LayScale;
+ LwpObjectID m_LayMargins;
+ LwpObjectID m_LayBorderStuff;
+ LwpObjectID m_LayBackgroundStuff;
+ LwpObjectID m_LayExtBorderStuff;
+ bool m_bGettingGeometry;
+ bool m_bGettingBackgroundStuff;
+public:
+ LwpObjectID& GetContent() { return m_Content; }
+ LwpTabOverride* GetTabOverride();
+};
+
+class LwpLayout : public LwpMiddleLayout
+{
+private:
+ bool m_bGettingShadow;
+ bool m_bGettingNumCols;
+public:
+ LwpLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
+ virtual ~LwpLayout() override;
+ XFColumns* GetXFColumns();
+ XFColumnSep* GetColumnSep();
+ LwpShadow* GetShadow();
+ XFShadow* GetXFShadow();
+protected:
+ void Read() override;
+protected:
+ LwpUseWhen m_aUseWhen;
+ LwpObjectID m_Position;
+ LwpObjectID m_LayColumns;
+ LwpObjectID m_LayGutterStuff;
+ LwpObjectID m_LayJoinStuff;
+ LwpObjectID m_LayShadow;
+ LwpObjectID m_LayExtJoinStuff;
+
+public:
+ LwpUseWhen* VirtualGetUseWhen() override;
+ virtual sal_uInt16 GetNumCols() override;
+ virtual double GetColGap(sal_uInt16 nIndex) override;
+ sal_uInt16 GetUsePage();
+public:
+ enum UseWhenType
+ {
+ StartWithinColume,
+ StartWithinPage,
+ StartOnNextPage,
+ StartOnOddPage,
+ StartOnEvenPage
+ };
+public:
+ UseWhenType GetUseWhenType();
+ virtual bool IsUseOnAllPages() override;
+ virtual bool IsUseOnAllEvenPages() override;
+ virtual bool IsUseOnAllOddPages() override;
+ virtual bool IsUseOnPage() override;
+ LwpObjectID& GetPosition(){ return m_Position;}
+ virtual rtl::Reference<LwpVirtualLayout> GetContainerLayout() override;
+};
+
+class LwpPlacableLayout : public LwpLayout
+{
+public:
+ LwpPlacableLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm );
+ virtual ~LwpPlacableLayout() override;
+ sal_uInt8 GetWrapType();
+ LwpLayoutRelativity* GetRelativityPiece();
+ virtual sal_uInt8 GetRelativeType() override;
+ sal_Int32 GetBaseLineOffset();
+ virtual bool IsAnchorPage() override;
+ virtual bool IsAnchorFrame() override;
+ virtual bool IsAnchorCell() override;
+ virtual void XFConvertFrame(XFContentContainer* /*pCont*/, sal_Int32 /*nStart*/ = 0, sal_Int32 /*nEnd*/ = 0, bool /*bAll*/ = false) {}
+ /**
+ * @descr: Get font style for setting position of frame
+ *
+ */
+ const rtl::Reference<XFFont>& GetFont() const { return m_pFont; }
+ void SetFont(rtl::Reference<XFFont> const & pFont);
+ enum WrapType
+ {
+ LAY_WRAP_AROUND = 1,
+ LAY_NO_WRAP_BESIDE,
+ LAY_NO_WRAP_AROUND,
+ LAY_WRAP_LEFT,
+ LAY_WRAP_RIGHT,
+ LAY_WRAP_BOTH,
+ LAY_WRAP_IRREG_BOTH,
+ LAY_WRAP_IRREG_LEFT,
+ LAY_WRAP_IRREG_RIGHT,
+ LAY_WRAP_IRREG_BIGGEST
+ };
+protected:
+ void Read() override;
+protected:
+ bool m_bGettingWrapType;
+ bool m_bGettingLayoutRelativity;
+ sal_uInt8 m_nWrapType;
+ sal_uInt8 m_nBuoyancy;
+ sal_Int32 m_nBaseLineOffset;
+ LwpAtomHolder m_Script;
+ LwpObjectID m_LayRelativity;
+ rtl::Reference<XFFont> m_pFont;//for frame position
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplayoutdef.hxx b/lotuswordpro/source/filter/lwplayoutdef.hxx
new file mode 100644
index 000000000..2dcd569d3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplayoutdef.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUTDEF_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUTDEF_HXX
+
+#define STYLE_AUTOLINK 0x01UL /* content span's to next container */
+#define STYLE_SELECTABLE 0x02UL /* selectable container */
+#define STYLE_SHARED 0x04UL /* is this a global layout style */
+#define STYLE_PAINTMARGINSINCOLOR 0x8UL /* does this layout paint margins */
+#define STYLE_PROTECTED 0x10UL /* is this layout protected */
+#define STYLE_LOCAL 0x20UL /* is local layout */
+#define STYLE_NOERRORCHECK 0x40UL /* is error checking enabled */
+#define STYLE_HEADING 0x80UL /* heading */
+#define STYLE_MUTE 0x100UL /* gray modify menu */
+#define STYLE_SCRIPTING 0x200UL /* scripting enabled */
+#define STYLE_CONTENTREPLACEABLE 0x400UL /* contents can be replaced */
+#define STYLE_PRINTABLE 0x800UL /* contents can be printed */
+#define STYLE_COLUMNBALANCE 0x1000UL
+#define STYLE_LANDSCAPE 0x2000UL
+#define STYLE_COLLAPSIBLE 0x4000UL
+#define STYLE_COLLAPSED 0x8000UL
+#define STYLE_NOTCOPYABLE 0x10000UL
+#define STYLE_PARENTSELECTABLE 0x20000UL
+#define STYLE_CONNECTED 0x40000UL
+#define STYLE_OVERRIDE 0x80000UL /* is layout an override */
+#define STYLE_SELECTED 0x100000UL
+#define STYLE_CENTEREDHORIZONTALLY 0x200000UL
+#define STYLE_CREATIONREVISION 0x400000UL
+#define STYLE_DELETIONREVISION 0x800000UL
+#define STYLE_PAGEBREAK 0x1000000UL
+#define STYLE_MODIFIED 0x2000000UL
+#define STYLE_INDIRECT 0x4000000UL /* double click required */
+#define STYLE_COMPLEX 0x8000000UL
+#define STYLE_CENTEREDVERTICALLY 0x10000000UL
+#define STYLE_BOTTOMALIGNED 0x20000000UL
+#define STYLE_NOTGROUPABLE 0x40000000UL
+#define STYLE_ABSOLUTE 0x80000000UL
+// Don't assign these flags from one layout to another
+#define STYLE_DONTASSIGN (STYLE_SHARED)
+
+#define STYLE2_VSCROLLABLE 0x1UL
+#define STYLE2_HSCROLLABLE 0x2UL
+#define STYLE2_SCROLLABLE 0x3UL
+#define STYLE2_MIRROR 0x4UL
+#define STYLE2_PRIVATE 0x8UL
+#define STYLE2_PUBLIC 0x00UL
+#define STYLE2_PRIVATE2 0x10UL
+#define STYLE2_PROTECTED 0x20UL
+#define STYLE2_ACCESSRIGHTS 0x30UL
+#define STYLE2_HONORPROTECTION 0x40UL
+#define STYLE2_CHILDSPANNABLE 0x80UL
+#define STYLE2_DEACTIVATED 0x200UL
+#define STYLE2_NOCONTENTREFERENCE 0x400UL
+#define STYLE2_ADOPTED 0x800UL
+#define STYLE2_NOTUSERDELETEABLE 0x1000UL
+#define STYLE2_EXPANDRIGHT 0x2000UL
+#define STYLE2_EXPANDLEFT 0x4000UL
+#define STYLE2_EXPANDUP 0x8000UL
+#define STYLE2_EXPANDDOWN 0x10000UL
+#define STYLE2_NOTDIRTYABLE 0x20000UL
+#define STYLE2_NONHIERARCHICAL 0x40000UL // Now not used
+#define STYLE2_NOTSIZABLE 0x80000UL
+#define STYLE2_MARGINSSAMEASPARENT 0x100000UL
+#define STYLE2_DISPLAYANCHORPOINTS 0x200000UL
+#define STYLE2_DISPLAYTETHERPOINTS 0x400000UL
+#define STYLE2_SNAPTO 0x800000UL
+#define STYLE2_NOINTERSECTSIBLINGS 0x1000000UL
+#define STYLE2_LOCALCOLUMNINFO 0x2000000UL
+#define STYLE2_INOVERRIDE 0x4000000UL
+#define STYLE2_FROMSTYLE 0x8000000UL
+#define STYLE2_CONTENTFROMSTYLE 0x10000000UL
+#define STYLE2_TEMPORARY 0x20000000UL
+#define STYLE2_JUSTIFIABLE 0x40000000UL
+// Don't assign these flags from one layout to another
+#define STYLE2_DONTASSIGN (STYLE2_DEACTIVATED | \
+ STYLE2_NOCONTENTREFERENCE)
+
+#define STYLE3_ORIGINVALID 0x0001UL
+#define STYLE3_WIDTHVALID 0x0002UL
+#define STYLE3_MINHEIGHTVALID 0x0004UL
+#define STYLE3_STYLELAYOUT 0x0008UL
+#define STYLE3_LINELOCATION1 0x0010UL
+#define STYLE3_LINELOCATION2 0x0020UL
+#define STYLE3_OPENED 0x0040UL
+#define STYLE3_ORIENTSWITHPARENT 0x0080UL
+#define STYLE3_FROZEN 0x0100UL
+#define STYLE3_VALUE_VALID 0x0200UL // moved from CLayout
+#define STYLE3_USEPRINTERSETTINGS 0x0400UL // moved from CLayout
+#define STYLE3_ISAMIPROTABLE 0x0800UL // wrap tables around frames
+ // like Ami Pro
+#define STYLE3_INLINETOMARGIN 0x1000UL // for Croom
+
+#define OVER_PLACEMENT 0x01UL
+#define OVER_SIZE 0x02UL
+#define OVER_MARGINS 0x04UL
+#define OVER_BORDERS 0x08UL
+#define OVER_BACKGROUND 0x10UL
+#define OVER_SHADOW 0x20UL
+#define OVER_JOIN 0x40UL
+#define OVER_COLUMNS 0x80UL
+#define OVER_ROTATION 0x100UL
+#define OVER_SCALING 0x200UL
+#define OVER_NUMERICS 0x400UL
+#define OVER_TABS 0x800UL
+#define OVER_SCRIPT 0x1000UL
+#define OVER_LEADERS 0x2000UL
+#define OVER_ORIENTATION 0x4000UL
+#define OVER_MISC 0x8000UL
+#define OVER_INTERNAL 0x10000UL // User can't access these props.
+
+// the first 4 orientations are left-handed
+// and are simply rotated forms of each other
+#define TEXT_ORIENT_LRTB 0 // left to right, top to bottom
+#define TEXT_ORIENT_TBRL 1 // top to bottom, right to left
+#define TEXT_ORIENT_RLBT 2 // right to left, bottom to top
+#define TEXT_ORIENT_BTLR 3 // bottom to top, left to right
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplaypiece.cxx b/lotuswordpro/source/filter/lwplaypiece.cxx
new file mode 100644
index 000000000..34a1e381e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplaypiece.cxx
@@ -0,0 +1,440 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwplaypiece.hxx"
+#include "lwpstyledef.hxx"
+#include <lwpfilehdr.hxx>
+
+
+LwpRotor::LwpRotor()
+ : m_nRotation(0)
+{}
+
+void LwpRotor:: Read(LwpObjectStream *pStrm)
+{
+ m_nRotation = pStrm->QuickReadInt16();
+}
+
+LwpLayoutGeometry::LwpLayoutGeometry(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+ , m_nWidth(0)
+ , m_nHeight(0)
+ , m_ContentOrientation(0)
+{}
+
+LwpLayoutGeometry::~LwpLayoutGeometry()
+{}
+
+void LwpLayoutGeometry::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if(LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_nWidth = m_pObjStrm->QuickReadInt32();
+ m_nHeight = m_pObjStrm->QuickReadInt32();
+ m_Origin.Read(m_pObjStrm.get());
+ m_AbsoluteOrigin.Read(m_pObjStrm.get());
+ m_ContainerRotor.Read(m_pObjStrm.get());
+ m_ContentOrientation = m_pObjStrm->QuickReaduInt8();
+ m_pObjStrm->SkipExtra();
+ }
+}
+void LwpLayoutGeometry::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutScale::LwpLayoutScale(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+ , m_nScaleMode(0)
+ , m_nScalePercentage(0)
+ , m_nScaleWidth(0)
+ , m_nScaleHeight(0)
+ , m_nContentRotation(0)
+ , m_nPlacement(0)
+{}
+
+LwpLayoutScale::~LwpLayoutScale()
+{}
+
+void LwpLayoutScale::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if(LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_nScaleMode = m_pObjStrm->QuickReaduInt16();
+ m_nScalePercentage = m_pObjStrm->QuickReaduInt32();
+ m_nScaleWidth = m_pObjStrm->QuickReadInt32();
+ m_nScaleHeight = m_pObjStrm->QuickReadInt32();
+ m_nContentRotation = m_pObjStrm->QuickReaduInt16();
+ m_Offset.Read(m_pObjStrm.get());
+
+ m_nPlacement = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutScale::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutMargins::LwpLayoutMargins(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutMargins::~LwpLayoutMargins()
+{}
+
+void LwpLayoutMargins::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_Margins.Read(m_pObjStrm.get());
+ m_ExtMargins.Read(m_pObjStrm.get());
+ m_ExtraMargins.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutMargins::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutBorder::LwpLayoutBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutBorder::~LwpLayoutBorder()
+{}
+
+void LwpLayoutBorder::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_BorderStuff.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutBorder::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutBackground::LwpLayoutBackground(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutBackground::~LwpLayoutBackground()
+{}
+
+void LwpLayoutBackground::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_BackgroundStuff.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutBackground::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpExternalBorder::LwpExternalBorder()
+{}
+
+LwpExternalBorder::~LwpExternalBorder()
+{}
+
+void LwpExternalBorder:: Read(LwpObjectStream *pStrm)
+{
+ if( LwpFileHeader::m_nFileRevision < 0x000F )
+ return;
+
+ //enum {BORDER,JOIN};
+ m_LeftName.Read(pStrm);
+ m_TopName.Read(pStrm);
+ m_RightName.Read(pStrm);
+ m_BottomName.Read(pStrm);
+ // TODO: Do not know what it is for
+ /*cLeftName = CStyleMgr::GetUniqueMetaFileName(cLeftName,BORDER);
+ cRightName = CStyleMgr::GetUniqueMetaFileName(cRightName,BORDER);
+ cTopName = CStyleMgr::GetUniqueMetaFileName(cTopName,BORDER);
+ cBottomName = CStyleMgr::GetUniqueMetaFileName(cBottomName,BORDER);*/
+ pStrm->SkipExtra();
+}
+
+LwpLayoutExternalBorder::LwpLayoutExternalBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutExternalBorder::~LwpLayoutExternalBorder()
+{}
+
+void LwpLayoutExternalBorder::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_ExtranalBorder.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutExternalBorder::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpColumnInfo::LwpColumnInfo()
+ : m_nWidth(0)
+ , m_nGap(0)
+{}
+
+void LwpColumnInfo:: Read(LwpObjectStream *pStrm)
+{
+ m_nWidth = pStrm->QuickReadInt32();
+ m_nGap = pStrm->QuickReadInt32();
+}
+
+LwpLayoutColumns::LwpLayoutColumns(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+ , m_nNumCols(0)
+{}
+
+LwpLayoutColumns::~LwpLayoutColumns()
+{
+}
+
+void LwpLayoutColumns::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_nNumCols = m_pObjStrm->QuickReaduInt16();
+ m_pColumns.reset( new LwpColumnInfo[m_nNumCols] );
+ for(int i=0; i<m_nNumCols; i++)
+ {
+ m_pColumns[i].Read(m_pObjStrm.get());
+ }
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+double LwpLayoutColumns::GetColGap(sal_uInt16 nIndex)
+{
+ if(nIndex >= m_nNumCols)
+ {
+ return 0;
+ }
+ return m_pColumns[nIndex].GetGap();
+}
+
+void LwpLayoutColumns::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutGutters::LwpLayoutGutters(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutGutters::~LwpLayoutGutters()
+{}
+
+void LwpLayoutGutters::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_BorderBuffer.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutGutters::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpJoinStuff::LwpJoinStuff()
+ : m_nPercentage(0)
+ , m_nCorners(0)
+ , m_nWidth(0)
+ , m_nHeight(0)
+ , m_nID(0)
+ , m_nScaling(0)
+{}
+
+void LwpJoinStuff:: Read(LwpObjectStream *pStrm)
+{
+ m_nWidth = pStrm->QuickReadInt32();
+ m_nHeight = pStrm->QuickReadInt32();
+ m_nPercentage = pStrm->QuickReaduInt16();
+ m_nID = pStrm->QuickReaduInt16();
+ m_nCorners = pStrm->QuickReaduInt16();
+ m_nScaling = pStrm->QuickReaduInt16();
+ m_Color.Read(pStrm);
+ pStrm->SkipExtra();
+
+ // Bug fix: if reading in from something older than Release 9
+ // then check for the external ID and change it to solid.
+ if (LwpFileHeader::m_nFileRevision < 0x0010)
+ {
+ if (m_nID & EXTERNAL_ID)
+ m_nID = MITRE;
+ }
+}
+
+LwpLayoutJoins::LwpLayoutJoins(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutJoins::~LwpLayoutJoins()
+{}
+
+void LwpLayoutJoins::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_JoinStuff.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutJoins::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutShadow::LwpLayoutShadow(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{}
+
+LwpLayoutShadow::~LwpLayoutShadow()
+{}
+
+void LwpLayoutShadow::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if( LwpFileHeader::m_nFileRevision >= 0x000B )
+ {
+ m_Shadow.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutShadow::Parse(IXFStream* /*pOutputStream*/)
+{}
+
+LwpLayoutRelativityGuts::LwpLayoutRelativityGuts()
+ : m_nRelType(LAY_PARENT_RELATIVE),
+ m_nRelFromWhere(LAY_UPPERLEFT),
+ m_nTether(LAY_UPPERLEFT),
+ m_nTetherWhere(LAY_BORDER),
+ m_nFlags(0)
+{
+ m_RelDistance.SetX(0);
+ m_RelDistance.SetY(0);
+}
+/**************************************************************************
+ * @descr: Read LayoutRelativityGuts' information.
+**************************************************************************/
+void LwpLayoutRelativityGuts::Read(LwpObjectStream *pStrm)
+{
+ m_nRelType = pStrm->QuickReaduInt8();
+ m_nRelFromWhere = pStrm->QuickReaduInt8();
+ m_RelDistance.Read(pStrm);
+ m_nTether = pStrm->QuickReaduInt8();
+ m_nTetherWhere = pStrm->QuickReaduInt8();
+ if(LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_nFlags = pStrm->QuickReaduInt8();
+ }
+ else
+ {
+ m_nFlags = 0;
+ }
+}
+
+LwpLayoutRelativity::LwpLayoutRelativity(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpVirtualPiece(objHdr, pStrm)
+{
+}
+
+LwpLayoutRelativity::~LwpLayoutRelativity()
+{
+}
+
+void LwpLayoutRelativity::Read()
+{
+ LwpVirtualPiece::Read();
+ if(LwpFileHeader::m_nFileRevision >= 0x000B)
+ {
+ m_RelGuts.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpLayoutRelativity::Parse(IXFStream * /*pOutputStream*/)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplaypiece.hxx b/lotuswordpro/source/filter/lwplaypiece.hxx
new file mode 100644
index 000000000..e05910041
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplaypiece.hxx
@@ -0,0 +1,389 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYPIECE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYPIECE_HXX
+
+#include "lwppiece.hxx"
+#include <lwpbasetype.hxx>
+#include "lwpmargins.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwpshadow.hxx"
+
+class LwpRotor
+{
+public:
+ LwpRotor();
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ sal_Int16 m_nRotation; //angle
+};
+
+class LwpLayoutGeometry final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutGeometry(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ sal_Int32 GetWidth() const { return m_nWidth; }
+ sal_Int32 GetHeight() const { return m_nHeight; }
+ const LwpPoint& GetOrigin() const { return m_Origin; }
+ const LwpPoint& GetAbsoluteOrigin() const { return m_AbsoluteOrigin; }
+ sal_uInt8 GetContentOrientation() const { return m_ContentOrientation; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutGeometry() override;
+
+ sal_Int32 m_nWidth;
+ sal_Int32 m_nHeight;
+ LwpPoint m_Origin;
+ LwpPoint m_AbsoluteOrigin;
+ LwpRotor m_ContainerRotor;
+ sal_uInt8 m_ContentOrientation;
+};
+
+class LwpLayoutScale final : public LwpVirtualPiece
+{
+public:
+ enum
+ {
+ ORIGINAL_SIZE = 1,
+ FIT_IN_FRAME = 2,
+ PERCENTAGE = 4,
+ CUSTOM = 8,
+ MAINTAIN_ASPECT_RATIO = 16
+ };
+
+ enum
+ {
+ CENTERED = 1,
+ TILED = 2
+ };
+ LwpLayoutScale(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ sal_uInt16 GetScaleMode() const { return m_nScaleMode; }
+ sal_uInt32 GetScalePercentage() const { return m_nScalePercentage; }
+ sal_Int32 GetScaleWidth() const { return m_nScaleWidth; }
+ sal_Int32 GetScaleHeight() const { return m_nScaleHeight; }
+ sal_uInt16 GetPlacement() const { return m_nPlacement; }
+ LwpPoint& GetOffset() { return m_Offset; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutScale() override;
+
+ sal_uInt16 m_nScaleMode;
+ sal_uInt32 m_nScalePercentage;
+ sal_Int32 m_nScaleWidth;
+ sal_Int32 m_nScaleHeight;
+ sal_uInt16 m_nContentRotation;
+ LwpPoint m_Offset;
+ sal_uInt16 m_nPlacement;
+};
+
+class LwpLayoutMargins final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutMargins(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpMargins& GetMargins() { return m_Margins; }
+ LwpMargins& GetExtMargins() { return m_ExtMargins; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutMargins() override;
+
+ LwpMargins m_Margins;
+ LwpMargins m_ExtMargins;
+ LwpMargins m_ExtraMargins;
+};
+
+class LwpLayoutBorder final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutBorder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpBorderStuff& GetBorderStuff() { return m_BorderStuff; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutBorder() override;
+
+ LwpBorderStuff m_BorderStuff;
+};
+
+class LwpLayoutBackground final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutBackground(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpBackgroundStuff& GetBackgoudStuff() { return m_BackgroundStuff; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutBackground() override;
+
+ LwpBackgroundStuff m_BackgroundStuff;
+};
+
+class LwpExternalBorder
+{
+public:
+ LwpExternalBorder();
+ ~LwpExternalBorder();
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ LwpAtomHolder m_LeftName;
+ LwpAtomHolder m_TopName;
+ LwpAtomHolder m_RightName;
+ LwpAtomHolder m_BottomName;
+};
+
+//It seems that this class is used for designer border. Only read now.
+class LwpLayoutExternalBorder final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutExternalBorder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutExternalBorder() override;
+
+ LwpExternalBorder m_ExtranalBorder;
+};
+
+class LwpColumnInfo
+{
+public:
+ LwpColumnInfo();
+ void Read(LwpObjectStream* pStrm);
+ double GetGap() { return LwpTools::ConvertFromUnitsToMetric(m_nGap); }
+
+private:
+ sal_Int32 m_nWidth;
+ sal_Int32 m_nGap;
+};
+
+class LwpLayoutColumns final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutColumns(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ sal_uInt16 GetNumCols() const { return m_nNumCols; }
+ double GetColGap(sal_uInt16 nIndex);
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutColumns() override;
+
+ sal_uInt16 m_nNumCols;
+ std::unique_ptr<LwpColumnInfo[]> m_pColumns;
+};
+
+class LwpLayoutGutters final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutGutters(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpBorderStuff& GetBorderStuff() { return m_BorderBuffer; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutGutters() override;
+
+ LwpBorderStuff m_BorderBuffer;
+};
+
+class LwpJoinStuff
+{
+public:
+ LwpJoinStuff();
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ sal_uInt16 m_nPercentage;
+ sal_uInt16 m_nCorners;
+ sal_Int32 m_nWidth;
+ sal_Int32 m_nHeight;
+
+ enum JoinType
+ {
+ MITRE = 1,
+ NEGATE = 2,
+ ROUNDED = 3,
+ RECTANGLE = 4,
+ SPECIAL = 5,
+ DIAGONAL = 6,
+ NEGATE_NO_CROSS = 7,
+ DOG_EAR_PAGE = 8,
+ DESKTOP = 9,
+ BOX_HIGHLIGHT = 10,
+ STAR = 11,
+ ROPE = 12,
+ DECO1 = 13,
+ DECO2 = 14,
+ RAIN = 15,
+ PIN = 16,
+ ROSE = 17,
+ SUNF = 18,
+ DECO3 = 19,
+ WARNING = 20,
+ BUBBLE = 21,
+ GIRDER = 22,
+ SMILE = 23,
+ ARROW = 24,
+ MAXJOIN = 24
+ };
+
+ sal_uInt16 m_nID; //JoinType
+ sal_uInt16 m_nScaling;
+ LwpColor m_Color;
+};
+
+class LwpLayoutJoins final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutJoins(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutJoins() override;
+
+ LwpJoinStuff m_JoinStuff;
+};
+
+class LwpLayoutShadow final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutShadow(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpShadow& GetShadow() { return m_Shadow; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutShadow() override;
+
+ LwpShadow m_Shadow;
+};
+
+class LwpLayoutRelativityGuts
+{
+public:
+ LwpLayoutRelativityGuts();
+ void Read(LwpObjectStream* pStrm);
+ sal_uInt8 GetRelativeType() const { return m_nRelType; }
+ enum RelativeType
+ {
+ LAY_PARENT_RELATIVE = 1,
+ LAY_PARA_RELATIVE,
+ LAY_INLINE,
+ LAY_INLINE_NEWLINE,
+ LAY_CONTENT_RELATIVE,
+ LAY_INLINE_VERTICAL
+ };
+ enum WhereType
+ {
+ LAY_UPPERLEFT = 1,
+ LAY_MIDDLETOP,
+ LAY_UPPERRIGHT,
+ LAY_MIDDLELEFT,
+ LAY_MIDDLERIGHT,
+ LAY_LOWERLEFT,
+ LAY_MIDDLEBOTTOM,
+ LAY_LOWERRIGHT,
+ LAY_MIDDLE
+ };
+ enum TetherWhereType
+ {
+ LAY_INTERNAL = 1,
+ LAY_EXTERNAL,
+ LAY_BORDER
+ };
+
+private:
+ sal_uInt8 m_nRelType;
+ sal_uInt8 m_nRelFromWhere;
+ LwpPoint m_RelDistance;
+ sal_uInt8 m_nTether;
+ sal_uInt8 m_nTetherWhere;
+ sal_uInt8 m_nFlags;
+};
+
+class LwpLayoutRelativity final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutRelativity(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpLayoutRelativityGuts& GetRelGuts() { return m_RelGuts; }
+
+private:
+ virtual void Read() override;
+ virtual ~LwpLayoutRelativity() override;
+
+ LwpLayoutRelativityGuts m_RelGuts;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplnopts.cxx b/lotuswordpro/source/filter/lwplnopts.cxx
new file mode 100644
index 000000000..566db68b3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplnopts.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpglobalmgr.hxx>
+#include "lwplnopts.hxx"
+
+LwpLineNumberOptions::LwpLineNumberOptions(LwpObjectStream* pStrm) { Read(pStrm); }
+/**
+ * @descr Read LwpLineNumberOptions from object stream
+ */
+void LwpLineNumberOptions::Read(LwpObjectStream* pStrm)
+{
+ m_nType = pStrm->QuickReaduInt16();
+ m_nFlags = pStrm->QuickReaduInt16();
+ m_nSeparator = pStrm->QuickReaduInt16();
+ m_nSpacing = pStrm->QuickReaduInt32();
+ m_nDistance = pStrm->QuickReaduInt32();
+ pStrm->SkipExtra();
+}
+/**
+ * @descr set XFLineNumberConfig
+ */
+void LwpLineNumberOptions::RegisterStyle()
+{
+ if (m_nType == NUMBER_NONE)
+ return;
+ XFLineNumberConfig* pLineNumber = new XFLineNumberConfig;
+ pLineNumber->SetNumberPosition(enumXFLineNumberLeft);
+ pLineNumber->SetNumberOffset(LwpTools::ConvertFromUnitsToMetric(m_nDistance));
+ pLineNumber->SetNumberIncrement(m_nSeparator);
+ if (m_nFlags & LN_RESETEACHPAGE)
+ pLineNumber->SetRestartOnPage();
+ else
+ pLineNumber->SetRestartOnPage(false);
+ if (m_nFlags & LN_COUNTBLANKLINES)
+ pLineNumber->SetCountEmptyLines();
+ else
+ pLineNumber->SetCountEmptyLines(false);
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pXFStyleManager->SetLineNumberConfig(pLineNumber);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwplnopts.hxx b/lotuswordpro/source/filter/lwplnopts.hxx
new file mode 100644
index 000000000..1608443ee
--- /dev/null
+++ b/lotuswordpro/source/filter/lwplnopts.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLNOPTS_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLNOPTS_HXX
+
+#include <lwpobjstrm.hxx>
+
+/**
+ * @brief line number options
+*/
+class LwpLineNumberOptions final
+{
+public:
+ explicit LwpLineNumberOptions(LwpObjectStream* pStrm);
+
+private:
+ sal_uInt16 m_nType;
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nSeparator;
+ sal_uInt32 m_nSpacing;
+ sal_uInt32 m_nDistance;
+
+public:
+ enum
+ {
+ NUMBER_NONE,
+ NUMBER_LINES,
+ NUMBER_TEXTLINESONLY
+ };
+ enum
+ {
+ LN_RESETEACHPAGE = 0x01,
+ LN_COUNTBLANKLINES = 0x02
+ };
+ void Read(LwpObjectStream* pStrm);
+ void RegisterStyle();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpmargins.hxx b/lotuswordpro/source/filter/lwpmargins.hxx
new file mode 100644
index 000000000..7095b3b81
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpmargins.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPMARGINS_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPMARGINS_HXX
+
+#include <lwpobjstrm.hxx>
+#include <lwptools.hxx>
+
+const sal_uInt8 MARGIN_LEFT = 0;
+const sal_uInt8 MARGIN_RIGHT = 1;
+const sal_uInt8 MARGIN_TOP = 2;
+const sal_uInt8 MARGIN_BOTTOM = 3;
+
+class LwpMargins
+{
+public:
+ LwpMargins():m_nLeft(0),m_nTop(0),m_nRight(0),m_nBottom(0){}
+public:
+ void Read(LwpObjectStream *pStrm)
+ {
+ m_nLeft = pStrm->QuickReadInt32();
+ m_nTop = pStrm->QuickReadInt32();
+ m_nRight = pStrm->QuickReadInt32();
+ m_nBottom = pStrm->QuickReadInt32();
+ pStrm->SkipExtra();
+ }
+ inline double GetMarginsValue(sal_uInt8 nWhichSide);
+private:
+ sal_Int32 m_nLeft;
+ sal_Int32 m_nTop;
+ sal_Int32 m_nRight;
+ sal_Int32 m_nBottom;
+};
+
+inline double LwpMargins::GetMarginsValue(sal_uInt8 nWhichSide)
+{
+ switch (nWhichSide)
+ {
+ case MARGIN_LEFT://left
+ return LwpTools::ConvertFromUnitsToMetric(m_nLeft);
+ case MARGIN_RIGHT://right
+ return LwpTools::ConvertFromUnitsToMetric(m_nRight);
+ case MARGIN_TOP://top
+ return LwpTools::ConvertFromUnitsToMetric(m_nTop);
+ case MARGIN_BOTTOM://bottom
+ return LwpTools::ConvertFromUnitsToMetric(m_nBottom);
+ }
+ // FIXME: this is needed to avoid warning: control reaches end of non-void function
+ // a better solution would be to enum value for the parameter side
+ return 0;
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpmarker.cxx b/lotuswordpro/source/filter/lwpmarker.cxx
new file mode 100644
index 000000000..e6b29c23c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpmarker.cxx
@@ -0,0 +1,537 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpfilehdr.hxx>
+#include "lwpstory.hxx"
+#include "lwpmarker.hxx"
+#include "lwpproplist.hxx"
+#include <lwpglobalmgr.hxx>
+#include <xfilter/xfplaceholder.hxx>
+#include <xfilter/xfinputlist.hxx>
+
+LwpMarker::LwpMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpDLNFPVList(objHdr,pStrm)
+ , m_nFlag(0)
+ , m_nPageNumber(0)
+ , m_nNeedUpdate(0)
+{
+}
+
+void LwpMarker::Read()
+{
+ LwpDLNFPVList::Read();
+ m_objContent.ReadIndexed(m_pObjStrm.get());
+ m_objLayout.ReadIndexed(m_pObjStrm.get());
+ m_objMarkerList.ReadIndexed(m_pObjStrm.get());
+ m_nNeedUpdate = m_pObjStrm->QuickReaduInt16();
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ m_nPageNumber = m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->SkipExtra();
+}
+
+OUString LwpMarker::GetNamedProperty(std::u16string_view name)
+{
+ LwpPropList* pProp = GetPropList();
+ if (pProp)
+ return pProp->GetNamedProperty(name);
+ else
+ return OUString();
+}
+
+LwpStoryMarker::LwpStoryMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpMarker(objHdr,pStrm)
+ , m_nFlag(0)
+{
+}
+
+void LwpStoryMarker::Read()
+{
+ LwpMarker::Read();
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ m_Range.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpFribRange::Read(LwpObjectStream* pObjStrm)
+{
+ m_StartPara.ReadIndexed(pObjStrm);
+ m_EndPara.ReadIndexed(pObjStrm);
+}
+
+LwpCHBlkMarker::LwpCHBlkMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpStoryMarker(objHdr, pStrm)
+ , m_nTab(0)
+ , m_nFlag(0)
+ , m_nAction(0)
+{
+}
+
+void LwpCHBlkMarker::Read()
+{
+ LwpStoryMarker::Read();
+ m_objPromptStory.ReadIndexed(m_pObjStrm.get());
+ m_Help.Read(m_pObjStrm.get());
+ m_nAction = m_pObjStrm->QuickReaduInt16();
+ m_nTab = m_pObjStrm->QuickReaduInt32();
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ if(m_pObjStrm->CheckExtra())
+ {
+ m_Mirror.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+OUString LwpCHBlkMarker::GetPromptText() const
+{
+ LwpStory* pStory = nullptr;
+ if (m_objPromptStory.obj().is())
+ pStory = dynamic_cast<LwpStory*>(m_objPromptStory.obj().get());
+ if (pStory)
+ return pStory->GetContentText();
+ return OUString();
+}
+
+void LwpCHBlkMarker::ConvertCHBlock(XFContentContainer* pXFPara, sal_uInt8 nType)
+{
+ sal_uInt16 nAction = GetAction();
+
+ switch(nAction)
+ {
+ case CLICKHERE_CHBEHAVIORTEXT:
+ case CLICKHERE_CHBEHAVIORTABLE:
+ case CLICKHERE_CHBEHAVIORPICTURE:
+ case CLICKHERE_CHBEHAVIOROLEOBJECT:
+ ProcessPlaceHolder(pXFPara,nAction,nType);
+ break;
+ case CLICKHERE_CHBEHAVIORCHART:
+ case CLICKHERE_CHBEHAVIORDRAWING:
+ case CLICKHERE_CHBEHAVIORGLOSSARY:
+ case CLICKHERE_CHBEHAVIOREQUATION:
+ case CLICKHERE_CHBEHAVIORSYMBOL:
+ case CLICKHERE_CHBEHAVIORPAGENUM:
+ case CLICKHERE_CHBEHAVIORDOCFIELD:
+ case CLICKHERE_CHBEHAVIORDATETIME:
+ ProcessOtherCHB(pXFPara,nType);
+ break;
+ case CLICKHERE_CHBEHAVIORSTRINGLIST:
+ ProcessKeylist(pXFPara,nType);
+ break;
+ default:
+ break;
+ }
+}
+
+void LwpCHBlkMarker::ProcessPlaceHolder(XFContentContainer* pXFPara,sal_uInt16 nAction,
+ sal_uInt8 nType)
+{
+ bool bFillFlag = IsHasFilled();
+ bool bHelpFlag = IsBubbleHelp();
+
+ if ( bFillFlag )
+ return;
+ if (nType == MARKER_START)
+ {
+ XFHolderStart* pHolder= new XFHolderStart;
+ switch(nAction)
+ {
+ case CLICKHERE_CHBEHAVIORTEXT:
+ pHolder->SetType("text");
+ break;
+ case CLICKHERE_CHBEHAVIORTABLE:
+ pHolder->SetType("table");
+ break;
+ case CLICKHERE_CHBEHAVIORPICTURE:
+ pHolder->SetType("image");
+ break;
+ case CLICKHERE_CHBEHAVIOROLEOBJECT:
+ pHolder->SetType("object");
+ break;
+ default:
+ break;
+ }
+
+ if (bHelpFlag)
+ pHolder->SetDesc(m_Help.str());
+ pHolder->SetPrompt(GetPromptText());
+ pXFPara->Add(pHolder);
+ }
+ else if (nType == MARKER_END)
+ {
+ XFHolderEnd* pHolder = new XFHolderEnd;
+ pXFPara->Add(pHolder);
+ }
+}
+
+void LwpCHBlkMarker::ProcessOtherCHB(XFContentContainer* pXFPara,sal_uInt8 nType)
+{
+ bool bFillFlag = IsHasFilled();
+ bool bHelpFlag = IsBubbleHelp();
+
+ if ( bFillFlag )
+ return;
+ if (nType == MARKER_START)
+ {
+ XFHolderStart* pHolder= new XFHolderStart;
+ pHolder->SetType("text");
+ if (bHelpFlag)
+ pHolder->SetDesc(m_Help.str());
+ pHolder->SetPrompt(GetPromptText());
+ pXFPara->Add(pHolder);
+ }
+ else if (nType == MARKER_END)
+ {
+ XFHolderEnd* pHolder = new XFHolderEnd;
+ pXFPara->Add(pHolder);
+ }
+
+}
+
+//note: there will be a blank to mark the list
+//all input content of key list processed as normal text
+void LwpCHBlkMarker::ProcessKeylist(XFContentContainer* pXFPara,sal_uInt8 nType)
+{
+ bool bFillFlag = IsHasFilled();
+
+ if ( bFillFlag )
+ {
+ if (nType == MARKER_START)
+ {
+ EnumAllKeywords();//traverse the proplist to find all keywords
+ XFInputList* pList = new XFInputList;
+ pList->SetName(LwpDLNFPVList::m_Name.str());
+ pList->SetLabels(std::vector(m_Keylist));
+ pXFPara->Add(pList);
+ }
+ // else skip MARKER_END
+ }
+ else
+ {
+ if (nType == MARKER_START)
+ {
+ EnumAllKeywords();
+ XFInputList* pList = new XFInputList;
+ pList->SetName(LwpDLNFPVList::m_Name.str());
+ pList->SetLabels(std::vector(m_Keylist));
+ pXFPara->Add(pList);
+
+ XFHolderStart* pHolder= new XFHolderStart;
+ pHolder->SetType("text");
+ pHolder->SetPrompt(GetPromptText());
+ pXFPara->Add(pHolder);
+ }
+ else if (nType == MARKER_END)
+ {
+ XFHolderEnd* pHolder = new XFHolderEnd;
+ pXFPara->Add(pHolder);
+ }
+ }
+}
+
+bool LwpCHBlkMarker::IsHasFilled() const
+{
+ return (CHB_PROMPT & m_nFlag) == 0;
+}
+
+bool LwpCHBlkMarker::IsBubbleHelp() const
+{
+ return (CHB_HELP & m_nFlag) != 0;
+}
+
+void LwpCHBlkMarker::EnumAllKeywords()
+{
+ OUString name1("");
+ OUString value1("");
+ OUString name2("start");
+ LwpPropList* pProp = GetPropList();
+ if (!pProp)
+ return;
+ while(!name2.isEmpty())
+ {
+ name2 = pProp->EnumNamedProperty(name1,value1);
+ if ( name1.match("LIST",0) )
+ {
+ m_Keylist.push_back(value1);
+ }
+ name1 = name2;
+ }
+}
+
+LwpBookMark::LwpBookMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpDLNFVList(objHdr,pStrm)
+ , m_nFlag(0)
+{
+}
+
+void LwpBookMark::Read()
+{
+ LwpDLNFVList::Read();
+ m_objMarker.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x0008)
+ {
+ if (m_pObjStrm->QuickReadBool())
+ m_nFlag |= BKMK_NOTESFX;
+ }
+ else
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+}
+
+bool LwpBookMark::IsRightMarker(LwpObjectID objMarker)
+{
+ return objMarker == m_objMarker;
+}
+
+OUString const & LwpBookMark::GetName()
+{
+ return LwpDLNFVList::GetName().str();
+}
+
+LwpFieldMark::LwpFieldMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+ : LwpStoryMarker(objHdr,pStrm)
+ , m_nFlag(0)
+ , m_nFieldType(0)
+ , m_bHasStyle(false)
+ , m_bHasStart(false)
+ , m_pFrib(nullptr)
+ , m_bRevisionFlag(false)
+{
+}
+
+void LwpFieldMark::Read()
+{
+ LwpStoryMarker::Read();
+ m_Formula.Read(m_pObjStrm.get());
+ m_objFormulaStory.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ return;
+ m_objResultContent.ReadIndexed(m_pObjStrm.get());
+ m_nFlag = m_pObjStrm->QuickReaduInt16();
+ m_nFieldType = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpFieldMark::ParseIndex(OUString& sKey1,OUString& sKey2)
+{
+ OUString sFormula = m_Formula.str();
+ sal_Int32 index[4];
+ sal_Unicode ch(0x0022);//"
+ index[0] = sFormula.indexOf(ch);
+ index[1] = sFormula.indexOf(ch,index[0]+1);
+
+ index[2] = sFormula.indexOf(ch,index[1]+1);
+ index[3] = sFormula.indexOf(ch,index[2]+1);
+ if (index[0]>=0 && index[1]>=0)
+ sKey1 = sFormula.copy(index[0]+1,index[1]-index[0]-1);
+ else
+ sKey1.clear();
+ if (index[2]>=0 && index[3]>=0)
+ sKey2 = sFormula.copy(index[2]+1,index[3]-index[2]-1);
+ else
+ sKey2.clear();
+}
+
+void LwpFieldMark::ParseTOC(OUString& sLevel,OUString& sText)
+{
+ OUString sFormula = m_Formula.str();
+ sal_Int32 index[4];
+ sal_Unicode ch1(0x0020);//space
+ sal_Unicode ch2(0x0022);//"
+
+ index[0] = sFormula.indexOf(ch1);
+ index[1] = sFormula.indexOf(ch1,index[0]+1);
+
+ index[2] = sFormula.indexOf(ch2,index[1]+1);
+ index[3] = sFormula.indexOf(ch2,index[2]+1);
+ if (index[0]>=0 && index[1]>=0)
+ sLevel = sFormula.copy(index[0]+1,index[1]-index[0]-1);
+ else
+ sLevel.clear();
+ if (index[2]>=0 && index[3]>=0)
+ sText = sFormula.copy(index[2]+1,index[3]-index[2]-1);
+ else
+ sText.clear();
+}
+
+bool LwpFieldMark::IsFormulaInsert() const
+{
+ return (m_nFlag & FF_FORMULAINSERTED) != 0;
+}
+
+bool LwpFieldMark::IsDateTimeField(sal_uInt8& type,OUString& formula)
+{
+ OUString sFormula = m_Formula.str();
+ sal_Int32 index = sFormula.indexOf(0x20); // space
+ if (index < 0)
+ {
+ if (sFormula == "TotalEditingTime")
+ {
+ type = DATETIME_TOTALTIME;
+ return true;
+ }
+ return false;
+ }
+
+ std::u16string_view tag = sFormula.subView(0,index);
+ if (tag == u"Now()")
+ {
+ type = DATETIME_NOW;
+ formula = sFormula.copy(index+1);
+ return true;
+ }
+ else if (tag == u"CreateDate")
+ {
+ type = DATETIME_CREATE;
+ formula = sFormula.copy(index+1);
+ return true;
+ }
+ else if (tag == u"EditDate")
+ {
+ type = DATETIME_LASTEDIT;
+ formula = sFormula.copy(index+1);
+ return true;
+ }
+ else if (tag == u"YesterdaysDate" || tag == u"TomorrowsDate"
+ || tag == u"TodaysDate")
+ {
+ type = DATETIME_SKIP;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool LwpFieldMark::IsCrossRefField(sal_uInt8& nType, OUString& sMarkName)
+{
+ OUString sFormula = m_Formula.str();
+ sal_Int32 index = sFormula.indexOf(0x20); // space
+ if (index < 0)
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpBookmarkMgr* pMarkMgr = pGlobal->GetLwpBookmarkMgr();
+ if (pMarkMgr->FindBookmark(sFormula))
+ {
+ sMarkName = sFormula;
+ nType = CROSSREF_TEXT;
+ return true;
+ }
+ else
+ return false;
+ }
+
+ std::u16string_view tag = sFormula.subView(0,index);
+ if (tag == u"PageRef")
+ {
+ sMarkName = sFormula.copy(index+1);
+ nType = CROSSREF_PAGE;
+ return true;
+ }
+ else if (tag == u"ParaRef")
+ {
+ sMarkName = sFormula.copy(index+1);
+ nType = CROSSREF_PARANUMBER;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool LwpFieldMark::IsDocPowerField(sal_uInt8& nType,OUString& sFormula)
+{
+ sFormula = m_Formula.str();
+
+ if (sFormula == "Description")
+ {
+ nType = DOC_DESCRIPTION;
+ return true;
+ }
+ else if (sFormula == "NumPages")
+ {
+ nType = DOC_NUMPAGES;
+ return true;
+ }
+ else if (sFormula == "NumChars")
+ {
+ nType = DOC_NUMCHARS;
+ return true;
+ }
+ else if (sFormula == "NumWords")
+ {
+ nType = DOC_NUMWORDS;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+LwpRubyMarker::LwpRubyMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm):LwpStoryMarker(objHdr,pStrm)
+{
+}
+
+void LwpRubyMarker::Read()
+{
+ LwpStoryMarker::Read();
+ m_objLayout.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpmarker.hxx b/lotuswordpro/source/filter/lwpmarker.hxx
new file mode 100644
index 000000000..8375d0732
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpmarker.hxx
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPMARKER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPMARKER_HXX
+
+#include <lwpobjid.hxx>
+#include "lwpdlvlist.hxx"
+#include <lwpfrib.hxx>
+
+class LwpMarker : public LwpDLNFPVList
+{
+public:
+ LwpMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+ void Read() override;
+ OUString GetNamedProperty(std::u16string_view name);
+protected:
+ enum{
+ MARKER_START=1,
+ MARKER_END=2
+ };
+private:
+ sal_uInt16 m_nFlag;
+ sal_uInt16 m_nPageNumber;
+ sal_uInt16 m_nNeedUpdate;
+ LwpObjectID m_objLayout;
+ LwpObjectID m_objMarkerList;
+ LwpObjectID m_objContent;
+
+};
+
+class LwpFribRange
+{
+public:
+ LwpFribRange(){}
+ void Read(LwpObjectStream* pObjStrm);
+private:
+ LwpObjectID m_StartPara;
+ LwpObjectID m_EndPara;
+};
+
+class LwpStoryMarker : public LwpMarker
+{
+public:
+ LwpStoryMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+ void Read() override;
+private:
+ LwpFribRange m_Range;
+ sal_uInt16 m_nFlag;
+};
+
+class LwpCHBlkMarker : public LwpStoryMarker
+{
+public:
+ LwpCHBlkMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+ void Read() override;
+ sal_uInt16 GetAction() const {return m_nAction;}
+ void ConvertCHBlock(XFContentContainer* pXFPara,sal_uInt8 nType);
+ enum{
+ CLICKHERE_CHBEHAVIORTEXT=1,
+ CLICKHERE_CHBEHAVIORTABLE=2,
+ CLICKHERE_CHBEHAVIORPICTURE=3,
+ CLICKHERE_CHBEHAVIOROLEOBJECT=4,
+ CLICKHERE_CHBEHAVIORCHART=5,
+ CLICKHERE_CHBEHAVIORDRAWING=6,
+ CLICKHERE_CHBEHAVIORFILE=7,
+ CLICKHERE_CHBEHAVIORGLOSSARY=8,
+ CLICKHERE_CHBEHAVIOREQUATION=9,
+ CLICKHERE_CHBEHAVIORINTERNETLINK=10,
+ CLICKHERE_CHBEHAVIORSTRINGLIST=11,
+ CLICKHERE_CHBEHAVIORDATETIME=12,
+ CLICKHERE_CHBEHAVIORSYMBOL=13,
+ CLICKHERE_CHBEHAVIORDOCFIELD=14,
+ CLICKHERE_CHBEHAVIORPAGENUM=15
+ };
+private:
+ void ProcessPlaceHolder(XFContentContainer* pXFPara,sal_uInt16 nAction,sal_uInt8 nType);
+ void ProcessOtherCHB(XFContentContainer* pXFPara,sal_uInt8 nType);
+ void ProcessKeylist(XFContentContainer* pXFPara,sal_uInt8 nType);
+ bool IsHasFilled() const;
+ bool IsBubbleHelp() const;
+ OUString GetPromptText() const;
+ void EnumAllKeywords();
+private:
+ enum{
+ CHB_PROMPT = 0x01,
+ CHB_EDIT = 0x02,
+ CHB_HELP = 0x04,
+ CHB_TAB = 0x08,
+ CHB_HIDDEN = 0x10,
+ CHB_ALLOWVALUESNOTINLIST = 0x20,
+ CHB_ALLOWMULTIVALUES = 0x40,
+ CHB_RETURN = 0x80,
+ CHB_NOEARS = 0x100,
+ CHB_MAGNETIC = 0x200,
+ CHB_PERSISTENT = (CHB_PROMPT+CHB_HELP+CHB_TAB+CHB_HIDDEN
+ +CHB_ALLOWVALUESNOTINLIST+CHB_ALLOWMULTIVALUES
+ +CHB_RETURN+CHB_NOEARS+CHB_MAGNETIC)
+ };
+ LwpObjectID m_objPromptStory;
+ sal_uInt32 m_nTab;
+ sal_uInt16 m_nFlag;
+ sal_uInt16 m_nAction;
+ LwpAtomHolder m_Help;
+ LwpAtomHolder m_Mirror;
+ std::vector<OUString> m_Keylist;
+};
+
+class LwpBookMark : public LwpDLNFVList
+{
+public:
+ LwpBookMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+protected:
+ void Read() override;
+public:
+ bool IsRightMarker(LwpObjectID objMarker);
+ OUString const & GetName();
+private:
+ enum { BKMK_NOTESFX = 0x0001,
+ BKMK_OLDNOTESFX = 0x0002
+ };
+ LwpObjectID m_objMarker;
+ sal_uInt16 m_nFlag;
+};
+
+class LwpFieldMark : public LwpStoryMarker
+{
+public:
+ LwpFieldMark(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+ void Read() override;
+ void ParseIndex(OUString& sKey1,OUString& sKey2);
+ void ParseTOC(OUString& sLevel,OUString& sText);
+ sal_uInt16 GetFieldType() const {return m_nFieldType;}
+ bool IsFormulaInsert() const;
+ bool IsDateTimeField(sal_uInt8& type,OUString& formula);
+ bool IsCrossRefField(sal_uInt8& nType, OUString& sMarkName);
+ bool IsDocPowerField(sal_uInt8& nType,OUString& sFormula);
+ OUString const & GetFormula() const {return m_Formula.str();}
+ void SetStyleFlag(bool bFalg){m_bHasStyle = bFalg;}
+ bool GetStyleFlag() const {return m_bHasStyle;}
+ bool GetStart() const {return m_bHasStart;}
+ void SetStart(bool bFlag){m_bHasStart = bFlag;}
+ LwpFrib* GetStartFrib(){return m_pFrib;}
+ void SetStartFrib(LwpFrib* pFrib){m_pFrib = pFrib;}
+ bool GetRevisionFlag() const {return m_bRevisionFlag;}
+ void SetRevisionFlag(bool bFlag){m_bRevisionFlag = bFlag;}
+
+ enum{
+ FLD_FIELD = 0x0003,
+ FLD_INDEX = 0x0008,
+ FLD_TOC = 0x000B
+ };
+ enum{
+ FF_FORMULAINSERTED = 0X0008,
+ };
+ enum{
+ CROSSREF_INVALID = 0,
+ CROSSREF_TEXT = 1,
+ CROSSREF_PAGE = 2,
+ CROSSREF_PARANUMBER = 3
+ };
+ enum{
+ DATETIME_SKIP = 0,
+ DATETIME_NOW = 1,
+ DATETIME_CREATE = 2,
+ DATETIME_LASTEDIT = 3,
+ DATETIME_TOTALTIME = 4
+ };
+ enum{
+ DOC_DESCRIPTION = 1,
+ DOC_NUMPAGES = 2,
+ DOC_NUMWORDS = 3,
+ DOC_NUMCHARS = 4,
+ };
+private:
+ LwpObjectID m_objFormulaStory;
+ LwpObjectID m_objResultContent;
+ sal_uInt16 m_nFlag;
+ sal_uInt16 m_nFieldType;
+ LwpAtomHolder m_Formula;
+
+ bool m_bHasStyle;
+ bool m_bHasStart;
+
+ LwpFrib* m_pFrib;
+ bool m_bRevisionFlag;
+};
+
+class LwpRubyMarker : public LwpStoryMarker
+{
+public:
+ LwpRubyMarker(LwpObjectHeader const &objHdr, LwpSvStream *pStrm);
+ void Read() override;
+ const OUString& GetRubyText() const {return m_strRubyText;}
+ void SetRubyText(const OUString& sText){m_strRubyText = sText;}
+ const OUString& GetTextStyleName() const {return m_TextStyle;}
+ void SetTextStyleName(const OUString& sName){m_TextStyle = sName;}
+ const OUString& GetRubyStyleName() const {return m_RubyStyle;}
+ void SetRubyStyleName(const OUString& sName){m_RubyStyle = sName;}
+private:
+ LwpObjectID m_objLayout;
+ OUString m_strRubyText;
+ OUString m_RubyStyle;
+ OUString m_TextStyle;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnotes.cxx b/lotuswordpro/source/filter/lwpnotes.cxx
new file mode 100644
index 000000000..273013dba
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnotes.cxx
@@ -0,0 +1,308 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - notes
+ */
+
+#include "lwpnotes.hxx"
+#include "lwppara.hxx"
+#include <xfilter/xfannotation.hxx>
+#include <xfilter/xftextspan.hxx>
+#include <localtime.hxx>
+#include <lwptools.hxx>
+
+LwpFribNote::LwpFribNote(LwpPara* pPara)
+ : LwpFrib(pPara)
+{
+}
+
+/**
+ * @descr read frib information
+ */
+void LwpFribNote::Read(LwpObjectStream* pObjStrm, sal_uInt16 /*len*/)
+{
+ m_Layout.ReadIndexed(pObjStrm);
+}
+
+/**
+ * @descr Register style
+ */
+void LwpFribNote::RegisterNewStyle()
+{
+ rtl::Reference<LwpObject> pLayout = m_Layout.obj();
+ if (pLayout.is())
+ {
+ //register font style
+ LwpFrib::RegisterStyle(m_pPara->GetFoundry());
+ //register foonote style
+ pLayout->SetFoundry(m_pPara->GetFoundry());
+ pLayout->DoRegisterStyle();
+ }
+}
+
+/**
+ * @descr convert note
+ */
+void LwpFribNote::XFConvert(XFContentContainer* pCont)
+{
+ LwpNoteLayout* pLayout = dynamic_cast<LwpNoteLayout*>(m_Layout.obj().get());
+ if (!pLayout)
+ return;
+
+ XFAnnotation* pXFNote = new XFAnnotation;
+ pXFNote->SetAuthor(pLayout->GetAuthor());
+ LtTm aTm;
+ tools::Long nTime = pLayout->GetTime();
+ if (LtgLocalTime(nTime, aTm))
+ {
+ pXFNote->SetDate(LwpTools::DateTimeToOUString(aTm));
+ }
+
+ pLayout->XFConvert(pXFNote);
+ if (m_pModifiers)
+ {
+ XFTextSpan* pSpan = new XFTextSpan();
+ pSpan->SetStyleName(GetStyleName());
+ pSpan->Add(pXFNote);
+ pCont->Add(pSpan);
+ }
+ else
+ {
+ pCont->Add(pXFNote);
+ }
+}
+
+LwpNoteLayout::LwpNoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpFrameLayout(objHdr, pStrm)
+ , m_nTime(0)
+{
+}
+
+LwpNoteLayout::~LwpNoteLayout() {}
+
+/**
+ * @descr read note layout object
+ *
+ */
+void LwpNoteLayout::Read()
+{
+ LwpFrameLayout::Read();
+
+ m_nTime = m_pObjStrm->QuickReaduInt32();
+ m_UserName.Read(m_pObjStrm.get());
+
+ LwpAtomHolder aUserInitials;
+ aUserInitials.Read(m_pObjStrm.get());
+
+ LwpColor aColor;
+ aColor.Read(m_pObjStrm.get());
+
+ // vacant note sequence
+ m_pObjStrm->QuickReadInt32();
+
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register style
+ */
+void LwpNoteLayout::RegisterStyle()
+{
+ LwpVirtualLayout* pTextLayout = GetTextLayout();
+ if (pTextLayout)
+ {
+ pTextLayout->SetFoundry(GetFoundry());
+ pTextLayout->DoRegisterStyle();
+ }
+}
+
+/**
+ * @descr convert note
+ */
+void LwpNoteLayout::XFConvert(XFContentContainer* pCont)
+{
+ LwpVirtualLayout* pTextLayout = GetTextLayout();
+ if (pTextLayout)
+ {
+ pTextLayout->DoXFConvert(pCont);
+ }
+}
+
+/**
+ * @descr Get layout that contains note text.
+ */
+LwpVirtualLayout* LwpNoteLayout::GetTextLayout()
+{
+ LwpVirtualLayout* pLayout = FindChildByType(LWP_VIEWPORT_LAYOUT);
+ if (pLayout)
+ {
+ return pLayout->FindChildByType(LWP_NOTETEXT_LAYOUT);
+ }
+
+ return nullptr;
+}
+/**
+ * @descr Get author.
+ */
+OUString LwpNoteLayout::GetAuthor()
+{
+ if (m_UserName.HasValue())
+ {
+ if (m_UserName.str() != " ")
+ {
+ return m_UserName.str();
+ }
+ }
+ //if username is null or writerspace, get username from noteheaderlayout
+ LwpNoteHeaderLayout* pTextLayout
+ = static_cast<LwpNoteHeaderLayout*>(FindChildByType(LWP_NOTEHEADER_LAYOUT));
+ if (pTextLayout)
+ {
+ LwpStory* pStory = dynamic_cast<LwpStory*>(pTextLayout->GetContent().obj().get());
+ if (pStory)
+ {
+ LwpPara* pFirst = dynamic_cast<LwpPara*>(pStory->GetFirstPara().obj().get());
+ if (pFirst)
+ return pFirst->GetContentText(true);
+ }
+ }
+
+ return m_UserName.str();
+}
+
+LwpNoteHeaderLayout::LwpNoteHeaderLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpFrameLayout(objHdr, pStrm)
+{
+}
+
+LwpNoteHeaderLayout::~LwpNoteHeaderLayout() {}
+
+/**
+ * @descr read note layout object
+ *
+ */
+void LwpNoteHeaderLayout::Read()
+{
+ LwpFrameLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpNoteHeaderLayout::RegisterStyle() {}
+
+void LwpNoteHeaderLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+LwpNoteTextLayout::LwpNoteTextLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpFrameLayout(objHdr, pStrm)
+{
+}
+
+LwpNoteTextLayout::~LwpNoteTextLayout() {}
+
+/**
+ * @descr read note layout object
+ *
+ */
+void LwpNoteTextLayout::Read()
+{
+ LwpFrameLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr Register style, SODC doesn't support text style in note
+ */
+void LwpNoteTextLayout::RegisterStyle()
+{
+ rtl::Reference<LwpObject> pContent = m_Content.obj();
+ if (pContent.is())
+ {
+ pContent->SetFoundry(GetFoundry());
+ pContent->DoRegisterStyle();
+ }
+}
+
+void LwpNoteTextLayout::XFConvert(XFContentContainer* pCont)
+{
+ rtl::Reference<LwpObject> pContent = m_Content.obj();
+ if (pContent.is())
+ {
+ pContent->DoXFConvert(pCont);
+ }
+}
+
+LwpViewportLayout::LwpViewportLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+{
+}
+
+LwpViewportLayout::~LwpViewportLayout() {}
+
+/**
+ * @descr read note layout object
+ *
+ */
+void LwpViewportLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpViewportLayout::RegisterStyle() {}
+
+void LwpViewportLayout::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnotes.hxx b/lotuswordpro/source/filter/lwpnotes.hxx
new file mode 100644
index 000000000..73ceb359f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnotes.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - notes
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNOTES_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNOTES_HXX
+
+#include <lwpfrib.hxx>
+#include "lwpframelayout.hxx"
+
+/**
+ * @brief TAG_NOTE_FRIB object
+ *
+ */
+class LwpFribNote : public LwpFrib
+{
+public:
+ explicit LwpFribNote(LwpPara* pPara);
+ void Read(LwpObjectStream* pObjStrm, sal_uInt16 len) override;
+ void RegisterNewStyle();
+ void XFConvert(XFContentContainer* pCont);
+
+private:
+ LwpObjectID m_Layout;
+};
+
+/**
+ * @brief VO_NOTELAYOUT object
+ *
+ */
+class LwpNoteLayout final : public LwpFrameLayout
+{
+public:
+ LwpNoteLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpNoteLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_NOTE_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ sal_uInt32 GetTime() const { return m_nTime; }
+ OUString GetAuthor();
+
+private:
+ void Read() override;
+ LwpVirtualLayout* GetTextLayout();
+
+ sal_uInt32 m_nTime;
+ LwpAtomHolder m_UserName;
+};
+
+/**
+ * @brief VO_NOTEHEADERLAYOUT object
+ *
+ */
+class LwpNoteHeaderLayout : public LwpFrameLayout
+{
+public:
+ LwpNoteHeaderLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpNoteHeaderLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_NOTEHEADER_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_NOTETEXTLAYOUT object
+ *
+ */
+class LwpNoteTextLayout : public LwpFrameLayout
+{
+public:
+ LwpNoteTextLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpNoteTextLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_NOTETEXT_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief VO_VPLAYOUT object
+ *
+ */
+class LwpViewportLayout : public LwpPlacableLayout
+{
+public:
+ LwpViewportLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpViewportLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_VIEWPORT_LAYOUT; }
+ virtual void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+
+protected:
+ void Read() override;
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnumberingoverride.cxx b/lotuswordpro/source/filter/lwpnumberingoverride.cxx
new file mode 100644
index 000000000..a478f7112
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnumberingoverride.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Numbering override of Wordpro.
+************************************************************************/
+
+#include "lwpnumberingoverride.hxx"
+#include <lwpobjstrm.hxx>
+
+LwpNumberingOverride::LwpNumberingOverride()
+ : m_nLevel(0)
+ , m_nPosition(0)
+{
+}
+
+LwpNumberingOverride::LwpNumberingOverride(LwpNumberingOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nLevel(rOther.m_nLevel)
+ , m_nPosition(rOther.m_nPosition)
+{
+}
+
+LwpNumberingOverride* LwpNumberingOverride::clone() const
+{
+ return new LwpNumberingOverride(*this);
+}
+
+void LwpNumberingOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+
+ m_nLevel = pStrm->QuickReaduInt16();
+ m_nPosition = pStrm->QuickReaduInt16();
+ }
+
+ pStrm->SkipExtra();
+}
+
+void LwpNumberingOverride::OverrideLevel(sal_uInt16 nNewLv)
+{
+ m_nLevel = nNewLv;
+ LwpOverride::Override(NO_LEVEL, STATE_ON);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnumberingoverride.hxx b/lotuswordpro/source/filter/lwpnumberingoverride.hxx
new file mode 100644
index 000000000..09975e885
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnumberingoverride.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Numbering override of Wordpro.
+************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMBERINGOVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMBERINGOVERRIDE_HXX
+
+#include <lwpoverride.hxx>
+
+class LwpObjectStream;
+class LwpNumberingOverride final : public LwpOverride
+{
+public:
+ LwpNumberingOverride();
+
+ virtual LwpNumberingOverride* clone() const override;
+
+ enum
+ {
+ NO_LEVEL = 0x0001,
+ NO_POSITION = 0x0002,
+ HEADING = 0x0004,
+ SMARTLEVEL = 0x0008
+ };
+
+ virtual void Read(LwpObjectStream* pStrm) override;
+
+ inline sal_uInt16 GetLevel() const;
+ inline sal_uInt16 GetPosition() const;
+ inline bool IsHeading() const;
+
+ void OverrideLevel(sal_uInt16 nNewLv);
+
+private:
+ LwpNumberingOverride(LwpNumberingOverride const& rOther);
+ LwpNumberingOverride& operator=(LwpNumberingOverride const& rOther) = delete;
+
+ sal_uInt16 m_nLevel;
+ sal_uInt16 m_nPosition;
+};
+
+inline sal_uInt16 LwpNumberingOverride::GetLevel() const { return m_nLevel; }
+
+inline sal_uInt16 LwpNumberingOverride::GetPosition() const { return m_nPosition; }
+
+inline bool LwpNumberingOverride::IsHeading() const { return (m_nValues & HEADING) != 0; }
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnumericfmt.cxx b/lotuswordpro/source/filter/lwpnumericfmt.cxx
new file mode 100644
index 000000000..c2dc4d4e7
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnumericfmt.cxx
@@ -0,0 +1,466 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table cell numerics format
+ */
+
+#include <memory>
+#include <lwpfilehdr.hxx>
+#include "lwpnumericfmt.hxx"
+
+LwpCurrencyPool LwpNumericFormat::m_aCurrencyInfo;
+
+OUString LwpCurrencyPool::GetCurrencySymbol(sal_uInt16 nFormat)
+{
+ return m_aCurrencyInfo[nFormat].sSymbol;
+}
+
+bool LwpCurrencyPool::IsSymbolPost(sal_uInt16 nFormat)
+{
+ return m_aCurrencyInfo[nFormat].bPost;
+}
+
+bool LwpCurrencyPool::IsShowSpace(sal_uInt16 nFormat)
+{
+ return m_aCurrencyInfo[nFormat].bShowSpace;
+}
+
+XFStyle* LwpLayoutNumerics::Convert()
+{
+ return cNumerics.Convert();
+}
+
+void LwpLayoutNumerics::Read()
+{
+ LwpVirtualPiece::Read();
+
+ if(LwpFileHeader::m_nFileRevision >= 0x000b)
+ {
+ cNumerics.Read();
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpNumericFormatSubset::QuickRead(LwpObjectStream* pStrm)
+{
+ cColor.Read(pStrm);
+ cPrefix.Read(pStrm);
+ cSuffix.Read(pStrm);
+ cSubFlags = pStrm->QuickReaduInt16();
+
+ pStrm->SkipExtra();
+}
+LwpColor LwpNumericFormatSubset::GetColor() const
+{
+ if (cSubFlags&0x04)
+ {
+ return cColor;
+ }
+ else
+ {
+ return LwpColor();
+ }
+}
+LwpNumericFormatSubset::LwpNumericFormatSubset():cSubFlags(0)
+{
+}
+
+LwpNumericFormat::LwpNumericFormat(LwpObjectStream * pStrm)
+ : m_pObjStrm(pStrm)
+ , cFlags(0)
+ , cFormat(FMT_DEFAULT)
+ , cDecimalPlaces(0)
+{
+ assert(pStrm);
+}
+/**
+* Read number format from wordpro file
+*/
+void LwpNumericFormat::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm;
+
+ if(LwpFileHeader::m_nFileRevision >= 0x000b)
+ {
+ cFlags = pStrm->QuickReaduInt16();
+ cDecimalPlaces = pStrm->QuickReaduInt16();
+ cFormat = pStrm->QuickReaduInt16();
+
+ cAnyNumber.QuickRead(pStrm);
+ cZero.QuickRead(pStrm);
+ cNegative.QuickRead(pStrm);
+
+ pStrm->SkipExtra();
+ }
+}
+bool LwpNumericFormat::IsCurrencyFormat(sal_uInt16 Format)
+{
+ switch (Format)
+ {
+ case FMT_ARGENTINEANPESO:
+ case FMT_AUSTRALIANDOLLAR:
+ case FMT_AUSTRIANSCHILLING:
+ case FMT_BELGIANFRANC:
+ case FMT_BRAZILIANCRUZEIRO:
+ case FMT_BRITISHPOUND:
+ case FMT_CANADIANDOLLAR:
+ case FMT_CHINESEYUAN:
+ case FMT_CZECHKORUNA:
+ case FMT_DANISHKRONE:
+ case FMT_ECU:
+ case FMT_FINNISHMARKKA:
+ case FMT_FRENCHFRANC:
+ case FMT_GREEKDRACHMA:
+ case FMT_HONGKONGDOLLAR:
+ case FMT_HUNGARIANFORINT:
+ case FMT_INDIANRUPEE:
+ case FMT_INDONESIANRUPIAH:
+ case FMT_IRISHPUNT:
+ case FMT_LUXEMBOURGFRANC:
+ case FMT_MALAYSIANRINGGIT:
+ case FMT_MEXICANPESO:
+ case FMT_NETHERLANDSGUILDER:
+ case FMT_NEWZEALANDDOLLAR:
+ case FMT_NORWEGIANKRONE:
+ case FMT_POLISHZLOTY:
+ case FMT_PORTUGUESEESCUDO:
+ case FMT_ROMANIANLEI:
+ case FMT_RUSSIANRUBLE:
+ case FMT_SINGAPOREDOLLAR:
+ case FMT_SLOVAKIANKORUNA:
+ case FMT_SLOVENIANTHOLAR:
+ case FMT_SOUTHAFRICANRAND:
+ case FMT_SOUTHKOREANWON:
+ case FMT_SWEDISHKRONA:
+ case FMT_SWISSFRANC:
+ case FMT_TAIWANDOLLAR:
+ case FMT_THAIBAHT:
+ case FMT_USDOLLAR:
+ case FMT_OTHERCURRENCY:
+ case FMT_GERMANMARK:
+ case FMT_ITALIANLIRA:
+ case FMT_JAPANESEYEN:
+ case FMT_SPANISHPESETA:
+ case FMT_EURO:
+ return true;
+
+ default:
+ return false;
+ }
+}
+sal_uInt16
+LwpNumericFormat::GetDecimalPlaces()
+{
+ if (IsDecimalPlacesOverridden())
+ return cDecimalPlaces;
+ return GetDefaultDecimalPlaces(cFormat);
+}
+void LwpNumericFormat::GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegative)
+{
+ aPrefix = aNumber.GetPrefix();
+ aSuffix = aNumber.GetSuffix();
+
+ //Make the default prefix and suffix
+ OUString aSymbol = m_aCurrencyInfo.GetCurrencySymbol(cFormat);
+ bool bPost = m_aCurrencyInfo.IsSymbolPost(cFormat);
+ bool bShowSpace = m_aCurrencyInfo.IsShowSpace(cFormat);
+ if ( aNumber.IsDefaultPrefix())
+ {
+ if (bNegative)
+ {
+ aPrefix = "(";
+ }
+ if (!bPost)
+ {
+ aPrefix += aSymbol;
+ if (bShowSpace)
+ {
+ aPrefix += " ";
+ }
+ }
+ }
+ if ( !aNumber.IsDefaultSuffix())
+ return;
+
+ if (bPost)
+ {
+ aSuffix = aSymbol;
+ if (bShowSpace)
+ {
+ aSuffix = " " + aSuffix;
+ }
+
+ }
+
+ if (bNegative)
+ {
+ aSuffix += ")";
+ }
+}
+void LwpNumericFormat::SetNumberType(XFNumberStyle* pStyle)
+{
+ switch(cFormat)
+ {
+ case FMT_PERCENT:
+ {
+ pStyle->SetNumberType(enumXFNumberPercent);
+ }
+ break;
+
+ case FMT_COMMA:
+ {
+ pStyle->SetNumberType(enumXFNumberNumber);
+ pStyle->SetGroup();
+ }
+ break;
+ case FMT_SCIENTIFIC:
+ {
+ pStyle->SetNumberType(enumXFNumberScientific);
+ }
+ break;
+ case FMT_FIXED:
+ case FMT_GENERAL:
+ {
+ pStyle->SetNumberType(enumXFNumberNumber);
+ }
+ break;
+ default://including text type, which is not a style of number format in SODC
+ {
+ pStyle->SetNumberType(enumXFText);
+ }
+ break;
+ }
+}
+/**
+* Make the xml content of number format
+*/
+XFStyle* LwpNumericFormat::Convert()
+{
+ XFNumberStyle* pStyle = new XFNumberStyle;
+ OUString aPrefix, aSuffix,aNegPrefix,aNegSuffix;
+ LwpColor aColor, aNegativeColor;
+
+ if (IsCurrencyFormat(cFormat))
+ {
+ pStyle->SetNumberType(enuMXFNumberCurrency);
+ pStyle->SetGroup();
+ GetCurrencyStr(cAnyNumber, aPrefix, aSuffix);
+ GetCurrencyStr(cNegative, aNegPrefix, aNegSuffix,true);
+ }
+ else
+ {
+ SetNumberType(pStyle);
+ {//Anynumber
+ aPrefix = cAnyNumber.GetPrefix();
+ //Set suffix
+ aSuffix = cAnyNumber.GetSuffix();
+ //Set color
+ aColor = cAnyNumber.GetColor();
+ }
+
+ if (!IsNegativeOverridden())
+ {
+ aNegPrefix = aPrefix;
+ aNegSuffix = aSuffix;
+ aNegativeColor = aColor;
+ }
+ else
+ {//negative
+ aNegPrefix = cNegative.GetPrefix();
+ aNegSuffix = cNegative.GetSuffix();
+ aNegativeColor = cNegative.GetColor();
+ }
+ if (FMT_COMMA==cFormat)
+ {
+ if (cNegative.IsDefaultPrefix() && aNegPrefix.isEmpty())
+ {
+ aNegPrefix = "(";
+ }
+ if (cNegative.IsDefaultSuffix() && aNegSuffix.isEmpty())
+ {
+ aNegSuffix = ")";
+ }
+ }
+
+ }
+
+ pStyle->SetDecimalDigits(GetDecimalPlaces());
+
+ aPrefix = reencode(aPrefix);
+ aSuffix = reencode(aSuffix);
+ aNegPrefix = reencode(aNegPrefix);
+ aNegSuffix = reencode(aNegSuffix);
+
+ {//Anynumber
+ //Set prefix
+ pStyle->SetPrefix(aPrefix);
+ //Set suffix
+ pStyle->SetSurfix(aSuffix);
+ pStyle->SetColor( XFColor( static_cast<sal_uInt8>(aColor.GetRed()),
+ static_cast<sal_uInt8>(aColor.GetGreen()),
+ static_cast<sal_uInt8>(aColor.GetBlue())) );
+ }
+ {//Negative
+ pStyle->SetNegativeStyle( aNegPrefix, aNegSuffix, XFColor(static_cast<sal_uInt8>(aNegativeColor.GetRed()),
+ static_cast<sal_uInt8>(aNegativeColor.GetGreen()),
+ static_cast<sal_uInt8>(aNegativeColor.GetBlue())) );
+ }
+
+ return pStyle;
+}
+/**
+*
+* @description for SODC_2754
+* @return fix wrong encoding of POUND symbol
+*/
+OUString LwpNumericFormat::reencode(const OUString& sCode)
+{
+ const sal_Unicode * pString = sCode.getStr();
+ sal_uInt16 nLen = sCode.getLength();
+ bool bFound = false;
+ sal_Int32 i;
+ std::unique_ptr<sal_Unicode[]> pBuff( new sal_Unicode[sCode.getLength()] );
+
+ for (i=0; i< sCode.getLength() - 1; i++)
+ {
+ if ( (pString[i] == 0x00a1) && (pString[i+1] == 0x00ea))
+ {
+ bFound = true;
+ break;
+ }
+ pBuff[i] = pString[i];
+ }
+ if (bFound)
+ {
+ pBuff[i] = 0xffe1;
+ for (sal_Int32 j=i+1; j < sCode.getLength() - 1; ++j)
+ {
+ pBuff[j] = pString[j+1];
+ }
+ OUString sRet(pBuff.get(), nLen - 1);
+ return sRet;
+ }
+
+ return sCode;
+}
+
+sal_uInt16
+LwpNumericFormat::GetDefaultDecimalPlaces(sal_uInt16 Format)
+{
+ switch (Format)
+ {
+ case FMT_ARGENTINEANPESO:
+ case FMT_AUSTRALIANDOLLAR:
+ case FMT_AUSTRIANSCHILLING:
+ case FMT_BELGIANFRANC:
+ case FMT_BRAZILIANCRUZEIRO:
+ case FMT_BRITISHPOUND:
+ case FMT_CANADIANDOLLAR:
+ case FMT_CHINESEYUAN:
+ case FMT_CZECHKORUNA:
+ case FMT_DANISHKRONE:
+ case FMT_ECU:
+ case FMT_FINNISHMARKKA:
+ case FMT_FRENCHFRANC:
+ case FMT_GERMANMARK:
+ case FMT_HONGKONGDOLLAR:
+ case FMT_HUNGARIANFORINT:
+ case FMT_INDIANRUPEE:
+ case FMT_INDONESIANRUPIAH:
+ case FMT_IRISHPUNT:
+ case FMT_LUXEMBOURGFRANC:
+ case FMT_MALAYSIANRINGGIT:
+ case FMT_MEXICANPESO:
+ case FMT_NETHERLANDSGUILDER:
+ case FMT_NEWZEALANDDOLLAR:
+ case FMT_NORWEGIANKRONE:
+ case FMT_POLISHZLOTY:
+ case FMT_PORTUGUESEESCUDO:
+ case FMT_ROMANIANLEI:
+ case FMT_RUSSIANRUBLE:
+ case FMT_SINGAPOREDOLLAR:
+ case FMT_SLOVAKIANKORUNA:
+ case FMT_SLOVENIANTHOLAR:
+ case FMT_SOUTHAFRICANRAND:
+ case FMT_SOUTHKOREANWON:
+ case FMT_SWEDISHKRONA:
+ case FMT_SWISSFRANC:
+ case FMT_TAIWANDOLLAR:
+ case FMT_THAIBAHT:
+ case FMT_USDOLLAR:
+ case FMT_OTHERCURRENCY:
+ case FMT_EURO:
+ return 2;
+
+ case FMT_GREEKDRACHMA:
+ case FMT_ITALIANLIRA:
+ case FMT_JAPANESEYEN:
+ case FMT_SPANISHPESETA:
+ return 0;
+
+ case FMT_DEFAULT:
+ case FMT_GENERAL:
+ case FMT_FIXED:
+ case FMT_COMMA:
+ case FMT_PERCENT:
+ case FMT_SCIENTIFIC:
+ default:
+ return 2;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpnumericfmt.hxx b/lotuswordpro/source/filter/lwpnumericfmt.hxx
new file mode 100644
index 000000000..ef1af1da0
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpnumericfmt.hxx
@@ -0,0 +1,305 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table object
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
+
+#include <map>
+
+#include <lwpatomholder.hxx>
+#include <lwpcolor.hxx>
+#include "lwppiece.hxx"
+
+//For converting to xml
+#include <xfilter/xfnumberstyle.hxx>
+
+class LwpObjectStream;
+
+class LwpNumericFormatSubset final
+{
+public:
+ LwpNumericFormatSubset();
+ void QuickRead(LwpObjectStream* pStrm);
+ OUString const & GetPrefix() const { return cPrefix.str();}
+ OUString const & GetSuffix() const { return cSuffix.str();}
+ bool IsDefaultPrefix() const { return !(cSubFlags&SF_OVER_PREFIX); }
+ bool IsDefaultSuffix() const { return !(cSubFlags&SF_OVER_SUFFIX); }
+ LwpColor GetColor() const;
+
+private:
+ LwpColor cColor;
+ LwpAtomHolder cPrefix;
+ LwpAtomHolder cSuffix;
+ sal_uInt16 cSubFlags;
+
+ enum // for cSubFlags
+ {
+ SF_OVER_PREFIX = 0x0001,
+ SF_OVER_SUFFIX = 0x0002,
+ SF_OVER_COLOR = 0x0004
+ };
+};
+
+struct LwpCurrencyInfo
+{
+ OUString sSymbol;
+ bool bPost;
+ bool bShowSpace;
+ explicit LwpCurrencyInfo(const OUString& sSym)
+ : sSymbol(sSym), bPost(false), bShowSpace(false)
+ {
+ }
+ LwpCurrencyInfo() : bPost(false), bShowSpace(false)
+ {
+ }
+ LwpCurrencyInfo(const OUString& sSym, bool bPost_, bool bShowSpace_)
+ : sSymbol(sSym), bPost(bPost_), bShowSpace(bShowSpace_)
+ {
+ }
+};
+
+enum
+{
+ /* These are types of formats. They are mutually exclusive.
+ */
+ FMT_NONE = 0,
+ FMT_ARGENTINEANPESO = 1,
+ FMT_AUSTRALIANDOLLAR = 2,
+ FMT_AUSTRIANSCHILLING = 3,
+ FMT_BELGIANFRANC = 4,
+ FMT_BRAZILIANCRUZEIRO = 5,
+ FMT_BRITISHPOUND = 6,
+ FMT_CANADIANDOLLAR = 7,
+ FMT_CHINESEYUAN = 8,
+ FMT_CZECHKORUNA = 9,
+ FMT_DANISHKRONE = 10,
+ FMT_ECU = 11,
+ FMT_FINNISHMARKKA = 12,
+ FMT_FRENCHFRANC = 13,
+ FMT_GERMANMARK = 14,
+ FMT_GREEKDRACHMA = 15,
+ FMT_HONGKONGDOLLAR = 16,
+ FMT_HUNGARIANFORINT = 17,
+ FMT_INDIANRUPEE = 18,
+ FMT_INDONESIANRUPIAH = 19,
+ FMT_IRISHPUNT = 20,
+ FMT_ITALIANLIRA = 21,
+ FMT_JAPANESEYEN = 22,
+ FMT_LUXEMBOURGFRANC = 23,
+ FMT_MALAYSIANRINGGIT = 24,
+ FMT_MEXICANPESO = 25,
+ FMT_NETHERLANDSGUILDER = 26,
+ FMT_NEWZEALANDDOLLAR = 27,
+ FMT_NORWEGIANKRONE = 28,
+ FMT_POLISHZLOTY = 29,
+ FMT_PORTUGUESEESCUDO = 30,
+ FMT_ROMANIANLEI = 31,
+ FMT_RUSSIANRUBLE = 32,
+ FMT_SINGAPOREDOLLAR = 33,
+ FMT_SLOVAKIANKORUNA = 34,
+ FMT_SLOVENIANTHOLAR = 35,
+ FMT_SOUTHAFRICANRAND = 36,
+ FMT_SOUTHKOREANWON = 37,
+ FMT_SPANISHPESETA = 38,
+ FMT_SWEDISHKRONA = 39,
+ FMT_SWISSFRANC = 40,
+ FMT_TAIWANDOLLAR = 41,
+ FMT_THAIBAHT = 42,
+ FMT_USDOLLAR = 43,
+ FMT_OTHERCURRENCY = 44,
+ FMT_DEFAULT = 45,
+ FMT_GENERAL = 46,
+ FMT_FIXED = 47,
+ FMT_COMMA = 48,
+ FMT_PERCENT = 49,
+ FMT_SCIENTIFIC = 50,
+ FMT_LABEL = 51,
+ FMT_EURO = 52
+};
+
+class LwpCurrencyPool
+{
+public:
+ LwpCurrencyPool(){InitCurrencySymbol();}
+ OUString GetCurrencySymbol(sal_uInt16 nFormat);
+ bool IsShowSpace(sal_uInt16 nFormat);
+ bool IsSymbolPost(sal_uInt16 nFormat);
+
+private:
+ std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
+ void InitCurrencySymbol()
+ {
+ sal_uInt16 nC=FMT_ARGENTINEANPESO;
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A"); //FMT_ARGENTINEANPESO = 1,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A$"); //FMT_AUSTRALIANDOLLAR = 2,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC = 4,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO = 5,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE1")); //FMT_BRITISHPOUND = 6,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("C$"); //FMT_CANADIANDOLLAR = 7,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"PRC\uFFE5"),false,true); //FMT_CHINESEYUAN = 8,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA = 9,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE = 10,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU = 11,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA = 12,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC = 13,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK = 14,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA = 15,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("HK$"); //FMT_HONGKONGDOLLAR = 16,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT = 17,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE = 18,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"IR\uFFE1")); //FMT_IRISHPUNT = 20,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA = 21,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(u"\uFFE5")); //FMT_JAPANESEYEN = 22,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC = 23,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Mex$"); //FMT_MEXICANPESO = 25,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER = 26,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NZ$"); //FMT_NEWZEALANDDOLLAR = 27,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE = 28,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY = 29,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO = 30,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI = 31,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE = 32,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("S$"); //FMT_SINGAPOREDOLLAR = 33,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA = 34,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR = 35,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R"); //FMT_SOUTHAFRICANRAND = 36,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("W"); //FMT_SOUTHKOREANWON = 37,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA = 38,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA = 39,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC = 40,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NT$"); //FMT_TAIWANDOLLAR = 41,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT = 42,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("$"); //FMT_USDOLLAR = 43,
+ m_aCurrencyInfo[nC++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY = 44,
+
+ m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(OUString(u"\u20AC")); //FMT_EURO = 52
+ }
+};
+
+class LwpNumericFormat
+{
+public:
+ explicit LwpNumericFormat(LwpObjectStream * pStrm);
+ void Read();
+ static bool IsCurrencyFormat(sal_uInt16 Format);
+ sal_uInt16 GetDecimalPlaces();
+ bool IsDecimalPlacesOverridden() const;
+ bool IsNegativeOverridden() const;
+ XFStyle* Convert();
+
+private:
+ LwpObjectStream * m_pObjStrm;
+
+ sal_uInt16 cFlags;
+ enum // for cFlags
+ {
+ NF_OVER_ZERO = 0x0001,
+ NF_OVER_NEGATIVE = 0x0002,
+ NF_OVER_DECIMAL_PLACES = 0x0004
+ };
+
+ sal_uInt16 cFormat;
+
+ LwpNumericFormatSubset cAnyNumber;
+ LwpNumericFormatSubset cZero;
+ LwpNumericFormatSubset cNegative;
+
+ sal_uInt16 cDecimalPlaces;
+
+ static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
+ static LwpCurrencyPool m_aCurrencyInfo;
+
+ void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegative=false);
+ void SetNumberType(XFNumberStyle* pStyle);
+ static OUString reencode(const OUString& sCode);
+};
+
+inline bool
+LwpNumericFormat::IsDecimalPlacesOverridden() const
+{
+ return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
+}
+
+inline bool
+LwpNumericFormat::IsNegativeOverridden() const
+{
+ return (cFlags & NF_OVER_NEGATIVE) != 0;
+}
+
+class LwpLayoutNumerics final : public LwpVirtualPiece
+{
+public:
+ LwpLayoutNumerics(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm.get()){}
+ XFStyle* Convert();
+ virtual void Read() override;
+
+private:
+ virtual ~LwpLayoutNumerics() override {}
+
+ LwpNumericFormat cNumerics;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx
new file mode 100644
index 000000000..c480fd3d0
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <lwpobj.hxx>
+
+/**
+ * @descr construct lwpobject from stream
+ */
+LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
+ : m_ObjHdr(objHdr)
+ , m_pFoundry(nullptr)
+ , m_pStrm(pStrm)
+ , m_bRegisteringStyle(false)
+ , m_bParsingStyle(false)
+ , m_bConvertingContent(false)
+{
+ m_pObjStrm.reset(new LwpObjectStream(pStrm, m_ObjHdr.IsCompressed(),
+ static_cast<sal_uInt16>(m_ObjHdr.GetSize())));
+}
+/**
+ * @descr dtor()
+*/
+LwpObject::~LwpObject() {}
+/**
+ * @descr QuickRead template
+ */
+void LwpObject::QuickRead()
+{
+ Read();
+ if (m_pObjStrm)
+ {
+ m_pObjStrm->ReadComplete();
+ m_pObjStrm.reset();
+ }
+}
+/**
+ * @descr default read function
+ */
+void LwpObject::Read() {}
+/**
+ * @descr default parse function
+ */
+void LwpObject::Parse(IXFStream* /*pOutputStream*/) {}
+/**
+ * @descr default register style function
+ */
+void LwpObject::RegisterStyle() {}
+
+/**
+ * @descr default XFConvert function
+ * pCont is the XFContentContainer for the object conversion
+ */
+void LwpObject::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpobjfactory.cxx b/lotuswordpro/source/filter/lwpobjfactory.cxx
new file mode 100644
index 000000000..72db1c7a4
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpobjfactory.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpobjfactory.hxx>
+#include <lwpdefs.hxx>
+#include "lwpdoc.hxx"
+#include "lwpstory.hxx"
+#include "lwplayout.hxx"
+#include "lwppara.hxx"
+#include "lwpparastyle.hxx"
+#include "lwpcharacterstyle.hxx"
+#include "lwppiece.hxx"
+#include "lwptabrack.hxx"
+#include "lwpsilverbullet.hxx"
+#include "lwpdivinfo.hxx"
+#include "lwpholder.hxx"
+#include "lwpdivopts.hxx"
+#include "lwplaypiece.hxx"
+#include "lwpsection.hxx"
+#include "lwppagehint.hxx"
+#include "lwpoleobject.hxx"
+#include "lwpgrfobj.hxx"
+#include "lwptable.hxx"
+#include "lwptblcell.hxx"
+#include "lwpmarker.hxx"
+#include "lwpproplist.hxx"
+#include "lwpframelayout.hxx"
+#include "lwptablelayout.hxx"
+#include "lwppagelayout.hxx"
+#include "lwptblformula.hxx"
+#include "lwpvpointer.hxx"
+#include "lwpfootnote.hxx"
+#include "lwpnumericfmt.hxx"
+#include "lwpfnlayout.hxx"
+#include "lwptoc.hxx"
+#include <lwpdocdata.hxx>
+#include "lwpnotes.hxx"
+#include "lwpverdocument.hxx"
+#include <sal/log.hxx>
+#include <osl/diagnose.h>
+
+//LwpObjectFactory* LwpObjectFactory::m_pMgr = NULL;
+
+LwpObjectFactory::LwpObjectFactory(LwpSvStream* pSvStream)
+ : m_pSvStream(pSvStream)
+{
+ m_IdToObjList.clear();
+}
+
+LwpObjectFactory::~LwpObjectFactory() {}
+
+/**
+ * @descr read the index manager
+*/
+void LwpObjectFactory::ReadIndex(LwpSvStream* pStrm) { m_IndexMgr.Read(pStrm); }
+
+/**
+ * @descr create all kinds of objects except lwp7
+*/
+rtl::Reference<LwpObject> LwpObjectFactory::CreateObject(sal_uInt32 type, LwpObjectHeader& objHdr)
+{
+ rtl::Reference<LwpObject> newObj;
+ SAL_WARN_IF(type >= 300, "lwp", "invalid type: " << type);
+ switch (type)
+ {
+ case VO_DOCUMENT:
+ {
+ newObj = new LwpDocument(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_DOCSOCK:
+ {
+ newObj = new LwpDocSock(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_DIVISIONINFO:
+ {
+ newObj = new LwpDivInfo(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_DIVOPTS:
+ {
+ newObj = new LwpDivisionOptions(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_HEADCONTENT:
+ {
+ newObj = new LwpHeadContent(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_HEADLAYOUT:
+ {
+ newObj = new LwpHeadLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PAGELAYOUT:
+ {
+ newObj = new LwpPageLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_STORY:
+ {
+ newObj = new LwpStory(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PARA:
+ {
+ newObj = new LwpPara(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_HEADERLAYOUT:
+ {
+ newObj = new LwpHeaderLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOOTERLAYOUT:
+ {
+ newObj = new LwpFooterLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FRAMELAYOUT:
+ {
+ newObj = new LwpFrameLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTGEOMETRY:
+ {
+ newObj = new LwpLayoutGeometry(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTSCALE:
+ {
+ newObj = new LwpLayoutScale(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTMARGINS:
+ {
+ newObj = new LwpLayoutMargins(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTBORDERSTUFF:
+ {
+ newObj = new LwpLayoutBorder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTBACKGROUNDSTUFF:
+ {
+ newObj = new LwpLayoutBackground(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTEXTERNALBORDERSTUFF:
+ {
+ newObj = new LwpLayoutExternalBorder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTCOLUMNS:
+ {
+ newObj = new LwpLayoutColumns(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTGUTTERSTUFF:
+ {
+ newObj = new LwpLayoutGutters(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTJOINSTUFF:
+ {
+ newObj = new LwpLayoutJoins(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTSHADOW:
+ {
+ newObj = new LwpLayoutShadow(objHdr, m_pSvStream);
+ break;
+ }
+ // 01/12/2005
+ case VO_PARASTYLE:
+ {
+ newObj = new LwpParaStyle(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CHARACTERSTYLE:
+ {
+ newObj = new LwpCharacterStyle(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SILVERBULLET:
+ {
+ newObj = new LwpSilverBullet(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ALIGNMENTPIECE:
+ {
+ newObj = new LwpAlignmentPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_INDENTPIECE:
+ {
+ newObj = new LwpIndentPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SPACINGPIECE:
+ {
+ newObj = new LwpSpacingPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CHARBORDERPIECE:
+ {
+ newObj = new LwpCharacterBorderPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_AMIKAKEPIECE:
+ {
+ newObj = new LwpAmikakePiece(objHdr, m_pSvStream);
+ break;
+ }
+
+ case VO_HEADHOLDER:
+ {
+ newObj = new LwpDLVListHeadHolder(objHdr, m_pSvStream);
+ break;
+ }
+
+ // start
+ case VO_PARABORDERPIECE:
+ {
+ newObj = new LwpParaBorderPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_BREAKSPIECE:
+ {
+ newObj = new LwpBreaksPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_NUMBERINGPIECE:
+ {
+ newObj = new LwpNumberingPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABRACK:
+ {
+ newObj = new LwpTabRack(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABPIECE:
+ {
+ newObj = new LwpTabPiece(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PARABACKGROUNDPIECE: //perhaps wrong.
+ {
+ newObj = new LwpBackgroundPiece(objHdr, m_pSvStream);
+ break;
+ }
+
+ case VO_SECTION:
+ {
+ newObj = new LwpSection(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_INDEXSECTION:
+ {
+ newObj = new LwpIndexSection(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_HEADTAILHOLDER:
+ {
+ newObj = new LwpDLVListHeadTailHolder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PAGEHINT:
+ {
+ newObj = new LwpPageHint(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_OLEOBJECT:
+ {
+ newObj = new LwpOleObject(objHdr, m_pSvStream);
+ break;
+ }
+
+ case VO_GRAPHIC:
+ {
+ newObj = new LwpGraphicObject(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_DOCDATA:
+ {
+ newObj = new LwpDocData(objHdr, m_pSvStream);
+ break;
+ }
+
+ case VO_DROPCAPLAYOUT:
+ {
+ newObj = new LwpDropcapLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTRELATIVITY:
+ {
+ newObj = new LwpLayoutRelativity(objHdr, m_pSvStream);
+ break;
+ }
+ // for table
+ case VO_TABLE:
+ {
+ newObj = new LwpTable(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABLELAYOUT:
+ {
+ newObj = new LwpTableLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SUPERTABLE:
+ {
+ newObj = new LwpSuperTable(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SUPERTABLELAYOUT:
+ {
+ newObj = new LwpSuperTableLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CELLLAYOUT:
+ {
+ newObj = new LwpCellLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ROWLAYOUT:
+ {
+ newObj = new LwpRowLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LAYOUTNUMERICS:
+ {
+ newObj = new LwpLayoutNumerics(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_NUMERICVALUE:
+ {
+ newObj = new LwpNumericValue(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FORMULAINFO:
+ {
+ newObj = new LwpFormulaInfo(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_COLUMNLAYOUT:
+ {
+ newObj = new LwpColumnLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ROWLIST:
+ {
+ newObj = new LwpRowList(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CELLLIST:
+ {
+ newObj = new LwpCellList(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABLERANGE:
+ {
+ newObj = new LwpTableRange(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CELLRANGE:
+ {
+ newObj = new LwpCellRange(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOLDER:
+ {
+ newObj = new LwpFolder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_DEPENDENT:
+ {
+ newObj = new LwpDependent(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CONNECTEDCELLLAYOUT:
+ {
+ newObj = new LwpConnectedCellLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_HIDDENCELLLAYOUT:
+ {
+ newObj = new LwpHiddenCellLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABLEHEADINGLAYOUT:
+ {
+ newObj = new LwpTableHeadingLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ROWHEADINGLAYOUT:
+ {
+ newObj = new LwpRowHeadingLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TABLEHEADING:
+ {
+ newObj = new LwpTableHeading(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CHBLKMARKER:
+ {
+ newObj = new LwpCHBlkMarker(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PROPLIST:
+ {
+ newObj = new LwpPropListElement(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_BOOKMARK:
+ {
+ newObj = new LwpBookMark(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FIELDMARKER:
+ {
+ newObj = new LwpFieldMark(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_OBJECTHOLDER:
+ {
+ newObj = new LwpObjectHolder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_POBJECTHOLDER:
+ {
+ newObj = new LwpObjectHolder(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_VERGTR: //fall through
+ case VO_VERQTR:
+ {
+ newObj = new LwpVersionedPointer(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOOTNOTE:
+ {
+ newObj = new LwpFootnote(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOOTNOTETABLE:
+ {
+ newObj = new LwpFootnoteTable(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOOTNOTEOPTS:
+ {
+ newObj = new LwpFootnoteOptions(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FOOTNOTELAYOUT:
+ {
+ newObj = new LwpFootnoteLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FNROWLAYOUT:
+ {
+ newObj = new LwpFnRowLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FNCELLLAYOUT:
+ {
+ newObj = new LwpFnCellLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ENDNOTELAYOUT:
+ {
+ newObj = new LwpEndnoteLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_ENSUPERTABLELAYOUT:
+ {
+ newObj = new LwpEnSuperTableLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_FNSUPERTABLELAYOUT:
+ {
+ newObj = new LwpFnSuperTableLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CONTONLAYOUT:
+ {
+ newObj = new LwpContOnLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_CONTFROMLAYOUT:
+ {
+ newObj = new LwpContFromLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_GROUPLAYOUT:
+ {
+ newObj = new LwpGroupLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_GROUPFRAME:
+ {
+ newObj = new LwpGroupFrame(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TOCSUPERTABLELAYOUT:
+ {
+ newObj = new LwpTocSuperLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_LISTLIST:
+ {
+ newObj = new LwpListList(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_TOCLEVELDATA:
+ {
+ newObj = new LwpTocLevelData(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_NOTELAYOUT:
+ {
+ newObj = new LwpNoteLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_NOTEHEADERLAYOUT:
+ {
+ newObj = new LwpNoteHeaderLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_NOTETEXTLAYOUT:
+ {
+ newObj = new LwpNoteTextLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_VPLAYOUT:
+ {
+ newObj = new LwpViewportLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PCOLBLOCK:
+ {
+ newObj = new LwpParallelColumnsBlock(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SUPERPARALLELCOLUMNLAYOUT:
+ {
+ newObj = new LwpSuperParallelColumnLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PCOLLAYOUT:
+ {
+ newObj = new LwpParallelColumnsLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_PARALLELCOLUMNS:
+ {
+ newObj = new LwpParallelColumns(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_RUBYMARKER:
+ {
+ newObj = new LwpRubyMarker(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_RUBYLAYOUT:
+ {
+ newObj = new LwpRubyLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_GLOSSARY:
+ {
+ newObj = new LwpGlossary(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_SUPERGLOSSARYLAYOUT:
+ {
+ newObj = new LwpSuperGlossaryLayout(objHdr, m_pSvStream);
+ break;
+ }
+ case VO_VERDOCUMENT:
+ {
+ newObj = new LwpVerDocument(objHdr, m_pSvStream);
+ break;
+ }
+ default:
+ {
+ //Unknown object type
+ newObj = nullptr;
+ break;
+ }
+ }
+ if (newObj.is())
+ {
+ newObj->QuickRead();
+ auto result = m_IdToObjList.emplace(objHdr.GetID(), newObj);
+ if (!result.second)
+ {
+ SAL_WARN("lwp", "clearing duplicate object");
+ newObj.clear();
+ }
+ }
+
+ return newObj;
+}
+/**
+ * @descr query object by object id
+ * object is created if not in the factory
+*/
+rtl::Reference<LwpObject> LwpObjectFactory::QueryObject(const LwpObjectID& objID)
+{
+ rtl::Reference<LwpObject> obj = FindObject(objID);
+ if (!obj.is())
+ {
+ //Read the object from file
+ sal_uInt32 nStreamOffset = m_IndexMgr.GetObjOffset(objID);
+ if (nStreamOffset == BAD_OFFSET) //does not find the offset in index manager
+ return nullptr;
+
+ sal_Int64 nDesiredPos = nStreamOffset + LwpSvStream::LWP_STREAM_BASE;
+ if (nDesiredPos != m_pSvStream->Seek(nDesiredPos))
+ return nullptr;
+ LwpObjectHeader objHdr;
+ if (!objHdr.Read(*m_pSvStream))
+ return nullptr;
+
+ LwpObjectID& rId = objHdr.GetID();
+ if (rId != objID)
+ {
+ OSL_FAIL("apparently incorrect objid, invalidating");
+ return nullptr;
+ }
+
+ if (std::find(m_aObjsIDInCreation.begin(), m_aObjsIDInCreation.end(), objID)
+ != m_aObjsIDInCreation.end())
+ throw std::runtime_error("recursion in object creation");
+
+ m_aObjsIDInCreation.push_back(objID);
+ obj = CreateObject(objHdr.GetTag(), objHdr);
+ m_aObjsIDInCreation.pop_back();
+ }
+ return obj;
+}
+
+/**
+ * @descr find object in the factory per the object id
+*/
+rtl::Reference<LwpObject> LwpObjectFactory::FindObject(const LwpObjectID& objID)
+{
+ LwpIdToObjMap::const_iterator it = m_IdToObjList.find(objID);
+ if (it != m_IdToObjList.end())
+ {
+ return (*it).second;
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+/**
+ * @descr release object in the factory per the object id
+*/
+void LwpObjectFactory::ReleaseObject(const LwpObjectID& objID) { m_IdToObjList.erase(objID); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpobjhdr.cxx b/lotuswordpro/source/filter/lwpobjhdr.cxx
new file mode 100644
index 000000000..d8474525e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpobjhdr.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpobjhdr.hxx>
+#include <lwpobjtags.hxx>
+#include <lwpdefs.hxx>
+#include <lwpfilehdr.hxx>
+
+LwpObjectHeader::LwpObjectHeader()
+ : m_nTag(0)
+ , m_nSize(0)
+ , m_bCompressed(false)
+{
+}
+/**
+ * @descr read header from stream
+ */
+bool LwpObjectHeader::Read(LwpSvStream& rStrm)
+{
+ sal_uInt32 nVersionID = 0;
+ sal_uInt32 nRefCount = 0;
+ sal_uInt32 nNextVersionOffset = 0;
+ sal_uInt32 nHeaderSize = 0;
+
+ sal_Int64 nStartPos = rStrm.Tell();
+
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ rStrm.ReadUInt32(m_nTag);
+ m_ID.Read(&rStrm);
+ rStrm.ReadUInt32(nVersionID);
+ rStrm.ReadUInt32(nRefCount);
+ rStrm.ReadUInt32(nNextVersionOffset);
+
+ nHeaderSize = sizeof(m_nTag) + LwpObjectID::DiskSize() + sizeof(nVersionID)
+ + sizeof(nRefCount) + sizeof(nNextVersionOffset) + sizeof(m_nSize);
+
+ if ((m_nTag == TAG_AMI) || (LwpFileHeader::m_nFileRevision < 0x0006))
+ {
+ sal_uInt32 nNextVersionID = 0;
+ rStrm.ReadUInt32(nNextVersionID);
+ nHeaderSize += sizeof(nNextVersionID);
+ }
+ rStrm.ReadUInt32(m_nSize);
+ }
+ else
+ {
+ sal_uInt8 nFlagBits = 0;
+ sal_uInt16 VOType = 0;
+ if (rStrm.remainingSize() < 3)
+ return false;
+ rStrm.ReadUInt16(VOType);
+ rStrm.ReadUInt8(nFlagBits);
+
+ m_nTag = static_cast<sal_uInt32>(VOType);
+ m_ID.ReadIndexed(&rStrm);
+ nHeaderSize = sizeof(VOType) + sizeof(nFlagBits) + m_ID.DiskSizeIndexed();
+
+ sal_uInt8 tmpByte;
+ sal_uInt16 tmpShort;
+ switch (nFlagBits & VERSION_BITS)
+ {
+ case ONE_BYTE_VERSION:
+ rStrm.ReadUInt8(tmpByte);
+ nVersionID = static_cast<sal_uInt32>(tmpByte);
+ nHeaderSize++;
+ break;
+
+ case TWO_BYTE_VERSION:
+ rStrm.ReadUInt16(tmpShort);
+ nVersionID = static_cast<sal_uInt32>(tmpShort);
+ nHeaderSize += 2;
+ break;
+
+ case FOUR_BYTE_VERSION:
+ rStrm.ReadUInt32(nVersionID);
+ nHeaderSize += 4;
+ break;
+ case DEFAULT_VERSION: //fall through
+ default:
+ nVersionID = 2;
+ break; // nothing
+ }
+
+ switch (nFlagBits & REFCOUNT_BITS)
+ {
+ case ONE_BYTE_REFCOUNT:
+ rStrm.ReadUInt8(tmpByte);
+ nRefCount = static_cast<sal_uInt32>(tmpByte);
+ nHeaderSize++;
+ break;
+
+ case TWO_BYTE_REFCOUNT:
+ rStrm.ReadUInt16(tmpShort);
+ nRefCount = static_cast<sal_uInt32>(tmpShort);
+ nHeaderSize += 2;
+ break;
+
+ case FOUR_BYTE_REFCOUNT: //through
+ default:
+ rStrm.ReadUInt32(nRefCount);
+ nHeaderSize += 4;
+ break;
+ }
+
+ if (nFlagBits & HAS_PREVOFFSET)
+ {
+ rStrm.ReadUInt32(nNextVersionOffset);
+ nHeaderSize += 4;
+ }
+ else
+ nNextVersionOffset = BAD_OFFSET;
+
+ switch (nFlagBits & SIZE_BITS)
+ {
+ case ONE_BYTE_SIZE:
+ rStrm.ReadUInt8(tmpByte);
+ m_nSize = static_cast<sal_uInt32>(tmpByte);
+ nHeaderSize++;
+ break;
+
+ case TWO_BYTE_SIZE:
+ rStrm.ReadUInt16(tmpShort);
+ m_nSize = static_cast<sal_uInt32>(tmpShort);
+ nHeaderSize += 2;
+ break;
+
+ case FOUR_BYTE_SIZE: //go through
+ default:
+ rStrm.ReadUInt32(m_nSize);
+ nHeaderSize += 4;
+ break;
+ }
+
+ if (nFlagBits & DATA_COMPRESSED)
+ {
+ m_bCompressed = true;
+ }
+ }
+ sal_Int64 nEndPos = rStrm.Tell();
+ return rStrm.good() && (nStartPos + nHeaderSize == nEndPos);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpobjid.cxx b/lotuswordpro/source/filter/lwpobjid.cxx
new file mode 100644
index 000000000..a0a278ec5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpobjid.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpobjid.hxx>
+#include <lwpfilehdr.hxx>
+#include <lwpobjfactory.hxx>
+#include <lwpglobalmgr.hxx>
+
+LwpObjectID::LwpObjectID()
+ : m_nLow(0)
+ , m_nHigh(0)
+ , m_nIndex(0)
+ , m_bIsCompressed(false)
+{
+}
+/**
+ * @descr Read object id with format: low(4bytes)+high(2bytes) from stream
+ * for LWP7 record
+*/
+void LwpObjectID::Read(LwpSvStream* pStrm)
+{
+ pStrm->ReadUInt32(m_nLow);
+ pStrm->ReadUInt16(m_nHigh);
+}
+/**
+ * @descr Read object id with format: low(4bytes)+high(2bytes) from object stream
+*/
+sal_uInt32 LwpObjectID::Read(LwpObjectStream* pObj)
+{
+ m_nLow = pObj->QuickReaduInt32();
+ m_nHigh = pObj->QuickReaduInt16();
+ return DiskSize();
+}
+/**
+ * @descr Read object id with indexed format from stream
+ * if index>0, lowid is get from time table per the index
+* else index+lowid+highid
+*/
+void LwpObjectID::ReadIndexed(LwpSvStream* pStrm)
+{
+ //note the m_nLow store the index instead of time from the timetable as in LWP
+ m_bIsCompressed = false;
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ Read(pStrm);
+ return;
+ }
+
+ pStrm->ReadUInt8(m_nIndex);
+
+ if (m_nIndex)
+ {
+ m_bIsCompressed = true;
+ //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
+ LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
+ m_nLow = rIdxMgr.GetObjTime(static_cast<sal_uInt16>(m_nIndex));
+ }
+ else
+ {
+ pStrm->ReadUInt32(m_nLow);
+ }
+ pStrm->ReadUInt16(m_nHigh);
+ DiskSizeIndexed();
+}
+
+/**
+ * @descr Read object id with indexed format from object stream
+ * if index>0, lowid is get from time table per the index
+* else index+lowid+highid
+*/
+sal_uInt32 LwpObjectID::ReadIndexed(LwpObjectStream* pStrm)
+{
+ m_bIsCompressed = false;
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ return Read(pStrm);
+ }
+
+ m_nIndex = pStrm->QuickReaduInt8();
+ if (m_nIndex)
+ {
+ m_bIsCompressed = true;
+ //m_nLow = index; //note the m_nLow stores the index instead of the actual time id
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpObjectFactory* pFactory = pGlobal->GetLwpObjFactory();
+ LwpIndexManager& rIdxMgr = pFactory->GetIndexManager();
+ m_nLow = rIdxMgr.GetObjTime(static_cast<sal_uInt16>(m_nIndex));
+ }
+ else
+ m_nLow = pStrm->QuickReaduInt32();
+ m_nHigh = pStrm->QuickReaduInt16();
+ return DiskSizeIndexed();
+}
+/**
+ * @descr Read object id with compressed format from object stream
+ * if diff == 255: 255+lowid+highid
+ * else lowid equals to the lowid of previous low id
+ * and high id = the high id of previous id + diff +1
+*/
+void LwpObjectID::ReadCompressed(LwpObjectStream* pObj, LwpObjectID const& prev)
+{
+ sal_uInt8 diff = pObj->QuickReaduInt8();
+
+ if (diff == 255)
+ {
+ Read(pObj);
+ }
+ else
+ {
+ m_nLow = prev.GetLow();
+ m_nHigh = prev.GetHigh() + diff + 1;
+ }
+}
+/**
+ * @descr return the size of indexed object id
+*/
+sal_uInt32 LwpObjectID::DiskSizeIndexed() const
+{
+ return sizeof(sal_uInt8) + ((m_nIndex != 0) ? 0 : sizeof(m_nLow)) + sizeof(m_nHigh);
+}
+/**
+ * @descr get object from object factory per the object id
+*/
+rtl::Reference<LwpObject> LwpObjectID::obj(VO_TYPE tag) const
+{
+ if (IsNull())
+ {
+ return nullptr;
+ }
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
+ rtl::Reference<LwpObject> pObj = pObjMgr->QueryObject(*this);
+ if (tag != VO_INVALID && (pObj.is()))
+ {
+ if (static_cast<sal_uInt32>(tag) != pObj->GetTag())
+ {
+ pObj.clear();
+ }
+ }
+ return pObj;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpobjstrm.cxx b/lotuswordpro/source/filter/lwpobjstrm.cxx
new file mode 100644
index 000000000..728e3a71f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpobjstrm.cxx
@@ -0,0 +1,369 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <lwpobjstrm.hxx>
+#include <lwptools.hxx>
+
+#include <sal/types.h>
+#include <tools/solar.h>
+#include <memory>
+
+/**
+ * @descr ctor() from LwpSvStream
+ */
+LwpObjectStream::LwpObjectStream(LwpSvStream* pStrm, bool isCompressed, sal_uInt16 size)
+ : m_pContentBuf(nullptr)
+ , m_nBufSize(size)
+ , m_nReadPos(0)
+ , m_pStrm(pStrm)
+ , m_bCompressed(isCompressed)
+{
+ if (m_nBufSize >= IO_BUFFERSIZE)
+ throw std::range_error("bad Object size");
+ // read object data from stream
+ if (m_nBufSize > 0)
+ Read2Buffer();
+}
+
+/**
+ * @descr read object data from stream to buffer
+ */
+void LwpObjectStream::Read2Buffer()
+{
+ ReleaseBuffer();
+
+ m_nReadPos = 0;
+
+ if (m_bCompressed)
+ {
+ std::unique_ptr<sal_uInt8[]> xCompressBuf(new sal_uInt8[m_nBufSize]);
+
+ sal_uInt8* pCompressBuffer = xCompressBuf.get();
+ memset(pCompressBuffer, 0, m_nBufSize);
+ m_nBufSize = m_pStrm->Read(pCompressBuffer, m_nBufSize);
+
+ sal_uInt8 pTempDst[IO_BUFFERSIZE];
+ m_nBufSize = DecompressBuffer(pTempDst, pCompressBuffer, m_nBufSize);
+ assert(m_nBufSize < IO_BUFFERSIZE);
+
+ m_pContentBuf = AllocBuffer(m_nBufSize);
+ memcpy(m_pContentBuf, pTempDst, m_nBufSize);
+ }
+ else
+ {
+ m_pContentBuf = AllocBuffer(m_nBufSize);
+ m_nBufSize = m_pStrm->Read(m_pContentBuf, m_nBufSize);
+ }
+}
+/**
+ * @descr alloc size of buffer
+ */
+sal_uInt8* LwpObjectStream::AllocBuffer(sal_uInt16 size)
+{
+ if (size <= 100)
+ {
+ return m_SmallBuffer;
+ }
+ m_BigBuffer.resize(size);
+ return m_BigBuffer.data();
+}
+/**
+ * @descr signal complete to release object buffer
+ */
+void LwpObjectStream::ReadComplete() { ReleaseBuffer(); }
+
+LwpObjectStream::~LwpObjectStream() { ReleaseBuffer(); }
+/**
+ * @descr release object buffer
+ */
+void LwpObjectStream::ReleaseBuffer()
+{
+ m_BigBuffer.clear();
+ m_pContentBuf = nullptr;
+}
+
+sal_uInt16 LwpObjectStream::remainingSize() const { return m_nBufSize - m_nReadPos; }
+
+/**
+ * @descr read len bytes from object stream to buffer
+ */
+sal_uInt16 LwpObjectStream::QuickRead(void* buf, sal_uInt16 len)
+{
+ memset(buf, 0, len);
+ if (len > m_nBufSize - m_nReadPos)
+ {
+ len = m_nBufSize - m_nReadPos;
+ }
+ if (m_pContentBuf && len)
+ {
+ memcpy(buf, m_pContentBuf + m_nReadPos, len);
+ m_nReadPos += len;
+ }
+ return len;
+}
+/**
+ * @descr SeekRel pos in object stream/buffer
+ */
+void LwpObjectStream::SeekRel(sal_uInt16 pos)
+{
+ if (pos > m_nBufSize - m_nReadPos)
+ pos = m_nBufSize - m_nReadPos;
+ m_nReadPos += pos;
+}
+/**
+ * @descr Seek to pos in object buffer/buffer
+ */
+void LwpObjectStream::Seek(sal_uInt16 pos)
+{
+ if (pos < m_nBufSize)
+ {
+ m_nReadPos = pos;
+ }
+}
+
+/**
+ * @descr Quick read sal_Bool
+ */
+bool LwpObjectStream::QuickReadBool()
+{
+ SVBT16 aValue = { 0 };
+ QuickRead(aValue, sizeof(aValue));
+ return static_cast<bool>(SVBT16ToUInt16(aValue));
+}
+/**
+ * @descr Quick read sal_uInt32
+ */
+sal_uInt32 LwpObjectStream::QuickReaduInt32(bool* pFailure)
+{
+ SVBT32 aValue = { 0 };
+ sal_uInt16 nRead = QuickRead(aValue, sizeof(aValue));
+ if (pFailure)
+ *pFailure = (nRead != sizeof(aValue));
+ return SVBT32ToUInt32(aValue);
+}
+/**
+ * @descr Quick read sal_uInt32
+ */
+sal_uInt16 LwpObjectStream::QuickReaduInt16(bool* pFailure)
+{
+ SVBT16 aValue = { 0 };
+ sal_uInt16 nRead = QuickRead(aValue, sizeof(aValue));
+ if (pFailure)
+ *pFailure = (nRead != sizeof(aValue));
+ return SVBT16ToUInt16(aValue);
+}
+/**
+ * @descr Quick read sal_Int32
+ */
+sal_Int32 LwpObjectStream::QuickReadInt32()
+{
+ SVBT32 aValue = { 0 };
+ QuickRead(aValue, sizeof(aValue));
+ return static_cast<sal_Int32>(SVBT32ToUInt32(aValue));
+}
+/**
+ * @descr Quick read sal_Int16
+ */
+sal_Int16 LwpObjectStream::QuickReadInt16()
+{
+ SVBT16 aValue = { 0 };
+ QuickRead(aValue, sizeof(aValue));
+
+ return static_cast<sal_Int16>(SVBT16ToUInt16(aValue));
+}
+/**
+ * @descr Quick read sal_uInt8
+ */
+sal_uInt8 LwpObjectStream::QuickReaduInt8(bool* pFailure)
+{
+ sal_uInt8 aValue = 0;
+ sal_uInt16 nRead = QuickRead(&aValue, sizeof(aValue));
+ if (pFailure)
+ *pFailure = (nRead != sizeof(aValue));
+ return aValue;
+}
+/**
+ * @descr Quick read double
+ */
+double LwpObjectStream::QuickReadDouble()
+{
+ union {
+ double d;
+ sal_uInt8 c[8];
+ } s;
+ memset(s.c, 0, sizeof(s.c));
+ QuickRead(s.c, sizeof(s.c));
+#if defined(OSL_BIGENDIAN)
+ for (size_t i = 0; i < 4; ++i)
+ std::swap(s.c[i], s.c[7 - i]);
+#endif
+ return s.d;
+}
+/**
+ * @descr skip extra bytes
+ */
+void LwpObjectStream::SkipExtra()
+{
+ sal_uInt16 extra = QuickReaduInt16();
+ while (extra != 0)
+ extra = QuickReaduInt16();
+}
+/**
+ * @descr check if extra bytes
+ */
+sal_uInt16 LwpObjectStream::CheckExtra() { return QuickReaduInt16(); }
+/**
+ * @descr decompress data buffer from pSrc to pDst
+ * Refer to the CAmiPro40File::DecompressObject(~) in LWP
+ */
+sal_uInt16 LwpObjectStream::DecompressBuffer(sal_uInt8* pDst, sal_uInt8* pSrc, sal_uInt16 Size)
+{
+ sal_uInt16 Cnt;
+ sal_uInt32 DstSize = 0;
+
+ while (Size)
+ {
+ switch (*pSrc & 0xC0)
+ {
+ case 0x00:
+ // 1 - 64 bytes of 0
+ // Code 00zzzzzz
+ // where zzzzzz is the count - 1 of compressed 0 bytes
+
+ Cnt = (*pSrc++ & 0x3F) + 1;
+ if (DstSize + Cnt >= IO_BUFFERSIZE)
+ throw BadDecompress();
+ memset(pDst, 0, Cnt);
+ pDst += Cnt;
+ DstSize += Cnt;
+ Size--;
+ break;
+
+ case 0x40:
+ // 1 - 8 zeros followed by 1 - 8 non-zero
+ // Code 01zzznnn binary
+ // where zzz is the count - 1 of compressed zero bytes
+ // and nnn is the count - 1 of following non-zero bytes
+
+ Cnt = ((*pSrc & 0x38) >> 3) + 1;
+ if (DstSize + Cnt >= IO_BUFFERSIZE)
+ throw BadDecompress();
+ memset(pDst, 0, Cnt);
+ pDst += Cnt;
+ DstSize += Cnt;
+ Cnt = (*pSrc++ & 0x07) + 1;
+ if (Size < Cnt + 1)
+ throw BadDecompress();
+ Size -= Cnt + 1;
+ if (DstSize + Cnt >= IO_BUFFERSIZE)
+ throw BadDecompress();
+ memcpy(pDst, pSrc, Cnt);
+ pDst += Cnt;
+ DstSize += Cnt;
+ pSrc += Cnt;
+ break;
+
+ case 0x80:
+ // 1 0 followed by 1 - 64 bytes of non-zero
+ // Code 0x80 (or 0x40 if 8 or less non-zero)
+ // Code 10nnnnnn binary
+ // where nnnnnn is the count - 1 of following non-zero bytes
+
+ *pDst++ = 0;
+ DstSize++;
+ [[fallthrough]];
+
+ case 0xC0:
+ // 1 - 64 bytes of non-zero
+ // Code = 11nnnnnn binary
+ // nnnnnn is the count less 1 of following non-zero bytes
+
+ Cnt = (*pSrc++ & 0x3F) + 1;
+ if (Size < Cnt + 1)
+ throw BadDecompress();
+ Size -= Cnt + 1;
+ if (DstSize + Cnt >= IO_BUFFERSIZE)
+ throw BadDecompress();
+ memcpy(pDst, pSrc, Cnt);
+ pDst += Cnt;
+ DstSize += Cnt;
+ pSrc += Cnt;
+ break;
+ }
+ assert(DstSize < IO_BUFFERSIZE);
+ if (DstSize >= IO_BUFFERSIZE)
+ throw BadDecompress();
+ }
+ return static_cast<sal_uInt16>(DstSize);
+}
+/**
+ * @descr quick read string with 1252
+ */
+OUString LwpObjectStream::QuickReadStringPtr()
+{
+ sal_uInt16 diskSize;
+
+ diskSize = QuickReaduInt16();
+ QuickReaduInt16(); //len
+
+ OUString str;
+ if (diskSize < sizeof diskSize)
+ throw std::range_error("Too small size");
+ LwpTools::QuickReadUnicode(this, str, diskSize - sizeof(diskSize), RTL_TEXTENCODING_MS_1252);
+ return str;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpoleobject.cxx b/lotuswordpro/source/filter/lwpoleobject.cxx
new file mode 100644
index 000000000..10712e294
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpoleobject.cxx
@@ -0,0 +1,254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - OLE object
+ */
+
+#include <lwpfilehdr.hxx>
+#include "lwpoleobject.hxx"
+#include "lwpframelayout.hxx"
+#include <o3tl/numeric.hxx>
+
+/**
+ * @descr: construction function
+ * @param: objHdr - object header, read before entering this function
+ * @param: pStrm - file stream
+ */
+LwpGraphicOleObject::LwpGraphicOleObject(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+{
+}
+/**
+ * @descr: Read GraphicOleObject part
+ */
+void LwpGraphicOleObject::Read()
+{
+ LwpContent::Read();
+
+ if (LwpFileHeader::m_nFileRevision >= 0x000b)
+ {
+ // I'm not sure about the read method
+ m_pNextObj.ReadIndexed(m_pObjStrm.get());
+ m_pPrevObj.ReadIndexed(m_pObjStrm.get());
+ }
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpGraphicOleObject::GetGrafOrgSize(double& rWidth, double& rHeight)
+{
+ rWidth = 0;
+ rHeight = 0;
+}
+
+void LwpGraphicOleObject::GetGrafScaledSize(double& fWidth, double& fHeight)
+{
+ GetGrafOrgSize(fWidth, fHeight);
+ // scaled image size
+ double fSclGrafWidth = fWidth; //LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
+ double fSclGrafHeight
+ = fHeight; //LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
+
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ if (xLayout.is() && xLayout->IsFrame())
+ {
+ LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(xLayout.get());
+ LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
+ LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
+
+ // original image size
+ //double fOrgGrafWidth = (double)m_Cache.Width/TWIPS_PER_CM;
+ //double fOrgGrafHeight = (double)m_Cache.Height/TWIPS_PER_CM;
+
+ // get margin values
+ double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
+ double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT);
+ double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
+ double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
+
+ if (pMyScale && pFrameGeo)
+ {
+ // frame size
+ double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
+ double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
+
+ // calculate the displayed size of the frame
+ double fDisFrameWidth = fFrameWidth - (fLeftMargin + fRightMargin);
+ double fDisFrameHeight = fFrameHeight - (fTopMargin + fBottomMargin);
+
+ // get scale mode
+ sal_uInt16 nScalemode = pMyScale->GetScaleMode();
+ if (nScalemode & LwpLayoutScale::CUSTOM)
+ {
+ fSclGrafWidth = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
+ fSclGrafHeight = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
+ }
+ else if (nScalemode & LwpLayoutScale::PERCENTAGE)
+ {
+ double fScalePercentage
+ = static_cast<double>(pMyScale->GetScalePercentage()) / 1000;
+ fSclGrafWidth = fScalePercentage * fWidth;
+ fSclGrafHeight = fScalePercentage * fHeight;
+ }
+ else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
+ {
+ if (pMyFrameLayout->IsFitGraphic())
+ {
+ fSclGrafWidth = fWidth;
+ fSclGrafHeight = fHeight;
+ }
+ else if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
+ {
+ if (fHeight == 0.0 || fDisFrameHeight == 0.0)
+ throw o3tl::divide_by_zero();
+ if (fWidth / fHeight >= fDisFrameWidth / fDisFrameHeight)
+ {
+ fSclGrafWidth = fDisFrameWidth;
+ if (fWidth == 0.0)
+ throw o3tl::divide_by_zero();
+ fSclGrafHeight = (fDisFrameWidth / fWidth) * fHeight;
+ }
+ else
+ {
+ fSclGrafHeight = fDisFrameHeight;
+ fSclGrafWidth = (fDisFrameHeight / fHeight) * fWidth;
+ }
+ }
+ else
+ {
+ fSclGrafWidth = fDisFrameWidth;
+ fSclGrafHeight = fDisFrameHeight;
+ }
+ }
+ }
+ }
+ fWidth = fSclGrafWidth;
+ fHeight = fSclGrafHeight;
+}
+
+/**
+ * @descr: construction function
+ * @param: objHdr - object header, read before entering this function
+ * @param: pStrm - file stream
+ */
+LwpOleObject::LwpOleObject(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpGraphicOleObject(objHdr, pStrm)
+ , cPersistentFlags(0)
+ , m_SizeRect(0, 0, 5, 5)
+{
+}
+/**
+ * @descr: Read VO_OLEOBJECT record
+ */
+void LwpOleObject::Read()
+{
+ LwpGraphicOleObject::Read();
+
+ cPersistentFlags = m_pObjStrm->QuickReaduInt16();
+
+ // qCMarker read
+
+ if (LwpFileHeader::m_nFileRevision >= 0x0004)
+ {
+ LwpObjectID ID;
+ m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->QuickReadStringPtr();
+
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ // null pointers have a VO_INVALID type
+ //if (VO_INVALID == m_pObjStrm->QuickReaduInt16())
+ // return;
+
+ ID.Read(m_pObjStrm.get());
+ //return m_pObjStrm->Locate(ID);
+ }
+ else
+ {
+ ID.ReadIndexed(m_pObjStrm.get());
+ //if (ID.IsNull())
+ // return;
+
+ //return m_pObjStrm->Locate(ID);
+ }
+ }
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+/**
+ * @descr: Parse VO_OLEOBJECT and dump to XML stream only on WIN32 platform
+ * @param: pOutputStream - stream to dump OLE object
+ * @param: pFrameLayout - framelayout object used to dump OLE object
+ */
+void LwpOleObject::Parse(IXFStream* /*pOutputStream*/) {}
+
+void LwpOleObject::XFConvert(XFContentContainer* /*pCont*/) {}
+
+void LwpOleObject::GetGrafOrgSize(double& rWidth, double& rHeight)
+{
+ rWidth = static_cast<double>(m_SizeRect.GetWidth()) / 1000; //cm unit
+ rHeight = static_cast<double>(m_SizeRect.GetHeight()) / 1000; //cm unit
+}
+
+void LwpOleObject::RegisterStyle() {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpoleobject.hxx b/lotuswordpro/source/filter/lwpoleobject.hxx
new file mode 100644
index 000000000..d9bb95d56
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpoleobject.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - OLE object
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPOLEOBJECT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPOLEOBJECT_HXX
+
+#include "lwpcontent.hxx"
+#include <lwpobjhdr.hxx>
+#include <lwpobjid.hxx>
+#include <tools/gen.hxx>
+
+typedef struct tagAFID_CACHE
+{
+ unsigned long LinkedFileSize; /* 0 if not linked */
+ unsigned long LinkedFileTime; /* 0 if not linked */
+ tools::Long Width; /* -1 if not present */
+ tools::Long Height; /* -1 if not present */
+ tagAFID_CACHE()
+ : LinkedFileSize(0)
+ , LinkedFileTime(0)
+ , Width(0)
+ , Height(0)
+ {
+ }
+} AFID_CACHE, * PAFID_CACHE;
+
+/* Maximum string sizes - includes space for null terminator */
+#define AFID_MAX_FILE_FORMAT_SIZE 80
+#define AFID_MAX_CONTEXT_FORMAT_SIZE 80
+
+/**
+ * @descr
+ * super class of LwpOleObject and LwpGraphicObject
+ */
+class LwpGraphicOleObject : public LwpContent
+{
+public:
+ LwpGraphicOleObject(LwpObjectHeader const & objHdr, LwpSvStream* pStrm);
+ virtual void Read() override;
+ void GetGrafScaledSize(double& fWidth, double& fHeight);
+ virtual void GetGrafOrgSize(double& rWidth, double& rHeight);
+protected:
+ LwpObjectID m_pPrevObj;
+ LwpObjectID m_pNextObj;
+
+ OUString m_strStyleName;
+};
+
+/**
+ * @descr
+ * class to read and parse VO_OLEOBJECT object
+ */
+class LwpOleObject : public LwpGraphicOleObject
+{
+public:
+ LwpOleObject(LwpObjectHeader const & objHdr, LwpSvStream* pStrm);
+ virtual void Read() override;
+ virtual void Parse(IXFStream* pOutputStream) override;
+ virtual void XFConvert(XFContentContainer * pCont) override;
+ virtual void RegisterStyle() override;
+ void GetGrafOrgSize(double& rWidth, double& rHeight) override ;
+private:
+ sal_uInt16 cPersistentFlags;
+
+ tools::Rectangle m_SizeRect;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpoverride.cxx b/lotuswordpro/source/filter/lwpoverride.cxx
new file mode 100644
index 000000000..928d642d6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpoverride.cxx
@@ -0,0 +1,587 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <sal/log.hxx>
+#include <memory>
+
+#include "clone.hxx"
+#include <lwpoverride.hxx>
+#include <lwpfilehdr.hxx>
+#include "lwpbackgroundstuff.hxx"
+
+/*class LwpOverride*/
+LwpOverride::LwpOverride(LwpOverride const& rOther)
+ : m_nValues(rOther.m_nValues)
+ , m_nOverride(rOther.m_nOverride)
+ , m_nApply(rOther.m_nApply)
+{
+}
+
+void LwpOverride::ReadCommon(LwpObjectStream* pStrm)
+{
+ m_nValues = pStrm->QuickReaduInt16();
+ m_nOverride = pStrm->QuickReaduInt16();
+ m_nApply = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+
+void LwpOverride::Clear()
+{
+ m_nValues = 0;
+ m_nOverride = 0;
+ m_nApply = 0;
+}
+
+void LwpOverride::Override(sal_uInt16 nBits, STATE eState)
+{
+ if (eState == STATE_STYLE)
+ {
+ m_nValues &= ~nBits;
+ m_nOverride &= ~nBits;
+ }
+ else
+ {
+ m_nOverride |= nBits;
+ if (eState == STATE_ON)
+ {
+ m_nValues |= nBits;
+ }
+ else /* State == STATE_OFF */
+ {
+ m_nValues &= ~nBits;
+ }
+ }
+ m_nApply |= nBits;
+}
+
+/*class LwpTextLanguageOverride*/
+LwpTextLanguageOverride::LwpTextLanguageOverride(LwpTextLanguageOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nLanguage(rOther.m_nLanguage)
+{
+}
+
+LwpTextLanguageOverride* LwpTextLanguageOverride::clone() const
+{
+ return new LwpTextLanguageOverride(*this);
+}
+
+void LwpTextLanguageOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_nLanguage = pStrm->QuickReaduInt16();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpTextAttributeOverride*/
+LwpTextAttributeOverride::LwpTextAttributeOverride(LwpTextAttributeOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nHideLevels(rOther.m_nHideLevels)
+ , m_nBaseLineOffset(rOther.m_nBaseLineOffset)
+{
+}
+
+LwpTextAttributeOverride* LwpTextAttributeOverride::clone() const
+{
+ return new LwpTextAttributeOverride(*this);
+}
+
+void LwpTextAttributeOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_nHideLevels = pStrm->QuickReaduInt16();
+
+ if (LwpFileHeader::m_nFileRevision > 0x000A)
+ m_nBaseLineOffset = pStrm->QuickReaduInt32();
+ }
+
+ pStrm->SkipExtra();
+}
+
+bool LwpTextAttributeOverride::IsHighlight() const { return (m_nValues & TAO_HIGHLIGHT) != 0; }
+
+/*class LwpKinsokuOptsOverride*/
+LwpKinsokuOptsOverride::LwpKinsokuOptsOverride(LwpKinsokuOptsOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nLevels(rOther.m_nLevels)
+{
+}
+
+LwpKinsokuOptsOverride* LwpKinsokuOptsOverride::clone() const
+{
+ return new LwpKinsokuOptsOverride(*this);
+}
+
+void LwpKinsokuOptsOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_nLevels = pStrm->QuickReaduInt16();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpBulletOverride*/
+LwpBulletOverride::LwpBulletOverride(LwpBulletOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_SilverBullet(rOther.m_SilverBullet)
+ , m_bIsNull(rOther.m_bIsNull)
+{
+}
+
+LwpBulletOverride* LwpBulletOverride::clone() const { return new LwpBulletOverride(*this); }
+
+void LwpBulletOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ m_bIsNull = false;
+ ReadCommon(pStrm);
+ m_SilverBullet.ReadIndexed(pStrm);
+ }
+ else
+ m_bIsNull = true;
+
+ pStrm->SkipExtra();
+}
+void LwpBulletOverride::OverrideSkip(bool bOver)
+{
+ if (bOver)
+ {
+ LwpOverride::Override(BO_SKIP, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_SKIP, STATE_OFF);
+ }
+}
+
+void LwpBulletOverride::OverrideRightAligned(bool bOver)
+{
+ if (bOver)
+ {
+ LwpOverride::Override(BO_RIGHTALIGN, STATE_ON);
+ }
+ else
+ {
+ LwpOverride::Override(BO_RIGHTALIGN, STATE_OFF);
+ }
+}
+
+void LwpBulletOverride::OverrideSilverBullet(LwpObjectID aID)
+{
+ if (!aID.IsNull())
+ {
+ m_SilverBullet = aID;
+ }
+
+ LwpOverride::Override(BO_SILVERBULLET, STATE_ON);
+}
+
+void LwpBulletOverride::Override(LwpBulletOverride* pOther)
+{
+ if (m_nApply & BO_SILVERBULLET)
+ {
+ if (IsSilverBulletOverridden())
+ {
+ pOther->OverrideSilverBullet(m_SilverBullet);
+ }
+ else
+ {
+ pOther->RevertSilverBullet();
+ }
+ }
+
+ if (m_nApply & BO_SKIP)
+ {
+ if (IsSkipOverridden())
+ {
+ pOther->OverrideSkip(IsSkip());
+ }
+ else
+ {
+ pOther->RevertSkip();
+ }
+ }
+
+ if (m_nApply & BO_RIGHTALIGN)
+ {
+ if (IsRightAlignedOverridden())
+ {
+ pOther->OverrideRightAligned(IsRightAligned());
+ }
+ else
+ {
+ pOther->RevertRightAligned();
+ }
+ }
+}
+
+/*class LwpAlignmentOverride*/
+LwpAlignmentOverride::LwpAlignmentOverride(LwpAlignmentOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nAlignType(rOther.m_nAlignType)
+ , m_nPosition(rOther.m_nPosition)
+ , m_nAlignChar(rOther.m_nAlignChar)
+{
+}
+
+LwpAlignmentOverride* LwpAlignmentOverride::clone() const
+{
+ return new LwpAlignmentOverride(*this);
+}
+
+void LwpAlignmentOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ sal_uInt8 nAlignType = pStrm->QuickReaduInt8();
+ if (nAlignType <= ALIGN_SQUEEZE)
+ m_nAlignType = static_cast<AlignType>(nAlignType);
+ else
+ SAL_WARN("lwp", "unknown align type:" << nAlignType);
+ m_nPosition = pStrm->QuickReaduInt32();
+ m_nAlignChar = pStrm->QuickReaduInt16();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpSpacingCommonOverride*/
+LwpSpacingCommonOverride::LwpSpacingCommonOverride(LwpSpacingCommonOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nSpacingType(rOther.m_nSpacingType)
+ , m_nAmount(rOther.m_nAmount)
+ , m_nMultiple(rOther.m_nMultiple)
+{
+}
+
+LwpSpacingCommonOverride* LwpSpacingCommonOverride::clone() const
+{
+ return new LwpSpacingCommonOverride(*this);
+}
+
+void LwpSpacingCommonOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ const sal_uInt16 nSpacingType = pStrm->QuickReaduInt16();
+ //only the bottom pair of bits matter
+ m_nSpacingType = static_cast<SpacingType>(nSpacingType & 0x3);
+ m_nAmount = pStrm->QuickReadInt32();
+ m_nMultiple = pStrm->QuickReadInt32();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpSpacingOverride*/
+LwpSpacingOverride::LwpSpacingOverride()
+ : m_pSpacing(new LwpSpacingCommonOverride)
+ , m_pAboveLineSpacing(new LwpSpacingCommonOverride)
+ , m_pParaSpacingAbove(new LwpSpacingCommonOverride)
+ , m_pParaSpacingBelow(new LwpSpacingCommonOverride)
+{
+}
+
+LwpSpacingOverride::~LwpSpacingOverride() {}
+
+LwpSpacingOverride::LwpSpacingOverride(LwpSpacingOverride const& rOther)
+ : LwpOverride(rOther)
+{
+ m_pSpacing.reset(::clone(rOther.m_pSpacing.get()));
+ m_pAboveLineSpacing.reset(::clone(rOther.m_pAboveLineSpacing.get()));
+ m_pParaSpacingAbove.reset(::clone(rOther.m_pParaSpacingAbove.get()));
+ m_pParaSpacingBelow.reset(::clone(rOther.m_pParaSpacingBelow.get()));
+}
+
+LwpSpacingOverride* LwpSpacingOverride::clone() const { return new LwpSpacingOverride(*this); }
+
+void LwpSpacingOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_pSpacing->Read(pStrm);
+ if (LwpFileHeader::m_nFileRevision >= 0x000d)
+ {
+ m_pAboveLineSpacing->Read(pStrm);
+ }
+ m_pParaSpacingAbove->Read(pStrm);
+ m_pParaSpacingBelow->Read(pStrm);
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpIndentOverride*/
+LwpIndentOverride::LwpIndentOverride(LwpIndentOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_nAll(rOther.m_nAll)
+ , m_nFirst(rOther.m_nFirst)
+ , m_nRest(rOther.m_nRest)
+ , m_nRight(rOther.m_nRight)
+{
+}
+
+LwpIndentOverride* LwpIndentOverride::clone() const { return new LwpIndentOverride(*this); }
+
+void LwpIndentOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+
+ m_nAll = pStrm->QuickReadInt32();
+ m_nFirst = pStrm->QuickReadInt32();
+ m_nRest = pStrm->QuickReadInt32();
+ m_nRight = pStrm->QuickReadInt32();
+ }
+
+ pStrm->SkipExtra();
+}
+
+/*class LwpAmikakeOverride*/
+LwpAmikakeOverride::LwpAmikakeOverride()
+ : m_pBackgroundStuff(new LwpBackgroundStuff)
+ , m_nType(AMIKAKE_NONE)
+{
+}
+
+LwpAmikakeOverride::~LwpAmikakeOverride() {}
+
+LwpAmikakeOverride::LwpAmikakeOverride(LwpAmikakeOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_pBackgroundStuff(::clone(rOther.m_pBackgroundStuff.get()))
+ , m_nType(rOther.m_nType)
+{
+}
+
+LwpAmikakeOverride* LwpAmikakeOverride::clone() const { return new LwpAmikakeOverride(*this); }
+
+void LwpAmikakeOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_pBackgroundStuff->Read(pStrm);
+ }
+ else
+ {
+ Clear();
+ }
+
+ if (pStrm->CheckExtra())
+ {
+ m_nType = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+ }
+ else
+ {
+ m_nType = AMIKAKE_NONE;
+ }
+}
+
+void LwpAlignmentOverride::Override(LwpAlignmentOverride* other)
+{
+ if (m_nOverride & AO_TYPE)
+ {
+ other->OverrideAlignment(m_nAlignType);
+ }
+}
+
+void LwpAlignmentOverride::OverrideAlignment(AlignType val)
+{
+ m_nAlignType = val;
+ m_nOverride |= AO_TYPE;
+}
+
+void LwpIndentOverride::Override(LwpIndentOverride* other)
+{
+ if (m_nOverride & IO_ALL)
+ other->OverrideIndentAll(m_nAll);
+ if (m_nOverride & IO_FIRST)
+ other->OverrideIndentFirst(m_nFirst);
+ if (m_nOverride & IO_RIGHT)
+ other->OverrideIndentRight(m_nRight);
+ if (m_nOverride & IO_REST)
+ other->OverrideIndentRest(m_nRest);
+ if (m_nOverride & IO_USE_RELATIVE)
+ other->OverrideUseRelative(IsUseRelative());
+ if (m_nOverride & IO_REL_FLAGS)
+ other->OverrideRelative(GetRelative());
+}
+
+sal_uInt16 LwpIndentOverride::GetRelative() const
+{
+ if ((m_nOverride & IO_REL_FLAGS) == IO_REL_FIRST)
+ return RELATIVE_FIRST;
+ else if ((m_nOverride & IO_REL_FLAGS) == IO_REL_ALL)
+ return RELATIVE_ALL;
+ return RELATIVE_REST;
+}
+
+bool LwpIndentOverride::IsUseRelative() const { return (m_nValues & IO_USE_RELATIVE) != 0; }
+
+void LwpIndentOverride::OverrideIndentAll(sal_Int32 val)
+{
+ m_nAll = val;
+ m_nOverride |= IO_ALL;
+}
+
+void LwpIndentOverride::OverrideIndentFirst(sal_Int32 val)
+{
+ m_nFirst = val;
+ m_nOverride |= IO_FIRST;
+}
+
+void LwpIndentOverride::OverrideIndentRight(sal_Int32 val)
+{
+ m_nRight = val;
+ m_nOverride |= IO_RIGHT;
+}
+
+void LwpIndentOverride::OverrideIndentRest(sal_Int32 val)
+{
+ m_nRest = val;
+ // m_nAll = val;
+ // m_nFirst = 0-val;
+ m_nOverride |= IO_REST;
+}
+
+void LwpIndentOverride::OverrideUseRelative(bool use)
+{
+ if (use)
+ {
+ m_nOverride |= IO_USE_RELATIVE;
+ m_nValues |= IO_USE_RELATIVE;
+ }
+ else
+ {
+ m_nOverride &= ~IO_USE_RELATIVE;
+ m_nValues &= ~IO_USE_RELATIVE;
+ }
+}
+
+void LwpIndentOverride::OverrideRelative(sal_uInt16 relative)
+{
+ sal_uInt16 Flag;
+
+ if (relative == RELATIVE_FIRST)
+ Flag = IO_REL_FIRST;
+ else if (relative == RELATIVE_ALL)
+ Flag = IO_REL_ALL;
+ else
+ Flag = IO_REL_REST;
+
+ m_nOverride &= ~IO_REL_FLAGS;
+ m_nOverride |= Flag;
+}
+
+void LwpSpacingOverride::Override(LwpSpacingOverride* other)
+{
+ if (other)
+ {
+ m_pSpacing->Override(other->GetSpacing());
+ m_pAboveLineSpacing->Override(other->GetAboveLineSpacing());
+ m_pParaSpacingAbove->Override(other->GetAboveSpacing());
+ m_pParaSpacingBelow->Override(other->GetBelowSpacing());
+ }
+}
+
+void LwpSpacingCommonOverride::Override(LwpSpacingCommonOverride* other)
+{
+ if (m_nOverride & SPO_TYPE)
+ other->OverrideType(m_nSpacingType);
+ if (m_nOverride & SPO_AMOUNT)
+ other->OverrideAmount(m_nAmount);
+ if (m_nOverride & SPO_MULTIPLE)
+ other->OverrideMultiple(m_nMultiple);
+}
+
+void LwpSpacingCommonOverride::OverrideType(SpacingType val)
+{
+ m_nSpacingType = val;
+ m_nOverride |= SPO_TYPE;
+}
+
+void LwpSpacingCommonOverride::OverrideAmount(sal_Int32 val)
+{
+ m_nAmount = val;
+ m_nOverride |= SPO_AMOUNT;
+}
+
+void LwpSpacingCommonOverride::OverrideMultiple(sal_Int32 val)
+{
+ m_nMultiple = val;
+ m_nOverride |= SPO_MULTIPLE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppagehint.cxx b/lotuswordpro/source/filter/lwppagehint.cxx
new file mode 100644
index 000000000..21fbf3d99
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppagehint.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwppagehint.hxx"
+
+void LwpSLVListHead::Read(LwpObjectStream* pObjStrm)
+{
+ m_ListHead.ReadIndexed(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+void LwpContentHintHead::Read(LwpObjectStream* pObjStrm)
+{
+ m_ListHead.Read(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+void LwpFootnoteSeenHead::Read(LwpObjectStream* pObjStrm)
+{
+ m_ListHead.Read(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+LwpPageHint::LwpPageHint(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+ , m_nLastFootnoteSeen(0)
+ , m_nLastFootnoteProcessed(0)
+ , m_nFlags(0)
+ , m_nPageNumber(0)
+ , m_nNumberStyle(0)
+ , m_nNumberFlags(0)
+ , m_nRenderedPageNumber(0)
+ , m_nCurrentSectionPage(0)
+ , m_nLayoutPageNumber(0)
+{
+}
+
+void LwpPageHint::Read()
+{
+ LwpDLVList::Read();
+
+ m_PageLayout.ReadIndexed(m_pObjStrm.get());
+ //m_ContentHints.ReadIndexed(m_pObjStrm);
+ m_ContentHints.Read(m_pObjStrm.get());
+ m_nLastFootnoteSeen = m_pObjStrm->QuickReaduInt16();
+ m_nLastFootnoteProcessed = m_pObjStrm->QuickReaduInt16();
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_nPageNumber = m_pObjStrm->QuickReaduInt16();
+ m_nNumberStyle = m_pObjStrm->QuickReaduInt16();
+ m_BeforeText.Read(m_pObjStrm.get());
+ m_AfterText.Read(m_pObjStrm.get());
+ m_nNumberFlags = m_pObjStrm->QuickReaduInt8();
+ m_nRenderedPageNumber = m_pObjStrm->QuickReaduInt16();
+ m_CurrentSection.ReadIndexed(m_pObjStrm.get());
+ m_nCurrentSectionPage = m_pObjStrm->QuickReaduInt16();
+ //m_FootnoteSeen.ReadIndexed(m_pObjStrm);
+ m_FootnoteSeen.Read(m_pObjStrm.get());
+ m_nLayoutPageNumber = m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpPageHint::Parse(IXFStream* /*pOutputStream*/) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppagehint.hxx b/lotuswordpro/source/filter/lwppagehint.hxx
new file mode 100644
index 000000000..a22bddb76
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppagehint.hxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPAGEHINT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPAGEHINT_HXX
+
+#include <lwpobjid.hxx>
+#include <lwpatomholder.hxx>
+#include "lwpdlvlist.hxx"
+
+class LwpSLVListHead
+{
+public:
+ LwpSLVListHead() {}
+ void Read(LwpObjectStream* pObjStrm);
+
+private:
+ LwpObjectID m_ListHead;
+};
+
+class LwpContentHintHead
+{
+public:
+ LwpContentHintHead() {}
+ void Read(LwpObjectStream* pObjStrm);
+
+private:
+ LwpSLVListHead m_ListHead;
+};
+
+class LwpFootnoteSeenHead
+{
+public:
+ LwpFootnoteSeenHead() {}
+ void Read(LwpObjectStream* pObjStrm);
+
+private:
+ LwpSLVListHead m_ListHead;
+};
+
+class LwpPageHint : public LwpDLVList
+{
+public:
+ LwpPageHint(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ void Parse(IXFStream* pOutputStream) override;
+ sal_uInt16 GetPageNumber() const { return m_nPageNumber; }
+ LwpObjectID& GetPageLayoutID() { return m_PageLayout; }
+ sal_uInt16 GetLayoutPageNumber() const { return m_nLayoutPageNumber; }
+
+private:
+ virtual ~LwpPageHint() override {}
+
+ LwpObjectID m_PageLayout;
+ LwpContentHintHead m_ContentHints;
+ sal_uInt16 m_nLastFootnoteSeen;
+ sal_uInt16 m_nLastFootnoteProcessed;
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nPageNumber;
+ sal_uInt16 m_nNumberStyle;
+ LwpAtomHolder m_BeforeText;
+ LwpAtomHolder m_AfterText;
+ sal_uInt8 m_nNumberFlags;
+ sal_uInt16 m_nRenderedPageNumber;
+ LwpObjectID m_CurrentSection;
+ sal_uInt16 m_nCurrentSectionPage;
+ LwpFootnoteSeenHead m_FootnoteSeen;
+ sal_uInt16 m_nLayoutPageNumber;
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
new file mode 100644
index 000000000..69e25d029
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -0,0 +1,1080 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <memory>
+#include "lwppagelayout.hxx"
+#include "lwplaypiece.hxx"
+#include "lwpfootnote.hxx"
+#include "lwpdoc.hxx"
+#include "lwpholder.hxx"
+#include "lwppagehint.hxx"
+#include "lwpdivinfo.hxx"
+#include "lwpstory.hxx"
+#include <o3tl/numeric.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfmasterpage.hxx>
+#include <xfilter/xfcontentcontainer.hxx>
+#include <xfilter/xfheader.hxx>
+#include <xfilter/xfheaderstyle.hxx>
+#include <xfilter/xffooterstyle.hxx>
+#include <xfilter/xffooter.hxx>
+#include <lwpchangemgr.hxx>
+#include <lwpfilehdr.hxx>
+#include <lwpglobalmgr.hxx>
+#include <o3tl/sorted_vector.hxx>
+#include <sal/log.hxx>
+#include <vcl/print.hxx>
+
+LwpPageLayout::LwpPageLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpLayout(objHdr, pStrm)
+ , m_nPrinterBin(0)
+ , m_nBdroffset(0)
+ , m_pXFPageMaster(nullptr)
+{
+}
+
+LwpPageLayout::~LwpPageLayout() {}
+void LwpPageLayout::Read()
+{
+ LwpLayout::Read();
+
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ // read PreRevBLayout...
+ }
+
+ m_nPrinterBin = m_pObjStrm->QuickReaduInt16();
+ m_PrinterBinName.Read(m_pObjStrm.get());
+
+ if (LwpFileHeader::m_nFileRevision >= 0x000B)
+ m_nBdroffset = m_pObjStrm->QuickReadInt32();
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ m_PaperName.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+}
+
+void LwpPageLayout::Parse(IXFStream* pOutputStream)
+{
+ //Only parse this layout
+ rtl::Reference<LwpObject> pStory = m_Content.obj();
+ if (pStory.is())
+ {
+ pStory->SetFoundry(m_pFoundry);
+ pStory->DoParse(pOutputStream); //Do not parse the next story
+ }
+}
+
+/**
+* @descr: set page margins
+*
+*/
+void LwpPageLayout::ParseMargins(XFPageMaster* pm1)
+{
+ double fLeft = GetMarginsValue(MARGIN_LEFT);
+ double fRight = GetMarginsValue(MARGIN_RIGHT);
+ double fTop = GetMarginsValue(MARGIN_TOP);
+ double fBottom = GetMarginsValue(MARGIN_BOTTOM);
+
+ pm1->SetMargins(fLeft, fRight, fTop, fBottom);
+}
+
+/**
+* @descr: set page height and width
+*
+*/
+void LwpPageLayout::ParseGeometry(XFPageMaster* pm1)
+{
+ /*
+ LwpLayoutGeometry* pLayoutGeo = GetGeometry();
+ if(pLayoutGeo)
+ {
+ pm1->SetPageHeight( GetGeometryHeight() );
+ pm1->SetPageWidth( GetGeometryWidth() );
+ }
+ */
+ double fWidth = 0;
+ double fHeight = 0;
+ GetWidthAndHeight(fWidth, fHeight);
+ pm1->SetPageWidth(fWidth);
+ pm1->SetPageHeight(fHeight);
+}
+
+/**
+* @descr: set page watermark
+*
+*/
+void LwpPageLayout::ParseWaterMark(XFPageMaster* pm1)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
+ if (xXFBGImage)
+ {
+ pm1->SetBackImage(xXFBGImage);
+ }
+}
+
+/**
+* @descr: set page columns
+*
+*/
+void LwpPageLayout::ParseColumns(XFPageMaster* pm1)
+{
+ XFColumns* pColumns = GetXFColumns();
+ if (pColumns)
+ {
+ pm1->SetColumns(pColumns);
+ }
+}
+
+/**
+* @descr: set page borders
+*
+*/
+void LwpPageLayout::ParseBorders(XFPageMaster* pm1)
+{
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
+ if (pBordres)
+ {
+ pm1->SetBorders(std::move(pBordres));
+ }
+}
+
+/**
+* @descr: set page shadow
+*
+*/
+void LwpPageLayout::ParseShadow(XFPageMaster* pm1)
+{
+ XFShadow* pXFShadow = GetXFShadow();
+ if (pXFShadow)
+ {
+ pm1->SetShadow(pXFShadow);
+ }
+}
+
+/**
+* @descr: set page back pattern
+*
+*/
+void LwpPageLayout::ParsePatternFill(XFPageMaster* pm1)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
+ if (xXFBGImage)
+ {
+ pm1->SetBackImage(xXFBGImage);
+ }
+}
+/**
+* @descr: set page background
+*
+*/
+void LwpPageLayout::ParseBackGround(XFPageMaster* pm1)
+{
+ if (IsPatternFill())
+ {
+ ParsePatternFill(pm1);
+ }
+ else
+ {
+ ParseBackColor(pm1);
+ }
+}
+
+/**
+* @descr: set page back color
+*
+*/
+void LwpPageLayout::ParseBackColor(XFPageMaster* pm1)
+{
+ LwpColor* pColor = GetBackColor();
+ if (pColor)
+ {
+ pm1->SetBackColor(XFColor(pColor->To24Color()));
+ }
+}
+
+/**
+* @descr: set page footnote separator information
+*
+*/
+void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster* pm1)
+{
+ //Get the footnoteoptions for the root document
+ LwpDocument* pDocument = m_pFoundry ? m_pFoundry->GetDocument() : nullptr;
+ if (!pDocument)
+ return;
+
+ LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts();
+
+ LwpFootnoteOptions* pFootnoteOpts
+ = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj().get()) : nullptr;
+ if (!pFootnoteOpts)
+ return;
+
+ LwpFootnoteSeparatorOptions& rFootnoteSep = pFootnoteOpts->GetFootnoteSeparator();
+ //set length
+ sal_uInt32 nLengthPercent = 100;
+ double fWidth = 0;
+ if (rFootnoteSep.HasSeparator())
+ {
+ fWidth = rFootnoteSep.GetTopBorderWidth();
+ }
+ if (rFootnoteSep.HasCustomLength())
+ {
+ const double fMarginWidth = GetMarginWidth();
+ if (fMarginWidth == 0.0)
+ throw o3tl::divide_by_zero();
+
+ nLengthPercent = static_cast<sal_uInt32>(
+ 100 * LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetLength()) / fMarginWidth);
+ if (nLengthPercent > 100)
+ nLengthPercent = 100;
+ }
+ double fAbove = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetAbove());
+ double fBelow = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetBelow());
+ LwpColor aColor = rFootnoteSep.GetTopBorderColor();
+ enumXFAlignType eAlignType = enumXFAlignStart;
+ if (rFootnoteSep.GetIndent() > 0)
+ {
+ const double fMarginWidth = GetMarginWidth();
+ if (fMarginWidth == 0.0)
+ throw o3tl::divide_by_zero();
+
+ //SODC don't support indent
+ sal_uInt32 nIndentPercent = static_cast<sal_uInt32>(
+ 100 * LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetIndent()) / fMarginWidth);
+ if (nIndentPercent + nLengthPercent >= 100)
+ eAlignType = enumXFAlignEnd;
+ }
+ if (aColor.IsValidColor())
+ {
+ XFColor aXFColor(aColor.To24Color());
+ pm1->SetFootNoteSeparator(eAlignType, fWidth, nLengthPercent, fAbove, fBelow, aXFColor);
+ }
+}
+
+/**
+* @descr: Register master page and page master style
+*
+*/
+void LwpPageLayout::RegisterStyle()
+{
+ std::unique_ptr<XFPageMaster> xpm1(new XFPageMaster);
+
+ ParseGeometry(xpm1.get());
+ //Does not process LayoutScale, for watermark is not supported in SODC.
+ ParseWaterMark(xpm1.get());
+ ParseMargins(xpm1.get());
+ ParseColumns(xpm1.get());
+ ParseBorders(xpm1.get());
+ ParseShadow(xpm1.get());
+ ParseBackGround(xpm1.get());
+ ParseFootNoteSeparator(xpm1.get());
+ xpm1->SetTextDir(GetTextDirection());
+
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (IsComplex() || (pUseWhen && pUseWhen->IsUseOnAllOddPages()))
+ {
+ xpm1->SetPageUsage(enumXFPageUsageMirror);
+ }
+
+ //Add the page master to stylemanager
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFPageMaster* pm1
+ = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(xpm1)).m_pStyle);
+ m_pXFPageMaster = pm1;
+ OUString pmname = pm1->GetStyleName();
+
+ //Add master page
+ std::unique_ptr<XFMasterPage> p1(new XFMasterPage);
+ p1->SetStyleName(GetName().str());
+ p1->SetPageMaster(pmname);
+ XFMasterPage* p1_added
+ = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(std::move(p1)).m_pStyle);
+ m_StyleName = p1_added->GetStyleName();
+
+ //Set footer style
+ LwpFooterLayout* pLayoutFooter = GetFooterLayout();
+ if (pLayoutFooter)
+ {
+ pLayoutFooter->SetFoundry(m_pFoundry);
+ pLayoutFooter->RegisterStyle(pm1);
+ pLayoutFooter->RegisterStyle(p1_added);
+ }
+
+ //Set header style
+ LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
+ if (pLayoutHeader)
+ {
+ pLayoutHeader->SetFoundry(m_pFoundry);
+ pLayoutHeader->RegisterStyle(pm1);
+ pLayoutHeader->RegisterStyle(p1_added);
+ }
+ //register child layout style for mirror page and frame
+ RegisterChildStyle();
+}
+
+/**
+* @descr: Register master page for endnote which name is "endnote"
+* @return: Return the master page name.
+*/
+OUString LwpPageLayout::RegisterEndnoteStyle()
+{
+ std::unique_ptr<XFPageMaster> pm1(new XFPageMaster);
+
+ ParseGeometry(pm1.get());
+ ParseWaterMark(pm1.get());
+ ParseMargins(pm1.get());
+ ParseColumns(pm1.get());
+ ParseBorders(pm1.get());
+ ParseShadow(pm1.get());
+ ParseBackGround(pm1.get());
+ pm1->SetTextDir(GetTextDirection());
+
+ LwpUseWhen* pUseWhen = GetUseWhen();
+ if (IsComplex() || (pUseWhen && pUseWhen->IsUseOnAllOddPages()))
+ {
+ pm1->SetPageUsage(enumXFPageUsageMirror);
+ }
+
+ //Add the page master to stylemanager
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_pXFPageMaster
+ = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(pm1)).m_pStyle);
+ OUString pmname = m_pXFPageMaster->GetStyleName();
+
+ //Add master page
+ std::unique_ptr<XFMasterPage> p1(new XFMasterPage);
+ p1->SetStyleName("Endnote");
+ p1->SetPageMaster(pmname);
+
+ //Set footer style
+ LwpFooterLayout* pLayoutFooter = GetFooterLayout();
+ if (pLayoutFooter)
+ {
+ pLayoutFooter->SetFoundry(m_pFoundry);
+ pLayoutFooter->RegisterStyle(m_pXFPageMaster);
+ pLayoutFooter->RegisterStyle(p1.get());
+ }
+
+ //Set header style
+ LwpHeaderLayout* pLayoutHeader = GetHeaderLayout();
+ if (pLayoutHeader)
+ {
+ pLayoutHeader->SetFoundry(m_pFoundry);
+ pLayoutHeader->RegisterStyle(m_pXFPageMaster);
+ pLayoutHeader->RegisterStyle(p1.get());
+ }
+
+ return pXFStyleManager->AddStyle(std::move(p1)).m_pStyle->GetStyleName();
+}
+/**
+* @descr: Whether current page layout has columns
+*
+*/
+bool LwpPageLayout::HasColumns() { return GetNumCols() > 1; }
+
+/**
+* @descr: Whether has filler page text in current page layout
+*
+*/
+bool LwpPageLayout::HasFillerPageText(LwpFoundry const* pFoundry)
+{
+ if (!pFoundry)
+ return false;
+
+ bool bFillerPage = false;
+ LwpLayout::UseWhenType eWhenType = GetUseWhenType();
+ if (eWhenType == LwpLayout::StartOnOddPage || eWhenType == LwpLayout::StartOnEvenPage)
+ {
+ //get the page number that current page layout inserted
+ sal_Int32 nPageNumber = GetPageNumber(FIRST_LAYOUTPAGENO) - 1;
+
+ if (nPageNumber > 0)
+ {
+ if ((eWhenType == LwpLayout::StartOnOddPage) && (LwpTools::IsOddNumber(nPageNumber)))
+ {
+ bFillerPage = true;
+ }
+ else if ((eWhenType == LwpLayout::StartOnEvenPage)
+ && (LwpTools::IsEvenNumber(nPageNumber)))
+ {
+ bFillerPage = true;
+ }
+ else
+ {
+ bFillerPage = false;
+ }
+ }
+ }
+
+ return bFillerPage;
+}
+
+/**
+* @descr: Parse filler page text
+*
+*/
+void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont)
+{
+ if (!HasFillerPageText(m_pFoundry))
+ return;
+
+ //get fillerpage story from division info
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID().obj().get());
+ LwpStory* pStory
+ = pDivInfo ? dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID().obj().get()) : nullptr;
+
+ //parse fillerpage story
+ if (pStory)
+ {
+ pStory->XFConvert(pCont);
+ }
+}
+/**
+* @descr: Clear columns style in page layout
+*
+*/
+void LwpPageLayout::ResetXFColumns()
+{
+ if (m_pXFPageMaster)
+ {
+ m_pXFPageMaster->SetColumns(nullptr);
+ }
+}
+
+LwpHeaderLayout* LwpPageLayout::GetHeaderLayout()
+{
+ rtl::Reference<LwpVirtualLayout> xLay(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ while (xLay.is())
+ {
+ if (xLay->GetLayoutType() == LWP_HEADER_LAYOUT)
+ return dynamic_cast<LwpHeaderLayout*>(xLay.get());
+ rtl::Reference<LwpVirtualLayout> xNext(
+ dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
+ if (xNext == xLay)
+ {
+ SAL_WARN("lwp", "loop in layout");
+ break;
+ }
+ xLay = xNext;
+ }
+ return nullptr;
+}
+
+LwpFooterLayout* LwpPageLayout::GetFooterLayout()
+{
+ rtl::Reference<LwpVirtualLayout> xLay(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ while (xLay.is())
+ {
+ if (xLay->GetLayoutType() == LWP_FOOTER_LAYOUT)
+ return dynamic_cast<LwpFooterLayout*>(xLay.get());
+ rtl::Reference<LwpVirtualLayout> xNext(
+ dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
+ if (xNext == xLay)
+ {
+ SAL_WARN("lwp", "loop in layout");
+ break;
+ }
+ xLay = xNext;
+ }
+ return nullptr;
+}
+
+/**
+* @descr: Get the odd layout if current page layout is mirror page
+*
+*/
+LwpPageLayout* LwpPageLayout::GetOddChildLayout()
+{
+ if (!IsComplex())
+ return nullptr;
+ rtl::Reference<LwpVirtualLayout> xLay(
+ dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xLay.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xLay.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ if (xLay->GetLayoutType() == LWP_PAGE_LAYOUT)
+ {
+ LwpPageLayout* pPageLayout = static_cast<LwpPageLayout*>(xLay.get());
+ LwpUseWhen* pUseWhen = pPageLayout->GetUseWhen();
+ if (pUseWhen && pUseWhen->IsUseOnAllOddPages())
+ {
+ return pPageLayout;
+ }
+ }
+ xLay.set(dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
+ }
+ return nullptr;
+}
+
+/**
+* @descr: Get margin width of page
+*
+*/
+double LwpPageLayout::GetMarginWidth()
+{
+ double fPagewidth = GetGeometryWidth();
+ double fLeftMargin = GetMarginsValue(MARGIN_LEFT);
+ double fRightMargin = GetMarginsValue(MARGIN_RIGHT);
+
+ return fPagewidth - (fLeftMargin + fRightMargin);
+}
+
+/**
+ * @descr: Get the pagenumber
+ * @param: if nLayoutNumber =FIRST_LAYOUTPAGENO, return the first page number that current page layout covers
+ =LAST_LAYOUTPAGENO, return the last page number that current page layout covers
+ else, return the specified page number that current page layout covers
+ * @param:
+ * @return: if return value >=0, success to find the page number, or fail.
+*/
+sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber)
+{
+ sal_Int16 nPageNumber = -1;
+ LwpFoundry* pFoundry = GetFoundry();
+ if (!pFoundry)
+ return nPageNumber;
+ LwpDocument* pDoc = pFoundry->GetDocument();
+ LwpDLVListHeadTailHolder* pHeadTail
+ = dynamic_cast<LwpDLVListHeadTailHolder*>(pDoc->GetPageHintsID().obj().get());
+ if (!pHeadTail)
+ return nPageNumber;
+
+ //get first pagehint
+ LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetHead().obj().get());
+ o3tl::sorted_vector<LwpPageHint*> aSeen;
+ while (pPageHint)
+ {
+ bool bAlreadySeen = !aSeen.insert(pPageHint).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ if (GetObjectID() == pPageHint->GetPageLayoutID())
+ {
+ sal_uInt16 nNumber = pPageHint->GetPageNumber();
+ if (nLayoutNumber == FIRST_LAYOUTPAGENO && pPageHint->GetLayoutPageNumber() == 1)
+ {
+ //get the first page number
+ nPageNumber = nNumber;
+ break;
+ }
+ else if (nLayoutNumber == LAST_LAYOUTPAGENO && nNumber > nPageNumber)
+ {
+ //get the last page number
+ nPageNumber = nNumber;
+ if (pPageHint->GetNext().IsNull())
+ {
+ //if is last page number of entire document, return directly
+ return nPageNumber + pDoc->GetNumberOfPagesBefore();
+ }
+ }
+ else if (nLayoutNumber > 0 && pPageHint->GetLayoutPageNumber() == nLayoutNumber)
+ {
+ //get specified page number
+ nPageNumber = nNumber;
+ break;
+ }
+ }
+
+ pPageHint = dynamic_cast<LwpPageHint*>(pPageHint->GetNext().obj().get());
+ }
+ if (nPageNumber >= 0)
+ {
+ return nPageNumber + 1 + pDoc->GetNumberOfPagesBefore();
+ }
+ return -1;
+}
+
+/**
+* @descr: Get page width and height
+*
+*/
+void LwpPageLayout::GetWidthAndHeight(double& fWidth, double& fHeight)
+{
+ //use customized size
+ LwpLayoutGeometry* pLayoutGeo = GetGeometry();
+ if (pLayoutGeo)
+ {
+ fWidth = GetGeometryWidth();
+ fHeight = GetGeometryHeight();
+ }
+
+ if (GetUsePrinterSettings())
+ {
+ //replaced by printer paper size
+ ScopedVclPtrInstance<Printer> pPrinter;
+ bool bScreen = pPrinter->IsDisplayPrinter();
+ if (!bScreen) //Printer available
+ {
+ Size aPaperSize = pPrinter->GetPaperSize();
+ aPaperSize = pPrinter->PixelToLogic(aPaperSize, MapMode(MapUnit::Map10thMM));
+ fWidth = static_cast<double>(aPaperSize.Width()) / 100; //cm unit
+ fHeight = static_cast<double>(aPaperSize.Height()) / 100;
+ }
+ }
+
+ //Follow the former design of Lotus WordPro filter, some default will be given:
+ //Page Width: 8.5 Inch -> 21.59 cm
+ //Page Height: 11 Inch -> 27.94 cm
+ if (fWidth < 4.39)
+ fWidth = 21.59;
+ if (fHeight < 4.49)
+ fHeight = 27.94;
+ //End of modification, by ZF
+}
+
+/**
+* @descr: Get page width
+*
+*/
+double LwpPageLayout::GetWidth()
+{
+ double fWidth = 0, fHeight = 0;
+ GetWidthAndHeight(fWidth, fHeight);
+ return fWidth;
+}
+
+/**
+* @descr: Get page height
+*
+*/
+double LwpPageLayout::GetHeight()
+{
+ double fWidth = 0, fHeight = 0;
+ GetWidthAndHeight(fWidth, fHeight);
+ return fHeight;
+}
+/**
+* @descr: Compare the position of layout. If the position of this layout is earlier than other layout,return true, or return false
+*
+*/
+bool LwpPageLayout::operator<(LwpPageLayout& Other)
+{
+ LwpPara* pThisPara = GetPagePosition();
+ LwpPara* pOtherPara = Other.GetPagePosition();
+ if (pThisPara && pOtherPara)
+ {
+ if (pThisPara == pOtherPara)
+ {
+ //If the two layouts in the same para, compare which layout is earlied according to frib order
+ return pThisPara->ComparePagePosition(this, &Other);
+ }
+ else
+ {
+ return *pThisPara < *pOtherPara;
+ }
+ }
+
+ return pThisPara == nullptr;
+}
+
+/**
+* @descr: Get the position of pagelayout
+*
+*/
+LwpPara* LwpPageLayout::GetPagePosition()
+{
+ LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition().obj().get());
+ if (pPara)
+ return pPara;
+ //Get the position from its related section
+ LwpFoundry* pFoundry = GetFoundry();
+ if (pFoundry)
+ {
+ LwpSection* pSection = nullptr;
+ while ((pSection = pFoundry->EnumSections(pSection)))
+ {
+ if (pSection->GetPageLayout() == this)
+ return dynamic_cast<LwpPara*>(pSection->GetPosition().obj().get());
+ }
+ }
+
+ return nullptr;
+}
+LwpHeaderLayout::LwpHeaderLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+ , m_nBorderOffset(0)
+{
+}
+
+LwpHeaderLayout::~LwpHeaderLayout() {}
+
+void LwpHeaderLayout::Read()
+{
+ LwpPlacableLayout::Read();
+
+ if (LwpFileHeader::m_nFileRevision >= 0x000E)
+ m_nBorderOffset = m_pObjStrm->QuickReadInt32();
+ else
+ m_nBorderOffset = 0;
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpHeaderLayout::RegisterStyle(XFPageMaster* pm1)
+{
+ std::unique_ptr<XFHeaderStyle> xHeaderStyle(new XFHeaderStyle);
+
+ //Modify page top margin
+ //page top margin: from top of header to the top edge
+ double top = GetMarginsValue(MARGIN_TOP);
+ pm1->SetMargins(-1, -1, top, -1);
+
+ ParseMargins(xHeaderStyle.get());
+ ParseBorder(xHeaderStyle.get());
+ ParseShadow(xHeaderStyle.get());
+ ParseBackGround(xHeaderStyle.get());
+
+ ParseWaterMark(xHeaderStyle.get());
+ //End by
+
+ pm1->SetHeaderStyle(xHeaderStyle.release());
+}
+
+void LwpHeaderLayout::ParseMargins(XFHeaderStyle* ph1)
+{
+ //Set height: from top of header to top of body, including the spacing between header and body
+ double height = GetGeometryHeight() - GetMarginsValue(MARGIN_TOP);
+ if (GetIsAutoGrowDown())
+ {
+ ph1->SetMinHeight(height);
+ }
+ else
+ {
+ ph1->SetHeight(height);
+ }
+
+ //Set left,right,bottom margins
+ LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*>(GetParent().obj().get());
+ //left margin in SODC: the space from the left edge of body to the left edge of header
+ double left
+ = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
+ if (left <= 0) //The left margin in SODC can not be minus value
+ {
+ left = -1;
+ }
+ //left margin in SODC: the space from the right edge of header to the right edge of body
+ double right
+ = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
+ if (right <= 0) //The right margin in SODC can not be minus value
+ {
+ right = -1;
+ }
+ ph1->SetMargins(left, right, GetMarginsValue(MARGIN_BOTTOM));
+
+ //Word Pro has no dynamic spacing, should be set to false
+ ph1->SetDynamicSpace(false);
+}
+
+void LwpHeaderLayout::ParseBorder(XFHeaderStyle* pHeaderStyle)
+{
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
+ if (pBordres)
+ {
+ pHeaderStyle->SetBorders(std::move(pBordres));
+ }
+}
+
+void LwpHeaderLayout::ParseShadow(XFHeaderStyle* pHeaderStyle)
+{
+ XFShadow* pXFShadow = GetXFShadow();
+ if (pXFShadow)
+ {
+ pHeaderStyle->SetShadow(pXFShadow);
+ }
+}
+
+/**
+* @descr: set header back pattern
+*
+*/
+void LwpHeaderLayout::ParsePatternFill(XFHeaderStyle* pHeaderStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
+ if (xXFBGImage)
+ {
+ pHeaderStyle->SetBackImage(xXFBGImage);
+ }
+}
+/**
+* @descr: set header background
+*
+*/
+void LwpHeaderLayout::ParseBackGround(XFHeaderStyle* pHeaderStyle)
+{
+ if (IsPatternFill())
+ {
+ ParsePatternFill(pHeaderStyle);
+ }
+ else
+ {
+ ParseBackColor(pHeaderStyle);
+ }
+}
+
+void LwpHeaderLayout::ParseBackColor(XFHeaderStyle* pHeaderStyle)
+{
+ LwpColor* pColor = GetBackColor();
+ if (pColor)
+ {
+ pHeaderStyle->SetBackColor(XFColor(pColor->To24Color()));
+ }
+}
+
+void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle* pHeaderStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
+ if (xXFBGImage)
+ {
+ pHeaderStyle->SetBackImage(xXFBGImage);
+ }
+}
+//End by
+
+void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
+{
+ rtl::Reference<XFHeader> xHeader(new XFHeader);
+ rtl::Reference<LwpObject> pStory = m_Content.obj();
+ if (pStory.is())
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ pChangeMgr->SetHeadFootFribMap(true);
+
+ //Call the RegisterStyle first to register the styles in header paras, and then XFConvert()
+ pStory->SetFoundry(m_pFoundry);
+ pStory->DoRegisterStyle();
+ //, 06/27/2005
+ //register child layout style for framelayout,
+ RegisterChildStyle();
+ //End
+ pChangeMgr->SetHeadFootChange(xHeader.get());
+ pStory->DoXFConvert(xHeader.get());
+
+ pChangeMgr->SetHeadFootFribMap(false);
+ }
+ mp1->SetHeader(xHeader);
+}
+
+LwpFooterLayout::LwpFooterLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+ , m_nBorderOffset(0)
+{
+}
+
+LwpFooterLayout::~LwpFooterLayout() {}
+
+void LwpFooterLayout::Read()
+{
+ LwpPlacableLayout::Read();
+
+ if (LwpFileHeader::m_nFileRevision >= 0x000E)
+ m_nBorderOffset = m_pObjStrm->QuickReadInt32();
+ else
+ m_nBorderOffset = 0;
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpFooterLayout::RegisterStyle(XFPageMaster* pm1)
+{
+ std::unique_ptr<XFFooterStyle> xFooterStyle(new XFFooterStyle);
+
+ //Modify page bottom margin
+ //page bottom margin: from bottom of footer to the bottom edge
+ double bottom = GetMarginsValue(MARGIN_BOTTOM);
+ pm1->SetMargins(-1, -1, -1, bottom);
+
+ ParseMargins(xFooterStyle.get());
+ ParseBorder(xFooterStyle.get());
+ ParseShadow(xFooterStyle.get());
+ ParseBackGround(xFooterStyle.get());
+
+ ParseWaterMark(xFooterStyle.get());
+
+ pm1->SetFooterStyle(xFooterStyle.release());
+}
+
+void LwpFooterLayout::ParseMargins(XFFooterStyle* pFooterStyle)
+{
+ //Set height: from top of header to top of body, including the spacing between header and body
+ double height = GetGeometryHeight() - GetMarginsValue(MARGIN_BOTTOM);
+ if (IsAutoGrowUp())
+ {
+ pFooterStyle->SetMinHeight(height);
+ }
+ else
+ {
+ pFooterStyle->SetHeight(height);
+ }
+
+ //Set left,right,top margins
+ LwpMiddleLayout* parent = dynamic_cast<LwpMiddleLayout*>(GetParent().obj().get());
+ double left
+ = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0);
+ if (left <= 0) //The left margin in SODC can not be minus value
+ {
+ left = -1;
+ }
+ double right
+ = GetMarginsValue(MARGIN_RIGHT) - (parent ? parent->GetMarginsValue(MARGIN_RIGHT) : 0);
+ if (right <= 0) //The left margin in SODC can not be minus value
+ {
+ right = -1;
+ }
+ pFooterStyle->SetMargins(left, right, GetMarginsValue(MARGIN_TOP));
+
+ //Word Pro has no dynamic spacing, should be set to false
+ pFooterStyle->SetDynamicSpace(false);
+}
+
+void LwpFooterLayout::ParseBorder(XFFooterStyle* pFooterStyle)
+{
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
+ if (pBordres)
+ {
+ pFooterStyle->SetBorders(std::move(pBordres));
+ }
+}
+
+void LwpFooterLayout::ParseShadow(XFFooterStyle* pFooterStyle)
+{
+ XFShadow* pXFShadow = GetXFShadow();
+ if (pXFShadow)
+ {
+ pFooterStyle->SetShadow(pXFShadow);
+ }
+}
+/**
+* @descr: set footer back pattern
+*
+*/
+void LwpFooterLayout::ParsePatternFill(XFFooterStyle* pFooterStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
+ if (xXFBGImage)
+ {
+ pFooterStyle->SetBackImage(xXFBGImage);
+ }
+}
+/**
+* @descr: set footer background
+*
+*/
+void LwpFooterLayout::ParseBackGround(XFFooterStyle* pFooterStyle)
+{
+ if (IsPatternFill())
+ {
+ ParsePatternFill(pFooterStyle);
+ }
+ else
+ {
+ ParseBackColor(pFooterStyle);
+ }
+}
+
+void LwpFooterLayout::ParseBackColor(XFFooterStyle* pFooterStyle)
+{
+ LwpColor* pColor = GetBackColor();
+ if (pColor)
+ {
+ pFooterStyle->SetBackColor(XFColor(pColor->To24Color()));
+ }
+}
+
+void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
+{
+ rtl::Reference<XFFooter> xFooter(new XFFooter);
+ rtl::Reference<LwpObject> pStory = m_Content.obj(VO_STORY);
+ //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert()
+ if (pStory.is())
+ {
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr();
+ pChangeMgr->SetHeadFootFribMap(true);
+
+ pStory->SetFoundry(m_pFoundry);
+ pStory->DoRegisterStyle();
+ //register child layout style for framelayout,
+ RegisterChildStyle();
+
+ pChangeMgr->SetHeadFootChange(xFooter.get());
+
+ pStory->DoXFConvert(xFooter.get());
+
+ pChangeMgr->SetHeadFootFribMap(false);
+ }
+ mp1->SetFooter(xFooter);
+}
+
+void LwpFooterLayout::ParseWaterMark(XFFooterStyle* pFooterStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetXFBGImage());
+ if (xXFBGImage)
+ {
+ pFooterStyle->SetBackImage(xXFBGImage);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppagelayout.hxx b/lotuswordpro/source/filter/lwppagelayout.hxx
new file mode 100644
index 000000000..0c8142f61
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppagelayout.hxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPAGELAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPAGELAYOUT_HXX
+
+#include "lwplayout.hxx"
+#include <xfilter/xfmasterpage.hxx>
+
+class LwpHeaderLayout;
+class LwpFooterLayout;
+
+class LwpPageLayout final : public LwpLayout
+{
+public:
+ LwpPageLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpPageLayout() override;
+ virtual void RegisterStyle() override;
+ OUString RegisterEndnoteStyle();
+ virtual void Parse(IXFStream* pOutputStream) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_PAGE_LAYOUT; }
+
+private:
+ void Read() override;
+ LwpHeaderLayout* GetHeaderLayout();
+ LwpFooterLayout* GetFooterLayout();
+ void ParseGeometry(XFPageMaster* pm1);
+ void ParseMargins(XFPageMaster* pm1);
+ void ParseBorders(XFPageMaster* pm1);
+ void ParsePatternFill(XFPageMaster* pm1);
+ void ParseBackGround(XFPageMaster* pm1);
+ void ParseBackColor(XFPageMaster* pm1);
+ void ParseWaterMark(XFPageMaster* pm1);
+ void ParseColumns(XFPageMaster* pm1);
+ void ParseShadow(XFPageMaster* pm1);
+ void ParseFootNoteSeparator(XFPageMaster* pm1);
+ double GetMarginWidth();
+ void GetWidthAndHeight(double& fWidth, double& fHeight);
+ double GetWidth() override;
+ double GetHeight() override;
+ LwpAtomHolder m_PrinterBinName;
+ sal_uInt16 m_nPrinterBin;
+ sal_Int32 m_nBdroffset;
+ LwpAtomHolder m_PaperName;
+ XFPageMaster* m_pXFPageMaster;
+
+public:
+ bool HasColumns();
+ bool HasFillerPageText(LwpFoundry const* pFoundry);
+ void ConvertFillerPageText(XFContentContainer* pCont);
+ void ResetXFColumns();
+ LwpPageLayout* GetOddChildLayout();
+ virtual sal_Int32 GetPageNumber(sal_uInt16 nLayoutNumber) override;
+ bool operator<(LwpPageLayout& Other);
+ LwpPara* GetPagePosition();
+};
+
+class LwpHeaderLayout : public LwpPlacableLayout
+{
+public:
+ LwpHeaderLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpHeaderLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_HEADER_LAYOUT; }
+ using LwpPlacableLayout::RegisterStyle;
+ void RegisterStyle(XFPageMaster* pm1);
+ void RegisterStyle(XFMasterPage* mp1);
+
+protected:
+ void Read() override;
+ void ParseMargins(XFHeaderStyle* ph1);
+ void ParseBorder(XFHeaderStyle* ph1);
+ void ParseShadow(XFHeaderStyle* ph1);
+ void ParsePatternFill(XFHeaderStyle* ph1);
+ void ParseBackGround(XFHeaderStyle* ph1);
+ void ParseBackColor(XFHeaderStyle* ph1);
+
+ void ParseWaterMark(XFHeaderStyle* ph1);
+
+private:
+ sal_Int32 m_nBorderOffset;
+};
+
+class LwpFooterLayout : public LwpPlacableLayout
+{
+public:
+ LwpFooterLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpFooterLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_FOOTER_LAYOUT; }
+ using LwpPlacableLayout::RegisterStyle;
+ void RegisterStyle(XFPageMaster* pm1);
+ void RegisterStyle(XFMasterPage* mp1);
+
+protected:
+ void Read() override;
+ void ParseMargins(XFFooterStyle* pFooterStyle);
+ void ParseBorder(XFFooterStyle* pFooterStyle);
+ void ParseShadow(XFFooterStyle* pFooterStyle);
+ void ParsePatternFill(XFFooterStyle* pFooterStyle);
+ void ParseBackGround(XFFooterStyle* pFooterStyle);
+
+ void ParseBackColor(XFFooterStyle* pFooterStyle);
+
+ void ParseWaterMark(XFFooterStyle* pFooterStyle);
+
+private:
+ sal_Int32 m_nBorderOffset;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
new file mode 100644
index 000000000..50a1cd96e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -0,0 +1,848 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwppara.hxx"
+#include <lwpglobalmgr.hxx>
+#include <lwpfilehdr.hxx>
+#include "lwppagelayout.hxx"
+#include "lwpparaproperty.hxx"
+#include "lwpparastyle.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfparagraph.hxx>
+#include <xfilter/xfmargins.hxx>
+#include <xfilter/xfsection.hxx>
+#include <xfilter/xfsectionstyle.hxx>
+#include <xfilter/xfcolor.hxx>
+#include <xfilter/xfliststyle.hxx>
+#include "lwpfribheader.hxx"
+#include "lwplayout.hxx"
+#include "lwpbulletstylemgr.hxx"
+#include "lwpstory.hxx"
+#include "lwpsilverbullet.hxx"
+
+#include <lwpdropcapmgr.hxx>
+#include <memory>
+#include <o3tl/sorted_vector.hxx>
+
+LwpPara::LwpPara(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+ , m_nOrdinal(0)
+ , m_nFlags(0)
+ , m_nLevel(0)
+ , m_FontID(0)
+ , m_AllText("")
+ , m_bHasBullet(false)
+ , m_pSilverBullet(nullptr)
+ , m_bBullContinue(false)
+ , m_SectionStyleName("")
+ , m_bHasDropcap(false)
+ , m_nLines(0)
+ , m_nChars(0)
+ , m_pDropcapLayout(nullptr)
+ , m_BelowSpacing(0)
+{
+}
+
+LwpPara::~LwpPara()
+{
+}
+
+void LwpPara::Read()
+{
+ LwpDLVList::Read();
+
+ bool Simple;
+ bool Notify = false;
+ if(LwpFileHeader::m_nFileRevision<0x0006)
+ Simple = false;
+ else if(LwpFileHeader::m_nFileRevision<0x000B)
+ Simple = m_pObjStrm->QuickReaduInt8() != 0;
+ else
+ {
+ sal_uInt8 Flag = m_pObjStrm->QuickReaduInt8();
+
+ const int DISK_SIMPLE = 1;
+ const int DISK_NOTIFY = 2;
+
+ Simple = (Flag & DISK_SIMPLE) != 0;
+ Notify = (Flag & DISK_NOTIFY) != 0;
+ }
+
+ if(!Simple)
+ {
+ m_nOrdinal = m_pObjStrm->QuickReaduInt32();
+ if(LwpFileHeader::m_nFileRevision<0x000B)
+ {
+ assert(false);
+ }
+ else
+ {
+ if (Notify)
+ {
+ LwpForked3NotifyList aNotifyList;
+ aNotifyList.GetExtraList().Read(m_pObjStrm.get());
+ aNotifyList.Read(m_pObjStrm.get());
+ }
+ }
+ }
+ else
+ m_nOrdinal = 0x0001;
+
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_ParaStyle.ReadIndexed(m_pObjStrm.get());
+
+ if(!Simple)
+ {
+ m_Hint.Read(m_pObjStrm.get());
+ }
+
+ m_Story.ReadIndexed(m_pObjStrm.get());
+ if(!Simple)
+ {
+ if(LwpFileHeader::m_nFileRevision<0x000B)
+ {
+ // TODO: to process
+ assert(false);
+ }
+ m_nLevel = m_pObjStrm->QuickReaduInt16();
+
+ if (m_nLevel > 9)
+ {
+ m_nLevel = 9;
+ }
+ }
+ else
+ m_nLevel = 0x0001;
+
+ m_Fribs.SetPara(this);// for silver bullet
+ m_Fribs.ReadPara(m_pObjStrm.get());
+
+ ReadPropertyList(m_pObjStrm.get());
+}
+
+void LwpPara::Parse(IXFStream* pOutputStream)
+{
+ m_xXFContainer.set(new XFContentContainer);
+ XFConvert(m_xXFContainer.get());
+ if (!m_xXFContainer)
+ return;
+ m_xXFContainer->ToXml(pOutputStream);
+ m_xXFContainer->Reset();
+ m_xXFContainer.clear();
+}
+
+void LwpPara::XFConvert(XFContentContainer* pCont)
+{
+ m_xXFContainer.set(pCont);
+
+ LwpStory *pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
+
+ if (pStory && pStory->GetDropcapFlag())
+ {
+ ParseDropcapContent();
+ return;
+ }
+
+ //Add the break before para
+ if (m_pBreaks && m_nOrdinal!=0)
+ AddBreakBefore(pCont);
+
+ //Create an XFPara for this VO_PARA
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(m_StyleName);
+
+ if(!m_SectionStyleName.isEmpty())
+ {
+ rtl::Reference<XFSection> xSection(CreateXFSection());
+ if (pStory)
+ pStory->AddXFContent(xSection.get());
+ m_xXFContainer = xSection;
+ }
+
+ if (m_bHasBullet && m_pSilverBullet)
+ {
+ rtl::Reference<XFContentContainer> xListItem = AddBulletList(m_xXFContainer.get());
+ if (xListItem)
+ {
+ xListItem->Add(xPara.get());
+ }
+ }
+ else if (m_xXFContainer)
+ {
+ LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
+ if (pBulletStyleMgr)
+ {
+ pBulletStyleMgr->SetCurrentSilverBullet(LwpObjectID());
+ pBulletStyleMgr->SetContinueFlag(false);
+ }
+ m_xXFContainer->Add(xPara.get());
+ }
+
+ m_Fribs.SetXFPara(xPara.get());
+ m_Fribs.XFConvert();
+
+ if (m_pBreaks && m_xXFContainer)
+ AddBreakAfter(m_xXFContainer.get());
+}
+
+void LwpPara::RegisterMasterPage(XFParaStyle const * pBaseStyle)
+{
+ //get story
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
+ //if pagelayout is modified, register the pagelayout
+ if(!(pStory && pStory->IsPMModified()))
+ return;
+
+ bool bNewSection = pStory->IsNeedSection();
+ LwpPageLayout* pLayout = pStory->GetCurrentLayout();
+ if(bNewSection)
+ {
+ RegisterNewSectionStyle(pLayout);
+ }
+
+ //register master page style
+ std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
+ *xOverStyle = *pBaseStyle;
+ xOverStyle->SetStyleName( "");
+ xOverStyle->SetMasterPage(pLayout->GetStyleName());
+ if (!m_ParentStyleName.isEmpty())
+ xOverStyle->SetParentStyleName(m_ParentStyleName);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+}
+/**
+ * @short register paragraph style
+ */
+void LwpPara::RegisterStyle()
+{ //1 reg autostyle
+// m_Fribs.SetPara(this);
+// m_Fribs.RegisterStyle();
+
+ //2 reg para style
+ if (!m_pFoundry)
+ return;
+ XFParaStyle* pBaseStyle = dynamic_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(m_ParaStyle));
+ if (pBaseStyle == nullptr) return;
+ m_StyleName = pBaseStyle->GetStyleName();//such intf to be added
+ m_ParentStyleName = m_StyleName;
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ if (pParaStyle && pParaStyle->GetIndent())
+ {
+ std::unique_ptr<LwpIndentOverride> pIndentOverride(GetParaStyle()->GetIndent()->clone());
+ m_pIndentOverride = std::move(pIndentOverride);
+ }
+
+ std::unique_ptr<XFParaStyle> xOverStyle;
+ bool noSpacing = true;
+ LwpParaProperty* pBulletProps = nullptr, *pNumberingProps = nullptr;
+
+ if (!m_vProps.empty())
+ {
+ bool noIndent = true;
+ xOverStyle.reset(new XFParaStyle);
+ *xOverStyle = *pBaseStyle;
+ xOverStyle->SetStyleName("");
+ sal_uInt32 PropType;
+ LwpParaStyle& rParaStyle = dynamic_cast<LwpParaStyle&>(*m_ParaStyle.obj());
+ for (auto & pProps : m_vProps)
+ {
+ PropType = pProps->GetType();
+ switch(PropType)
+ {
+ case PP_LOCAL_ALIGN:
+ {
+ LwpAlignmentOverride *pAlignment = static_cast<LwpParaAlignProperty*>(pProps.get())->GetAlignment();
+ if (pAlignment)
+ {
+ if (!rParaStyle.GetAlignment())
+ OverrideAlignment(nullptr, pAlignment, xOverStyle.get());
+ else
+ {
+ std::unique_ptr<LwpAlignmentOverride> const pAlign(
+ rParaStyle.GetAlignment()->clone());
+ OverrideAlignment(pAlign.get(),
+ pAlignment,
+ xOverStyle.get());
+ }
+ }
+ break;
+ }
+ case PP_LOCAL_INDENT:
+ {
+ noIndent = false;
+ LwpIndentOverride *pIndent = static_cast<LwpParaIndentProperty*>(pProps.get())->GetIndent();
+ if (pIndent)
+ {
+ if (!rParaStyle.GetIndent())
+ OverrideIndent(nullptr, pIndent, xOverStyle.get());
+ else
+ OverrideIndent(m_pIndentOverride.get(), pIndent, xOverStyle.get());
+ }
+ break;
+ }
+ case PP_LOCAL_SPACING:
+ {
+ noSpacing = false;
+ LwpSpacingOverride *pSpacing = static_cast<LwpParaSpacingProperty*>(pProps.get())->GetSpacing();
+ if (pSpacing)
+ {
+ if (!rParaStyle.GetSpacing())
+ OverrideSpacing(nullptr, pSpacing, xOverStyle.get());
+ else
+ {
+ std::unique_ptr<LwpSpacingOverride> const
+ pNewSpacing(rParaStyle.GetSpacing()->clone());
+ OverrideSpacing(pNewSpacing.get(), pSpacing, xOverStyle.get());
+ }
+ }
+ break;
+ }
+ case PP_LOCAL_BORDER:
+ {
+ OverrideParaBorder(pProps.get(), xOverStyle.get());
+ break;
+ }
+ case PP_LOCAL_BREAKS:
+ {
+ OverrideParaBreaks(pProps.get(), xOverStyle.get());
+ break;
+ }
+ case PP_LOCAL_BULLET:
+ {
+ pBulletProps = pProps.get();
+ break;
+ }
+ case PP_LOCAL_NUMBERING:
+ {
+ pNumberingProps = pProps.get();
+ break;
+ }
+ case PP_LOCAL_TABRACK:
+ {
+ break;
+ }
+ case PP_LOCAL_BACKGROUND:
+ {
+ LwpBackgroundOverride* pBGOver = static_cast<LwpParaBackGroundProperty*>(pProps.get())->GetBackground();
+ if (pBGOver)
+ {
+ LwpBackgroundStuff& rBGStuff = pBGOver->GetBGStuff();
+ if (!rBGStuff.IsTransparent() )
+ {
+ if (rBGStuff.IsPatternFill())
+ {
+ std::unique_ptr<XFBGImage> xXFBGImage(rBGStuff.GetFillPattern());
+ xOverStyle->SetBackImage(xXFBGImage);
+ }
+ else
+ {
+ LwpColor* pColor = rBGStuff.GetFillColor();
+ if (pColor && pColor->IsValidColor())
+ {
+ XFColor aXFColor( pColor->To24Color());
+ xOverStyle->SetBackColor( aXFColor );
+ }
+ }
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if (noIndent && m_pIndentOverride)
+ {
+ if (m_pIndentOverride->IsUseRelative() && GetParent())
+ {
+ OverrideIndent(nullptr,m_pIndentOverride.get(),xOverStyle.get());
+ }
+ }
+ if (!m_ParentStyleName.isEmpty())
+ xOverStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+
+ }
+ else //use named style
+ {
+ if (m_pIndentOverride)
+ {
+ if (m_pIndentOverride->IsUseRelative() && GetParent())
+ {
+ xOverStyle.reset(new XFParaStyle);
+ *xOverStyle = *pBaseStyle;
+ OverrideIndent(nullptr,m_pIndentOverride.get(),xOverStyle.get());
+ if (!m_ParentStyleName.isEmpty())
+ xOverStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+ }
+ }
+ }
+
+ if (IsInCell())
+ {
+ XFParaStyle* pOldStyle = pXFStyleManager->FindParaStyle(m_StyleName);
+ if (pOldStyle->GetNumberRight())
+ {
+ xOverStyle.reset(new XFParaStyle);
+ *xOverStyle = *pOldStyle;
+ xOverStyle->SetAlignType(enumXFAlignStart);
+ if (!m_ParentStyleName.isEmpty())
+ xOverStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+ }
+ }
+
+ // override bullet and numbering
+ OverrideParaBullet(pBulletProps);
+ OverrideParaNumbering(pNumberingProps);
+
+ //register bullet style
+ LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
+ if (pBulletStyleMgr)
+ {
+ // if has bullet or numbering
+ if (m_bHasBullet)
+ {
+ //if it's normal bullet
+ if (m_pSilverBullet)
+ {
+ if (m_pSilverBullet->HasName())
+ {
+ m_aBulletStyleName = m_pSilverBullet->GetBulletStyleName();
+ }
+ else if (!m_xBullOver->IsEditable())
+ {
+ m_aBulletStyleName = pBulletStyleMgr->RegisterBulletStyle(this, m_xBullOver.get(), m_pIndentOverride.get());
+ }
+
+ // test codes
+ if (m_pSilverBullet->IsBulletOrdered())
+ {
+ OUString aPreBullStyleName;
+ LwpNumberingOverride* pNumbering = GetParaNumbering();
+ sal_uInt16 nPosition = pNumbering->GetPosition();
+ bool bLesser = m_pSilverBullet->IsLesserLevel(nPosition);
+ LwpPara* pPara = this;
+ LwpPara* pPrePara = nullptr;
+ sal_uInt16 nNum = 0, nLevel = 0, nFoundLevel = 0xffff, nFoundBound = 0;
+
+ nFoundBound = nLevel = pNumbering->GetLevel();
+ if (nPosition == pNumbering->GetPosition())
+ {
+ nFoundBound++;
+ }
+ bool bHeading = pNumbering->IsHeading();
+
+ o3tl::sorted_vector<LwpPara*> aSeen;
+ while(true)
+ {
+ bool bAlreadySeen = !aSeen.insert(pPara).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ LwpSilverBullet* pParaSilverBullet = pPara->GetSilverBullet();
+ pNumbering = pPara->GetParaNumbering();
+
+ if (pPara->GetObjectID() != GetObjectID())
+ {
+ if (!pParaSilverBullet)
+ {
+ break;
+ }
+
+ /* If lesser, stop when we hit an outline style whose level is
+ * higher than our current level.
+ */
+ // restart based on Outline level?
+ if (pNumbering && bLesser && (!bHeading || pNumbering->IsHeading()))
+ {
+ if (nFoundLevel != 0xffff)
+ {
+ if (pNumbering->GetLevel() < nFoundLevel)
+ {
+ break;
+ }
+ if ((pNumbering->GetLevel() == nFoundLevel)
+ && (pParaSilverBullet->GetObjectID() != m_pSilverBullet->GetObjectID()
+ || pNumbering->GetPosition() != nPosition))
+ {
+ break;
+ }
+ }
+ else
+ {
+ if (pNumbering->GetLevel() < nFoundBound
+ && (pParaSilverBullet->GetObjectID() != m_pSilverBullet->GetObjectID()
+ || pNumbering->GetPosition() != nPosition))
+ {
+ nFoundBound = pNumbering->GetLevel();
+ }
+ }
+ }
+ }
+
+ // Don't bump the number if this bullet is skipped
+ if (m_xBullOver->IsSkip())
+ ;
+ else if ( pParaSilverBullet
+ && pParaSilverBullet->GetObjectID() == m_pSilverBullet->GetObjectID()
+ && pNumbering && nPosition == pNumbering->GetPosition())
+ {
+ if (bLesser)
+ {
+ if (nFoundLevel != 0xffff)
+ {
+ if (nFoundLevel == pNumbering->GetLevel())
+ {
+ aPreBullStyleName = pPara->GetBulletStyleName();
+ nNum++;
+ }
+ }
+ else if (pNumbering->GetLevel() <= nLevel)
+ {
+ if (pNumbering->GetLevel() >= nFoundBound)
+ {
+ break;
+ }
+ nFoundLevel = pNumbering->GetLevel();
+ aPreBullStyleName = pPara->GetBulletStyleName();
+ nNum++;
+ }
+ }
+ else
+ {
+ aPreBullStyleName = pPara->GetBulletStyleName();
+ nNum++;
+ }
+ }
+
+ pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj(VO_PARA).get());
+
+ if (!pPrePara)
+ {
+ LwpStory* pStory = pPara->GetStory();
+ pPrePara = pStory ? pStory->GetLastParaOfPreviousStory() : nullptr;
+
+ if (!pPrePara)
+ {
+ break;
+ }
+ }
+ pPara = pPrePara;
+ }
+ nNum = nNum ? nNum : 1;
+
+ if (nNum > 1)
+ {
+ m_aBulletStyleName = aPreBullStyleName;
+ m_bBullContinue = true;
+ }
+ else
+ {
+ m_bBullContinue = false;
+ if (IsInCell())
+ {
+ XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName));
+ if (pOldStyle)
+ {
+ std::unique_ptr<XFListStyle> xNewStyle(new XFListStyle(*pOldStyle));
+ m_aBulletStyleName = pXFStyleManager->AddStyle(std::move(xNewStyle)).m_pStyle->GetStyleName();
+ }
+ }
+ }
+
+ LwpStory* pMyStory = GetStory();
+ if (pMyStory)
+ {
+ if (pMyStory->IsBullStyleUsedBefore(m_aBulletStyleName, m_xParaNumbering->GetPosition()))
+ {
+ //m_bBullContinue = sal_True;
+ }
+ else
+ {
+ pMyStory->AddBullStyleName2List(m_aBulletStyleName, m_xParaNumbering->GetPosition());
+ }
+ }
+
+ }
+ // end of test codes
+ }
+ }
+ }
+
+ if (noSpacing)
+ {
+ LwpPara* pPrePara = dynamic_cast<LwpPara*>(GetPrevious().obj().get());
+ if (pPrePara && pPrePara->GetBelowSpacing()!=0)
+ {
+ xOverStyle.reset(new XFParaStyle);
+ *xOverStyle = *GetXFParaStyle();
+ XFMargins* pMargin = &xOverStyle->GetMargins();
+ pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
+ if (!m_ParentStyleName.isEmpty())
+ xOverStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+ }
+ }
+
+ //register tab style
+ if(m_Fribs.HasFrib(FRIB_TAG_TAB))
+ {
+ std::unique_ptr<XFParaStyle> xNewParaStyle(new XFParaStyle);
+ *xNewParaStyle = *GetXFParaStyle();
+ //xOverStyle->SetStyleName("");
+ RegisterTabStyle(xNewParaStyle.get());
+ if (!m_ParentStyleName.isEmpty())
+ xNewParaStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xNewParaStyle)).m_pStyle->GetStyleName();
+ }
+
+ //register master page;
+ RegisterMasterPage(GetXFParaStyle());
+
+ // reg auto style,lay here for pagebreak need overridden para style
+ m_Fribs.SetPara(this);
+ m_Fribs.RegisterStyle();
+
+ if (m_bHasDropcap)
+ {
+ GatherDropcapInfo();
+ std::unique_ptr<XFParaStyle> xStyle(new XFParaStyle);
+ *xStyle = *GetXFParaStyle();
+ xStyle->SetDropCap(m_nChars-1,m_nLines);
+ if (!m_ParentStyleName.isEmpty())
+ xStyle->SetParentStyleName(m_ParentStyleName);
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xStyle)).m_pStyle->GetStyleName();
+ }
+ // maybe useful for further version
+ // deleted because Leader of Table is not supported in this version
+ //AddTabStyleForTOC();
+}
+
+void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
+{
+ if( !pLayout )
+ return;
+
+ std::unique_ptr<XFSectionStyle> xSectStyle(new XFSectionStyle);
+ XFColumns* pColumns = pLayout->GetXFColumns();
+ if(pColumns)
+ {
+ xSectStyle->SetColumns(pColumns);
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_SectionStyleName = pXFStyleManager->AddStyle(std::move(xSectStyle)).m_pStyle->GetStyleName();
+}
+
+rtl::Reference<XFSection> LwpPara::CreateXFSection()
+{
+ rtl::Reference<XFSection> xXFSection(new XFSection);
+ xXFSection->SetStyleName(m_SectionStyleName);
+ m_SectionStyleName.clear();
+ return xXFSection;
+}
+
+/**************************************************************************
+ * @descr: register tab style
+**************************************************************************/
+void LwpPara::RegisterTabStyle(XFParaStyle* pXFParaStyle)
+{
+ LwpTabOverride aFinaOverride;
+ LwpTabOverride* pBase = nullptr;
+ //get the tabrack from the current layout
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
+ LwpMiddleLayout* pLayout = pStory ? pStory->GetTabLayout() : nullptr;
+ if(pLayout)
+ {
+ pBase = pLayout->GetTabOverride();
+ if(pBase)
+ {
+ pBase->Override(&aFinaOverride);
+ }
+ }
+
+ //get the tabrack from the base parastyle
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ pBase = pParaStyle->GetTabOverride();
+ if(pBase)
+ {
+ pBase->Override(&aFinaOverride);
+ }
+ //get the tabrack from the local property
+ pBase = GetLocalTabOverride();
+ if(pBase)
+ {
+ pBase->Override(&aFinaOverride);
+ }
+
+ LwpParaStyle::ApplyTab(pXFParaStyle, &aFinaOverride);
+}
+/**
+ * @short parse dropcap text
+ */
+void LwpPara::ParseDropcapContent()
+{
+ if (!GetFoundry())
+ return;
+ XFParagraph* pDropcap = GetFoundry()->GetDropcapMgr()->GetXFPara();
+ if (pDropcap)
+ {
+ m_Fribs.SetXFPara(pDropcap);
+ m_Fribs.XFConvert();
+ }
+}
+/**
+ * @short add paragraph break attribute
+ */
+void LwpPara::AddBreakBefore(XFContentContainer* pCont)
+{
+ if (!m_pBreaks || !pCont)
+ return;
+ if (m_pBreaks->IsPageBreakBefore())
+ {
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(m_BefPageBreakName);
+ pCont->Add(xPara.get());
+ }
+ else if (m_pBreaks->IsColumnBreakBefore())
+ {
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(m_BefColumnBreakName);
+ pCont->Add(xPara.get());
+ }
+}
+
+void LwpPara::AddBreakAfter(XFContentContainer* pCont)
+{
+ if (!m_pBreaks)
+ return;
+ if (m_pBreaks->IsPageBreakAfter())
+ {
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(m_AftPageBreakName);
+ pCont->Add(xPara.get());
+ }
+ else if (m_pBreaks->IsColumnBreakAfter())
+ {
+ rtl::Reference<XFParagraph> xPara(new XFParagraph);
+ xPara->SetStyleName(m_AftColumnBreakName);
+ pCont->Add(xPara.get());
+ }
+}
+
+LwpBulletStyleMgr* LwpPara::GetBulletStyleMgr()
+{
+ if (m_pFoundry)
+ {
+ return m_pFoundry->GetBulletStyleMgr();
+ }
+
+ return nullptr;
+}
+
+rtl::Reference<XFContentContainer> LwpPara::AddBulletList(XFContentContainer* pCont)
+{
+ LwpBulletStyleMgr* pBulletStyleMgr = GetBulletStyleMgr();
+ if (!pBulletStyleMgr)
+ {
+ assert(false);
+ return rtl::Reference<XFContentContainer>();
+ }
+
+ sal_uInt16 nLevel = m_nLevel;
+ bool bOrdered = false;
+ /*LwpStory* pMyStory =*/ GetStory();
+
+ pBulletStyleMgr->SetContinueFlag(m_bBullContinue);
+
+ if (m_pSilverBullet->IsBulletOrdered())
+ {
+ bOrdered = true;
+ }
+ if (m_pSilverBullet->HasName())
+ {
+ nLevel = m_xParaNumbering->GetPosition();
+ m_nLevel = nLevel;//for get para level
+ }
+
+ return pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
+ nLevel, m_xBullOver->IsSkip());
+}
+
+LwpNumberingOverride* LwpPara::GetParaNumbering()
+{
+ return m_xParaNumbering.get();
+}
+
+void LwpForked3NotifyList::Read(LwpObjectStream* pObjStrm)
+{
+ m_PersistentList.Read(pObjStrm);
+}
+
+void LwpNotifyListPersistent::Read(LwpObjectStream* pObjStrm)
+{
+ m_Head.ReadIndexed(pObjStrm);
+ pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppara.hxx b/lotuswordpro/source/filter/lwppara.hxx
new file mode 100644
index 000000000..bfb1dcb82
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppara.hxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * LwpPara: Word Pro object for paragraph
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARA_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARA_HXX
+
+#include <memory>
+#include <config_lgpl.h>
+
+#include <lwpobj.hxx>
+#include <lwpobjstrm.hxx>
+
+#include <string_view>
+#include <vector>
+#include "lwpdlvlist.hxx"
+#include <lwpbasetype.hxx>
+#include <lwpoverride.hxx>
+#include <lwpfoundry.hxx>
+#include "lwplayout.hxx"
+#include "lwpfribptr.hxx"
+#include "lwpfribtext.hxx"
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xfsection.hxx>
+
+class LwpParaProperty;
+class LwpPara;
+class LwpBreaksOverride;
+class LwpBulletStyleMgr;
+
+class LwpNotifyListPersistent final
+{
+public:
+ LwpNotifyListPersistent(){}
+ void Read(LwpObjectStream* pObjStrm);
+private:
+ LwpObjectID m_Head;
+};
+
+class LwpForked3NotifyList final
+{
+public:
+ LwpForked3NotifyList(){}
+ LwpNotifyListPersistent& GetExtraList() { return m_ExtraList; }
+ void Read(LwpObjectStream* pObjStrm);
+private:
+ LwpNotifyListPersistent m_ExtraList;
+ LwpNotifyListPersistent m_PersistentList;
+};
+
+class LwpParaStyle;
+class LwpTabOverride;
+class LwpNumberingOverride;
+class LwpSilverBullet;
+class LwpPageLayout;
+
+struct ParaNumbering
+{
+ LwpFribText* pPrefix;
+ LwpFribParaNumber* pParaNumber;
+ LwpFribText* pSuffix;
+
+ sal_uInt16 nNumLevel;//hidelevels of paranumber frib
+
+ ParaNumbering()
+ {
+ clear();
+ }
+
+ void clear()
+ {
+ pPrefix = nullptr;
+ pParaNumber = nullptr;
+ pSuffix = nullptr;
+ nNumLevel = 0;
+ }
+};
+
+class LwpDropcapLayout;
+class LwpPara : public LwpDLVList
+{
+public:
+ LwpPara(LwpObjectHeader const & objHdr, LwpSvStream* pStrm);
+
+ void Read() override;
+ void RegisterStyle() override;
+ void Parse(IXFStream* pOutputStream) override;
+ void XFConvert(XFContentContainer* pCont) override;
+
+ LwpPara* GetParent();
+ LwpObjectID& GetStoryID();
+ LwpStory* GetStory();
+
+ LwpParaStyle* GetParaStyle();
+ XFParaStyle* GetXFParaStyle();
+ LwpIndentOverride* GetIndent();
+ LwpTabOverride* GetLocalTabOverride();
+ LwpNumberingOverride* GetParaNumbering();
+
+ inline LwpSilverBullet* GetSilverBullet();
+ const OUString& GetBulletChar() const;
+ sal_uInt32 GetBulletFontID() const;
+ sal_uInt16 GetLevel() const;
+ bool GetBulletFlag() const;
+
+ void GetParaNumber(sal_uInt16 nPosition, ParaNumbering* pParaNumbering);
+ LwpFribPtr& GetFribs();
+ double GetBelowSpacing() const;
+ LwpParaProperty* GetProperty(sal_uInt32 nPropType);
+ void GatherDropcapInfo();
+ const OUString& GetBulletStyleName() const;
+ void SetBelowSpacing(double value);
+ void SetBulletFlag(bool bFlag);
+ void SetIndent(LwpIndentOverride* pIndentOverride);
+ void SetFirstFrib(const OUString& Content,sal_uInt32 FontID);
+ OUString const & GetContentText(bool bAllText = false);
+
+ void SetParaDropcap(bool bFlag);
+ void SetDropcapLayout(LwpDropcapLayout* pLayout);
+
+ XFContentContainer* GetXFContainer();
+ void AddXFContent(XFContent* pCont);
+ void SetXFContainer(XFContentContainer* pCont);
+ void RegisterTabStyle(XFParaStyle* pXFParaStyle);
+
+ LwpBulletStyleMgr* GetBulletStyleMgr();
+ bool operator <(LwpPara const & Other);
+ bool ComparePagePosition(LwpVirtualLayout const * pPreLayout, LwpVirtualLayout const * pNextLayout);
+
+ bool IsInCell();
+
+ void SetAllText(std::u16string_view sText);
+
+protected:
+ sal_uInt32 m_nOrdinal; // Ordinal number of this paragraph
+ LwpObjectID m_ParaStyle; // handle of paragraph style
+ LwpPoint m_Hint; // Paragraph hint - width & height
+ LwpObjectID m_Story; // Story the paragraph is part of
+
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nLevel;
+ LwpFribPtr m_Fribs;
+ std::vector< std::unique_ptr<LwpParaProperty> > m_vProps;
+ //LwpForked3NotifyList* m_NotifyList; //not saved
+
+ OUString m_StyleName;
+ OUString m_ParentStyleName;//Add to support toc
+ std::unique_ptr<LwpBreaksOverride> m_pBreaks;
+ OUString m_AftPageBreakName;
+ OUString m_BefPageBreakName;
+ OUString m_AftColumnBreakName;
+
+ OUString m_BefColumnBreakName;
+ std::unique_ptr<LwpIndentOverride> m_pIndentOverride;
+ OUString m_Content;//for silver bullet,get text of first frib
+ sal_uInt32 m_FontID;//for silver bullet
+ OUString m_AllText;//get all text in this paragraph
+
+ bool m_bHasBullet;
+ LwpObjectID m_aSilverBulletID;
+ LwpSilverBullet* m_pSilverBullet;
+ std::unique_ptr<LwpBulletOverride> m_xBullOver;
+ std::unique_ptr<LwpNumberingOverride> m_xParaNumbering;
+ OUString m_aBulletStyleName;
+ bool m_bBullContinue;
+ //end add
+
+ OUString m_SectionStyleName;
+ bool m_bHasDropcap;
+ sal_uInt16 m_nLines;
+ sal_uInt32 m_nChars;
+ LwpDropcapLayout* m_pDropcapLayout;
+ double m_BelowSpacing;
+
+ rtl::Reference<XFContentContainer> m_xXFContainer; //Current container for VO_PARA
+
+ enum
+ {
+ /* bit definitions for the paragraph object flags */
+ DEMAND_LOAD = 0x0001, // need to demand load this para
+ DATA_DIRTY = 0x0002, // paragraph data is dirty
+ SPELLSTARTOVER = 0x0004, // need to recheck paragraph
+ SPELLDIRTY = 0x0008, // has misspelled word in para
+ SPELLCHECKING = 0x0010, // started checking paragraph
+ READING = 0x0020, // We're loading this para from disk
+ DISKCHANGED = 0x0040, // Read size different from write size
+ USEFLOWBREAKS = 0x0080, // Use line breaks provided by filter
+ VALID_LEVEL = 0x0100, // cLevel is valid
+ NOUSECOUNT = 0x0200, // Don't change the style's use count
+ CHANGED = 0x0400, // This para has been edited
+ SPREADBULLET = 0x0800, // Para's bullet is in edit-on-page mode
+ NEWBULLET = 0x1000, // Bullets should have new font behavior
+
+ // Don't write these flags out to disk
+ NOWRITEFLAGS = (READING | DISKCHANGED | CHANGED),
+
+ MAX_INDENT_LEVELS = 10
+ };
+private:
+ virtual ~LwpPara() override;
+
+ static void OverrideAlignment(LwpAlignmentOverride* base,LwpAlignmentOverride* over,XFParaStyle* pOverStyle);
+ void OverrideIndent(LwpIndentOverride* base,LwpIndentOverride* over,XFParaStyle* pOverStyle);
+ void OverrideSpacing(LwpSpacingOverride* base,LwpSpacingOverride* over,XFParaStyle* pOverStyle);
+ void OverrideParaBorder(LwpParaProperty* pProps, XFParaStyle* pOverStyle);
+ void OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyle);
+
+ void OverrideParaBullet(LwpParaProperty* pProps);
+ void OverrideParaNumbering(LwpParaProperty const * pProps);
+
+ void RegisterMasterPage(XFParaStyle const * pBaseStyle);
+ void RegisterNewSectionStyle(LwpPageLayout* pLayout);
+
+ void ParseDropcapContent();
+ rtl::Reference<XFContentContainer> AddBulletList(XFContentContainer* pCont);
+ void AddBreakAfter(XFContentContainer* pCont);
+ void AddBreakBefore(XFContentContainer* pCont);
+ rtl::Reference<XFSection> CreateXFSection();
+
+ void ReadPropertyList(LwpObjectStream* pFile);
+};
+
+inline LwpSilverBullet* LwpPara::GetSilverBullet()
+{
+ return m_pSilverBullet;
+}
+inline const OUString& LwpPara::GetBulletChar() const
+{
+ return m_Content;
+}
+inline sal_uInt32 LwpPara::GetBulletFontID() const
+{
+ return m_FontID;
+}
+inline sal_uInt16 LwpPara::GetLevel() const
+{
+ return m_nLevel;
+}
+inline void LwpPara::SetBulletFlag(bool bFlag)
+{
+ m_bHasBullet = bFlag;
+}
+inline bool LwpPara::GetBulletFlag() const
+{
+ return m_bHasBullet;
+}
+inline LwpFribPtr& LwpPara::GetFribs()
+{
+ return m_Fribs;
+}
+inline XFContentContainer* LwpPara::GetXFContainer()
+{
+ return m_xXFContainer.get();
+}
+inline const OUString& LwpPara::GetBulletStyleName() const
+{
+ return m_aBulletStyleName;
+}
+inline void LwpPara::AddXFContent(XFContent* pCont)
+{
+ if (!m_xXFContainer)
+ throw std::runtime_error("paragraph lacks container");
+ m_xXFContainer->Add(pCont);
+}
+inline void LwpPara::SetXFContainer(XFContentContainer* pCont)
+{
+ m_xXFContainer.set(pCont);
+}
+inline LwpIndentOverride* LwpPara::GetIndent()
+{
+ return m_pIndentOverride.get();
+}
+inline void LwpPara::SetIndent(LwpIndentOverride* pIndentOverride)
+{
+ m_pIndentOverride.reset( pIndentOverride );
+}
+inline LwpObjectID& LwpPara::GetStoryID()
+{
+ return m_Story;
+}
+inline LwpStory* LwpPara::GetStory()
+{
+ if (m_Story.obj().is())
+ return dynamic_cast<LwpStory*>(m_Story.obj().get());
+ return nullptr;
+}
+inline void LwpPara::SetParaDropcap(bool bFlag)
+{
+ m_bHasDropcap = bFlag;
+}
+inline void LwpPara::SetDropcapLayout(LwpDropcapLayout* pLayout)
+{
+ m_pDropcapLayout = pLayout;
+}
+inline double LwpPara::GetBelowSpacing() const
+{
+ return m_BelowSpacing;
+}
+inline void LwpPara::SetBelowSpacing(double value)
+{
+ m_BelowSpacing = value;
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
new file mode 100644
index 000000000..cfd801cc0
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -0,0 +1,573 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+
+#include <boost/cast.hpp>
+
+#include "lwppara.hxx"
+#include <lwpglobalmgr.hxx>
+#include "lwpparaproperty.hxx"
+#include "lwpparastyle.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include "lwpfribheader.hxx"
+#include "lwplayout.hxx"
+
+#include "lwpstory.hxx"
+#include "lwpsilverbullet.hxx"
+#include "lwpframelayout.hxx"
+
+#include <o3tl/sorted_vector.hxx>
+
+// boost::polymorphic_downcast checks and reports (using assert), if the
+// cast is incorrect (in debug builds).
+using boost::polymorphic_downcast;
+
+/**
+ * @short get text of paragraph
+ */
+OUString const & LwpPara::GetContentText(bool bAllText)
+{
+// rFont = m_FontID;
+ if (bAllText)
+ {
+ m_Fribs.SetPara(this);
+ m_Fribs.GatherAllText();
+ return m_AllText;
+ }
+ else
+ return m_Content;
+}
+
+/**
+ * @short set text of paragraph
+ */
+void LwpPara::SetAllText(std::u16string_view sText)
+{
+ m_AllText+=sText;
+}
+
+/**
+ * @short set first frib content
+ */
+void LwpPara::SetFirstFrib(const OUString& Content,sal_uInt32 FontID)
+{
+ m_FontID= FontID;
+ m_Content=Content;
+}
+/**
+ * @short get paragraph xfstyle
+ */
+XFParaStyle* LwpPara::GetXFParaStyle()
+{
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ return pXFStyleManager->FindParaStyle(m_StyleName);
+}
+/**
+ * @short get drop cap info
+ */
+void LwpPara::GatherDropcapInfo()
+{
+ m_nLines = m_pDropcapLayout->GetLines();
+ m_nChars = m_pDropcapLayout->GetChars();
+}
+/**
+ * @short get parent paragraph
+ */
+LwpPara* LwpPara::GetParent()
+{
+ LwpPara* pPara;
+ sal_uInt16 otherlevel;
+ sal_uInt16 level = GetLevel();
+
+ if (level != 1)
+ {
+ pPara = dynamic_cast<LwpPara*>(GetPrevious().obj().get());
+ o3tl::sorted_vector<LwpPara*> aSeen;
+ while (pPara)
+ {
+ bool bAlreadySeen = !aSeen.insert(pPara).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ otherlevel = pPara->GetLevel();
+ if ((otherlevel < level) || (otherlevel && (level == 0)))
+ return pPara;
+ pPara = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj().get());
+ }
+ }
+ return nullptr;
+}
+
+/**
+ * @short: Offer prefix, paranumber and suffix according to position.
+ * @param: nPosition index of wanted paranumbering in the style-list.
+ * @param: pParaNumbering a pointer to the structure which contains prefix, paranumber and
+ * suffix.
+ */
+void LwpPara::GetParaNumber(sal_uInt16 nPosition, ParaNumbering* pParaNumbering)
+{
+ if (nPosition > 9)
+ {
+ return;
+ }
+ sal_uInt16 nCurrentPos = 0;
+
+ LwpFrib* pPreFrib = nullptr;
+ LwpFrib* pFrib = m_Fribs.GetFribs();
+ if (!pFrib)
+ {
+ return;
+ }
+
+ while (pFrib)
+ {
+ sal_uInt8 nFribType = pFrib->GetType();
+ if (nFribType == FRIB_TAG_PARANUMBER)
+ {
+ nCurrentPos++;
+ ModifierInfo* pModInfo = pFrib->GetModifiers();
+ if (pModInfo)
+ {
+ sal_uInt16 nHideLevels = pModInfo->aTxtAttrOverride.GetHideLevels();
+ if (nCurrentPos == nPosition)
+ {
+ //get prefix text frib
+ if (pPreFrib)
+ {
+ if ((pPreFrib->GetType() == FRIB_TAG_TEXT) &&
+ (pPreFrib->GetModifiers() && pPreFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels))
+ {
+ pParaNumbering->pPrefix = static_cast<LwpFribText*>(pPreFrib);
+ }
+ }
+
+ //get para numbering
+ pParaNumbering->pParaNumber = static_cast<LwpFribParaNumber*>(pFrib);
+ pParaNumbering->nNumLevel = nHideLevels;
+
+ //get suffix text frib
+ pFrib = pFrib->GetNext();
+ if ( pFrib )
+ {
+ if( pFrib->GetType() == FRIB_TAG_TEXT )
+ {
+ if (
+ (pFrib->GetNext() && pFrib->GetNext()->GetType() == FRIB_TAG_TEXT) ||
+ (pFrib->GetModifiers() && pFrib->GetModifiers()->aTxtAttrOverride.GetHideLevels() == nHideLevels)
+ )
+ {
+ pParaNumbering->pSuffix = static_cast<LwpFribText*>(pFrib);
+ }
+ }
+ }
+
+ break;
+ }
+ }
+ else
+ {
+ if (nCurrentPos == nPosition)
+ {
+ //get prefix text frib
+ if (pPreFrib)
+ {
+ if (pPreFrib->GetType() == FRIB_TAG_TEXT)
+ {
+ pParaNumbering->pPrefix = static_cast<LwpFribText*>(pPreFrib);
+ }
+ }
+
+ //get para numbering
+ pParaNumbering->pParaNumber = static_cast<LwpFribParaNumber*>(pFrib);
+
+ //get suffix text frib
+ pFrib = pFrib->GetNext();
+ if ( pFrib )
+ {
+ if (pFrib->GetType() == FRIB_TAG_TEXT)
+ {
+ pParaNumbering->pSuffix = static_cast<LwpFribText*>(pFrib);
+ }
+ }
+
+ }
+ }
+ }
+ pPreFrib = pFrib;
+ if (pFrib)
+ {
+ pFrib = pFrib->GetNext();
+ }
+ }
+}
+/**
+ * @short override alignment
+ */
+void LwpPara::OverrideAlignment(LwpAlignmentOverride* base,LwpAlignmentOverride* over,XFParaStyle* pOverStyle)
+{
+ if (base)//the latter two parameter never be null
+ {
+ over->Override(base);
+ LwpParaStyle::ApplyAlignment(pOverStyle,base);
+ }
+ else
+ LwpParaStyle::ApplyAlignment(pOverStyle,over);
+}
+/**
+ * @short override indent attribute
+ */
+void LwpPara::OverrideIndent(LwpIndentOverride* base,LwpIndentOverride* over,XFParaStyle* pOverStyle)
+{
+ if (base)//the latter two parameter never be null
+ {
+ over->Override(base);
+ LwpParaStyle::ApplyIndent(this,pOverStyle,base);
+ }
+ else
+ {
+ LwpParaStyle::ApplyIndent(this,pOverStyle,over);
+ }
+}
+/**
+ * @short override spacing
+ */
+void LwpPara::OverrideSpacing(LwpSpacingOverride* base,LwpSpacingOverride* over,XFParaStyle* pOverStyle)
+{
+ if (base)//the latter two parameter never be null
+ {
+ if (over)
+ over->Override(base);
+ LwpParaStyle::ApplySpacing(this,pOverStyle,base);
+ }
+ else
+ LwpParaStyle::ApplySpacing(this,pOverStyle,over);
+}
+
+/**
+ * @short: Get parastyle object according to the objID.
+ * @return: pointer to the parastyle.
+ */
+LwpParaStyle* LwpPara::GetParaStyle()
+{
+ return dynamic_cast<LwpParaStyle*>(m_ParaStyle.obj(VO_PARASTYLE).get());
+}
+
+/**
+ * @short: Override paraborder style.
+ * @param: pProps pointer to the LwpParaProperty and we can get local breaks through it.
+ * @param: pOverStyle pointer to XFParaStyle which contains the parastyle for XFilter.
+ */
+void LwpPara::OverrideParaBorder(LwpParaProperty* pProps, XFParaStyle* pOverStyle)
+{
+ // get paraborder in parastyle
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ if (!pParaStyle)
+ {
+ return;
+ }
+
+ LwpOverride* pBorder = pParaStyle->GetParaBorder();
+ std::unique_ptr<LwpParaBorderOverride> pFinalBorder(
+ pBorder
+ ? polymorphic_downcast<LwpParaBorderOverride*>(pBorder->clone())
+ : new LwpParaBorderOverride)
+ ;
+
+ // get local border
+ pBorder = static_cast<LwpParaBorderProperty*>(pProps)->GetLocalParaBorder();
+ if (pBorder)
+ {
+ std::unique_ptr<LwpParaBorderOverride> pLocalBorder(
+ polymorphic_downcast<LwpParaBorderOverride*>(pBorder->clone()));
+ pLocalBorder->Override(pFinalBorder.get());
+ }
+
+ LwpParaStyle::ApplyParaBorder(pOverStyle, pFinalBorder.get());
+}
+/**
+ * @short: Override parabreaks style.
+ * @param: pProps pointer to the LwpParaProperty and we can get local breaks through it.
+ * @param: pOverStyle pointer to XFParaStyle which contains the parastyle for XFilter.
+ */
+void LwpPara::OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyle)
+{
+ // get breaks in parastyle
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ if (!pParaStyle)
+ {
+ return;
+ }
+
+ LwpOverride* pBreaks = pParaStyle->GetBreaks();
+ std::unique_ptr<LwpBreaksOverride> pFinalBreaks(
+ pBreaks
+ ? polymorphic_downcast<LwpBreaksOverride*>(pBreaks->clone())
+ : new LwpBreaksOverride)
+ ;
+
+ // get local breaks
+ pBreaks = static_cast<LwpParaBreaksProperty*>(pProps)->GetLocalParaBreaks();
+ if (pBreaks)
+ {
+ std::unique_ptr<LwpBreaksOverride> const pLocalBreaks(
+ polymorphic_downcast<LwpBreaksOverride*>(pBreaks->clone()));
+ pLocalBreaks->Override(pFinalBreaks.get());
+ }
+
+ // save the breaks
+ m_pBreaks.reset( pFinalBreaks.release() );
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ if (m_pBreaks->IsKeepWithNext())
+ {
+ pOverStyle->SetBreaks(enumXFBreakKeepWithNext);
+ }
+ if (m_pBreaks->IsPageBreakBefore())
+ {
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+ pStyle->SetBreaks(enumXFBreakAftPage);
+ m_BefPageBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+ }
+ if (m_pBreaks->IsPageBreakAfter())
+ {
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+ pStyle->SetBreaks(enumXFBreakAftPage);
+ m_AftPageBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+ }
+ if (m_pBreaks->IsColumnBreakBefore())
+ {
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+ pStyle->SetBreaks(enumXFBreakAftColumn);//tmp after, should change when layout read
+ m_BefColumnBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+ }
+ if (m_pBreaks->IsColumnBreakAfter())
+ {
+ std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
+ pStyle->SetBreaks(enumXFBreakAftColumn);
+ m_AftColumnBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
+ }
+
+// pParaStyle->ApplyBreaks(pOverStyle, &aFinalBreaks);
+}
+
+/**
+ * @short: Override bullet styles.
+ * @param: pProps pointer to the LwpParaProperty and we can get local bullet through it.
+ */
+void LwpPara::OverrideParaBullet(LwpParaProperty* pProps)
+{
+ // get bulletoverride in parastyle
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ if (!pParaStyle)
+ {
+ return;
+ }
+
+ if (pProps)
+ {
+ m_xBullOver.reset(new LwpBulletOverride);
+ // get local bulletoverride
+ LwpBulletOverride* pLocalBullet = static_cast<LwpParaBulletProperty*>(pProps)->GetLocalParaBullet();
+ if (!pLocalBullet)
+ {
+ return;
+ }
+
+ LwpObjectID aSilverBulletID = pLocalBullet->GetSilverBullet();
+ if (aSilverBulletID.IsNull())
+ {
+ return;
+ }
+ else
+ {
+ m_bHasBullet = true;
+
+ const LwpBulletOverride& rBullet= pParaStyle->GetBulletOverride();
+ std::unique_ptr<LwpBulletOverride> xFinalBullet(rBullet.clone());
+
+ std::unique_ptr<LwpBulletOverride> const pLocalBullet2(pLocalBullet->clone());
+ pLocalBullet2->Override(xFinalBullet.get());
+
+ aSilverBulletID = xFinalBullet->GetSilverBullet();
+ m_xBullOver = std::move(xFinalBullet);
+ if (!aSilverBulletID.IsNull())
+ {
+ m_pSilverBullet = dynamic_cast<LwpSilverBullet*>(aSilverBulletID.obj(VO_SILVERBULLET).get());
+ if (m_pSilverBullet)
+ m_pSilverBullet->SetFoundry(m_pFoundry);
+ }
+
+ m_aSilverBulletID = aSilverBulletID;
+ }
+ }
+ else
+ {
+ const LwpBulletOverride& rBullOver = pParaStyle->GetBulletOverride();
+ m_aSilverBulletID = rBullOver.GetSilverBullet();
+ if (!m_aSilverBulletID.IsNull())
+ {
+ m_bHasBullet = true;
+
+ m_pSilverBullet = dynamic_cast<LwpSilverBullet*>(m_aSilverBulletID.obj(VO_SILVERBULLET).get());
+ if (m_pSilverBullet)
+ m_pSilverBullet->SetFoundry(m_pFoundry);
+ }
+
+ m_xBullOver.reset(rBullOver.clone());
+ }
+}
+/**
+ * @short: Override paranumbering properties.
+ * @param: pProps pointer to the LwpParaProperty and we can get local paranumbering through it.
+ */
+void LwpPara::OverrideParaNumbering(LwpParaProperty const * pProps)
+{
+ // get numbering override in parastyle
+ LwpParaStyle* pParaStyle = GetParaStyle();
+ if (!pParaStyle)
+ {
+ return;
+ }
+
+ LwpNumberingOverride* pParaNumbering = pParaStyle->GetNumberingOverride();
+ std::unique_ptr<LwpNumberingOverride> pOver(new LwpNumberingOverride);
+ //Override with the local numbering, if any
+ if (pProps)
+ {
+ LwpNumberingOverride* pPropNumbering = static_cast<LwpParaNumberingProperty const *>(pProps)->GetLocalNumbering();
+ if (pPropNumbering)
+ {
+ pOver.reset(pPropNumbering->clone());
+ }
+ }
+ else
+ {
+ if (pParaNumbering)
+ {
+ pOver.reset(pParaNumbering->clone());
+ }
+ }
+
+ if (m_nFlags & VALID_LEVEL)
+ {
+ pOver->OverrideLevel(m_nLevel);
+ }
+
+ m_xParaNumbering = std::move(pOver);
+}
+
+/**************************************************************************
+ * @descr: Get property according to the property type
+**************************************************************************/
+LwpParaProperty* LwpPara::GetProperty(sal_uInt32 nPropType)
+{
+ for (auto & i : m_vProps)
+ if(i->GetType() == nPropType)
+ {
+ return i.get();
+ }
+ return nullptr;
+}
+
+/**************************************************************************
+ * @descr: Get local tab rack
+**************************************************************************/
+LwpTabOverride* LwpPara::GetLocalTabOverride()
+{
+ LwpParaProperty* pProp = GetProperty(PP_LOCAL_TABRACK);
+ if(pProp)
+ {
+ return static_cast<LwpParaTabRackProperty*>(pProp)->GetTab();
+ }
+ return nullptr;
+}
+
+/**
+* @descr: Determined which para is earlier in position
+*
+*/
+bool LwpPara::operator< (LwpPara const & Other)
+{
+ return m_nOrdinal < Other.m_nOrdinal;
+}
+
+/**
+* @descr: If the two layouts in the same para, compare which layout is earlied according to frib order
+*
+*/
+bool LwpPara::ComparePagePosition(LwpVirtualLayout const * pPreLayout, LwpVirtualLayout const * pNextLayout)
+{
+ m_Fribs.SetPara(this);
+ return m_Fribs.ComparePagePosition(pPreLayout, pNextLayout);
+}
+
+/**
+ * @short check paragraph in cell or not
+ */
+bool LwpPara::IsInCell()
+{
+ LwpStory *pStory = GetStory();
+ if (!pStory)
+ return false;
+ rtl::Reference<LwpVirtualLayout> xLayout(pStory->GetLayout(nullptr));
+ return xLayout.is() && xLayout->IsCell();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparaborderoverride.cxx b/lotuswordpro/source/filter/lwpparaborderoverride.cxx
new file mode 100644
index 000000000..dc0a11c8f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparaborderoverride.cxx
@@ -0,0 +1,386 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Border override of Wordpro.
+************************************************************************/
+#include <memory>
+
+#include "clone.hxx"
+#include "lwpparaborderoverride.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwpshadow.hxx"
+#include "lwpmargins.hxx"
+#include <sal/log.hxx>
+
+LwpParaBorderOverride::LwpParaBorderOverride()
+{
+ m_pBorderStuff.reset(new LwpBorderStuff());
+ m_pBetweenStuff.reset(new LwpBorderStuff());
+ m_pShadow.reset(new LwpShadow());
+ m_pMargins.reset(new LwpMargins());
+
+ m_eAboveType = PB_NONE;
+ m_eBelowType = PB_NONE;
+ m_eRightType = PB_NONE;
+ m_eBetweenType = PB_NONE;
+
+ m_nAboveWidth = 0;
+ m_nBelowWidth = 0;
+ m_nBetweenWidth = 0;
+ m_nRightWidth = 0;
+
+ m_nBetweenMargin = 0;
+}
+
+LwpParaBorderOverride::LwpParaBorderOverride(LwpParaBorderOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_eAboveType(rOther.m_eAboveType)
+ , m_eBelowType(rOther.m_eBelowType)
+ , m_eRightType(rOther.m_eRightType)
+ , m_eBetweenType(rOther.m_eBetweenType)
+ , m_nAboveWidth(rOther.m_nAboveWidth)
+ , m_nBelowWidth(rOther.m_nBelowWidth)
+ , m_nBetweenWidth(rOther.m_nBetweenWidth)
+ , m_nRightWidth(rOther.m_nRightWidth)
+ , m_nBetweenMargin(rOther.m_nBetweenMargin)
+{
+ m_pBorderStuff.reset(::clone(rOther.m_pBorderStuff.get()));
+ m_pBetweenStuff.reset(::clone(rOther.m_pBetweenStuff.get()));
+ m_pShadow.reset(::clone(rOther.m_pShadow.get()));
+ m_pMargins.reset(::clone(rOther.m_pMargins.get()));
+}
+
+LwpParaBorderOverride::~LwpParaBorderOverride() {}
+
+LwpParaBorderOverride* LwpParaBorderOverride::clone() const
+{
+ return new LwpParaBorderOverride(*this);
+}
+
+namespace
+{
+LwpParaBorderOverride::BorderWidthType readBorderWidthType(LwpObjectStream* stream)
+{
+ sal_uInt16 n = stream->QuickReaduInt16();
+ if (n > LwpParaBorderOverride::PB_CUSTOMWIDTH)
+ {
+ SAL_WARN("lwp", "bad BorderWidthType " << n);
+ n = LwpParaBorderOverride::PB_NONE;
+ }
+ return static_cast<LwpParaBorderOverride::BorderWidthType>(n);
+}
+}
+
+void LwpParaBorderOverride::Read(LwpObjectStream* pStrm)
+{
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ //start here:
+ m_pBorderStuff->Read(pStrm);
+ m_pShadow->Read(pStrm);
+ m_pMargins->Read(pStrm);
+
+ m_eAboveType = readBorderWidthType(pStrm);
+ m_eBelowType = readBorderWidthType(pStrm);
+ m_eRightType = readBorderWidthType(pStrm);
+
+ if (pStrm->CheckExtra())
+ {
+ m_pBetweenStuff->Read(pStrm);
+
+ m_eBetweenType = readBorderWidthType(pStrm);
+ m_nBetweenWidth = pStrm->QuickReaduInt32();
+ m_nBetweenMargin = pStrm->QuickReaduInt32();
+
+ if (pStrm->CheckExtra())
+ {
+ m_eRightType = readBorderWidthType(pStrm);
+ m_nRightWidth = pStrm->QuickReaduInt32();
+ }
+ }
+ }
+
+ pStrm->SkipExtra();
+}
+
+void LwpParaBorderOverride::Override(LwpParaBorderOverride* pOther)
+{
+ if (m_nApply & PBO_STUFF)
+ {
+ if (IsBorderStuffOverridden())
+ {
+ pOther->OverrideBorderStuff(m_pBorderStuff.get());
+ }
+ else
+ {
+ pOther->RevertBorderStuff();
+ }
+ }
+
+ if (m_nApply & PBO_BETWEENSTUFF)
+ {
+ if (IsBetweenStuffOverridden())
+ {
+ pOther->OverrideBetweenStuff(m_pBetweenStuff.get());
+ }
+ else
+ {
+ pOther->RevertBetweenStuff();
+ }
+ }
+
+ if (m_nApply & PBO_SHADOW)
+ {
+ if (IsShadowOverridden())
+ {
+ pOther->OverrideShadow(m_pShadow.get());
+ }
+ else
+ {
+ pOther->RevertShadow();
+ }
+ }
+
+ if (m_nApply & PBO_MARGINS)
+ {
+ if (IsMarginsOverridden())
+ {
+ pOther->OverrideMargins(m_pMargins.get());
+ }
+ else
+ {
+ pOther->RevertMargins();
+ }
+ }
+
+ if (m_nApply & PBO_ABOVETYPE)
+ {
+ if (IsAboveTypeOverridden())
+ {
+ pOther->OverrideAboveType(m_eAboveType);
+ }
+ else
+ {
+ pOther->RevertAboveType();
+ }
+ }
+
+ if (m_nApply & PBO_BELOWTYPE)
+ {
+ if (IsBelowTypeOverridden())
+ {
+ pOther->OverrideBelowType(m_eBelowType);
+ }
+ else
+ {
+ pOther->RevertBelowType();
+ }
+ }
+
+ if (m_nApply & PBO_RIGHTTYPE)
+ {
+ if (IsRightTypeOverridden())
+ {
+ pOther->OverrideRightType(m_eRightType);
+ }
+ else
+ {
+ pOther->RevertRightType();
+ }
+ }
+
+ if (m_nApply & PBO_BETWEENTYPE)
+ {
+ if (IsBetweenTypeOverridden())
+ {
+ pOther->OverrideBetweenType(m_eBetweenType);
+ }
+ else
+ {
+ pOther->RevertBetweenType();
+ }
+ }
+
+ if (m_nApply & PBO_ABOVE)
+ {
+ if (IsAboveWidthOverridden())
+ {
+ pOther->OverrideAboveWidth(m_nAboveWidth);
+ }
+ else
+ {
+ pOther->RevertAboveWidth();
+ }
+ }
+
+ if (m_nApply & PBO_BELOW)
+ {
+ if (IsBelowWidthOverridden())
+ {
+ pOther->OverrideBelowWidth(m_nBelowWidth);
+ }
+ else
+ {
+ pOther->RevertBelowWidth();
+ }
+ }
+
+ if (m_nApply & PBO_BETWEEN)
+ {
+ if (IsBetweenWidthOverridden())
+ {
+ pOther->OverrideBetweenWidth(m_nBetweenWidth);
+ }
+ else
+ {
+ pOther->RevertBetweenWidth();
+ }
+ }
+
+ if (m_nApply & PBO_BETWEENMARGIN)
+ {
+ if (IsBetweenMarginOverridden())
+ {
+ pOther->OverrideBetweenMargin(m_nBetweenMargin);
+ }
+ else
+ {
+ pOther->RevertBetweenMargin();
+ }
+ }
+
+ if (m_nApply & PBO_RIGHT)
+ {
+ if (IsRightWidthOverridden())
+ {
+ pOther->OverrideRightWidth(m_nRightWidth);
+ }
+ else
+ {
+ pOther->RevertRightWidth();
+ }
+ }
+}
+
+void LwpParaBorderOverride::OverrideBorderStuff(LwpBorderStuff const* pBorderStuff)
+{
+ *m_pBorderStuff = *pBorderStuff;
+ LwpOverride::Override(PBO_STUFF, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBetweenStuff(LwpBorderStuff const* pBorderStuff)
+{
+ *m_pBetweenStuff = *pBorderStuff;
+ LwpOverride::Override(PBO_BETWEENSTUFF, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideShadow(LwpShadow const* pShadow)
+{
+ *m_pShadow = *pShadow;
+ LwpOverride::Override(PBO_SHADOW, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideMargins(LwpMargins const* pMargins)
+{
+ *m_pMargins = *pMargins;
+ LwpOverride::Override(PBO_MARGINS, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideAboveType(BorderWidthType eNewType)
+{
+ m_eAboveType = eNewType;
+ LwpOverride::Override(PBO_ABOVETYPE, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBelowType(BorderWidthType eNewType)
+{
+ m_eBelowType = eNewType;
+ LwpOverride::Override(PBO_BELOWTYPE, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideRightType(BorderWidthType eNewType)
+{
+ m_eRightType = eNewType;
+ LwpOverride::Override(PBO_RIGHTTYPE, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBetweenType(BorderWidthType eNewType)
+{
+ m_eBetweenType = eNewType;
+ LwpOverride::Override(PBO_BETWEENTYPE, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideAboveWidth(sal_uInt32 nNewWidth)
+{
+ m_nAboveWidth = nNewWidth;
+ LwpOverride::Override(PBO_ABOVE, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBelowWidth(sal_uInt32 nNewWidth)
+{
+ m_nBelowWidth = nNewWidth;
+ LwpOverride::Override(PBO_BELOW, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBetweenWidth(sal_uInt32 nNewWidth)
+{
+ m_nBetweenWidth = nNewWidth;
+ LwpOverride::Override(PBO_BETWEEN, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideRightWidth(sal_uInt32 nNewWidth)
+{
+ m_nRightWidth = nNewWidth;
+ LwpOverride::Override(PBO_RIGHT, STATE_ON);
+}
+void LwpParaBorderOverride::OverrideBetweenMargin(sal_uInt32 nNewMargin)
+{
+ m_nBetweenMargin = nNewMargin;
+ LwpOverride::Override(PBO_BETWEENMARGIN, STATE_ON);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparaborderoverride.hxx b/lotuswordpro/source/filter/lwpparaborderoverride.hxx
new file mode 100644
index 000000000..cb711052c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparaborderoverride.hxx
@@ -0,0 +1,283 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+* @file
+* Border override of Wordpro.
+************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARABORDEROVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARABORDEROVERRIDE_HXX
+
+#include <lwpoverride.hxx>
+
+class LwpBorderStuff;
+class LwpShadow;
+class LwpMargins;
+
+class LwpParaBorderOverride final : public LwpOverride
+{
+public:
+ LwpParaBorderOverride();
+ virtual ~LwpParaBorderOverride() override;
+
+ virtual LwpParaBorderOverride* clone() const override;
+
+ enum BorderWidthType
+ {
+ PB_NONE = 0, /* No border */
+ PB_TEXTWIDTH = 1, /* Border is width of text */
+ PB_MARGINWIDTH = 2, /* Border extends to margins */
+ PB_CUSTOMWIDTH = 3 /* Border width is specified explicitly */
+ };
+ virtual void Read(LwpObjectStream *pStrm) override;
+
+ LwpShadow* GetShadow(){ return m_pShadow.get(); }
+ LwpBorderStuff* GetBorderStuff(){ return m_pBorderStuff.get(); }
+ LwpMargins* GetMargins() { return m_pMargins.get(); };
+
+ void Override(LwpParaBorderOverride* pOther);
+
+ inline bool IsBorderStuffOverridden() const;
+ inline bool IsBetweenStuffOverridden() const;
+ inline bool IsShadowOverridden() const;
+ inline bool IsMarginsOverridden() const;
+ inline bool IsAboveTypeOverridden() const;
+ inline bool IsBelowTypeOverridden() const;
+ inline bool IsRightTypeOverridden() const;
+ inline bool IsBetweenTypeOverridden() const;
+ inline bool IsAboveWidthOverridden() const;
+ inline bool IsBelowWidthOverridden() const;
+ inline bool IsBetweenWidthOverridden() const;
+ inline bool IsRightWidthOverridden() const;
+ inline bool IsBetweenMarginOverridden() const;
+
+ void OverrideBorderStuff(LwpBorderStuff const * pBorderStuff);
+ void OverrideBetweenStuff(LwpBorderStuff const * pBorderStuff);
+ void OverrideShadow(LwpShadow const * pShadow);
+ void OverrideMargins(LwpMargins const * pMargins);
+ void OverrideAboveType(BorderWidthType eNewType);
+ void OverrideBelowType(BorderWidthType eNewType);
+ void OverrideRightType(BorderWidthType eNewType);
+ void OverrideBetweenType(BorderWidthType eNewType);
+ void OverrideAboveWidth(sal_uInt32 nNewWidth);
+ void OverrideBelowWidth(sal_uInt32 nNewWidth);
+ void OverrideBetweenWidth(sal_uInt32 nNewWidth);
+ void OverrideRightWidth(sal_uInt32 nNewWidth);
+ void OverrideBetweenMargin(sal_uInt32 nNewMargin);
+
+ inline void RevertBorderStuff();
+ inline void RevertBetweenStuff();
+ inline void RevertShadow();
+ inline void RevertMargins();
+ inline void RevertAboveType();
+ inline void RevertBelowType();
+ inline void RevertRightType();
+ inline void RevertBetweenType();
+ inline void RevertAboveWidth();
+ inline void RevertBelowWidth();
+ inline void RevertBetweenWidth();
+ inline void RevertRightWidth();
+ inline void RevertBetweenMargin();
+
+ friend class LwpParaBorderPiece;
+
+private:
+ LwpParaBorderOverride(LwpParaBorderOverride const& rOther);
+ LwpParaBorderOverride& operator=(LwpParaBorderOverride const& rOther) = delete;
+
+ enum
+ {
+ PBO_STUFF = 0x0001,
+ PBO_SHADOW = 0x0002,
+ PBO_MARGINS = 0x0004,
+ PBO_ABOVETYPE = 0x0008,
+ PBO_BELOWTYPE = 0x0010,
+ PBO_RIGHTTYPE = 0x0020,
+ PBO_ABOVE = 0x0040,
+ PBO_BELOW = 0x0080,
+ PBO_BETWEENSTUFF = 0x0100,
+ PBO_BETWEENTYPE = 0x0200,
+ PBO_BETWEEN = 0x0400,
+ PBO_BETWEENMARGIN = 0x0800,
+ PBO_RIGHT = 0x1000
+ };
+
+ std::unique_ptr<LwpBorderStuff> m_pBorderStuff;
+ std::unique_ptr<LwpBorderStuff> m_pBetweenStuff;
+ std::unique_ptr<LwpShadow> m_pShadow;
+ std::unique_ptr<LwpMargins> m_pMargins;
+
+ BorderWidthType m_eAboveType;
+ BorderWidthType m_eBelowType;
+ BorderWidthType m_eRightType;
+ BorderWidthType m_eBetweenType;
+
+ sal_uInt32 m_nAboveWidth;
+ sal_uInt32 m_nBelowWidth;
+ sal_uInt32 m_nBetweenWidth;
+ sal_uInt32 m_nRightWidth;
+
+ sal_uInt32 m_nBetweenMargin;
+};
+
+inline bool LwpParaBorderOverride::IsBorderStuffOverridden() const
+{
+ return ((m_nOverride & PBO_STUFF) != 0);
+}
+inline bool LwpParaBorderOverride::IsBetweenStuffOverridden() const
+{
+ return ((m_nOverride & PBO_BETWEENSTUFF) != 0);
+}
+inline bool LwpParaBorderOverride::IsShadowOverridden() const
+{
+ return ((m_nOverride & PBO_SHADOW) != 0);
+}
+inline bool LwpParaBorderOverride::IsMarginsOverridden() const
+{
+ return ((m_nOverride & PBO_MARGINS) != 0);
+}
+inline bool LwpParaBorderOverride::IsAboveTypeOverridden() const
+{
+ return ((m_nOverride & PBO_ABOVETYPE) != 0);
+}
+inline bool LwpParaBorderOverride::IsBelowTypeOverridden() const
+{
+ return ((m_nOverride & PBO_BELOWTYPE) != 0);
+}
+inline bool LwpParaBorderOverride::IsRightTypeOverridden() const
+{
+ return ((m_nOverride & PBO_RIGHTTYPE) != 0);
+}
+inline bool LwpParaBorderOverride::IsBetweenTypeOverridden() const
+{
+ return ((m_nOverride & PBO_BETWEENTYPE) != 0);
+}
+inline bool LwpParaBorderOverride::IsAboveWidthOverridden() const
+{
+ return ((m_nOverride & PBO_ABOVE) != 0);
+}
+inline bool LwpParaBorderOverride::IsBelowWidthOverridden() const
+{
+ return ((m_nOverride & PBO_BELOW) != 0);
+}
+inline bool LwpParaBorderOverride::IsBetweenWidthOverridden() const
+{
+ return ((m_nOverride & PBO_BETWEEN) != 0);
+}
+inline bool LwpParaBorderOverride::IsRightWidthOverridden() const
+{
+ return ((m_nOverride & PBO_RIGHT) != 0);
+}
+inline bool LwpParaBorderOverride::IsBetweenMarginOverridden() const
+{
+ return ((m_nOverride & PBO_BETWEENMARGIN) != 0);
+}
+
+inline void LwpParaBorderOverride::RevertBorderStuff()
+{
+ LwpOverride::Override(PBO_STUFF, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBetweenStuff()
+{
+ LwpOverride::Override(PBO_BETWEENSTUFF, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertShadow()
+{
+ LwpOverride::Override(PBO_SHADOW, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertMargins()
+{
+ LwpOverride::Override(PBO_MARGINS, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertAboveType()
+{
+ LwpOverride::Override(PBO_ABOVETYPE, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBelowType()
+{
+ LwpOverride::Override(PBO_BELOWTYPE, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertRightType()
+{
+ LwpOverride::Override(PBO_RIGHTTYPE, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBetweenType()
+{
+ LwpOverride::Override(PBO_BETWEENTYPE, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertAboveWidth()
+{
+ LwpOverride::Override(PBO_ABOVE, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBelowWidth()
+{
+ LwpOverride::Override(PBO_BELOW, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBetweenWidth()
+{
+ LwpOverride::Override(PBO_BETWEEN, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertRightWidth()
+{
+ LwpOverride::Override(PBO_RIGHT, STATE_STYLE);
+}
+inline void LwpParaBorderOverride::RevertBetweenMargin()
+{
+ LwpOverride::Override(PBO_BETWEENMARGIN, STATE_STYLE);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparaproperty.cxx b/lotuswordpro/source/filter/lwpparaproperty.cxx
new file mode 100644
index 000000000..a60b291c1
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparaproperty.cxx
@@ -0,0 +1,269 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpparaproperty.hxx"
+#include <lwpobjtags.hxx>
+#include "lwppara.hxx"
+
+void LwpPara::ReadPropertyList(LwpObjectStream* pFile)
+{
+ LwpParaProperty* NewProp= nullptr;
+
+ for(;;)
+ {
+ bool bFailure;
+
+ sal_uInt32 tag = pFile->QuickReaduInt32(&bFailure);
+ // Keep reading properties until we hit the end tag or
+ // the stream ends
+ if (bFailure || tag == TAG_ENDSUBOBJ)
+ break;
+
+ // Get the length of this property
+ sal_uInt16 Len = pFile->QuickReaduInt16(&bFailure);
+
+ if (bFailure)
+ break;
+
+ // Create whatever kind of tag we just found
+ switch (tag)
+ {
+ case TAG_PARA_ALIGN:
+ NewProp = new LwpParaAlignProperty(pFile);
+ break;
+
+ case TAG_PARA_INDENT:
+ NewProp = new LwpParaIndentProperty(pFile);
+ break;
+
+ case TAG_PARA_SPACING:
+ NewProp = new LwpParaSpacingProperty(pFile);
+ break;
+
+ case TAG_PARA_BORDER:
+ NewProp = new LwpParaBorderProperty(pFile);
+ break;
+
+ case TAG_PARA_BACKGROUND:
+ NewProp = new LwpParaBackGroundProperty(pFile);
+ break;
+
+ case TAG_PARA_BREAKS:
+ NewProp = new LwpParaBreaksProperty(pFile);
+ break;
+
+ case TAG_PARA_BULLET:
+ NewProp = new LwpParaBulletProperty(pFile);
+ SetBulletFlag(true);
+ break;
+
+ case TAG_PARA_NUMBERING:
+ NewProp = new LwpParaNumberingProperty(pFile);
+ break;
+
+ case TAG_PARA_TAB:
+ NewProp = new LwpParaTabRackProperty(pFile);
+ break;
+
+ default:
+ pFile->SeekRel(Len);
+ NewProp = nullptr;
+ break;
+ }
+ // Stick it at the beginning of the list
+ if (NewProp)
+ {
+ m_vProps.emplace(m_vProps.begin(), NewProp);
+ }
+ }
+}
+
+LwpParaAlignProperty::LwpParaAlignProperty(LwpObjectStream* pFile)
+{
+ LwpObjectID align;
+ align.ReadIndexed(pFile);
+
+ rtl::Reference<LwpAlignmentPiece> xAlignmentPiece(dynamic_cast<LwpAlignmentPiece*>(align.obj(VO_ALIGNMENTPIECE).get()));
+ m_pAlignment = xAlignmentPiece.is() ? dynamic_cast<LwpAlignmentOverride*>(xAlignmentPiece->GetOverride()) : nullptr;
+
+}
+
+LwpParaAlignProperty::~LwpParaAlignProperty()
+{
+}
+
+sal_uInt32 LwpParaAlignProperty::GetType()
+{
+ return PP_LOCAL_ALIGN;
+}
+
+LwpParaIndentProperty::LwpParaIndentProperty(LwpObjectStream* pFile)
+{
+ m_aIndentID.ReadIndexed(pFile);
+
+ LwpIndentPiece *pIndentPiece = dynamic_cast<LwpIndentPiece*>(m_aIndentID.obj(VO_INDENTPIECE).get());
+ m_pIndent = pIndentPiece ? dynamic_cast<LwpIndentOverride*>(pIndentPiece->GetOverride()) : nullptr;
+}
+
+LwpParaIndentProperty::~LwpParaIndentProperty()
+{
+}
+
+sal_uInt32 LwpParaIndentProperty::GetType()
+{
+ return PP_LOCAL_INDENT;
+}
+
+LwpParaSpacingProperty::LwpParaSpacingProperty(LwpObjectStream* pFile)
+{
+ LwpObjectID spacing;
+ spacing.ReadIndexed(pFile);
+
+ LwpSpacingPiece *pSpacingPiece = dynamic_cast<LwpSpacingPiece*>(spacing.obj(VO_SPACINGPIECE).get());
+ m_pSpacing = pSpacingPiece ? dynamic_cast<LwpSpacingOverride*>(pSpacingPiece->GetOverride()) : nullptr;
+}
+
+LwpParaSpacingProperty::~LwpParaSpacingProperty()
+{
+}
+
+sal_uInt32 LwpParaSpacingProperty::GetType()
+{
+ return PP_LOCAL_SPACING;
+}
+
+// 01/25/2004
+LwpParaBorderProperty::LwpParaBorderProperty(LwpObjectStream* pStrm) :
+m_pParaBorderOverride(nullptr)
+{
+ LwpObjectID aParaBorder;
+ aParaBorder.ReadIndexed(pStrm);
+
+ if (!aParaBorder.IsNull())
+ {
+ LwpParaBorderPiece *pParaBorderPiece = dynamic_cast<LwpParaBorderPiece*>(aParaBorder.obj().get());
+ m_pParaBorderOverride = pParaBorderPiece ? dynamic_cast<LwpParaBorderOverride*>(pParaBorderPiece->GetOverride()) : nullptr;
+ }
+}
+
+LwpParaBreaksProperty::LwpParaBreaksProperty(LwpObjectStream* pStrm) :
+m_pBreaks(nullptr)
+{
+ LwpObjectID aBreaks;
+ aBreaks.ReadIndexed(pStrm);
+
+ if (!aBreaks.IsNull())
+ {
+ LwpBreaksPiece *pBreaksPiece = dynamic_cast<LwpBreaksPiece*>(aBreaks.obj().get());
+ m_pBreaks = pBreaksPiece ? dynamic_cast<LwpBreaksOverride*>(pBreaksPiece->GetOverride()) : nullptr;
+ }
+}
+
+LwpParaBulletProperty::LwpParaBulletProperty(LwpObjectStream* pStrm) :
+m_pBullet(new LwpBulletOverride)
+{
+ m_pBullet->Read(pStrm);
+}
+
+LwpParaBulletProperty::~LwpParaBulletProperty()
+{
+}
+
+LwpParaNumberingProperty::LwpParaNumberingProperty(LwpObjectStream * pStrm)
+ : m_pNumberingOverride(nullptr)
+{
+ LwpObjectID aNumberingPiece;
+ aNumberingPiece.ReadIndexed(pStrm);
+ if (aNumberingPiece.IsNull())
+ {
+ return;
+ }
+
+ LwpNumberingPiece *pNumberingPiece = dynamic_cast<LwpNumberingPiece*>(aNumberingPiece.obj(VO_NUMBERINGPIECE).get());
+ m_pNumberingOverride = pNumberingPiece ? dynamic_cast<LwpNumberingOverride*>(pNumberingPiece->GetOverride()) : nullptr;
+}
+
+LwpParaTabRackProperty::LwpParaTabRackProperty(LwpObjectStream* pFile)
+{
+ LwpObjectID aTabRack;
+ aTabRack.ReadIndexed(pFile);
+
+ LwpTabPiece *pTabPiece = dynamic_cast<LwpTabPiece*>(aTabRack.obj().get());
+ m_pTabOverride = pTabPiece ? dynamic_cast<LwpTabOverride*>(pTabPiece->GetOverride()) : nullptr;
+}
+
+LwpParaTabRackProperty::~LwpParaTabRackProperty()
+{
+}
+
+LwpParaBackGroundProperty::LwpParaBackGroundProperty(LwpObjectStream* pFile)
+{
+ LwpObjectID background;
+ background.ReadIndexed(pFile);
+
+ LwpBackgroundPiece *pBackgroundPiece = dynamic_cast<LwpBackgroundPiece*>(background.obj().get());
+ m_pBackground = pBackgroundPiece ? dynamic_cast<LwpBackgroundOverride*>(pBackgroundPiece->GetOverride()) : nullptr;
+}
+
+LwpParaBackGroundProperty::~LwpParaBackGroundProperty()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparaproperty.hxx b/lotuswordpro/source/filter/lwpparaproperty.hxx
new file mode 100644
index 000000000..e4c10062d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparaproperty.hxx
@@ -0,0 +1,272 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARAPROPERTY_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARAPROPERTY_HXX
+
+#include <memory>
+#include <lwpobjstrm.hxx>
+
+#include <lwpoverride.hxx>
+#include "lwpbackgroundoverride.hxx"
+#include "lwpbreaksoverride.hxx"
+#include "lwpnumberingoverride.hxx"
+#include "lwpparaborderoverride.hxx"
+#include "lwptaboverride.hxx"
+
+/* paragraph property ID's */
+#define PP_OUTLINE_SHOW 0x53484f4cUL /* "SHOW" */
+#define PP_OUTLINE_HIDE 0x48494445UL /* "HIDE" */
+#define PP_LOCAL_ALIGN 0x414c494eUL /* "ALIN" */
+#define PP_LOCAL_INDENT 0x494e444eUL /* "INDN" */
+#define PP_LOCAL_SPACING 0x5350434eUL /* "SPCN" */
+#define PP_LOCAL_TABRACK 0x54414253UL /* "TABS" */
+#define PP_LOCAL_BREAKS 0x42524b53UL /* "BRKS" */
+#define PP_LOCAL_BULLET 0x42554c4cUL /* "BULL" */
+#define PP_LOCAL_BORDER 0x424f5244UL /* "BORD" */
+#define PP_LOCAL_BACKGROUND 0x4241434bUL /* "BACK" */
+#define PP_LOCAL_NUMBERING 0x4e4d4252UL /* "NMBR" */
+#define PP_LOCAL_KINSOKU 0x4b494e53UL /* "KINS" */
+#define PP_PROPLIST 0x50524f50UL /* "PROP" */
+
+class LwpParaProperty
+{
+public:
+ LwpParaProperty(){}
+ virtual ~LwpParaProperty() {}
+ virtual sal_uInt32 GetType() = 0;
+};
+
+//align/indent/spacing
+//TO DO:border/background etc
+
+class LwpParaAlignProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaAlignProperty(LwpObjectStream* pFile);
+ virtual ~LwpParaAlignProperty() override;
+ LwpAlignmentOverride* GetAlignment();
+ sal_uInt32 GetType() override;
+
+private:
+ LwpAlignmentOverride* m_pAlignment;
+};
+
+inline LwpAlignmentOverride* LwpParaAlignProperty::GetAlignment()
+{
+ return m_pAlignment;
+}
+
+class LwpParaIndentProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaIndentProperty(LwpObjectStream* pFile);
+ virtual ~LwpParaIndentProperty() override;
+ LwpIndentOverride* GetIndent();
+ sal_uInt32 GetType() override;
+ inline const LwpObjectID& GetIndentID() const;
+
+private:
+ LwpObjectID m_aIndentID;
+ LwpIndentOverride* m_pIndent;
+};
+inline const LwpObjectID& LwpParaIndentProperty::GetIndentID() const
+{
+ return m_aIndentID;
+}
+inline LwpIndentOverride* LwpParaIndentProperty::GetIndent()
+{
+ return m_pIndent;
+}
+
+class LwpParaSpacingProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaSpacingProperty(LwpObjectStream* pFile);
+ virtual ~LwpParaSpacingProperty() override;
+ LwpSpacingOverride* GetSpacing();
+ sal_uInt32 GetType() override;
+private:
+ LwpSpacingOverride* m_pSpacing;
+
+};
+
+inline LwpSpacingOverride* LwpParaSpacingProperty::GetSpacing()
+{
+ return m_pSpacing;
+}
+
+class LwpParaBorderOverride;
+class LwpParaBorderProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaBorderProperty(LwpObjectStream* pStrm);
+
+ sal_uInt32 GetType() override { return PP_LOCAL_BORDER; }
+
+ inline LwpParaBorderOverride* GetLocalParaBorder();
+
+private:
+ LwpParaBorderOverride* m_pParaBorderOverride;
+};
+
+inline LwpParaBorderOverride* LwpParaBorderProperty::GetLocalParaBorder()
+{
+ return m_pParaBorderOverride;
+}
+
+class LwpParaBreaksProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaBreaksProperty(LwpObjectStream* pStrm);
+
+ sal_uInt32 GetType() override { return PP_LOCAL_BREAKS; }
+
+ inline LwpBreaksOverride* GetLocalParaBreaks();
+
+private:
+ LwpBreaksOverride* m_pBreaks;
+
+};
+
+inline LwpBreaksOverride* LwpParaBreaksProperty::GetLocalParaBreaks()
+{
+ return m_pBreaks;
+}
+
+class LwpParaBulletProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaBulletProperty(LwpObjectStream* pStrm);
+
+ virtual ~LwpParaBulletProperty() override;
+
+ sal_uInt32 GetType() override { return PP_LOCAL_BULLET; }
+
+ inline LwpBulletOverride* GetLocalParaBullet();
+
+private:
+ std::unique_ptr<LwpBulletOverride> m_pBullet;
+};
+
+inline LwpBulletOverride* LwpParaBulletProperty::GetLocalParaBullet()
+{
+ return m_pBullet.get();
+}
+
+class LwpParaNumberingProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaNumberingProperty(LwpObjectStream* pStrm);
+
+ sal_uInt32 GetType() override { return PP_LOCAL_NUMBERING; }
+
+ inline LwpNumberingOverride* GetLocalNumbering() const;
+private:
+ LwpNumberingOverride* m_pNumberingOverride;
+};
+
+inline LwpNumberingOverride* LwpParaNumberingProperty::GetLocalNumbering() const
+{
+ return m_pNumberingOverride;
+}
+
+class LwpParaTabRackProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaTabRackProperty(LwpObjectStream* pStrm);
+ virtual ~LwpParaTabRackProperty() override;
+ sal_uInt32 GetType() override { return PP_LOCAL_TABRACK; }
+
+ inline LwpTabOverride* GetTab();
+
+private:
+ LwpTabOverride* m_pTabOverride;
+};
+
+inline LwpTabOverride* LwpParaTabRackProperty::GetTab()
+{
+ return m_pTabOverride;
+}
+
+class LwpParaBackGroundProperty : public LwpParaProperty
+{
+public:
+ explicit LwpParaBackGroundProperty(LwpObjectStream* pFile);
+ virtual ~LwpParaBackGroundProperty() override;
+ LwpBackgroundOverride* GetBackground();
+ sal_uInt32 GetType() override;
+private:
+ LwpBackgroundOverride* m_pBackground;
+};
+
+inline LwpBackgroundOverride* LwpParaBackGroundProperty::GetBackground()
+{
+ return m_pBackground;
+}
+
+inline sal_uInt32 LwpParaBackGroundProperty::GetType()
+{
+ return PP_LOCAL_BACKGROUND;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparastyle.cxx b/lotuswordpro/source/filter/lwpparastyle.cxx
new file mode 100644
index 000000000..fdec20bc3
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparastyle.cxx
@@ -0,0 +1,745 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+
+#include "lwpparastyle.hxx"
+#include <lwpfilehdr.hxx>
+#include <lwpoverride.hxx>
+#include "lwpparaborderoverride.hxx"
+#include "lwpbreaksoverride.hxx"
+#include "lwpnumberingoverride.hxx"
+#include "lwptaboverride.hxx"
+#include "lwpbackgroundoverride.hxx"
+#include <o3tl/safeint.hxx>
+#include <xfilter/xfdefs.hxx>
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xfborders.hxx>
+#include <lwpfont.hxx>
+#include <lwpfoundry.hxx>
+#include "lwppiece.hxx"
+#include "lwpshadow.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwpmargins.hxx"
+#include "lwptabrack.hxx"
+
+LwpParaStyle::LwpParaStyle(LwpObjectHeader const & objHdr, LwpSvStream* pStrm) :
+LwpTextStyle(objHdr, pStrm)
+{
+}
+
+LwpParaStyle::~LwpParaStyle()
+{
+}
+
+void LwpParaStyle::Read()
+{
+ LwpTextStyle::Read();
+
+ if (LwpFileHeader::m_nFileRevision < 0x000B)
+ {
+ // read many overrides
+ LwpAlignmentOverride aAlignOverride;
+ aAlignOverride.Read(m_pObjStrm.get());
+
+ LwpSpacingOverride aSpacingOverride;
+ aSpacingOverride.Read(m_pObjStrm.get());
+
+ LwpIndentOverride aIndentOverride;
+ aIndentOverride.Read(m_pObjStrm.get());
+
+ LwpParaBorderOverride aPBOverride;
+ aPBOverride.Read(m_pObjStrm.get());
+
+ LwpBreaksOverride aBreaksOverride;
+ aBreaksOverride.Read(m_pObjStrm.get());
+
+ LwpNumberingOverride aNumberingOverride;
+ aNumberingOverride.Read(m_pObjStrm.get());
+
+ LwpTabOverride aTabOverride;
+ aTabOverride.Read(m_pObjStrm.get());
+
+ }
+ else
+ {
+ m_AlignmentStyle.ReadIndexed(m_pObjStrm.get());
+ m_SpacingStyle.ReadIndexed(m_pObjStrm.get());
+ m_IndentStyle.ReadIndexed(m_pObjStrm.get());
+ m_BorderStyle.ReadIndexed(m_pObjStrm.get());
+ m_BreaksStyle.ReadIndexed(m_pObjStrm.get());
+ m_NumberingStyle.ReadIndexed(m_pObjStrm.get());
+ m_TabStyle.ReadIndexed(m_pObjStrm.get());
+
+ m_KinsokuOptsOverride.Read(m_pObjStrm.get());
+ m_BulletOverride.Read(m_pObjStrm.get());
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ m_BackgroundStyle.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+
+ }
+}
+
+void LwpParaStyle::Apply(XFParaStyle *pParaStyle)
+{
+ assert(pParaStyle);
+
+ //alignment:
+ LwpVirtualPiece *pPiece = dynamic_cast<LwpVirtualPiece*>(m_AlignmentStyle.obj().get());
+ if( pPiece )
+ {
+ LwpAlignmentOverride *pAlign = dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
+ if( pAlign )
+ ApplyAlignment(pParaStyle,pAlign);
+ }
+
+ //don't known top and bottom indent now.
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_IndentStyle.obj().get());
+ if( pPiece )
+ {
+ LwpIndentOverride *pIndent = dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
+ if( pIndent )
+ {
+ if (!m_BulletOverride.IsInValid())// for remove bullet indent in named bullet style
+ {
+ std::unique_ptr<LwpIndentOverride> pNewIndent(pIndent->clone());
+ pNewIndent->SetMFirst(0);
+ pNewIndent->SetMRest(0);
+ ApplyIndent(nullptr, pParaStyle, pNewIndent.get());
+ }
+ else
+ ApplyIndent(nullptr,pParaStyle,pIndent);
+ }
+ }
+ //shadow & borders.
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_BorderStyle.obj().get());
+ if( pPiece )
+ {
+ LwpParaBorderOverride *pBorder = dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
+ if( pBorder )
+ {
+ ApplyParaBorder(pParaStyle, pBorder);
+ }
+ }
+
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_SpacingStyle.obj().get());
+ if (pPiece)
+ {
+ LwpSpacingOverride *pSpacing = dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
+ if( pSpacing)
+ ApplySpacing(nullptr,pParaStyle,pSpacing);
+ }
+
+ //paragraph background.
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_BackgroundStyle.obj().get());
+ if( pPiece )
+ {
+ LwpBackgroundOverride *pBack = dynamic_cast<LwpBackgroundOverride*>(pPiece->GetOverride());
+ if( pBack )
+ {
+ LwpColor color = pBack->GetBackColor();
+ XFColor aXFColor( color.To24Color() );
+ pParaStyle->SetBackColor( aXFColor );
+ }
+ }
+
+ //add tab style
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_TabStyle.obj().get());
+ if( pPiece )
+ {
+ LwpTabOverride *pTab = dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
+ if(pTab)
+ {
+ ApplyTab(pParaStyle,pTab);
+ }
+ }
+ pPiece = dynamic_cast<LwpVirtualPiece*>(m_BreaksStyle.obj().get());
+ if( pPiece )
+ {
+ LwpBreaksOverride *pBreak = dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
+ if(pBreak)
+ {
+ ApplyBreaks(pParaStyle,pBreak);
+ }
+ }
+
+}
+
+void LwpParaStyle::ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType, XFBorders* pXFBorders)
+{
+ enumXFBorder eXFBorderSide = enumXFBorderNone;
+ switch (eType)
+ {
+ case LwpBorderStuff::LEFT:
+ eXFBorderSide = enumXFBorderLeft;
+ break;
+ case LwpBorderStuff::RIGHT:
+ eXFBorderSide = enumXFBorderRight;
+ break;
+ case LwpBorderStuff::TOP:
+ eXFBorderSide = enumXFBorderTop;
+ break;
+ case LwpBorderStuff::BOTTOM:
+ eXFBorderSide = enumXFBorderBottom;
+ break;
+ default:
+ break;
+ }
+
+ LwpColor aColor = pBorderStuff->GetSideColor(eType);
+ float fWidth = pBorderStuff->GetSideWidth(eType);
+ sal_uInt16 nType = pBorderStuff->GetSideType(eType);
+
+ switch (nType)
+ {
+ default://fall through!
+ case 0x14: //single fall through!
+ case 0x17: //treble
+ pXFBorders->SetWidth(eXFBorderSide, fWidth);
+ break;
+ case 0x15: //double , fall through!
+ case 0x16: //thick double
+ pXFBorders->SetDoubleLine(eXFBorderSide);
+ pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.333));
+ pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.334));
+ pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.333));
+// pXFBorders->SetWidth(eXFBorderSide, fWidth);
+ break;
+ case 0x18: //thick-thin
+ pXFBorders->SetDoubleLine(eXFBorderSide);
+ pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.5));
+ pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.25));
+ pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.25));
+ break;
+ case 0x19: //thin-thick
+ pXFBorders->SetDoubleLine(eXFBorderSide);
+ pXFBorders->SetWidthInner(eXFBorderSide, static_cast<float>(fWidth*0.7));
+ pXFBorders->SetWidthOuter(eXFBorderSide, static_cast<float>(fWidth*0.15));
+ pXFBorders->SetWidthSpace(eXFBorderSide, static_cast<float>(fWidth*0.15));
+ break;
+ }
+
+ if (aColor.IsValidColor())
+ {
+ XFColor aXFColor(aColor.To24Color());
+ pXFBorders->SetColor(eXFBorderSide, aXFColor );
+ }
+}
+
+void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder)
+{
+ //convert LwpShadow:
+ LwpShadow *pShadow = pBorder->GetShadow();
+ if( pShadow )
+ {
+ LwpColor color = pShadow->GetColor();
+ float offsetX = pShadow->GetOffsetX();
+ float offsetY = pShadow->GetOffsetY();
+
+ if( offsetX && offsetY && color.IsValidColor() )
+ {
+ XFColor aXFColor(color.To24Color());
+ bool left = false;
+ bool top = false;
+ if( offsetX < 0 )
+ left = true;
+ if( offsetY < 0 )
+ top = true;
+ if( left )
+ {
+ if( top )
+ pParaStyle->SetShadow(enumXFShadowLeftTop,-offsetX,aXFColor);
+ else
+ pParaStyle->SetShadow(enumXFShadowLeftBottom,-offsetX,aXFColor);
+ }
+ else
+ {
+ if( top )
+ pParaStyle->SetShadow(enumXFShadowRightTop,offsetX,aXFColor);
+ else
+ pParaStyle->SetShadow(enumXFShadowRightBottom,offsetX,aXFColor);
+ }
+ }
+ }
+
+ //convert to XFBorders object:
+ LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
+ if( !(pBorderStuff && pBorderStuff->GetSide() != 0) )
+ return;
+
+ XFBorders *pXFBorders = new XFBorders();
+ pParaStyle->SetBorders(pXFBorders);
+
+ LwpMargins* pMargins = pBorder->GetMargins();
+
+ // apply 4 borders respectively
+ LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
+ LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
+ float pMarginValue[4] = { 0.0, 0.0, 0.0, 0.0 };
+
+ for (sal_uInt8 nC = 0; nC < 4; nC++)
+ {
+ if (pBorderStuff->HasSide(pType[nC]))
+ {
+ ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
+
+ //get border spacing to text content
+ if (pMargins)
+ {
+ pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
+ }
+ }
+
+ }
+
+ //apply border spacing to text content
+ pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
+}
+
+void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, const LwpBreaksOverride* pBreaks)
+{
+ if (pBreaks->IsKeepWithNext())
+ {
+ pParaStyle->SetBreaks(enumXFBreakKeepWithNext);
+ }
+ if (pBreaks->IsPageBreakBefore())
+ {
+ pParaStyle->SetBreaks(enumXFBreakBefPage);
+ }
+ if (pBreaks->IsPageBreakAfter())
+ {
+ pParaStyle->SetBreaks(enumXFBreakAftPage);
+ }
+ if (pBreaks->IsColumnBreakBefore())
+ {
+ pParaStyle->SetBreaks(enumXFBreakBefColumn);
+ }
+ if (pBreaks->IsColumnBreakAfter())
+ {
+ pParaStyle->SetBreaks(enumXFBreakAftColumn);
+ }
+}
+
+void LwpParaStyle::ApplyAlignment(XFParaStyle* pParaStyle, const LwpAlignmentOverride* pAlign)
+{
+ enumXFAlignType alignType = enumXFAlignStart;
+ auto type = pAlign->GetAlignType();
+
+ pParaStyle->SetNumberRight(false);//to identify its align attribute
+ switch(type)
+ {
+ case LwpAlignmentOverride::ALIGN_LEFT:
+ alignType = enumXFAlignStart;
+ break;
+ case LwpAlignmentOverride::ALIGN_RIGHT:
+ alignType = enumXFAlignEnd;
+ break;
+ case LwpAlignmentOverride::ALIGN_CENTER:
+ alignType = enumXFAlignCenter;
+ break;
+ case LwpAlignmentOverride::ALIGN_NUMERICLEFT://if non-number in table,ALIGN_NUMERICLEFT/RIGHT are useless
+ alignType = enumXFAlignStart; //note by 1/28
+ break;
+ case LwpAlignmentOverride::ALIGN_JUSTIFY:
+ case LwpAlignmentOverride::ALIGN_JUSTIFYALL:
+ alignType = enumXFAlignJustify;
+ break;
+ case LwpAlignmentOverride::ALIGN_NUMERICRIGHT:
+ pParaStyle->SetNumberRight(true);//to identify its align attribute
+ alignType = enumXFAlignEnd;
+ break;
+ default:
+ break;
+ }
+ pParaStyle->SetAlignType(alignType);
+}
+
+void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, const LwpIndentOverride* pIndent)
+{
+ LwpPara* pParentPara;
+ if (pPara)
+ pParentPara = pPara->GetParent();
+ else
+ pParentPara = nullptr;
+
+ std::unique_ptr<LwpIndentOverride> pTotalIndent(new LwpIndentOverride);
+ if (pIndent->IsUseRelative() && pParentPara)
+ {
+ LwpIndentOverride* pParentIndent = pParentPara->GetIndent();
+ if (!pParentIndent)
+ return;
+ pTotalIndent.reset(pIndent->clone());
+
+ //for bullet only
+ if (pPara && pPara->GetBulletFlag())
+ {
+ pTotalIndent->SetMAll(o3tl::saturating_add(pParentIndent->GetMAll(), pTotalIndent->GetMAll()));
+ pTotalIndent->SetMRight(o3tl::saturating_add(pParentIndent->GetMRight(), pTotalIndent->GetMRight()));
+ pParaStyle->SetMargins(LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(
+ pTotalIndent->GetMAll())), pTotalIndent->GetRight());
+ pPara->SetIndent(pTotalIndent.release());
+ return;
+ }
+ sal_uInt16 relative = pParentIndent->GetRelative();
+
+ sal_Int32 Amount = pParentIndent->GetMAll();
+
+ if (relative == LwpIndentOverride::RELATIVE_FIRST)
+ Amount = o3tl::saturating_add(Amount, pParentIndent->GetMFirst());
+ else if (relative == LwpIndentOverride::RELATIVE_REST)
+ Amount = o3tl::saturating_add(Amount, pParentIndent->GetMRest());
+ pTotalIndent->SetMAll(o3tl::saturating_add(Amount, pTotalIndent->GetMAll()));
+ pTotalIndent->SetMRight(o3tl::saturating_add(pParentIndent->GetMRight(), pTotalIndent->GetMRight()));
+
+ pParaStyle->SetIndent(pTotalIndent->GetFirst());
+ pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
+ pPara->SetIndent(pTotalIndent.release());
+
+ }
+ else
+ {
+ pTotalIndent.reset(pIndent->clone());
+ if (pPara && pPara->GetBulletFlag())
+ {
+ pParaStyle->SetMargins(LwpTools::ConvertToMetric(
+ LwpTools::ConvertFromUnits(pIndent->GetMAll())), pIndent->GetRight());
+ pPara->SetIndent(pTotalIndent.release());
+ return;
+ }
+
+ pParaStyle->SetIndent(pIndent->GetFirst());
+ pParaStyle->SetMargins(pIndent->GetLeft(), pIndent->GetRight());
+ if (pPara)
+ {
+ pPara->SetIndent(pTotalIndent.release());
+ }
+ }
+}
+
+void LwpParaStyle::ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing)
+{
+ LwpSpacingCommonOverride* spacing = pSpacing->GetSpacing();
+ LwpSpacingCommonOverride* abovepara = pSpacing->GetAboveSpacing();
+ LwpSpacingCommonOverride* belowpara = pSpacing->GetBelowSpacing();
+
+ LwpSpacingCommonOverride::SpacingType type = spacing->GetType();
+ sal_Int32 amount = spacing->GetAmount();
+ sal_Int32 multiple = spacing->GetMultiple();
+ enumLHType xftype;
+ double height;
+
+ switch(type)
+ {
+ case LwpSpacingCommonOverride::SPACING_DYNAMIC:
+ {
+ xftype = enumLHPercent;
+ height = double(multiple)/65536L*100;
+ pParaStyle->SetLineHeight(xftype,height);
+ }
+ break;
+ case LwpSpacingCommonOverride::SPACING_LEADING:
+ {
+ xftype = enumLHSpace;
+ height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(amount));
+ pParaStyle->SetLineHeight(xftype,height);
+ }
+ break;
+ case LwpSpacingCommonOverride::SPACING_CUSTOM:
+ {
+ xftype = enumLHHeight;
+ height = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
+ pParaStyle->SetLineHeight(xftype,height);
+ }
+ break;
+ case LwpSpacingCommonOverride::SPACING_NONE:
+ break;
+ }
+
+//TO DO: Above Line need to be processed!!!!!!! what it means?????? 1-26
+
+ type = abovepara->GetType();
+ amount = abovepara->GetAmount();
+ multiple = abovepara->GetMultiple();
+ double above_val =-1;
+ switch(type)
+ {
+ case LwpSpacingCommonOverride::SPACING_DYNAMIC:
+ break;
+ case LwpSpacingCommonOverride::SPACING_LEADING:
+ break;
+ case LwpSpacingCommonOverride::SPACING_CUSTOM:
+ above_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
+ break;
+ case LwpSpacingCommonOverride::SPACING_NONE:
+ break;
+ }
+
+ type = belowpara->GetType();
+ amount = belowpara->GetAmount();
+ multiple = belowpara->GetMultiple();
+ double below_val=-1;
+ switch(type)
+ {
+ case LwpSpacingCommonOverride::SPACING_DYNAMIC:
+ break;
+ case LwpSpacingCommonOverride::SPACING_LEADING:
+ break;
+ case LwpSpacingCommonOverride::SPACING_CUSTOM:
+ below_val = LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(sal_Int32(float(multiple)/65536L*amount)));
+ break;
+ case LwpSpacingCommonOverride::SPACING_NONE:
+ break;
+ }
+
+ if (pPara)
+ {
+ if (below_val != -1)
+ pPara->SetBelowSpacing(below_val);
+ LwpPara* pPrePara = dynamic_cast<LwpPara*>(pPara->GetPrevious().obj().get());
+ if (pPrePara && above_val != -1)
+ {
+ above_val += pPrePara->GetBelowSpacing();
+
+ }
+
+ }
+ pParaStyle->SetMargins(-1,-1,above_val,below_val);
+}
+
+void LwpParaStyle::ApplyTab(XFParaStyle *pParaStyle, LwpTabOverride *pTabOverRide)
+{
+ LwpObjectID& rTabRackID = pTabOverRide->GetTabRackID();
+ if(rTabRackID.IsNull())
+ {
+ return;
+ }
+
+ LwpTabRack* pTabRack = dynamic_cast<LwpTabRack*>(rTabRackID.obj().get());
+ if(!pTabRack)
+ {
+ return;
+ }
+
+ pParaStyle->ClearTabStyles();
+ //Get margin left value
+ double dMarginLeft = pParaStyle->GetMargins().GetLeft();
+
+ sal_uInt16 nNumTabs = pTabRack->GetNumTabs();
+ for(sal_uInt16 nIndex=0; nIndex<nNumTabs; nIndex++)
+ {
+ //get tab type
+ LwpTab* pTab = pTabRack->Lookup(nIndex);
+ if(!pTab)
+ return;
+
+ enumXFTab eType = enumXFTabNone;
+ sal_uInt32 type = pTab->GetTabType();
+ switch(type)
+ {
+ case LwpTab::TT_LEFT:
+ eType = enumXFTabLeft;
+ break;
+ case LwpTab::TT_CENTER:
+ eType = enumXFTabCenter;
+ break;
+ case LwpTab::TT_RIGHT:
+ eType = enumXFTabRight;
+ break;
+ case LwpTab::TT_NUMERIC:
+ eType = enumXFTabChar;
+ break;
+ }
+
+ //get position
+ sal_uInt32 nPos = pTab->GetPosition();
+ //different feature between SODC and lwp, the tab length must minus the margin left of para.
+ double fLen = LwpTools::ConvertFromUnitsToMetric(nPos) - dMarginLeft;
+
+ //get leader type
+ sal_Unicode cLeader = 0x00;
+ auto leader= pTab->GetLeaderType();
+ switch(leader)
+ {
+ case LwpTab::TL_NONE:
+ cLeader = 0x20; //space
+ break;
+ case LwpTab::TL_HYPHEN: //'-'
+ cLeader = 0xAD;
+ break;
+ case LwpTab::TL_DOT: //'.'
+ cLeader = 0x2E;
+ break;
+ case LwpTab::TL_LINE: //'_'
+ cLeader = 0x5F;
+ break;
+ }
+
+ sal_Unicode cAlignChar = static_cast<sal_Unicode>(pTab->GetAlignChar());
+
+ pParaStyle->AddTabStyle(eType,fLen,cLeader,cAlignChar);
+ }
+
+}
+
+void LwpParaStyle::RegisterStyle()
+{
+ if (!m_pFoundry)
+ throw std::runtime_error("missing Foundry");
+
+ std::unique_ptr<XFParaStyle> xStyle(new XFParaStyle());
+
+ //Set name
+ OUString styleName = GetName().str();
+ xStyle->SetStyleName(styleName);
+
+ //Create font
+ LwpFontManager& rFontMgr = m_pFoundry->GetFontManager();
+ rtl::Reference<XFFont> pFont = rFontMgr.CreateFont(m_nFinalFontID);
+ xStyle->SetFont(pFont);
+
+ //Set other paragraph properties...
+
+ Apply(xStyle.get());
+ //Add style
+ LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
+ pStyleMgr->AddStyle(GetObjectID(), std::move(xStyle));
+}
+
+LwpAlignmentOverride* LwpParaStyle::GetAlignment()
+{
+ if (m_AlignmentStyle.obj() == nullptr)
+ return nullptr;
+
+ LwpAlignmentPiece *pPiece = dynamic_cast<LwpAlignmentPiece*>(m_AlignmentStyle.obj().get());
+ if (pPiece)
+ return dynamic_cast<LwpAlignmentOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+LwpIndentOverride* LwpParaStyle::GetIndent()
+{
+ if (m_IndentStyle.obj() == nullptr)
+ return nullptr;
+
+ LwpIndentPiece *pPiece = dynamic_cast<LwpIndentPiece*>(m_IndentStyle.obj().get());
+ if (pPiece)
+ return dynamic_cast<LwpIndentOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+LwpSpacingOverride* LwpParaStyle::GetSpacing()
+{
+ if (m_SpacingStyle.obj() == nullptr)
+ return nullptr;
+
+ LwpSpacingPiece *pPiece = dynamic_cast<LwpSpacingPiece*>(m_SpacingStyle.obj().get());
+ if (pPiece)
+ return dynamic_cast<LwpSpacingOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+LwpParaBorderOverride* LwpParaStyle::GetParaBorder() const
+{
+ if(m_BorderStyle.IsNull())
+ return nullptr;
+
+ LwpParaBorderPiece *pPiece = dynamic_cast<LwpParaBorderPiece*>(m_BorderStyle.obj(VO_PARABORDERPIECE).get());
+ if (pPiece)
+ return dynamic_cast<LwpParaBorderOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+LwpBreaksOverride* LwpParaStyle::GetBreaks() const
+{
+ if(m_BreaksStyle.IsNull())
+ return nullptr;
+
+ LwpBreaksPiece *pPiece = dynamic_cast<LwpBreaksPiece*>(m_BreaksStyle.obj(VO_BREAKSPIECE).get());
+ if (pPiece)
+ return dynamic_cast<LwpBreaksOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+
+LwpNumberingOverride* LwpParaStyle::GetNumberingOverride() const
+{
+ if(m_NumberingStyle.IsNull())
+ return nullptr;
+
+ LwpNumberingPiece *pPiece = dynamic_cast<LwpNumberingPiece*>(m_NumberingStyle.obj(VO_NUMBERINGPIECE).get());
+ if (pPiece)
+ return dynamic_cast<LwpNumberingOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+LwpTabOverride* LwpParaStyle::GetTabOverride() const
+{
+ if(m_TabStyle.obj() == nullptr)
+ return nullptr;
+ LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabStyle.obj().get());
+ if (pPiece)
+ return dynamic_cast<LwpTabOverride*>(pPiece->GetOverride());
+ return nullptr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpparastyle.hxx b/lotuswordpro/source/filter/lwpparastyle.hxx
new file mode 100644
index 000000000..c41382c6c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpparastyle.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARASTYLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPARASTYLE_HXX
+
+#include "lwpcharacterstyle.hxx"
+#include "lwpborderstuff.hxx"
+#include "lwppara.hxx"
+
+class LwpKinsokuOptsOverride;
+class LwpBulletOverride;
+class XFParaStyle;
+class XFBorders;
+
+class LwpParaStyle : public LwpTextStyle
+{
+public:
+ LwpParaStyle(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+
+ virtual ~LwpParaStyle() override;
+
+ void Read() override;
+
+ void Apply(XFParaStyle* pStrm);
+ static void ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverride* pBorder);
+ static void ApplyBreaks(XFParaStyle* pParaStyle, const LwpBreaksOverride* pBreaks);
+ static void ApplyAlignment(XFParaStyle* pParaStyle, const LwpAlignmentOverride* pAlign);
+ static void ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle,
+ const LwpIndentOverride* pIndent);
+ static void ApplySpacing(LwpPara* pPara, XFParaStyle* pParaStyle, LwpSpacingOverride* pSpacing);
+
+ static void ApplyTab(XFParaStyle* pParaStyle, LwpTabOverride* pTab);
+
+ void RegisterStyle() override;
+
+ LwpAlignmentOverride* GetAlignment();
+ LwpIndentOverride* GetIndent();
+ LwpSpacingOverride* GetSpacing();
+ LwpParaBorderOverride* GetParaBorder() const;
+ LwpBreaksOverride* GetBreaks() const;
+ LwpTabOverride* GetTabOverride() const;
+ const LwpBulletOverride& GetBulletOverride() const { return m_BulletOverride; }
+ LwpNumberingOverride* GetNumberingOverride() const;
+
+public:
+ static void ApplySubBorder(LwpBorderStuff* pBorderStuff, LwpBorderStuff::BorderType eType,
+ XFBorders* pXFBorders);
+
+private:
+ //style IDs
+ LwpObjectID m_AlignmentStyle;
+ LwpObjectID m_SpacingStyle;
+ LwpObjectID m_IndentStyle;
+ LwpObjectID m_BorderStyle;
+ LwpObjectID m_BreaksStyle;
+ LwpObjectID m_NumberingStyle;
+ LwpObjectID m_TabStyle;
+ LwpObjectID m_BackgroundStyle;
+
+ LwpKinsokuOptsOverride m_KinsokuOptsOverride;
+ LwpBulletOverride m_BulletOverride;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppiece.hxx b/lotuswordpro/source/filter/lwppiece.hxx
new file mode 100644
index 000000000..707c4e542
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppiece.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPIECE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPIECE_HXX
+
+#include <lwpoverride.hxx>
+#include "lwpdlvlist.hxx"
+#include "lwpbreaksoverride.hxx"
+#include "lwpparaborderoverride.hxx"
+#include "lwpnumberingoverride.hxx"
+#include "lwpcharborderoverride.hxx"
+#include "lwpbackgroundoverride.hxx"
+#include "lwptaboverride.hxx"
+
+class LwpOverride;
+class LwpDLVList;
+
+class LwpVirtualPiece : public LwpDLVList
+{
+public:
+ LwpVirtualPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpDLVList(objHdr, pStrm)
+ {
+ }
+
+ virtual void Read() override
+ {
+ LwpDLVList::Read();
+ if( m_pOverride )
+ m_pOverride->Read(m_pObjStrm.get());
+ }
+
+ LwpOverride* GetOverride()
+ {
+ return m_pOverride.get();
+ }
+protected:
+ virtual ~LwpVirtualPiece() override
+ {
+ }
+
+ std::unique_ptr<LwpOverride> m_pOverride;
+};
+
+class LwpParaBorderPiece : public LwpVirtualPiece
+{
+public:
+ LwpParaBorderPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpParaBorderOverride());
+ }
+
+private:
+ virtual ~LwpParaBorderPiece() override {}
+};
+
+class LwpBreaksPiece : public LwpVirtualPiece
+{
+public:
+ LwpBreaksPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpBreaksOverride());
+ }
+
+private:
+ virtual ~LwpBreaksPiece() override {}
+};
+
+class LwpNumberingPiece : public LwpVirtualPiece
+{
+public:
+ LwpNumberingPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpNumberingOverride());
+ }
+
+private:
+ virtual ~LwpNumberingPiece() override {}
+};
+
+class LwpTabPiece : public LwpVirtualPiece
+{
+public:
+ LwpTabPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpTabOverride());
+ }
+
+private:
+ virtual ~LwpTabPiece() override {}
+};
+
+class LwpBackgroundPiece : public LwpVirtualPiece
+{
+public:
+ LwpBackgroundPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpBackgroundOverride());
+ }
+
+private:
+ virtual ~LwpBackgroundPiece() override {}
+};
+
+class LwpAlignmentPiece : public LwpVirtualPiece
+{
+public:
+ LwpAlignmentPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpAlignmentOverride());
+ }
+
+private:
+ virtual ~LwpAlignmentPiece() override {}
+};
+
+class LwpIndentPiece : public LwpVirtualPiece
+{
+public:
+ LwpIndentPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpIndentOverride());
+ }
+
+private:
+ virtual ~LwpIndentPiece() override {}
+};
+
+class LwpSpacingPiece : public LwpVirtualPiece
+{
+public:
+ LwpSpacingPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpSpacingOverride());
+ }
+
+private:
+ virtual ~LwpSpacingPiece() override {}
+};
+
+class LwpAmikakePiece : public LwpVirtualPiece
+{
+public:
+ LwpAmikakePiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpAmikakeOverride());
+ }
+
+private:
+ virtual ~LwpAmikakePiece() override {}
+};
+
+class LwpCharacterBorderPiece : public LwpVirtualPiece
+{
+public:
+ LwpCharacterBorderPiece(LwpObjectHeader const & objHdr, LwpSvStream* pStrm):LwpVirtualPiece(objHdr, pStrm)
+ {
+ m_pOverride.reset(new LwpCharacterBorderOverride());
+ }
+
+private:
+ virtual ~LwpCharacterBorderPiece() override {}
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpproplist.cxx b/lotuswordpro/source/filter/lwpproplist.cxx
new file mode 100644
index 000000000..e0e159cad
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpproplist.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpproplist.hxx"
+
+LwpPropListElement::LwpPropListElement(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
+:LwpDLVList(objHdr,pStrm)
+{
+}
+
+LwpPropListElement* LwpPropListElement::GetNext()
+{
+ return dynamic_cast<LwpPropListElement*>(LwpDLVList::GetNext().obj().get());
+}
+
+void LwpPropListElement::Read()
+{
+ LwpDLVList::Read();
+ m_Name.Read(m_pObjStrm.get());
+ m_Value.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+bool LwpPropListElement::IsNamed(std::u16string_view name)
+{
+ return name == m_Name.str();
+}
+
+OUString LwpPropList::GetNamedProperty(std::u16string_view name)
+{
+ LwpPropListElement* pProp = FindPropByName(name);
+ if (pProp)
+ {
+ return pProp->GetValue().str();
+ }
+ return OUString();
+}
+
+LwpPropListElement* LwpPropList::FindPropByName(std::u16string_view name)
+{
+ LwpPropListElement* pElement = GetFirst();
+
+ while(pElement)
+ {
+ if (pElement->IsNamed(name))
+ return pElement;
+ pElement = pElement->GetNext();
+ }
+ return nullptr;
+}
+
+LwpPropListElement* LwpPropList::GetFirst()
+{
+ return dynamic_cast<LwpPropListElement*>(LwpDLVListHead::GetFirst().obj().get());
+}
+
+OUString LwpPropList::EnumNamedProperty(OUString& name,OUString& value)
+{
+ LwpPropListElement* pElement;
+ if (name.isEmpty())
+ {
+ pElement = GetFirst();
+ if (pElement)
+ {
+ value = pElement->GetValue().str();
+ name = pElement->GetName().str();
+ pElement = pElement->GetNext();
+ if(pElement)
+ return pElement->GetName().str();
+ }
+ return OUString();
+ }
+ else
+ {
+ pElement = FindPropByName(name);
+ if (pElement)
+ {
+ value = pElement->GetValue().str();
+ pElement = pElement->GetNext();
+ if(pElement)
+ return pElement->GetName().str();
+ }
+ return OUString();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpproplist.hxx b/lotuswordpro/source/filter/lwpproplist.hxx
new file mode 100644
index 000000000..3600b8417
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpproplist.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPROPLIST_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPROPLIST_HXX
+
+#include "lwpdlvlist.hxx"
+#include <lwpatomholder.hxx>
+
+class LwpPropListElement : public LwpDLVList
+{
+public:
+ LwpPropListElement(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ bool IsNamed(std::u16string_view name);
+ LwpPropListElement* GetNext();
+ const LwpAtomHolder& GetValue() const { return m_Value; }
+ const LwpAtomHolder& GetName() const { return m_Name; }
+
+private:
+ virtual ~LwpPropListElement() override {}
+
+ LwpAtomHolder m_Name;
+ LwpAtomHolder m_Value;
+};
+
+class LwpPropList : public LwpDLVListHead
+{
+public:
+ LwpPropList() {}
+ using LwpDLVListHead::Read;
+ LwpPropListElement* GetFirst();
+ OUString GetNamedProperty(std::u16string_view name);
+ OUString EnumNamedProperty(OUString& name, OUString& value);
+
+private:
+ LwpPropListElement* FindPropByName(std::u16string_view name);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpprtinfo.cxx b/lotuswordpro/source/filter/lwpprtinfo.cxx
new file mode 100644
index 000000000..c935d9351
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpprtinfo.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "lwpprtinfo.hxx"
+#include <lwpatomholder.hxx>
+
+LwpPrinterInfo::LwpPrinterInfo(LwpObjectStream* pStrm) { Skip(pStrm); }
+/**
+ * @descr skip printer info in VO_DOCUMENT
+ */
+void LwpPrinterInfo::Skip(LwpObjectStream* pStrm)
+{
+ /*sal_uInt16 platform =*/pStrm->QuickReaduInt16();
+
+ //Skip the size and the buffer
+ sal_uInt32 size = pStrm->QuickReaduInt32();
+ pStrm->SeekRel(static_cast<sal_uInt16>(size));
+
+ //Skip other printer info
+ pStrm->SeekRel(6 * sizeof(sal_uInt16) + sizeof(sal_uInt32) + sizeof(sal_uInt16));
+
+ //Skip the next five LwpAtomHolder
+ {
+ LwpAtomHolder toSkip;
+ toSkip.Skip(pStrm);
+ toSkip.Skip(pStrm);
+ toSkip.Skip(pStrm);
+ toSkip.Skip(pStrm);
+ toSkip.Skip(pStrm);
+ }
+
+ sal_uInt16 count = pStrm->QuickReaduInt16();
+ //Skip each selected division
+ LwpAtomHolder toSkip;
+ while (count--)
+ {
+ toSkip.Skip(pStrm);
+ pStrm->SkipExtra();
+ }
+ pStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpprtinfo.hxx b/lotuswordpro/source/filter/lwpprtinfo.hxx
new file mode 100644
index 000000000..95b4df109
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpprtinfo.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPRTINFO_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPRTINFO_HXX
+
+#include <lwpobjstrm.hxx>
+/**
+ * @brief printer info used in VO_DOCUMENT
+ * not parsed yet
+*/
+class LwpPrinterInfo
+{
+public:
+ explicit LwpPrinterInfo(LwpObjectStream* pStrm);
+
+public:
+ static void Skip(LwpObjectStream* pStrm);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwppttntbl.hxx b/lotuswordpro/source/filter/lwppttntbl.hxx
new file mode 100644
index 000000000..8c59cd3e5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwppttntbl.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype
+ * WordPro Pattern Table
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPTTNTBL_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPPTTNTBL_HXX
+
+#include <sal/types.h>
+
+const sal_uInt8 s_pLwpPatternTab[][8] = {
+ //Id Name
+ { 0xDF, 0xAF, 0x77, 0x77, 0x77, 0x77, 0xFA, 0xFD }, //0 Transparent
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //1 SolidForeground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0x7F, 0xFF, 0xF7, 0xFF, 0x7F, 0xFF, 0xF7, 0xFF }, //3 BACK_10PCTDOTS(31 GrayScale4thLightest)
+ { 0x77, 0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF }, //4 BACK_30PCTDOTS(30 GrayScale5thLightest)
+ { 0x6F, 0xFF, 0xB5, 0xFF, 0xB5, 0xFF, 0xDA, 0xFF }, //5 BACK_50PCTDOTS
+ { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD }, //6
+ { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 }, //7
+ { 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88 }, //8
+ { 0x22, 0x00, 0x88, 0x00, 0x22, 0x00, 0x88, 0x00 }, //9
+ { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 }, //10
+ { 0x80, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 }, //11
+ { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //12
+ { 0xB1, 0x30, 0x03, 0x1B, 0xD8, 0xC0, 0x0C, 0x8D }, //13
+ { 0x80, 0x10, 0x02, 0x20, 0x01, 0x08, 0x40, 0x04 }, //14
+ { 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66 }, //15
+ { 0x77, 0xBB, 0xDD, 0xEE, 0x77, 0xBB, 0xDD, 0xEE }, //16
+ { 0x6F, 0xB7, 0xDB, 0xED, 0xF6, 0x7B, 0xBD, 0xDE }, //17
+ { 0x5F, 0xAF, 0xD7, 0xEB, 0xF5, 0xFA, 0x7D, 0xBE }, //18
+ { 0xEA, 0x75, 0xBA, 0x5D, 0xAE, 0x57, 0xAB, 0xD5 }, //19
+ { 0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE }, //20
+ { 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66 }, //21
+ { 0xEE, 0xDD, 0xBB, 0x77, 0xEE, 0xDD, 0xBB, 0x77 }, //22
+ { 0xDE, 0xBD, 0x7B, 0xF6, 0xED, 0xDB, 0xB7, 0x6F }, //23
+ { 0xFA, 0xF5, 0xEB, 0xD7, 0xAF, 0x5F, 0xBE, 0x7D }, //24
+ { 0x57, 0xAE, 0x5D, 0xBA, 0x75, 0xEA, 0xD5, 0xAB }, //25
+ { 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F }, //26
+ { 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11, 0xAA }, //27
+ { 0xBB, 0x55, 0xEE, 0x55, 0xBB, 0x55, 0xEE, 0x55 }, //28
+ { 0x7E, 0xBD, 0xDB, 0xE7, 0xE7, 0xDB, 0xBD, 0x7E }, //29
+ { 0xF9, 0xF6, 0x6F, 0x9F, 0x9F, 0x6F, 0xF6, 0xF9 }, //30
+ { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF }, //31
+ { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00 }, //32
+ { 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF }, //33
+ { 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //34
+ { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, //35
+ { 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99 }, //36
+ { 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB }, //37
+ { 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE }, //38
+ { 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0xFF, 0x55 }, //39
+ { 0xBB, 0xBB, 0x00, 0xBB, 0xBB, 0xBB, 0x00, 0xBB }, //40
+ { 0x00, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD }, //41
+ { 0x22, 0x00, 0x20, 0x00, 0xAA, 0x00, 0x20, 0x00 }, //42
+ { 0x40, 0xA0, 0x00, 0x00, 0x04, 0x0A, 0x00, 0x00 }, //43
+ { 0x01, 0x80, 0x00, 0x08, 0x10, 0x20, 0x00, 0x02 }, //44
+ { 0xED, 0xED, 0x0C, 0xC0, 0xDE, 0xDE, 0xC0, 0x0C }, //45
+ { 0xC1, 0xE2, 0x77, 0x2E, 0x1C, 0x3A, 0x77, 0xA3 }, //46
+ { 0x00, 0xF7, 0xF7, 0xF7, 0x00, 0x7F, 0x7F, 0x7F }, //47
+ { 0x7C, 0xBB, 0xC7, 0xEF, 0xDF, 0xBF, 0x7F, 0xFE }, //48
+ { 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF, 0xCC }, //49
+ { 0xCC, 0xCC, 0x33, 0x33, 0x33, 0x33, 0xCC, 0xCC }, //50
+ { 0xF0, 0xF0, 0x0F, 0x0F, 0xF0, 0xF0, 0x0F, 0x0F }, //51
+ { 0xC3, 0xC3, 0xC3, 0xC3, 0x3C, 0x3C, 0x3C, 0x3C }, //52
+ { 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC }, //53
+ { 0x08, 0x08, 0x14, 0x22, 0xC9, 0x22, 0x14, 0x08 }, //54
+ { 0x0A, 0x04, 0x04, 0x55, 0xA0, 0x40, 0x40, 0x55 }, //55
+ { 0x01, 0x01, 0x03, 0x84, 0x48, 0x30, 0x0C, 0x02 }, //56
+ { 0x28, 0xC7, 0x01, 0x01, 0x82, 0x7C, 0x10, 0x10 }, //57
+ { 0x40, 0x80, 0x01, 0x02, 0x04, 0x8A, 0x55, 0xFF }, //58
+ { 0xC7, 0xC7, 0xBB, 0x4C, 0x7C, 0x7C, 0xBB, 0xC4 }, //59
+ { 0x8A, 0x05, 0x02, 0x00, 0x02, 0x05, 0x8A, 0x55 }, //60
+ { 0x28, 0x44, 0x82, 0x11, 0x00, 0x55, 0x00, 0x11 }, //61
+ { 0x81, 0x41, 0x60, 0x70, 0x78, 0x70, 0x60, 0x41 }, //62
+ { 0xEE, 0x57, 0xAB, 0x55, 0xEE, 0x5D, 0xBA, 0x75 }, //63
+
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, //2 SolidBackground
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
new file mode 100644
index 000000000..b5583d19e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -0,0 +1,499 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - row layouts
+ */
+
+#include "lwprowlayout.hxx"
+#include "lwptable.hxx"
+#include <lwpglobalmgr.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfrow.hxx>
+#include <xfilter/xfrowstyle.hxx>
+#include <xfilter/xftable.hxx>
+#include <xfilter/xfcell.hxx>
+#include <o3tl/sorted_vector.hxx>
+
+LwpRowLayout::LwpRowLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpVirtualLayout(objHdr, pStrm)
+ , crowid(0)
+ , cheight(0)
+ , cLeaderDotCount(0)
+ , cLeaderDotY(0)
+ , cRowFlags(0)
+{
+ m_ConnCellList.clear();
+}
+
+LwpRowLayout::~LwpRowLayout()
+{}
+
+/**
+ * @short register row style
+ * @param
+ * @param
+ * @param
+ * @return
+ */
+void LwpRowLayout::SetRowMap()
+{
+ LwpObjectID *pCellID= &GetChildHead();
+ LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+
+ o3tl::sorted_vector<LwpCellLayout*> aSeen;
+ while(pCellLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pCellLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ pCellLayout->SetCellMap();
+
+ pCellID = &pCellLayout->GetNext();
+ pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+ }
+}
+/**
+ * @short register row style
+ * @param
+ * @param
+ * @param
+ * @return
+ */
+void LwpRowLayout::RegisterStyle()
+{
+ // register row style
+ std::unique_ptr<XFRowStyle> pRowStyle(new XFRowStyle());
+
+ if (m_nDirection & 0x0030)
+ {
+ pRowStyle->SetMinRowHeight(static_cast<float>(LwpTools::ConvertFromUnitsToMetric(cheight)));
+ }
+ else
+ {
+ pRowStyle->SetRowHeight(static_cast<float>(LwpTools::ConvertFromUnitsToMetric(cheight)));
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(pRowStyle)).m_pStyle->GetStyleName();
+
+ LwpTableLayout* pTableLayout = GetParentTableLayout();
+ if (pTableLayout)
+ {
+ pTableLayout->GetTable();
+ }
+ // register cells' style
+ LwpObjectID *pCellID= &GetChildHead();
+ LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+
+ o3tl::sorted_vector<LwpCellLayout*> aSeen;
+ while (pCellLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pCellLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ pCellLayout->SetFoundry(m_pFoundry);
+ pCellLayout->RegisterStyle();
+ pCellID = &pCellLayout->GetNext();
+ pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+ }
+
+}
+/**
+ * @short register row style
+ * @param
+ * @param
+ * @param
+ * @return
+ */
+void LwpRowLayout::Read()
+{
+ #define MAXUNIT (0x7fffffffL) // Highest positive UNIT value
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ LwpVirtualLayout::Read();
+
+ //skip CLiteLayout data;
+ LwpAtomHolder ContentClass;
+ ContentClass.Read(pStrm);
+ pStrm->SkipExtra();
+
+ // Row layout content
+ crowid = pStrm->QuickReaduInt16();
+ cheight = pStrm->QuickReadInt32();
+ cLeaderDotCount = static_cast<sal_uInt8>(pStrm->QuickReaduInt16()); // was written as lushort.
+ cLeaderDotY = MAXUNIT; // Sentinel meaning "not calculated yet"
+ cRowFlags = static_cast<sal_uInt8>(pStrm->QuickReaduInt16()); // was written as lushort.
+
+ pStrm->SkipExtra();
+}
+
+/**
+ * @short Parse rows with connect cell
+ * @param pXFTable - pointer to created XFTable
+ */
+void LwpRowLayout::ConvertRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
+{
+ LwpTableLayout* pTableLayout = GetParentTableLayout();
+ if (!pTableLayout)
+ throw std::runtime_error("missing TableLayout");
+ LwpTable* pTable = pTableLayout->GetTable();
+
+ //calculate the connected cell position
+ sal_Int32 nMarkConnCell = FindMarkConnCell(nStartCol,nEndCol);
+
+ //if there is no connected cell
+ if (nMarkConnCell == -1)
+ {
+ ConvertCommonRow(pXFTable,nStartCol,nEndCol);
+ return;
+ }
+
+ //register connect row style
+ sal_uInt16 nRowMark = crowid + GetCurMaxSpannedRows(nStartCol,nEndCol);
+ rtl::Reference<XFRow> xXFRow(new XFRow);
+ RegisterCurRowStyle(xXFRow.get(), nRowMark);
+
+ //if there is connected cell
+ for (sal_uInt8 i=nStartCol; i<nEndCol; )
+ {
+ rtl::Reference<XFCell> xXFCell;
+ sal_uInt8 nColMark;
+
+ if (nMarkConnCell == -1)
+ nColMark = nEndCol;
+ else
+ nColMark = m_ConnCellList[nMarkConnCell]->GetColID();
+
+ if (nColMark > i)//create subtable
+ {
+ xXFCell.set(new XFCell);
+ xXFCell->SetColumnSpaned(nColMark-i);
+ rtl::Reference<XFTable> xSubTable(new XFTable);
+ pTableLayout->ConvertTable(xSubTable,crowid,nRowMark,i,nColMark);
+ xXFCell->Add(xSubTable.get());
+ i = nColMark;
+ }
+ else
+ {
+ sal_uInt8 nColID = m_ConnCellList[nMarkConnCell]->GetColID()
+ +m_ConnCellList[nMarkConnCell]->GetNumcols()-1;
+ xXFCell = m_ConnCellList[nMarkConnCell]->DoConvertCell(
+ pTable->GetObjectID(),
+ crowid+m_ConnCellList[nMarkConnCell]->GetNumrows()-1,
+ m_ConnCellList[nMarkConnCell]->GetColID());
+
+ //set all cell in this merge cell to cellsmap
+ pTableLayout->SetCellsMap(crowid, i, nRowMark - 1, nColID, xXFCell.get());
+
+ i += m_ConnCellList[nMarkConnCell]->GetNumcols();
+ nMarkConnCell = FindNextMarkConnCell(static_cast<sal_uInt16>(nMarkConnCell),nEndCol);
+ }
+
+ if (xXFCell)
+ xXFRow->AddCell(xXFCell);
+ }
+ pXFTable->AddRow(xXFRow);
+}
+
+/**
+ * @short register row style in SODC table
+ * @param pXFRow - pointer of row
+ * @param nRowMark - spanned row number
+ */
+void LwpRowLayout::RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark)
+{
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFRowStyle* pRowStyle = static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(m_StyleName));
+ if (!pRowStyle)
+ return;
+ double fHeight = pRowStyle->GetRowHeight();
+
+ std::unique_ptr<XFRowStyle> pNewStyle(new XFRowStyle);
+ *pNewStyle = *pRowStyle;
+ LwpTableLayout* pTableLayout = GetParentTableLayout();
+ if (!pTableLayout)
+ {
+ return;
+ }
+ std::map<sal_uInt16,LwpRowLayout*> RowsMap = pTableLayout->GetRowsMap();
+
+ for (sal_uInt16 i=crowid+1; i<nRowMark;i++)
+ {
+ std::map<sal_uInt16,LwpRowLayout*>::iterator iter = RowsMap.find(i);
+ if (iter == RowsMap.end())
+ {
+ pRowStyle = static_cast<XFRowStyle*>(
+ pXFStyleManager->FindStyle(pTableLayout->GetDefaultRowStyleName()));
+ }
+ else
+ {
+ pRowStyle = static_cast<XFRowStyle*>(
+ pXFStyleManager->FindStyle(iter->second->GetStyleName()));
+ }
+ if (!pRowStyle)
+ throw std::runtime_error("missing RowStyle");
+ fHeight += pRowStyle->GetRowHeight();
+ }
+
+ if (m_nDirection & 0x0030)
+ {
+ pNewStyle->SetMinRowHeight(static_cast<float>(fHeight));
+ }
+ else
+ {
+ pNewStyle->SetRowHeight(static_cast<float>(fHeight));
+ }
+
+ pXFRow->SetStyleName(pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName());
+}
+
+/**
+ * @short find max merge cell in a given column range
+ * @param nStartCol - start column ID
+ * @param nEndCol - end column ID
+ */
+sal_Int32 LwpRowLayout::FindMarkConnCell(sal_uInt8 nStartCol,sal_uInt8 nEndCol)
+{
+ if (m_ConnCellList.empty())
+ return -1;
+
+ sal_uInt16 nSpannRows = 1;
+ sal_Int32 nMarkConnCell = -1;
+
+ for (size_t i=0;i<m_ConnCellList.size();i++)
+ {
+ if (m_ConnCellList[i]->GetColID()>=nEndCol)
+ break;
+ if (m_ConnCellList[i]->GetColID()>=nStartCol)
+ {
+ if (m_ConnCellList[i]->GetNumrows()>nSpannRows)
+ {
+ nSpannRows = m_ConnCellList[i]->GetNumrows();
+ nMarkConnCell = i;
+ }
+ }
+ }
+ return nMarkConnCell;
+}
+
+/**
+ * @short find next merge cell with the same spanned row number with current merge cell
+ * @param nStartCol - start column ID
+ * @param nEndCol - end column ID
+ */
+sal_Int32 LwpRowLayout::FindNextMarkConnCell(sal_uInt16 nMarkConnCell,sal_uInt8 nEndCol)
+{
+ sal_uInt16 nMaxRows = m_ConnCellList[nMarkConnCell]->GetNumrows();
+
+ for (size_t i=nMarkConnCell+1;i<m_ConnCellList.size();i++)
+ {
+ if (m_ConnCellList[i]->GetColID()>=nEndCol)
+ break;
+ if (m_ConnCellList[i]->GetNumrows() == nMaxRows)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+/**
+ * @short get max spanned row numbers in a given column range
+ * @param nStartCol - start column ID
+ * @param nEndCol - end column ID
+ */
+sal_uInt16 LwpRowLayout::GetCurMaxSpannedRows(sal_uInt8 nStartCol,sal_uInt8 nEndCol)
+{
+ sal_Int32 nMarkConnCell = FindMarkConnCell(nStartCol,nEndCol);
+ if (nMarkConnCell == -1)
+ return 1;
+ else
+ return m_ConnCellList[nMarkConnCell]->GetNumrows();
+}
+/**
+ * @short convert row with rowlayout,but no merge cells
+ * @param pXFTable - pointer of table
+ * @param nStartCol - start column ID
+ * @param nEndCol - end column ID
+ */
+void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
+{
+ LwpTableLayout* pTableLayout = GetParentTableLayout();
+ if (!pTableLayout)
+ return;
+ LwpTable* pTable = pTableLayout->GetTable();
+ if (!pTable)
+ return;
+
+ rtl::Reference<XFRow> xRow(new XFRow);
+ xRow->SetStyleName(m_StyleName);
+
+ sal_uInt8 nCellStartCol,nCellEndCol;
+
+ for (sal_uInt16 i = nStartCol; i < nEndCol; i++)
+ {
+ // add row to table
+ LwpObjectID *pCellID= &GetChildHead();
+ LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+ nCellStartCol = i;//mark the begin position of cell
+ nCellEndCol = i;//mark the end position of cell
+ rtl::Reference<XFCell> xCell;
+ while(pCellLayout)
+ {
+ if (pCellLayout->GetColID() == i)
+ {
+ if (pCellLayout->GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT)
+ {
+ LwpConnectedCellLayout* pConnCell = static_cast<LwpConnectedCellLayout*>(pCellLayout);
+ auto nNumCols = pConnCell->GetNumcols();
+ if (!nNumCols)
+ throw std::runtime_error("loop in conversion");
+ auto nNewEndCol = i + nNumCols - 1;
+ if (nNewEndCol > std::numeric_limits<sal_uInt8>::max())
+ throw std::range_error("column index too large");
+ nCellEndCol = nNewEndCol;
+ i = nCellEndCol;
+ }
+ xCell = pCellLayout->DoConvertCell(pTable->GetObjectID(),crowid,i);
+ break;
+ }
+ pCellID = &pCellLayout->GetNext();
+ pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+ }
+ if (!pCellLayout)
+ {
+ // if table has default cell layout, use it to ConvertCell
+ // otherwise use blank cell
+ LwpCellLayout * pDefaultCell = pTableLayout->GetDefaultCellLayout();
+ if (pDefaultCell)
+ {
+ xCell = pDefaultCell->DoConvertCell(
+ pTable->GetObjectID(),crowid, i);
+ }
+ else
+ {
+ xCell.set(new XFCell);
+ }
+ }
+ xRow->AddCell(xCell);
+
+ pTableLayout->SetCellsMap(crowid, nCellStartCol, crowid, nCellEndCol, xCell.get()); //set to cellsmap
+ }
+
+ pXFTable->AddRow(xRow);
+}
+/**
+ * @short collect merge cell info when register row styles
+ */
+void LwpRowLayout::CollectMergeInfo()
+{
+ LwpObjectID *pCellID= &GetChildHead();
+ LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+
+ while(pCellLayout)
+ {
+ if (pCellLayout->GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT)
+ {
+ LwpConnectedCellLayout* pConnCell = static_cast<LwpConnectedCellLayout*>(pCellLayout);
+ m_ConnCellList.push_back(pConnCell);
+ }
+ pCellID = &pCellLayout->GetNext();
+ pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
+ }
+}
+/**
+ * @short split merge cells in this row
+ * @param nEffectRows - max spanned number of previous row
+ */
+void LwpRowLayout::SetCellSplit(sal_uInt16 nEffectRows)
+{
+ for (LwpConnectedCellLayout* pConnCell : m_ConnCellList)
+ {
+ sal_uInt16 nRowSpan;
+ if (o3tl::checked_add(pConnCell->GetRowID(), pConnCell->GetNumrows(), nRowSpan))
+ throw std::range_error("bad span");
+ if (nRowSpan > nEffectRows)
+ {
+ if (o3tl::checked_sub(nEffectRows, pConnCell->GetRowID(), nRowSpan))
+ throw std::range_error("bad span");
+ pConnCell->SetNumrows(nRowSpan);
+ }
+ }
+}
+/**
+ * @short check if the row has merge cell
+ */
+bool LwpRowLayout::GetMergeCellFlag() const
+{
+ return !m_ConnCellList.empty();
+}
+
+LwpRowHeadingLayout::LwpRowHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpRowLayout(objHdr, pStrm)
+{}
+
+LwpRowHeadingLayout::~LwpRowHeadingLayout()
+{}
+void LwpRowHeadingLayout::Read()
+{
+ LwpRowLayout::Read();
+
+ cRowLayout.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwprowlayout.hxx b/lotuswordpro/source/filter/lwprowlayout.hxx
new file mode 100644
index 000000000..ad2c9eacb
--- /dev/null
+++ b/lotuswordpro/source/filter/lwprowlayout.hxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - row layouts
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPROWLAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPROWLAYOUT_HXX
+
+#include "lwplayout.hxx"
+#include "lwptablelayout.hxx"
+#include "lwpcelllayout.hxx"
+
+class XFRow;
+class XFTable;
+class LwpTableLayout;
+/**
+ * @brief
+ * VO_ROWLAYOUT obj
+ */
+class LwpRowLayout : public LwpVirtualLayout
+{
+public:
+ LwpRowLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpRowLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_ROW_LAYOUT;}
+ sal_uInt16 GetRowID() const { return crowid;}
+ virtual void RegisterStyle() override;
+ LwpTableLayout * GetParentTableLayout(){return dynamic_cast<LwpTableLayout *>(GetParent().obj().get());}
+ void SetRowMap();
+protected:
+ void Read() override;
+ sal_uInt16 crowid;
+ sal_Int32 cheight; // Minimum height if height is automatic.
+ sal_uInt8 cLeaderDotCount; // dfb - # of cells with leader dots
+ sal_Int32 cLeaderDotY;
+ sal_uInt8 cRowFlags;
+ enum // for cRowFlags
+ {
+ RF_HAS_BORDER = 0x01,
+ RF_VALID_HAS_BORDER = 0x02,
+ RF_LEADER_COUNT_VALID = 0x4
+ };
+private:
+ std::vector<LwpConnectedCellLayout*> m_ConnCellList;
+ sal_Int32 FindMarkConnCell(sal_uInt8 nStartCol,sal_uInt8 nEndCol);
+ sal_Int32 FindNextMarkConnCell(sal_uInt16 nMarkConnCell,sal_uInt8 nEndCol);
+
+public:
+ void ConvertRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
+ void ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
+ void CollectMergeInfo();
+ void SetCellSplit(sal_uInt16 nEffectRows);
+ bool GetMergeCellFlag() const;
+ sal_uInt16 GetCurMaxSpannedRows(sal_uInt8 nStartCol,sal_uInt8 nEndCol);
+ void RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark);
+};
+
+/**
+ * @brief
+ * VO_ROWHEADINGLAYOUT obj
+ */
+class LwpRowHeadingLayout : public LwpRowLayout
+{
+public:
+ LwpRowHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpRowHeadingLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_ROW_HEADING_LAYOUT;}
+protected:
+ void Read() override;
+private:
+ LwpObjectID cRowLayout;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwdrawheader.hxx b/lotuswordpro/source/filter/lwpsdwdrawheader.hxx
new file mode 100644
index 000000000..85318afbf
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwdrawheader.hxx
@@ -0,0 +1,366 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype
+ * The file declares structures and enums used by Lwp-Drawing-Module
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWDRAWHEADER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWDRAWHEADER_HXX
+
+#include <config_lgpl.h>
+#include <sal/types.h>
+#include <vector>
+
+const sal_uInt8 DRAW_FACESIZE = 32;
+const double THRESHOLD = 0.0001;
+
+enum DrawObjectType
+{
+ OT_UNDEFINED = 0,
+
+ OT_SELECT = 0,
+ OT_HAND = 1,
+ OT_LINE = 2,
+ OT_PERPLINE = 3,
+ OT_POLYLINE = 4,
+ OT_POLYGON = 5,
+ OT_RECT = 6,
+ OT_SQUARE = 7,
+ OT_RNDRECT = 8,
+ OT_RNDSQUARE = 9,
+ OT_OVAL = 10,
+ OT_CIRCLE = 11,
+ OT_ARC = 12,
+ OT_TEXT = 13,
+ OT_GROUP = 14,
+ OT_CHART = 15,
+ OT_METAFILE = 16,
+ OT_METAFILEIMG = 17,
+ OT_BITMAP = 18,
+ OT_TEXTART = 19,
+ OT_BIGBITMAP = 20
+};
+
+enum DrawFillType
+{
+ FT_TRANSPARENT = 0,
+ FT_VLTGRAY = 1,
+ FT_LTGRAY = 2,
+ FT_GRAY = 3,
+ FT_DKGRAY = 4,
+ FT_SOLID = 5,
+ FT_HORZHATCH = 6,
+ FT_VERTHATCH = 7,
+ FT_FDIAGHATCH = 8,
+ FT_BDIAGHATCH = 9,
+ FT_CROSSHATCH = 10,
+ FT_DIAGCROSSHATCH = 11,
+ FT_PATTERN = 12
+};
+
+enum DrawLineStyle
+{
+ LS_SOLID = 0,
+ LS_DASH = 1,
+ LS_DOT = 2,
+ LS_DASHDOT = 3,
+ LS_DASHDOTDOT = 4,
+ LS_NULL = 5,
+ LS_INSIDEFRAME = 6
+};
+
+// Text Attributes as stored in Draw files V1.2 and earlier
+enum DrawTextAttribute
+{
+ TA_BOLD = 0x0001, /* bolded font */
+ TA_ITALIC = 0x0002, /* italic font */
+ TA_UNDERLINE = 0x0004, /* underlined font */
+ TA_WORDUNDERLINE = 0x0008, /* broken underline */
+ TA_ALLCAPS = 0x0010, /* capitalized font */
+ TA_SMALLCAPS = 0x0020, /* all small capital letters */
+ TA_DOUBLEUNDER = 0x0040, /* double underline */
+ TA_STRIKETHRU = 0x0080, /* strikethru */
+ TA_SUPERSCRIPT = 0x0100, /* superscript */
+ TA_SUBSCRIPT = 0x0200 /* subscript */
+};
+
+enum DrawArrowHead
+{
+ AH_ARROW_NONE = 0,
+ AH_ARROW_FULLARROW = 1,
+ AH_ARROW_HALFARROW = 2,
+ AH_ARROW_LINEARROW = 3,
+ AH_ARROW_INVFULLARROW = 4,
+ AH_ARROW_INVHALFARROW = 5,
+ AH_ARROW_INVLINEARROW = 6,
+ AH_ARROW_TEE = 7,
+ AH_ARROW_SQUARE = 8,
+ AH_ARROW_CIRCLE = 9
+};
+
+struct SdwPoint
+{
+ sal_Int16 x;
+ sal_Int16 y;
+ SdwPoint()
+ : x(0)
+ , y(0)
+ {
+ }
+};
+
+struct SdwColor
+{
+ sal_uInt8 nR;
+ sal_uInt8 nG;
+ sal_uInt8 nB;
+ sal_uInt8 unused;
+ SdwColor()
+ : nR(0)
+ , nG(0)
+ , nB(0)
+ , unused(0)
+ {
+ }
+};
+
+struct SdwClosedObjStyleRec
+{
+ sal_uInt8 nLineWidth = 0;
+ sal_uInt8 nLineStyle = 0;
+ SdwColor aPenColor;
+ SdwColor aForeColor;
+ SdwColor aBackColor;
+ sal_uInt16 nFillType = 0;
+ sal_uInt8 pFillPattern[8] = {};
+ SdwClosedObjStyleRec() = default;
+};
+
+struct SdwDrawObjHeader
+{
+ sal_uInt16 nRecLen;
+ sal_Int16 nLeft;
+ sal_Int16 nTop;
+ sal_Int16 nRight;
+ sal_Int16 nBottom;
+ SdwDrawObjHeader()
+ : nRecLen(0)
+ , nLeft(0)
+ , nTop(0)
+ , nRight(0)
+ , nBottom(0)
+ {
+ }
+};
+
+struct SdwLineRecord
+{
+ sal_Int16 nStartX;
+ sal_Int16 nStartY;
+ sal_Int16 nEndX;
+ sal_Int16 nEndY;
+ sal_uInt8 nLineWidth;
+ sal_uInt8 nLineEnd;
+ sal_uInt8 nLineStyle;
+ SdwColor aPenColor;
+ SdwLineRecord()
+ : nStartX(0)
+ , nStartY(0)
+ , nEndX(0)
+ , nEndY(0)
+ , nLineWidth(0)
+ , nLineEnd(0)
+ , nLineStyle(0)
+ {
+ }
+};
+
+struct SdwPolyLineRecord
+{
+ sal_uInt8 nLineWidth;
+ sal_uInt8 nLineEnd;
+ sal_uInt8 nLineStyle;
+ SdwColor aPenColor;
+ sal_uInt16 nNumPoints;
+ SdwPolyLineRecord()
+ : nLineWidth(0)
+ , nLineEnd(0)
+ , nLineStyle(0)
+ , nNumPoints(0)
+ {
+ }
+};
+
+struct SdwArcRecord
+{
+ sal_uInt8 nLineWidth;
+ sal_uInt8 nLineEnd;
+ sal_uInt8 nLineStyle;
+ SdwColor aPenColor;
+ SdwArcRecord()
+ : nLineWidth(0)
+ , nLineEnd(0)
+ , nLineStyle(0)
+ {
+ }
+};
+
+struct SdwTextBoxRecord
+{
+ sal_Int16 nTextWidth;
+ sal_Int16 nTextHeight;
+ sal_Int16 nTextSize;
+ SdwColor aTextColor;
+ sal_uInt8 tmpTextFaceName[DRAW_FACESIZE];
+ sal_uInt16 nTextAttrs;
+ sal_uInt16 nTextCharacterSet;
+ sal_Int16 nTextRotation;
+ sal_Int16 nTextExtraSpacing;
+ sal_uInt8* pTextString;
+ SdwTextBoxRecord()
+ : nTextWidth(0)
+ , nTextHeight(0)
+ , nTextSize(0)
+ , tmpTextFaceName{}
+ , nTextAttrs(0)
+ , nTextCharacterSet(0)
+ , nTextRotation(0)
+ , nTextExtraSpacing(0)
+ , pTextString(nullptr)
+ {
+ }
+};
+
+struct SdwFMPATH
+{
+ sal_uInt16 n;
+ std::vector<SdwPoint> aPts;
+ SdwFMPATH()
+ : n(0)
+ {
+ }
+};
+
+struct SdwTextArt : public SdwTextBoxRecord
+{
+ sal_uInt8 nIndex;
+ sal_Int16 nRotation;
+ sal_uInt16 nTextLen;
+ SdwFMPATH aPath[2];
+ SdwTextArt()
+ : nIndex(0)
+ , nRotation(0)
+ , nTextLen(0)
+ {
+ }
+};
+
+struct SdwBmpRecord
+{
+ sal_uInt16 nTranslation;
+ sal_uInt16 nRotation;
+ sal_uInt32 nFileSize;
+ SdwBmpRecord()
+ : nTranslation(0)
+ , nRotation(0)
+ , nFileSize(0)
+ {
+ }
+};
+
+struct BmpInfoHeader
+{
+ sal_uInt32 nHeaderLen;
+ sal_uInt16 nWidth;
+ sal_uInt16 nHeight;
+ sal_uInt16 nPlanes;
+ sal_uInt16 nBitCount;
+};
+
+struct BmpInfoHeader2
+{
+ sal_uInt32 nHeaderLen;
+ sal_uInt32 nWidth;
+ sal_uInt32 nHeight;
+ sal_uInt16 nPlanes;
+ sal_uInt16 nBitCount;
+};
+
+struct DrawingOffsetAndScale
+{
+ double fOffsetX;
+ double fOffsetY;
+ double fScaleX;
+ double fScaleY;
+ double fLeftMargin;
+ double fTopMargin;
+
+ DrawingOffsetAndScale()
+ {
+ fOffsetX = 0.00;
+ fOffsetY = 0.00;
+ fScaleX = 1.00;
+ fScaleY = 1.00;
+ fLeftMargin = 0.00;
+ fTopMargin = 0.00;
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwfileloader.cxx b/lotuswordpro/source/filter/lwpsdwfileloader.cxx
new file mode 100644
index 000000000..1bcd96301
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwfileloader.cxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/stream.hxx>
+
+#include "lwpsdwfileloader.hxx"
+#include "lwpsdwgrouploaderv0102.hxx"
+
+#include <xfilter/xfframe.hxx>
+
+LwpSdwFileLoader::LwpSdwFileLoader(SvStream* pStream, LwpGraphicObject* pGraphicObj)
+ : m_pStream(pStream)
+ , m_pGraphicObj(pGraphicObj)
+{
+ pStream->Seek(0);
+}
+
+/**
+ * @descr entry of lwp-drawing objects.
+ * @param pDrawObjVector a container which will contains the created drawing object of XF-Model.
+ */
+void LwpSdwFileLoader::CreateDrawObjects(std::vector<rtl::Reference<XFFrame>>* pDrawObjVector)
+{
+ unsigned char BinSignature[2];
+ if (m_pStream->ReadBytes(BinSignature, 2) != 2)
+ return;
+
+ if (BinSignature[0] != 'S' || BinSignature[1] != 'M')
+ return;
+
+ unsigned short nVersion(0);
+ m_pStream->ReadUInt16(nVersion);
+
+ m_pStream->Seek(0);
+ if (nVersion < 0x0102)
+ {
+ assert(false);
+ }
+ if (nVersion >= 0x0102)
+ {
+ LwpSdwGroupLoaderV0102 sdwGroupLoader(m_pStream, m_pGraphicObj);
+ sdwGroupLoader.BeginDrawObjects(pDrawObjVector);
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwfileloader.hxx b/lotuswordpro/source/filter/lwpsdwfileloader.hxx
new file mode 100644
index 000000000..9fa056684
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwfileloader.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWFILELOADER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWFILELOADER_HXX
+
+#include <sal/config.h>
+#include <config_lgpl.h>
+
+#include <vector>
+
+#include <rtl/ref.hxx>
+
+class SvStream;
+class XFFrame;
+class LwpGraphicObject;
+class LwpSdwFileLoader
+{
+private:
+ SvStream* m_pStream;
+ LwpGraphicObject* m_pGraphicObj;
+
+public:
+ LwpSdwFileLoader(SvStream* pStream, LwpGraphicObject* pGraphicObj);
+
+public:
+ void CreateDrawObjects(std::vector<rtl::Reference<XFFrame>>* pDrawObjVector);
+};
+
+#endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWFILELOADER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx
new file mode 100644
index 000000000..db51eb39e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx
@@ -0,0 +1,395 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/stream.hxx>
+
+#include "lwpsdwgrouploaderv0102.hxx"
+#include "lwpdrawobj.hxx"
+#include <lwptools.hxx>
+#include "lwpgrfobj.hxx"
+#include "lwpframelayout.hxx"
+
+#include <xfilter/xfdrawgroup.hxx>
+#include <sal/log.hxx>
+
+LwpSdwGroupLoaderV0102::LwpSdwGroupLoaderV0102(SvStream* pStream, LwpGraphicObject* pGraphicObj)
+ : m_pStream(pStream)
+ , m_pGraphicObj(pGraphicObj)
+ , m_pDrawObjVector(nullptr)
+{
+}
+
+/**
+ * @descr entry of lwp-drawing objects. the function begins to parse the sdw-drawing bento stream and create
+ * the corresponding drawing objects.
+ * @param pDrawObjVector a container which will contains the created drawing object of XF-Model.
+ */
+void LwpSdwGroupLoaderV0102::BeginDrawObjects(std::vector< rtl::Reference<XFFrame> >* pDrawObjVector)
+{
+ // save the container
+ m_pDrawObjVector = pDrawObjVector;
+
+ //flag
+ unsigned char BinSignature[2];
+ m_pStream->ReadBytes(BinSignature, 2);
+ if (BinSignature[0] != 'S' || BinSignature[1] != 'M')
+ {
+ assert(false);
+ return;
+ }
+ //version
+ unsigned short nVersion;
+ m_pStream->ReadUInt16(nVersion);
+ if (nVersion<0x0102)
+ {
+ assert(false);
+ return;
+ }
+ // topObj, botObj
+ m_pStream->SeekRel(4);
+ //record count
+ unsigned short nRecCount(0);
+ m_pStream->ReadUInt16(nRecCount);
+ // selCount
+ m_pStream->SeekRel(2);
+ //boundrect
+ unsigned short left(0),top(0),right(0),bottom(0);
+ m_pStream->ReadUInt16(left);
+ m_pStream->ReadUInt16(top);
+ m_pStream->ReadUInt16(right);
+ m_pStream->ReadUInt16(bottom);
+ // fileSize
+ m_pStream->SeekRel(2);
+
+ //for calculating transformation params.
+ rtl::Reference<LwpFrameLayout> xMyFrameLayout(dynamic_cast<LwpFrameLayout*>(m_pGraphicObj->GetLayout(nullptr).get()));
+ if (xMyFrameLayout.is())
+ {
+ LwpLayoutScale* pMyScale = xMyFrameLayout->GetLayoutScale();
+ LwpLayoutGeometry* pFrameGeo = xMyFrameLayout->GetGeometry();
+ if (pMyScale && pFrameGeo)
+ {
+ // original drawing size
+ tools::Long nWidth = 0, nHeight = 0;
+ m_pGraphicObj->GetGrafOrgSize(nWidth, nHeight);
+ double fGrafOrgWidth = static_cast<double>(nWidth)/TWIPS_PER_CM;
+ double fGrafOrgHeight = static_cast<double>(nHeight)/TWIPS_PER_CM;
+
+ // get margin values
+ double fLeftMargin = xMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
+ double fTopMargin = xMyFrameLayout->GetMarginsValue(MARGIN_TOP);
+
+ // frame size
+ double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
+ double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
+
+ // get frame offset
+ LwpPoint& rOffset = pMyScale->GetOffset();
+ double fOffsetX = LwpTools::ConvertFromUnitsToMetric(rOffset.GetX());
+ double fOffsetY = LwpTools::ConvertFromUnitsToMetric(rOffset.GetY());
+
+ // get scale mode
+ sal_uInt16 nScalemode = pMyScale->GetScaleMode();
+
+ if (nScalemode & LwpLayoutScale::CUSTOM)
+ {
+ m_aTransformData.fScaleX =
+ LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth()) / fGrafOrgWidth;
+ m_aTransformData.fScaleY =
+ LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight()) / fGrafOrgHeight;
+ }
+ else if (nScalemode & LwpLayoutScale::PERCENTAGE)
+ {
+ double fScalePercentage = static_cast<double>(pMyScale->GetScalePercentage()) / 1000;
+ m_aTransformData.fScaleX = fScalePercentage;
+ m_aTransformData.fScaleY = fScalePercentage;
+ }
+ else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
+ {
+ double fWidth0 = static_cast<double>(right) / TWIPS_PER_CM;
+ double fHeight0 = static_cast<double>(bottom) / TWIPS_PER_CM;
+
+ double fWidth1 = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
+ double fHeight1 = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
+
+ double fScaleX = fWidth1 / fWidth0;
+ double fScaleY = fHeight1 / fHeight0;
+
+ if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
+ {
+ m_aTransformData.fScaleX = std::min(fScaleX, fScaleY);
+ m_aTransformData.fScaleY = m_aTransformData.fScaleX;
+ }
+ else
+ {
+ m_aTransformData.fScaleX = fWidth1 / fWidth0;
+ m_aTransformData.fScaleY = fHeight1 / fHeight0;
+ }
+ }
+
+ // placement: centered
+ if (xMyFrameLayout->GetScaleCenter())
+ {
+ tools::Rectangle aBoundRect(static_cast<tools::Long>(left*m_aTransformData.fScaleX + fLeftMargin),
+ static_cast<tools::Long>(top * m_aTransformData.fScaleY + fTopMargin),
+ static_cast<tools::Long>(right * m_aTransformData.fScaleX),
+ static_cast<tools::Long>(bottom * m_aTransformData.fScaleY));
+ Point aCenter = aBoundRect.Center();
+
+ double fNewCenterX = (double(left)/TWIPS_PER_CM + fFrameWidth/*-fOffsetX*/) / 2;
+ double fNewCenterY = (double(top)/TWIPS_PER_CM + fFrameHeight/*-fOffsetY*/) / 2;
+
+ m_aTransformData.fOffsetX = fNewCenterX - static_cast<double>(aCenter.X())/TWIPS_PER_CM;
+ m_aTransformData.fOffsetY = fNewCenterY -static_cast<double>(aCenter.Y())/TWIPS_PER_CM;
+ }
+ else
+ {
+ m_aTransformData.fOffsetX = fOffsetX;
+ m_aTransformData.fOffsetY = fOffsetY;
+ }
+
+ m_aTransformData.fOffsetX += fLeftMargin;
+ m_aTransformData.fOffsetY += fTopMargin;
+ m_aTransformData.fLeftMargin = fLeftMargin;
+ m_aTransformData.fTopMargin = fTopMargin;
+ }
+ }
+
+ if (nRecCount > m_pStream->remainingSize())
+ {
+ SAL_WARN("lwp", "stream too short for claimed no of records");
+ nRecCount = m_pStream->remainingSize();
+ }
+
+ //load draw object
+ for (unsigned short i = 0; i < nRecCount; i++)
+ {
+ rtl::Reference<XFFrame> xXFDrawObj = CreateDrawObject();
+ if (xXFDrawObj)
+ {
+ pDrawObjVector->push_back(xXFDrawObj);
+ }
+ }
+}
+
+/**
+ * @descr when we encounter a group object the function will be called to create a XF-drawgroup object
+ * the corresponding drawing objects.
+ * @param pDrawObjVector a container which will contains the created drawing object of XF-Model.
+ */
+rtl::Reference<XFDrawGroup> LwpSdwGroupLoaderV0102::CreateDrawGroupObject()
+{
+ //flag
+ unsigned char BinSignature[2];
+ if (m_pStream->ReadBytes(BinSignature, 2) != 2)
+ return nullptr;
+ if (BinSignature[0] != 'S' || BinSignature[1] != 'M')
+ return nullptr;
+ //version
+ unsigned short nVersion(0);
+ m_pStream->ReadUInt16(nVersion);
+ if (nVersion<0x0102)
+ return nullptr;
+ // topObj, botObj
+ m_pStream->SeekRel(4);
+ //record count
+ unsigned short nRecCount(0);
+ m_pStream->ReadUInt16(nRecCount);
+ // selCount
+ m_pStream->SeekRel(2);
+ //boundrect
+ unsigned short left(0),top(0),right(0),bottom(0);
+ m_pStream->ReadUInt16(left);
+ m_pStream->ReadUInt16(top);
+ m_pStream->ReadUInt16(right);
+ m_pStream->ReadUInt16(bottom);
+ // fileSize
+ m_pStream->SeekRel(2);
+
+ rtl::Reference<XFDrawGroup> xXFDrawGroup(new XFDrawGroup());
+
+ if (nRecCount > m_pStream->remainingSize())
+ {
+ SAL_WARN("lwp", "stream too short for claimed no of records");
+ nRecCount = m_pStream->remainingSize();
+ }
+
+ //load draw object
+ for (unsigned short i = 0; i < nRecCount; i++)
+ {
+ rtl::Reference<XFFrame> xXFDrawObj = CreateDrawObject();
+
+ if (xXFDrawObj)
+ {
+ if (xXFDrawObj->GetFrameType() == enumXFFrameImage)
+ {
+ m_pDrawObjVector->push_back(xXFDrawObj);
+ }
+ else
+ {
+ xXFDrawGroup->Add(xXFDrawObj.get());
+ }
+ }
+ }
+
+ return xXFDrawGroup;
+}
+
+/**
+ * @descr Create the XF-drawing objects according to the object type read from bento stream.
+ * @return the created XF-drawing objects.
+ */
+rtl::Reference<XFFrame> LwpSdwGroupLoaderV0102::CreateDrawObject()
+{
+ //record type
+ unsigned char recType(0);
+ m_pStream->ReadUChar(recType);
+
+ std::unique_ptr<LwpDrawObj> pDrawObj;
+ rtl::Reference<XFFrame> xRetObject;
+
+ switch(recType)
+ {
+ case OT_PERPLINE://fall-through
+ case OT_LINE:
+ {
+ pDrawObj.reset(new LwpDrawLine(m_pStream, &m_aTransformData));
+ break;
+ }
+ case OT_POLYLINE:
+ {
+ pDrawObj.reset(new LwpDrawPolyLine(m_pStream, &m_aTransformData));
+ break;
+ }
+ case OT_POLYGON:
+ {
+ pDrawObj.reset(new LwpDrawPolygon(m_pStream, &m_aTransformData));
+ pDrawObj->SetObjectType(OT_POLYGON);
+ break;
+ }
+ case OT_SQUARE://fall-through
+ case OT_RECT:
+ {
+ pDrawObj.reset(new LwpDrawRectangle(m_pStream, &m_aTransformData));
+ break;
+ }
+ case OT_RNDSQUARE://fall-through
+ case OT_RNDRECT:
+ {
+ pDrawObj.reset(new LwpDrawRectangle(m_pStream, &m_aTransformData));
+ pDrawObj->SetObjectType(OT_RNDRECT);
+ break;
+ }
+ case OT_CIRCLE://fall-through
+ case OT_OVAL:
+ {
+ pDrawObj.reset(new LwpDrawEllipse(m_pStream, &m_aTransformData));
+ break;
+ }
+ case OT_ARC:
+ {
+ pDrawObj.reset(new LwpDrawArc(m_pStream, &m_aTransformData));
+ break;
+ }
+ case OT_TEXT:
+ {
+ pDrawObj.reset(new LwpDrawTextBox(m_pStream));
+ break;
+ }
+ case OT_TEXTART:
+ {
+ pDrawObj.reset(new LwpDrawTextArt(m_pStream, &m_aTransformData));
+ pDrawObj->SetObjectType(OT_TEXTART);
+ break;
+ }
+ case OT_GROUP:
+ {
+ m_pStream->SeekRel(2);
+ // read out the object header
+ pDrawObj.reset(new LwpDrawGroup(m_pStream));
+
+ xRetObject = CreateDrawGroupObject();
+
+ if (xRetObject)
+ {
+ // set anchor type
+ xRetObject->SetAnchorType(enumXFAnchorFrame);
+ }
+ break;
+ }
+ case OT_CHART://fall-through
+ case OT_METAFILE://fall-through
+ case OT_METAFILEIMG:
+ {
+ LwpDrawMetafile aMeta(m_pStream);
+ break;
+ }
+ case OT_BITMAP:
+ pDrawObj.reset(new LwpDrawBitmap(m_pStream));
+ pDrawObj->SetObjectType(OT_BITMAP);
+ break;
+ }
+
+ // we don't need create the corresponding XF-object of a group object.
+ if (pDrawObj && recType != OT_GROUP)
+ {
+ xRetObject = pDrawObj->CreateXFDrawObject();
+ }
+
+ return xRetObject;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.hxx b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.hxx
new file mode 100644
index 000000000..238ee8533
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWGROUPLOADERV0102_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWGROUPLOADERV0102_HXX
+
+#include <sal/config.h>
+#include <config_lgpl.h>
+
+#include <rtl/ref.hxx>
+
+#include "lwpsdwdrawheader.hxx"
+
+class SvStream;
+class XFFrame;
+class XFDrawGroup;
+class LwpGraphicObject;
+class LwpSdwGroupLoaderV0102
+{
+private:
+ SvStream* m_pStream;
+ LwpGraphicObject* m_pGraphicObj;
+ std::vector<rtl::Reference<XFFrame>>* m_pDrawObjVector;
+
+ DrawingOffsetAndScale m_aTransformData;
+
+public:
+ LwpSdwGroupLoaderV0102(SvStream* pStream, LwpGraphicObject* pGraphicObj);
+
+public:
+ void BeginDrawObjects(std::vector<rtl::Reference<XFFrame>>* pDrawObjVector);
+ rtl::Reference<XFDrawGroup> CreateDrawGroupObject();
+ rtl::Reference<XFFrame> CreateDrawObject();
+};
+
+#endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWGROUPLOADERV0102_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwrect.cxx b/lotuswordpro/source/filter/lwpsdwrect.cxx
new file mode 100644
index 000000000..3bc2704ac
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwrect.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype
+ * Implementation file of SdwRectangle.
+ */
+
+#include "lwpsdwrect.hxx"
+#include <cmath>
+
+/**************************************************************************
+ * @short: Default constructor
+**************************************************************************/
+SdwRectangle::SdwRectangle()
+ : m_bRotated(false)
+ // m_nRectCorner array fields are default initialized with Point()
+{
+}
+/**************************************************************************
+ * @short: Constructor
+ * @param: aPt0~aPt3 four corner points of a rectangle.
+**************************************************************************/
+SdwRectangle::SdwRectangle(const Point& rPt0, const Point& rPt1,
+ const Point& rPt2, const Point& rPt3)
+ : m_bRotated(rPt0.Y() != rPt1.Y() || rPt0.Y() >= rPt3.Y())
+ , m_nRectCorner({{rPt0, rPt1, rPt2, rPt3}})
+{
+}
+
+/**************************************************************************
+ * @short: Calculate and return center point of the rectangle.
+ * @return: center point
+**************************************************************************/
+Point SdwRectangle::GetRectCenter() const
+{
+ tools::Long nX = static_cast<tools::Long>(static_cast<double>(m_nRectCorner[0].X() + m_nRectCorner[2].X())/2 + 0.5);
+ tools::Long nY = static_cast<tools::Long>(static_cast<double>(m_nRectCorner[0].Y() + m_nRectCorner[2].Y())/2 + 0.5);
+
+ return Point(nX, nY);
+}
+/**************************************************************************
+ * @short: Calculate width of the rectangle.
+ * @return: rectangle width.
+**************************************************************************/
+tools::Long SdwRectangle::GetWidth() const
+{
+ tools::Long nX0 = m_nRectCorner[0].X();
+ tools::Long nY0 = m_nRectCorner[0].Y();
+ tools::Long nX1 = m_nRectCorner[1].X();
+ tools::Long nY1 = m_nRectCorner[1].Y();
+
+ return static_cast<tools::Long>(CalcDistBetween2Points(nX0, nY0, nX1, nY1));
+}
+/**************************************************************************
+ * @short: Calculate height of the rectangle.
+ * @return: rectangle height.
+**************************************************************************/
+tools::Long SdwRectangle::GetHeight() const
+{
+ tools::Long nX1 = m_nRectCorner[1].X();
+ tools::Long nY1 = m_nRectCorner[1].Y();
+ tools::Long nX2 = m_nRectCorner[2].X();
+ tools::Long nY2 = m_nRectCorner[2].Y();
+
+ return static_cast<tools::Long>(CalcDistBetween2Points(nX1, nY1, nX2, nY2));
+}
+/**************************************************************************
+ * @short: Calculate coordinate of the original rectangle.
+ * @return: a prz rectangle
+**************************************************************************/
+tools::Rectangle SdwRectangle::GetOriginalRect() const
+{
+ if (m_bRotated)
+ {
+ tools::Long nHeight = GetHeight();
+ tools::Long nWidth = GetWidth();
+ Point aCenter = GetRectCenter();
+
+ Point aLT(aCenter.X()-static_cast<tools::Long>(static_cast<double>(nWidth)/2+0.5),
+ aCenter.Y()-static_cast<tools::Long>(static_cast<double>(nHeight)/2+0.5));
+ Point aRB(aLT.X()+nWidth, aLT.Y()+nHeight);
+
+ return tools::Rectangle(aLT, aRB);
+ }
+ else
+ {
+ return tools::Rectangle(m_nRectCorner[3], m_nRectCorner[1]);
+ }
+}
+/**************************************************************************
+ * @short: Calculate rotation angle of the rectangle.
+ * @return: rotation angle.
+**************************************************************************/
+double SdwRectangle::GetRotationAngle() const
+{
+ if (!m_bRotated)
+ {
+ return 0.00;
+ }
+
+ double fX1 = static_cast<double>(m_nRectCorner[1].X());
+ double fY1 = static_cast<double>(m_nRectCorner[1].Y());
+ double fX2 = static_cast<double>(m_nRectCorner[2].X());
+ double fY2 = static_cast<double>(m_nRectCorner[2].Y());
+ double fMidX = (fX1 + fX2) / 2;
+ double fMidY = (fY1 + fY2) / 2;
+
+ Point aCenter = GetRectCenter();
+ double fCenterX = static_cast<double>(aCenter.X());
+ double fCenterY = static_cast<double>(aCenter.Y());
+
+ double fAngle = atan2((fMidY - fCenterY), (fMidX - fCenterX));
+
+ return -fAngle;
+}
+
+double SdwRectangle::CalcDistBetween2Points(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2)
+{
+ return std::hypot(nX1 - nX2, nY1 - nY2);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsdwrect.hxx b/lotuswordpro/source/filter/lwpsdwrect.hxx
new file mode 100644
index 000000000..ec92097f5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsdwrect.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype
+ * Implementation file of SdwRectangle.
+ */
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWRECT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSDWRECT_HXX
+
+#include <config_lgpl.h>
+#include <tools/gen.hxx>
+#include <array>
+
+/**
+ * @brief
+ * SdwRectangle: Not like rectangle in SODC, rectangles in Word Pro are
+ * defined by 4 points. So they can be any posture in the two-dimensional
+ * coordinate system. The class is used to describe such rectangles.
+ * The four corner points must be saved in member variable:m_nRectCorner
+ * one after another. We assume the input order(the same order in .lwp files)
+ * is as below:
+ *
+ * y ^ m_nRectCorner[3] m_nRectCorner[2]
+ * | |--------------------|
+ * | | |
+ * | | |
+ * | |--------------------|
+ * | m_nRectCorner[0] m_nRectCorner[1]
+ * |
+ * |------------------------------------------------------->
+ * (0,0) x
+ *
+ */
+class SdwRectangle
+{
+private:
+ bool m_bRotated;
+
+public:
+ std::array<Point, 4> m_nRectCorner;
+
+public:
+ SdwRectangle();
+
+ SdwRectangle(const Point& rPt0, const Point& rPt1, const Point& rPt2, const Point& rPt3);
+
+public:
+ /*
+ * @short: Get the flag whether if the rectangle has been rotated.
+ * @return: m_bRotated rotation flag.
+ */
+ bool IsRectRotated() const { return m_bRotated; }
+
+ Point GetRectCenter() const;
+
+ tools::Long GetWidth() const;
+
+ tools::Long GetHeight() const;
+
+ tools::Rectangle GetOriginalRect() const;
+
+ double GetRotationAngle() const;
+
+ static double CalcDistBetween2Points(tools::Long nX1, tools::Long nY1, tools::Long nX2,
+ tools::Long nY2);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsection.cxx b/lotuswordpro/source/filter/lwpsection.cxx
new file mode 100644
index 000000000..a4bb2567f
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsection.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwpcolor.hxx>
+#include <lwpatomholder.hxx>
+#include "lwpdlvlist.hxx"
+#include "lwpsection.hxx"
+
+LwpOrderedObject::LwpOrderedObject(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLNFVList(objHdr, pStrm)
+{
+}
+
+/**
+ * @descr: read object information
+ *
+ */
+void LwpOrderedObject::Read()
+{
+ LwpDLNFVList::Read();
+
+ m_ListList.ReadIndexed(m_pObjStrm.get());
+ m_Para.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+LwpSection::LwpSection(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpOrderedObject(objHdr, pStrm)
+ , m_Flags(0)
+{
+}
+
+LwpSection::~LwpSection() {}
+
+/**
+ * @descr: read object information
+ *
+ */
+void LwpSection::Read()
+{
+ LwpOrderedObject::Read();
+ m_Flags = m_pObjStrm->QuickReaduInt16();
+ m_PageLayout.ReadIndexed(m_pObjStrm.get());
+ m_Color.Read(m_pObjStrm.get());
+ m_AtomHolder.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @descr: do nothing
+ *
+ */
+void LwpSection::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpIndexSection::LwpIndexSection(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpSection(objHdr, pStrm)
+ , m_nForm(0)
+ , m_nFlags(0)
+{
+}
+
+LwpIndexSection::~LwpIndexSection() {}
+
+/**
+ * @descr: read object information
+ *
+ */
+void LwpIndexSection::Read()
+{
+ LwpSection::Read();
+ m_TextMarker.Read(m_pObjStrm.get());
+ m_ParentName.Read(m_pObjStrm.get());
+ m_DivisionName.Read(m_pObjStrm.get());
+ m_SectionName.Read(m_pObjStrm.get());
+ m_nForm = m_pObjStrm->QuickReaduInt16();
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_pObjStrm->SkipExtra();
+}
+
+bool LwpIndexSection::IsFormatRunin() const { return (m_nFlags & RUN_IN) != 0; }
+
+bool LwpIndexSection::IsFormatSeparator() const { return (m_nFlags & SEPARATORS) != 0; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsection.hxx b/lotuswordpro/source/filter/lwpsection.hxx
new file mode 100644
index 000000000..4f43aea78
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsection.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSECTION_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSECTION_HXX
+#include "lwppagelayout.hxx"
+
+/**
+ * @brief COrderedObject class in .lwp file
+ *
+ */
+class LwpDLNFVList;
+class LwpOrderedObject : public LwpDLNFVList
+{
+public:
+ LwpOrderedObject(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ LwpObjectID& GetPosition() { return m_Para; }
+ LwpObjectID& GetListList() { return m_ListList; }
+
+private:
+ LwpObjectID m_ListList; //lwplistlist object,
+ LwpObjectID m_Para;
+};
+
+/**
+ * @brief VO_SECTION object in .lwp file
+ *
+ */
+class LwpColor;
+class LwpAtomHolder;
+class LwpSection : public LwpOrderedObject
+{
+public:
+ LwpSection(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpSection() override;
+ inline LwpPageLayout* GetPageLayout();
+ void Parse(IXFStream* pOutputStream) override;
+ OUString const& GetSectionName() const { return m_AtomHolder.str(); }
+
+protected:
+ void Read() override;
+
+private:
+ sal_uInt16 m_Flags;
+ LwpObjectID m_PageLayout;
+ LwpColor m_Color;
+ LwpAtomHolder m_AtomHolder;
+};
+
+/**
+ * @descr Get page layout pointer
+ *
+ */
+inline LwpPageLayout* LwpSection::GetPageLayout()
+{
+ return dynamic_cast<LwpPageLayout*>(m_PageLayout.obj().get());
+}
+
+class LwpIndexSection : public LwpSection
+{
+public:
+ LwpIndexSection(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpIndexSection() override;
+ bool IsFormatRunin() const;
+ bool IsFormatSeparator() const;
+
+protected:
+ void Read() override;
+
+private:
+ enum
+ {
+ SEPARATORS = 0x01,
+ RUN_IN = 0X02,
+ };
+ LwpAtomHolder m_TextMarker;
+ LwpAtomHolder m_ParentName;
+ LwpAtomHolder m_DivisionName;
+ LwpAtomHolder m_SectionName;
+ sal_uInt16 m_nForm;
+ sal_uInt16 m_nFlags;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpshadow.hxx b/lotuswordpro/source/filter/lwpshadow.hxx
new file mode 100644
index 000000000..7e38f78b2
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpshadow.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSHADOW_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSHADOW_HXX
+
+#include <lwpcolor.hxx>
+#include <lwptools.hxx>
+
+class LwpShadow
+{
+public:
+ LwpShadow():m_nDirX(0),m_nDirY(0){}
+public:
+ void Read(LwpObjectStream *pStrm)
+ {
+ m_aColor.Read(pStrm);
+ m_nDirX = pStrm->QuickReadInt32();
+ m_nDirY = pStrm->QuickReadInt32();
+ pStrm->SkipExtra();
+ }
+
+ double GetOffsetX();
+
+ double GetOffsetY();
+
+ const LwpColor& GetColor() const;
+
+private:
+ LwpColor m_aColor;
+ sal_Int32 m_nDirX;
+ sal_Int32 m_nDirY;
+};
+
+inline double LwpShadow::GetOffsetX()
+{
+ // return 0.102;
+ return LwpTools::ConvertFromUnitsToMetric(m_nDirX);
+}
+
+inline double LwpShadow::GetOffsetY()
+{
+ return LwpTools::ConvertFromUnitsToMetric(m_nDirY);
+}
+
+inline const LwpColor& LwpShadow::GetColor() const
+{
+ return m_aColor;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx
new file mode 100644
index 000000000..629b5affc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx
@@ -0,0 +1,452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <memory>
+#include <lwpglobalmgr.hxx>
+#include "lwpsilverbullet.hxx"
+#include "lwpdoc.hxx"
+#include "lwpdivinfo.hxx"
+#include "lwpfribheader.hxx"
+#include <lwpfoundry.hxx>
+#include "lwpstory.hxx"
+#include "lwppara.hxx"
+#include <xfilter/xfliststyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+
+LwpSilverBullet::LwpSilverBullet(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
+ : LwpDLNFVList(objHdr, pStrm)
+ , m_nFlags(0)
+ , m_nUseCount(0)
+ , m_pAtomHolder(new LwpAtomHolder)
+{
+ memset(m_pHideLevels, 0, sizeof(m_pHideLevels));
+}
+
+LwpSilverBullet::~LwpSilverBullet()
+{
+}
+
+void LwpSilverBullet::Read()
+{
+ LwpDLNFVList::Read();
+
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_aStory.ReadIndexed(m_pObjStrm.get());
+
+ sal_uInt16 nNumPos = m_pObjStrm->QuickReaduInt16();
+
+ if (nNumPos > SAL_N_ELEMENTS(m_pResetPositionFlags))
+ throw std::range_error("corrupt SilverBullet");
+
+ for (sal_uInt16 nC = 0; nC < nNumPos; nC++)
+ m_pResetPositionFlags[nC] = m_pObjStrm->QuickReaduInt8();
+
+ if (nNumPos < SAL_N_ELEMENTS(m_pResetPositionFlags))
+ std::fill(m_pResetPositionFlags + nNumPos, m_pResetPositionFlags + SAL_N_ELEMENTS(m_pResetPositionFlags), 0);
+
+ m_nUseCount = m_pObjStrm->QuickReaduInt32();
+
+ m_pAtomHolder->Read(m_pObjStrm.get());
+}
+
+/**
+ * @short: Register bullet or numbering style-list and store the returned
+ * name from XFStyleManager.
+ * @descr:
+ */
+void LwpSilverBullet::RegisterStyle()
+{
+ std::unique_ptr<XFListStyle> xListStyle(new XFListStyle());
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+
+ GetBulletPara();
+
+ if (IsBulletOrdered() && HasName())
+ {
+ //todo: find the flag in the file
+ bool bCumulative = false;
+
+ for (sal_uInt8 nPos = 1; nPos < 10; nPos++)
+ {
+ ParaNumbering aParaNumbering;
+ //get numbering format according to the position.
+ m_xBulletPara->GetParaNumber(nPos, &aParaNumbering);
+ LwpFribParaNumber* pParaNumber = aParaNumbering.pParaNumber;
+ if (pParaNumber)
+ {
+ if (pParaNumber->GetStyleID() != NUMCHAR_other)
+ {
+ m_pHideLevels[nPos] = aParaNumbering.nNumLevel;
+ sal_uInt16 nDisplayLevel = GetDisplayLevel(nPos);
+ bCumulative = (nDisplayLevel > 1);
+ OUString aPrefix = GetAdditionalName(nPos);
+
+ XFNumFmt aFmt;
+ if (!bCumulative && aParaNumbering.pPrefix)
+ {
+ aFmt.SetPrefix(aPrefix + aParaNumbering.pPrefix->GetText());
+ }
+
+ aFmt.SetFormat(GetNumCharByStyleID(pParaNumber));
+
+ if (aParaNumbering.pSuffix)
+ {
+ aFmt.SetSuffix(aParaNumbering.pSuffix->GetText());
+ }
+
+ //set numbering format into the style-list.
+ xListStyle->SetListNumber(nPos, aFmt, pParaNumber->GetStart()+1);
+
+ if (bCumulative && nPos > 1)
+ {
+ xListStyle->SetDisplayLevel(nPos, nDisplayLevel);
+ }
+
+ }
+ else
+ {
+ OUString aPrefix, aSuffix;
+ if (aParaNumbering.pPrefix)
+ {
+ aPrefix = aParaNumbering.pPrefix->GetText();
+ }
+ if (aParaNumbering.pSuffix)
+ {
+ aSuffix = aParaNumbering.pSuffix->GetText();
+ }
+
+ xListStyle->SetListBullet(nPos, GetNumCharByStyleID(pParaNumber),
+ "Times New Roman", aPrefix, aSuffix);
+ }
+
+ xListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
+ aParaNumbering.clear();
+ }
+ }
+ }
+
+ //add style-list to style manager.
+ m_strStyleName = pXFStyleManager->AddStyle(std::move(xListStyle)).m_pStyle->GetStyleName();
+}
+
+/**
+ * @short: Get the font name of the bullet.
+ * @descr:
+ * @return: Font name of the bullet.
+ */
+OUString LwpSilverBullet::GetBulletFontName()
+{
+ //foundry has been set?
+ if (!m_pFoundry)
+ {
+ return OUString();
+ }
+
+ LwpFontManager& rFontMgr = m_pFoundry->GetFontManager();
+
+ sal_uInt32 nBulletFontID = m_xBulletPara->GetBulletFontID();
+ sal_uInt16 nFinalFont = static_cast<sal_uInt16>((nBulletFontID >> 16) & 0xFFFF);
+
+ //final fontid is valid?
+ if (nFinalFont > 255 || nFinalFont == 0)
+ {
+ return OUString();
+ }
+
+ //get font name from font manager.
+ OUString aFontName = rFontMgr.GetNameByID(nBulletFontID);
+
+ return aFontName;
+}
+/**
+ * @short: Get bullet character of the bullet vo_para.
+ * @descr:
+ * @return: An UChar32 bullet character.
+ */
+OUString const & LwpSilverBullet::GetBulletChar() const
+{
+ return m_xBulletPara->GetBulletChar();
+}
+
+/**
+ * @short: Get the LwpPara object through story id.
+ */
+LwpPara* LwpSilverBullet::GetBulletPara()
+{
+ if (!m_xBulletPara.is())
+ {
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_aStory.obj(VO_STORY).get());
+ if (!pStory)
+ {
+ return nullptr;
+ }
+
+ m_xBulletPara.set(dynamic_cast<LwpPara*>(pStory->GetFirstPara().obj(VO_PARA).get()));
+ }
+
+ return m_xBulletPara.get();
+}
+
+/**
+ * @short: Get numbering character of the bullet vo_para.
+ * @descr:
+ * @param: pParaNumber a pointer to the structure LwpFribParaNumber which
+ * includes numbering prefix, format and suffix.
+ * @return: An OUString object which store the numbering character.
+ */
+OUString LwpSilverBullet::GetNumCharByStyleID(LwpFribParaNumber const * pParaNumber)
+{
+ if (!pParaNumber)
+ {
+ assert(false);
+ return OUString();
+ }
+
+ OUString strNumChar("1");
+ sal_uInt16 nStyleID = pParaNumber->GetStyleID();
+
+ switch (nStyleID)
+ {
+ case NUMCHAR_1:
+ case NUMCHAR_01:
+ case NUMCHAR_Chinese4:
+ strNumChar = "1";
+ break;
+ case NUMCHAR_A :
+ strNumChar = "A";
+ break;
+ case NUMCHAR_a:
+ strNumChar = "a";
+ break;
+ case NUMCHAR_I:
+ strNumChar = "I";
+ break;
+ case NUMCHAR_i:
+ strNumChar = "i";
+ break;
+ case NUMCHAR_other:
+ strNumChar = OUString(sal_Unicode(pParaNumber->GetNumberChar()));
+ break;
+ case NUMCHAR_Chinese1:
+ {
+ static constexpr OUStringLiteral sBuf = u"\u58f9\u002c\u0020\u8d30, \u53c1, ...";
+ strNumChar = OUString(sBuf);
+ }
+ break;
+ case NUMCHAR_Chinese2:
+ {
+ static constexpr OUStringLiteral sBuf = u"\u4e00, \u4e8c, \u4e09, ...";
+ strNumChar = OUString(sBuf);
+ }
+ break;
+ case NUMCHAR_Chinese3:
+ {
+ static constexpr OUStringLiteral sBuf = u"\u7532, \u4e59, \u4e19, ...";
+ strNumChar = OUString(sBuf);
+ }
+ break;
+ case NUMCHAR_none:
+ strNumChar.clear();
+ break;
+ default:
+ break;
+ }//mod end
+ return strNumChar;
+}
+
+/**
+ * @short: To judge the silverbullet list is ordered or not.
+ * @descr:
+ * @return: sal_True if list is ordered, sal_False if list is unordered.
+ */
+bool LwpSilverBullet::IsBulletOrdered()
+{
+ if (!m_xBulletPara.is())
+ return false;
+
+ LwpFribPtr& rFribs = m_xBulletPara->GetFribs();
+
+ return (rFribs.HasFrib(FRIB_TAG_PARANUMBER) != nullptr);
+}
+
+/**
+ * @short: Calculate the displaylevel according to the position and hidelevels.
+ * @descr:
+ * @param: nPos position of the numbering.
+ * @return: displaylevel of the position passed in.
+ */
+sal_uInt16 LwpSilverBullet::GetDisplayLevel(sal_uInt8 nPos)
+{
+ if (nPos > 1)
+ {
+ sal_uInt16 nHideBit = (1 << nPos);
+ for (sal_uInt8 nC = nPos-1; nC > 0; nC--)
+ {
+ sal_uInt16 nAttrMask = ~m_pHideLevels[nC];
+ if (!(nAttrMask & nHideBit))
+ {
+ return static_cast<sal_uInt16>(nPos - nC);
+ }
+ }
+ }
+
+ return static_cast<sal_uInt16>(nPos);
+}
+
+/**
+ * @descr: Get the additional information, "Division name" or "Section Name" from document
+ * variable frib according to numbering position. Whether we should add a
+ * Division/Section name or not is determined by the hidelevels of the frib.
+ * @param: nPos position of the numbering.
+ * @return: Division or Section name.
+ */
+OUString LwpSilverBullet::GetAdditionalName(sal_uInt8 nPos)
+{
+ OUString aRet;
+ sal_uInt16 nHideBit = (1 << nPos);
+ bool bDivisionName = false;
+ bool bSectionName = false;
+
+ LwpFrib* pParaFrib = m_xBulletPara->GetFribs().GetFribs();
+ if (!pParaFrib)
+ {
+ return OUString();
+ }
+
+ while (pParaFrib)
+ {
+ if (pParaFrib->GetType() == FRIB_TAG_DOCVAR)
+ {
+ ModifierInfo* pMoInfo = pParaFrib->GetModifiers();
+ if (!pMoInfo)
+ {
+ return OUString();
+ }
+ sal_uInt16 nHideLevels = pMoInfo->aTxtAttrOverride.GetHideLevels();
+ sal_uInt16 nType = static_cast<LwpFribDocVar*>(pParaFrib)->GetType();
+
+ if (~nHideLevels & nHideBit)
+ {
+ if (nType == 0x000D)
+ {
+ bDivisionName = true;
+ }
+ else if (nType == 0x000E)
+ {
+ bSectionName= true;
+ }
+ }
+ }
+ pParaFrib = pParaFrib->GetNext();
+ }
+
+ if (bDivisionName)
+ {
+ aRet += GetDivisionName();
+ }
+ if (bSectionName)
+ {
+ aRet += GetSectionName();
+ }
+
+ return aRet;
+}
+
+OUString LwpSilverBullet::GetDivisionName()
+{
+ OUString aRet;
+
+ if (!m_pFoundry)
+ {
+ return aRet;
+ }
+
+ LwpDocument* pDoc = m_pFoundry->GetDocument();
+ if (pDoc)
+ {
+ LwpObjectID& rID = pDoc->GetDivInfoID();
+ if (!rID.IsNull())
+ {
+ LwpDivInfo *pInfo = dynamic_cast<LwpDivInfo*>(rID.obj(VO_DIVISIONINFO).get());
+ if (pInfo)
+ aRet = pInfo->GetDivName();
+ }
+ }
+
+ return aRet;
+}
+
+OUString LwpSilverBullet::GetSectionName() const
+{
+ LwpStory* pStory = dynamic_cast<LwpStory*>(m_aStory.obj(VO_STORY).get());
+ if (!pStory)
+ {
+ return OUString();
+ }
+
+ return pStory->GetSectionName();
+}
+
+bool LwpSilverBullet::HasName()
+{
+ LwpAtomHolder& rName = GetName();
+ return (!rName.str().isEmpty());
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsilverbullet.hxx b/lotuswordpro/source/filter/lwpsilverbullet.hxx
new file mode 100644
index 000000000..8c68a960e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsilverbullet.hxx
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSILVERBULLET_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSILVERBULLET_HXX
+
+#include <config_lgpl.h>
+#include <memory>
+#include "lwpdlvlist.hxx"
+#include <lwpobjid.hxx>
+#include <lwpatomholder.hxx>
+
+const sal_uInt16 MAXNUMBERPOSITIONS = 10; //max number of positions
+const sal_uInt16 NUMCHAR_none = 0x00; //none of numberchar
+const sal_uInt16 NUMCHAR_1 = 0x01; //index for numberchar "1"
+const sal_uInt16 NUMCHAR_A = 0x02; //index for numberchar "A"
+const sal_uInt16 NUMCHAR_a = 0x03; //index for numberchar "a"
+const sal_uInt16 NUMCHAR_I = 0x04; //index for numberchar "I"
+const sal_uInt16 NUMCHAR_i = 0x05; //index for numberchar "i"
+const sal_uInt16 NUMCHAR_other = 0x06; //index for numberchar "other"
+const sal_uInt16 NUMCHAR_01 = 0x0B; //index for numberchar "01"
+
+const sal_uInt16 NUMCHAR_Chinese1 = 0x09; //index for numberchar "Ò¼"
+const sal_uInt16 NUMCHAR_Chinese2 = 0x08; //index for numberchar "Ò»"
+const sal_uInt16 NUMCHAR_Chinese3 = 0x0A; //index for numberchar "¼×"
+const sal_uInt16 NUMCHAR_Chinese4 = 0x13; //index for numberchar "01" in chinese version
+
+class LwpAtomHolder;
+class LwpPara;
+class LwpFribParaNumber;
+
+class LwpSilverBullet : public LwpDLNFVList
+{
+public:
+ LwpSilverBullet(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+
+ virtual ~LwpSilverBullet() override;
+
+ virtual void RegisterStyle() override;
+
+ void Read() override;
+
+ bool IsBulletOrdered();
+
+ OUString GetBulletFontName();
+
+ const OUString& GetBulletStyleName() const;
+
+ OUString const& GetBulletChar() const;
+
+ static OUString GetPrefix() { return OUString(); }
+
+ static OUString GetSuffix() { return OUString(); }
+
+ bool HasName();
+
+ static OUString GetNumCharByStyleID(LwpFribParaNumber const* pParaNumber);
+
+ inline bool IsLesserLevel(sal_uInt16 nPos);
+
+ LwpPara* GetBulletPara();
+
+ sal_uInt16 GetDisplayLevel(sal_uInt8 nPos);
+
+ OUString GetAdditionalName(sal_uInt8 nPos);
+
+ OUString GetDivisionName();
+
+ OUString GetSectionName() const;
+
+private:
+ sal_uInt16 m_nFlags;
+ LwpObjectID m_aStory;
+ sal_uInt8 m_pResetPositionFlags[MAXNUMBERPOSITIONS];
+ sal_uInt32 m_nUseCount;
+ std::unique_ptr<LwpAtomHolder> m_pAtomHolder;
+
+ rtl::Reference<LwpPara> m_xBulletPara;
+ OUString m_strStyleName;
+ sal_uInt16 m_pHideLevels[10];
+
+private:
+ enum // For m_pResetPositionFlags
+ {
+ LESSERLEVEL = 0x01,
+ LESSERSPECIFIC = 0x02,
+ NEWDIVISION = 0x04,
+ NEWSECTION = 0x08,
+ CUMULATIVE = 0x10
+ };
+};
+inline const OUString& LwpSilverBullet::GetBulletStyleName() const { return m_strStyleName; }
+inline bool LwpSilverBullet::IsLesserLevel(sal_uInt16 nPos)
+{
+ if (nPos < std::size(m_pResetPositionFlags))
+ return ((m_pResetPositionFlags[nPos] & LESSERLEVEL) != 0);
+ return false;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsortopt.cxx b/lotuswordpro/source/filter/lwpsortopt.cxx
new file mode 100644
index 000000000..951439e47
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsortopt.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpsortopt.hxx"
+
+void LwpSortKey::Read(LwpObjectStream* pStrm)
+{
+ m_nField = pStrm->QuickReaduInt16();
+ m_nFlag = pStrm->QuickReaduInt16();
+ m_nWord = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+LwpSortOption::LwpSortOption(LwpObjectStream* pStrm) { Read(pStrm); }
+/**
+ * @descr Read sort option in VO_DOCUMENT from object stream
+ **/
+void LwpSortOption::Read(LwpObjectStream* pStrm)
+{
+ m_nCount = pStrm->QuickReaduInt16();
+ m_nFlags = pStrm->QuickReaduInt16();
+ m_nText = pStrm->QuickReaduInt8();
+ for (LwpSortKey& key : m_Keys)
+ {
+ key.Read(pStrm);
+ }
+ pStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsortopt.hxx b/lotuswordpro/source/filter/lwpsortopt.hxx
new file mode 100644
index 000000000..54fcba15d
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsortopt.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSORTOPT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSORTOPT_HXX
+
+#include <config_lgpl.h>
+
+#include <lwpobjstrm.hxx>
+
+/**
+ * @brief sort key class for LwpSortOption
+*/
+class LwpSortKey
+{
+private:
+ sal_uInt16 m_nField;
+ sal_uInt16 m_nFlag;
+ sal_uInt16 m_nWord;
+
+public:
+ void Read(LwpObjectStream* pStrm);
+};
+/**
+ * @brief sort options in VO_DOCUMENT
+ * only for read, not parsed now
+*/
+class LwpSortOption
+{
+public:
+ explicit LwpSortOption(LwpObjectStream* pStrm);
+
+public:
+ void Read(LwpObjectStream* pStrm);
+
+private:
+ LwpSortKey m_Keys[3];
+ sal_uInt16 m_nCount;
+ sal_uInt16 m_nFlags;
+ sal_uInt8 m_nText;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
new file mode 100644
index 000000000..acc0beebc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * LwpStory:
+ 1. Word Pro object for paragraph list;
+ 2. the content of layout object
+ ************************************************************************/
+
+#include <lwpglobalmgr.hxx>
+#include "lwpstory.hxx"
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include "lwppara.hxx"
+#include <lwpobjfactory.hxx>
+#include "lwppagelayout.hxx"
+#include <rtl/ustrbuf.hxx>
+
+#include <algorithm>
+#include <o3tl/sorted_vector.hxx>
+
+
+LwpStory::LwpStory(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+ , m_bPMModified(false)
+ , m_pCurrentLayout(nullptr)
+ , m_pTabLayout(nullptr)
+ , m_bDropcap(false)
+ , m_pHyperlinkMgr(new LwpHyperlinkMgr)
+{
+}
+
+LwpStory::~LwpStory()
+{
+}
+
+void LwpStory::Read()
+{
+ LwpContent::Read();
+ m_ParaList.Read(m_pObjStrm.get());
+ m_FirstParaStyle.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+/**************************************************************************
+ * @descr: Convert all the contents in current story
+**************************************************************************/
+void LwpStory::XFConvert(XFContentContainer* pCont)
+{
+ //process frame which anchor frame
+ XFConvertFrameInFrame(pCont);
+ //process para list
+ XFContentContainer* pParaCont = pCont;
+ rtl::Reference<LwpPara> xPara(dynamic_cast<LwpPara*>(GetFirstPara().obj().get()));
+ o3tl::sorted_vector<LwpPara*> aSeen;
+ while (xPara.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xPara.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ xPara->SetFoundry(m_pFoundry);
+ xPara->XFConvert(pParaCont);
+
+ //Get the xfcontainer for the next para
+ pParaCont = xPara->GetXFContainer();
+ rtl::Reference<LwpPara> xNext(dynamic_cast<LwpPara*>(xPara->GetNext().obj().get()));
+ xPara = xNext;
+ }
+
+ //process frame which anchor is to cell after converter all the para
+ XFConvertFrameInCell(pCont);
+ XFConvertFrameInHeaderFooter(pCont);
+
+ //Release Lwp Objects
+ rtl::Reference<LwpPara> xCur(dynamic_cast<LwpPara*>(GetFirstPara().obj().get()));
+ rtl::Reference<LwpPara> xNext;
+ while (xCur.is())
+ {
+ xNext.set(dynamic_cast<LwpPara*>(xCur->GetNext().obj().get()));
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ LwpObjectFactory* pObjMgr = pGlobal->GetLwpObjFactory();
+ pObjMgr->ReleaseObject(xCur->GetObjectID());
+ xCur = xNext;
+ }
+}
+
+void LwpStory::RegisterStyle()
+{
+ rtl::Reference<LwpPara> xPara(dynamic_cast<LwpPara*>(GetFirstPara().obj().get()));
+ o3tl::sorted_vector<LwpPara*> aSeen;
+ while (xPara.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xPara.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in register style");
+ xPara->SetFoundry(m_pFoundry);
+ xPara->DoRegisterStyle();
+ xPara.set(dynamic_cast<LwpPara*>(xPara->GetNext().obj().get()));
+ }
+}
+
+void LwpStory::Parse(IXFStream* pOutputStream)
+{
+ m_xXFContainer.set(new XFContentContainer);
+ XFConvert(m_xXFContainer.get());
+ m_xXFContainer->ToXml(pOutputStream);
+ m_xXFContainer.clear();
+}
+
+/**************************************************************************
+ * @descr: Set current page layout. If pPageLayout is a mirror page layout,
+ use odd child page layout as current page layout.
+**************************************************************************/
+void LwpStory::SetCurrentLayout(LwpPageLayout *pPageLayout)
+{
+ LwpPageLayout* pLayout = pPageLayout->GetOddChildLayout();
+ if(pLayout)
+ {
+ m_pCurrentLayout = pLayout;
+ m_pTabLayout = pLayout;
+ }
+ else
+ {
+ m_pCurrentLayout = pPageLayout;
+ m_pTabLayout = pPageLayout;
+ }
+ m_bPMModified = true;
+}
+
+/**************************************************************************
+ * @descr: Get the next page layout relative to m_pCurrentLayout
+**************************************************************************/
+LwpPageLayout* LwpStory::GetNextPageLayout()
+{
+ std::vector<LwpPageLayout*>::iterator it = std::find(m_LayoutList.begin(), m_LayoutList.end(), m_pCurrentLayout);
+ if (it != m_LayoutList.end() && (it+1) != m_LayoutList.end())
+ return *(it+1);
+ return nullptr;
+}
+/**************************************************************************
+ * @descr: Sort the pagelayout according to their position
+**************************************************************************/
+void LwpStory::SortPageLayout()
+{
+ //Get all the pagelayout and store in list
+ std::vector<LwpPageLayout*> aLayoutList;
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ while (xLayout)
+ {
+ LwpPageLayout *pLayout = xLayout->IsPage()
+ ? dynamic_cast<LwpPageLayout*>(xLayout.get())
+ : nullptr;
+ if (pLayout)
+ {
+ LwpLayout::UseWhenType eSectionType = pLayout->GetUseWhenType();
+ //for mirror page, the child is pagelayout
+ rtl::Reference<LwpVirtualLayout> xParent = xLayout->GetParentLayout();
+ if(eSectionType != LwpLayout::StartWithinColume && xParent.is() && !xParent->IsPage())
+ {
+ aLayoutList.push_back(pLayout);
+ }
+ }
+ xLayout = GetLayout(xLayout.get());
+ }
+ // sort the pagelayout according to their position
+ if (!aLayoutList.empty())
+ {
+ for( std::vector<LwpPageLayout*>::iterator aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt)
+ {
+ for( std::vector<LwpPageLayout*>::iterator bIt = aIt +1; bIt != aLayoutList.end(); ++bIt )
+ {
+ if(!(**aIt < **bIt))
+ {
+ std::swap(*aIt, *bIt);
+ }
+ }
+ }
+ }
+
+ //put all the sorted layouts into list
+ m_LayoutList.clear();
+
+ for (auto const& layout : aLayoutList)
+ {
+ m_LayoutList.push_back(layout);
+ }
+}
+
+/**************************************************************************
+ * @descr: whether need create a new section and reset column in current page layout
+**************************************************************************/
+bool LwpStory::IsNeedSection()
+{
+ bool bNewSection = false;
+ if(m_pCurrentLayout)
+ {
+ if(m_pCurrentLayout->HasColumns())
+ {
+ //get the following pagelayout and its type
+ bool bColumns = true;
+ LwpPageLayout* pNextLayout = GetNextPageLayout();
+ if(pNextLayout)
+ {
+ //get layout type
+ LwpLayout::UseWhenType eWhenType = pNextLayout->GetUseWhenType();
+ switch(eWhenType)
+ {
+ case LwpLayout::StartWithinColume://not support now
+ case LwpLayout::StartWithinPage:
+ {
+ bColumns =false;
+ bNewSection = true;
+ break;
+ }
+ case LwpLayout::StartOnNextPage:
+ case LwpLayout::StartOnOddPage://not support now
+ case LwpLayout::StartOnEvenPage://not support now
+ {
+ bColumns =true;
+ bNewSection = false;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ //if bColumns is true, the page layout doesn't need columns, set the xfcolumns to NULL in page master
+ if(!bColumns)
+ {
+ m_pCurrentLayout->ResetXFColumns();
+ }
+ }
+ SetPMModified(false);
+ }
+ return bNewSection;
+}
+/**************************************************************************
+ * @descr: process frame which anchor type is to cell
+**************************************************************************/
+void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont)
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ while (xLayout.is())
+ {
+ rtl::Reference<LwpVirtualLayout> xFrameLayout(dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get()));
+ while (xFrameLayout.is())
+ {
+ if (xFrameLayout->IsAnchorCell() && xFrameLayout->HasContent())
+ {
+ //get the first xfpara
+ rtl::Reference<XFContent> first(
+ pCont->FindFirstContent(enumXFContentPara));
+ XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
+ if(pXFFirtPara)
+ xFrameLayout->DoXFConvert(pXFFirtPara);
+ }
+ xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
+ }
+ xLayout = GetLayout(xLayout.get());
+ }
+}
+
+/**************************************************************************
+ * @descr: process frame which anchor type is to page
+**************************************************************************/
+void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont)
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ while (xLayout.is())
+ {
+ rtl::Reference<LwpVirtualLayout> xFrameLayout(dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xFrameLayout.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xFrameLayout.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if( xFrameLayout->IsAnchorPage()
+ && (xFrameLayout->IsFrame()
+ || xFrameLayout->IsSuperTable()
+ || xFrameLayout->IsGroupHead()) )
+ {
+ xFrameLayout->DoXFConvert(pCont);
+ }
+ xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
+ }
+ xLayout = GetLayout(xLayout.get());
+ }
+}
+/**************************************************************************
+ * @descr: process frame which anchor type is to frame
+**************************************************************************/
+void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ while (xLayout)
+ {
+ rtl::Reference<LwpVirtualLayout> xFrameLayout(dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
+ while (xFrameLayout.is())
+ {
+ bool bAlreadySeen = !aSeen.insert(xFrameLayout.get()).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in register style");
+ if (xFrameLayout->IsAnchorFrame())
+ {
+ xFrameLayout->DoXFConvert(pCont);
+ }
+ xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
+ }
+ xLayout = GetLayout(xLayout.get());
+ }
+}
+/**************************************************************************
+ * @descr: process frame which anchor type is to page and the frame is contained by header or footer
+**************************************************************************/
+void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont)
+{
+ rtl::Reference<LwpVirtualLayout> xLayout(GetLayout(nullptr));
+ while (xLayout.is())
+ {
+ rtl::Reference<LwpVirtualLayout> xFrameLayout(dynamic_cast<LwpVirtualLayout*>(xLayout->GetChildHead().obj().get()));
+ while (xFrameLayout.is())
+ {
+ if (xFrameLayout->IsAnchorPage() && (xLayout->IsHeader() || xLayout->IsFooter()))
+ {
+ //The frame must be included by <text:p>
+ rtl::Reference<XFContent> first(
+ pCont->FindFirstContent(enumXFContentPara));
+ XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
+ if(pXFFirtPara)
+ xFrameLayout->DoXFConvert(pXFFirtPara);
+ }
+ xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
+ }
+ xLayout = GetLayout(xLayout.get());
+ }
+}
+
+void LwpStory::AddXFContent(XFContent* pContent)
+{
+ if (m_xXFContainer)
+ m_xXFContainer->Add(pContent);
+}
+
+XFContentContainer* LwpStory::GetXFContent()
+{
+ return m_xXFContainer.get();
+}
+
+LwpPara* LwpStory::GetLastParaOfPreviousStory()
+{
+ rtl::Reference<LwpVirtualLayout> xVLayout(GetLayout(nullptr));
+ if (xVLayout.is())
+ {
+ return xVLayout->GetLastParaOfPreviousStory();
+ }
+
+ return nullptr;
+}
+/**************************************************************************
+ * @descr: get text from story
+**************************************************************************/
+OUString LwpStory::GetContentText(bool bAllText)
+{
+ if (bAllText)//convert all text fribs
+ {
+ OUStringBuffer sText;
+ //process para list
+ LwpPara* pPara = dynamic_cast<LwpPara*>(GetFirstPara().obj().get());
+ while (pPara)
+ {
+ pPara->SetFoundry(m_pFoundry);
+ sText.append(pPara->GetContentText(true));
+ pPara = dynamic_cast<LwpPara*>(pPara->GetNext().obj().get());
+ }
+ return sText.makeStringAndClear();
+ }
+ else //only the first text frib
+ {
+ rtl::Reference<LwpObject> pObj = GetFirstPara().obj();
+ if(pObj.is())
+ {
+ LwpPara* pPara = dynamic_cast<LwpPara*>(pObj.get());
+ if (!pPara || pPara->GetNext().obj() != nullptr)
+ return OUString();
+ pPara->SetFoundry(m_pFoundry);
+ return pPara->GetContentText();
+ }
+ return OUString();
+ }
+
+}
+OUString LwpStory::RegisterFirstFribStyle()
+{
+ LwpPara* pPara = dynamic_cast<LwpPara*>(GetFirstPara().obj().get());
+ if (!pPara)
+ return OUString();
+ pPara->SetFoundry(m_pFoundry);
+ LwpFribPtr& rFribs = pPara->GetFribs();
+ LwpFrib* pFirstFrib = rFribs.GetFribs();
+ pFirstFrib->RegisterStyle(m_pFoundry);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFTextStyle* pBaseStyle = pXFStyleManager->FindTextStyle(pFirstFrib->GetStyleName());
+ if (pBaseStyle == nullptr)
+ return OUString();
+ std::unique_ptr<XFTextStyle> pStyle(new XFTextStyle);
+ *pStyle = *pBaseStyle;
+ OUString sName = "Ruby" + pFirstFrib->GetStyleName();
+ pStyle->SetStyleName(sName);
+ pXFStyleManager->AddStyle(std::move(pStyle));
+ return sName;
+}
+
+bool LwpStory::IsBullStyleUsedBefore(const OUString& rStyleName, sal_uInt8 nPos)
+{
+ return std::any_of(m_vBulletStyleNameList.rbegin(), m_vBulletStyleNameList.rend(),
+ [&rStyleName, &nPos](const NamePosPair& rPair) { return rPair.first == rStyleName && rPair.second == nPos; });
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpstory.hxx b/lotuswordpro/source/filter/lwpstory.hxx
new file mode 100644
index 000000000..809cc2bbb
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpstory.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * LwpStory:
+ 1. Word Pro object for paragraph list;
+ 2. the content of layout object
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSTORY_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSTORY_HXX
+
+#include <memory>
+#include "lwpcontent.hxx"
+#include "lwphyperlinkmgr.hxx"
+
+class LwpPageLayout;
+class LwpStory final : public LwpContent
+{
+public:
+ LwpStory(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpStory() override;
+
+private:
+ //File format members:
+ LwpDLVListHeadTail m_ParaList;
+ LwpObjectID m_FirstParaStyle;
+
+ // for bullet , 05/23/2005
+ typedef std::pair<OUString, sal_uInt8> NamePosPair;
+ std::vector<NamePosPair> m_vBulletStyleNameList;
+
+ // , 02/16/2005
+ bool m_bPMModified;
+ LwpPageLayout* m_pCurrentLayout; //for register page layout style
+ std::vector<LwpPageLayout*> m_LayoutList;
+ LwpLayout* m_pTabLayout; //for register tab style
+
+ bool m_bDropcap;
+ std::unique_ptr<LwpHyperlinkMgr> m_pHyperlinkMgr;
+ OUString m_CurrSectionName;
+
+ rtl::Reference<XFContentContainer> m_xXFContainer;
+
+ void Read() override;
+ void XFConvertFrameInCell(XFContentContainer* pCont);
+ void XFConvertFrameInFrame(XFContentContainer* pCont);
+ void XFConvertFrameInHeaderFooter(XFContentContainer* pCont);
+
+public:
+ void RegisterStyle() override;
+ void Parse(IXFStream* pOutputStream) override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ void XFConvertFrameInPage(XFContentContainer* pCont);
+ inline LwpObjectID& GetFirstPara();
+ inline LwpObjectID& GetLastPara();
+ XFContentContainer* GetXFContent();
+ void AddXFContent(XFContent* pContent);
+
+ bool GetDropcapFlag() const { return m_bDropcap; }
+ LwpPageLayout* GetCurrentLayout() { return m_pCurrentLayout; }
+ inline LwpMiddleLayout* GetTabLayout(); //for register tab style
+ const OUString& GetSectionName() const { return m_CurrSectionName; }
+ LwpHyperlinkMgr* GetHyperlinkMgr() { return m_pHyperlinkMgr.get(); }
+
+ bool IsPMModified() const { return m_bPMModified; }
+ inline void SetPMModified(bool bPMModified);
+ inline void SetDropcapFlag(bool bFlag);
+ inline void SetTabLayout(LwpLayout* pLayout);
+ inline void SetSectionName(const OUString& StyleName);
+
+ void SetCurrentLayout(LwpPageLayout* pPageLayout);
+ LwpPageLayout* GetNextPageLayout();
+ bool IsNeedSection();
+ void SortPageLayout();
+
+ LwpPara* GetLastParaOfPreviousStory();
+
+ OUString GetContentText(bool bAllText = false);
+ inline void AddBullStyleName2List(const OUString& rStyleName, sal_uInt8 nPos);
+ bool IsBullStyleUsedBefore(const OUString& rStyleName, sal_uInt8 nPos);
+
+ OUString RegisterFirstFribStyle();
+};
+
+LwpObjectID& LwpStory::GetFirstPara() { return m_ParaList.GetHead(); }
+LwpObjectID& LwpStory::GetLastPara() { return m_ParaList.GetTail(); }
+LwpMiddleLayout* LwpStory::GetTabLayout()
+{
+ if (m_pTabLayout)
+ return m_pTabLayout;
+ return dynamic_cast<LwpMiddleLayout*>(GetLayout(nullptr).get());
+}
+void LwpStory::SetPMModified(bool bPMModified) { m_bPMModified = bPMModified; }
+void LwpStory::SetDropcapFlag(bool bFlag) { m_bDropcap = bFlag; }
+void LwpStory::SetTabLayout(LwpLayout* pLayout) { m_pTabLayout = pLayout; }
+void LwpStory::SetSectionName(const OUString& StyleName) { m_CurrSectionName = StyleName; }
+inline void LwpStory::AddBullStyleName2List(const OUString& rStyleName, sal_uInt8 nPos)
+{
+ m_vBulletStyleNameList.push_back(std::make_pair(rStyleName, nPos));
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpstyledef.hxx b/lotuswordpro/source/filter/lwpstyledef.hxx
new file mode 100644
index 000000000..bbc042415
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpstyledef.hxx
@@ -0,0 +1,258 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSTYLEDEF_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPSTYLEDEF_HXX
+
+#define INVALID_ATTR_ID 0
+#define EXTERNAL_ID 0x8000
+#define EXTERNAL_MASK 0x7FFF
+#define MAX_DESIGNERBORDERS 18
+
+#define BORDER_SOLID 1
+#define BORDER_SDASH 2
+#define BORDER_LDASH 3
+#define BORDER_WAVY 4
+#define BORDER_THKWAVY 5
+#define BORDER_LSDASH 6
+#define BORDER_LSSDASH 7
+#define BORDER_DOT 8
+#define BORDER_CIRCLE 9
+#define BORDER_DBLWAVY 10
+#define BORDER_DBLTHKWAVY 11
+#define BORDER_STAR 12
+#define BORDER_ROPE 13
+#define BORDER_DECO1 14
+#define BORDER_DECO2 15
+#define BORDER_RAIN 16
+#define BORDER_PIN 17
+#define BORDER_ROSE 18
+#define BORDER_SUNF 19
+#define BORDER_DECO3 20
+#define BORDER_WARNING 21
+// SPACE 22
+#define BORDER_GIRDER 23
+
+// User defined bitmap borders (200 - 400)
+
+// scalable lines
+#define BGRP_SOLID 20
+#define BGRP_DOUBLE_ONE 21
+#define BGRP_DOUBLE_TWO 22
+#define BGRP_121 23
+#define BGRP_31 24
+#define BGRP_13 25
+#define BGRP_WAVY 26
+#define BGRP_DBLWAVY 27
+#define BGRP_THICK_WAVY 28
+#define BGRP_THICK_DBLWAVY 29
+#define BGRP_SDASH 30
+#define BGRP_LDASH 31
+#define BGRP_LDASH_SDASH 32
+#define BGRP_LDASH_SDASH_SDASH 33
+#define BGRP_BUTTONUP 34
+#define BGRP_BUTTONDOWN 35
+#define BGRP_13SPACE 36
+#define BGRP_31SPACE 37
+#define BGRP_DIAGONAL 38
+#define BGRP_TARO 39
+#define BGRP_DOT 40
+#define BGRP_CIRCLE 41
+#define BGRP_STAR 42
+#define BGRP_ROPE 43
+#define BGRP_DECO1 44
+#define BGRP_DECO2 45
+#define BGRP_RAIN 46
+#define BGRP_PIN 47
+#define BGRP_ROSE 48
+#define BGRP_SUNF 49
+#define BGRP_DECO3 50
+#define BGRP_WARNING 51
+//SPACE 52
+#define BGRP_GIRDER 53
+
+#define UNIT_4_96 ((UNIT)196608L) //INCHES(4/96)
+#define UNIT_13_96 ((UNIT)638976L) //INCHES(13/96)
+#define UNIT_14_96 ((UNIT)688128L) //INCHES(14/96)
+#define UNIT_15_96 ((UNIT)737280L) //INCHES(15/96)
+#define UNIT_17_96 ((UNIT)835584L) //INCHES(17/96)
+#define UNIT_18_96 ((UNIT)884736L) //INCHES(18/96)
+#define UNIT_19_96 ((UNIT)933888L) //INCHES(19/96)
+#define UNIT_20_96 ((UNIT)983040L) //INCHES(20/96)
+#define UNIT_21_96 ((UNIT)1032192L) //INCHES(21/96)
+#define UNIT_22_96 ((UNIT)1081344L) //INCHES(22/96)
+#define UNIT_25_96 ((UNIT)1228800L) //INCHES(25/96)
+#define UNIT_28_96 ((UNIT)1376256L) //INCHES(28/96)
+#define UNIT_34_96 ((UNIT)1671108L) //INCHES(34/96)
+#define UNIT_42_96 ((UNIT)2064384L) //INCHES(42/96)
+#define UNIT_44_96 ((UNIT)2162688L) //INCHES(44/96)
+#define UNIT_48_96 ((UNIT)2359296L) //INCHES(48/96)
+#define UNIT_56_96 ((UNIT)2752512L) //INCHES(56/96)
+#define UNIT_64_96 ((UNIT)3145728L) //INCHES(64/96)
+
+#define ROPE_AMPLITUDE UNIT_18_96
+#define ROPE_PERIOD UNIT_20_96
+#define DECO1_AMPLITUDE UNIT_17_96
+#define DECO1_PERIOD UNIT_4_96
+#define DECO2_AMPLITUDE UNIT_18_96
+#define DECO2_PERIOD UNIT_64_96
+#define RAIN_AMPLITUDE UNIT_22_96
+#define RAIN_PERIOD UNIT_28_96
+#define PIN_AMPLITUDE UNIT_15_96
+#define PIN_PERIOD UNIT_4_96
+#define ROSE_AMPLITUDE UNIT_34_96
+#define ROSE_PERIOD UNIT_64_96
+#define SUNF_AMPLITUDE UNIT_25_96
+#define SUNF_PERIOD UNIT_48_96
+#define DECO3_AMPLITUDE UNIT_14_96
+#define DECO3_PERIOD UNIT_20_96
+
+#define ROPE_JOIN_W UNIT_18_96
+#define ROPE_JOIN_H UNIT_18_96
+#define DECO1_JOIN_W UNIT_56_96
+#define DECO1_JOIN_H UNIT_44_96
+#define DECO2_JOIN_W UNIT_64_96
+#define DECO2_JOIN_H UNIT_64_96
+#define RAIN_JOIN_W UNIT_48_96
+#define RAIN_JOIN_H UNIT_48_96
+#define PIN_JOIN_W UNIT_42_96
+#define PIN_JOIN_H UNIT_42_96
+#define ROSE_JOIN_W UNIT_48_96
+#define ROSE_JOIN_H UNIT_48_96
+#define SUNF_JOIN_W UNIT_48_96
+#define SUNF_JOIN_H UNIT_48_96
+#define DECO3_JOIN_W UNIT_56_96
+#define DECO3_JOIN_H UNIT_56_96
+
+// User defined bitmap border groups 200 - 400
+
+/* background patterns */
+#define BACK_TRANSPARENT 0
+#define BACK_FILL 1
+#define BACK_PATTERN 2
+#define BACK_10PCTDOTS 3
+#define BACK_30PCTDOTS 4
+#define BACK_50PCTDOTS 5
+#define BACK_75PCTDOTS 6
+#define BACK_90PCTDOTS 7
+#define BACK_90PCTINVDOTS 8
+#define BACK_75PCTINVDOTS 9
+#define BACK_50PCTINVDOTS 10
+#define BACK_30PCTINVDOTS 11
+#define BACK_10PCTINVDOTS 12
+#define BACK_MARBLES 13
+#define BACK_STARRYNIGHT 14
+#define BACK_DIAGTHICK 15
+#define BACK_DIAGTHIN 16
+#define BACK_DIAGDOUBLE 17
+#define BACK_DIAGDOUBLENARROW 18
+#define BACK_DIAGTRIPLE 19
+#define BACK_DIAGSINGLEWIDE 20
+#define BACK_DIAGTHICKINV 21
+#define BACK_DIAGTHININV 22
+#define BACK_DIAGDOUBLEINV 23
+#define BACK_DIAGDOUBLENARROWINV 24
+#define BACK_DIAGTRIPLEINV 25
+#define BACK_DIAGSINGLEWIDEINV 26
+#define BACK_CHAINLINKSMALLINV 27
+#define BACK_CHAINLINKSMALL 28
+#define BACK_CHAINLINKMEDIUM 29
+#define BACK_CHAINLINKLARGE 30
+#define BACK_HORZSTRIPE1 31
+#define BACK_HORZSTRIPE2 32
+#define BACK_HORZSTRIPE3 33
+#define BACK_HORZSTRIPE4 34
+#define BACK_VERTSTRIPE1 35
+#define BACK_VERTSTRIPE2 36
+#define BACK_VERTSTRIPE3 37
+#define BACK_VERTSTRIPE4 38
+#define BACK_GRIDSMALL 39
+#define BACK_GRIDMEDIUM 40
+#define BACK_GRIDLARGE 41
+#define BACK_BOXDOT 42
+#define BACK_GOLFGREEN 43
+#define BACK_DITZ 44
+#define BACK_HORZWEAVE 45
+#define BACK_APPLEPIE 46
+#define BACK_BRICK 47
+#define BACK_DIAGBRICK 48
+#define BACK_CHECKER1 49
+#define BACK_CHECKER2 50
+#define BACK_CHECKER3 51
+#define BACK_CHECKER4 52
+#define BACK_CHECKER5 53
+#define BACK_SNOWFLAKE 54
+#define BACK_MARGARITA 55
+#define BACK_SIDEHARP 56
+#define BACK_SCALES 57
+#define BACK_TAYLOR 58
+#define BACK_BUBBLES 59
+#define BACK_ARGYLE 60
+#define BACK_INDIAN1 61
+#define BACK_INDIAN3 62
+#define BACK_PEACHPIE 63
+#define BACK_GRADIENT1 64
+#define BACK_GRADIENT2 65
+#define BACK_GRADIENT3 66
+#define BACK_GRADIENT4 67
+#define BACK_GRADIENT5 68
+#define BACK_GRADIENT6 69
+#define BACK_GRADIENT7 70
+#define BACK_GRADIENT8 71
+
+#endif //STYLEDEF_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpsvstream.cxx b/lotuswordpro/source/filter/lwpsvstream.cxx
new file mode 100644
index 000000000..7e485014c
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpsvstream.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <lwpsvstream.hxx>
+#include <tools/stream.hxx>
+
+const sal_uInt32 LwpSvStream::LWP_STREAM_BASE = 0x0010;
+
+LwpSvStream::LwpSvStream(SvStream* pStream, LwpSvStream* pCompressed)
+ : m_pStream(pStream)
+ , m_pCompressedStream(pCompressed)
+{
+}
+
+/**
+ * @descr read nBytesToRead bytes to buf
+*/
+size_t LwpSvStream::Read(void* buf, size_t nBytesToRead)
+{
+ return m_pStream->ReadBytes(buf, nBytesToRead);
+}
+
+LwpSvStream& LwpSvStream::ReadUInt8(sal_uInt8& rUInt8)
+{
+ m_pStream->ReadUChar(rUInt8);
+ return *this;
+}
+
+LwpSvStream& LwpSvStream::ReadUInt16(sal_uInt16& rUInt16)
+{
+ m_pStream->ReadUInt16(rUInt16);
+ return *this;
+}
+
+LwpSvStream& LwpSvStream::ReadUInt32(sal_uInt32& rUInt32)
+{
+ m_pStream->ReadUInt32(rUInt32);
+ return *this;
+}
+
+bool LwpSvStream::good() const { return m_pStream->good(); }
+
+/**
+ * @descr SeekRel in stream
+*/
+void LwpSvStream::SeekRel(sal_Int64 pos) { m_pStream->SeekRel(pos); }
+/**
+ * @descr Get the current position in stream
+*/
+sal_Int64 LwpSvStream::Tell() { return m_pStream->Tell(); }
+
+sal_uInt64 LwpSvStream::remainingSize() { return m_pStream->remainingSize(); }
+/**
+ * @descr Seek to pos
+*/
+sal_Int64 LwpSvStream::Seek(sal_Int64 pos) { return m_pStream->Seek(pos); }
+
+bool LwpSvStream::CheckSeek(sal_Int64 pos) { return checkSeek(*m_pStream, pos); }
+/**
+ * @descr Return the stream data length
+*/
+//sal_Int64 LwpSvStream::GetLength()
+//{
+// return m_pStream->get
+//}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptable.cxx b/lotuswordpro/source/filter/lwptable.cxx
new file mode 100644
index 000000000..402d8b2f5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptable.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table object
+ */
+
+#include <sal/config.h>
+
+#include <algorithm>
+
+#include <lwpfilehdr.hxx>
+#include "lwptable.hxx"
+
+LwpSuperTable::LwpSuperTable(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+{
+}
+
+LwpSuperTable::~LwpSuperTable() {}
+
+void LwpSuperTable::Read()
+{
+ LwpContent::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpSuperTable::Parse(IXFStream* /*pOutputStream*/) {}
+
+void LwpSuperTable::XFConvert(XFContentContainer* /*pCont*/) {}
+
+/*****************************************************************************/
+LwpTable::LwpTable(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpContent(objHdr, pStrm)
+ , m_nRow(0)
+ , m_nColumn(0)
+ , m_nHeight(0)
+ , m_nWidth(0)
+ , m_nDefaultAutoGrowRowHeight(0)
+ , m_nAttributes(0)
+{
+}
+
+LwpTable::~LwpTable() {}
+
+void LwpTable::Read()
+{
+ LwpContent::Read();
+ //m_RowCache.Read(m_pObjStrm);
+ //m_ColumnCache.Read(m_pObjStrm);
+
+ //m_CPNotifyList.Read(m_pObjStrm);
+ //m_CPTempVersionedNotifyList.Read(m_pObjStrm);
+
+ m_nRow = m_pObjStrm->QuickReaduInt16();
+ m_nColumn = m_pObjStrm->QuickReaduInt16();
+
+ m_nHeight = m_pObjStrm->QuickReadInt32();
+ m_nWidth = m_pObjStrm->QuickReadInt32();
+
+ m_nDefaultAutoGrowRowHeight = m_pObjStrm->QuickReadInt32();
+
+ m_nAttributes = m_pObjStrm->QuickReaduInt16();
+
+ m_Layout.ReadIndexed(m_pObjStrm.get());
+
+ m_DefaultCellStyle.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision >= 0x0007)
+ m_CPNotifyList.Read(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+}
+
+bool LwpTable::IsNumberDown() const { return (m_nAttributes & NUMBER_DOWN) != 0; }
+
+void LwpTable::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpSuperTableLayout* LwpTable::GetSuperTableLayout()
+{
+ LwpTableLayout* pLayout = dynamic_cast<LwpTableLayout*>(m_Layout.obj().get());
+ if (pLayout)
+ return dynamic_cast<LwpSuperTableLayout*>(pLayout->GetParent().obj().get());
+
+ return nullptr;
+}
+
+/*****************************************************************************/
+LwpTableHeading::LwpTableHeading(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTable(objHdr, pStrm)
+{
+}
+
+LwpTableHeading::~LwpTableHeading() {}
+
+void LwpTableHeading::Read() { m_pObjStrm->SkipExtra(); }
+
+void LwpTableHeading::Parse(IXFStream* /*pOutputStream*/) {}
+
+/*****************************************************************************/
+LwpParallelColumns::LwpParallelColumns(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpTable(objHdr, pStrm)
+{
+}
+
+LwpParallelColumns::~LwpParallelColumns() {}
+
+void LwpParallelColumns::Read()
+{
+ LwpTable::Read();
+ cDefaultLeftColumnStyle.ReadIndexed(m_pObjStrm.get());
+ cDefaultRightColumnStyle.ReadIndexed(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+}
+/*****************************************************************************/
+LwpGlossary::LwpGlossary(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpParallelColumns(objHdr, pStrm)
+{
+}
+
+LwpGlossary::~LwpGlossary() {}
+sal_uInt16 LwpGlossary::GetNumIndexRows() const
+{
+ if (GetRow() > 0 && GetRow() <= MAX_NUM_ROWS)
+ return GetRow() - 1; // Minus one row for repeated heading.
+ return 0;
+}
+
+void LwpGlossary::Read()
+{
+ LwpParallelColumns::Read();
+
+ sal_uInt16 FiledEntries = m_pObjStrm->QuickReaduInt16();
+ sal_uInt16 NumIndexRows = GetNumIndexRows();
+
+ if (FiledEntries < NumIndexRows)
+ {
+ /* We'll have to do sequential (slow) searches. */
+ m_pObjStrm->SeekRel(FiledEntries * sizeof(sal_uInt16));
+ }
+ else
+ {
+ if (NumIndexRows)
+ {
+ sal_uInt16 EntriesRead = std::min(FiledEntries, NumIndexRows);
+
+ for (sal_uInt16 EntryCount = 1; EntryCount <= EntriesRead; EntryCount++)
+ m_pObjStrm->QuickReaduInt16();
+
+ if (FiledEntries > EntriesRead)
+ m_pObjStrm->SeekRel((FiledEntries - EntriesRead) * sizeof(sal_uInt16));
+ }
+ else
+ m_pObjStrm->SeekRel(FiledEntries * sizeof(sal_uInt16));
+ }
+
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptable.hxx b/lotuswordpro/source/filter/lwptable.hxx
new file mode 100644
index 000000000..b55d7a4b4
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptable.hxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table object
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLE_HXX
+
+#include <lwpobjhdr.hxx>
+#include <lwpobjid.hxx>
+#include "lwppara.hxx"
+#include <lwptools.hxx>
+#include "lwptablelayout.hxx"
+
+class LwpTableLayout;
+/**
+ * @brief
+ * VO_SUPERTABLE object
+ */
+class LwpSuperTable: public LwpContent
+{
+public:
+ LwpSuperTable(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpSuperTable() override;
+
+ virtual void Parse(IXFStream* pOutputStream) override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+protected:
+ void Read() override;
+};
+/**
+ * @brief
+ * for VO_TABLE object reading
+ */
+class LwpForkedNotifyList final
+{
+public:
+ LwpForkedNotifyList(){}
+ void Read(LwpObjectStream* pObjStrm)
+ {
+ m_PersistentList.Read(pObjStrm);
+ };
+
+private:
+ LwpNotifyListPersistent m_PersistentList;
+};
+/**
+ * @brief
+ * VO_TABLE object
+ */
+class LwpTable: public LwpContent
+{
+public:
+ LwpTable(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpTable() override;
+
+ virtual void Parse(IXFStream* pOutputStream) override;
+ double GetWidth() {return LwpTools::ConvertFromUnitsToMetric(m_nWidth);}
+ double GetHeight() {return LwpTools::ConvertFromUnitsToMetric(m_nHeight);}
+ LwpObjectID& GetDefaultCellStyle() {return m_DefaultCellStyle;}
+ sal_uInt16 GetRow() const {return m_nRow;}
+ sal_uInt16 GetColumn() const {return m_nColumn;}
+ rtl::Reference<LwpTableLayout> GetTableLayout()
+ {
+ return rtl::Reference<LwpTableLayout>(dynamic_cast<LwpTableLayout*>(GetLayout(nullptr).get()));
+ }
+ bool IsNumberDown() const;
+ virtual bool IsTable() override { return true;}
+ LwpSuperTableLayout* GetSuperTableLayout();
+protected:
+ LwpForkedNotifyList m_CPNotifyList;
+
+ sal_uInt16 m_nRow, m_nColumn;
+ sal_Int32 m_nHeight;
+ sal_Int32 m_nWidth;
+ sal_Int32 m_nDefaultAutoGrowRowHeight;
+ sal_uInt16 m_nAttributes;
+ enum lTableAttributes
+ {
+ NUMBER_DOWN = 0x01,
+ SIZING_VIA_MOUSE_ENABLED = 0x02,
+ NUMBER_RESET = 0x04
+ };
+
+ LwpObjectID m_Layout;
+ LwpObjectID m_DefaultCellStyle; // gCVirtualLayout
+ void Read() override;
+};
+
+/**
+ * @brief
+ * VO_TABLEHEADING object
+ */
+class LwpTableHeading : public LwpTable
+{
+public:
+ LwpTableHeading(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpTableHeading() override;
+
+ virtual void Parse(IXFStream* pOutputStream) override;
+protected:
+ void Read() override;
+
+};
+class LwpParallelColumns : public LwpTable
+{
+public:
+ LwpParallelColumns(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpParallelColumns() override;
+protected:
+ void Read() override;
+private:
+ LwpObjectID cDefaultLeftColumnStyle;
+ LwpObjectID cDefaultRightColumnStyle;
+};
+
+#define MAX_NUM_ROWS 8192
+#define MAX_NUM_COLS 255
+
+class LwpGlossary final : public LwpParallelColumns
+{
+public:
+ LwpGlossary(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpGlossary() override;
+private:
+ void Read() override;
+ sal_uInt16 GetNumIndexRows() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
new file mode 100644
index 000000000..c3d027e91
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -0,0 +1,1564 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table layouts
+ */
+
+#include <lwpglobalmgr.hxx>
+#include "lwptablelayout.hxx"
+#include <lwpfoundry.hxx>
+#include "lwpholder.hxx"
+#include "lwptable.hxx"
+#include "lwptblcell.hxx"
+#include "lwprowlayout.hxx"
+#include <lwpfilehdr.hxx>
+
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftablestyle.hxx>
+#include <xfilter/xfrow.hxx>
+#include <xfilter/xfrowstyle.hxx>
+#include <xfilter/xfcell.hxx>
+#include <xfilter/xfcolstyle.hxx>
+#include <xfilter/xfframestyle.hxx>
+#include <xfilter/xfframe.hxx>
+#include <xfilter/xffloatframe.hxx>
+#include "lwpframelayout.hxx"
+#include <xfilter/xfnumberstyle.hxx>
+#include <xfilter/xfparastyle.hxx>
+#include <o3tl/sorted_vector.hxx>
+#include <sal/log.hxx>
+
+#include <algorithm>
+#include <memory>
+
+LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpPlacableLayout(objHdr, pStrm)
+{
+ m_pFrame.reset(new LwpFrame(this) );
+}
+
+LwpSuperTableLayout::~LwpSuperTableLayout()
+{
+}
+/**
+ * @short Read super table layout record
+ */
+void LwpSuperTableLayout::Read()
+{
+ LwpPlacableLayout::Read();
+ m_pObjStrm->SkipExtra();
+
+}
+/**
+ * @short Get child table layout
+ * @return pointer to table layout
+ */
+LwpTableLayout* LwpSuperTableLayout::GetTableLayout()
+{
+ LwpObjectID *pID = &GetChildTail();
+
+ o3tl::sorted_vector<LwpObjectID*> aSeen;
+ while (pID && !pID->IsNull())
+ {
+ bool bAlreadySeen = !aSeen.insert(pID).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pID->obj().get());
+ if (!pLayout)
+ break;
+ if (pLayout->GetLayoutType() == LWP_TABLE_LAYOUT)
+ return dynamic_cast<LwpTableLayout *>(pLayout);
+ pID = &pLayout->GetPrevious();
+ }
+
+ return nullptr;
+}
+
+/**
+ * @short Get effective heading table layout, the one just before table layout is the only one which is effective
+ * @return LwpTableHeadingLayout* - pointer to table heading layout
+ */
+LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout()
+{
+ LwpObjectID *pID = &GetChildTail();
+
+ o3tl::sorted_vector<LwpObjectID*> aSeen;
+ while (pID && !pID->IsNull())
+ {
+ bool bAlreadySeen = !aSeen.insert(pID).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ LwpLayout * pLayout = dynamic_cast<LwpLayout *>(pID->obj().get());
+ if (!pLayout)
+ break;
+ if (pLayout->GetLayoutType() == LWP_TABLE_HEADING_LAYOUT)
+ return dynamic_cast<LwpTableHeadingLayout *>(pLayout);
+ pID = &pLayout->GetPrevious();
+ }
+
+ return nullptr;
+}
+
+/**
+ * @short Register super table layout style
+ */
+void LwpSuperTableLayout::RegisterNewStyle()
+{
+ // if this layout is style of real table entry
+ LwpTableLayout* pTableLayout = GetTableLayout();
+ if (pTableLayout != nullptr)
+ {
+ pTableLayout->SetFoundry(m_pFoundry);
+ pTableLayout->RegisterStyle();
+ }
+}
+/**
+ * @short Judge whether table size is according to content, borrowed from Word Pro code
+ * @param
+ * @return sal_Bool
+ */
+bool LwpSuperTableLayout::IsSizeRightToContent()
+{
+ /* Only "with paragraph above" tables can size right to content. */
+ if (GetRelativeType() == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE)
+ return LwpPlacableLayout::IsSizeRightToContent();
+
+ return false;
+}
+/**
+ * @short Judge whether table is justifiable, borrowed from Word Pro code
+ * @param
+ * @return sal_Bool
+ */
+bool LwpSuperTableLayout::IsJustifiable()
+{
+ return (GetRelativeType() != LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE || IsSizeRightToContent());
+}
+/**
+ * @short Get width of frame outside table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return double - table width
+ */
+double LwpSuperTableLayout::GetWidth()
+{
+ double dWidth = GetTableWidth();
+ double dLeft = GetMarginsValue(MARGIN_LEFT);
+ double dRight = GetMarginsValue(MARGIN_RIGHT);
+
+ return (dWidth + dLeft + dRight);
+}
+/**
+ * @short Get width of table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return double - table width
+ */
+double LwpSuperTableLayout::GetTableWidth()
+{
+ sal_Int32 nWidth = 0;
+ if(!IsJustifiable() || ((nWidth = LwpMiddleLayout::GetMinimumWidth()) <= 0))
+ {
+ LwpTableLayout* pTableLayout = GetTableLayout();
+ if(!pTableLayout)
+ {
+ SAL_WARN("lwp", "missing table layout, early return");
+ return 0;
+ }
+ LwpTable *pTable = pTableLayout->GetTable();
+ if(!pTable)
+ {
+ SAL_WARN("lwp", "missing table, early return");
+ return 0;
+ }
+ double dDefaultWidth = pTable->GetWidth();
+ sal_uInt16 nCol = pTable->GetColumn();
+
+ double dWidth = 0;
+
+ for(sal_uInt16 i =0; i< nCol; i++)
+ {
+ LwpObjectID *pColumnID = &pTableLayout->GetColumnLayoutHead();
+ LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
+ double dColumnWidth = dDefaultWidth;
+ o3tl::sorted_vector<LwpColumnLayout*> aSeen;
+ while (pColumnLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pColumnLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+ if(pColumnLayout->GetColumnID() == i)
+ {
+ dColumnWidth = pColumnLayout->GetWidth();
+ break;
+ }
+ pColumnID = &pColumnLayout->GetNext();
+ pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
+ }
+ dWidth += dColumnWidth;
+ }
+
+ return dWidth;
+ }
+
+ double dLeft = GetMarginsValue(MARGIN_LEFT);
+ double dRight = GetMarginsValue(MARGIN_RIGHT);
+ return LwpTools::ConvertFromUnitsToMetric(nWidth)-dLeft-dRight;
+
+}
+/**
+ * @short Apply shadow to table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyShadow(XFTableStyle *pTableStyle)
+{
+ // use shadow property of supertable
+ std::unique_ptr<XFShadow> pXFShadow(GetXFShadow());
+ if(pXFShadow)
+ {
+ pTableStyle->SetShadow(pXFShadow->GetPosition(), pXFShadow->GetOffset(), pXFShadow->GetColor());
+ }
+}
+/**
+ * @short Apply pattern fill to table style
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyPatternFill(XFTableStyle* pTableStyle)
+{
+ std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
+ if (xXFBGImage)
+ {
+ pTableStyle->SetBackImage(xXFBGImage);
+ }
+}
+
+/**
+ * @short Apply background to table style
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyBackGround(XFTableStyle* pTableStyle)
+{
+ if (IsPatternFill())
+ {
+ ApplyPatternFill(pTableStyle);
+ }
+ else
+ {
+ ApplyBackColor(pTableStyle);
+ }
+}
+/**
+ * @short Apply back color to table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyBackColor(XFTableStyle *pTableStyle)
+{
+ LwpColor* pColor = GetBackColor();
+ if(pColor && pColor->IsValidColor())
+ {
+ XFColor aColor(pColor->To24Color());
+ pTableStyle->SetBackColor(aColor);
+ }
+}
+/**
+ * @short Apply watermark to table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyWatermark(XFTableStyle *pTableStyle)
+{
+ std::unique_ptr<XFBGImage> xBGImage(GetXFBGImage());
+ if (xBGImage)
+ {
+ pTableStyle->SetBackImage(xBGImage);
+ }
+}
+/**
+ * @short Apply alignment to table
+ * @param pTableStyle - pointer of XFTableStyle
+ * @return
+ */
+void LwpSuperTableLayout::ApplyAlignment(XFTableStyle * pTableStyle)
+{
+ LwpPoint aPoint;
+ if (LwpLayoutGeometry* pGeometry = GetGeometry())
+ aPoint = pGeometry->GetOrigin();
+ double dXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
+
+ // add left padding to alignment distance
+ double dLeft = GetMarginsValue(MARGIN_LEFT);
+
+ pTableStyle->SetAlign(enumXFAlignStart, dXOffset+ dLeft);
+}
+/**
+ * @short Add table to container
+ * @param pCont - pointer of container
+ * @return pCont
+ */
+void LwpSuperTableLayout::XFConvert(XFContentContainer* pCont)
+{
+ if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == GetRelativeType()
+ && (!GetContainerLayout().is() || !GetContainerLayout()->IsCell()) )
+ {
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (pTableLayout)
+ {
+ pTableLayout->XFConvert(pCont);
+ }
+ }
+ else if(IsRelativeAnchored())
+ {
+ //anchor to paragraph except "with paragraph above"
+ XFConvertFrame(pCont);
+ }
+ else if(m_pFrame)
+ {
+ //anchor to page, frame, cell
+ m_pFrame->XFConvert(pCont);
+ }
+}
+/**
+ * @short convert frame which anchor to page
+ * @param
+ * @return
+ */
+void LwpSuperTableLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll)
+{
+ if(!m_pFrame)
+ return;
+
+ rtl::Reference<XFFrame> xXFFrame;
+ if(nEnd < nStart)
+ {
+ xXFFrame.set(new XFFrame);
+ }
+ else
+ {
+ xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
+ }
+
+ m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
+ //parse table, and add table to frame
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (pTableLayout)
+ {
+ pTableLayout->XFConvert(xXFFrame.get());
+ }
+ //add frame to the container
+ pCont->Add(xXFFrame.get());
+
+}
+/**
+ * @short register frame style
+ * @param
+ * @return
+ */
+void LwpSuperTableLayout::RegisterFrameStyle()
+{
+ std::unique_ptr<XFFrameStyle> xFrameStyle(new XFFrameStyle);
+ m_pFrame->RegisterStyle(xFrameStyle);
+}
+
+LwpTableLayout::LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpLayout(objHdr, pStrm)
+ , m_nRows(0)
+ , m_nCols(0)
+ , m_pDefaultCellLayout(nullptr)
+ , m_bConverted(false)
+{
+}
+
+/**
+ * @short Get neighbour cell by specifying ROW+COL
+ * @param nRow
+ * @param nCol
+ * @return LwpCellLayout *
+ */
+LwpCellLayout * LwpTableLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol)
+{
+ if (nRow >= m_nRows || nCol >= m_nCols)
+ return nullptr;
+
+ return m_WordProCellsMap[static_cast<size_t>(nRow)*m_nCols + nCol];
+}
+
+/**
+ * @short traverse all table cells
+ * @param
+ * @param
+ * @param
+ */
+void LwpTableLayout::TraverseTable()
+{
+ sal_uInt32 nCount = m_nRows*m_nCols;
+
+ // new cell map nRow*nCOl and initialize
+ m_WordProCellsMap.insert(m_WordProCellsMap.end(), nCount, m_pDefaultCellLayout);
+
+ // set value
+ LwpObjectID* pRowID = &GetChildHead();
+ LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ o3tl::sorted_vector<LwpRowLayout*> aSeen;
+ while (pRowLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pRowLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ pRowLayout->SetRowMap();
+
+ // for 's analysis job
+ m_RowsMap[pRowLayout->GetRowID()] = pRowLayout;
+ pRowLayout->CollectMergeInfo();
+ // end for 's analysis
+
+ pRowID = &pRowLayout->GetNext();
+ pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ }
+}
+
+/**
+ * @short search the cell map
+ * @param nRow - row id (0 based)
+ * @param nRow - row id (0 based)
+ * @return LwpObjectID * - pointer to cell story object ID
+ */
+LwpObjectID * LwpTableLayout::SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol)
+{
+ if (nRow >= m_nRows || nCol >= m_nCols )
+ {
+ return nullptr;
+ }
+
+ LwpCellLayout * pCell = GetCellByRowCol(nRow, nCol);
+ if (pCell)
+ {
+ // maybe connected cell layout
+ // maybe default cell layout
+ if (nRow != pCell->GetRowID() || nCol != pCell->GetColID())
+ {
+ return nullptr;
+ }
+ return &pCell->GetContent();
+ }
+
+ return nullptr;
+}
+
+/**
+ * @short Get parent super table layout of table layout
+ * @return LwpSuperTableLayout * - pointer of parent super table layout
+ */
+LwpSuperTableLayout * LwpTableLayout::GetSuperTableLayout()
+{
+ return dynamic_cast<LwpSuperTableLayout *>(GetParent().obj().get());
+}
+/**
+ * @short Get table pointer
+ * @return LwpTable * - content table pointer
+ */
+LwpTable * LwpTableLayout::GetTable()
+{
+ return dynamic_cast<LwpTable *>(m_Content.obj().get());
+}
+/**
+ * @short Get column style name by column ID
+ * @param sal_uInt16 -- col id(0 based)
+ * @return OUString - name of column style
+ */
+OUString LwpTableLayout::GetColumnWidth(sal_uInt16 nCol)
+{
+ if (nCol >= m_nCols)
+ {
+ assert(false);
+ return m_DefaultColumnStyleName;
+ }
+
+ LwpColumnLayout * pCol = m_aColumns[nCol];
+ if (pCol)
+ {
+ return pCol->GetStyleName();
+ }
+
+ return m_DefaultColumnStyleName;
+}
+/**
+ * @short analyze all columns to get whole table width and width of all columns
+ * @short and register all column styles
+ * @param none
+ */
+void LwpTableLayout::RegisterColumns()
+{
+ LwpTable* pTable = GetTable();
+ if (!pTable)
+ throw std::range_error("corrupt LwpTableLayout");
+
+ LwpSuperTableLayout* pSuper = GetSuperTableLayout();
+ if (!pSuper)
+ throw std::range_error("corrupt LwpTableLayout");
+
+ sal_uInt16 nCols = m_nCols;
+
+ m_aColumns.resize(nCols);
+ std::unique_ptr<bool[]> pWidthCalculated( new bool[nCols] );
+ for(sal_uInt16 i=0;i<nCols; i++)
+ {
+ pWidthCalculated[i] = false;
+ m_aColumns[i] = nullptr;
+ }
+
+ double dDefaultColumn = pTable->GetWidth();
+ sal_uInt16 nJustifiableColumn = nCols;
+
+ double dTableWidth = pSuper->GetTableWidth();
+
+ // Get total width of justifiable columns
+ // NOTICE: all default columns are regarded as justifiable columns
+ LwpObjectID* pColumnID = &GetColumnLayoutHead();
+ LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
+ o3tl::sorted_vector<LwpColumnLayout*> aSeen;
+ while (pColumnLayout)
+ {
+ bool bAlreadySeen = !aSeen.insert(pColumnLayout).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ auto nColId = pColumnLayout->GetColumnID();
+ if (nColId >= nCols)
+ {
+ throw std::range_error("corrupt LwpTableLayout");
+ }
+ m_aColumns[nColId] = pColumnLayout;
+ if (!pColumnLayout->IsJustifiable())
+ {
+ pWidthCalculated[nColId] = true;
+ dTableWidth -= pColumnLayout->GetWidth();
+ nJustifiableColumn --;
+ }
+
+ pColumnID = &pColumnLayout->GetNext();
+ pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
+ }
+
+ // if all columns are not justifiable, the rightmost column will be changed to justifiable
+ if (nJustifiableColumn == 0 && nCols != 0)
+ {
+ nJustifiableColumn ++;
+ if (m_aColumns[nCols - 1])
+ {
+ pWidthCalculated[nCols-1] = false;
+ dTableWidth += m_aColumns[nCols-1]->GetWidth();
+ }
+ else
+ {
+ // this can't happen
+ dTableWidth = dDefaultColumn;
+ assert(false);
+ }
+ }
+
+ // justifiable columns will share the remain width averagely
+ dDefaultColumn = nJustifiableColumn ? dTableWidth/nJustifiableColumn : 0;
+
+ // register default column style
+ std::unique_ptr<XFColStyle> xColStyle(new XFColStyle);
+ xColStyle->SetWidth(static_cast<float>(dDefaultColumn));
+
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_DefaultColumnStyleName = pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
+
+ // register existed column style
+ sal_uInt16 i=0;
+ for( i=0;i<nCols; i++)
+ {
+ if (m_aColumns[i])
+ {
+ m_aColumns[i]->SetFoundry(m_pFoundry);
+ if(!pWidthCalculated[i])
+ {
+ // justifiable ----register style with calculated value
+ m_aColumns[i]->SetStyleName(m_DefaultColumnStyleName);
+ }
+ else
+ {
+ // not justifiable ---- register style with original value
+ m_aColumns[i]->RegisterStyle(m_aColumns[i]->GetWidth());
+ }
+ }
+ }
+}
+/**
+ * @short register all row styles
+ * @param none
+ */
+void LwpTableLayout::RegisterRows()
+{
+ LwpTable * pTable = GetTable();
+ if (pTable == nullptr)
+ {
+ assert(false);
+ return;
+ }
+
+ // register default row style
+ std::unique_ptr<XFRowStyle> xRowStyle(new XFRowStyle);
+ if (m_nDirection & 0x0030)
+ {
+ xRowStyle->SetMinRowHeight(static_cast<float>(pTable->GetHeight()));
+ }
+ else
+ {
+ xRowStyle->SetRowHeight(static_cast<float>(pTable->GetHeight()));
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_DefaultRowStyleName = pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName();
+
+ // register style of rows
+ LwpObjectID * pRowID = &GetChildHead();
+ LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ while (pRowLayout)
+ {
+ pRowLayout->SetFoundry(m_pFoundry);
+ pRowLayout->RegisterStyle();
+
+ pRowID = &pRowLayout->GetNext();
+ pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ }
+}
+/**
+ * @short register table style, if needed, including frame style
+ * @param none
+ */
+void LwpTableLayout::RegisterStyle()
+{
+ // get super table layout
+ LwpSuperTableLayout * pSuper = GetSuperTableLayout();
+ if (!pSuper)
+ return;
+
+ // get table
+ LwpTable * pTable = GetTable();
+ if (pTable == nullptr)
+ {
+ SAL_WARN("lwp", "missing table, early return");
+ return;
+ }
+
+ // get row/column number of this table
+ m_nRows = pTable->GetRow();
+ m_nCols = pTable->GetColumn();
+ //http://www.danielsays.com/ss-gallery-win1x2x3x-lotus-word-pro-96.html
+ //tables with up to 255 rows and 8192 columns
+ //the row limit tallies with the casting of m_nCols to an unsigned char
+ //elsewhere
+ if (m_nRows > MAX_NUM_ROWS)
+ throw std::runtime_error("max legal row exceeded");
+ if (m_nCols > MAX_NUM_COLS)
+ throw std::runtime_error("max legal column exceeded");
+
+ // get default cell layout of current table
+ LwpObjectID& rID= pTable->GetDefaultCellStyle();
+ m_pDefaultCellLayout = dynamic_cast<LwpCellLayout *>(rID.obj().get());
+
+ // register columns styles
+ RegisterColumns();
+
+ // register style of whole table
+ std::unique_ptr<XFTableStyle> xTableStyle(new XFTableStyle);
+
+ sal_uInt8 nType = pSuper->GetRelativeType();
+ // If the table is not "with paragraph above" placement, create an frame style
+ // by supertable layout
+ if ( LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE == nType
+ && (!pSuper->GetContainerLayout().is() || !pSuper->GetContainerLayout()->IsCell()) )
+ {
+ //with para above
+ pSuper->ApplyBackGround(xTableStyle.get());
+ pSuper->ApplyWatermark(xTableStyle.get());
+ pSuper->ApplyShadow(xTableStyle.get());
+ pSuper->ApplyAlignment(xTableStyle.get());
+ xTableStyle->SetWidth(pSuper->GetTableWidth());
+ }
+ else
+ {
+ pSuper->RegisterFrameStyle();
+ xTableStyle->SetAlign(enumXFAlignCenter);
+ xTableStyle->SetWidth(pSuper->GetTableWidth());
+ }
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xTableStyle)).m_pStyle->GetStyleName();
+
+ //convert to OO table now and register row style traverse
+ TraverseTable();
+
+ SplitConflictCells();
+
+ // Register rows layouts, it must be after SplitConflictCells
+ RegisterRows();
+
+ // Parse table
+ ParseTable();
+
+ // the old code doesn't check if the LwpFoundry pointer is NULL,
+ // so the NULL pointer cause sodc freeze. Add code to check the pointer.
+ if (GetFoundry())
+ PutCellVals(GetFoundry(), pTable->GetObjectID());
+}
+/**
+ * @short read table layout
+ * @param none
+ */
+void LwpTableLayout::ParseTable()
+{
+ // get super table layout
+ LwpSuperTableLayout* pSuper = GetSuperTableLayout();
+ if (!pSuper)
+ {
+ throw std::runtime_error("missing super table");
+ }
+
+ if (m_pXFTable)
+ {
+ throw std::runtime_error("this table is already parsed");
+ }
+
+ // set name of object
+ m_pXFTable.set(new XFTable);
+
+ m_pXFTable->SetTableName(pSuper->GetName().str());
+ // set table style
+ m_pXFTable->SetStyleName(m_StyleName);
+
+ sal_uInt16 nRow = m_nRows;
+ sal_uInt8 nCol = static_cast<sal_uInt8>(m_nCols);
+
+ //process header rows
+ LwpTableHeadingLayout* pTableHeading;
+ pTableHeading = pSuper->GetTableHeadingLayout();
+ if (pTableHeading)
+ {
+ sal_uInt16 nStartHeadRow;
+ sal_uInt16 nEndHeadRow;
+ pTableHeading->GetStartEndRow(nStartHeadRow,nEndHeadRow);
+ if (nStartHeadRow != 0)
+ ConvertTable(m_pXFTable,0,nRow,0,nCol);
+ else
+ {
+ sal_uInt16 nContentRow = ConvertHeadingRow(m_pXFTable,nStartHeadRow,nEndHeadRow+1);
+ ConvertTable(m_pXFTable,nContentRow,nRow,0,nCol);
+ }
+ }
+ else
+ ConvertTable(m_pXFTable,0,nRow,0,nCol);
+}
+
+/**
+ * @short read table layout
+ * @param none
+ */
+void LwpTableLayout::Read()
+{
+ LwpLayout::Read();
+
+ // before layout hierarchy rework!
+ if(LwpFileHeader::m_nFileRevision < 0x000b)
+ {
+ assert(false);
+ }
+ m_ColumnLayout.ReadIndexed(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+ * @short Convert table
+ * @param
+ * @return pCont - container which will contain table
+ */
+void LwpTableLayout::XFConvert(XFContentContainer* pCont)
+{
+ if (!m_pXFTable)
+ return;
+ if (m_bConverted)
+ throw std::runtime_error("already added to a container");
+ pCont->Add(m_pXFTable.get());
+ m_bConverted = true;
+}
+
+/**
+ * @short convert heading row
+ * @param pXFTable - pointer of table
+ * @param nStartRow - start heading row ID
+ * @param nEndRow - end heading row ID
+ */
+sal_uInt16 LwpTableLayout::ConvertHeadingRow(
+ rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartHeadRow, sal_uInt16 nEndHeadRow)
+{
+ sal_uInt16 nContentRow;
+ LwpTable* pTable = GetTable();
+ assert(pTable);
+ sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
+ rtl::Reference<XFTable> pTmpTable( new XFTable );
+
+ ConvertTable(pTmpTable,nStartHeadRow,nEndHeadRow,0,nCol);
+
+ sal_uInt16 nRowNum = pTmpTable->GetRowCount();
+ std::vector<sal_uInt8> CellMark(nRowNum);
+
+ if (nRowNum == 1)
+ {
+ XFRow* pXFRow = pTmpTable->GetRow(1);
+ pXFTable->AddHeaderRow(pXFRow);
+ pTmpTable->RemoveRow(1);
+ nContentRow = nEndHeadRow;
+ }
+ else
+ {
+ sal_uInt8 nFirstColSpann = 1;
+ const bool bFindFlag = FindSplitColMark(pTmpTable.get(), CellMark, nFirstColSpann);
+
+ if (bFindFlag)//split to 2 cells
+ {
+ SplitRowToCells(pTmpTable.get(), pXFTable, nFirstColSpann, CellMark.data());
+ nContentRow = nEndHeadRow;
+ }
+ else//can not split,the first row will be the heading row,the rest will be content row
+ {
+ XFRow* pXFRow = pTmpTable->GetRow(1);
+ pXFTable->AddHeaderRow(pXFRow);
+ pTmpTable->RemoveRow(1);
+ auto iter = m_RowsMap.find(0);
+ if (iter == m_RowsMap.end())
+ {
+ SAL_WARN("lwp", "row 0 is unknown");
+ nContentRow = 0;
+ }
+ else
+ nContentRow = iter->second->GetCurMaxSpannedRows(0,nCol);
+ }
+ }
+ return nContentRow;
+}
+
+void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable> const & pXFTable,
+ sal_uInt8 nFirstColSpann,const sal_uInt8* pCellMark)
+{
+ sal_uInt16 i;
+ sal_uInt16 nRowNum = pTmpTable->GetRowCount();
+ LwpTable* pTable = GetTable();
+ assert(pTable);
+ sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
+
+ rtl::Reference<XFRow> xXFRow(new XFRow);
+
+ //register style for heading row
+ double fHeight = 0;
+ OUString styleName;
+ std::unique_ptr<XFRowStyle> xRowStyle(new XFRowStyle);
+ XFRow* pRow = pTmpTable->GetRow(1);
+ if (!pRow)
+ throw std::runtime_error("missing row");
+ styleName = pRow->GetStyleName();
+
+ // get settings of the row and assign them to new row style
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ XFRowStyle *pTempRowStyle = static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName));
+ if (pTempRowStyle)
+ *xRowStyle = *pTempRowStyle;
+
+ for (i=1;i<=nRowNum;i++)
+ {
+ styleName = pTmpTable->GetRow(i)->GetStyleName();
+ fHeight+=static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName))->GetRowHeight();
+ }
+ if (m_nDirection & 0x0030)
+ {
+ xRowStyle->SetMinRowHeight(static_cast<float>(fHeight));
+ }
+ else
+ {
+ xRowStyle->SetRowHeight(static_cast<float>(fHeight));
+ }
+ xXFRow->SetStyleName(pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName());
+
+ //construct heading row
+ rtl::Reference<XFCell> xXFCell1(new XFCell);
+ rtl::Reference<XFCell> xXFCell2(new XFCell);
+ rtl::Reference<XFTable> xSubTable1(new XFTable);
+ rtl::Reference<XFTable> xSubTable2(new XFTable);
+ rtl::Reference<XFCell> xNewCell;
+
+ for (i=1;i<=nRowNum;i++)
+ {
+ XFRow* pOldRow = pTmpTable->GetRow(i);
+ rtl::Reference<XFRow> xNewRow(new XFRow);
+ xNewRow->SetStyleName(pOldRow->GetStyleName());
+ for (sal_uInt8 j=1;j<=pCellMark[i];j++)
+ {
+ xNewCell = pOldRow->GetCell(j);
+ xNewRow->AddCell(xNewCell);
+ }
+ xSubTable1->AddRow(xNewRow);
+ }
+ ConvertColumn(xSubTable1, 0, nFirstColSpann);//add column info
+
+ xXFCell1->Add(xSubTable1.get());
+ xXFCell1->SetColumnSpaned(nFirstColSpann);
+ xXFRow->AddCell(xXFCell1);
+
+ for (i=1;i<=nRowNum;i++)
+ {
+ XFRow* pOldRow = pTmpTable->GetRow(i);
+ rtl::Reference<XFRow> xNewRow(new XFRow);
+ xNewRow->SetStyleName(pOldRow->GetStyleName());
+ for(sal_Int32 j=pCellMark[i]+1;j<=pOldRow->GetCellCount();j++)
+ {
+ xNewCell = pOldRow->GetCell(j);
+ xNewRow->AddCell(xNewCell);
+ }
+ xSubTable2->AddRow(xNewRow);
+
+ }
+ ConvertColumn(xSubTable2, nFirstColSpann, nCol);//add column info
+ xXFCell2->Add(xSubTable2.get());
+ xXFCell2->SetColumnSpaned(nCol-nFirstColSpann);
+ xXFRow->AddCell(xXFCell2);
+
+ pXFTable->AddHeaderRow(xXFRow.get());
+
+ //remove tmp table
+ for (i=1;i<=nRowNum;i++)
+ {
+ pTmpTable->RemoveRow(i);
+ }
+}
+
+/**
+ * @short find if the heading rows can be split to 2 cells
+ * @param pXFTable - pointer of tmp XFtable
+ * @param CellMark - pointer of cell mark array
+ */
+bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark,
+ sal_uInt8& nMaxColSpan)
+{
+ sal_uInt16 nRowNum = pXFTable->GetRowCount();
+ sal_uInt8 nColNum = static_cast<sal_uInt8>(pXFTable->GetColumnCount());
+ sal_uInt8 nCount;
+ sal_uInt8 nColSpan;
+ bool bFindFlag = false;
+ XFRow* pTmpRow;
+
+ for(sal_uInt8 i=1;i<=nColNum;i++)
+ {
+ sal_uInt16 nRowLoop;
+
+ //find current max column span
+ nMaxColSpan = 1;
+ for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
+ {
+ nColSpan = 0;
+ for(sal_uInt8 nCellLoop=1; nCellLoop<i+1; nCellLoop++)
+ {
+ pTmpRow = pXFTable->GetRow(nRowLoop);
+ XFCell* pCell = pTmpRow->GetCell(nCellLoop);
+ if (pCell)
+ nColSpan += static_cast<sal_uInt8>(pCell->GetColSpaned());
+ else
+ return false;
+ }
+ if (nColSpan > nMaxColSpan)
+ nMaxColSpan = nColSpan;
+ rCellMark.at(nRowLoop) = 0;//reset all cell mark to zero
+ }
+
+ //find if other row has the same column
+ for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
+ {
+ pTmpRow = pXFTable->GetRow(nRowLoop);
+ nCount = 0;
+ sal_Int32 nCellMark = 0;
+ for (sal_Int32 nCellLoop=1; nCellLoop<=pTmpRow->GetCellCount(); nCellLoop++)
+ {
+ if (nCount>nMaxColSpan)
+ break;
+ nCount+= static_cast<sal_uInt8>(pTmpRow->GetCell(nCellLoop)->GetColSpaned());
+ if (nCount == nMaxColSpan)
+ {
+ nCellMark = nCellLoop;
+ break;
+ }
+ }
+ if (nCellMark == 0)
+ break;
+ else
+ rCellMark.at(nRowLoop) = nCellMark;
+ }
+ for(nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)//check if all ==0,break
+ {
+ if (rCellMark.at(nRowLoop) == 0)
+ break;
+ }
+ if (nRowLoop == nRowNum+1)
+ {
+ bFindFlag = true;
+ return bFindFlag;
+ }
+
+ }
+ return bFindFlag;
+}
+
+static bool operator==(const TableConvertAttempt& a, const TableConvertAttempt& b)
+{
+ return a.mnStartRow == b.mnStartRow &&
+ a.mnEndRow == b.mnEndRow &&
+ a.mnStartCol== b.mnStartCol &&
+ a.mnEndCol == b.mnEndCol;
+}
+
+/**
+ * @short convert word pro table to SODC table
+ * @param pXFTable - pointer of table
+ * @param nStartRow - start row ID
+ * @param nEndRow - end row ID
+ * @param nStartCol - start column ID
+ * @param nEndCol - end column ID
+ */
+void LwpTableLayout::ConvertTable(rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartRow,
+ sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
+{
+ TableConvertAttempt aConversionAttempt(nStartRow, nEndRow, nStartCol, nEndCol);
+ auto itr = std::find(m_aConvertingStack.begin(), m_aConvertingStack.end(), aConversionAttempt);
+ if (itr != m_aConvertingStack.end())
+ {
+ SAL_WARN("lwp", "already trying to convert this range");
+ return;
+ }
+
+ m_aConvertingStack.push_back(aConversionAttempt);
+
+ //out put column info TO BE CHANGED
+ ConvertColumn(pXFTable,nStartCol,nEndCol);
+
+ std::map<sal_uInt16,LwpRowLayout*>::iterator iter;
+
+ for (sal_uInt16 i=nStartRow; i<nEndRow;)
+ {
+ iter = m_RowsMap.find(i);
+ if (iter == m_RowsMap.end())
+ {
+ ConvertDefaultRow(pXFTable,nStartCol,nEndCol,i);
+ i++;
+ }
+ else
+ {
+ LwpRowLayout* pRow = iter->second;
+ if (pRow->GetCurMaxSpannedRows(nStartCol,nEndCol) == 1)
+ {
+ pRow->ConvertCommonRow(pXFTable,nStartCol,nEndCol);
+ i++;
+ }
+ else
+ {
+ pRow->ConvertRow(pXFTable,nStartCol,nEndCol);
+ i += pRow->GetCurMaxSpannedRows(nStartCol,nEndCol);
+ }
+ }
+ }
+
+ m_aConvertingStack.pop_back();
+}
+
+/**
+ * @short apply numeric value and formula to cell
+ * @param pFoundry - pointer of foundry
+ * @param aTableID - table ID
+ */
+void LwpTableLayout::PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID)
+{
+
+ // The old code doesn't check if the LwpFoundry pointer is NULL, so the NULL
+ // pointer cause sodc frozen. Add code to check the pointer.
+ if( !pFoundry ) return;
+
+ try{
+
+ LwpDLVListHeadHolder* pHolder = dynamic_cast<LwpDLVListHeadHolder*>(pFoundry->GetNumberManager().GetTableRangeID().obj().get());
+
+ LwpTableRange* pTableRange = pHolder ? dynamic_cast<LwpTableRange*>(pHolder->GetHeadID().obj().get()) : nullptr;
+
+ //Look up the table
+ o3tl::sorted_vector<LwpTableRange*> aTableSeen;
+ while (pTableRange)
+ {
+ bool bAlreadySeenTable = !aTableSeen.insert(pTableRange).second;
+ if (bAlreadySeenTable)
+ throw std::runtime_error("loop in conversion");
+ LwpObjectID aID = pTableRange->GetTableID();
+ if (aID == aTableID)
+ {
+ break;
+ }
+ pTableRange = pTableRange->GetNext();
+ }
+
+ if (!pTableRange)
+ return;
+
+ LwpCellRange* pRange = dynamic_cast<LwpCellRange*>(pTableRange->GetCellRangeID().obj().get());
+ if (!pRange)
+ return;
+
+ LwpFolder* pFolder = dynamic_cast<LwpFolder*>(pRange->GetFolderID().obj().get());
+ if (!pFolder)
+ return;
+
+ LwpObjectID aRowListID = pFolder->GetChildHeadID();
+ LwpRowList* pRowList = dynamic_cast<LwpRowList*>(aRowListID.obj().get());
+
+ //loop the rowlist
+ o3tl::sorted_vector<LwpRowList*> aOuterSeen;
+ while (pRowList)
+ {
+ bool bAlreadySeenOuter = !aOuterSeen.insert(pRowList).second;
+ if (bAlreadySeenOuter)
+ throw std::runtime_error("loop in conversion");
+ sal_uInt16 nRowID = pRowList->GetRowID();
+ {
+ LwpCellList* pCellList = dynamic_cast<LwpCellList*>(pRowList->GetChildHeadID().obj().get());
+ //loop the cellList
+ o3tl::sorted_vector<LwpCellList*> aSeen;
+ while (pCellList)
+ {
+ bool bAlreadySeen = !aSeen.insert(pCellList).second;
+ if (bAlreadySeen)
+ throw std::runtime_error("loop in conversion");
+
+ {//put cell
+ sal_uInt16 nColID = pCellList->GetColumnID();
+
+ XFCell* pCell = GetCellsMap(nRowID,static_cast<sal_uInt8>(nColID));
+ if (!pCell)
+ {
+ throw std::runtime_error("Hidden cell would not be in cellsmap");
+ }
+
+ pCellList->Convert(pCell, this);
+
+ //process paragraph
+ PostProcessParagraph(pCell, nRowID, nColID);
+
+ }
+ pCellList = dynamic_cast<LwpCellList*>(pCellList->GetNextID().obj().get());
+ }
+ }
+ pRowList = dynamic_cast<LwpRowList*>(pRowList->GetNextID().obj().get());
+ }
+
+ }catch (...) {
+ SAL_WARN("lwp", "bad PutCellVals");
+ }
+}
+
+/**
+ * @short 1. set number right alignment to right if number 2. remove tab added before if number
+ * @param pCell - cell which to be process
+ * @param nRowID - row number in Word Pro file
+ * @param nColID - column number in Word Pro file
+ */
+void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID)
+{
+ // if number right, set alignment to right
+ LwpCellLayout * pCellLayout = GetCellByRowCol(nRowID, nColID);
+ if(!pCellLayout)
+ return;
+
+ rtl::Reference<XFContent> first(
+ pCell->FindFirstContent(enumXFContentPara));
+ XFParagraph * pXFPara = static_cast<XFParagraph*>(first.get());
+ if (!pXFPara)
+ return;
+ XFColor aNullColor;
+
+ OUString sNumfmt = pCellLayout->GetNumfmtName();
+ bool bColorMod = false;
+ XFNumberStyle* pNumStyle = nullptr;
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ if (!sNumfmt.isEmpty())
+ {
+ pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt));
+ XFColor aColor = pNumStyle->GetColor();
+ if ( aColor != aNullColor )
+ bColorMod = true;//end
+ }
+
+ XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
+ if (!((pStyle && pStyle->GetNumberRight()) || bColorMod))
+ return;
+
+ std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
+
+ if (pStyle)
+ {
+ *xOverStyle = *pStyle;
+
+ if (pStyle->GetNumberRight())
+ xOverStyle->SetAlignType(enumXFAlignEnd);
+ }
+
+ if (bColorMod)
+ {
+ rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
+ if (xFont.is())
+ {
+ XFColor aColor = xFont->GetColor();
+ if (aColor == aNullColor)
+ {
+ rtl::Reference<XFFont> pNewFont(new XFFont);
+ aColor = pNumStyle->GetColor();
+ pNewFont->SetColor(aColor);
+ xOverStyle->SetFont(pNewFont);
+ }
+ }
+ }
+
+ xOverStyle->SetStyleName("");
+ OUString StyleName
+ = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
+
+ pXFPara->SetStyleName(StyleName);
+}
+
+/**
+ * @short Parse all cols of table
+ * @param pXFTable - pointer to created XFTable
+ */
+void LwpTableLayout::ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
+{
+ LwpTable * pTable = GetTable();
+ if (!pTable)
+ {
+ assert(false);
+ return;
+ }
+
+ for (sal_uInt32 iLoop = 0; iLoop < static_cast<sal_uInt32>(nEndCol)-nStartCol; ++iLoop)
+ {
+ // add row to table
+ LwpObjectID *pColID = &GetColumnLayoutHead();
+ LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
+ while (pColumnLayout)
+ {
+ if (pColumnLayout->GetColumnID() == (iLoop+nStartCol))
+ {
+ pXFTable->SetColumnStyle(iLoop+1, pColumnLayout->GetStyleName());
+ break;
+ }
+ pColID = &pColumnLayout->GetNext();
+ pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
+ }
+ if (!pColumnLayout)
+ {
+ pXFTable->SetColumnStyle(iLoop+1, m_DefaultColumnStyleName);
+ }
+ }
+}
+/**
+ * @short split conflict merged cells
+ */
+void LwpTableLayout::SplitConflictCells()
+{
+ LwpTable * pTable = GetTable();
+ if (!pTable)
+ return;
+ sal_uInt16 nCol = pTable->GetColumn();
+ sal_uInt16 nRow = pTable->GetRow();
+
+ sal_uInt16 nEffectRows;
+ std::map<sal_uInt16,LwpRowLayout*>::iterator iter1;
+ std::map<sal_uInt16,LwpRowLayout*>::iterator iter2;
+ LwpRowLayout* pRowLayout;
+ LwpRowLayout* pEffectRow;
+
+ for (sal_uInt16 i=0; i<nRow; )
+ {
+ iter1 = m_RowsMap.find(i);
+ if (iter1 == m_RowsMap.end())//default rows
+ {
+ i++;
+ continue;
+ }
+ pRowLayout= iter1->second;
+ if (!pRowLayout->GetMergeCellFlag())
+ {
+ i++;
+ continue;
+ }
+ else
+ {
+ nEffectRows = i + pRowLayout->GetCurMaxSpannedRows(0,static_cast<sal_uInt8>(nCol));
+
+ for (sal_uInt16 j = i+1; j<nEffectRows; j++)
+ {
+ iter2 = m_RowsMap.find(j);
+ if (iter2 == m_RowsMap.end())
+ continue;
+ pEffectRow = iter2->second;
+ if (!pEffectRow->GetMergeCellFlag())
+ continue;
+ else
+ pEffectRow->SetCellSplit(nEffectRows);
+ }
+ i = nEffectRows;
+ }
+ }//end for
+
+}
+/**
+ * @short add default row which are missing in the file
+ * @param pXFTable - pointer to new created table
+ * @param nStartCol - starting column
+ * @param nEndCol - end column
+ * @return pXFTable
+ */
+void LwpTableLayout::ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol,
+ sal_uInt8 nEndCol, sal_uInt16 nRowID)
+{
+ // current row doesn't exist in the file
+ rtl::Reference<XFRow> xRow(new XFRow);
+ xRow->SetStyleName(m_DefaultRowStyleName);
+
+ for (sal_uInt16 j =0;j < nEndCol-nStartCol; j++)
+ {
+ // if table has default cell layout, use it to ConvertCell
+ // otherwise use blank cell
+ rtl::Reference<XFCell> xCell;
+ if (m_pDefaultCellLayout)
+ {
+ LwpTable* pTable = GetTable();
+ assert(pTable);
+ xCell = m_pDefaultCellLayout->DoConvertCell(
+ pTable->GetObjectID(),nRowID,j+nStartCol);
+ }
+ else
+ {
+ xCell.set(new XFCell);
+ }
+ xRow->AddCell(xCell);
+ }
+
+ pXFTable->AddRow(xRow);
+}
+
+/**
+ * @short set cell map info
+ * @param pXFCell - pointer to xfcell
+ * @param nRow - row id
+ * @param nCol - column id
+ */
+void LwpTableLayout::SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1,
+ sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell)
+{
+ m_CellsMap.insert({{nRow1, nCol1}, {nRow2, nCol2}}, pXFCell);
+}
+
+/**
+ * @short get cell map info
+ * @param nRow - row id
+ * @param nCol - column id
+ * @return pXFCell
+ */
+XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol)
+{
+ auto results = m_CellsMap.search({{nRow, nCol}, {nRow, nCol}}, rt_type::search_type::overlap);
+ if (results.begin() == results.end())
+ return nullptr;
+ // return the last thing inserted for this position
+ return std::prev(results.end())->GetCell();
+}
+/**
+ * @descr Get row layout by row id
+ * @param nRow - row id
+ */
+LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow)
+{
+ LwpObjectID *pRowID = &GetChildHead();
+ LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ while (pRowLayout)
+ {
+ if(pRowLayout->GetRowID() == nRow)
+ return pRowLayout;
+
+ pRowID = &pRowLayout->GetNext();
+ pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
+ }
+ return nullptr;
+}
+
+//add end by
+LwpColumnLayout::LwpColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpVirtualLayout(objHdr, pStrm)
+ , ccolid(0)
+ , cwidth(0)
+{}
+
+LwpColumnLayout::~LwpColumnLayout()
+{}
+void LwpColumnLayout::Read()
+{
+ LwpObjectStream* pStrm = m_pObjStrm.get();
+
+ LwpVirtualLayout::Read();
+
+ sal_uInt16 colid;
+
+ colid = pStrm->QuickReaduInt16(); // forced to lushort
+ ccolid = static_cast<sal_uInt8>(colid);
+ cwidth = pStrm->QuickReadInt32();
+
+ pStrm->SkipExtra();
+}
+
+void LwpColumnLayout::RegisterStyle(double dCalculatedWidth)
+{
+ std::unique_ptr<XFColStyle> xColStyle(new XFColStyle);
+ xColStyle->SetWidth(static_cast<float>(dCalculatedWidth));
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_StyleName = pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
+}
+
+LwpTableHeadingLayout::LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpTableLayout(objHdr, pStrm)
+ , cStartRow(0)
+ , cEndRow(0)
+{}
+
+LwpTableHeadingLayout::~LwpTableHeadingLayout()
+{}
+/**
+ * @short read table heading layout
+ * @param
+ * @return
+ */
+void LwpTableHeadingLayout::Read()
+{
+ LwpTableLayout::Read();
+
+ cStartRow = m_pObjStrm->QuickReaduInt16();
+ cEndRow = m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->SkipExtra();
+
+}
+/**
+ * @short get start and end row number of table heading
+ * @param
+ * @return *pStartRow - starting row number
+ * @return *pEndRow - end row number
+ */
+void LwpTableHeadingLayout::GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow)
+{
+ nStartRow = cStartRow;
+ nEndRow = cEndRow;
+}
+
+LwpSuperParallelColumnLayout::LwpSuperParallelColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm):LwpSuperTableLayout(objHdr, pStrm)
+{
+}
+LwpSuperParallelColumnLayout::~LwpSuperParallelColumnLayout()
+{}
+
+void LwpSuperParallelColumnLayout::Read()
+{
+ LwpSuperTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+
+}
+
+LwpSuperGlossaryLayout::LwpSuperGlossaryLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm):LwpSuperTableLayout(objHdr, pStrm)
+{
+}
+
+LwpSuperGlossaryLayout::~LwpSuperGlossaryLayout()
+{
+}
+
+void LwpSuperGlossaryLayout::Read()
+{
+ LwpSuperTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+LwpParallelColumnsLayout::LwpParallelColumnsLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm):LwpTableLayout(objHdr, pStrm)
+{
+}
+
+LwpParallelColumnsLayout::~LwpParallelColumnsLayout()
+{
+}
+
+void LwpParallelColumnsLayout::Read()
+{
+ LwpTableLayout::Read();
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptablelayout.hxx b/lotuswordpro/source/filter/lwptablelayout.hxx
new file mode 100644
index 000000000..beee6acb6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptablelayout.hxx
@@ -0,0 +1,313 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table layouts
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABLELAYOUT_HXX
+
+#include "lwplayout.hxx"
+#include <xfilter/xftable.hxx>
+#include <svl/hint.hxx>
+#include <svl/lstner.hxx>
+
+#include <mdds/rtree.hpp>
+
+#include <vector>
+#include <map>
+#include <memory>
+
+class XFTableStyle;
+class XFTable;
+class XFCell;
+class LwpTable;
+class LwpFrame;
+class LwpSuperTableLayout;
+class LwpRowLayout;
+class LwpCellLayout;
+class LwpTableHeadingLayout;
+class LwpRowHeadingLayout;
+class LwpConnectedCellLayout;
+class LwpColumnLayout;
+
+struct TableConvertAttempt
+{
+ sal_uInt16 mnStartRow;
+ sal_uInt16 mnEndRow;
+ sal_uInt8 mnStartCol;
+ sal_uInt8 mnEndCol;
+
+ TableConvertAttempt(sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
+ : mnStartRow(nStartRow), mnEndRow(nEndRow), mnStartCol(nStartCol), mnEndCol(nEndCol)
+ {
+ }
+};
+
+class XFCellListener : public SfxListener
+{
+public:
+ XFCellListener(XFCell* pCell)
+ : m_pCell(pCell)
+ {
+ if (m_pCell)
+ StartListening(*m_pCell);
+ }
+
+ XFCell* GetCell()
+ {
+ return m_pCell;
+ }
+
+private:
+ XFCell* m_pCell;
+
+ virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
+ {
+ if (rHint.GetId() == SfxHintId::Dying)
+ m_pCell = nullptr;
+ }
+};
+
+/**
+ * @brief
+ * VO_TABLELAYOUT object and functions for registering styles and converting tables
+ */
+class LwpTableLayout: public LwpLayout
+{
+public:
+ LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_TABLE_LAYOUT;}
+ LwpObjectID& GetColumnLayoutHead(){return m_ColumnLayout;}
+ void RegisterStyle() override;
+ LwpTable * GetTable();
+ LwpCellLayout * GetDefaultCellLayout(){return m_pDefaultCellLayout;}
+ LwpSuperTableLayout * GetSuperTableLayout();
+ LwpObjectID * SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol);
+ LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol);
+ OUString GetColumnWidth(sal_uInt16 nCol);
+ void SetWordProCellMap(sal_uInt16 nRow, sal_uInt16 nCol, LwpCellLayout * pCell)
+ {
+ if (nRow >= m_nRows || nCol >= m_nCols)
+ return;
+ m_WordProCellsMap[static_cast<size_t>(nRow) * m_nCols + nCol] = pCell;
+ };
+protected:
+ void Read() override;
+ void TraverseTable();
+ void RegisterColumns();
+ void RegisterRows();
+ void ParseTable();
+ void PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID);
+
+ sal_uInt16 m_nRows;
+ sal_uInt16 m_nCols;
+
+ std::vector<TableConvertAttempt> m_aConvertingStack;
+
+private:
+ //CColumnLayoutHead cColumnLayout;
+ LwpObjectID m_ColumnLayout;
+ LwpCellLayout * m_pDefaultCellLayout;
+ OUString m_DefaultColumnStyleName;
+ OUString m_DefaultRowStyleName;
+
+ // wordpro cell map
+ std::vector<LwpCellLayout*> m_WordProCellsMap;
+ // column vector
+ std::vector<LwpColumnLayout*> m_aColumns;
+
+public:
+ void XFConvert(XFContentContainer* pCont) override;
+ void ConvertTable(rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartRow,
+ sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol);
+ const OUString& GetDefaultRowStyleName() const {return m_DefaultRowStyleName;}
+ void SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1, sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell);
+ XFCell* GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol);
+ const std::map<sal_uInt16,LwpRowLayout*>& GetRowsMap() const {return m_RowsMap;}
+ LwpRowLayout* GetRowLayout(sal_uInt16 nRow);
+private:
+ void ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol,
+ sal_uInt8 nEndCol, sal_uInt16 nRowID);
+ void ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol);
+ sal_uInt16 ConvertHeadingRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt16 nStartHeadRow,sal_uInt16 nEndHeadRow);
+ static bool FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark, sal_uInt8& nMaxColSpan);
+ void SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable> const & pXFTable,
+ sal_uInt8 nFirstColSpann, const sal_uInt8* pCellMark);
+
+ std::map<sal_uInt16,LwpRowLayout*> m_RowsMap;
+ void SplitConflictCells();
+ rtl::Reference<XFTable> m_pXFTable;
+ bool m_bConverted;
+
+ using rt_type = mdds::rtree<int, XFCellListener>;
+ rt_type m_CellsMap;
+
+ void PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID);
+};
+
+/**
+ * @brief
+ * VO_SUPERTABLELAYOUT object
+ */
+class LwpSuperTableLayout: public LwpPlacableLayout
+{
+public:
+ LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpSuperTableLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_SUPERTABLE_LAYOUT;}
+ void RegisterNewStyle();
+ // for table style
+ void ApplyPatternFill(XFTableStyle* pTableStyle);
+ void ApplyBackGround(XFTableStyle* pTableStyle);
+
+ void ApplyBackColor(XFTableStyle *pTableStyle);
+ void ApplyShadow(XFTableStyle *pTableStyle);
+ double GetWidth() override;
+ double GetTableWidth();
+ void ApplyWatermark(XFTableStyle *pTableStyle);
+ void ApplyAlignment(XFTableStyle * pTableStyle);
+ void XFConvert(XFContentContainer* pCont) override;
+ // for frame style
+ virtual void XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart = 0, sal_Int32 nEnd = 0, bool bAll = false) override;
+ void RegisterFrameStyle();
+ LwpTableHeadingLayout* GetTableHeadingLayout();
+protected:
+ void Read() override;
+ LwpTableLayout* GetTableLayout();
+ bool IsSizeRightToContent();
+ bool IsJustifiable();
+ std::unique_ptr<LwpFrame> m_pFrame;
+};
+
+/**
+ * @brief
+ * VO_COLUMNLAYOUT object
+ */
+class LwpColumnLayout : public LwpVirtualLayout
+{
+public:
+ LwpColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpColumnLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_COLUMN_LAYOUT;}
+ sal_uInt32 GetColumnID() const {return ccolid;}
+ double GetWidth() override {return LwpTools::ConvertFromUnitsToMetric(cwidth);}
+ using LwpVirtualLayout::RegisterStyle;
+ void RegisterStyle(double dCalculatedWidth);
+ bool IsJustifiable() const {return (( m_nAttributes2 & STYLE2_JUSTIFIABLE) != 0);}
+protected:
+ void Read() override;
+private:
+ sal_uInt8 ccolid;
+ sal_Int32 cwidth;
+
+};
+/**
+ * @brief
+ * VO_TABLEHEADINGLAYOUT object
+ */
+class LwpTableHeadingLayout : public LwpTableLayout
+{
+public:
+ LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpTableHeadingLayout() override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_TABLE_HEADING_LAYOUT;}
+ void GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow);
+protected:
+ void Read() override;
+private:
+ sal_uInt16 cStartRow;
+ sal_uInt16 cEndRow;
+};
+/**
+ * @brief
+ * VO_SUPERPARALLELCOLUMNLAYOUT object
+ */
+class LwpSuperParallelColumnLayout : public LwpSuperTableLayout
+{
+public:
+ LwpSuperParallelColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpSuperParallelColumnLayout() override;
+protected:
+ void Read() override;
+};
+
+/**
+ * @brief
+ * VO_PCOLLAYOUT object
+ */
+class LwpParallelColumnsLayout : public LwpTableLayout
+{
+public:
+ LwpParallelColumnsLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpParallelColumnsLayout() override;
+protected:
+ void Read() override;
+};
+
+class LwpSuperGlossaryLayout : public LwpSuperTableLayout
+{
+public:
+ LwpSuperGlossaryLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ virtual ~LwpSuperGlossaryLayout() override;
+protected:
+ void Read() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptaboverride.cxx b/lotuswordpro/source/filter/lwptaboverride.cxx
new file mode 100644
index 000000000..40c34abdc
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptaboverride.cxx
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "lwptaboverride.hxx"
+
+LwpTabOverride::LwpTabOverride(LwpTabOverride const& rOther)
+ : LwpOverride(rOther)
+ , m_aTabRackID(rOther.m_aTabRackID)
+{
+}
+
+LwpTabOverride* LwpTabOverride::clone() const { return new LwpTabOverride(*this); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptaboverride.hxx b/lotuswordpro/source/filter/lwptaboverride.hxx
new file mode 100644
index 000000000..f86de477e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptaboverride.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tab override for VO_PARASTYLE.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABOVERRIDE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABOVERRIDE_HXX
+
+#include <lwpoverride.hxx>
+#include <lwpobjid.hxx>
+
+class LwpTabOverride final : public LwpOverride
+{
+public:
+ LwpTabOverride() {}
+
+ virtual LwpTabOverride* clone() const override;
+
+ virtual void Read(LwpObjectStream* pStrm) override
+ {
+ if (pStrm->QuickReadBool())
+ {
+ ReadCommon(pStrm);
+ m_aTabRackID.ReadIndexed(pStrm);
+ }
+
+ pStrm->SkipExtra();
+ }
+
+ inline LwpObjectID& GetTabRackID();
+ inline void Override(LwpTabOverride* pOther);
+
+private:
+ LwpTabOverride(LwpTabOverride const& rOther);
+ LwpTabOverride& operator=(LwpTabOverride const& rOther) = delete;
+
+ LwpObjectID m_aTabRackID;
+ enum
+ {
+ TO_TABRACK = 0x01
+ };
+};
+
+inline LwpObjectID& LwpTabOverride::GetTabRackID() { return m_aTabRackID; }
+
+inline void LwpTabOverride::Override(LwpTabOverride* pOther)
+{
+ if (m_nApply & TO_TABRACK)
+ {
+ if ((m_nOverride & TO_TABRACK) != 0)
+ pOther->m_aTabRackID = GetTabRackID();
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptabrack.cxx b/lotuswordpro/source/filter/lwptabrack.cxx
new file mode 100644
index 000000000..3aea3905e
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptabrack.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tabrack for LwpTabPiece object.
+ ************************************************************************/
+#include "lwptabrack.hxx"
+#include <lwpobjstrm.hxx>
+
+#include <stdexcept>
+
+LwpTab::LwpTab()
+ : m_nX(0),
+ m_nType(0),
+ m_nLeader(0),
+ m_nRelativeType(0),
+ m_nAlignChar(0) //be careful,not quite sure it's 8-bit,perhaps 16-bit.
+{
+}
+
+void LwpTab::Read(LwpObjectStream *pStrm)
+{
+ m_nX = pStrm->QuickReaduInt32();
+ m_nType = pStrm->QuickReaduInt8();
+ m_nLeader = pStrm->QuickReaduInt8();
+ m_nRelativeType = pStrm->QuickReaduInt8();
+ m_nAlignChar = pStrm->QuickReaduInt16();
+}
+
+LwpTabRack::LwpTabRack(LwpObjectHeader objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr,pStrm),
+ m_nNumTabs(0)
+{
+}
+
+void LwpTabRack::Read()
+{
+ m_NextID.ReadIndexed(m_pObjStrm.get());
+
+ m_nNumTabs = m_pObjStrm->QuickReaduInt16();
+ if (m_nNumTabs > MaxTabs)
+ throw std::range_error("corrupt LwpTabRack");
+ for (int i=0; i<m_nNumTabs; ++i)
+ {
+ m_aTabs[i].Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+ m_pObjStrm->SkipExtra();
+}
+
+LwpTab* LwpTabRack::Lookup(sal_uInt16 nIndex)
+{
+ /* Is the tab in this tabrack? */
+ if(nIndex<m_nNumTabs)
+ {
+ return &m_aTabs[nIndex];
+ }
+ //return NULL;
+ /* It's not in this tabrack, so get it out of our next. */
+ if (!GetNext())
+ return nullptr; /* ouch */
+
+ return GetNext()->Lookup(nIndex - m_nNumTabs);
+}
+
+LwpTabRack* LwpTabRack::GetNext()
+{
+ return dynamic_cast<LwpTabRack*>(m_NextID.obj().get());
+}
+
+sal_uInt16 LwpTabRack::GetNumTabs()
+{
+ sal_uInt16 nNum=0;
+ if(GetNext())
+ {
+ nNum = GetNext()->GetNumTabs();
+ }
+ return m_nNumTabs+nNum;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptabrack.hxx b/lotuswordpro/source/filter/lwptabrack.hxx
new file mode 100644
index 000000000..7157e08ab
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptabrack.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tabrack for LwpTabPiece object.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABRACK_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTABRACK_HXX
+
+#include <lwpobj.hxx>
+
+class LwpObjectStream;
+class LwpTab;
+class LwpTabRack;
+
+class LwpTab
+{
+public:
+ LwpTab();
+
+ enum TabType
+ {
+ TT_LEFT = 1,
+ TT_CENTER,
+ TT_RIGHT,
+ TT_NUMERIC
+ };
+
+ enum LeaderType
+ {
+ TL_NONE = 0,
+ TL_HYPHEN,
+ TL_DOT,
+ TL_LINE
+ };
+
+ enum RelativeType
+ {
+ TR_LEFT = 1,
+ TR_RIGHT,
+ TR_CENTER
+ };
+public:
+ void Read(LwpObjectStream *pStrm);
+ inline sal_uInt32 GetPosition() const;
+ sal_uInt8 GetTabType() const
+ {
+ return m_nType;
+ }
+ sal_uInt8 GetLeaderType() const
+ {
+ return m_nLeader;
+ }
+ sal_uInt16 GetAlignChar() const
+ {
+ return m_nAlignChar;
+ }
+private:
+ sal_uInt32 m_nX;
+ sal_uInt8 m_nType;
+ sal_uInt8 m_nLeader;
+ sal_uInt8 m_nRelativeType;
+ sal_uInt16 m_nAlignChar; //be careful
+};
+
+inline sal_uInt32 LwpTab::GetPosition() const
+{
+ return m_nX;
+}
+
+class LwpTabRack : public LwpObject
+{
+public:
+ LwpTabRack(LwpObjectHeader objHdr, LwpSvStream* pStrm);
+public:
+ void Read() override;
+ sal_uInt16 GetNumTabs();
+ LwpTab* Lookup(sal_uInt16 nIndex);
+ LwpTabRack* GetNext();
+private:
+ virtual ~LwpTabRack() override {}
+
+ enum{
+ MaxTabs = 15
+ };
+ sal_uInt16 m_nNumTabs;
+ LwpTab m_aTabs[MaxTabs];
+ LwpObjectID m_NextID;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptblcell.cxx b/lotuswordpro/source/filter/lwptblcell.cxx
new file mode 100644
index 000000000..6831dce23
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptblcell.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table cell numerics format
+ */
+
+#include <lwpfilehdr.hxx>
+#include <lwpobjid.hxx>
+#include "lwptblcell.hxx"
+
+LwpCellList::LwpCellList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+ , cColumn(0)
+{
+}
+
+LwpCellList::~LwpCellList() {}
+
+void LwpCellList::Read()
+{
+ // CDLFVList read construction
+ LwpDLVList::Read();
+
+ LwpDLVListHeadTail cChild;
+ cChild.Read(m_pObjStrm.get());
+
+ cParent.ReadIndexed(m_pObjStrm.get());
+
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ m_pObjStrm->SkipExtra();
+
+ cValue.ReadIndexed(m_pObjStrm.get());
+
+ LwpObjectID cDependent;
+ cDependent.ReadIndexed(m_pObjStrm.get());
+
+ cColumn = static_cast<sal_uInt8>(m_pObjStrm->QuickReaduInt16()); // written as a sal_uInt16
+ // sal_uInt8 cCellFlags = (sal_uInt8) m_pObjStrm->QuickReaduInt16(); // written as a sal_uInt16
+ m_pObjStrm->SeekRel(2); //CellFlags
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpCellList::Parse(IXFStream* /*pOutputStream*/) {}
+
+void LwpCellList::Convert(XFCell* pCell, LwpTableLayout* /*pCellsMap*/)
+{
+ LwpObjectID aValueID = cValue;
+ LwpNumericValue* pValue = dynamic_cast<LwpNumericValue*>(aValueID.obj().get());
+ if (pValue)
+ {
+ pCell->SetValue(pValue->GetValue());
+ }
+}
+
+LwpNumericValue::LwpNumericValue(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+ , cNumber(0)
+{
+}
+
+LwpNumericValue::~LwpNumericValue() {}
+
+void LwpNumericValue::Read()
+{
+ cNumber = m_pObjStrm->QuickReadDouble();
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpNumericValue::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpRowList::LwpRowList(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+ , cRowID(0)
+{
+}
+
+LwpRowList::~LwpRowList() {}
+
+void LwpRowList::Read()
+{
+ // CDLFVList read construction
+ LwpDLVList::Read();
+
+ cChild.Read(m_pObjStrm.get());
+ cParent.ReadIndexed(m_pObjStrm.get());
+
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ m_pObjStrm->SkipExtra();
+
+ cRowID = m_pObjStrm->QuickReaduInt16();
+
+ m_pObjStrm->SkipExtra();
+}
+void LwpRowList::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpTableRange::LwpTableRange(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+{
+}
+
+LwpTableRange::~LwpTableRange() {}
+
+void LwpTableRange::Read()
+{
+ LwpDLVList::Read();
+
+ cqTable.ReadIndexed(m_pObjStrm.get());
+ cpCellRange.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpTableRange::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpCellRange::LwpCellRange(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+{
+}
+
+LwpCellRange::~LwpCellRange() {}
+
+void LwpCellRange::Read()
+{
+ cpFolder.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpCellRange::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpFolder::LwpFolder(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+{
+}
+
+LwpFolder::~LwpFolder() {}
+
+void LwpFolder::Read()
+{
+ // CDLFVList read construction
+ LwpDLVList::Read();
+
+ cChild.Read(m_pObjStrm.get());
+ cParent.ReadIndexed(m_pObjStrm.get());
+
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ m_pObjStrm->SkipExtra();
+
+ cqTable.ReadIndexed(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpFolder::Parse(IXFStream* /*pOutputStream*/) {}
+
+LwpDependent::LwpDependent(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm)
+ , cReferenceOffset(0)
+ , cFlags(0)
+{
+}
+
+LwpDependent::~LwpDependent() {}
+
+void LwpDependent::Read()
+{
+ LwpDLVList::Read();
+
+ cFormulaInfo.ReadIndexed(m_pObjStrm.get());
+ cReferenceOffset = m_pObjStrm->QuickReaduInt16();
+ cFlags = static_cast<sal_uInt8>(m_pObjStrm->QuickReaduInt16()); // Written as lushort.
+
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpDependent::Parse(IXFStream* /*pOutputStream*/) {}
+
+void LwpRowSpecifier::QuickRead(LwpObjectStream* pStrm)
+{
+ cRow = pStrm->QuickReaduInt16();
+ cQualifier.QuickRead(pStrm);
+}
+void LwpColumnSpecifier::QuickRead(LwpObjectStream* pStrm)
+{
+ cColumn = static_cast<sal_uInt8>(pStrm->QuickReaduInt16());
+ cQualifier.QuickRead(pStrm);
+}
+
+void LwpRowColumnQualifier::QuickRead(LwpObjectStream* pStrm)
+{
+ // written as lushort for future flags
+ cFlags = static_cast<sal_uInt8>(pStrm->QuickReaduInt16());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptblcell.hxx b/lotuswordpro/source/filter/lwptblcell.hxx
new file mode 100644
index 000000000..e9def931b
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptblcell.hxx
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table object
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLCELL_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLCELL_HXX
+
+#include <lwpobj.hxx>
+#include "lwpdlvlist.hxx"
+
+#include <xfilter/xfcell.hxx>
+
+// temporarily added for compile
+class LwpObject;
+
+class LwpContent;
+class LwpTableLayout;
+/**
+ * @brief
+ * VO_CELLLIST object
+ */
+class LwpCellList : public LwpDLVList
+{
+public:
+ LwpCellList(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ virtual void Parse(IXFStream* pOutputStream) override;
+ LwpObjectID const & GetNextID(){return GetNext();}
+ sal_uInt8 GetColumnID() const {return cColumn;}
+
+ virtual void Convert(XFCell * pCell, LwpTableLayout* pCellsMap=nullptr);
+protected:
+ virtual ~LwpCellList() override;
+
+ sal_uInt8 cColumn;
+ LwpObjectID cParent;
+
+ void Read() override;
+ LwpObjectID cValue;
+};
+/**
+ * @brief
+ * VO_ROWLIST object
+ */
+class LwpRowList final : public LwpDLVList
+{
+public:
+ LwpRowList(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ void Parse(IXFStream* pOutputStream) override;
+ LwpObjectID const & GetChildHeadID(){return cChild.GetHead();}
+ LwpObjectID const & GetNextID(){return GetNext();}
+ sal_uInt16 GetRowID() const {return cRowID;}
+private:
+ void Read() override;
+ virtual ~LwpRowList() override;
+
+ LwpDLVListHeadTail cChild;
+ LwpObjectID cParent;
+ sal_uInt16 cRowID;
+};
+/**
+ * @brief
+ * VO_NUMERICVALUE object
+ */
+class LwpNumericValue final : public LwpObject
+{
+public:
+ LwpNumericValue(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ double GetValue() const {return cNumber;}
+ void Parse(IXFStream* pOutputStream) override;
+private:
+ void Read() override;
+ virtual ~LwpNumericValue() override;
+
+ double cNumber;
+};
+
+/**
+ * @brief
+ * VO_TABLERANGE object
+ */
+class LwpTableRange final : public LwpDLVList
+{
+public:
+ LwpTableRange(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ void Parse(IXFStream* pOutputStream) override;
+ const LwpObjectID& GetCellRangeID() const {return cpCellRange;}
+ const LwpObjectID& GetTableID() const { return cqTable;}
+ LwpTableRange* GetNext() { return dynamic_cast<LwpTableRange*>(LwpDLVList::GetNext().obj().get());}
+private:
+ void Read() override;
+ virtual ~LwpTableRange() override;
+
+ LwpObjectID cqTable;
+ LwpObjectID cpCellRange;
+};
+/**
+ * @brief
+ * VO_CELLRANGE object
+ */
+class LwpCellRange final : public LwpObject
+{
+public:
+ LwpCellRange(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ void Parse(IXFStream* pOutputStream) override;
+ const LwpObjectID& GetFolderID() const {return cpFolder;}
+private:
+ void Read() override;
+ virtual ~LwpCellRange() override;
+
+ LwpObjectID cpFolder;
+};
+/**
+ * @brief
+ * VO_FOLDER object
+ */
+class LwpFolder final : public LwpDLVList
+{
+public:
+ LwpFolder(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ void Parse(IXFStream* pOutputStream) override;
+ LwpObjectID const & GetChildHeadID(){ return cChild.GetHead();}
+private:
+ void Read() override;
+ virtual ~LwpFolder() override;
+
+ LwpDLVListHeadTail cChild;
+ LwpObjectID cParent;
+ LwpObjectID cqTable;
+};
+/**
+ * @brief
+ * VO_DEPENDENT object
+ */
+class LwpDependent final : public LwpDLVList
+{
+public:
+ LwpDependent(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+
+ void Parse(IXFStream* pOutputStream) override;
+private:
+ void Read() override;
+ virtual ~LwpDependent() override;
+
+ LwpObjectID cFormulaInfo;
+ sal_uInt16 cReferenceOffset; // Used to fix dependent formula when we're
+ // dropped, sorted.
+ // Flags:
+ enum
+ {
+ START_CELL = 0x01,
+ END_CELL = 0x02,
+ REGISTERED = 0x04
+ };
+ sal_uInt8 cFlags; // Used to fix dependent formula when we're
+ // dropped, sorted.
+};
+
+/**
+ * @brief
+ * row or column id
+ */
+class LwpRowColumnQualifier
+{
+public:
+ LwpRowColumnQualifier();
+
+ bool IsAbsolute() const;
+
+ bool IsAfter() const;
+
+ bool IsBad() const;
+
+ void QuickRead(LwpObjectStream *pStrm);
+
+private:
+ enum // cFlags bit definitions
+ {
+ REF_ABSOLUTE = 0x01,
+ REF_AFTER = 0x02,
+ REF_BAD = 0x04
+ };
+ sal_uInt8 cFlags;
+};
+
+inline
+LwpRowColumnQualifier::LwpRowColumnQualifier() : cFlags(0)
+{
+}
+
+inline bool
+LwpRowColumnQualifier::IsAfter() const
+{
+ return (cFlags & REF_AFTER) != 0;
+}
+
+inline bool
+LwpRowColumnQualifier::IsBad() const
+{
+ return (cFlags & REF_BAD) != 0;
+}
+
+inline bool
+LwpRowColumnQualifier::IsAbsolute() const
+{
+ return (cFlags & REF_ABSOLUTE) != 0;
+}
+/**
+ * @brief
+ * row id
+ */
+class LwpRowSpecifier
+{
+public:
+ LwpRowSpecifier()
+ : cRow(0)
+ {}
+
+ void QuickRead(LwpObjectStream *pStrm);
+
+ sal_uInt16 RowID(sal_uInt16 FormulaRow);
+
+private:
+ sal_uInt16 cRow;
+ LwpRowColumnQualifier cQualifier;
+};
+
+inline sal_uInt16
+LwpRowSpecifier::RowID(sal_uInt16 FormulaRow)
+{
+ if (cQualifier.IsBad())
+ {
+ return 0xffff;
+ }
+ if (cQualifier.IsAbsolute())
+ return cRow;
+
+ if (cQualifier.IsAfter())
+ return FormulaRow + cRow;
+ return FormulaRow - cRow;
+}
+
+/**
+ * @brief
+ * column id
+ */
+class LwpColumnSpecifier
+{
+public:
+ LwpColumnSpecifier()
+ : cColumn(0)
+ {}
+
+ void QuickRead(LwpObjectStream *pStrm);
+
+ sal_uInt8 ColumnID(sal_uInt8 FormulaColumn);
+
+private:
+ sal_uInt8 cColumn;
+ LwpRowColumnQualifier cQualifier;
+};
+
+inline sal_uInt8
+LwpColumnSpecifier::ColumnID(sal_uInt8 FormulaColumn)
+{
+ if (cQualifier.IsBad())
+ {
+ return 0xff;
+ }
+ if (cQualifier.IsAbsolute())
+ return cColumn;
+ if (cQualifier.IsAfter())
+ return FormulaColumn + cColumn;
+ return FormulaColumn - cColumn;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
new file mode 100644
index 000000000..bec6bcf74
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -0,0 +1,575 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table cell numerics format
+ */
+
+#include "lwptblcell.hxx"
+#include "lwppara.hxx"
+#include "lwptblformula.hxx"
+
+#include "lwptablelayout.hxx"
+#include <osl/thread.h>
+#include <rtl/ustrbuf.hxx>
+#include <sal/log.hxx>
+#include <memory>
+
+LwpFormulaArg::~LwpFormulaArg()
+{
+}
+
+ LwpFormulaInfo::LwpFormulaInfo(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpCellList(objHdr, pStrm)
+ , m_bSupported(true)
+ , m_nFormulaRow(0)
+{}
+
+LwpFormulaInfo::~LwpFormulaInfo()
+{
+}
+
+void LwpFormulaInfo::ReadConst()
+{
+ double Constant = m_pObjStrm->QuickReadDouble();
+
+ m_aStack.push_back( std::make_unique<LwpFormulaConst>(Constant) );
+}
+
+/**
+* Need more effort for unicode.
+*/
+void LwpFormulaInfo::ReadText()
+{
+ m_pObjStrm->QuickReadInt16(); //Disk Size
+ sal_uInt16 nStrLen = m_pObjStrm->QuickReadInt16();
+
+ std::vector<char> aBuf(nStrLen + 1);
+ m_pObjStrm->QuickRead(aBuf.data(), nStrLen);
+ aBuf[nStrLen]= '\0';
+ OUString aText = "\"" +
+ OUString(aBuf.data(), nStrLen, osl_getThreadTextEncoding()) +
+ "\"";
+
+ m_aStack.push_back(std::make_unique<LwpFormulaText>(aText));
+}
+
+void LwpFormulaInfo::ReadCellID()
+{
+ LwpRowSpecifier RowSpecifier;
+ LwpColumnSpecifier ColumnSpecifier;
+
+ RowSpecifier.QuickRead(m_pObjStrm.get());
+ ColumnSpecifier.QuickRead(m_pObjStrm.get());
+
+ m_aStack.push_back( std::make_unique<LwpFormulaCellAddr>(ColumnSpecifier.ColumnID(cColumn),
+ RowSpecifier.RowID(m_nFormulaRow)) );
+}
+
+void LwpFormulaInfo::ReadCellRange()
+{
+ ReadCellID( ); // start
+ std::unique_ptr<LwpFormulaCellAddr> pStartCellAddr( static_cast<LwpFormulaCellAddr*>(m_aStack.back().release()));
+ m_aStack.pop_back();
+
+ ReadCellID(); // end
+ std::unique_ptr<LwpFormulaCellAddr> pEndCellAddr(static_cast<LwpFormulaCellAddr*>(m_aStack.back().release()));
+ m_aStack.pop_back();
+
+ m_aStack.push_back( std::make_unique<LwpFormulaCellRangeAddr>(pStartCellAddr->GetCol(),
+ pStartCellAddr->GetRow(),
+ pEndCellAddr->GetCol(),
+ pEndCellAddr->GetRow()) );
+}
+
+/**
+* Read expression from wordpro file
+*/
+void LwpFormulaInfo::ReadExpression()
+{
+ sal_uInt16 TokenType, DiskLength;
+
+ /* Read the compiled expression length */
+ m_pObjStrm->SeekRel(2);
+
+ bool bError = false;
+ while ((TokenType = m_pObjStrm->QuickReaduInt16(&bError)) != TK_END)
+ {
+
+ if (bError)
+ throw std::runtime_error("error reading expression");
+
+ // Get the disk length of this token
+ DiskLength = m_pObjStrm->QuickReaduInt16();
+
+ switch (TokenType)
+ {
+ case TK_CONSTANT:
+ {
+ ReadConst();
+ break;
+ }
+
+ case TK_CELLID:
+ ReadCellID();
+ break;
+
+ case TK_CELLRANGE:
+ ReadCellRange();
+ break;
+
+ case TK_SUM:
+ case TK_IF:
+ case TK_COUNT:
+ case TK_MINIMUM:
+ case TK_MAXIMUM:
+ case TK_AVERAGE:
+ {
+ std::unique_ptr<LwpFormulaFunc> xFunc(new LwpFormulaFunc(TokenType));
+ ReadArguments(*xFunc);
+ m_aStack.push_back(std::move(xFunc));
+ }
+ break;
+
+ case TK_ADD://7
+ case TK_SUBTRACT:
+ case TK_MULTIPLY:
+ case TK_DIVIDE:
+ case TK_LESS:
+ case TK_LESS_OR_EQUAL:
+ case TK_GREATER:
+ case TK_GREATER_OR_EQUAL:
+ case TK_EQUAL:
+ case TK_NOT_EQUAL:
+ case TK_AND:
+ case TK_OR:
+ case TK_NOT:
+ m_pObjStrm->SeekRel(DiskLength); // extensible for future
+
+ if (m_aStack.size() >= 2)
+ {//binary operator
+ std::unique_ptr<LwpFormulaOp> pOp(new LwpFormulaOp(TokenType));
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ m_aStack.push_back(std::move(pOp));
+ }
+ break;
+ case TK_UNARY_MINUS:
+ if (!m_aStack.empty())
+ {
+ std::unique_ptr<LwpFormulaUnaryOp> pOp(new LwpFormulaUnaryOp(TokenType));
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ m_aStack.push_back(std::move(pOp));
+ }
+ break;
+ default:
+ // We don't know what to do with this token, so eat it.
+ m_pObjStrm->SeekRel(DiskLength);
+ break;
+ }
+ MarkUnsupported(TokenType);
+ }
+}
+
+void LwpFormulaInfo::MarkUnsupported(sal_uInt16 TokenType)
+{
+ switch(TokenType)
+ {
+ case TK_IF:
+ case TK_COUNT:
+ case TK_NOT:
+ {
+ m_bSupported = false;//Not supported formulas
+ }
+ break;
+ default:
+ break;
+ }
+}
+/**
+* Read arguments of functions from wordpro file
+* @param LwpFormulaFunc& aFunc, functions object
+*/
+void LwpFormulaInfo::ReadArguments(LwpFormulaFunc& aFunc)
+{
+ sal_uInt16 NumberOfArguments = m_pObjStrm->QuickReaduInt16();
+
+ for (sal_uInt16 Count = 0; Count < NumberOfArguments; Count++)
+ {
+ sal_uInt8 ArgumentType = static_cast<sal_uInt8>(m_pObjStrm->QuickReaduInt16()); // written as lushort
+ sal_uInt16 ArgumentDiskLength = m_pObjStrm->QuickReaduInt16();
+ bool bArgument = true;
+
+ switch(ArgumentType)
+ {
+ case TK_CELLID:
+ ReadCellID();
+ break;
+
+ case TK_CELLRANGE:
+ ReadCellRange();
+ break;
+
+ case TK_CONSTANT:
+ ReadConst();
+ break;
+
+ case TK_TEXT:
+ ReadText();
+ break;
+
+ case TK_EXPRESSION:
+ ReadExpression();
+ break;
+
+ default:
+ bArgument = false;
+ m_pObjStrm->SeekRel(ArgumentDiskLength);
+ break;
+ }
+
+ if (bArgument && !m_aStack.empty())
+ {
+ aFunc.AddArg(std::move(m_aStack.back()));
+ m_aStack.pop_back();
+ }
+ }
+}
+
+void LwpFormulaInfo::Read()
+{
+ LwpCellList::Read();
+ {
+ LwpRowList* pRowList = dynamic_cast<LwpRowList*>(cParent.obj().get());
+ if (pRowList)
+ {
+ m_nFormulaRow = pRowList->GetRowID();
+ }
+ else
+ {
+ SAL_WARN("lwp", "missing row list");
+ }
+ }
+ m_pObjStrm->SeekRel(2);//flags, size in file: sal_uInt16
+
+ LwpNotifyListPersistent cNotifyList;
+ cNotifyList.Read(m_pObjStrm.get());
+
+ ReadExpression();
+
+ m_pObjStrm->SkipExtra();
+}
+
+/**
+* Make the formula string.
+*/
+OUString LwpFormulaInfo::Convert(LwpTableLayout* pCellsMap)
+{
+ OUString aFormula;
+ if (m_bSupported)
+ {
+ if(1==m_aStack.size())
+ {
+ aFormula = m_aStack[0]->ToString(pCellsMap);
+ }
+ else
+ {
+ assert(false);
+ }
+ }
+ return aFormula;
+}
+
+/**
+* Fill the XFCell content
+*/
+void LwpFormulaInfo::Convert(XFCell * pCell,LwpTableLayout* pCellsMap)
+{
+ OUString aFormula = Convert(pCellsMap);
+ if (!aFormula.isEmpty())
+ {
+ pCell->SetFormula(aFormula);
+ }
+ LwpCellList::Convert(pCell);
+}
+
+LwpFormulaConst::LwpFormulaConst(double dVal)
+{
+ m_dVal = dVal;
+}
+
+OUString LwpFormulaConst::ToString(LwpTableLayout* /*pCellsMap*/)
+{
+ return OUString::number(m_dVal);
+}
+
+LwpFormulaText::LwpFormulaText( const OUString& aText) : m_aText(aText)
+{
+}
+
+LwpFormulaCellAddr::LwpFormulaCellAddr(sal_Int16 aCol, sal_Int16 aRow)
+ : m_aCol(aCol), m_aRow(aRow)
+{
+}
+
+OUString LwpFormulaCellAddr::ToString(LwpTableLayout* pCellsMap)
+{
+ OUString aCellAddr = "<" + LwpFormulaTools::GetCellAddr(m_aRow,m_aCol,pCellsMap) + ">";
+ return aCellAddr;
+}
+
+LwpFormulaCellRangeAddr::LwpFormulaCellRangeAddr(sal_Int16 aStartCol,
+ sal_Int16 aStartRow,
+ sal_Int16 aEndCol,
+ sal_Int16 aEndRow)
+ : m_aStartCol(aStartCol), m_aStartRow(aStartRow),
+ m_aEndCol(aEndCol), m_aEndRow(aEndRow)
+{
+}
+
+/**
+* Convert the cell range into a string
+*/
+OUString LwpFormulaCellRangeAddr::ToString(LwpTableLayout* pCellsMap)
+{
+ OUString aCellAddr = "<"
+ + LwpFormulaTools::GetCellAddr(m_aStartRow,m_aStartCol,pCellsMap) + ":"
+ + LwpFormulaTools::GetCellAddr(m_aEndRow,m_aEndCol,pCellsMap) + ">";
+
+ return aCellAddr;
+}
+
+LwpFormulaFunc::LwpFormulaFunc(sal_uInt16 nTokenType) : m_nTokenType(nTokenType)
+{
+}
+
+LwpFormulaFunc::~LwpFormulaFunc()
+{
+}
+void LwpFormulaFunc::AddArg(std::unique_ptr<LwpFormulaArg> pArg)
+{
+ m_aArgs.push_back(std::move(pArg));
+}
+/**
+* Convert the functions to a string, which is an argument of other formula
+*/
+OUString LwpFormulaFunc::ToArgString(LwpTableLayout* pCellsMap)
+{
+ return "(" + ToString(pCellsMap) + ")";
+}
+/**
+* Convert the function to a formula string.
+*/
+OUString LwpFormulaFunc::ToString(LwpTableLayout* pCellsMap)
+{
+ OUStringBuffer aFormula;
+
+ OUString aFuncName = LwpFormulaTools::GetName(m_nTokenType);
+ aFormula.append(aFuncName +
+ " ");//Append a blank space
+
+ //Append args
+ for (auto const& elem : m_aArgs)
+ {
+ aFormula.append(elem->ToArgString(pCellsMap) + "|"); //separator
+ }
+
+ //erase the last "|"
+ if (!m_aArgs.empty())
+ {
+ aFormula.setLength(aFormula.getLength()-1);
+ }
+ else
+ {
+ assert(false);
+ }
+
+ return aFormula.makeStringAndClear();
+}
+
+/**
+* Convert the formula in operators to a string : e.g. 1+2+3
+*/
+OUString LwpFormulaOp::ToString(LwpTableLayout* pCellsMap)
+{
+ OUString aFormula;
+ if (2==m_aArgs.size())
+ {
+ aFormula += m_aArgs[1]->ToArgString(pCellsMap) + " ";
+ OUString aFuncName = LwpFormulaTools::GetName(m_nTokenType);
+
+ aFormula += aFuncName + " " +
+ m_aArgs[0]->ToArgString(pCellsMap);
+ }
+ else
+ {
+ assert(false);
+ }
+ return aFormula;
+}
+
+/**
+* convert the formula in unary operators into string : e.g. -2
+*/
+OUString LwpFormulaUnaryOp::ToString(LwpTableLayout* pCellsMap)
+{
+ OUString aFormula;
+ if (1==m_aArgs.size())
+ {
+ OUString aFuncName = LwpFormulaTools::GetName(m_nTokenType);
+ aFormula += aFuncName +
+ m_aArgs[0]->ToArgString(pCellsMap);
+ }
+ else
+ {
+ assert(false);
+ }
+ return aFormula;
+}
+/**
+* Get token name
+*/
+OUString LwpFormulaTools::GetName(sal_uInt16 nTokenType)
+{
+ OUString aName;
+ switch(nTokenType)
+ {
+ case TK_SUM:
+ aName = "SUM";
+ break;
+ case TK_IF:
+ aName = "IF";//Not supported by SODC
+ break;
+ case TK_COUNT:
+ aName = "COUNT";//Not supported by SODC
+ break;
+ case TK_MINIMUM:
+ aName = "MIN";
+ break;
+ case TK_MAXIMUM:
+ aName = "MAX";
+ break;
+ case TK_AVERAGE:
+ aName = "MEAN";
+ break;
+ case TK_ADD:
+ aName = "+";
+ break;
+ case TK_SUBTRACT:
+ aName = "-";
+ break;
+ case TK_MULTIPLY:
+ aName = "*";
+ break;
+ case TK_DIVIDE:
+ aName = "/";
+ break;
+ case TK_UNARY_MINUS:
+ aName = "-";
+ break;
+ case TK_LESS:
+ aName = "L";
+ break;
+ case TK_LESS_OR_EQUAL:
+ aName = "LEQ";
+ break;
+ case TK_GREATER:
+ aName = "G";
+ break;
+ case TK_GREATER_OR_EQUAL:
+ aName = "GEQ";
+ break;
+ case TK_EQUAL:
+ aName = "EQ";
+ break;
+ case TK_NOT_EQUAL:
+ aName = "NEQ";
+ break;
+ case TK_NOT:
+ aName = "NOT";
+ break;
+ case TK_AND:
+ aName = "AND";
+ break;
+ case TK_OR:
+ aName = "OR";
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ return aName;
+}
+
+/**
+* Get cell address in String
+*/
+OUString LwpFormulaTools::GetCellAddr(sal_Int16 nRow, sal_Int16 nCol, LwpTableLayout* pCellsMap)
+{
+ OUString aCellAddr;
+ XFCell* pCell = pCellsMap->GetCellsMap(nRow,static_cast<sal_uInt8>(nCol));
+ if (pCell)
+ {
+ aCellAddr = pCell->GetCellName();
+ }
+ else
+ {
+ assert( -1==nRow || -1==static_cast<sal_Int8>(nCol));
+ }
+ return aCellAddr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptblformula.hxx b/lotuswordpro/source/filter/lwptblformula.hxx
new file mode 100644
index 000000000..ee90e1944
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptblformula.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - table object
+ */
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTBLFORMULA_HXX
+
+#include <rtl/ustring.hxx>
+#include <memory>
+#include <vector>
+#include "lwptblcell.hxx"
+
+/* These token types are written to the file. Don't change their
+values unless you filter them.
+*/
+enum lTokenType
+{
+ TK_BAD = 0,
+ TK_OPERAND = 1,
+ TK_END = 2,
+ TK_RIGHTPAREN = 3,
+ TK_FUNCTION = 4,
+ TK_LEFTPAREN = 5,
+ TK_UNARY_MINUS = 6,
+ TK_ADD = 7,
+ TK_SUBTRACT = 8,
+ TK_MULTIPLY = 9,
+ TK_DIVIDE = 10,
+ TK_EQUAL = 11,
+ TK_LESS = 12,
+ TK_GREATER = 13,
+ TK_NOT_EQUAL = 14,
+ TK_GREATER_OR_EQUAL = 15,
+ TK_LESS_OR_EQUAL = 16,
+ TK_NOT = 17,
+ TK_AND = 18,
+ TK_OR = 19,
+ TK_CELLID = 20,
+ TK_CONSTANT = 21,
+ TK_TEXT = 22,
+ TK_SUM = 23,
+ TK_IF = 24,
+ TK_AVERAGE = 25,
+ TK_MAXIMUM = 26,
+ TK_MINIMUM = 27,
+ TK_COUNT = 28,
+ TK_CELLRANGE = 29,
+ TK_EXPRESSION = 30,
+ TK_OPEN_FUNCTION = 31,
+ TK_LIST_SEPARATOR = 32
+};
+class LwpTableLayout;
+class LwpFormulaArg
+{
+public:
+ virtual ~LwpFormulaArg() = 0;
+ virtual OUString ToString(LwpTableLayout* pCellsMap)=0;
+ virtual OUString ToArgString(LwpTableLayout* pCellsMap){ return ToString(pCellsMap);}
+};
+
+class LwpFormulaTools
+{
+public:
+ static OUString GetName(sal_uInt16 nTokenType);
+ static OUString GetCellAddr(sal_Int16 nRow, sal_Int16 nCol, LwpTableLayout* pCellsMap);
+};
+
+class LwpFormulaConst:public LwpFormulaArg
+{
+public:
+ explicit LwpFormulaConst( double dVal);
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+private:
+ double m_dVal;
+};
+
+class LwpFormulaText:public LwpFormulaArg
+{
+public:
+ explicit LwpFormulaText( const OUString& aText);
+ virtual OUString ToString(LwpTableLayout* /*pCellsMap*/) override {return m_aText;}
+private:
+ OUString m_aText;
+};
+
+class LwpFormulaCellAddr:public LwpFormulaArg
+{
+public:
+ LwpFormulaCellAddr(sal_Int16 aCol, sal_Int16 aRow);
+
+ sal_Int16 GetCol() const {return m_aCol;}
+ sal_Int16 GetRow() const {return m_aRow;}
+
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+private:
+ sal_Int16 m_aCol;
+ sal_Int16 m_aRow;
+};
+
+class LwpFormulaCellRangeAddr:public LwpFormulaArg
+{
+public:
+ LwpFormulaCellRangeAddr(sal_Int16 aStartCol, sal_Int16 aStartRow, sal_Int16 aEndCol, sal_Int16 aEndRow);
+
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+private:
+ sal_Int16 m_aStartCol;
+ sal_Int16 m_aStartRow;
+ sal_Int16 m_aEndCol;
+ sal_Int16 m_aEndRow;
+};
+
+class LwpFormulaFunc :public LwpFormulaArg
+{
+public:
+ explicit LwpFormulaFunc(sal_uInt16 nTokenType);
+ virtual ~LwpFormulaFunc() override;
+
+ void AddArg(std::unique_ptr<LwpFormulaArg> pArg);
+
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+ OUString ToArgString(LwpTableLayout* pCellsMap) override;
+
+protected:
+ std::vector<std::unique_ptr<LwpFormulaArg>> m_aArgs;
+ sal_uInt16 m_nTokenType;
+};
+
+class LwpFormulaOp : public LwpFormulaFunc
+{
+public:
+ explicit LwpFormulaOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){}
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+};
+
+class LwpFormulaUnaryOp : public LwpFormulaFunc
+{
+public:
+ explicit LwpFormulaUnaryOp(sal_uInt16 nTokenType):LwpFormulaFunc(nTokenType){}
+ virtual OUString ToString(LwpTableLayout* pCellsMap) override;
+};
+
+class LwpFormulaInfo final : public LwpCellList
+{
+public:
+ LwpFormulaInfo(LwpObjectHeader const &objHdr, LwpSvStream* pStrm);
+ OUString Convert(LwpTableLayout* pCellsMap);
+ void Convert(XFCell * pCell, LwpTableLayout* pCellsMap=nullptr) override;
+private:
+ void Read() override;
+ void ReadCellID();
+ void ReadText();
+ void ReadCellRange();
+ void ReadExpression();
+ void ReadArguments(LwpFormulaFunc& aFunc);
+ bool m_bSupported;
+ virtual ~LwpFormulaInfo() override;
+ void ReadConst();
+ void MarkUnsupported(sal_uInt16 TokenType);
+
+ std::vector<std::unique_ptr<LwpFormulaArg>> m_aStack;
+ sal_uInt16 m_nFormulaRow;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx
new file mode 100644
index 000000000..9268f8e33
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptoc.cxx
@@ -0,0 +1,471 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/**
+ * @file
+ * For LWP filter architecture prototype - TOC related object
+ */
+
+#include "lwptoc.hxx"
+#include <lwpfoundry.hxx>
+#include "lwpdoc.hxx"
+#include "lwpframelayout.hxx"
+#include <lwpglobalmgr.hxx>
+
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xfindex.hxx>
+#include <xfilter/xffloatframe.hxx>
+#include <xfilter/xfframe.hxx>
+
+LwpTocSuperLayout::LwpTocSuperLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpSuperTableLayout(objHdr, pStrm)
+ , m_nFrom(0)
+ , m_pCont(nullptr)
+{
+}
+
+LwpTocSuperLayout::~LwpTocSuperLayout()
+{
+}
+
+/**
+ * @short Read TOCSUPERTABLELAYOUT object
+ * @return none
+ */
+void LwpTocSuperLayout::Read()
+{
+ LwpSuperTableLayout::Read();
+ m_TextMarker.Read(m_pObjStrm.get());
+ m_ParentName.Read(m_pObjStrm.get());
+ m_DivisionName.Read(m_pObjStrm.get());
+ m_SectionName.Read(m_pObjStrm.get());
+ m_nFrom = m_pObjStrm->QuickReaduInt16();
+
+ m_SearchItems.Read(m_pObjStrm.get());
+
+ sal_uInt16 count = m_pObjStrm->QuickReaduInt16();
+ if (count > MAX_LEVELS)
+ throw std::range_error("corrupt LwpTocSuperLayout");
+ for (sal_uInt16 i = 0; i < count; ++i)
+ m_DestName[i].Read(m_pObjStrm.get());
+
+ count = m_pObjStrm->QuickReaduInt16();
+ if (count > MAX_LEVELS)
+ throw std::range_error("corrupt LwpTocSuperLayout");
+ for (sal_uInt16 i = 0; i < count; ++i)
+ m_DestPGName[i].Read(m_pObjStrm.get());
+
+ count = m_pObjStrm->QuickReaduInt16();
+ if (count > MAX_LEVELS)
+ throw std::range_error("corrupt LwpTocSuperLayout");
+ for (sal_uInt16 i = 0; i < count; ++i)
+ m_nFlags[i] = m_pObjStrm->QuickReaduInt32();
+
+ m_pObjStrm->SkipExtra();
+}
+/**
+ * @short Register style of TOC
+ * @return none
+ */
+void LwpTocSuperLayout::RegisterStyle()
+{
+ LwpSuperTableLayout::RegisterStyle();
+
+ // Get font info of default text style and set into tab style
+ const LwpObjectID *pDefaultTextStyle = m_pFoundry ? m_pFoundry->GetDefaultTextStyle() : nullptr;
+ XFParaStyle* pBaseStyle = pDefaultTextStyle ? dynamic_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*pDefaultTextStyle)) : nullptr;
+ std::unique_ptr<XFTextStyle> pTextStyle(new XFTextStyle);
+ if (pBaseStyle)
+ pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_TabStyleName = pXFStyleManager->AddStyle(std::move(pTextStyle)).m_pStyle->GetStyleName();
+
+}
+/**
+ * @short Convert TOC
+ * @param pCont - container
+ * @return none
+ */
+void LwpTocSuperLayout::XFConvert(XFContentContainer* pCont)
+{
+ rtl::Reference<XFIndex> xToc(new XFIndex);
+
+ xToc->SetProtected(false);
+ xToc->SetIndexType(enumXFIndexTOC);
+
+ // add TOC template
+ for (sal_uInt16 i = 1; i<= MAX_LEVELS; i++)
+ {
+ LwpTocLevelData * pLevel = GetSearchLevelPtr(i);
+ XFIndexTemplate * pTemplate = new XFIndexTemplate();
+
+ if(!pLevel)
+ {
+ // add a blank template so that SODC won't add default style to this level
+ xToc->AddTemplate(OUString::number(i), OUString(), pTemplate);
+ continue;
+ }
+
+ bool bInserted = false;
+ do
+ {
+ // One level has 1 template
+ if (!bInserted)
+ {
+ pTemplate->SetLevel(OUString::number(i));
+ if(pLevel->GetUseLeadingText())
+ {
+ pTemplate->AddEntry(enumXFIndexTemplateChapter, pLevel->GetSearchStyle());
+ }
+ if(pLevel->GetUseText())
+ {
+ pTemplate->AddEntry(enumXFIndexTemplateText, pLevel->GetSearchStyle());
+ }
+ if(GetUsePageNumber(i))
+ {
+ sal_uInt16 nLeaderType = GetSeparatorType(i);
+ if (GetRightAlignPageNumber(i))
+ {
+ char cSep = ' ';
+ switch(nLeaderType)
+ {
+ default: // go through
+ case NONE: // no leaders
+ cSep = ' ';
+ break;
+ case LEADERDOTS:
+ cSep = '.';
+ break;
+ case LEADERDASHES:
+ cSep = '-';
+ break;
+ case LEADERUNDERLINE:
+ cSep = '_';
+ break;
+ }
+
+ pTemplate->AddTabEntry(enumXFTabRight, 0, cSep, 'd', m_TabStyleName);
+ }
+ else
+ {
+ OUString sSep;
+ switch(nLeaderType)
+ {
+ default: // go through
+ case NONE: // no leaders
+ sSep = " ";
+ break;
+ case SEPARATORCOMMA:
+ sSep = ", ";
+ break;
+ case SEPARATORDOTS:
+ sSep = "...";
+ break;
+ }
+ pTemplate->AddTextEntry(sSep, m_TabStyleName);
+ }
+ //"TOC Page Number Text Style" style always exists in Word Pro file
+ pTemplate->AddEntry(enumXFIndexTemplatePage, "TOC Page Number Text Style");
+ }
+
+ xToc->AddTemplate(OUString::number(static_cast<sal_Int32>(i)), m_pFoundry->FindActualStyleName(pLevel->GetSearchStyle()), pTemplate);
+ bInserted = true;
+ }
+
+ // 1 style in WordPro may be mapped to several styles in SODC
+ LwpDocument * pDocument = m_pFoundry->GetDocument()->GetRootDocument();
+ AddSourceStyle(xToc.get(), pLevel, pDocument->GetFoundry());
+
+ // one level may have several corresponding Styles
+ pLevel = GetNextSearchLevelPtr(i, pLevel); // find next LwpTocLevelData which is same index
+ }while (pLevel != nullptr);
+ }
+
+ m_pCont = pCont;
+ // add TOC content
+ LwpSuperTableLayout::XFConvert(xToc.get());
+
+ rtl::Reference<LwpVirtualLayout> xContainer(GetContainerLayout());
+ if (!xContainer.is())
+ return;
+
+ // if current TOC is located in a cell, we must add a frame between upper level container and TOC
+ if (!xContainer->IsCell())
+ {
+ pCont->Add(xToc.get());
+ }
+}
+
+/**
+ * @short convert frame which anchor to page
+ * @param pCont -
+ * @return
+ */
+void LwpTocSuperLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll)
+{
+ if (!m_pFrame)
+ return;
+
+ rtl::Reference<XFFrame> xXFFrame;
+ if(nEnd < nStart)
+ {
+ xXFFrame.set(new XFFrame);
+ }
+ else
+ {
+ xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
+ }
+
+ m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
+
+ //parse table, and add table to frame or TOC
+ LwpTableLayout * pTableLayout = GetTableLayout();
+ if (!pTableLayout)
+ return;
+
+ XFContentContainer* pTableContainer = xXFFrame.get();
+ // if *this is a TOCSuperTableLayout and it's located in a cell
+ // add the frame to upper level and add TOCSuperTableLayout into the frame
+ rtl::Reference<LwpVirtualLayout> xContainer(GetContainerLayout());
+ if (!xContainer.is())
+ return;
+ if (xContainer->IsCell())
+ {
+ pTableContainer = pCont; // TOC contain table directly
+ xXFFrame->Add(pCont);
+ m_pCont->Add(xXFFrame.get());
+ }
+ else
+ {
+ //add frame to the container
+ pCont->Add(xXFFrame.get());
+ }
+ pTableLayout->XFConvert(pTableContainer);
+
+}
+
+/**
+ * @short Add source style into TOC
+ * @param pToc - TOC pointer
+ * @param pLevel - TOC level data
+ * @param pFoundry - foundry pointer
+ * @return sal_Bool
+ */
+void LwpTocSuperLayout::AddSourceStyle(XFIndex* pToc, LwpTocLevelData * pLevel, LwpFoundry * pFoundry)
+{
+ if (!pLevel)
+ {
+ return;
+ }
+
+ OUString sLwpStyleName = pLevel->GetSearchStyle();
+
+ if (!pFoundry)
+ return;
+
+ LwpDocument * pDoc = pFoundry->GetDocument();
+ if (pDoc && pDoc->IsChildDoc())
+ {
+ OUString sSodcStyleName = pFoundry->FindActualStyleName(sLwpStyleName);
+ pToc->AddTocSource(pLevel->GetLevel(), sSodcStyleName);
+ }
+ else
+ {
+ pDoc = pDoc->GetFirstDivision();
+ while (pDoc)
+ {
+ AddSourceStyle(pToc, pLevel, pDoc->GetFoundry() );
+ pDoc = pDoc->GetNextDivision();
+ }
+ }
+}
+
+/**
+ * @short Get whether page number is right alignment
+ * @param index - TOC level
+ * @return sal_Bool
+ */
+bool LwpTocSuperLayout::GetRightAlignPageNumber(sal_uInt16 index)
+{
+ if (index < MAX_LEVELS)
+ return (m_nFlags[index] & TS_RIGHTALIGN) != 0;
+ return false;
+}
+/**
+ * @short Get whether page number is used in TOC entries
+ * @param index - TOC level
+ * @return sal_Bool
+ */
+bool LwpTocSuperLayout::GetUsePageNumber(sal_uInt16 index)
+{
+ if (index < MAX_LEVELS)
+ return (m_nFlags[index] & TS_PAGENUMBER) != 0;
+ return false;
+}
+/**
+ * @short Get what is used for separator
+ * @param index - TOC level
+ * @return sal_uInt16 - separator type
+ */
+sal_uInt16 LwpTocSuperLayout::GetSeparatorType(sal_uInt16 index)
+{
+ if (index >= MAX_LEVELS)
+ return NONE;
+
+ sal_uInt16 Flag = static_cast<sal_uInt16>(m_nFlags[index]);
+
+ if (Flag & TS_LEADERDOTS)
+ return LEADERDOTS;
+ else if (Flag & TS_LEADERDASHES)
+ return LEADERDASHES;
+ else if (Flag & TS_LEADERUNDERLINE)
+ return LEADERUNDERLINE;
+ else if (Flag & TS_SEPARATORCOMMA)
+ return SEPARATORCOMMA;
+ else if (Flag & TS_SEPARATORDOTS)
+ return SEPARATORDOTS;
+ else
+ return NONE;
+}
+
+/**
+ * @short Get TOCLEVELDATA obj
+ * @param index - TOC level
+ * @return LwpTocLevelData * - pointer to TOCLEVELDATA obj
+ */
+LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index)
+{
+ LwpObjectID * pID = &m_SearchItems.GetHead(); // not necessary to check pID NULL or not
+ LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
+
+ while(pObj)
+ {
+ if(pObj->GetLevel()== index)
+ {
+ return pObj;
+ }
+
+ pID = &pObj->GetNext(); // not necessary to check pID NULL or not
+ pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
+ }
+
+ return nullptr;
+}
+/**
+ * @short Get next TOCLEVELDATA obj from current position
+ * @param index - TOC level
+ * @param pCurData - current LwpTocLevelData
+ * @return LwpTocLevelData * - pointer to TOCLEVELDATA obj
+ */
+LwpTocLevelData * LwpTocSuperLayout::GetNextSearchLevelPtr(sal_uInt16 index, LwpTocLevelData * pCurData)
+{
+ LwpObjectID * pID = &pCurData->GetNext();
+ LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
+
+ while(pObj)
+ {
+ if(pObj->GetLevel()== index)
+ {
+ return pObj;
+ }
+
+ pID = &pObj->GetNext(); // not necessary to check pID NULL or not
+ pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
+ }
+
+ return nullptr;
+}
+
+LwpTocLevelData::LwpTocLevelData(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
+ : LwpDLVList(objHdr, pStrm), m_nFlags(0), m_nLevel(0)
+{
+}
+LwpTocLevelData::~LwpTocLevelData()
+{
+}
+/**
+ * @short Register style
+ * @param
+ * @return
+ */
+void LwpTocLevelData::RegisterStyle()
+{
+}
+/**
+ * @short Convert
+ * @param pCont - container
+ * @return none
+ */
+void LwpTocLevelData::XFConvert(XFContentContainer* /*pCont*/)
+{
+}
+/**
+ * @short Read TOCLEVELDATA obj
+ * @param
+ * @return
+ */
+void LwpTocLevelData::Read()
+{
+ LwpDLVList::Read();
+ m_nFlags = m_pObjStrm->QuickReaduInt16();
+ m_nLevel = m_pObjStrm->QuickReaduInt16();
+ m_SearchName.Read(m_pObjStrm.get());
+
+ m_pObjStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptoc.hxx b/lotuswordpro/source/filter/lwptoc.hxx
new file mode 100644
index 000000000..e22fcecf2
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptoc.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTOC_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPTOC_HXX
+
+#include "lwptablelayout.hxx"
+
+class XFIndex;
+class LwpFoundry;
+class LwpTocLevelData;
+class XFIndex;
+/**
+ * @brief
+ * VO_TOCSUPERTABLELAYOUT object
+ */
+class LwpTocSuperLayout final : public LwpSuperTableLayout
+{
+public:
+ LwpTocSuperLayout(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ virtual ~LwpTocSuperLayout() override;
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ virtual LWP_LAYOUT_TYPE GetLayoutType() override { return LWP_TOC_SUPERTABLE_LAYOUT; }
+ virtual void XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart = 0, sal_Int32 nEnd = 0,
+ bool bAll = false) override;
+
+private:
+ void Read() override;
+ bool GetRightAlignPageNumber(sal_uInt16 index);
+ bool GetUsePageNumber(sal_uInt16 index);
+ sal_uInt16 GetSeparatorType(sal_uInt16 index);
+ LwpTocLevelData* GetSearchLevelPtr(sal_uInt16 index);
+ static LwpTocLevelData* GetNextSearchLevelPtr(sal_uInt16 index, LwpTocLevelData* pCurData);
+ void AddSourceStyle(XFIndex* pToc, LwpTocLevelData* pLevel, LwpFoundry* pFoundry);
+
+ enum
+ {
+ MAX_LEVELS = 9
+ };
+ enum
+ {
+ TS_NOLEADERS = 0x01,
+ TS_LEADERDOTS = 0x02,
+ TS_LEADERDASHES = 0x04,
+ TS_LEADERUNDERLINE = 0x08,
+ TS_SEPARATORCOMMA = 0x10,
+ TS_SEPARATORDOTS = 0x20,
+ TS_PAGENUMBER = 0x40,
+ TS_RIGHTALIGN = 0x80
+ };
+
+ enum
+ {
+ NONE = 0,
+ LEADERDOTS = 1,
+ LEADERDASHES = 2,
+ LEADERUNDERLINE = 3,
+ SEPARATORCOMMA = 4,
+ SEPARATORDOTS = 5
+ };
+
+ //m_nFrom
+ enum
+ {
+ SELECTEDTEXT = 1,
+ ENTIREDOCUMENT = 2,
+ CURRENTLEVELDIVISION = 3,
+ CURRENTDIVISION = 4,
+ CURRENTSECTION = 5
+ };
+
+ LwpAtomHolder m_TextMarker; /* for selected text */
+ LwpAtomHolder m_ParentName; /* for currentleveldivision */
+ LwpAtomHolder m_DivisionName; /* for currentdivision&currentsection */
+ LwpAtomHolder m_SectionName; /* for currentsection */
+ sal_uInt16 m_nFrom;
+ LwpDLVListHeadTail m_SearchItems;
+ LwpAtomHolder m_DestName[MAX_LEVELS];
+ LwpAtomHolder m_DestPGName[MAX_LEVELS];
+ sal_uInt32 m_nFlags[MAX_LEVELS];
+
+ OUString m_TabStyleName;
+
+ XFContentContainer* m_pCont;
+};
+/**
+ * @brief
+ * VO_TOCLEVELDATA object
+ */
+class LwpTocLevelData : public LwpDLVList
+{
+public:
+ enum
+ {
+ USETEXT = 0x01,
+ USENUMBER = 0x02
+ };
+ LwpTocLevelData(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void RegisterStyle() override;
+ virtual void XFConvert(XFContentContainer* pCont) override;
+ sal_uInt16 GetLevel() const { return m_nLevel; }
+ bool GetUseText() const { return (m_nFlags & USETEXT) != 0; }
+ OUString const& GetSearchStyle() const { return m_SearchName.str(); }
+ bool GetUseLeadingText() const { return (m_nFlags & USENUMBER) != 0; }
+
+private:
+ virtual ~LwpTocLevelData() override;
+
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nLevel;
+ LwpAtomHolder m_SearchName;
+
+protected:
+ void Read() override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptools.cxx b/lotuswordpro/source/filter/lwptools.cxx
new file mode 100644
index 000000000..8a171fda7
--- /dev/null
+++ b/lotuswordpro/source/filter/lwptools.cxx
@@ -0,0 +1,850 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <lwptools.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <o3tl/string_view.hxx>
+#include <osl/process.h>
+#include <osl/thread.h>
+#include <osl/file.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <unicode/datefmt.h>
+#include <unicode/udat.h>
+#include <i18nlangtag/languagetagicu.hxx>
+
+#ifdef SAL_UNX
+#define SEPARATOR '/'
+#else
+#define SEPARATOR '\\'
+#endif
+
+using namespace ::osl;
+
+/**
+ * @descr read lwp unicode string from stream to OUString per aEncoding
+*/
+void LwpTools::QuickReadUnicode(LwpObjectStream* pObjStrm,
+ OUString& str, sal_uInt16 strlen, rtl_TextEncoding aEncoding)
+ //strlen: length of bytes
+{
+ OUStringBuffer strBuf(128);
+
+ if( !IsUnicodePacked(pObjStrm, strlen) )
+ {
+ sal_uInt16 len = 0;
+ char buf[1024];
+
+ while(strlen)
+ {
+ len = std::min(sal_uInt16(1023), strlen);
+ len = pObjStrm->QuickRead(buf, len);
+ buf[len] = '\0';
+ strBuf.append( OUString(buf, len, aEncoding) );
+ strlen -= len;
+ if(!len) break;
+ }
+ str = strBuf.makeStringAndClear();
+ }
+ else
+ {
+ char buf[1024];
+ sal_Unicode unibuf[1024];
+ sal_uInt8 readbyte;
+ sal_uInt16 readword;
+
+ bool flag = false; //switch if unicode part reached
+ sal_uInt16 sublen = 0;
+
+ sal_uInt16 readLen = 0;
+ while(readLen<strlen)
+ {
+ if(!flag) //Not unicode string
+ {
+ bool bFailure;
+ readbyte = pObjStrm->QuickReaduInt8(&bFailure);
+ if(bFailure) break;
+ readLen+=sizeof(readbyte);
+
+ if(readbyte == 0x00)
+ {
+ flag = true;
+ if(sublen>0) //add it to the strBuf
+ {
+ strBuf.append( OUString(buf, sublen, aEncoding) ); //try the aEncoding
+ sublen = 0;
+ }
+ }
+ else
+ {
+ buf[sublen++] = readbyte;
+ }
+ if(sublen>=1023 || readLen==strlen) //add it to the strBuf
+ {
+ strBuf.append( OUString(buf, sublen, aEncoding) ); //try the aEncoding
+ sublen = 0;
+ }
+ }
+ else //unicode string
+ {
+ bool bFailure;
+ readword = pObjStrm->QuickReaduInt16(&bFailure);
+ if(bFailure) break;
+ readLen+=sizeof(readword);
+
+ if(readword == 0x0000)
+ {
+ flag = false;
+ if(sublen)
+ {
+ unibuf[sublen] = '\0';
+ strBuf.append( unibuf );
+ sublen = 0;
+ }
+ }
+ else
+ {
+ unibuf[sublen++] = readword;
+ }
+ if(sublen>=1023 || readLen==strlen)
+ {
+ unibuf[sublen] = '\0';
+ strBuf.append( unibuf );
+ sublen = 0;
+ }
+ }
+ }
+ str = strBuf.makeStringAndClear();
+ }
+}
+
+/**
+ * @descr Judge if the data (len) in object stream is lwp unicode packed
+*/
+bool LwpTools::IsUnicodePacked(LwpObjectStream* pObjStrm, sal_uInt16 len)
+{
+ sal_uInt8 byte;
+ sal_uInt16 oldpos = pObjStrm->GetPos();
+
+ for (sal_uInt16 i = 0; i < len; i++)
+ {
+ byte = pObjStrm->QuickReaduInt8();
+ if (byte == 0x00)
+ {
+ pObjStrm->Seek(oldpos);
+ return true;
+ }
+ }
+ pObjStrm->Seek(oldpos);
+ return false;
+}
+
+bool LwpTools::isFileUrl(std::string_view fileName)
+{
+ return o3tl::starts_with(fileName, "file://");
+}
+
+OUString LwpTools::convertToFileUrl(const OString &fileName)
+{
+ if ( isFileUrl(fileName) )
+ {
+ return OStringToOUString(fileName, osl_getThreadTextEncoding());
+ }
+
+ OUString uUrlFileName;
+ OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
+ if ( fileName.startsWith(".") || fileName.indexOf(SEPARATOR) < 0 )
+ {
+ OUString uWorkingDir;
+ OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None );
+ OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) == FileBase::E_None );
+ } else
+ {
+ OSL_VERIFY( FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) == FileBase::E_None );
+ }
+
+ return uUrlFileName;
+}
+
+OUString LwpTools::DateTimeToOUString(const LtTm &dt)
+{
+ OUString aResult = OUString::number(dt.tm_year) + "-" + OUString::number(dt.tm_mon) + "-" + OUString::number(dt.tm_mday) +
+ "T" + OUString::number(dt.tm_hour) + ":" + OUString::number(dt.tm_min) + ":" + OUString::number(dt.tm_sec);
+
+ return aResult;
+}
+
+/**
+ * @descr get the system date format
+*/
+std::unique_ptr<XFDateStyle> LwpTools::GetSystemDateStyle(bool bLongFormat)
+{
+ icu::DateFormat::EStyle style;
+ if (bLongFormat)
+ style = icu::DateFormat::FULL;//system full date format
+ else
+ style = icu::DateFormat::SHORT;//system short date format
+
+ //1 get locale for system
+ icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
+ //2 get icu format pattern by locale
+ icu::DateFormat* fmt = icu::DateFormat::createDateInstance(style,aLocale);
+
+ int32_t nLength = 0;
+ int32_t nLengthNeed;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar* pattern = nullptr;
+
+ nLengthNeed = udat_toPattern(reinterpret_cast<void **>(fmt),false,nullptr,nLength,&status);
+ if (status == U_BUFFER_OVERFLOW_ERROR)
+ {
+ status = U_ZERO_ERROR;
+ nLength = nLengthNeed +1;
+ pattern = static_cast<UChar*>(malloc(sizeof(UChar)*nLength));
+ udat_toPattern(reinterpret_cast<void **>(fmt),false,pattern,nLength,&status);
+ }
+ if (pattern == nullptr)
+ return nullptr;
+ // 3 parse pattern string,per icu date/time format syntax, there are 20 letters reserved
+ // as pattern letter,each represent an element in date/time and its repeat numbers represent
+ // different format: for example: M produces '1', MM produces '01', MMM produces 'Jan', MMMM produces 'January'
+ // letter other than these letters is regard as text in the format, for example ',' in 'Jan,2005'
+ // we parse pattern string letter by letter and get the time format.
+ UChar cSymbol;
+ UChar cTmp;
+ std::unique_ptr<XFDateStyle> pDateStyle(new XFDateStyle);
+
+ for (int32_t i=0;i<nLengthNeed;)
+ {
+ cSymbol = pattern[i];
+ int32_t j;
+ switch(cSymbol)
+ {
+ case 'G':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ pDateStyle->AddEra();
+ break;
+ }
+ case 'y':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j <= 2)
+ pDateStyle->AddYear(false);
+ else
+ pDateStyle->AddYear();
+ break;
+ }
+ case 'M':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddMonth(false);
+ else if (j==2)
+ pDateStyle->AddMonth();
+ else if (j==3)
+ pDateStyle->AddMonth(false,true);
+ else
+ pDateStyle->AddMonth(true,true);
+ break;
+ }
+ case 'd':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddMonthDay(false);
+ else
+ pDateStyle->AddMonthDay();
+ break;
+ }
+ case 'h':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddHour(false);
+ else
+ pDateStyle->AddHour();
+ break;
+ }
+ case 'H':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddHour(false);
+ else
+ pDateStyle->AddHour();
+ break;
+ }
+ case 'm':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddMinute(false);
+ else
+ pDateStyle->AddMinute();
+ break;
+ }
+ case 's':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddSecond(false);
+ else
+ pDateStyle->AddSecond();
+ break;
+ }
+ case 'S':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddSecond(sal_False);
+ else
+ pDateStyle->AddSecond();*/
+ break;
+ }
+ case 'E':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j<=2)
+ pDateStyle->AddWeekDay(false);
+ else
+ pDateStyle->AddWeekDay();
+ break;
+ }
+ case 'D':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddWeekDay(sal_False);
+ else
+ pDateStyle->AddWeekDay();*/
+ break;
+ }
+ case 'F':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddWeekDay(sal_False);
+ else
+ pDateStyle->AddWeekDay();*/
+ break;
+ }
+ case 'w':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddWeekDay(sal_False);
+ else
+ pDateStyle->AddWeekDay();*/
+ break;
+ }
+ case 'W':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddWeekDay(sal_False);
+ else
+ pDateStyle->AddWeekDay();*/
+ break;
+ }
+ case 'a':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ pDateStyle->AddAmPm();
+ break;
+ }
+ case 'k':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ break;
+ }
+ case 'K':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pDateStyle->AddHour(false);
+ else
+ pDateStyle->AddHour();
+ break;
+ }
+ case 'Z':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ break;
+ }
+ case '\''://'
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ break;
+ }
+ case '"':
+ {
+ pDateStyle->AddText("'");
+ break;
+ }
+ default:
+ {
+ if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
+ {
+ return nullptr;
+ }
+ else//TEXT
+ {
+ //UChar buffer[1024];
+ sal_Unicode buffer[1024];
+ buffer[0] = cSymbol;
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if ((cTmp>='A' && cTmp<='Z') || (cTmp>='a' && cTmp<='z') ||
+ cTmp=='\'' || cTmp=='"' )
+ {
+ i=i+j;
+ buffer[j]= '\0';
+ break;
+ }
+ else
+ buffer[j] = cTmp;
+ }
+
+ pDateStyle->AddText(OUString(buffer));//keep for all parsed
+ }
+ break;
+ }
+ }
+ }
+// udat_close(fmt);
+ return pDateStyle;
+}
+/**
+ * @descr get the system time format
+*/
+std::unique_ptr<XFTimeStyle> LwpTools::GetSystemTimeStyle()
+{
+ //1 get locale for system
+ icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
+ //2 get icu format pattern by locale
+ icu::DateFormat* fmt = icu::DateFormat::createTimeInstance(icu::DateFormat::DEFAULT,aLocale);
+
+ int32_t nLength = 0;
+ int32_t nLengthNeed;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar* pattern = nullptr;
+ nLengthNeed = udat_toPattern(reinterpret_cast<void **>(fmt),false,nullptr,nLength,&status);
+ if (status == U_BUFFER_OVERFLOW_ERROR)
+ {
+ status = U_ZERO_ERROR;
+ nLength = nLengthNeed +1;
+ pattern = static_cast<UChar*>(malloc(sizeof(UChar)*nLength));
+ udat_toPattern(reinterpret_cast<void **>(fmt),false,pattern,nLength,&status);
+ }
+
+ if (pattern == nullptr)
+ return nullptr;
+ // 3 parse pattern string,per icu date/time format syntax, there are 20 letters reserved
+ // as pattern letter,each represent an element in date/time and its repeat numbers represent
+ // different format: for example: M produces '1',MM produces '01', MMM produces 'Jan', MMMM produces 'Januaray'
+ // letter other than these letters is regard as text in the format, for example ','in 'Jan,2005'
+ // we parse pattern string letter by letter and get the time format.
+ // for time format ,for there is not date info,we can only parse the letter representing time.
+ UChar cSymbol;
+ UChar cTmp;
+ std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);
+
+ for (int32_t i=0;i<nLengthNeed;)
+ {
+ cSymbol = pattern[i];
+ int32_t j;
+ switch(cSymbol)
+ {
+ case 'h':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pTimeStyle->AddHour(false);
+ else
+ pTimeStyle->AddHour();
+ break;
+ }
+ case 'H':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pTimeStyle->AddHour(false);
+ else
+ pTimeStyle->AddHour();
+ break;
+ }
+ case 'm':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pTimeStyle->AddMinute(false);
+ else
+ pTimeStyle->AddMinute();
+ break;
+ }
+ case 's':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pTimeStyle->AddSecond(false);
+ else
+ pTimeStyle->AddSecond();
+ break;
+ }
+ case 'S':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ /*if (j==1)
+ pDateStyle->AddSecond(sal_False);
+ else
+ pDateStyle->AddSecond();*/
+ break;
+ }
+ case 'a':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ pTimeStyle->SetAmPm(true);
+ break;
+ }
+ case 'k':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ break;
+ }
+ case 'K':
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ if (j==1)
+ pTimeStyle->AddHour(false);
+ else
+ pTimeStyle->AddHour();
+ break;
+ }
+ case '\''://'
+ {
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if (cTmp != cSymbol)
+ {
+ i=i+j;
+ break;
+ }
+ }
+ break;
+ }
+ case '"':
+ {
+ pTimeStyle->AddText("'");
+ break;
+ }
+ default:
+ {
+ if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
+ {
+ return nullptr;
+ }
+ else//TEXT
+ {
+ sal_Unicode buffer[1024];
+ buffer[0] = cSymbol;
+ //strBuffer.append(cSymbol);
+ for (j=1;;j++)
+ {
+ cTmp = pattern[i+j];
+ if ((cTmp>='A' && cTmp<='Z') || (cTmp>='a' && cTmp<='z') ||
+ cTmp=='\'' || cTmp=='"' )
+ {
+ i=i+j;
+ buffer[j]= '\0';
+ break;
+ }
+ else
+ buffer[j] = cTmp;
+ }
+ pTimeStyle->AddText(OUString(buffer));//keep for all parsed
+ }
+ break;
+ }
+ }
+ }
+// udat_close(fmt);
+ return pTimeStyle;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpuidoc.cxx b/lotuswordpro/source/filter/lwpuidoc.cxx
new file mode 100644
index 000000000..a65efe558
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpuidoc.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpuidoc.hxx"
+
+LwpUIDocument::LwpUIDocument(LwpObjectStream* pStrm)
+ : m_nFlags(DOC_LOCKED)
+{
+ Read(pStrm);
+}
+
+LwpUIDocument::~LwpUIDocument() {}
+
+void LwpUIDocument::Read(LwpObjectStream* pStrm)
+{
+ LwpNamedProperties::Read(pStrm);
+ m_ARMacroOpts.Read(pStrm);
+ m_MergedOpts.Read(pStrm);
+ m_SheetFullPath.ReadPathAtom(pStrm);
+
+ sal_uInt16 saved_flags = pStrm->QuickReaduInt16();
+ m_nFlags |= saved_flags;
+
+ if (pStrm->CheckExtra())
+ {
+ m_InitialSaveAsType.Read(pStrm);
+ pStrm->SkipExtra();
+ }
+}
+/**
+ * @descr Read macro options from object stream
+ **/
+void LwpNamedProperties::Read(LwpObjectStream* pStrm)
+{
+ sal_uInt16 numEntries = pStrm->QuickReaduInt16();
+
+ if (numEntries)
+ throw std::runtime_error("TODO: Read each NamedProperties");
+
+ pStrm->SkipExtra();
+}
+/**
+ * @descr Read macro options from object stream
+ **/
+void LwpAutoRunMacroOptions::Read(LwpObjectStream* pStrm)
+{
+ m_OpenName.ReadPathAtom(pStrm);
+ m_CloseName.ReadPathAtom(pStrm);
+ m_NewName.ReadPathAtom(pStrm);
+ m_OptionFlag = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+/**
+ * @descr Read merge options from object stream
+ **/
+void LwpMergeOptions::Read(LwpObjectStream* pStrm)
+{
+ m_RecordFile.ReadPathAtom(pStrm);
+ m_DescriptionFile.ReadPathAtom(pStrm);
+ m_Filter.Read(pStrm);
+ m_nType = pStrm->QuickReaduInt16();
+
+ //Does not process m_nType here. Assume m_nType is 0.
+ if (m_nType != 0)
+ throw std::runtime_error("TODO: Read the CMergeDataFile");
+
+ m_nLastActionFlag = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpuidoc.hxx b/lotuswordpro/source/filter/lwpuidoc.hxx
new file mode 100644
index 000000000..3e2ce786a
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpuidoc.hxx
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * all classes for LwpUIDocument
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUIDOC_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUIDOC_HXX
+
+#include <config_lgpl.h>
+#include <lwpobjstrm.hxx>
+#include <lwpatomholder.hxx>
+
+class LwpNamedProperties;
+class LwpAutoRunMacroOptions;
+class LwpMergeOptions;
+
+/**
+ * @brief Properties in UIDocument structure
+ * not parsed yet
+*/
+class LwpNamedProperties
+{
+public:
+ LwpNamedProperties() = delete;
+ static void Read(LwpObjectStream* pStrm);
+};
+/**
+ * @brief macro options contained in UIDocument structure
+ * not parsed yet
+*/
+class LwpAutoRunMacroOptions
+{
+public:
+ LwpAutoRunMacroOptions()
+ : m_OptionFlag(0)
+ {
+ }
+
+private:
+ LwpAtomHolder m_OpenName;
+ LwpAtomHolder m_CloseName;
+ LwpAtomHolder m_NewName;
+ sal_uInt16 m_OptionFlag;
+
+public:
+ void Read(LwpObjectStream* pStrm);
+};
+/**
+ * @brief Merge options contained in UIDocument structure
+ * not parsed yet
+*/
+class LwpMergeOptions
+{
+public:
+ LwpMergeOptions()
+ : m_nType(0)
+ , m_nLastActionFlag(0)
+ {
+ }
+
+private:
+ LwpAtomHolder m_RecordFile;
+ LwpAtomHolder m_DescriptionFile;
+ LwpAtomHolder m_Filter;
+ sal_uInt16 m_nType;
+ sal_uInt16 m_nLastActionFlag; // flag remembers last merge action
+public:
+ void Read(LwpObjectStream* pStrm);
+};
+/**
+ * @brief UIDocument structure contained in VO_DOCUMENT
+ * not parsed yet
+*/
+class LwpUIDocument
+{
+public:
+ explicit LwpUIDocument(LwpObjectStream* pStrm);
+ ~LwpUIDocument();
+
+private:
+ LwpAutoRunMacroOptions m_ARMacroOpts;
+ LwpMergeOptions m_MergedOpts;
+ LwpAtomHolder m_SheetFullPath; // full path for style sheet
+ sal_uInt16 m_nFlags;
+ LwpAtomHolder m_InitialSaveAsType;
+ enum
+ {
+ DOC_READONLY = 0x01,
+ DOC_BLOCKSETS = 0x02,
+ DOC_LOCKED = 0x04,
+ DOC_ENVELOPE = 0x08,
+ DOC_EXTERNALFILE = 0x10,
+ DOC_SANITYCHECK = 0x20,
+ DOC_ANNOTATEONLY = 0x40,
+ DOC_CANCELED = 0x80
+ };
+
+public:
+ void Read(LwpObjectStream* pStrm);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpusewhen.hxx b/lotuswordpro/source/filter/lwpusewhen.hxx
new file mode 100644
index 000000000..21b5ce7f0
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpusewhen.hxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUSEWHEN_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUSEWHEN_HXX
+
+#include <config_lgpl.h>
+#include <lwpobjstrm.hxx>
+
+#define STYLE_USEONALLPAGES 0x0001U /* repeat on all pages */
+#define STYLE_USEONALLEVENPAGES 0x0002U /* repeat on all even pages */
+#define STYLE_USEONALLODDPAGES 0x0004U /* repeat on all odd pages */
+#define STYLE_USEONTHISPAGE 0x0008U /* use this guy on this page */
+#define STYLE_USEEXCEPTTHISPAGE 0x0010U /* use guy except on this page */
+#define STYLE_USESTARTINGONPAGE 0x0020U /* use starting on page n */
+#define STYLE_USEONMASK (STYLE_USEONALLPAGES | \
+ STYLE_USEONALLEVENPAGES | \
+ STYLE_USEONALLODDPAGES | \
+ STYLE_USEONTHISPAGE | \
+ STYLE_USEEXCEPTTHISPAGE | \
+ STYLE_USESTARTINGONPAGE)
+
+#define STYLE_STARTONNEXTPAGE 0x0000U // This is the default
+#define STYLE_STARTONTHISPAGE 0x0040U
+#define STYLE_STARTONNEXTODD 0x0080U
+#define STYLE_STARTONNEXTEVEN 0x0100U
+#define STYLE_STARTONTHISHF 0x0200U
+#define STYLE_STARTONMASK (STYLE_STARTONTHISPAGE | \
+ STYLE_STARTONNEXTODD | \
+ STYLE_STARTONNEXTEVEN | \
+ STYLE_STARTONTHISHF)
+class LwpUseWhen
+{
+public:
+ LwpUseWhen() : m_nFlags(0), m_nUsePage(0) {}
+
+ inline void Read(LwpObjectStream* pStrm);
+
+ inline bool IsUseOnAllPages() const;
+ inline bool IsUseOnAllEvenPages() const;
+ inline bool IsUseOnAllOddPages() const;
+ inline bool IsUseOnPage() const;
+
+ inline bool IsStartOnThisPage() const;
+ inline bool IsStartOnNextPage() const;
+ inline bool IsStartOnNextEvenPage() const;
+ inline bool IsStartOnNextOddPage() const;
+ inline bool IsStartOnThisHF() const;
+
+ inline sal_uInt16 GetUsePage() const;
+private:
+ sal_uInt16 m_nFlags;
+ sal_uInt16 m_nUsePage;
+};
+
+inline void LwpUseWhen::Read(LwpObjectStream* pStrm)
+{
+ m_nFlags = pStrm->QuickReaduInt16();
+ m_nUsePage = pStrm->QuickReaduInt16();
+ pStrm->SkipExtra();
+}
+inline bool LwpUseWhen::IsUseOnAllPages() const
+{
+ return ((m_nFlags & STYLE_USEONALLPAGES) != 0);
+}
+inline bool LwpUseWhen::IsUseOnAllEvenPages() const
+{
+ return ((m_nFlags & STYLE_USEONALLEVENPAGES) != 0);
+}
+inline bool LwpUseWhen::IsUseOnAllOddPages() const
+{
+ return ((m_nFlags & STYLE_USEONALLODDPAGES) != 0);
+}
+
+inline bool LwpUseWhen::IsUseOnPage() const
+{
+ return ((m_nFlags & STYLE_USEONTHISPAGE) != 0);
+}
+
+inline bool LwpUseWhen::IsStartOnThisPage() const
+{
+ return ((m_nFlags & STYLE_STARTONTHISPAGE) != 0);
+}
+
+inline bool LwpUseWhen::IsStartOnNextPage() const
+{
+ return ((m_nFlags & STYLE_STARTONMASK) == 0);
+}
+
+inline bool LwpUseWhen::IsStartOnNextOddPage() const
+{
+ return ((m_nFlags & STYLE_STARTONNEXTODD) != 0);
+}
+
+inline bool LwpUseWhen::IsStartOnNextEvenPage() const
+{
+ return ((m_nFlags & STYLE_STARTONNEXTEVEN) != 0);
+}
+
+inline bool LwpUseWhen::IsStartOnThisHF() const
+{
+ return ((m_nFlags & STYLE_STARTONTHISHF) != 0);
+}
+
+inline sal_uInt16 LwpUseWhen::GetUsePage() const
+{
+ return m_nUsePage;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpusrdicts.cxx b/lotuswordpro/source/filter/lwpusrdicts.cxx
new file mode 100644
index 000000000..d4a74e6f5
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpusrdicts.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include "lwpusrdicts.hxx"
+#include <lwpatomholder.hxx>
+
+LwpUserDictFiles::LwpUserDictFiles(LwpObjectStream* pStrm) { Read(pStrm); }
+/**
+ * @descr Read UserDictFiles in VO_DOCUMENT
+ * words are skipped, not parsed yet
+ **/
+void LwpUserDictFiles::Read(LwpObjectStream* pStrm)
+{
+ sal_uInt16 cnt = pStrm->QuickReaduInt16();
+ LwpAtomHolder word;
+ while (cnt--)
+ {
+ word.Read(pStrm);
+ pStrm->SkipExtra();
+ }
+ pStrm->SkipExtra();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpusrdicts.hxx b/lotuswordpro/source/filter/lwpusrdicts.hxx
new file mode 100644
index 000000000..49ac08d69
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpusrdicts.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUSRDICTS_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPUSRDICTS_HXX
+
+#include <config_lgpl.h>
+#include <lwpobjstrm.hxx>
+/**
+ * @brief User defined words used in VO_DOCUMENT
+*/
+class LwpUserDictFiles
+{
+public:
+ explicit LwpUserDictFiles(LwpObjectStream* pStrm);
+ static void Read(LwpObjectStream* pStrm);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpverdocument.cxx b/lotuswordpro/source/filter/lwpverdocument.cxx
new file mode 100644
index 000000000..4a228a7a6
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpverdocument.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Versioned Pointer object, used for VO_VEGTR and VO_QTR
+ * Does not find the difference between CVersionedQointer and
+ * CVersionedGointer, so use one class
+ ************************************************************************/
+
+#include <lwpglobalmgr.hxx>
+#include "lwpverdocument.hxx"
+#include "lwplnopts.hxx"
+#include "lwpproplist.hxx"
+#include <xfilter/xfparastyle.hxx>
+#include <lwptools.hxx>
+
+LwpVerDocument::LwpVerDocument(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+ , m_nTabSpacing(0)
+{
+}
+
+void LwpVerDocument::Read()
+{
+ m_nTabSpacing = m_pObjStrm->QuickReaduInt32();
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ LwpLineNumberOptions aLineNumberOptions(m_pObjStrm.get());
+
+ if (m_pObjStrm->CheckExtra())
+ {
+ LwpPropList aPropList;
+ aPropList.Read(m_pObjStrm.get());
+ m_pObjStrm->SkipExtra();
+ }
+ }
+}
+
+void LwpVerDocument::RegisterStyle()
+{
+ std::unique_ptr<XFDefaultParaStyle> pDefault(new XFDefaultParaStyle);
+ double len = static_cast<double>(m_nTabSpacing) / UNITS_PER_INCH * CM_PER_INCH;
+ if (len < 0.001)
+ {
+ len = 1.27; //0.5 inch
+ }
+ pDefault->SetTabDistance(len);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ pXFStyleManager->AddStyle(std::move(pDefault));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpverdocument.hxx b/lotuswordpro/source/filter/lwpverdocument.hxx
new file mode 100644
index 000000000..b77bd7bad
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpverdocument.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Versioned Pointer object, used for VO_VEGTR and VO_QTR
+ * Does not find the difference between CVersionedQointer and
+ * CVersionedGointer, so use one class
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPVERDOCUMENT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPVERDOCUMENT_HXX
+
+#include <lwpobj.hxx>
+
+/*VO_VERDOCUMENT*/
+
+class LwpVerDocument : public LwpObject
+{
+public:
+ LwpVerDocument(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ virtual void RegisterStyle() override;
+
+private:
+ virtual ~LwpVerDocument() override {}
+
+ sal_uInt32 m_nTabSpacing;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpvpointer.cxx b/lotuswordpro/source/filter/lwpvpointer.cxx
new file mode 100644
index 000000000..c9da88a74
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpvpointer.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "lwpvpointer.hxx"
+#include <lwpfilehdr.hxx>
+
+LwpVersionedPointer::LwpVersionedPointer(LwpObjectHeader const& objHdr, LwpSvStream* pStrm)
+ : LwpObject(objHdr, pStrm)
+{
+}
+
+void LwpVersionedPointer::Read()
+{
+ m_PointerID.ReadIndexed(m_pObjStrm.get());
+ if (LwpFileHeader::m_nFileRevision < 0x0006)
+ m_pObjStrm->SkipExtra();
+}
+
+void LwpVersionedPointer::Parse(IXFStream* /*pOutputStream*/) {}
+
+void LwpVersionedPointer::RegisterStyle()
+{
+ rtl::Reference<LwpObject> pObj = m_PointerID.obj();
+ if (pObj.is())
+ {
+ pObj->SetFoundry(m_pFoundry);
+ pObj->DoRegisterStyle();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpvpointer.hxx b/lotuswordpro/source/filter/lwpvpointer.hxx
new file mode 100644
index 000000000..bce43a204
--- /dev/null
+++ b/lotuswordpro/source/filter/lwpvpointer.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Versioned Pointer object, used for VO_VEGTR and VO_QTR
+ * Does not find the difference between CVersionedQointer and
+ * CVersionedGointer, so use one class
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPVPOINTER_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPVPOINTER_HXX
+
+#include <lwpobj.hxx>
+class LwpVersionedPointer final : public LwpObject
+{
+public:
+ LwpVersionedPointer(LwpObjectHeader const& objHdr, LwpSvStream* pStrm);
+ void Read() override;
+ void RegisterStyle() override;
+ void Parse(IXFStream* pOutputStream) override;
+ LwpObjectID& GetPointer() { return m_PointerID; }
+
+private:
+ LwpObjectID m_PointerID;
+ virtual ~LwpVersionedPointer() override {}
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/tocread.cxx b/lotuswordpro/source/filter/tocread.cxx
new file mode 100644
index 000000000..2942005df
--- /dev/null
+++ b/lotuswordpro/source/filter/tocread.cxx
@@ -0,0 +1,520 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sal/config.h>
+#include <sal/log.hxx>
+
+#include <cstring>
+
+#include "first.hxx"
+#include "bentoid.hxx"
+#include "tocread.hxx"
+#include "ut.hxx"
+#include <assert.h>
+namespace OpenStormBento
+{
+
+BenError
+CBenTOCReader::ReadLabelAndTOC()
+{
+ BenError Err;
+
+ tools::ULong TOCOffset;
+ if ((Err = ReadLabel(&TOCOffset, &cTOCSize)) != BenErr_OK)
+ return Err;
+
+ sal_uLong nLength = cpContainer->GetSize();
+
+ if (TOCOffset > nLength)
+ return BenErr_ReadPastEndOfTOC;
+
+ if (cTOCSize > nLength - TOCOffset)
+ return BenErr_ReadPastEndOfTOC;
+
+ cpContainer->SeekToPosition(TOCOffset);
+
+ cpTOC.reset( new BenByte[cTOCSize] );
+ if ((Err = cpContainer->ReadKnownSize(cpTOC.get(), cTOCSize)) != BenErr_OK)
+ return Err;
+
+ if ((Err = ReadTOC()) != BenErr_OK)
+ return Err;
+
+ return BenErr_OK;
+}
+
+BenError
+CBenTOCReader::ReadLabel(tools::ULong * pTOCOffset, tools::ULong * pTOCSize)
+{
+ // If seek fails, then probably because stream is smaller than
+ // BEN_LABEL_SIZE and thus can't be Bento container
+ BenError Err;
+ cpContainer->SeekFromEnd(-BEN_LABEL_SIZE);
+
+ BenByte Label[BEN_LABEL_SIZE];
+ if ((Err = cpContainer->ReadKnownSize(Label, BEN_LABEL_SIZE)) != BenErr_OK)
+ return Err;
+
+ if (memcmp(Label, gsBenMagicBytes, BEN_MAGIC_BYTES_SIZE) != 0)
+ if ((Err = SearchForLabel(Label)) != BenErr_OK)
+ return Err;
+
+ BenByte * pCurrLabel = Label + BEN_MAGIC_BYTES_SIZE;
+
+ BenWord Flags =
+ UtGetIntelWord(pCurrLabel);
+ pCurrLabel += 2; // Flags
+ // Newer files are 0x0101--indicates if big or little endian. Older
+ // files are 0x0 for flags
+ if (Flags != 0x0101 && Flags != 0x0)
+ return BenErr_UnknownBentoFormatVersion;
+
+ cBlockSize = UtGetIntelWord(pCurrLabel) * 1024; pCurrLabel += 2;
+ if (cBlockSize == 0)
+ return BenErr_NotBentoContainer;
+
+ // Check major version
+ if (UtGetIntelWord(pCurrLabel) != BEN_CURR_MAJOR_VERSION)
+ return BenErr_UnknownBentoFormatVersion;
+ pCurrLabel += 2;
+
+ pCurrLabel += 2; // Minor version
+
+ *pTOCOffset = UtGetIntelDWord(pCurrLabel); pCurrLabel += 4;
+ *pTOCSize = UtGetIntelDWord(pCurrLabel);
+
+ assert(pCurrLabel + 4 == Label + BEN_LABEL_SIZE);
+
+ return BenErr_OK;
+}
+
+#define LABEL_READ_BUFFER_SIZE 500
+#define MAX_SEARCH_AMOUNT 1024 * 1024
+
+BenError
+CBenTOCReader::SearchForLabel(BenByte * pLabel)
+{
+ BenError Err;
+
+ sal_uLong Length = cpContainer->GetSize();
+
+ // Always ready to check for MagicBytes from
+ // CurrOffset - BEN_MAGIC_BYTES_SIZE to CurrOffset - 1
+ unsigned long CurrOffset = Length - BEN_LABEL_SIZE + BEN_MAGIC_BYTES_SIZE -
+ 1;
+
+ char Buffer[LABEL_READ_BUFFER_SIZE] = {0};
+
+ unsigned long BufferStartOffset = Length; // Init to big value
+
+ while (CurrOffset >= BEN_MAGIC_BYTES_SIZE)
+ {
+ // Don't search backwards more than 1 meg
+ if (Length - CurrOffset > MAX_SEARCH_AMOUNT)
+ break;
+
+ // If before beginning of buffer
+ if (CurrOffset - BEN_MAGIC_BYTES_SIZE < BufferStartOffset)
+ {
+ unsigned long UsedBufferSize;
+ if (CurrOffset < LABEL_READ_BUFFER_SIZE)
+ UsedBufferSize = CurrOffset;
+ else UsedBufferSize = LABEL_READ_BUFFER_SIZE;
+
+ cpContainer->SeekToPosition(CurrOffset - UsedBufferSize);
+
+ if ((Err = cpContainer->ReadKnownSize(Buffer, UsedBufferSize)) !=
+ BenErr_OK)
+ return Err;
+
+ BufferStartOffset = CurrOffset - UsedBufferSize;
+ }
+
+ if (memcmp(Buffer + (CurrOffset - BEN_MAGIC_BYTES_SIZE -
+ BufferStartOffset), gsBenMagicBytes, BEN_MAGIC_BYTES_SIZE) == 0)
+ {
+ cpContainer->SeekToPosition(CurrOffset -
+ BEN_MAGIC_BYTES_SIZE);
+
+ return cpContainer->ReadKnownSize(pLabel, BEN_LABEL_SIZE);
+ }
+
+ --CurrOffset;
+ }
+
+ return BenErr_NotBentoContainer; // Didn't find magic bytes
+}
+
+BenError
+CBenTOCReader::ReadTOC()
+{
+ BenError Err;
+ BenByte LookAhead = GetCode();
+ BenGeneration Generation = 0;
+
+ // Read in all objects
+ while (LookAhead == BEN_NEW_OBJECT)
+ {
+ BenObjectID ObjectID;
+ if ((Err = GetDWord(&ObjectID)) != BenErr_OK)
+ return Err;
+ CBenObject * pObject = nullptr;
+
+ // Read in all properties for object
+ do
+ {
+ BenObjectID PropertyID;
+
+ if ((Err = GetDWord(&PropertyID)) != BenErr_OK)
+ return Err;
+ CBenProperty * pProperty = nullptr;
+
+ // Read in all values for property
+ do
+ {
+ BenObjectID ReferencedListID = 0;
+
+ BenObjectID TypeID;
+ if ((Err = GetDWord(&TypeID)) != BenErr_OK)
+ return Err;
+ LookAhead = GetCode();
+
+ if (LookAhead == BEN_EXPLICIT_GEN)
+ {
+ if ((Err = GetDWord(&Generation)) != BenErr_OK)
+ return Err;
+ LookAhead = GetCode();
+ }
+
+ if (LookAhead == BEN_REFERENCE_LIST_ID)
+ {
+ if ((Err = GetDWord(&ReferencedListID)) != BenErr_OK)
+ return Err;
+ LookAhead = GetCode();
+ }
+
+ if (PropertyID == BEN_PROPID_GLOBAL_PROPERTY_NAME ||
+ PropertyID == BEN_PROPID_GLOBAL_TYPE_NAME)
+ {
+ // Read property or type name
+
+ if (pObject != nullptr || TypeID != BEN_TYPEID_7_BIT_ASCII ||
+ LookAhead != BEN_OFFSET4_LEN4)
+ return BenErr_NamedObjectError;
+
+ BenContainerPos Pos;
+ sal_uInt32 Length;
+
+ if ((Err = GetDWord(&Pos)) != BenErr_OK)
+ return Err;
+ if ((Err = GetDWord(&Length)) != BenErr_OK)
+ return Err;
+ LookAhead = GetCode();
+
+ cpContainer->SeekToPosition(Pos);
+
+ const auto nRemainingSize = cpContainer->remainingSize();
+ if (Length > nRemainingSize)
+ {
+ SAL_WARN("lwp", "stream too short for claimed no of records");
+ Length = nRemainingSize;
+ }
+
+ #define STACK_BUFFER_SIZE 256
+ char sStackBuffer[STACK_BUFFER_SIZE];
+ std::unique_ptr<char[]> sAllocBuffer;
+ char * sBuffer;
+ if (Length > STACK_BUFFER_SIZE)
+ {
+ sAllocBuffer.reset(new char[Length]);
+ sBuffer = sAllocBuffer.get();
+ }
+ else
+ {
+ sBuffer = sStackBuffer;
+ }
+
+ if ((Err = cpContainer->ReadKnownSize(sBuffer, Length)) !=
+ BenErr_OK)
+ {
+ return Err;
+ }
+
+ OString sName;
+ if (Length)
+ sName = OString(sBuffer, Length - 1);
+
+ CUtListElmt * pPrevNamedObjectListElmt;
+ if (FindNamedObject(&cpContainer->GetNamedObjects(),
+ sName, &pPrevNamedObjectListElmt) != nullptr)
+ {
+ return BenErr_DuplicateName;
+ }
+
+ CUtListElmt* pPrevObject = cpContainer->GetObjects().GetLast();
+
+ if (PropertyID == BEN_PROPID_GLOBAL_PROPERTY_NAME)
+ pObject = new CBenPropertyName(cpContainer, ObjectID,
+ pPrevObject, sName, pPrevNamedObjectListElmt);
+ else
+ pObject = new CBenTypeName(cpContainer, ObjectID,
+ pPrevObject, sName, pPrevNamedObjectListElmt);
+ }
+ else if (PropertyID == BEN_PROPID_OBJ_REFERENCES)
+ {
+ // Don't need to read in references object--we assume
+ // that all references use object ID as key
+ if ((Err = ReadSegments(nullptr, &LookAhead)) != BenErr_OK)
+ return Err;
+ }
+ else if (ObjectID == BEN_OBJID_TOC)
+ {
+ if (PropertyID == BEN_PROPID_TOC_SEED)
+ {
+ if (TypeID != BEN_TYPEID_TOC_TYPE ||
+ LookAhead != BEN_IMMEDIATE4)
+ return BenErr_TOCSeedError;
+
+ BenDWord Data;
+ if ((Err = GetDWord(&Data)) != BenErr_OK)
+ return Err;
+ LookAhead = GetCode();
+
+ cpContainer->SetNextAvailObjectID(Data);
+ }
+ else
+ {
+ // Ignore the other BEN_OBJID_TOC properties
+ if ((Err = ReadSegments(nullptr, &LookAhead)) != BenErr_OK)
+ return Err;
+ }
+ }
+ else
+ {
+ if (pProperty != nullptr)
+ return BenErr_PropertyWithMoreThanOneValue;
+
+ if (pObject == nullptr)
+ pObject = new CBenObject(cpContainer, ObjectID,
+ cpContainer->GetObjects().GetLast());
+
+ pProperty = new CBenProperty(pObject, PropertyID, TypeID,
+ pObject->GetProperties().GetLast());
+
+ if ((Err = ReadSegments(&pProperty->UseValue(),
+ &LookAhead)) != BenErr_OK)
+ return Err;
+ }
+ } while (LookAhead == BEN_NEW_TYPE);
+ } while (LookAhead == BEN_NEW_PROPERTY);
+ }
+
+ if (LookAhead == BEN_READ_PAST_END_OF_TOC)
+ return BenErr_OK;
+ else return BenErr_InvalidTOC;
+}
+
+BenError
+CBenTOCReader::ReadSegments(CBenValue * pValue, BenByte * pLookAhead)
+{
+ BenError Err;
+
+ while (*pLookAhead >= BEN_SEGMENT_CODE_START &&
+ *pLookAhead <= BEN_SEGMENT_CODE_END)
+ {
+ if ((Err = ReadSegment(pValue, pLookAhead)) !=
+ BenErr_OK)
+ return Err;
+ }
+
+ return BenErr_OK;
+}
+
+BenError
+CBenTOCReader::ReadSegment(CBenValue * pValue, BenByte * pLookAhead)
+{
+ BenError Err;
+
+ bool Immediate = false;
+ bool EightByteOffset = false;
+ sal_uInt32 Offset(0), Length(0);
+
+ switch (*pLookAhead)
+ {
+ case BEN_CONT_OFFSET4_LEN4:
+ case BEN_OFFSET4_LEN4:
+ if ((Err = GetDWord(&Offset)) != BenErr_OK)
+ return Err;
+ if ((Err = GetDWord(&Length)) != BenErr_OK)
+ return Err;
+ break;
+
+ case BEN_IMMEDIATE0:
+ Length = 0; Immediate = true;
+ break;
+
+ case BEN_IMMEDIATE1:
+ Length = 1; Immediate = true;
+ break;
+
+ case BEN_IMMEDIATE2:
+ Length = 2; Immediate = true;
+ break;
+
+ case BEN_IMMEDIATE3:
+ Length = 3; Immediate = true;
+ break;
+
+ case BEN_CONT_IMMEDIATE4:
+ case BEN_IMMEDIATE4:
+ Length = 4; Immediate = true;
+ break;
+
+ case BEN_CONT_OFFSET8_LEN4:
+ case BEN_OFFSET8_LEN4:
+ EightByteOffset = true;
+ break;
+
+ default:
+ return BenErr_OK;
+ }
+
+ BenByte ImmData[4];
+ if (Immediate && Length != 0)
+ if ((Err = GetData(ImmData, 4)) != BenErr_OK)
+ return Err;
+
+ *pLookAhead = GetCode();
+
+ if (EightByteOffset)
+ return BenErr_64BitOffsetNotSupported;
+
+ if (pValue != nullptr)
+ {
+ if (! Immediate)
+ new CBenValueSegment(pValue, Offset, Length);
+ else if (Length != 0)
+ {
+ assert(Length <= 4);
+ new CBenValueSegment(pValue, ImmData, static_cast<unsigned short>(Length));
+ }
+ }
+
+ return BenErr_OK;
+}
+
+bool
+CBenTOCReader::CanGetData(tools::ULong Amt)
+{
+ return cCurr + Amt <= cTOCSize;
+}
+
+BenError
+CBenTOCReader::GetByte(BenByte * pByte)
+{
+ if (! CanGetData(1))
+ return BenErr_ReadPastEndOfTOC;
+
+ *pByte = UtGetIntelByte(cpTOC.get() + cCurr);
+ ++cCurr;
+ return BenErr_OK;
+}
+
+BenError
+CBenTOCReader::GetDWord(BenDWord * pDWord)
+{
+ if (! CanGetData(4))
+ return BenErr_ReadPastEndOfTOC;
+
+ *pDWord = UtGetIntelDWord(cpTOC.get() + cCurr);
+ cCurr += 4;
+ return BenErr_OK;
+}
+
+BenByte
+CBenTOCReader::GetCode()
+{
+ BenByte Code;
+ do
+ {
+ if (GetByte(&Code) != BenErr_OK)
+ return BEN_READ_PAST_END_OF_TOC;
+
+ if (Code == BEN_END_OF_BUFFER)
+ {
+ assert(cBlockSize && "cBlockSize of 0 should have already caused BenErr_UnknownBentoFormatVersion in CBenTOCReader::ReadLabel");
+ // Advance to next block
+ cCurr = cBlockSize * ((cCurr + (cBlockSize - 1)) /
+ cBlockSize);
+ }
+ }
+ while (Code == BEN_NOOP || Code == BEN_END_OF_BUFFER);
+ return Code;
+}
+
+BenError
+CBenTOCReader::GetData(void * pBuffer, tools::ULong Amt)
+{
+ if (! CanGetData(Amt))
+ return BenErr_ReadPastEndOfTOC;
+
+ std::memcpy(pBuffer, cpTOC.get() + cCurr, Amt);
+ cCurr += Amt;
+ return BenErr_OK;
+}
+}//end OpenStormBento namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/tocread.hxx b/lotuswordpro/source/filter/tocread.hxx
new file mode 100644
index 000000000..46c09ee73
--- /dev/null
+++ b/lotuswordpro/source/filter/tocread.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_TOCREAD_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_TOCREAD_HXX
+
+#include "bento.hxx"
+#include <memory>
+#include <tools/long.hxx>
+
+namespace OpenStormBento
+{
+class CBenTOCReader
+{
+public: // Methods
+ explicit CBenTOCReader(LtcBenContainer* pContainer)
+ : cpContainer(pContainer)
+ , cBlockSize(0)
+ , cCurr(0)
+ , cTOCSize(0)
+ {
+ }
+ BenError ReadLabelAndTOC();
+
+private: // Methods
+ BenError ReadLabel(tools::ULong* pTOCOffset, tools::ULong* pTOCSize);
+ BenError SearchForLabel(BenByte* pLabel);
+ BenError ReadTOC();
+ BenError ReadSegments(CBenValue* pValue, BenByte* pLookAhead);
+ BenError ReadSegment(CBenValue* pValue, BenByte* pLookAhead);
+ bool CanGetData(tools::ULong Amt);
+ BenError GetByte(BenByte* pByte);
+ BenError GetDWord(BenDWord* pDWord);
+ BenByte GetCode();
+ BenError GetData(void* pBuffer, tools::ULong Amt);
+
+private: // Data
+ LtcBenContainer* cpContainer;
+ std::unique_ptr<BenByte[]> cpTOC;
+ tools::ULong cBlockSize;
+ tools::ULong cCurr;
+ tools::ULong cTOCSize;
+};
+} //end namespace OpenStormBento
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/ut.hxx b/lotuswordpro/source/filter/ut.hxx
new file mode 100644
index 000000000..4f5022976
--- /dev/null
+++ b/lotuswordpro/source/filter/ut.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_UT_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_UT_HXX
+#include <sal/types.h>
+
+namespace OpenStormBento
+{
+inline sal_uInt16 UtGetIntelWord(sal_uInt8 const* pData) { return pData[0] | pData[1] << 8; }
+
+inline sal_uInt32 UtGetIntelDWord(sal_uInt8 const* pData)
+{
+ return pData[0] | pData[1] << 8 | pData[2] << 16 | pData[3] << 24;
+}
+
+inline sal_uInt8 UtGetIntelByte(sal_uInt8 const* pData) { return *pData; }
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/utbenvs.cxx b/lotuswordpro/source/filter/utbenvs.cxx
new file mode 100644
index 000000000..bb515c12f
--- /dev/null
+++ b/lotuswordpro/source/filter/utbenvs.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "bento.hxx"
+#include <assert.h>
+namespace OpenStormBento
+{
+/**
+* Value stream read function
+* @param data pointer of bytes read
+* @param number of bytes to be read
+* @return number of bytes read
+*/
+std::size_t LtcUtBenValueStream::GetData(void* pData, std::size_t nSize)
+{
+ size_t AmtRead;
+
+ /*BenError Err = */ cpValue->ReadValueData(pData, cCurrentPosition, nSize, &AmtRead);
+ cCurrentPosition += AmtRead;
+
+ return AmtRead;
+}
+/**
+* Value stream write function, not supported now
+* @param pointer of saved buffer
+* @param size of buffer to be written
+* @return number of bytes written into value stream
+*/
+std::size_t LtcUtBenValueStream::PutData(const void* /*pData*/, std::size_t nSize)
+{
+ /* Because we only support IMPORT filter, PutData implementation is ignored
+ It won't bring negative influence to read-only stream object */
+ assert(false);
+ return nSize;
+}
+/**
+* Seek function of value stream
+* @param position in value stream
+* @return current position in value stream
+*/
+sal_uInt64 LtcUtBenValueStream::SeekPos(sal_uInt64 const nPos)
+{
+ if (nPos <= m_ulValueLength)
+ cCurrentPosition = nPos;
+ else
+ cCurrentPosition = m_ulValueLength;
+ return cCurrentPosition;
+}
+/**
+* Set buffer size function
+* @param size of buffer
+* @return
+*/
+void LtcUtBenValueStream::SetSize(sal_uInt64 /*nSize*/)
+{
+ //pLtcBenContainer pContainer = cpValue->GetContainer();
+ //pContainer->GetStream()->SetStreamSize(nSize);
+}
+/**
+* Flush data function, not supported now
+*/
+void LtcUtBenValueStream::FlushData()
+{
+ /* Because we only support IMPORT filter, FlushData implementation is ignored
+ It won't bring negative influence to read-only stream object
+ pLtcBenContainer pContainer = cpValue->GetContainer();
+ pContainer->GetStream()->Flush();*/
+ assert(false);
+}
+/**
+* Construction
+*/
+LtcUtBenValueStream::LtcUtBenValueStream(CBenValue* pValue)
+ : cpValue(pValue)
+ ,
+ // Calculate the length of the whole value stream
+ cCurrentPosition(0)
+ , m_ulValueLength(pValue->GetValueSize())
+{
+}
+
+LtcUtBenValueStream::~LtcUtBenValueStream() {}
+
+} // end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/utlist.cxx b/lotuswordpro/source/filter/utlist.cxx
new file mode 100644
index 000000000..7b0f4c9fe
--- /dev/null
+++ b/lotuswordpro/source/filter/utlist.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "utlist.hxx"
+namespace OpenStormBento
+{
+CUtListElmt::CUtListElmt(CUtList* pList)
+ : cpNext(nullptr)
+ , cpPrev(nullptr)
+{
+ if (pList != nullptr)
+ InsertAfter(pList->GetLast());
+}
+
+CUtListElmt::~CUtListElmt()
+{
+ if (cpNext != nullptr)
+ {
+ cpPrev->cpNext = cpNext;
+ cpNext->cpPrev = cpPrev;
+ }
+}
+
+CUtList::~CUtList()
+{
+ CUtListElmt& rTerminating = GetTerminating();
+ for (CUtListElmt* pCurr = GetFirst(); pCurr != &rTerminating;)
+ {
+ CUtListElmt* pNext = pCurr->GetNext();
+ pCurr->MakeNotOnList();
+ pCurr = pNext;
+ }
+ rTerminating.SetPrev(&rTerminating);
+ rTerminating.SetNext(&rTerminating);
+}
+
+// If pCurr is NULL, returns first item in list. Otherwise, returns item
+// in list after pCurr or NULL if no more items in list. Terminating item
+// is never returned
+CUtListElmt* CUtList::GetNextOrNULL(CUtListElmt const* pCurr)
+{
+ CUtListElmt* pNext;
+
+ if (pCurr == nullptr)
+ pNext = GetFirst();
+ else
+ pNext = pCurr->GetNext();
+ if (pNext == &GetTerminating())
+ pNext = nullptr;
+ return pNext;
+}
+
+void CUtList::Destroy()
+{
+ CUtListElmt& rTerminating = GetTerminating();
+ for (CUtListElmt* pCurr = GetFirst(); pCurr != &rTerminating;)
+ {
+ CUtListElmt* pNext = pCurr->GetNext();
+ delete pCurr;
+ pCurr = pNext;
+ }
+}
+
+CUtOwningList::~CUtOwningList() { Destroy(); }
+} //end namespace OpenStormBento
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/utlist.hxx b/lotuswordpro/source/filter/utlist.hxx
new file mode 100644
index 000000000..c4eee183a
--- /dev/null
+++ b/lotuswordpro/source/filter/utlist.hxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_UTLIST_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_UTLIST_HXX
+
+namespace OpenStormBento
+{
+class CUtList;
+
+class CUtListElmt
+{
+public: // Methods
+ CUtListElmt()
+ : cpNext(nullptr)
+ , cpPrev(nullptr)
+ {
+ }
+ explicit CUtListElmt(CUtListElmt* pPrev) { InsertAfter(pPrev); }
+ explicit CUtListElmt(CUtList* pList);
+ virtual ~CUtListElmt();
+ void MakeNotOnList() { cpNext = nullptr; } // Same as Remove but doesn't patch up list
+ CUtListElmt* GetNext() const { return cpNext; }
+ void SetNext(CUtListElmt* pNext) { cpNext = pNext; }
+ CUtListElmt* GetPrev() const { return cpPrev; }
+ void SetPrev(CUtListElmt* pPrev) { cpPrev = pPrev; }
+ void InsertAfter(CUtListElmt* pPrev)
+ {
+ cpNext = pPrev->cpNext;
+ cpPrev = pPrev;
+ cpNext->cpPrev = this;
+ pPrev->cpNext = this;
+ }
+
+private: // Data
+ CUtListElmt* cpNext;
+ CUtListElmt* cpPrev;
+};
+
+class CUtList
+{
+public: // Methods
+ CUtList()
+ {
+ cDummyElmt.SetNext(&cDummyElmt);
+ cDummyElmt.SetPrev(&cDummyElmt);
+ }
+ virtual ~CUtList();
+ CUtListElmt* GetFirst() { return cDummyElmt.GetNext(); }
+ CUtListElmt* GetLast() { return cDummyElmt.GetPrev(); }
+ CUtListElmt& GetTerminating() { return cDummyElmt; }
+ CUtListElmt* GetNextOrNULL(CUtListElmt const* pCurr);
+
+ void Destroy();
+
+private: // Data
+ CUtListElmt cDummyElmt;
+};
+
+class CUtOwningList : public CUtList
+{
+public: // Methods
+ virtual ~CUtOwningList() override;
+};
+} //end namespace OpenStormBento
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfbase64.cxx b/lotuswordpro/source/filter/xfilter/xfbase64.cxx
new file mode 100644
index 000000000..1b7224a24
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfbase64.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Base64 tool.
+ ************************************************************************/
+#include <string.h>
+#include <memory>
+#include "xfbase64.hxx"
+
+const char aBase64EncodeTable[] =
+{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' };
+
+/**
+ * @descr Encode 3 byte to 4 byte.
+ * Please refer to RFC to get the base64 algorithm.
+ */
+static void Encode_(const sal_uInt8 *src, char* dest)
+{
+ sal_Int32 nBinaer = (src[ 0] << 16) +
+ (src[1] << 8) +
+ (src[2]);
+
+ sal_uInt8 nIndex = ((nBinaer & 0xFC0000) >> 18);
+ dest[0] = aBase64EncodeTable [nIndex];
+
+ nIndex = (nBinaer & 0x3F000) >> 12;
+ dest[1] =aBase64EncodeTable [nIndex];
+
+ nIndex = (nBinaer & 0xFC0) >> 6;
+ dest[2] = aBase64EncodeTable [nIndex];
+
+ nIndex = (nBinaer & 0x3F);
+ dest[3] = aBase64EncodeTable [nIndex];
+}
+
+/**
+ * @descr Base64 encode.
+ */
+OUString XFBase64::Encode(sal_uInt8 const *buf, sal_Int32 len)
+{
+ std::unique_ptr<char[]> buffer;
+ sal_Int32 nNeeded;
+ sal_Int32 cycles = len/3;
+ sal_Int32 remain = len%3;
+
+ if( remain == 0 )
+ nNeeded = cycles*4;
+ else
+ nNeeded = (cycles+1)*4;
+ buffer.reset(new char[nNeeded+1]);
+
+ memset(buffer.get(), 0, nNeeded+1);
+
+ for( sal_Int32 i=0; i<cycles; i++ )
+ Encode_(buf+i*3,buffer.get()+i*4);
+
+ sal_uInt8 last[3];
+ if( remain == 1 )
+ {
+ last[0] = buf[len-1];
+ last[1] = last[2] = 0;
+ Encode_(last,buffer.get()+nNeeded+1-5);
+ }
+ else if( remain == 2 )
+ {
+ last[0] = buf[len-2];
+ last[1] = buf[len-1];
+ last[2] = 0;
+ Encode_(last,buffer.get()+nNeeded+1-5);
+ }
+
+ OUString str = OUString::createFromAscii(buffer.get());
+ return str;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfbase64.hxx b/lotuswordpro/source/filter/xfilter/xfbase64.hxx
new file mode 100644
index 000000000..58f790a30
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfbase64.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Base64 tool.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFBASE64_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFBASE64_HXX
+
+#include <rtl/ustring.hxx>
+
+/**
+ * @brief
+ * Base64 algorithm implementation.
+ * I only implements encode function now, i'll add decode if needed later.
+ * http://www.faqs.org/rfcs/rfc3548.html.
+ */
+
+class XFBase64
+{
+public:
+ /**
+ * @descr Encode binary buffer to base64 encoding.
+ */
+ static OUString Encode(sal_uInt8 const* buf, sal_Int32 len);
+};
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfbgimage.cxx b/lotuswordpro/source/filter/xfilter/xfbgimage.cxx
new file mode 100644
index 000000000..d4b4e5be6
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfbgimage.cxx
@@ -0,0 +1,162 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Background image.
+ ************************************************************************/
+#include <xfilter/xfbgimage.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfutil.hxx>
+#include "xfbase64.hxx"
+
+XFBGImage::XFBGImage()
+ : m_bUserFileLink(false)
+ , m_bRepeate(false)
+ , m_bStretch(false)
+ , m_bPosition(true)
+ , m_eHoriAlign(enumXFAlignCenter)
+ , m_eVertAlign(enumXFAlignCenter)
+{}
+
+void XFBGImage::SetImageData(sal_uInt8 const *buf, int len)
+{
+ m_strData = XFBase64::Encode(buf,len);
+ m_bUserFileLink = false;
+}
+
+bool XFBGImage::Equal(IXFStyle * /* pStyle */)
+{
+ return false;
+}
+
+void XFBGImage::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ if( m_bUserFileLink )
+ {
+ pAttrList->AddAttribute( "xlink:href", m_strFileName);
+ }
+
+ pAttrList->AddAttribute( "xlink:type", "simple" );
+ pAttrList->AddAttribute( "xlink:actuate", "onLoad");
+
+ if( m_bPosition )
+ {
+ OUString str = GetAlignName(m_eVertAlign) + " ";
+ if( m_eHoriAlign == enumXFAlignStart )
+ str += "left";
+ else if( m_eHoriAlign == enumXFAlignCenter )
+ str += "center";
+ else if( m_eHoriAlign == enumXFAlignEnd )
+ str += "right";
+
+ pAttrList->AddAttribute( "style:position", str );
+ pAttrList->AddAttribute( "style:repeat", "no-repeat" );
+ }
+ else if( m_bRepeate )
+ pAttrList->AddAttribute( "style:repeat", "repeat" );
+ else if( m_bStretch )
+ pAttrList->AddAttribute( "style:repeat", "stretch" );
+
+ pStrm->StartElement( "style:background-image" );
+
+ if( !m_bUserFileLink )
+ {
+ pAttrList->Clear();
+ pStrm->StartElement( "office:binary-data" );
+ pStrm->Characters(m_strData);
+ pStrm->EndElement( "office:binary-data" );
+ }
+
+ pStrm->EndElement( "style:background-image" );
+}
+
+bool operator==(XFBGImage const & img1, XFBGImage const & img2)
+{
+ if( img1.m_bUserFileLink != img2.m_bUserFileLink )
+ return false;
+ if( img1.m_bUserFileLink )
+ {
+ if( img1.m_strFileName != img2.m_strFileName )
+ return false;
+ }
+ else
+ {
+ //I'll not compare the content of the two buffer,it's time consuming.
+ return false;
+ }
+ if( img1.m_bPosition != img2.m_bPosition )
+ return false;
+ if( img1.m_bRepeate != img2.m_bRepeate )
+ return false;
+ if( img1.m_bStretch != img2.m_bStretch )
+ return false;
+ if( img1.m_bPosition )
+ {
+ if( (img1.m_eHoriAlign != img2.m_eHoriAlign) || (img1.m_eVertAlign != img2.m_eVertAlign) )
+ return false;
+ }
+ return true;
+}
+
+bool operator!=(XFBGImage const & img1, XFBGImage const & img2)
+{
+ return !(img1==img2);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfborders.cxx b/lotuswordpro/source/filter/xfilter/xfborders.cxx
new file mode 100644
index 000000000..f6027a155
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfborders.cxx
@@ -0,0 +1,366 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Border object,now only used by paragraph object.
+ ************************************************************************/
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFBorder::XFBorder()
+{
+ m_bDouble = false;
+ m_bSameWidth = false;
+ m_fWidthInner = 0;
+ m_fWidthSpace = 0;
+ m_fWidthOuter = 0;
+}
+
+void XFBorder::SetColor(XFColor const & color)
+{
+ m_aColor = color;
+}
+
+void XFBorder::SetWidth(double width)
+{
+ if( !m_bDouble )
+ {
+ m_fWidthInner = width;
+ m_bSameWidth = true;
+ }
+ else if (m_bSameWidth)
+ {
+ m_fWidthInner = width;
+ m_fWidthOuter = width;
+ m_fWidthSpace = width;
+ }
+}
+
+void XFBorder::SetDoubleLine(bool dual,bool bSameWidth)
+{
+ m_bDouble = dual;
+ m_bSameWidth = bSameWidth;
+}
+
+void XFBorder::SetWidthInner(double inner)
+{
+ assert(m_bDouble);
+ m_fWidthInner = inner;
+}
+
+void XFBorder::SetWidthSpace(double space)
+{
+ assert(m_bDouble);
+ m_fWidthSpace = space;
+}
+
+void XFBorder::SetWidthOuter(double outer)
+{
+ assert(m_bDouble);
+ m_fWidthOuter = outer;
+}
+
+OUString XFBorder::GetLineWidth()
+{
+ OUString str;
+
+ if( m_bDouble )
+ {
+ str = OUString::number(m_fWidthInner) + "cm " +
+ OUString::number(m_fWidthSpace) + "cm " +
+ OUString::number(m_fWidthOuter) + "cm";
+ }
+ return str;
+}
+
+OUString XFBorder::ToString()
+{
+ OUString str;
+
+ if( m_bDouble )
+ {
+ double width = m_fWidthInner + m_fWidthSpace + m_fWidthOuter;
+ if( width<FLOAT_MIN )
+ {
+ return str;
+ }
+
+ str = OUString::number(width) + "cm double " + m_aColor.ToString();
+ }
+ else
+ {
+ double width = m_fWidthInner;
+ if( width<FLOAT_MIN )
+ {
+ return str;
+ }
+ str = OUString::number(width) + "cm solid " + m_aColor.ToString();
+ }
+ return str;
+}
+
+bool operator==(XFBorder const & b1, XFBorder const & b2)
+{
+ if( b1.m_bDouble != b2.m_bDouble )
+ return false;
+ if( !b1.m_bDouble )
+ {
+ if( b1.m_fWidthInner != b2.m_fWidthInner )
+ return false;
+ }
+ else
+ {
+ if( b1.m_bSameWidth != b2.m_bSameWidth )
+ return true;
+ if( b1.m_fWidthInner != b2.m_fWidthInner ||
+ b1.m_fWidthSpace != b2.m_fWidthSpace ||
+ b1.m_fWidthOuter != b2.m_fWidthOuter
+ )
+ return false;
+ }
+ if( b1.m_aColor != b2.m_aColor )
+ return false;
+ return true;
+}
+
+bool operator!=(XFBorder const & b1, XFBorder const & b2)
+{
+ return !(b1 == b2);
+}
+
+//XFBorders:
+
+void XFBorders::SetColor(enumXFBorder side, XFColor const & color)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetColor(color);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetColor(color);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetColor(color);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetColor(color);
+ break;
+ default:
+ break;
+ }
+}
+
+void XFBorders::SetWidth(enumXFBorder side, double width)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetWidth(width);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetWidth(width);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetWidth(width);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetWidth(width);
+ break;
+ default:
+ break;
+ }
+}
+
+void XFBorders::SetDoubleLine(enumXFBorder side)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetDoubleLine(true/*dual*/,false/*bSameWidth*/);
+ break;
+ default:
+ break;
+ }
+}
+
+void XFBorders::SetWidthInner(enumXFBorder side, double inner)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetWidthInner(inner);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetWidthInner(inner);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetWidthInner(inner);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetWidthInner(inner);
+ break;
+ default:
+ break;
+ }
+}
+
+void XFBorders::SetWidthSpace(enumXFBorder side, double space)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetWidthSpace(space);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetWidthSpace(space);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetWidthSpace(space);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetWidthSpace(space);
+ break;
+ default:
+ break;
+ }
+}
+
+void XFBorders::SetWidthOuter(enumXFBorder side, double outer)
+{
+ switch(side)
+ {
+ case enumXFBorderLeft:
+ m_aBorderLeft.SetWidthOuter(outer);
+ break;
+ case enumXFBorderRight:
+ m_aBorderRight.SetWidthOuter(outer);
+ break;
+ case enumXFBorderTop:
+ m_aBorderTop.SetWidthOuter(outer);
+ break;
+ case enumXFBorderBottom:
+ m_aBorderBottom.SetWidthOuter(outer);
+ break;
+ default:
+ break;
+ }
+}
+
+bool operator ==(XFBorders const & b1, XFBorders const & b2)
+{
+ if( b1.m_aBorderLeft != b2.m_aBorderLeft )
+ return false;
+ if( b1.m_aBorderRight != b2.m_aBorderRight )
+ return false;
+ if( b1.m_aBorderTop != b2.m_aBorderTop )
+ return false;
+ if( b1.m_aBorderBottom != b2.m_aBorderBottom )
+ return false;
+ return true;
+}
+
+bool operator!=(XFBorders const & b1, XFBorders const & b2)
+{
+ return !(b1 == b2);
+}
+
+void XFBorders::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( !m_aBorderLeft.GetLineWidth().isEmpty() )
+ pAttrList->AddAttribute( "style:border-line-width-left", m_aBorderLeft.GetLineWidth() );
+ if( !m_aBorderRight.GetLineWidth().isEmpty() )
+ pAttrList->AddAttribute( "style:border-line-width-right", m_aBorderRight.GetLineWidth() );
+ if( !m_aBorderTop.GetLineWidth().isEmpty() )
+ pAttrList->AddAttribute( "style:border-line-width-top", m_aBorderTop.GetLineWidth() );
+ if( !m_aBorderBottom.GetLineWidth().isEmpty() )
+ pAttrList->AddAttribute( "style:border-line-width-bottom", m_aBorderBottom.GetLineWidth() );
+
+ if( !m_aBorderLeft.ToString().isEmpty() )
+ pAttrList->AddAttribute( "fo:border-left", m_aBorderLeft.ToString() );
+ else
+ pAttrList->AddAttribute( "fo:border-left", "none" );
+
+ if( !m_aBorderRight.ToString().isEmpty() )
+ pAttrList->AddAttribute( "fo:border-right", m_aBorderRight.ToString() );
+ else
+ pAttrList->AddAttribute( "fo:border-right", "none" );
+
+ if( !m_aBorderTop.ToString().isEmpty() )
+ pAttrList->AddAttribute( "fo:border-top", m_aBorderTop.ToString() );
+ else
+ pAttrList->AddAttribute( "fo:border-top", "none" );
+
+ if( !m_aBorderBottom.ToString().isEmpty() )
+ pAttrList->AddAttribute( "fo:border-bottom", m_aBorderBottom.ToString() );
+ else
+ pAttrList->AddAttribute( "fo:border-bottom", "none" );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcell.cxx b/lotuswordpro/source/filter/xfilter/xfcell.cxx
new file mode 100644
index 000000000..dfc5889db
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcell.cxx
@@ -0,0 +1,197 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table cell.
+ ************************************************************************/
+#include <xfilter/xfcell.hxx>
+
+#include <stdexcept>
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfparagraph.hxx>
+#include <xfilter/xftable.hxx>
+#include <xfilter/xfrow.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFCell::XFCell()
+ : m_pOwnerRow(nullptr)
+ , m_nCol(0)
+ , m_nColSpaned(1)
+ , m_nRepeated(0)
+ , m_eValueType(enumXFValueTypeNone)
+ , m_bProtect(false)
+{}
+
+XFCell::~XFCell()
+{
+}
+
+void XFCell::Add(XFContent *pContent)
+{
+ if( m_eValueType != enumXFValueTypeNone )
+ {
+ Reset();
+ m_eValueType = enumXFValueTypeNone;
+ }
+ if (m_pSubTable.is())
+ {
+ throw std::runtime_error("subtable already set");
+ }
+ if (!pContent)
+ {
+ throw std::runtime_error("no content");
+ }
+ if( pContent->GetContentType() == enumXFContentTable )
+ {
+ XFTable *pTable = dynamic_cast<XFTable*>(pContent);
+ if( !pTable )
+ return;
+ //the sub table will fill all the cell, there can't be other contents.
+ pTable->SetOwnerCell(this);
+ m_pSubTable = pTable;
+ }
+ else if( pContent->GetContentType() == enumXFContentText )
+ {
+ XFParagraph *pPara = new XFParagraph();
+ pPara->Add(pContent);
+ XFContentContainer::Add(pPara);
+ }
+ else if( pContent->GetContentType() == enumXFContentFrame )
+ {
+ XFParagraph *pPara = new XFParagraph();
+ pPara->Add(pContent);
+ XFContentContainer::Add(pPara);
+ }
+ else
+ {
+ XFContentContainer::Add(pContent);
+ }
+}
+
+void XFCell::SetValue(double value)
+{
+ SetValue(OUString::number(value));
+}
+
+void XFCell::SetValue(const OUString& value)
+{
+ m_eValueType = enumXFValueTypeFloat;
+ m_strValue = value;
+}
+
+OUString XFCell::GetCellName()
+{
+ XFRow *pRow = m_pOwnerRow;
+
+ if( !pRow )
+ return OUString();
+
+ XFTable *pTable = pRow->GetOwnerTable();
+
+ if( !pTable )
+ return OUString();
+
+ OUString name;
+ if( pTable->IsSubTable() )
+ {
+ name = pTable->GetTableName() + "." + OUString::number(m_nCol) + "." + OUString::number(pRow->GetRow());
+ }
+ else
+ {
+ name = GetTableColName(m_nCol) + OUString::number(pRow->GetRow());
+ }
+ return name;
+}
+
+void XFCell::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "table:style-name", GetStyleName() );
+ if( m_nColSpaned>1 )
+ pAttrList->AddAttribute( "table:number-columns-spanned", OUString::number(m_nColSpaned) );
+ if( m_nRepeated )
+ pAttrList->AddAttribute( "table:number-columns-repeated", OUString::number(m_nRepeated) );
+ if( m_eValueType != enumXFValueTypeNone )
+ {
+ pAttrList->AddAttribute( "table:value-type", GetValueType(m_eValueType) );
+ pAttrList->AddAttribute( "table:value", m_strValue );
+ }
+ if( !m_strFormula.isEmpty() )
+ pAttrList->AddAttribute( "table:formula", m_strFormula );
+
+ if( m_bProtect )
+ pAttrList->AddAttribute( "table:protected", "true" );
+
+ //for test only.
+// pAttrList->AddAttribute( "table:cell-name", GetCellName() );
+
+ pStrm->StartElement( "table:table-cell" );
+
+ if( m_pSubTable.is() )
+ m_pSubTable->ToXml(pStrm);
+ else
+ {
+ XFContentContainer::ToXml(pStrm);
+ }
+
+ pStrm->EndElement( "table:table-cell" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx
new file mode 100644
index 000000000..e615778a9
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx
@@ -0,0 +1,245 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table cell style. Number format, string value, and so on...
+ ************************************************************************/
+#include <xfilter/xfcellstyle.hxx>
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xffont.hxx>
+#include <xfilter/xfbgimage.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFCellStyle::XFCellStyle()
+ : m_eHoriAlign(enumXFAlignNone)
+ , m_eVertAlign(enumXFAlignNone)
+{}
+
+XFCellStyle::~XFCellStyle()
+{
+}
+
+void XFCellStyle::SetPadding(double left, double right,double top, double bottom)
+{
+ if( left != -1 )
+ m_aPadding.SetLeft(left);
+ if( right != -1 )
+ m_aPadding.SetRight(right);
+ if( top != -1 )
+ m_aPadding.SetTop(top);
+ if( bottom != -1 )
+ m_aPadding.SetBottom( bottom );
+}
+
+void XFCellStyle::SetBackColor(XFColor const & color)
+{
+ m_aBackColor = color;
+}
+
+void XFCellStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_xBackImage = std::move(rImage);
+}
+
+void XFCellStyle::SetBorders(XFBorders *pBorders)
+{
+ m_pBorders.reset( pBorders );
+}
+
+enumXFStyle XFCellStyle::GetStyleFamily()
+{
+ return enumXFStyleTableCell;
+}
+
+/**
+ *Affirm whether two XFCellStyle objects are equal.
+ */
+bool XFCellStyle::Equal(IXFStyle *pStyle)
+{
+ if( this == pStyle )
+ return true;
+ if( !pStyle || pStyle->GetStyleFamily() != enumXFStyleTableCell )
+ return false;
+
+ XFCellStyle *pOther = dynamic_cast<XFCellStyle*>(pStyle);
+ if( !pOther )
+ return false;
+
+ if( m_strDataStyle != pOther->m_strDataStyle )
+ return false;
+
+ if( m_strParentStyleName != pOther->m_strParentStyleName )
+ return false;
+
+ //align:
+ if( m_eHoriAlign != pOther->m_eHoriAlign )
+ return false;
+ if( m_eVertAlign != pOther->m_eVertAlign )
+ return false;
+
+ if( m_aBackColor != pOther->m_aBackColor )
+ return false;
+ //shadow:
+ if( m_aShadow != pOther->m_aShadow )
+ return false;
+ //margin:
+ if( m_aMargin != pOther->m_aMargin )
+ return false;
+ //padding:
+ if( m_aPadding != pOther->m_aPadding )
+ return false;
+
+ //font:
+ if( m_pFont.is() )
+ {
+ if( !pOther->m_pFont.is() )
+ return false;
+ if(*m_pFont != *pOther->m_pFont )
+ return false;
+ }
+ else if( pOther->m_pFont.is() )
+ return false;
+
+ //border:
+ if( m_pBorders )
+ {
+ if( !pOther->m_pBorders )
+ return false;
+ if( *m_pBorders != *pOther->m_pBorders )
+ return false;
+ }
+ else if( pOther->m_pBorders )
+ return false;
+
+ //if there is backimage
+ if (m_xBackImage)
+ {
+ if( !pOther->m_xBackImage )
+ return false;
+ if( !m_xBackImage->Equal(pOther) )
+ return false;
+ }
+ else
+ {
+ if( pOther->m_xBackImage )
+ return false;
+ }
+
+ return true;
+}
+
+void XFCellStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ OUString style = GetStyleName();
+
+ pAttrList->Clear();
+ if( !style.isEmpty() )
+ pAttrList->AddAttribute("style:name",GetStyleName());
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+
+ pAttrList->AddAttribute("style:family", "table-cell");
+ if( !m_strParentStyleName.isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",m_strParentStyleName);
+ if( !m_strDataStyle.isEmpty() )
+ pAttrList->AddAttribute( "style:data-style-name", m_strDataStyle );
+
+ pStrm->StartElement("style:style");
+
+ //Paragraph properties:
+ pAttrList->Clear();
+
+ //padding:
+ m_aPadding.ToXml(pStrm);
+ //margin:
+ m_aMargin.ToXml(pStrm);
+
+ //text horizontal align:
+ if( m_eHoriAlign != enumXFAlignNone )
+ {
+ pAttrList->AddAttribute("fo:text-align", GetAlignName(m_eHoriAlign) );
+ }
+ //text vertical align
+ if( m_eVertAlign != enumXFAlignNone )
+ pAttrList->AddAttribute( "fo:vertical-align", GetAlignName(m_eVertAlign) );
+
+ //shadow:
+ m_aShadow.ToXml(pStrm);
+ //borders:
+ if( m_pBorders )
+ m_pBorders->ToXml(pStrm);
+
+ //background color:
+ if( m_aBackColor.IsValid() && !m_xBackImage )
+ {
+ pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
+ }
+ //Font properties:
+ if( m_pFont.is() )
+ m_pFont->ToXml(pStrm);
+
+ pStrm->StartElement("style:properties");
+
+ if( m_xBackImage )
+ m_xBackImage->ToXml(pStrm);
+
+ pStrm->EndElement("style:properties");
+
+ pStrm->EndElement("style:style");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfchange.cxx b/lotuswordpro/source/filter/xfilter/xfchange.cxx
new file mode 100644
index 000000000..0beef2120
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfchange.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * For LWP filter architecture prototype
+ ************************************************************************/
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfchange.hxx>
+
+void XFChangeList::ToXml(IXFStream *pStrm)
+{
+ if (XFContentContainer::GetCount() == 0)
+ return;
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ // Add for disable change tracking
+ pAttrList->AddAttribute( "text:track-changes","false");
+ pStrm->StartElement( "text:tracked-changes" );
+ XFContentContainer::ToXml(pStrm);
+ pStrm->EndElement("text:tracked-changes");
+}
+
+void XFChangeRegion::ToXml(IXFStream * /*pStrm*/)
+{
+}
+
+void XFChangeInsert::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if(m_sID.isEmpty())
+ return;
+ pAttrList->AddAttribute( "text:id",m_sID);
+
+ pStrm->StartElement( "text:changed-region" );
+ pStrm->StartElement( "text:insertion" );
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "office:chg-author",m_sEditor);
+ pAttrList->AddAttribute( "office:chg-date-time","0000-00-00T00:00:00");
+ pStrm->StartElement( "office:change-info" );
+ pStrm->EndElement( "office:change-info" );
+ pStrm->EndElement( "text:insertion" );
+ pStrm->EndElement( "text:changed-region" );
+}
+
+void XFChangeDelete::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if(m_sID.isEmpty())
+ return;
+ pAttrList->AddAttribute( "text:id",m_sID);
+
+ pStrm->StartElement( "text:changed-region" );
+ pStrm->StartElement( "text:deletion" );
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "office:chg-author",m_sEditor);
+ pAttrList->AddAttribute( "office:chg-date-time","0000-00-00T00:00:00");
+ pStrm->StartElement( "office:change-info" );
+ pStrm->EndElement( "office:change-info" );
+
+ pStrm->EndElement( "text:deletion" );
+ pStrm->EndElement( "text:changed-region" );
+}
+
+void XFChangeStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if(m_sID.isEmpty())
+ return;
+ pAttrList->AddAttribute( "text:change-id",m_sID);
+
+ pStrm->StartElement( "text:change-start" );
+ pStrm->EndElement( "text:change-start" );
+}
+
+void XFChangeEnd::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if(m_sID.isEmpty())
+ return;
+ pAttrList->AddAttribute( "text:change-id",m_sID);
+
+ pStrm->StartElement( "text:change-end" );
+ pStrm->EndElement( "text:change-end" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcolor.cxx b/lotuswordpro/source/filter/xfilter/xfcolor.cxx
new file mode 100644
index 000000000..c30e35341
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcolor.cxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Color object to serial to xml filter.
+ ************************************************************************/
+#include <stdio.h>
+#include <xfilter/xfcolor.hxx>
+
+OUString XFColor::ToString() const
+{
+ char buf[8] = {};
+ sprintf(buf,"#%2x%2x%2x",m_nRed, m_nGreen, m_nBlue);
+ for( int i=1; i<7;i++ )
+ {
+ if( buf[i] == ' ' )
+ buf[i] = '0';
+ }
+ return OUString::createFromAscii(buf);
+}
+
+bool operator==(XFColor const & c1, XFColor const & c2)
+{
+ return (
+ (c1.m_nRed==c2.m_nRed)&&
+ (c1.m_nGreen==c2.m_nGreen)&&
+ (c1.m_nBlue==c2.m_nBlue)
+ );
+}
+
+bool operator!=(XFColor const & c1, XFColor const & c2)
+{
+ return !(c1==c2);
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcolstyle.cxx b/lotuswordpro/source/filter/xfilter/xfcolstyle.cxx
new file mode 100644
index 000000000..c44720a6b
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcolstyle.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Column style object.
+ ************************************************************************/
+#include <xfilter/xfcolstyle.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFColStyle::XFColStyle() { m_fWidth = 0; }
+
+XFColStyle::~XFColStyle() {}
+
+enumXFStyle XFColStyle::GetStyleFamily() { return enumXFStyleTableCol; }
+
+void XFColStyle::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute("style:name", GetStyleName());
+ pAttrList->AddAttribute("style:family", "table-column");
+ pStrm->StartElement("style:style");
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute("style:column-width", OUString::number(m_fWidth) + "cm");
+ pStrm->StartElement("style:properties");
+ pStrm->EndElement("style:properties");
+
+ pStrm->EndElement("style:style");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcolumns.cxx b/lotuswordpro/source/filter/xfilter/xfcolumns.cxx
new file mode 100644
index 000000000..b5f427d88
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcolumns.cxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Columns styles for section, or paragraph.
+ ************************************************************************/
+#include <xfilter/xfcolumns.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+void XFColumn::SetRelWidth(sal_Int32 width)
+{
+ m_nRelWidth = width;
+}
+
+void XFColumn::SetMargins(double left, double right)
+{
+ m_fMarginLeft = left;
+ m_fMarginRight = right;
+}
+
+void XFColumn::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:rel-width", OUString::number(m_nRelWidth) + "*" );
+ pAttrList->AddAttribute( "fo:margin-left", OUString::number(m_fMarginLeft) + "cm" );
+ pAttrList->AddAttribute( "fo:margin-right", OUString::number(m_fMarginRight) + "cm" );
+
+ pStrm->StartElement( "style:column" );
+ pStrm->EndElement( "style:column" );
+}
+
+void XFColumnSep::SetRelHeight(sal_Int32 height)
+{
+ assert(height>=0&&height<=100);
+ m_nRelHeight = height;
+}
+void XFColumnSep::SetWidth(double width)
+{
+ m_fWidth = width;
+}
+void XFColumnSep::SetColor(XFColor const & color)
+{
+ m_aColor = color;
+}
+void XFColumnSep::SetVerticalAlign(enumXFAlignType align)
+{
+ m_eVertAlign = align;
+}
+
+void XFColumnSep::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:width", OUString::number(m_fWidth) + "cm" );
+ if( m_aColor.IsValid() )
+ pAttrList->AddAttribute( "style:color", m_aColor.ToString() );
+ pAttrList->AddAttribute( "style:height", OUString::number(m_nRelHeight) + "%" );
+ //text align:
+ if( m_eVertAlign == enumXFAlignTop )
+ {
+ pAttrList->AddAttribute("style:vertical-align","top");
+ }
+ else if( m_eVertAlign == enumXFAlignMiddle )
+ {
+ pAttrList->AddAttribute("style:vertical-align","middle");
+ }
+ else if( m_eVertAlign == enumXFAlignBottom )
+ {
+ pAttrList->AddAttribute("style:vertical-align","bottom");
+ }
+
+ pStrm->StartElement( "style:column-sep" );
+ pStrm->EndElement( "style:column-sep" );
+}
+
+void XFColumns::SetSeparator(XFColumnSep const & aSeparator)
+{
+ m_aSeparator = aSeparator;
+ m_nFlag |= XFCOLUMNS_FLAG_SEPARATOR;
+}
+
+void XFColumns::AddColumn(XFColumn const & column)
+{
+ m_aColumns.push_back(column);
+}
+
+void XFColumns::SetGap(double fGap)
+{
+ m_fGap = fGap;
+ m_nFlag |= XFCOLUMNS_FLAG_GAP;
+}
+
+void XFColumns::SetCount(sal_uInt16 nCount)
+{
+ m_nCount = nCount;
+}
+
+void XFColumns::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "fo:column-count", OUString::number(m_nCount));
+ if( m_nFlag&XFCOLUMNS_FLAG_GAP )
+ {
+ pAttrList->AddAttribute( "fo:column-gap", OUString::number(m_fGap)+"cm" );
+ }
+
+ pStrm->StartElement( "style:columns" );
+
+ if( m_nFlag&XFCOLUMNS_FLAG_SEPARATOR ) //column-sep:
+ {
+ m_aSeparator.ToXml(pStrm);
+ }
+
+ if(!(m_nFlag&XFCOLUMNS_FLAG_GAP) )
+ {
+ for (auto & column : m_aColumns)
+ {
+ column.ToXml(pStrm);
+ }
+ }
+ pStrm->EndElement( "style:columns" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx
new file mode 100644
index 000000000..8d669c90e
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Manager for all config object,include line number config.
+ ************************************************************************/
+#include <xfilter/xfconfigmanager.hxx>
+
+XFConfigManager::XFConfigManager() {}
+
+XFConfigManager::~XFConfigManager() {}
+
+void XFConfigManager::SetLineNumberConfig(XFLineNumberConfig* pLNConfig)
+{
+ m_pLineNumberConfig.reset(pLNConfig);
+}
+
+void XFConfigManager::SetFootnoteConfig(XFFootnoteConfig* pFNConfig)
+{
+ m_pFootnoteConfig.reset(pFNConfig);
+}
+
+void XFConfigManager::SetEndnoteConfig(XFEndnoteConfig* pENConfig)
+{
+ m_pEndnoteConfig.reset(pENConfig);
+}
+
+void XFConfigManager::ToXml(IXFStream* pStrm)
+{
+ if (m_pLineNumberConfig)
+ AddStyle(std::move(m_pLineNumberConfig));
+ if (m_pFootnoteConfig)
+ AddStyle(std::move(m_pFootnoteConfig));
+ if (m_pEndnoteConfig)
+ AddStyle(std::move(m_pEndnoteConfig));
+
+ XFStyleContainer::ToXml(pStrm);
+ XFStyleContainer::Reset();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx b/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx
new file mode 100644
index 000000000..14aaea951
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcontentcontainer.cxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Container for content.It will destroy all children when destroy.
+ ************************************************************************/
+#include <xfilter/xfcontentcontainer.hxx>
+#include <xfilter/xftextcontent.hxx>
+
+XFContentContainer::XFContentContainer()
+{
+}
+
+XFContentContainer::~XFContentContainer()
+{
+}
+
+void XFContentContainer::Add(XFContent *pContent)
+{
+ m_aContents.emplace_back(pContent);
+}
+
+void XFContentContainer::Add(const OUString& text)
+{
+ rtl::Reference<XFTextContent> xTC(new XFTextContent);
+ xTC->SetText(text);
+ Add(xTC.get());
+}
+
+bool XFContentContainer::HierarchyContains(const XFContent *pContent) const
+{
+ if (pContent == this)
+ return true;
+
+ for (int i = 0, nCount = GetCount(); i < nCount; i++)
+ {
+ rtl::Reference<XFContent> xContent = GetContent(i);
+ if (xContent.get() == pContent)
+ return true;
+ const XFContentContainer *pChildCont = dynamic_cast<const XFContentContainer*>(xContent.get());
+ if (pChildCont && pChildCont->HierarchyContains(pContent))
+ return true;
+ }
+
+ return false;
+}
+
+int XFContentContainer::GetCount() const
+{
+ return m_aContents.size();
+}
+
+void XFContentContainer::Reset()
+{
+ m_aContents.clear();
+}
+
+rtl::Reference<XFContent> XFContentContainer::FindFirstContent(enumXFContent type)
+{
+ rtl::Reference<XFContent> pRet;
+ rtl::Reference<XFContent> pContent;
+
+ for( int i=0; i<GetCount(); i++ )
+ {
+ pContent = GetContent(i);
+ if( !pContent.is() )
+ continue;
+
+ enumXFContent eType = pContent->GetContentType();
+ if( eType == type )
+ return pContent;
+ else
+ {
+ XFContentContainer *pChildCont = static_cast<XFContentContainer*>(pContent.get());
+ if( pChildCont )
+ {
+ pRet = pChildCont->FindFirstContent(type);
+ if( pRet.is() )
+ return pRet;
+ }
+ }
+ }
+ return pRet;
+}
+
+enumXFContent XFContentContainer::GetContentType()
+{
+ return enumXFContentContainer;
+}
+
+void XFContentContainer::ToXml(IXFStream *pStrm)
+{
+ for (auto const& content : m_aContents)
+ {
+ XFContent *pContent = content.get();
+ if( pContent )
+ pContent->DoToXml(pStrm);
+ }
+}
+
+rtl::Reference<XFContent> XFContentContainer::GetLastContent()
+{
+ // TODO JNA : if m_aContents size is 0, there's some pb
+ sal_uInt32 index = m_aContents.size()-1;
+ if(index >0)
+ {
+ return m_aContents[index];
+ }
+
+ return nullptr;
+}
+
+void XFContentContainer::RemoveLastContent()
+{
+ sal_uInt32 index = m_aContents.size()-1;
+ if(index >0)
+ {
+ m_aContents.erase(m_aContents.begin() + index);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfcrossref.cxx b/lotuswordpro/source/filter/xfilter/xfcrossref.cxx
new file mode 100644
index 000000000..e04052611
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfcrossref.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * index entry object.
+ ************************************************************************/
+
+#include <sal/config.h>
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xfcrossref.hxx>
+
+XFCrossRefStart::XFCrossRefStart()
+ : m_nType(CROSSREF_INVALID)
+{
+}
+
+XFCrossRefStart::~XFCrossRefStart() {}
+
+void XFCrossRefStart::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ if (m_nType == CROSSREF_TEXT)
+ {
+ pAttrList->AddAttribute("text:reference-format", "text");
+ }
+ else if (m_nType == CROSSREF_PAGE)
+ {
+ pAttrList->AddAttribute("text:reference-format", "page");
+ }
+ else if (m_nType == CROSSREF_PARANUMBER)
+ {
+ pAttrList->AddAttribute("text:reference-format", "chapter");
+ }
+ pAttrList->AddAttribute("text:ref-name", m_strMarkName);
+ pStrm->StartElement("text:bookmark-ref");
+}
+
+XFCrossRefEnd::XFCrossRefEnd() {}
+
+XFCrossRefEnd::~XFCrossRefEnd() {}
+
+void XFCrossRefEnd::ToXml(IXFStream* pStrm) { pStrm->EndElement("text:bookmark-ref"); }
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdate.cxx b/lotuswordpro/source/filter/xfilter/xfdate.cxx
new file mode 100644
index 000000000..73425802f
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdate.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Date field with date style.
+ ************************************************************************/
+#include <xfilter/xfdate.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFDate::XFDate()
+{
+}
+
+XFDate::~XFDate()
+{
+}
+
+void XFDate::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "style:data-style-name", GetStyleName() );
+
+ pStrm->StartElement( "text:date" );
+ if (!m_strText.isEmpty())
+ pStrm->Characters(m_strText);
+ pStrm->EndElement( "text:date" );
+}
+
+void XFDateStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "style:data-style-name", GetStyleName() );
+/* if (m_bValued)
+ pAttrList->AddAttribute( "text:date-value", DateTimeToOUString(m_aDateTime) );
+ if( m_bFixed )
+ pAttrList->AddAttribute( "text:fixed", "true" );
+
+ pStrm->StartElement( "text:date" );
+ if (m_strText.getLength()>0)
+ pStrm->Characters(m_strText);
+*/
+ pStrm->StartElement( "text:date" );
+}
+
+void XFDateEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:date" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdatestyle.cxx b/lotuswordpro/source/filter/xfilter/xfdatestyle.cxx
new file mode 100644
index 000000000..77eeb6aca
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdatestyle.cxx
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Date style. The date format for date field.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfdatestyle.hxx>
+
+XFDatePart::XFDatePart()
+{
+ m_bTexture = false;
+}
+
+void XFDatePart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ switch(m_ePart)
+ {
+ case enumXFDateUnknown:
+ break;
+ case enumXFDateYear:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:year" );
+ pStrm->EndElement( "number:year" );
+ break;
+ case enumXFDateMonth:
+ pAttrList->Clear();
+ if( m_bTexture )
+ pAttrList->AddAttribute( "number:textual", "true" );
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:month" );
+ pStrm->EndElement( "number:month" );
+ break;
+ case enumXFDateMonthDay:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:day" );
+ pStrm->EndElement( "number:day" );
+ break;
+ case enumXFDateWeekDay:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:day-of-week" );
+ pStrm->EndElement( "number:day-of-week" );
+ break;
+ case enumXFDateYearWeek:
+ pAttrList->Clear();
+ pStrm->StartElement( "number:week-of-year" );
+ pStrm->EndElement( "number:week-of-year" );
+ break;
+ case enumXFDateEra:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:era" );
+ pStrm->EndElement( "number:era" );
+ break;
+ case enumXFDateQuarter:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:quarter" );
+ pStrm->EndElement( "number:quarter" );
+ break;
+ case enumXFDateHour:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:hours" );
+ pStrm->EndElement( "number:hours" );
+ break;
+ case enumXFDateMinute:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:minutes" );
+ pStrm->EndElement( "number:minutes" );
+ break;
+ case enumXFDateSecond:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ if( m_nDecimalPos )
+ pAttrList->AddAttribute( "number:decimal-places", OUString::number(m_nDecimalPos) );
+ pStrm->StartElement( "number:seconds" );
+ pStrm->EndElement( "number:seconds" );
+ break;
+ case enumXFDateAmPm:
+ pStrm->StartElement( "number:am-pm" );
+ pStrm->EndElement( "number:am-pm" );
+ break;
+ case enumXFDateText:
+ pAttrList->Clear();
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters( m_strText );
+ pStrm->EndElement( "number:text" );
+ break;
+ }
+}
+
+XFDateStyle::XFDateStyle()
+{
+}
+
+XFDateStyle::~XFDateStyle()
+{
+}
+
+enumXFStyle XFDateStyle::GetStyleFamily()
+{
+ return enumXFStyleDate;
+}
+
+void XFDateStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ pAttrList->AddAttribute( "style:family", "data-style" );
+
+ pStrm->StartElement( "number:date-style" );
+
+ m_aParts.ToXml(pStrm);
+
+ pStrm->EndElement( "number:date-style" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdocfield.cxx b/lotuswordpro/source/filter/xfilter/xfdocfield.cxx
new file mode 100644
index 000000000..da32ed829
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdocfield.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * doc field.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xfdocfield.hxx>
+
+void XFFileName::SetType(const OUString& sType)
+{
+ m_strType = sType;
+}
+
+void XFFileName::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (m_strType == "FileName")
+ pAttrList->AddAttribute( "text:display", "name-and-extension" );
+ else if (m_strType == "Path")
+ pAttrList->AddAttribute( "text:display", "path" );
+ pStrm->StartElement( "text:file-name" );
+ pStrm->EndElement( "text:file-name" );
+}
+
+void XFWordCount::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:word-count" );
+ pStrm->EndElement( "text:word-count" );
+}
+
+void XFCharCount::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:character-count" );
+ pStrm->EndElement( "text:character-count" );
+}
+
+void XFDescription::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:description" );
+ pStrm->EndElement( "text:description" );
+}
+
+void XFPageCountStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:page-count" );
+}
+void XFPageCountEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:page-count" );
+}
+
+void XFWordCountStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:word-count" );
+}
+
+void XFCharCountStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:character-count" );
+}
+
+void XFDescriptionStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:description" );
+}
+
+void XFWordCountEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:word-count" );
+}
+
+void XFCharCountEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:character-count" );
+}
+
+void XFDescriptionEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:description" );
+}
+
+void XFKeywords::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:keywords" );
+ pStrm->EndElement( "text:keywords" );
+}
+
+void XFTotalEditTime::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:editing-duration" );
+ pStrm->EndElement( "text:editing-duration" );
+}
+void XFTotalEditTimeStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:editing-duration" );
+}
+void XFTotalEditTimeEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:editing-duration" );
+}
+void XFCreateTime::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:creation-time" );
+ pStrm->EndElement( "text:creation-time" );
+}
+void XFLastEditTime::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:modification-time" );
+ pStrm->EndElement( "text:modification-time" );
+}
+
+void XFCreateTimeStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:creation-time" );
+}
+
+void XFLastEditTimeStart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ if (!m_strStyleName.isEmpty())
+ pAttrList->AddAttribute( "style:data-style-name", m_strStyleName );
+ pStrm->StartElement( "text:modification-time" );
+}
+void XFCreateTimeEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:creation-time" );
+}
+
+void XFLastEditTimeEnd::ToXml(IXFStream *pStrm)
+{
+ pStrm->EndElement( "text:modification-time" );
+}
+
+void XFInitialCreator::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pStrm->StartElement( "text:initial-creator" );
+ pStrm->EndElement( "text:initial-creator" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawareastyle.cxx b/lotuswordpro/source/filter/xfilter/xfdrawareastyle.cxx
new file mode 100644
index 000000000..4f086032f
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawareastyle.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Area style of Drawing object.
+ ************************************************************************/
+#include "xfdrawareastyle.hxx"
+#include <xfilter/ixfattrlist.hxx>
+
+XFDrawAreaStyle::XFDrawAreaStyle()
+ : m_eAreaStyle(enumXFAreaSolid)
+ , m_eLineStyle(enumXFAreaLineSingle)
+ , m_nAngle(0)
+ , m_fSpace(0.18)
+{
+}
+
+enumXFStyle XFDrawAreaStyle::GetStyleFamily() { return enumXFStyleArea; }
+
+void XFDrawAreaStyle::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute("draw:name", GetStyleName());
+
+ if (m_eLineStyle == enumXFAreaLineSingle)
+ pAttrList->AddAttribute("draw:style", "single");
+ else if (m_eLineStyle == enumXFAreaLineCrossed)
+ pAttrList->AddAttribute("draw:style", "double");
+ else if (m_eLineStyle == enumXFAreaLineTriple)
+ pAttrList->AddAttribute("draw:style", "triple");
+
+ pAttrList->AddAttribute("draw:color", m_aLineColor.ToString());
+ pAttrList->AddAttribute("draw:rotation", OUString::number(m_nAngle * 10));
+ pAttrList->AddAttribute("draw:distance", OUString::number(m_fSpace) + "cm");
+
+ pStrm->StartElement("draw:hatch");
+ pStrm->EndElement("draw:hatch");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawareastyle.hxx b/lotuswordpro/source/filter/xfilter/xfdrawareastyle.hxx
new file mode 100644
index 000000000..6775b049c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawareastyle.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Area style of Drawing object.
+ * Only support fill color and fill pattern now.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFDRAWAREASTYLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFDRAWAREASTYLE_HXX
+
+#include <xfilter/xfstyle.hxx>
+#include <xfilter/xfcolor.hxx>
+
+class XFDrawAreaStyle : public XFStyle
+{
+public:
+ XFDrawAreaStyle();
+
+public:
+ void SetAreaStyle(enumXFAreaStyle style);
+
+ void SetLineStyle(enumXFAreaLineStyle style);
+
+ void SetBackColor(XFColor const & color);
+
+ void SetLineColor(XFColor const & color);
+
+ void SetLineAngle(sal_Int32 angle);
+
+ void SetLineSpace(double space);
+
+ enumXFAreaStyle GetAreaStyle() const;
+
+ const XFColor& GetBackColor() const;
+
+ virtual enumXFStyle GetStyleFamily() override;
+
+ virtual void ToXml(IXFStream *pStrm) override;
+
+private:
+ enumXFAreaStyle m_eAreaStyle;
+ enumXFAreaLineStyle m_eLineStyle;
+ XFColor m_aBackColor;
+ XFColor m_aLineColor;
+ sal_Int32 m_nAngle;
+ double m_fSpace;
+};
+
+inline void XFDrawAreaStyle::SetAreaStyle(enumXFAreaStyle style)
+{
+ m_eAreaStyle = style;
+}
+
+inline void XFDrawAreaStyle::SetLineStyle(enumXFAreaLineStyle style)
+{
+ m_eLineStyle = style;
+}
+
+inline void XFDrawAreaStyle::SetBackColor(XFColor const & color)
+{
+ m_aBackColor = color;
+}
+
+inline void XFDrawAreaStyle::SetLineColor(XFColor const & color)
+{
+ m_aLineColor = color;
+}
+
+inline void XFDrawAreaStyle::SetLineAngle(sal_Int32 angle)
+{
+ m_nAngle = angle;
+}
+
+inline void XFDrawAreaStyle::SetLineSpace(double space)
+{
+ m_fSpace = space;
+}
+
+inline enumXFAreaStyle XFDrawAreaStyle::GetAreaStyle() const
+{
+ return m_eAreaStyle;
+}
+
+inline const XFColor& XFDrawAreaStyle::GetBackColor() const
+{
+ return m_aBackColor;
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawline.cxx b/lotuswordpro/source/filter/xfilter/xfdrawline.cxx
new file mode 100644
index 000000000..32a68f9df
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawline.cxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Line object.
+ ************************************************************************/
+#include <xfilter/xfdrawline.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFDrawLine::XFDrawLine()
+{
+}
+
+void XFDrawLine::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "draw:style-name", GetStyleName() );
+
+ assert(!m_strName.isEmpty() && "name should not be null.");
+ if( !m_strName.isEmpty() )
+ pAttrList->AddAttribute( "draw:name", m_strName );
+ //anchor type:
+ switch( m_eAnchor )
+ {
+ case enumXFAnchorPara:
+ pAttrList->AddAttribute( "text:anchor-type", "paragraph" );
+ break;
+ case enumXFAnchorPage:
+ pAttrList->AddAttribute( "text:anchor-type", "page" );
+ break;
+ case enumXFAnchorChar:
+ pAttrList->AddAttribute( "text:anchor-type", "char" );
+ break;
+ case enumXFAnchorAsChar:
+ pAttrList->AddAttribute( "text:anchor-type", "as-char" );
+ break;
+ case enumXFAnchorFrame:
+ pAttrList->AddAttribute( "text:anchor-type", "frame" );
+ break;
+ default:
+ break;
+ }
+ pAttrList->AddAttribute( "draw:z-index", OUString::number(m_nZIndex) );
+
+ pAttrList->AddAttribute( "svg:x1", OUString::number(m_aPoint1.GetX()) + "cm" );
+ pAttrList->AddAttribute( "svg:y1", OUString::number(m_aPoint1.GetY()) + "cm" );
+ pAttrList->AddAttribute( "svg:x2", OUString::number(m_aPoint2.GetX()) + "cm" );
+ pAttrList->AddAttribute( "svg:y2", OUString::number(m_aPoint2.GetY()) + "cm" );
+
+ //transform
+ OUString strTransform;
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_ROTATE )
+ strTransform = "rotate (" + OUString::number(m_fRotate) + ") ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_TRANSLATE )
+ strTransform += "translate (" + OUString::number(m_aRotatePoint.GetX()) + "cm " + OUString::number(m_aRotatePoint.GetY()) + "cm) ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_SKEWX )
+ strTransform += "skewX (" + OUString::number(0) + " ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_SKEWY )
+ strTransform += "skewY (" + OUString::number(0) + " ";
+ strTransform = strTransform.trim();
+
+ if( !strTransform.isEmpty() )
+ pAttrList->AddAttribute( "draw:transform", strTransform );
+
+ pStrm->StartElement( "draw:line" );
+ ContentToXml(pStrm);
+ pStrm->EndElement( "draw:line" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawlinestyle.cxx b/lotuswordpro/source/filter/xfilter/xfdrawlinestyle.cxx
new file mode 100644
index 000000000..575e6184c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawlinestyle.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Line style of Drawing object.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfdrawlinestyle.hxx>
+
+XFDrawLineStyle::XFDrawLineStyle()
+ : m_eLineStyle(enumXFLineSolid)
+ , m_fWidth(0)
+ , m_nTransparency(0)
+ , m_nNumber1(1)
+ , m_nNumber2(1)
+ , m_fSpace(0)
+ , m_fLength1(0)
+ , m_fLength2(0)
+{
+}
+
+enumXFStyle XFDrawLineStyle::GetStyleFamily() { return enumXFStyleStrokeDash; }
+
+void XFDrawLineStyle::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute("draw:name", GetStyleName());
+ //simple place here:
+ pAttrList->AddAttribute("draw:style", "rect");
+
+ if (m_eLineStyle == enumXFLineDot)
+ {
+ }
+ else if (m_eLineStyle == enumXFLineDash)
+ {
+ pAttrList->AddAttribute("draw:dots1", OUString::number(m_nNumber1));
+ pAttrList->AddAttribute(" draw:dots1-length", OUString::number(m_fLength1) + "cm");
+
+ pAttrList->AddAttribute("draw:dots2", OUString::number(m_nNumber2));
+ pAttrList->AddAttribute(" draw:dots2-length", OUString::number(m_fLength2) + "cm");
+ }
+ else if (m_eLineStyle == enumXFLineDotDash)
+ {
+ pAttrList->AddAttribute("draw:dots1", OUString::number(m_nNumber1));
+
+ pAttrList->AddAttribute("draw:dots2", OUString::number(m_nNumber2));
+ pAttrList->AddAttribute(" draw:dots2-length", OUString::number(m_fLength2) + "cm");
+ }
+ else if (m_eLineStyle == enumXFLineDashDot)
+ {
+ pAttrList->AddAttribute("draw:dots1", OUString::number(m_nNumber1));
+ pAttrList->AddAttribute(" draw:dots1-length", OUString::number(m_fLength1) + "cm");
+
+ pAttrList->AddAttribute("draw:dots2", OUString::number(m_nNumber2));
+ }
+
+ pAttrList->AddAttribute("draw:distance", OUString::number(m_fSpace) + "cm");
+
+ pStrm->StartElement("draw:stroke-dash");
+ pStrm->EndElement("draw:stroke-dash");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawobj.cxx b/lotuswordpro/source/filter/xfilter/xfdrawobj.cxx
new file mode 100644
index 000000000..0cac7a8f7
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawobj.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Interface for all Drawing object.
+ ************************************************************************/
+#include <xfilter/xfdrawobj.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFDrawObject::XFDrawObject()
+{
+ m_fRotate = 0;
+ m_nDrawFlag = 0;
+ m_eType = enumXFFrameDrawing;
+}
+
+void XFDrawObject::ContentToXml(IXFStream *pStrm)
+{
+ XFContentContainer::ToXml(pStrm);
+}
+
+void XFDrawObject::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "draw:style-name", GetStyleName() );
+
+ assert(!m_strName.isEmpty() && "name should not be null.");
+ if( !m_strName.isEmpty() )
+ pAttrList->AddAttribute( "draw:name", m_strName );
+ //anchor type:
+ switch( m_eAnchor )
+ {
+ case enumXFAnchorPara:
+ pAttrList->AddAttribute( "text:anchor-type", "paragraph" );
+ break;
+ case enumXFAnchorPage:
+ pAttrList->AddAttribute( "text:anchor-type", "page" );
+ break;
+ case enumXFAnchorChar:
+ pAttrList->AddAttribute( "text:anchor-type", "char" );
+ break;
+ case enumXFAnchorAsChar:
+ pAttrList->AddAttribute( "text:anchor-type", "as-char" );
+ break;
+ case enumXFAnchorFrame:
+ pAttrList->AddAttribute( "text:anchor-type", "frame" );
+ break;
+ default:
+ break;
+ }
+ pAttrList->AddAttribute( "draw:z-index", OUString::number(m_nZIndex) );
+
+ pAttrList->AddAttribute( "svg:x", OUString::number(m_aRect.GetX()) + "cm" );
+ pAttrList->AddAttribute( "svg:y", OUString::number(m_aRect.GetY()) + "cm" );
+ pAttrList->AddAttribute( "svg:width", OUString::number(m_aRect.GetWidth()) + "cm" );
+ pAttrList->AddAttribute( "svg:height", OUString::number(m_aRect.GetHeight()) + "cm" );
+
+ //transform
+ OUString strTransform;
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_ROTATE )
+ strTransform = "rotate (" + OUString::number(m_fRotate) + ") ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_TRANSLATE )
+ strTransform += "translate (" + OUString::number(m_aRotatePoint.GetX()) + "cm " + OUString::number(m_aRotatePoint.GetY()) + "cm) ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_SCALE )
+ strTransform += "scale (" + OUString::number(0) + "cm " + OUString::number(0) + "cm) ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_SKEWX )
+ strTransform += "skewX (" + OUString::number(0) + " ";
+ if( m_nDrawFlag&XFDRAWOBJECT_FLAG_SKEWY )
+ strTransform += "skewY (" + OUString::number(0) + " ";
+ strTransform = strTransform.trim();
+
+ if( !strTransform.isEmpty() )
+ pAttrList->AddAttribute( "draw:transform", strTransform );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx b/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx
new file mode 100644
index 000000000..b85f2d6dc
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawpath.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Draw path object.
+ ************************************************************************/
+#include <xfilter/xfdrawpath.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <rtl/ustrbuf.hxx>
+
+XFSvgPathEntry::XFSvgPathEntry()
+{
+}
+
+OUString XFSvgPathEntry::ToString()
+{
+ assert(!m_strCommand.isEmpty());
+ OUStringBuffer str(m_strCommand);
+
+ for (auto const& point : m_aPoints)
+ {
+ str.append( OUString::number(point.GetX()*1000) + " " + OUString::number(point.GetY()*1000) + " ");
+ }
+ str.stripEnd(' ');
+ return str.makeStringAndClear();
+}
+
+XFDrawPath::XFDrawPath()
+{
+}
+
+void XFDrawPath::MoveTo(XFPoint pt)
+{
+ XFSvgPathEntry entry;
+
+ entry.SetCommand("M");
+ entry.AddPoint(pt);
+ m_aPaths.push_back(entry);
+}
+
+void XFDrawPath::LineTo(XFPoint pt)
+{
+ XFSvgPathEntry entry;
+
+ entry.SetCommand("L");
+ entry.AddPoint(pt);
+ m_aPaths.push_back(entry);
+}
+
+void XFDrawPath::CurveTo(XFPoint dest, XFPoint ctrl1, XFPoint ctrl2)
+{
+ XFSvgPathEntry entry;
+
+ entry.SetCommand("C");
+ entry.AddPoint(ctrl1);
+ entry.AddPoint(ctrl2);
+ entry.AddPoint(dest);
+
+ m_aPaths.push_back(entry);
+}
+
+void XFDrawPath::ClosePath()
+{
+ XFSvgPathEntry entry;
+
+ entry.SetCommand("Z");
+
+ m_aPaths.push_back(entry);
+}
+
+void XFDrawPath::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ //view-box:
+ XFRect rect = m_aRect;
+
+ OUString strViewBox = "0 0 " +
+ OUString::number(rect.GetWidth()*1000) + " " +
+ OUString::number(rect.GetHeight()*1000);
+ pAttrList->AddAttribute( "svg:viewBox", strViewBox);
+
+ //points
+ OUStringBuffer strPath;
+ for (auto & path : m_aPaths)
+ {
+ strPath.append(path.ToString());
+ }
+ if (!strPath.isEmpty())
+ strPath.setLength(strPath.getLength()-1);
+ pAttrList->AddAttribute( "svg:d", strPath.makeStringAndClear());
+
+ SetPosition(rect);
+ XFDrawObject::ToXml(pStrm);
+
+ pStrm->StartElement( "draw:path" );
+ ContentToXml(pStrm);
+ pStrm->EndElement( "draw:path" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawpolygon.cxx b/lotuswordpro/source/filter/xfilter/xfdrawpolygon.cxx
new file mode 100644
index 000000000..d0e023994
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawpolygon.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ */
+/*
+ * @file
+ * Polygon object.
+ */
+#include <xfilter/xfdrawpolygon.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <rtl/ustrbuf.hxx>
+
+XFDrawPolygon::XFDrawPolygon()
+{
+}
+
+void XFDrawPolygon::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ //view-box:
+ XFRect rect = CalcViewBox();
+ OUString strViewBox = "0 0 " +
+ OUString::number(rect.GetWidth()*1000) + " " +
+ OUString::number(rect.GetHeight()*1000);
+ pAttrList->AddAttribute( "svg:viewBox", strViewBox);
+
+ //points
+ OUStringBuffer strPoints;
+ for (auto const& point : m_aPoints)
+ {
+ double x = (point.GetX()-rect.GetX())*1000;
+ double y = (point.GetY()-rect.GetY())*1000;
+ strPoints.append( OUString::number(x) + " " + OUString::number(y) + " ");
+ }
+ strPoints.stripEnd(' ');
+ pAttrList->AddAttribute( "draw:points", strPoints.makeStringAndClear());
+
+ SetPosition(rect.GetX(),rect.GetY(),rect.GetWidth(),rect.GetHeight());
+ XFDrawObject::ToXml(pStrm);
+
+ pStrm->StartElement( "draw:polygon" );
+ ContentToXml(pStrm);
+ pStrm->EndElement( "draw:polygon" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawpolyline.cxx b/lotuswordpro/source/filter/xfilter/xfdrawpolyline.cxx
new file mode 100644
index 000000000..6f5fb1a0f
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawpolyline.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Polyline.
+ ************************************************************************/
+#include <xfilter/xfdrawpolyline.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <rtl/ustrbuf.hxx>
+
+XFDrawPolyline::XFDrawPolyline()
+{
+}
+
+void XFDrawPolyline::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ //view-box:
+ XFRect rect = CalcViewBox();
+ OUString strViewBox = "0 0 " +
+ OUString::number(rect.GetWidth()*1000) + " " +
+ OUString::number(rect.GetHeight()*1000);
+ pAttrList->AddAttribute( "svg:viewBox", strViewBox);
+
+ //points
+ OUStringBuffer strPoints;
+ for (auto const& point : m_aPoints)
+ {
+ double x = (point.GetX()-rect.GetX())*1000;
+ double y = (point.GetY()-rect.GetY())*1000;
+ strPoints.append( OUString::number(x) + "," + OUString::number(y) + " ");
+ }
+ strPoints.stripEnd(' ');
+ pAttrList->AddAttribute( "draw:points", strPoints.makeStringAndClear());
+
+ SetPosition(rect.GetX(),rect.GetY(),rect.GetWidth(),rect.GetHeight());
+ XFDrawObject::ToXml(pStrm);
+
+ pStrm->StartElement( "draw:polyline" );
+ ContentToXml(pStrm);
+ pStrm->EndElement( "draw:polyline" );
+}
+
+XFRect XFDrawPolyline::CalcViewBox()
+{
+ double x1 = 0;
+ double y1 = 0;
+ double x2 = 0;
+ double y2 = 0;
+ XFPoint aPoint;
+
+ assert(!m_aPoints.empty());
+
+ x1 = aPoint.GetX();
+ x2 = aPoint.GetX();
+ y1 = aPoint.GetY();
+ y2 = aPoint.GetY();
+ for (auto const& point : m_aPoints)
+ {
+ if( x1>point.GetX() )
+ x1 = point.GetX();
+ if( x2<point.GetX() )
+ x2 = point.GetX();
+
+ if( y1>point.GetY() )
+ y1 = point.GetY();
+ if( y2<point.GetY() )
+ y2 = point.GetY();
+ }
+ return XFRect(x1,y1,x2-x1,y2-y1);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawrect.cxx b/lotuswordpro/source/filter/xfilter/xfdrawrect.cxx
new file mode 100644
index 000000000..6f613b153
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawrect.cxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Rect object.
+ ************************************************************************/
+#include <xfilter/xfdrawrect.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFDrawRect::XFDrawRect() {}
+
+void XFDrawRect::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+
+ XFDrawObject::ToXml(pStrm);
+
+ pStrm->StartElement("draw:rect");
+ ContentToXml(pStrm);
+ pStrm->EndElement("draw:rect");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
new file mode 100644
index 000000000..f824dd5a8
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
@@ -0,0 +1,327 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Style for all draw object.
+ ************************************************************************/
+#include <xfilter/xfdrawstyle.hxx>
+#include <xfilter/xfdrawlinestyle.hxx>
+#include <xfilter/xfglobal.hxx>
+#include "xfdrawareastyle.hxx"
+#include <xfilter/xfstylemanager.hxx>
+#include "xffontworkstyle.hxx"
+#include <lwpglobalmgr.hxx>
+XFDrawStyle::XFDrawStyle()
+ : m_pLineStyle(nullptr)
+ , m_pAreaStyle(nullptr)
+ , m_fArrowStartSize(0.3)
+ , m_fArrowEndSize(0.3)
+ , m_bArrowStartCenter(false)
+ , m_bArrowEndCenter(false)
+ , m_bLineStyleRegistered(false)
+ , m_bAreaStyleRegistered(false)
+{}
+
+XFDrawStyle::~XFDrawStyle()
+{
+ // normally don't delete m_pLineStyle, it was managed by XFStyleManager.
+ if (!m_bLineStyleRegistered)
+ delete m_pLineStyle;
+ // normally don't delete m_pAreaStyle, it was managed by XFStyleManager.
+ if (!m_bAreaStyleRegistered)
+ delete m_pAreaStyle;
+}
+
+void XFDrawStyle::SetLineStyle(double width, XFColor color)
+{
+ if( !m_pLineStyle )
+ {
+ m_pLineStyle = new XFDrawLineStyle();
+ m_pLineStyle->SetStyleName( XFGlobal::GenStrokeDashName());
+ }
+ m_pLineStyle->SetWidth(width);
+ m_pLineStyle->SetColor(color);
+ m_pLineStyle->SetTransparency(0);
+}
+
+void XFDrawStyle::SetLineDashStyle(enumXFLineStyle style, double len1, double len2, double space )
+{
+ if( !m_pLineStyle )
+ {
+ m_pLineStyle = new XFDrawLineStyle();
+ m_pLineStyle->SetStyleName( XFGlobal::GenStrokeDashName());
+ }
+ m_pLineStyle->SetLineStyle(style);
+ m_pLineStyle->SetDot1Number(1);
+ m_pLineStyle->SetDot1Length(len1);
+ m_pLineStyle->SetDot2Number(1);
+ m_pLineStyle->SetDot2Length(len2);
+ m_pLineStyle->SetSpace(space);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_bLineStyleRegistered = true;
+ pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pLineStyle));
+}
+
+void XFDrawStyle::SetFontWorkStyle(enumXFFWStyle eStyle, enumXFFWAdjust eAdjust)
+{
+ if (!m_pFontWorkStyle)
+ {
+ m_pFontWorkStyle.reset( new XFFontWorkStyle() );
+ }
+
+ m_pFontWorkStyle->SetButtonForm(0);
+ m_pFontWorkStyle->SetFWStyleType(eStyle);
+ m_pFontWorkStyle->SetFWAdjustType(eAdjust);
+}
+
+void XFDrawStyle::SetAreaColor(XFColor const & color)
+{
+ if( !m_pAreaStyle )
+ {
+ m_pAreaStyle = new XFDrawAreaStyle();
+ m_pAreaStyle->SetStyleName( XFGlobal::GenAreaName());
+ }
+ m_pAreaStyle->SetBackColor(color);
+}
+
+void XFDrawStyle::SetAreaLineStyle(enumXFAreaLineStyle style, sal_Int32 angle, double space, XFColor lineColor)
+{
+ if( !m_pAreaStyle )
+ {
+ m_pAreaStyle = new XFDrawAreaStyle();
+ m_pAreaStyle->SetStyleName( XFGlobal::GenAreaName());
+ }
+ m_pAreaStyle->SetAreaStyle(enumXFAreaHatch);
+
+ m_pAreaStyle->SetLineStyle(style);
+ m_pAreaStyle->SetLineAngle(angle);
+ m_pAreaStyle->SetLineSpace(space);
+ m_pAreaStyle->SetLineColor(lineColor);
+ XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
+ m_bAreaStyleRegistered = true;
+ pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pAreaStyle));
+}
+
+enumXFStyle XFDrawStyle::GetStyleFamily()
+{
+ return enumXFStyleGraphics;
+}
+
+/**************************************************************************
+ *************************************************************************/
+void XFDrawStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ pAttrList->AddAttribute( "style:family", "graphics" );
+ pStrm->StartElement( "style:style" );
+
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:run-through", "foreground" );
+ pAttrList->AddAttribute( "style:wrap", "none" );
+
+ //line style:
+ if( m_pLineStyle )
+ {
+ //1. if is a dash style, register the stroke-dash style first.
+ if( !m_pLineStyle->IsSolid() )
+ {
+// pAttrList->Clear();
+ pAttrList->AddAttribute( "draw:stroke", "dash" );
+ pAttrList->AddAttribute( "draw:stroke-dash", m_pLineStyle->GetStyleName() );
+ }
+ else
+ {
+ pAttrList->AddAttribute( "draw:stroke", "solid" );
+ }
+
+ if( m_pLineStyle->GetWidth() > 0 )
+ pAttrList->AddAttribute( "svg:stroke-width", OUString::number(m_pLineStyle->GetWidth()) + "cm" );
+
+ XFColor color = m_pLineStyle->GetColor();
+ if( color.IsValid() )
+ pAttrList->AddAttribute( "svg:stroke-color", color.ToString() );
+
+ if( m_pLineStyle->GetTransparency()>0 )
+ pAttrList->AddAttribute( "svg:stroke-opacity", OUString::number(m_pLineStyle->GetTransparency()) + "%" );
+ }
+ else
+ pAttrList->AddAttribute( "draw:stroke", "none" );
+ //area style:
+ if( m_pAreaStyle )
+ {
+ if( enumXFAreaSolid == m_pAreaStyle->GetAreaStyle() )
+ {
+ pAttrList->AddAttribute( "draw:fill", "solid" );
+ XFColor color = m_pAreaStyle->GetBackColor();
+ if( color.IsValid() )
+ pAttrList->AddAttribute( "draw:fill-color", color.ToString() );
+ }
+ else if( enumXFAreaHatch == m_pAreaStyle->GetAreaStyle() )
+ {
+ pAttrList->AddAttribute( "draw:fill", "hatch" );
+ pAttrList->AddAttribute( "draw:fill-hatch-name", m_pAreaStyle->GetStyleName() );
+ XFColor color = m_pAreaStyle->GetBackColor();
+ if( color.IsValid() )
+ {
+ pAttrList->AddAttribute( "draw:fill-hatch-solid", "true" );
+ pAttrList->AddAttribute( "draw:fill-color", color.ToString() );
+ }
+ }
+ }
+ else
+ pAttrList->AddAttribute( "draw:fill", "none" );
+
+ if( !m_strArrowStart.isEmpty() )
+ {
+ pAttrList->AddAttribute( "draw:marker-start", m_strArrowStart );
+ pAttrList->AddAttribute( "draw:marker-start-width", OUString::number(m_fArrowStartSize)+"cm" );
+ if( m_bArrowStartCenter )
+ pAttrList->AddAttribute( "draw:draw:marker-start-center", "true" );
+ }
+ if( !m_strArrowEnd.isEmpty() )
+ {
+ pAttrList->AddAttribute( "draw:marker-end", m_strArrowEnd );
+ pAttrList->AddAttribute( "draw:marker-end-width", OUString::number(m_fArrowEndSize)+"cm" );
+ if( m_bArrowEndCenter )
+ pAttrList->AddAttribute( "draw:draw:marker-end-center", "true" );
+ }
+ if (m_pFontWorkStyle)
+ {
+ // style
+ OUString aStr = "";
+ switch (m_pFontWorkStyle->GetStyleType())
+ {
+ default: // fall through!
+ case enumXFFWOff:
+ break;
+ case enumXFFWRotate:
+ aStr = "rotate";
+ break;
+ case enumXFFWUpright:
+ aStr = "upright";
+ break;
+ case enumXFFWSlantX:
+ aStr = "slant-x";
+ break;
+ case enumXFFWSlantY:
+ aStr = "slant-y";
+ break;
+ }
+ if (!aStr.isEmpty())
+ {
+ pAttrList->AddAttribute("draw:fontwork-style", aStr);
+ }
+
+ //adjust
+ aStr.clear();
+ switch (m_pFontWorkStyle->GetAdjustType())
+ {
+ default: // fall through
+ case enumXFFWAdjustAutosize:
+ aStr = "autosize";
+ break;
+ case enumXFFWAdjustLeft:
+ aStr = "left";
+ break;
+ case enumXFFWAdjustCenter:
+ aStr = "center";
+ break;
+ case enumXFFWAdustRight:
+ aStr = "right";
+ break;
+ }
+ if (!aStr.isEmpty())
+ {
+ pAttrList->AddAttribute("draw:fontwork-adjust", aStr);
+ }
+
+ //form
+ aStr.clear();
+ switch (m_pFontWorkStyle->GetButtonForm())
+ {
+ default: // fall through!
+ case -1:
+ break;
+ case 4:
+ aStr = "top-arc";
+ break;
+ case 5:
+ aStr = "bottom-arc";
+ break;
+ }
+ if (!aStr.isEmpty())
+ {
+ pAttrList->AddAttribute("draw:fontwork-form", aStr);
+ }
+
+ // distance
+ //pAttrList->AddAttribute("draw:fontwork-distance",
+ // OUString::number(m_pFontWorkStyle->GetFWDistance())+"cm");
+ }
+
+ pStrm->StartElement( "style:properties" );
+
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfentry.cxx b/lotuswordpro/source/filter/xfilter/xfentry.cxx
new file mode 100644
index 000000000..d252cc2bc
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfentry.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * index entry object.
+ ************************************************************************/
+
+#include <sal/config.h>
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xfentry.hxx>
+
+XFEntry::XFEntry()
+ : m_eType(enumXFEntryTOC)
+ , m_nOutlineLevel(1)
+{
+}
+
+void XFEntry::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute("text:string-value", m_strValue);
+
+ if (m_eType == enumXFEntryTOC)
+ {
+ pAttrList->AddAttribute("text:outline-level", OUString::number(m_nOutlineLevel));
+ pStrm->StartElement("text:toc-mark");
+ // pStrm->Characters(m_strDisplay);
+ pStrm->EndElement("text:toc-mark");
+ }
+ else if (m_eType == enumXFEntryAlphabetical)
+ {
+ pAttrList->AddAttribute("text:key1", m_strKey1);
+ if (!m_strKey2.isEmpty())
+ pAttrList->AddAttribute("text:key2", m_strKey2);
+
+ pStrm->StartElement("text:alphabetical-index-mark");
+ // pStrm->Characters(m_strDisplay);
+ pStrm->EndElement("text:alphabetical-index-mark");
+ }
+ else if (m_eType == enumXFEntryUserIndex)
+ {
+ pAttrList->AddAttribute("text:outline-level", OUString::number(m_nOutlineLevel));
+ pAttrList->AddAttribute("text:index-name", m_strName);
+
+ pStrm->StartElement("text:user-index-mark");
+ // pStrm->Characters(m_strDisplay);
+ pStrm->EndElement("text:user-index-mark");
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xffloatframe.cxx b/lotuswordpro/source/filter/xfilter/xffloatframe.cxx
new file mode 100644
index 000000000..7a27242cd
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xffloatframe.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Float frame whose anchor is page.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xffloatframe.hxx>
+
+XFFloatFrame::XFFloatFrame(sal_Int32 start, sal_Int32 end, bool all)
+{
+ m_nStart = start;
+ m_nEnd = end;
+ m_bAll = all;
+ SetAnchorType(enumXFAnchorPage);
+}
+
+void XFFloatFrame::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ for (int i = m_nStart; i <= m_nEnd; i++)
+ {
+ XFFrame::SetAnchorPage(i);
+ XFFrame::ToXml(pStrm);
+ if (!m_bAll)
+ i++;
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xffont.cxx b/lotuswordpro/source/filter/xfilter/xffont.cxx
new file mode 100644
index 000000000..14bb56db6
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xffont.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Font object to serial to xml filter.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xffont.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFFont::XFFont()
+ : m_nFontSize(0)
+ , m_nFontSizeAsia(0)
+ , m_nFontSizeComplex(0)
+ , m_bItalic(false)
+ , m_bItalicAsia(false)
+ , m_bItalicComplex(false)
+ , m_bBold(false)
+ , m_bBoldAsia(false)
+ , m_bBoldComplex(false)
+ , m_eUnderline(enumXFUnderlineNone)
+ , m_eCrossout(enumXFCrossoutNone)
+ , m_eTransform(enumXFTransformNone)
+ , m_bWordByWord(false)
+ , m_nPosition(33)
+ , m_nScale(58)
+ , m_nFlag(0)
+ , m_bTransparent(false)
+{
+}
+/*
+ The Following variable are to be compared:
+ OUString m_strFontName;
+ OUString m_strFontNameAsia;
+ OUString m_strFontNameComplex;
+ sal_Int16 m_nFontSize;
+ sal_Int16 m_nFontSizeAsia;
+ sal_Int16 m_nFontSizeComplex;
+ sal_Bool m_bItalic;
+ sal_Bool m_bItalicAsia;
+ sal_Bool m_bItalicComplex;
+ sal_Bool m_bBold;
+ sal_Bool m_bBoldAsia;
+ sal_Bool m_bBoldComplex;
+ sal_Int16 m_nUnderline;
+ sal_uInt32 m_nUnderlineColor;
+
+ sal_uInt32 m_nFlag;
+*/
+bool operator==(XFFont const & f1, XFFont const & f2)
+{
+ //The most possible entry be first:
+ if( f1.m_nFlag != f2.m_nFlag )
+ return false;
+
+ if( f1.m_strFontName != f2.m_strFontName ||
+ f1.m_strFontNameAsia != f2.m_strFontNameAsia ||
+ f1.m_strFontNameComplex != f2.m_strFontNameComplex
+ )
+ return false;
+
+ if( f1.m_nFontSize != f2.m_nFontSize ||
+ f1.m_nFontSizeAsia != f2.m_nFontSizeAsia ||
+ f1.m_nFontSizeComplex != f2.m_nFontSizeComplex
+ )
+ return false;
+
+ if( f1.m_bItalic != f2.m_bItalic ||
+ f1.m_bItalicAsia != f2.m_bItalicAsia ||
+ f1.m_bItalicComplex != f2.m_bItalicComplex
+ )
+ return false;
+
+ if( f1.m_bBold != f2.m_bBold ||
+ f1.m_bBoldAsia != f2.m_bBoldAsia ||
+ f1.m_bBoldComplex != f2.m_bBoldComplex
+ )
+ return false;
+
+ if( f1.m_nFlag&XFFONT_FLAG_UNDERLINE )
+ {
+ if( f1.m_eUnderline != f2.m_eUnderline )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_UNDERLINECOLOR )
+ {
+ if( f1.m_aUnderlineColor != f2.m_aUnderlineColor )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_CROSSOUT )
+ {
+ if( f1.m_eCrossout != f2.m_eCrossout )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_TRANSFORM )
+ {
+ if( f1.m_eTransform != f2.m_eTransform )
+ return false;
+ }
+
+ if( f1.m_bWordByWord != f2.m_bWordByWord )
+ return false;
+
+ if( f1.m_nFlag&XFFONT_FLAG_POSITION )
+ {
+ if( f1.m_nPosition != f2.m_nPosition )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_SCALE )
+ {
+ if( f1.m_nScale != f2.m_nScale )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_COLOR )
+ {
+ if( f1.m_aColor != f2.m_aColor )
+ return false;
+ }
+
+ if( f1.m_nFlag&XFFONT_FLAG_BGCOLOR )
+ {
+ if( f1.m_aBackColor != f2.m_aBackColor )
+ return false;
+ }
+
+ return true;
+}
+
+bool operator!=(XFFont const & f1, XFFont const & f2)
+{
+ return !(f1==f2);
+}
+
+void XFFont::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( m_nFlag & XFFONT_FLAG_NAME )
+ {
+ pAttrList->AddAttribute("style:font-name",m_strFontName );
+ }
+
+ if( m_nFlag & XFFONT_FLAG_NAME_ASIA )
+ {
+ pAttrList->AddAttribute("style:font-name-asian",m_strFontNameAsia );
+ }
+
+ if( m_nFlag & XFFONT_FLAG_NAME_COMPLEX )
+ {
+ pAttrList->AddAttribute("style:font-name-complex", m_strFontNameComplex);
+ }
+
+ //font size:
+ if( (m_nFlag & XFFONT_FLAG_SIZE) && m_nFontSize != 0 )
+ {
+ OUString strSize = OUString::number(m_nFontSize) + "pt";
+ pAttrList->AddAttribute("fo:font-size",strSize);
+ }
+ if( (m_nFlag & XFFONT_FLAG_SIZE_ASIA) && m_nFontSizeAsia )
+ {
+ OUString strSize = OUString::number(m_nFontSizeAsia) + "pt";
+ pAttrList->AddAttribute("style:font-size-asian",strSize);
+ }
+ if( (m_nFlag & XFFONT_FLAG_SIZE_COMPLEX) && m_nFontSizeComplex )
+ {
+ OUString strSize = OUString::number(m_nFontSizeComplex) + "pt";
+ pAttrList->AddAttribute("style:font-size-complex",strSize);
+ }
+
+ //italic flag:
+ if( ( m_nFlag & XFFONT_FLAG_ITALIC) && m_bItalic )
+ {
+ pAttrList->AddAttribute("fo:font-style", "italic");
+ }
+ if( (m_nFlag & XFFONT_FLAG_ITALIC_ASIA) && m_bItalicAsia )
+ {
+ pAttrList->AddAttribute("style:font-style-asian", "italic");
+ }
+ if( (m_nFlag & XFFONT_FLAG_ITALIC_COMPLEX) && m_bItalicComplex )
+ {
+ pAttrList->AddAttribute("style:font-style-complex", "italic");
+ }
+
+ //Bold flag:
+ if( (m_nFlag & XFFONT_FLAG_BOLD) && m_bBold )
+ {
+ pAttrList->AddAttribute("fo:font-weight", "bold");
+ }
+ if( (m_nFlag & XFFONT_FLAG_BOLD_ASIA) && m_bBoldAsia )
+ {
+ pAttrList->AddAttribute("style:font-weight-asian", "bold");
+ }
+ if( (m_nFlag & XFFONT_FLAG_BOLD_ASIA) && m_bBoldComplex )
+ {
+ pAttrList->AddAttribute("style:font-weight-complex", "bold");
+ }
+ //underline:
+ if( (m_nFlag & XFFONT_FLAG_UNDERLINE) && m_eUnderline )
+ {
+ pAttrList->AddAttribute("style:text-underline", GetUnderlineName(m_eUnderline) );
+ if( m_nFlag & XFFONT_FLAG_UNDERLINECOLOR )
+ {
+ pAttrList->AddAttribute( "style:text-underline-color", m_aUnderlineColor.ToString() );
+ }
+ else
+ pAttrList->AddAttribute( "style:text-underline-color", "font-color" );
+ }
+
+ //enumCrossoutType m_eCrossout;
+ if( (m_nFlag & XFFONT_FLAG_CROSSOUT) && m_eCrossout )
+ {
+ pAttrList->AddAttribute("style:text-crossing-out", GetCrossoutName(m_eCrossout) );
+ }
+
+ if( m_nFlag & XFFONT_FLAG_UNDERLINE || m_nFlag & XFFONT_FLAG_CROSSOUT )
+ {
+ if( m_bWordByWord )
+ pAttrList->AddAttribute("fo:score-spaces", "false" );
+ else
+ pAttrList->AddAttribute("fo:score-spaces", "true" );
+ }
+
+ if( (m_nFlag & XFFONT_FLAG_TRANSFORM) && m_eTransform )
+ {
+ //enumTransformSmallCap is different:
+ if( m_eTransform == enumXFTransformSmallCaps )
+ pAttrList->AddAttribute("fo:font-variant", GetTransformName(m_eTransform) );
+ else
+ pAttrList->AddAttribute("fo:text-transform", GetTransformName(m_eTransform) );
+ }
+
+ //position & scale:
+ if( ((m_nFlag & XFFONT_FLAG_SCALE) && m_nScale>0 ) ||
+ ((m_nFlag & XFFONT_FLAG_POSITION) && m_nPosition != 0)
+ )
+ {
+ OUString tmp = OUString::number(m_nPosition) + "% "
+ + OUString::number(m_nScale) + "%";
+ pAttrList->AddAttribute("style:text-position", tmp );
+ }
+
+ //Color:
+ if( m_nFlag & XFFONT_FLAG_COLOR )
+ {
+ pAttrList->AddAttribute( "fo:color", m_aColor.ToString() );
+ }
+
+ if( m_nFlag & XFFONT_FLAG_BGCOLOR )
+ {
+ if (m_bTransparent)
+ pAttrList->AddAttribute( "style:text-background-color", "transparent");
+ else
+ pAttrList->AddAttribute( "style:text-background-color", m_aBackColor.ToString() );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xffontdecl.cxx b/lotuswordpro/source/filter/xfilter/xffontdecl.cxx
new file mode 100644
index 000000000..b971a2073
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xffontdecl.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Font decl of all used fonts.
+ ************************************************************************/
+#include <xfilter/xffontdecl.hxx>
+
+XFFontDecl::XFFontDecl(const OUString& name, const OUString& family)
+{
+ m_strFontName = name;
+ m_strFontFamily = family;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xffontfactory.cxx b/lotuswordpro/source/filter/xfilter/xffontfactory.cxx
new file mode 100644
index 000000000..30a682433
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xffontfactory.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Implement for font factory which will manage all font.
+ ************************************************************************/
+#include <xfilter/xffontfactory.hxx>
+
+XFFontFactory::XFFontFactory() {}
+
+XFFontFactory::~XFFontFactory() {}
+
+void XFFontFactory::AddFont(rtl::Reference<XFFont> const& pFont) { s_aFonts.push_back(pFont); }
+
+rtl::Reference<XFFont> XFFontFactory::FindSameFont(rtl::Reference<XFFont> const& pFont)
+{
+ for (auto const& font : s_aFonts)
+ {
+ if (*pFont == *font)
+ return font;
+ }
+
+ return nullptr;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xffontworkstyle.hxx b/lotuswordpro/source/filter/xfilter/xffontworkstyle.hxx
new file mode 100644
index 000000000..1554fdaf7
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xffontworkstyle.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Style of Fontwork object.
+ ************************************************************************/
+
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONTWORKSTYLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONTWORKSTYLE_HXX
+
+#include <sal/types.h>
+#include <xfilter/xfdefs.hxx>
+
+class XFFontWorkStyle
+{
+public:
+ XFFontWorkStyle() :
+ m_nButtonForm(-1),
+ m_eStyleType(enumXFFWOff),
+ m_eAdjustType(enumXFFWAdjustAutosize)
+ {}
+
+ inline void SetButtonForm(sal_Int8 nIndex);
+ inline void SetFWStyleType(enumXFFWStyle eStyle);
+ inline void SetFWAdjustType(enumXFFWAdjust eAdjust);
+
+ inline sal_Int8 GetButtonForm() const;
+ inline enumXFFWStyle GetStyleType() const;
+ inline enumXFFWAdjust GetAdjustType() const;
+
+private:
+ sal_Int8 m_nButtonForm;
+ enumXFFWStyle m_eStyleType;
+ enumXFFWAdjust m_eAdjustType;
+};
+
+inline void XFFontWorkStyle::SetButtonForm(sal_Int8 nIndex)
+{
+ m_nButtonForm = nIndex;
+}
+
+inline void XFFontWorkStyle::SetFWStyleType(enumXFFWStyle eStyle)
+{
+ m_eStyleType = eStyle;
+}
+
+inline void XFFontWorkStyle::SetFWAdjustType(enumXFFWAdjust eAdjust)
+{
+ m_eAdjustType = eAdjust;
+}
+
+inline sal_Int8 XFFontWorkStyle::GetButtonForm() const
+{
+ return m_nButtonForm;
+}
+
+inline enumXFFWStyle XFFontWorkStyle::GetStyleType() const
+{
+ return m_eStyleType;
+}
+inline enumXFFWAdjust XFFontWorkStyle::GetAdjustType() const
+{
+ return m_eAdjustType;
+}
+
+#endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONTWORKSTYLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfframe.cxx b/lotuswordpro/source/filter/xfilter/xfframe.cxx
new file mode 100644
index 000000000..62bd2caf2
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfframe.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Frame whose anchor is not page.
+ ************************************************************************/
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfframe.hxx>
+
+#define ZINDEX_MIN 0
+
+XFFrame::XFFrame()
+ : XFFrame::XFFrame(false)
+{}
+
+XFFrame::XFFrame(bool isTextBox)
+ : m_eAnchor(enumXFAnchorPara)
+ , m_nAnchorPage(0)
+ , m_strName(XFGlobal::GenFrameName()) // give it a default name
+ , m_nZIndex(ZINDEX_MIN)
+ , m_fMinHeight(0)
+ , m_eType(enumXFFrameTextbox)
+ , m_nFrameFlag(0)
+ , m_isTextBox(isTextBox)
+{}
+
+XFFrame::~XFFrame()
+{
+}
+
+void XFFrame::Add(XFContent *pContent)
+{
+ if (!pContent)
+ return;
+ XFContentContainer::Add(pContent);
+ if( pContent->GetContentType() == enumXFContentFrame )
+ {
+ XFFrame *pFrame = static_cast<XFFrame*>(pContent);
+ if( pFrame )
+ {
+ pFrame->SetZIndex(pFrame->m_nZIndex + 1);
+ }
+ }
+
+}
+
+void XFFrame::SetZIndex(sal_uInt32 zIndex)
+{
+ if( zIndex == m_nZIndex )
+ return;
+ m_nZIndex = zIndex;
+ AdjustZIndex();
+}
+
+enumXFFrameType XFFrame::GetFrameType() const
+{
+ return m_eType;
+}
+
+enumXFContent XFFrame::GetContentType()
+{
+ return enumXFContentFrame;
+}
+
+void XFFrame::ToXml(IXFStream *pStrm)
+{
+ StartFrame(pStrm);
+
+ XFContentContainer::ToXml(pStrm);
+
+ EndFrame(pStrm);
+}
+
+void XFFrame::StartFrame(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "draw:style-name", GetStyleName() );
+
+ assert(!m_strName.isEmpty() && "name should not be null.");
+ if( !m_strName.isEmpty() && !m_isTextBox)
+ pAttrList->AddAttribute( "draw:name", m_strName );
+ //anchor type:
+ switch( m_eAnchor )
+ {
+ case enumXFAnchorPara:
+ pAttrList->AddAttribute( "text:anchor-type", "paragraph" );
+ break;
+ case enumXFAnchorPage:
+ pAttrList->AddAttribute( "text:anchor-type", "page" );
+ pAttrList->AddAttribute( "text:anchor-page-number", OUString::number(m_nAnchorPage) );
+ break;
+ case enumXFAnchorChar:
+ pAttrList->AddAttribute( "text:anchor-type", "char" );
+ break;
+ case enumXFAnchorAsChar:
+ pAttrList->AddAttribute( "text:anchor-type", "as-char" );
+ break;
+ case enumXFAnchorFrame:
+ pAttrList->AddAttribute( "text:anchor-type", "frame" );
+ break;
+ default:
+ break;
+ }
+ pAttrList->AddAttribute( "svg:x", OUString::number(m_aRect.GetX()) + "cm" );
+ pAttrList->AddAttribute( "svg:y", OUString::number(m_aRect.GetY()) + "cm" );
+ pAttrList->AddAttribute( "svg:width", OUString::number(m_aRect.GetWidth()) + "cm" );
+ if( m_nFrameFlag& XFFRAME_FLAG_MINHEIGHT )
+ {
+ pAttrList->AddAttribute( "fo:min-height", OUString::number(m_fMinHeight) + "cm" );
+ if( m_nFrameFlag&XFFRAME_FLAG_MAXHEIGHT )
+ pAttrList->AddAttribute( "fo:max-height", OUString::number(0) + "cm" );
+ }
+ else
+ pAttrList->AddAttribute( "svg:height", OUString::number(m_aRect.GetHeight()) + "cm" );
+
+ pAttrList->AddAttribute( "draw:z-index", OUString::number(m_nZIndex) );
+
+ if( !m_strNextLink.isEmpty() )
+ pAttrList->AddAttribute( "draw:chain-next-name", m_strNextLink );
+
+ pStrm->StartElement( "draw:text-box" );
+}
+
+void XFFrame::EndFrame(IXFStream *pStrm)
+{
+ pStrm->EndElement( "draw:text-box" );
+}
+
+void XFFrame::AdjustZIndex()
+{
+ for( int i=0; i<GetCount(); i++ )
+ {
+ rtl::Reference<XFContent> pContent = GetContent(i);
+ if( pContent.is() )
+ {
+ if( pContent->GetContentType() == enumXFContentFrame )
+ {
+ XFFrame *pFrame = static_cast<XFFrame*>(pContent.get());
+ pFrame->m_nZIndex = m_nZIndex + 1;
+ pFrame->AdjustZIndex();
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfframestyle.cxx b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx
new file mode 100644
index 000000000..e3c5b315c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Frame style include position,size,rotation and so on.
+ ************************************************************************/
+#include <xfilter/xfframestyle.hxx>
+#include <xfilter/xfcolumns.hxx>
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xfshadow.hxx>
+#include <xfilter/xfbgimage.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFFrameStyle::XFFrameStyle()
+ : m_eWrap(enumXFWrapNone)
+ , m_bProtectContent(false)
+ , m_bProtectSize(false)
+ , m_bProtectPos(false)
+ , m_nTransparency(0)
+ , m_eTextDir(enumXFTextDirNone)
+ , m_eXPos(enumXFFrameXPosCenter)
+ , m_eXRel(enumXFFrameXRelParaContent)
+ , m_eYPos(enumXFFrameYPosTop)
+ , m_eYRel(enumXFFrameYRelPage)
+{}
+
+XFFrameStyle::~XFFrameStyle()
+{
+}
+
+void XFFrameStyle::SetBorders(std::unique_ptr<XFBorders> pBorders)
+{
+ m_pBorders = std::move(pBorders);
+}
+
+void XFFrameStyle::SetColumns(XFColumns *pColumns)
+{
+ m_pColumns.reset(pColumns);
+}
+
+void XFFrameStyle::SetShadow(XFShadow *pShadow)
+{
+ m_pShadow.reset(pShadow);
+}
+
+void XFFrameStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_pBGImage = std::move(rImage);
+}
+
+enumXFStyle XFFrameStyle::GetStyleFamily()
+{
+ return enumXFStyleGraphics;
+}
+
+void XFFrameStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( GetParentStyleName().getLength() > 0 )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pAttrList->AddAttribute( "style:family", "graphics" );
+ //parent style name ignore now.
+ pStrm->StartElement( "style:style" );
+
+ m_aMargins.ToXml(pStrm);
+
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:run-through", "foreground" );
+
+ if( m_eWrap == enumXFWrapNone )
+ pAttrList->AddAttribute( "style:wrap", "none" );
+ else if( m_eWrap == enumXFWrapLeft )
+ pAttrList->AddAttribute( "style:wrap", "left" );
+ else if( m_eWrap == enumXFWrapRight )
+ pAttrList->AddAttribute( "style:wrap", "right" );
+ else if( m_eWrap == enumXFWrapParallel )
+ pAttrList->AddAttribute( "style:wrap", "parallel" );
+ else if( m_eWrap == enumXFWrapRunThrough )
+ pAttrList->AddAttribute( "style:wrap", "run-through" );
+ else if( m_eWrap == enumXFWrapBest )
+ pAttrList->AddAttribute( "style:wrap", "dynamic" );
+ //}
+ //background
+ if( m_aBackColor.IsValid() )
+ {
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+ pAttrList->AddAttribute( "style:background-transparency", OUString::number(static_cast<sal_Int32>(m_nTransparency)) + "%");
+ }
+
+ //pad
+ m_aPad.ToXml(pStrm);
+ //margin:
+ m_aMargins.ToXml(pStrm);
+ //border
+ if( m_pBorders )
+ m_pBorders->ToXml(pStrm);
+ else
+ pAttrList->AddAttribute( "fo:border", "none" );
+ //shadow
+ if( m_pShadow )
+ m_pShadow->ToXml(pStrm);
+ //print
+ pAttrList->AddAttribute( "style:print-content", "true" );
+ //text directory
+ if( m_eTextDir != enumXFTextDirNone )
+ pAttrList->AddAttribute( "style:writing-mode", GetTextDirName(m_eTextDir) );
+ //protect:
+ if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
+ {
+ OUString protect;
+ if( m_bProtectContent )
+ protect += "content";
+ if( m_bProtectSize )
+ {
+ if( protect.getLength()>0 )
+ protect += " ";
+ protect += "size";
+ }
+ if( m_bProtectPos )
+ {
+ if( protect.getLength()>0 )
+ protect += " ";
+ protect += "position";
+ }
+ pAttrList->AddAttribute( "style:protect", protect );
+ }
+ //vertical pos and horizon pos:
+ pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
+ pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
+ pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
+ pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
+
+ pStrm->StartElement( "style:properties" );
+ if( m_pColumns )
+ m_pColumns->ToXml(pStrm);
+ if( m_pBGImage )
+ m_pBGImage->ToXml(pStrm);
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfglobal.cxx b/lotuswordpro/source/filter/xfilter/xfglobal.cxx
new file mode 100644
index 000000000..29bfe08d0
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfglobal.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Global functions or include files that are needed.
+ * It's all for the full filter.
+ ************************************************************************/
+#include <xfilter/xfglobal.hxx>
+
+int XFGlobal::s_nFrameID = 1;
+int XFGlobal::s_nSectionID = 1;
+int XFGlobal::s_nNoteID = 1;
+int XFGlobal::s_nStrokeDashID = 1;
+int XFGlobal::s_nAreaID = 1;
+int XFGlobal::s_nImageID = 1;
+
+OUString XFGlobal::GenSectionName()
+{
+ //give it an initial name:
+ OUString sResult = "sect" + OUString::number(s_nSectionID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenFrameName()
+{
+ //give it an initial name:
+ OUString sResult = "frame" + OUString::number(s_nFrameID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenTableName()
+{
+ OUString sResult = "table" + OUString::number(s_nFrameID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenNoteName()
+{
+ OUString sResult = "ftn" + OUString::number(s_nNoteID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenStrokeDashName()
+{
+ OUString sResult = "stroke dash " + OUString::number(s_nStrokeDashID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenAreaName()
+{
+ OUString sResult = "draw area" + OUString::number(s_nAreaID++);
+ return sResult;
+}
+
+OUString XFGlobal::GenImageName()
+{
+ OUString sResult = "Graphic" + OUString::number(s_nImageID++);
+ return sResult;
+}
+
+void XFGlobal::Reset()
+{
+ s_nSectionID = 1;
+ s_nFrameID = 1;
+ s_nNoteID = 1;
+ s_nStrokeDashID = 1;
+ s_nAreaID = 1;
+}
+
+void XFGlobalReset()
+{
+ // XFFontFactory::Reset();
+ // XFStyleManager::Reset();
+ XFGlobal::Reset();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx
new file mode 100644
index 000000000..eb061b6d5
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Header style,exist in page-master object.
+ ************************************************************************/
+#include <xfilter/xfheaderstyle.hxx>
+#include <xfilter/xfbgimage.hxx>
+
+XFHeaderStyle::XFHeaderStyle(bool isFooter)
+{
+ m_bIsFooter = isFooter;
+ m_bDynamicSpace = true;
+ m_fHeight = -1;
+ m_fMinHeight = -1;
+}
+
+XFHeaderStyle::~XFHeaderStyle()
+{
+}
+
+void XFHeaderStyle::SetMargins(double left, double right, double bottom)
+{
+ if( left != -1 )
+ m_aMargin.SetLeft(left);
+ if( right != -1 )
+ m_aMargin.SetRight(right);
+ if( bottom != -1 )
+ m_aMargin.SetBottom(bottom);
+}
+void XFHeaderStyle::SetDynamicSpace(bool dynamic)
+{
+ m_bDynamicSpace = dynamic;
+}
+
+void XFHeaderStyle::SetHeight(double height)
+{
+ m_fHeight = height;
+}
+
+void XFHeaderStyle::SetMinHeight(double minHeight)
+{
+ m_fMinHeight = minHeight;
+}
+
+void XFHeaderStyle::SetShadow(XFShadow *pShadow)
+{
+ if( pShadow == m_pShadow.get() )
+ return;
+ m_pShadow.reset( pShadow );
+}
+
+void XFHeaderStyle::SetBorders(std::unique_ptr<XFBorders> pBorders)
+{
+ m_pBorders = std::move(pBorders);
+}
+
+void XFHeaderStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_pBGImage = std::move(rImage);
+}
+
+void XFHeaderStyle::SetBackColor(XFColor color)
+{
+ m_aBackColor = color;
+}
+
+void XFHeaderStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ if( m_bIsFooter )
+ pStrm->StartElement( "style:footer-style" );
+ else
+ pStrm->StartElement( "style:header-style" );
+
+ //height
+ if( m_fMinHeight>0 )
+ pAttrList->AddAttribute( "fo:min-height", OUString::number(m_fMinHeight) + "cm" );
+ else if( m_fHeight>0 )
+ pAttrList->AddAttribute( "svg:height", OUString::number(m_fHeight) + "cm" );
+
+ m_aMargin.ToXml(pStrm);
+ if(m_pShadow)
+ m_pShadow->ToXml(pStrm);
+ m_aPadding.ToXml(pStrm);
+ if( m_pBorders )
+ m_pBorders->ToXml(pStrm);
+
+ if( m_aBackColor.IsValid() )
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+
+ if( m_bDynamicSpace )
+ pAttrList->AddAttribute( "style:dynamic-spacing", "true" );
+ else
+ pAttrList->AddAttribute( "style:dynamic-spacing", "false" );
+
+ pStrm->StartElement( "style:properties" );
+
+ // background image
+ if( m_pBGImage )
+ m_pBGImage->ToXml(pStrm);
+
+ pStrm->EndElement( "style:properties" );
+
+ if( m_bIsFooter )
+ pStrm->EndElement( "style:footer-style" );
+ else
+ pStrm->EndElement( "style:header-style" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfimage.cxx b/lotuswordpro/source/filter/xfilter/xfimage.cxx
new file mode 100644
index 000000000..33f483c7c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfimage.cxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Image object.
+ ************************************************************************/
+#include <xfilter/xfimage.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include "xfbase64.hxx"
+
+XFImage::XFImage() : m_bUseLink(false)
+{
+ m_eType = enumXFFrameImage;
+ m_strName = XFGlobal::GenImageName();
+}
+
+void XFImage::SetFileURL(const OUString& url)
+{
+ m_strImageFile = url;
+ m_bUseLink = true;
+}
+
+void XFImage::SetImageData(sal_uInt8 const *buf, int len)
+{
+ m_strData = XFBase64::Encode(buf, len);
+ m_bUseLink = false;
+}
+
+/*
+ <text:p text:style-name="Standard">
+ <draw:image draw:style-name="fr1" draw:name="Graphic1"
+ text:anchor-type="paragraph" svg:width="4.981cm" svg:height="4.77cm"
+ draw:z-index="0" xlink:href="file:///d:/bee.wmf" xlink:type="simple"
+ xlink:show="embed" xlink:actuate="onLoad"/>
+ </text:p>
+ */
+void XFImage::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "draw:style-name", GetStyleName() );
+
+ assert(!m_strName.isEmpty() && "name should not be null.");
+ if( !m_strName.isEmpty() )
+ pAttrList->AddAttribute( "draw:name", m_strName );
+ //anchor type:
+ switch( m_eAnchor )
+ {
+ case enumXFAnchorPara:
+ pAttrList->AddAttribute( "text:anchor-type", "paragraph" );
+ break;
+ case enumXFAnchorPage:
+ pAttrList->AddAttribute( "text:anchor-type", "page" );
+ pAttrList->AddAttribute( "text:anchor-page-number", OUString::number(m_nAnchorPage) );
+ break;
+ case enumXFAnchorChar:
+ pAttrList->AddAttribute( "text:anchor-type", "char" );
+ break;
+ case enumXFAnchorAsChar:
+ pAttrList->AddAttribute( "text:anchor-type", "as-char" );
+ break;
+ case enumXFAnchorFrame:
+ pAttrList->AddAttribute( "text:anchor-type", "frame" );
+ break;
+ default:
+ break;
+ }
+ pAttrList->AddAttribute( "svg:x", OUString::number(m_aRect.GetX()) + "cm" );
+ pAttrList->AddAttribute( "svg:y", OUString::number(m_aRect.GetY()) + "cm" );
+ pAttrList->AddAttribute( "svg:width", OUString::number(m_aRect.GetWidth()) + "cm" );
+ pAttrList->AddAttribute( "svg:height", OUString::number(m_aRect.GetHeight()) + "cm" );
+ pAttrList->AddAttribute( "draw:z-index", OUString::number(m_nZIndex) );
+
+ if( m_bUseLink )
+ {
+ pAttrList->AddAttribute( "xlink:href", m_strImageFile );
+ pAttrList->AddAttribute( "xlink:type", "simple" );
+ pAttrList->AddAttribute( "xlink:show", "embed" );
+ pAttrList->AddAttribute( "xlink:actuate", "onLoad" );
+ }
+
+ pStrm->StartElement( "draw:image" );
+ if( !m_bUseLink )
+ {
+ pAttrList->Clear();
+ pStrm->StartElement( "office:binary-data" );
+ pStrm->Characters(m_strData);
+ pStrm->EndElement( "office:binary-data" );
+ }
+ pStrm->EndElement( "draw:image" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfimagestyle.cxx b/lotuswordpro/source/filter/xfilter/xfimagestyle.cxx
new file mode 100644
index 000000000..0694fdc26
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfimagestyle.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Image style object.
+ ************************************************************************/
+#include <xfilter/xfimagestyle.hxx>
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/xfshadow.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFImageStyle::XFImageStyle()
+ : m_nBrightness(0)
+ , m_nContrast(0)
+ , m_fClipLeft(0)
+ , m_fClipRight(0)
+ , m_fClipTop(0)
+ , m_fClipBottom(0)
+{}
+
+void XFImageStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pAttrList->AddAttribute( "style:family", "graphics" );
+ //parent style name ignore now.
+ pStrm->StartElement( "style:style" );
+
+ m_aMargins.ToXml(pStrm);
+
+ pAttrList->Clear();
+
+ if( m_eWrap == enumXFWrapBackground )
+ {
+ pAttrList->AddAttribute( "style:run-through", "background" );
+ }
+ else
+ {
+ pAttrList->AddAttribute( "style:run-through", "foreground" );
+
+ if( m_eWrap == enumXFWrapNone )
+ pAttrList->AddAttribute( "style:wrap", "none" );
+ else if( m_eWrap == enumXFWrapLeft )
+ pAttrList->AddAttribute( "style:wrap", "left" );
+ else if( m_eWrap == enumXFWrapRight )
+ pAttrList->AddAttribute( "style:wrap", "right" );
+ else if( m_eWrap == enumXFWrapParallel )
+ pAttrList->AddAttribute( "style:wrap", "parallel" );
+ else if( m_eWrap == enumXFWrapRunThrough )
+ pAttrList->AddAttribute( "style:wrap", "run-through" );
+ else if( m_eWrap == enumXFWrapBest )
+ pAttrList->AddAttribute( "style:wrap", "dynamic" );
+ }
+ //background
+ if( m_aBackColor.IsValid() )
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+ //pad
+ m_aPad.ToXml(pStrm);
+ //margin:
+ m_aMargins.ToXml(pStrm);
+
+ if( m_nBrightness )
+ pAttrList->AddAttribute( "draw:luminance", OUString::number(m_nBrightness) + "%" );
+ if( m_nContrast )
+ pAttrList->AddAttribute( "draw:contrast", OUString::number(m_nContrast) + "%" );
+
+ pAttrList->AddAttribute("draw:color-mode", GetColorMode(enumXFColorStandard));
+ //border
+ if( m_pBorders )
+ m_pBorders->ToXml(pStrm);
+ //shadow
+ if( m_pShadow )
+ m_pShadow->ToXml(pStrm);
+
+ pAttrList->AddAttribute( "style:print-content", "true" );
+ //protect:
+ if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
+ {
+ OUString protect;
+ if( m_bProtectContent )
+ protect += "content";
+ if( m_bProtectSize )
+ {
+ if( !protect.isEmpty() )
+ protect += " ";
+ protect += "size";
+ }
+ if( m_bProtectPos )
+ {
+ if( !protect.isEmpty() )
+ protect += " ";
+ protect += "position";
+ }
+ pAttrList->AddAttribute( "style:protect", protect );
+ }
+ //vertical pos and horizon pos:
+ pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
+ pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
+ pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
+ pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
+
+ //clip:
+ if( FABS(m_fClipLeft)>FLOAT_MIN || FABS(m_fClipRight)>FLOAT_MIN || FABS(m_fClipTop)>FLOAT_MIN || FABS(m_fClipBottom)>FLOAT_MIN )
+ {
+ OUString clip = "rect(" + OUString::number(m_fClipTop) + "cm " +
+ OUString::number(m_fClipRight) + "cm " +
+ OUString::number(m_fClipBottom) + "cm " +
+ OUString::number(m_fClipLeft) + "cm)";
+ pAttrList->AddAttribute("fo:clip",clip);
+ }
+
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfindex.cxx b/lotuswordpro/source/filter/xfilter/xfindex.cxx
new file mode 100644
index 000000000..902e1e970
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfindex.cxx
@@ -0,0 +1,330 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Represents index source, index body and index entry.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfindex.hxx>
+
+XFIndex::XFIndex()
+ : m_eType(enumXFIndexTOC)
+ , m_bProtect(true)
+ , m_bSeparator(false)
+{}
+
+XFIndex::~XFIndex()
+{
+}
+
+void XFIndex::AddTemplate(const OUString& level, const OUString& style, XFIndexTemplate* templ)
+{
+ templ->SetLevel( level );
+ if(m_eType != enumXFIndexTOC) // TOC's styles are applied to template entries separately
+ {
+ templ->SetStyleName( style );
+ }
+ m_aTemplates.push_back( templ );
+}
+
+void XFIndex::SetProtected(bool protect)
+{
+ m_bProtect = protect;
+}
+
+void XFIndex::SetSeparator(bool sep)
+{
+ m_bSeparator = sep;
+}
+
+void XFIndex::AddTocSource(sal_uInt16 nLevel, const OUString& sStyleName)
+{
+ if (nLevel > MAX_TOC_LEVEL)
+ {
+ return;
+ }
+
+ m_aTOCSource[nLevel].push_back(sStyleName);
+}
+
+void XFIndex::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ OUString strIndexName;
+ OUString strTplName;
+ OUString strSourceName;
+
+ if(m_eType == enumXFIndexTOC )
+ {
+ strIndexName = "text:table-of-content";
+ strSourceName = "text:table-of-content-source";
+ strTplName = "text:table-of-content-entry-template";
+ }
+ else if( m_eType == enumXFIndexAlphabetical )
+ {
+ strIndexName = "text:alphabetical-index";
+ strSourceName = "text:alphabetical-index-source";
+ strTplName = "text:alphabetical-index-entry-template";
+ }
+ else if( m_eType == enumXFIndexUserIndex )
+ {
+ strIndexName = "text:user-index";
+ strSourceName = "text:text:user-index-source";
+ strTplName = "text:user-index-entry-template";
+ }
+ else if( m_eType == enumXFIndexObject )
+ {
+ strIndexName = "text:object-index";
+ strSourceName = "text:object-index-source";
+ strTplName = "text:object-index-entry-template";
+ }
+ else if( m_eType == enumXFIndexIllustration )
+ {
+ strIndexName = "text:illustration-index";
+ strSourceName = "text:illustration-index-source";
+ strTplName = "text:illustration-index-entry-template";
+ }
+ else if( m_eType == enumXFIndexTableIndex )
+ {
+ strIndexName = "text:table-index";
+ strSourceName = "text:table-index-source";
+ strTplName = "text:table-index-entry-template";
+ }
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "text:style-name", GetStyleName() );
+ if( m_bProtect )
+ pAttrList->AddAttribute( "text:protected", "true" );
+ else
+ pAttrList->AddAttribute( "text:protected", "false" );
+
+ pAttrList->AddAttribute( "text:name", m_strTitle );
+ pStrm->StartElement( strIndexName );
+
+ //text:table-of-content-source:
+ pAttrList->Clear();
+
+ if(m_eType == enumXFIndexTOC )
+ {
+ pAttrList->AddAttribute( "text:outline-level", OUString::number(10));
+ pAttrList->AddAttribute( "text:use-index-source-styles", "true");
+ pAttrList->AddAttribute( "text:use-index-marks", "true");
+ pAttrList->AddAttribute( "text:use-outline-level", "false");
+ }
+ if (m_bSeparator)
+ pAttrList->AddAttribute( "text:alphabetical-separators", "true" );
+
+ pStrm->StartElement( strSourceName );
+ //title template:
+ pAttrList->Clear();
+
+ pStrm->StartElement( "text:index-title-template" );
+ pStrm->Characters( m_strTitle );
+ pStrm->EndElement( "text:index-title-template" );
+
+ //entry templates:
+ for (auto const& elem : m_aTemplates)
+ {
+ elem->SetTagName( strTplName);
+ elem->ToXml(pStrm);
+ }
+
+ // by
+ if(m_eType == enumXFIndexTOC )
+ {
+ for(sal_uInt16 i=1; i <= MAX_TOC_LEVEL; i++)
+ {
+ if (m_aTOCSource[i].empty())
+ {
+ // unnecessary to output this level
+ continue;
+ }
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "text:outline-level", OUString::number(i));
+ pStrm->StartElement( "text:index-source-styles" );
+
+ for (auto const& elemTOCSource : m_aTOCSource[i])
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "text:style-name", elemTOCSource);
+ pStrm->StartElement( "text:index-source-style" );
+ pStrm->EndElement( "text:index-source-style" );
+ }
+ pStrm->EndElement( "text:index-source-styles" );
+ }
+ }
+
+ pStrm->EndElement( strSourceName );
+
+ //index-body:
+ pAttrList->Clear();
+ pStrm->StartElement( "text:index-body" );
+ //index-title:
+ if(!m_strTitle.isEmpty())
+ {
+ pAttrList->AddAttribute( "text:name", m_strTitle + "_Head" );
+ pStrm->StartElement( "text:index-title" );
+ pStrm->EndElement( "text:index-title" );
+ }
+
+ XFContentContainer::ToXml(pStrm);
+ pStrm->EndElement( "text:index-body" );
+
+ pStrm->EndElement( strIndexName );
+}
+
+void XFIndexTemplate::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "text:outline-level", m_nLevel );
+ pAttrList->AddAttribute( "text:style-name", m_strStyle );
+ if( m_strTagName.isEmpty() )
+ m_strTagName = "text:table-of-content-entry-template";
+ pStrm->StartElement( m_strTagName );
+
+ for( size_t i=0; i<m_aEntries.size(); i++ )
+ {
+ pAttrList->Clear();
+
+ switch( m_aEntries[i].first )
+ {
+ case enumXFIndexTemplateChapter:
+ if(!m_aEntries[i].second.isEmpty())
+ pAttrList->AddAttribute( "text:style-name", m_aEntries[i].second );
+
+ pStrm->StartElement( "text:index-entry-chapter-number" );
+ pStrm->EndElement( "text:index-entry-chapter-number" );
+ break;
+ case enumXFIndexTemplateText:
+ if(!m_aEntries[i].second.isEmpty())
+ pAttrList->AddAttribute( "text:style-name", m_aEntries[i].second );
+
+ pStrm->StartElement( "text:index-entry-text" );
+ pStrm->EndElement( "text:index-entry-text" );
+ break;
+ case enumXFIndexTemplateTab:
+ if( m_eTabType != enumXFTabRight )
+ pAttrList->AddAttribute( "style:position", OUString::number(m_fTabLength) + "cm" );
+
+ if(!m_aEntries[i].second.isEmpty())
+ pAttrList->AddAttribute( "text:style-name", m_aEntries[i].second );
+
+ switch(m_eTabType)
+ {
+ case enumXFTabLeft:
+ pAttrList->AddAttribute( "style:type", "left" );
+ break;
+ case enumXFTabCenter:
+ pAttrList->AddAttribute( "style:type", "center" );
+ break;
+ case enumXFTabRight:
+ pAttrList->AddAttribute( "style:type", "right" );
+ break;
+ case enumXFTabChar:
+ pAttrList->AddAttribute( "style:type", "char" );
+ break;
+ default:
+ break;
+ }
+ //delimiter:
+ if( m_eTabType == enumXFTabChar )
+ pAttrList->AddAttribute( "style:char", m_strTabDelimiter );
+ //leader char:
+ if( !m_strTabLeader.isEmpty() )
+ pAttrList->AddAttribute( "style:leader-char", m_strTabLeader );
+
+ pStrm->StartElement( "text:index-entry-tab-stop" );
+ pStrm->EndElement( "text:index-entry-tab-stop" );
+ break;
+ case enumXFIndexTemplatePage:
+ if(!m_aEntries[i].second.isEmpty())
+ pAttrList->AddAttribute( "text:style-name", m_aEntries[i].second );
+
+ pStrm->StartElement( "text:index-entry-page-number" );
+ pStrm->EndElement( "text:index-entry-page-number" );
+ break;
+ case enumXFIndexTemplateLinkStart:
+ pStrm->StartElement( "text:index-entry-link-start" );
+ pStrm->EndElement( "text:index-entry-link-start" );
+ break;
+ case enumXFIndexTemplateLinkEnd:
+ pStrm->StartElement( "text:index-entry-link-end" );
+ pStrm->EndElement( "text:index-entry-link-end" );
+ break;
+ case enumXFIndexTemplateSpan:
+ pAttrList->Clear();
+ pAttrList->AddAttribute("text:style-name", GetStyleName());
+ pStrm->StartElement( "text:index-entry-span" );
+ pStrm->Characters(m_aTextEntries[i]);
+ pStrm->EndElement( "text:index-entry-span" );
+ break;
+ case enumXFIndexTemplateBibliography:
+ pStrm->StartElement( "text:index-entry-bibliography" );
+ pStrm->EndElement( "text:index-entry-bibliography" );
+ break;
+ default:
+ break;
+ }
+ }
+
+ pStrm->EndElement( m_strTagName );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xflist.cxx b/lotuswordpro/source/filter/xfilter/xflist.cxx
new file mode 100644
index 000000000..ae61aef6c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xflist.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * List object.
+ ************************************************************************/
+#include <xfilter/xflist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFList::XFList()
+{
+ m_bOrdered = true;
+ m_bContinueNumber = false;
+}
+
+XFList::~XFList() {}
+
+void XFList::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+ assert(nullptr != pAttrList);
+
+ pAttrList->Clear();
+ if (!GetStyleName().isEmpty())
+ pAttrList->AddAttribute("text:style-name", GetStyleName());
+ if (m_bContinueNumber)
+ pAttrList->AddAttribute("text:continue-numbering", "true");
+
+ if (m_bOrdered)
+ pStrm->StartElement("text:ordered-list");
+ else
+ pStrm->StartElement("text:unordered-list");
+
+ XFContentContainer::ToXml(pStrm);
+
+ if (m_bOrdered)
+ pStrm->EndElement("text:ordered-list");
+ else
+ pStrm->EndElement("text:unordered-list");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfliststyle.cxx b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
new file mode 100644
index 000000000..4f4f32ea7
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfliststyle.cxx
@@ -0,0 +1,290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Styles for ordered list and unordered list.
+ ************************************************************************/
+#include <xfilter/xfliststyle.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFListLevel::XFListLevel()
+ : m_nLevel(0)
+ , m_nDisplayLevel(0)
+ , m_fIndent(0)
+ , m_fMinLabelWidth(0.499)
+ , m_fMinLabelDistance(0)
+ , m_eAlign(enumXFAlignStart)
+ , m_eListType(enumXFListLevelNumber)
+{}
+
+void XFListLevel::ToXml(IXFStream * /*pStrm*/)
+{
+}
+
+void XFListlevelNumber::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "text:level", OUString::number(static_cast<sal_Int32>(m_nLevel)) );
+ //text:style-name,ignore now.
+ m_aNumFmt.ToXml(pStrm);
+ if( m_nDisplayLevel )
+ pAttrList->AddAttribute( "text:display-levels", OUString::number(static_cast<sal_Int32>(m_nDisplayLevel)) );
+
+ pStrm->StartElement( "text:list-level-style-number" );
+
+ //<style:properties>...</style:properties>
+ pAttrList->Clear();
+ if( m_fIndent > FLOAT_MIN )
+ {
+ pAttrList->AddAttribute( "text:space-before", OUString::number(m_fIndent) + "cm" );
+ }
+ if( m_fMinLabelWidth > FLOAT_MIN )
+ {
+ pAttrList->AddAttribute( "text:min-label-width", OUString::number(m_fMinLabelWidth) + "cm" );
+ }
+ if( m_fMinLabelDistance > FLOAT_MIN )
+ {
+ pAttrList->AddAttribute( "text:min-label-distance", OUString::number(m_fMinLabelDistance) + "cm" );
+ }
+ pAttrList->AddAttribute( "fo:text-align", GetAlignName(m_eAlign) );
+
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "text:list-level-style-number" );
+}
+
+void XFListLevelBullet::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "text:level", OUString::number(static_cast<sal_Int32>(m_nLevel)) );
+ //text:style-name,ignore now.
+ m_aNumFmt.ToXml(pStrm);
+ //bullet-char
+ pAttrList->AddAttribute( "text:bullet-char", m_chBullet );
+
+ pStrm->StartElement( "text:list-level-style-bullet" );
+
+ //<style:properties>...</style:properties>
+ pAttrList->Clear();
+ if( m_fIndent != 0 )
+ {
+ pAttrList->AddAttribute( "text:space-before", OUString::number(m_fIndent) + "cm" );
+ }
+ if( m_fMinLabelWidth != 0 )
+ {
+ pAttrList->AddAttribute( "text:min-label-width", OUString::number(m_fMinLabelWidth) + "cm" );
+ }
+ if( m_fMinLabelDistance != 0 )
+ {
+ pAttrList->AddAttribute( "text:min-label-distance", OUString::number(m_fMinLabelDistance) + "cm" );
+ }
+
+ pAttrList->AddAttribute( "fo:text-align", GetAlignName(m_eAlign) );
+
+ if( !m_strFontName.isEmpty() )
+ {
+ pAttrList->AddAttribute( "style:font-name", m_strFontName );
+ }
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "text:list-level-style-bullet" );
+}
+
+XFListStyle::XFListStyle()
+{
+ XFNumFmt nf;
+ nf.SetSuffix( "." );
+ nf.SetFormat( "1" );
+
+ for( int i=0; i<10; i++ )
+ {
+ m_pListLevels[i].reset(new XFListlevelNumber());
+ m_pListLevels[i]->SetListlevelType(enumXFListLevelNumber);
+ m_pListLevels[i]->SetMinLabelWidth(0.499);
+ m_pListLevels[i]->SetIndent(0.501*(i+1));
+ m_pListLevels[i]->SetLevel(i+1);
+ static_cast<XFListlevelNumber*>(m_pListLevels[i].get())->SetNumFmt(nf);
+ }
+}
+
+XFListStyle::XFListStyle(const XFListStyle& other):XFStyle(other)
+{
+ for( int i=0; i<10; i++ )
+ {
+ const enumXFListLevel type = other.m_pListLevels[i]->m_eListType;
+ if( type == enumXFListLevelNumber )
+ {
+ XFListlevelNumber *pNum = static_cast<XFListlevelNumber*>(other.m_pListLevels[i].get());
+ m_pListLevels[i].reset(new XFListlevelNumber(*pNum));
+ }
+ else if( type == enumXFListLevelBullet )
+ {
+ XFListLevelBullet *pBullet = static_cast<XFListLevelBullet*>(other.m_pListLevels[i].get());
+ m_pListLevels[i].reset(new XFListLevelBullet(*pBullet));
+ }
+ else
+ m_pListLevels[i].reset();
+ }
+}
+
+XFListStyle::~XFListStyle()
+{
+}
+
+void XFListStyle::SetDisplayLevel(sal_Int32 level, sal_Int16 nDisplayLevel)
+{
+ assert(level>=1&&level<=10);
+
+ XFListLevel *pLevel = m_pListLevels[level-1].get();
+ if( !pLevel )
+ {
+ m_pListLevels[level-1].reset(new XFListlevelNumber());
+ pLevel = m_pListLevels[level-1].get();
+ pLevel->SetListlevelType(enumXFListLevelNumber);
+ pLevel->SetLevel(level+1);
+ pLevel->SetMinLabelWidth(0.499);
+ pLevel->SetIndent(0.501*(level+1));
+ }
+ pLevel->SetDisplayLevel(nDisplayLevel);
+}
+
+void XFListStyle::SetListPosition(sal_Int32 level,
+ double indent,
+ double minLabelWidth,
+ double minLabelDistance,
+ enumXFAlignType align
+ )
+{
+ assert(level>=1&&level<=10);
+
+ XFListLevel *pLevel = m_pListLevels[level-1].get();
+ if( !pLevel )
+ {
+ m_pListLevels[level-1].reset( new XFListLevelBullet() );
+ pLevel = m_pListLevels[level-1].get();
+ pLevel->SetListlevelType(enumXFListLevelNumber);
+ pLevel->SetLevel(level+1);
+ }
+ pLevel->SetIndent(indent);
+ pLevel->SetMinLabelWidth(minLabelWidth);
+ pLevel->SetMinLabelDistance(minLabelDistance);
+ pLevel->SetAlignType(align);
+}
+
+void XFListStyle::SetListBullet(sal_Int32 level,
+ OUString const & bullet,
+ const OUString& fontname,
+ const OUString& prefix,
+ const OUString& suffix
+ )
+{
+ assert(level>=1&&level<=10);
+
+ std::unique_ptr<XFListLevelBullet> pLevel(new XFListLevelBullet());
+ pLevel->SetPrefix(prefix);
+ pLevel->SetSuffix(suffix);
+ pLevel->SetBulletChar(bullet);
+ pLevel->SetFontName(fontname);
+
+ pLevel->SetListlevelType(enumXFListLevelBullet);
+ pLevel->SetMinLabelWidth(0.499);
+ pLevel->SetIndent(0.501*level);
+ pLevel->SetLevel(level);
+ m_pListLevels[level-1] = std::move(pLevel);
+}
+
+void XFListStyle::SetListNumber(sal_Int32 level, XFNumFmt const & fmt, sal_Int16 start )
+{
+ assert(level>=1&&level<=10);
+
+ std::unique_ptr<XFListlevelNumber> pLevel(new XFListlevelNumber());
+ pLevel->SetNumFmt(fmt);
+ pLevel->SetStartValue(start);
+
+ pLevel->SetListlevelType(enumXFListLevelNumber);
+ pLevel->SetMinLabelWidth(0.499);
+ pLevel->SetIndent(0.501*level);
+ pLevel->SetLevel(level);
+ m_pListLevels[level-1] = std::move(pLevel);
+}
+
+void XFListStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pStrm->StartElement( "text:list-style" );
+
+ for(auto const & pLevel : m_pListLevels)
+ {
+ if( pLevel )
+ pLevel->ToXml(pStrm);
+ }
+
+ pStrm->EndElement( "text:list-style" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfmargins.cxx b/lotuswordpro/source/filter/xfilter/xfmargins.cxx
new file mode 100644
index 000000000..b6aab56d0
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfmargins.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Margins object, include left margin,right margin,top margin and bottom margin.
+ ************************************************************************/
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfmargins.hxx>
+
+XFMargins::XFMargins()
+{
+ Reset();
+}
+
+void XFMargins::Reset()
+{
+ m_fLeft = 0;
+ m_fRight = 0;
+ m_fTop = 0;
+ m_fBottom = 0;
+ m_nFlag = 0;
+}
+
+void XFMargins::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ //margin left:
+ if( m_nFlag&XFMARGINS_FLAG_LEFT )
+ {
+ pAttrList->AddAttribute( "fo:margin-left", OUString::number(m_fLeft) + "cm" );
+ }
+ //margin right:
+ if( m_nFlag&XFMARGINS_FLAG_RIGHT )
+ {
+ pAttrList->AddAttribute("fo:margin-right", OUString::number(m_fRight) + "cm" );
+ }
+ //margin top:
+ if( m_nFlag&XFMARGINS_FLAG_TOP )
+ {
+ pAttrList->AddAttribute("fo:margin-top", OUString::number(m_fTop) + "cm" );
+ }
+ //margin bottom:
+ if( m_nFlag&XFMARGINS_FLAG_BOTTOM )
+ {
+ pAttrList->AddAttribute("fo:margin-bottom", OUString::number(m_fBottom) + "cm" );
+ }
+}
+
+bool operator==(XFMargins const & indent1, XFMargins const & indent2)
+{
+ return (
+ (indent1.m_nFlag == indent2.m_nFlag) &&
+ (indent1.m_fLeft == indent2.m_fLeft) &&
+ (indent1.m_fRight == indent2.m_fRight) &&
+ (indent1.m_fTop == indent2.m_fTop) &&
+ (indent1.m_fBottom == indent2.m_fBottom)
+ );
+}
+bool operator!=(XFMargins const & indent1, XFMargins const & indent2)
+{
+ return !(indent1==indent2);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfmasterpage.cxx b/lotuswordpro/source/filter/xfilter/xfmasterpage.cxx
new file mode 100644
index 000000000..29eb8a9e7
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfmasterpage.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Master page object which was used to apply a layout to the pages.
+ ************************************************************************/
+#include <xfilter/xfmasterpage.hxx>
+#include <xfilter/xffooter.hxx>
+#include <xfilter/xfheader.hxx>
+
+void XFMasterPage::SetHeader(rtl::Reference<XFHeader> const& rHeader) { m_xHeader = rHeader; }
+
+void XFMasterPage::SetFooter(rtl::Reference<XFFooter> const& rFooter) { m_xFooter = rFooter; }
+
+enumXFStyle XFMasterPage::GetStyleFamily() { return enumXFStyleMasterPage; }
+
+void XFMasterPage::SetPageMaster(const OUString& pm) { m_strPageMaster = pm; }
+
+void XFMasterPage::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute("style:name", m_strStyleName);
+ pAttrList->AddAttribute("style:page-master-name", m_strPageMaster);
+ pStrm->StartElement("style:master-page");
+ if (m_xHeader)
+ m_xHeader->ToXml(pStrm);
+ if (m_xFooter)
+ m_xFooter->ToXml(pStrm);
+ pStrm->EndElement("style:master-page");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfnumberstyle.cxx b/lotuswordpro/source/filter/xfilter/xfnumberstyle.cxx
new file mode 100644
index 000000000..169f5e7e5
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfnumberstyle.cxx
@@ -0,0 +1,356 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Number style for table cell.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfnumberstyle.hxx>
+
+XFNumberStyle::XFNumberStyle()
+ : m_eType(enumXFNumberNumber)
+ , m_nDecimalDigits(0)
+ , m_bGroup(false)
+ , m_aColor(0,0,0)
+ , m_bRedIfNegative(false)
+ , m_aNegativeColor(255,0,0)
+{}
+
+enumXFStyle XFNumberStyle::GetStyleFamily()
+{
+ return enumXFStyleNumber;
+}
+
+bool XFNumberStyle::Equal(IXFStyle *pStyle)
+{
+ if( !pStyle || pStyle->GetStyleFamily() != enumXFStyleNumber )
+ return false;
+ XFNumberStyle *pOther = dynamic_cast<XFNumberStyle*>(pStyle);
+ if( !pOther )
+ return false;
+
+ if( m_eType != pOther->m_eType )
+ return false;
+ if( m_nDecimalDigits != pOther->m_nDecimalDigits )
+ return false;
+ if( m_bRedIfNegative != pOther->m_bRedIfNegative )
+ return false;
+ if( m_bGroup != pOther->m_bGroup )
+ return false;
+ if( m_aColor != pOther->m_aColor )
+ return false;
+ if( m_strPrefix != pOther->m_strPrefix )
+ return false;
+ if( m_strSuffix != pOther->m_strSuffix )
+ return false;
+
+ if( m_bRedIfNegative )
+ {
+ if( m_aNegativeColor != pOther->m_aNegativeColor )
+ return false;
+ if( m_strNegativePrefix != pOther->m_strNegativePrefix )
+ return false;
+ if( m_strNegativeSuffix != pOther->m_strNegativeSuffix )
+ return false;
+ }
+
+ if( m_eType == enuMXFNumberCurrency )
+ {
+ if( m_strCurrencySymbol != pOther->m_strCurrencySymbol )
+ return false;
+ }
+
+ return true;
+}
+
+void XFNumberStyle::ToXml(IXFStream *pStrm)
+{
+ // for Text content number format
+ if (m_eType == enumXFText)
+ {
+ ToXml_StartElement(pStrm);
+ ToXml_EndElement(pStrm);
+ return;
+ }
+
+ if( !m_bRedIfNegative )
+ {
+ ToXml_Normal(pStrm);
+ }
+ else
+ {
+ ToXml_Negative(pStrm);
+ }
+}
+
+void XFNumberStyle::ToXml_StartElement(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+
+ pAttrList->AddAttribute( "style:family", "data-style" );
+
+ if( m_eType == enumXFNumberNumber )
+ {
+ pStrm->StartElement( "number:number-style" );
+ }
+ else if( m_eType == enumXFNumberPercent )
+ {
+ pStrm->StartElement( "number:percentage-style" );
+ }
+ else if( m_eType == enuMXFNumberCurrency )
+ {
+ pStrm->StartElement( "number:currency-style" );
+ }
+ else if( m_eType == enumXFNumberScientific )
+ {
+ pStrm->StartElement( "number:number-style" );
+ }
+ // for Text content number format
+ else if (m_eType == enumXFText)
+ {
+ pStrm->StartElement( "number:text-content");
+ }
+
+}
+
+void XFNumberStyle::ToXml_EndElement(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ pAttrList->AddAttribute( "style:family", "data-style" );
+
+ if( m_eType == enumXFNumberNumber )
+ {
+ pStrm->EndElement( "number:number-style" );
+ }
+ else if( m_eType == enumXFNumberPercent )
+ {
+ pStrm->EndElement( "number:percentage-style" );
+ }
+ else if( m_eType == enuMXFNumberCurrency )
+ {
+ pStrm->EndElement( "number:currency-style" );
+ }
+ else if( m_eType == enumXFNumberScientific )
+ {
+ pStrm->EndElement( "number:number-style" );
+ }
+ // for Text content number format
+ else if (m_eType == enumXFText)
+ {
+ pStrm->EndElement( "number:text-content");
+ }
+ // END for Text content number format
+
+}
+void XFNumberStyle::ToXml_Normal(IXFStream *pStrm)
+{
+ ToXml_StartElement(pStrm);
+
+ ToXml_Content(pStrm,false);
+
+ ToXml_EndElement(pStrm);
+}
+
+void XFNumberStyle::ToXml_Negative(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ OUString strStyleName = GetStyleName();
+ OUString strGEStyle = strStyleName + "PO";
+
+ SetStyleName(strGEStyle);
+ ToXml_Normal(pStrm);
+ SetStyleName(strStyleName);
+
+ ToXml_StartElement(pStrm);
+
+ ToXml_Content(pStrm,true);
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:condition", "value()>=0" );
+ pAttrList->AddAttribute( "style:apply-style-name", strGEStyle );
+ pStrm->StartElement( "style:map" );
+ pStrm->EndElement( "style:map" );
+
+ ToXml_EndElement(pStrm);
+}
+
+void XFNumberStyle::ToXml_Content(IXFStream *pStrm, bool nagetive)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ //color:
+ if( !nagetive )
+ pAttrList->AddAttribute( "fo:color", m_aColor.ToString() );
+ else
+ pAttrList->AddAttribute( "fo:color", m_aNegativeColor.ToString() );
+
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ if( !nagetive )
+ {
+ if( !m_strPrefix.isEmpty() )
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters(m_strPrefix);
+ pStrm->EndElement( "number:text" );
+ }
+ }
+ else
+ {
+ if( m_strNegativePrefix.isEmpty() )
+ m_strNegativePrefix = m_strPrefix;
+ if( !m_strNegativePrefix.isEmpty() )
+ {
+ pStrm->StartElement( "number:text" );
+ // pStrm->Characters(m_strNegativePrefix);
+ pStrm->Characters(m_strNegativePrefix + "-");
+ pStrm->EndElement( "number:text" );
+ }
+ else
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters("-");
+ pStrm->EndElement( "number:text" );
+ }
+ }
+
+ if( m_eType == enuMXFNumberCurrency )
+ {
+ if( !m_strCurrencySymbol.isEmpty() )
+ {
+ pStrm->StartElement( "number:currency-symbol" );
+ pStrm->Characters(m_strCurrencySymbol);
+ pStrm->EndElement( "number:currency-symbol" );
+ }
+ }
+
+ //When category of number format is scientific, the number can not be displayed normally in table.
+ if ( m_eType == enumXFNumberScientific )
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute("number:decimal-places", OUString::number(m_nDecimalDigits));
+ pAttrList->AddAttribute("number:min-integer-digits", OUString::number(1));
+ pAttrList->AddAttribute("number:min-exponent-digits", OUString::number(2));
+ pStrm->StartElement( "number:scientific-number" );
+ pStrm->EndElement( "number:scientific-number" );
+ }
+ else
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute("number:decimal-places", OUString::number(m_nDecimalDigits));
+ pAttrList->AddAttribute("number:min-integer-digits", OUString::number(1));
+
+ if( m_bGroup )
+ pAttrList->AddAttribute("number:grouping","true");
+ else
+ pAttrList->AddAttribute("number:grouping","false");
+
+ pStrm->StartElement( "number:number" );
+ pStrm->EndElement( "number:number" );
+ }
+
+ if( !nagetive )
+ {
+ if( !m_strSuffix.isEmpty() )
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters(m_strSuffix);
+ pStrm->EndElement( "number:text" );
+ }
+ else
+ {
+ if( m_eType == enumXFNumberPercent )
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters("%");
+ pStrm->EndElement( "number:text" );
+ }
+ }
+ }
+ else
+ {
+ if( m_strNegativeSuffix.isEmpty() )
+ m_strNegativeSuffix = m_strSuffix;
+ if( !m_strNegativeSuffix.isEmpty() )
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters(m_strNegativeSuffix);
+ pStrm->EndElement( "number:text" );
+ }
+ else
+ {
+ if( m_eType == enumXFNumberPercent )
+ {
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters("%");
+ pStrm->EndElement( "number:text" );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfofficemeta.cxx b/lotuswordpro/source/filter/xfilter/xfofficemeta.cxx
new file mode 100644
index 000000000..9867449bc
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfofficemeta.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Implementation file for Meta data,pls reference to the header file.
+ ************************************************************************/
+#include <xfilter/xfofficemeta.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+void XFOfficeMeta::SetCreator(const OUString& creator)
+{
+ m_strCreator = creator;
+}
+void XFOfficeMeta::SetDescription(const OUString& dsr)
+{
+ m_strDsr = dsr;
+}
+void XFOfficeMeta::SetKeywords(const OUString& keywords)
+{
+ m_strKeywords = keywords;
+}
+void XFOfficeMeta::SetCreationTime(const OUString& crtime)
+{
+ m_strCrtime = crtime;
+}
+void XFOfficeMeta::SetLastTime(const OUString& lstime)
+{
+ m_strLstime = lstime;
+}
+void XFOfficeMeta::SetEditTime(const OUString& edtime)
+{
+ m_strEdtime = edtime;
+}
+void XFOfficeMeta::ToXml(IXFStream *pStream)
+{
+ IXFAttrList *pAttrList = pStream->GetAttrList();
+
+ pAttrList->Clear();
+ pStream->StartElement( "office:meta" );
+
+ //generator:
+ pStream->StartElement( "meta:generator" );
+ pStream->Characters( m_strGenerator );
+ pStream->EndElement( "meta:generator" );
+
+ //title
+ pStream->StartElement( "dc:title" );
+ pStream->Characters( m_strTitle );
+ pStream->EndElement( "dc:title" );
+
+ //keywords
+ pStream->StartElement( "meta:keywords" );
+ pStream->StartElement( "meta:keyword" );
+ pStream->Characters( m_strKeywords );
+ pStream->EndElement( "meta:keyword" );
+ pStream->EndElement( "meta:keywords" );
+
+ //creation time
+ pStream->StartElement( "meta:creation-date" );
+ pStream->Characters( m_strCrtime);
+ pStream->EndElement( "meta:creation-date" );
+
+ //last revision time
+ pStream->StartElement( "dc:date" );
+ pStream->Characters( m_strLstime);
+ pStream->EndElement( "dc:date" );
+ //total edit time
+ pStream->StartElement( "meta:editing-duration" );
+ pStream->Characters( m_strEdtime);
+ pStream->EndElement( "meta:editing-duration" );
+
+ //description
+ pStream->StartElement( "dc:description" );
+ pStream->Characters( m_strDsr );
+ pStream->EndElement( "dc:description" );
+ //creator
+ pStream->StartElement( "meta:initial-creator" );
+ pStream->Characters( m_strCreator );
+ pStream->EndElement( "meta:initial-creator" );
+
+ pStream->EndElement( "office:meta" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx b/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx
new file mode 100644
index 000000000..d6419e1df
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Page master used bye XFMasterPage.
+ * It is the real object to define header and footer of pages.
+ ************************************************************************/
+#include <xfilter/xfpagemaster.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfborders.hxx>
+#include <xfilter/xfshadow.hxx>
+#include <xfilter/xfcolumns.hxx>
+#include <xfilter/xfheaderstyle.hxx>
+#include <xfilter/xffooterstyle.hxx>
+#include <xfilter/xfbgimage.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFPageMaster::XFPageMaster() : m_fPageWidth(0), m_fPageHeight(0), m_eUsage(enumXFPageUsageNone),
+m_eTextDir(enumXFTextDirNone),
+m_eSepAlign(enumXFAlignNone), m_fSepWidth(0), m_aSepColor(0), m_fSepSpaceAbove(0),
+m_fSepSpaceBelow(0), m_nSepLengthPercent(0)
+{
+}
+
+XFPageMaster::~XFPageMaster()
+{
+}
+
+enumXFStyle XFPageMaster::GetStyleFamily()
+{
+ return enumXFStylePageMaster;
+}
+
+void XFPageMaster::SetPageWidth(double width)
+{
+ m_fPageWidth = width;
+}
+
+void XFPageMaster::SetPageHeight(double height)
+{
+ m_fPageHeight = height;
+}
+
+void XFPageMaster::SetMargins(double left, double right,double top, double bottom)
+{
+ if( left != -1 )
+ m_aMargin.SetLeft(left);
+ if( right != -1 )
+ m_aMargin.SetRight(right);
+ if( top != -1 )
+ m_aMargin.SetTop(top);
+ if( bottom != -1 )
+ m_aMargin.SetBottom(bottom);
+}
+
+void XFPageMaster::SetBorders(std::unique_ptr<XFBorders> pBorders)
+{
+ m_pBorders = std::move( pBorders );
+}
+
+void XFPageMaster::SetShadow(XFShadow *pShadow)
+{
+ if( pShadow == m_pShadow.get() )
+ return;
+ m_pShadow.reset( pShadow );
+}
+
+void XFPageMaster::SetBackColor(XFColor color)
+{
+ m_aBackColor = color;
+}
+
+void XFPageMaster::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_pBGImage = std::move(rImage);
+}
+
+void XFPageMaster::SetColumns(XFColumns *pColumns)
+{
+ if( pColumns == m_pColumns.get() )
+ return;
+ m_pColumns.reset(pColumns);
+}
+
+ void XFPageMaster::SetHeaderStyle(XFHeaderStyle *pHeaderStyle)
+{
+ if( pHeaderStyle == m_pHeaderStyle.get() )
+ return;
+ m_pHeaderStyle.reset( pHeaderStyle );
+}
+
+void XFPageMaster::SetFooterStyle(XFFooterStyle *pFooterStyle)
+{
+ if( pFooterStyle == m_pFooterStyle.get() )
+ return;
+ m_pFooterStyle.reset( pFooterStyle );
+}
+
+void XFPageMaster::SetFootNoteSeparator(
+ enumXFAlignType align,
+ double width,
+ sal_Int32 lengthPercent,
+ double spaceAbove,
+ double spaceBelow,
+ XFColor color
+ )
+{
+ m_eSepAlign = align;
+ m_fSepWidth = width;
+ m_nSepLengthPercent = lengthPercent;
+ m_fSepSpaceAbove = spaceAbove;
+ m_fSepSpaceBelow = spaceBelow;
+ m_aSepColor = color;
+}
+
+/**
+ *
+ <style:page-master style:name="pm1">
+ <style:properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1"
+ style:print-orientation="portrait" fo:margin-top="1.249cm" fo:margin-bottom="1.249cm"
+ fo:margin-left="3.175cm" fo:margin-right="3.175cm" style:writing-mode="lr-tb"
+ style:layout-grid-color="#c0c0c0" style:layout-grid-lines="42"
+ style:layout-grid-base-height="0.494cm" style:layout-grid-ruby-height="0.141cm"
+ style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false"
+ style:layout-grid-display="false" style:footnote-max-height="0cm">
+ <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm"
+ style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+ </style:properties>
+ <style:header-style>
+ <style:properties fo:min-height="1.291cm" fo:margin-bottom="0.792cm" style:dynamic-spacing="true"/>
+ </style:header-style>
+ <style:footer-style>
+ <style:properties fo:min-height="1.291cm" fo:margin-top="0.792cm" style:dynamic-spacing="true"/>
+ </style:footer-style>
+ </style:page-master>
+
+ */
+void XFPageMaster::ToXml(IXFStream *pStream)
+{
+ IXFAttrList *pAttrList = pStream->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute("style:name",GetStyleName());
+
+ if( m_eUsage != enumXFPageUsageNone )
+ pAttrList->AddAttribute("style:page-usage", GetPageUsageName(m_eUsage));
+
+ pStream->StartElement( "style:page-master" );
+
+ //style:properties
+ pAttrList->Clear();
+ if( m_fPageWidth != 0 )
+ pAttrList->AddAttribute( "fo:page-width", OUString::number(m_fPageWidth) + "cm" );
+ if( m_fPageHeight != 0 )
+ pAttrList->AddAttribute( "fo:page-height", OUString::number(m_fPageHeight) + "cm" );
+
+ m_aMargin.ToXml(pStream);
+
+ pAttrList->AddAttribute( "style:print-orientation", "portrait" );
+
+ if( m_pBorders )
+ m_pBorders->ToXml(pStream);
+ if( m_pShadow )
+ pAttrList->AddAttribute( "style:shadow", m_pShadow->ToString() );
+
+ if( m_aBackColor.IsValid() )
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+
+ //text directory
+ if( m_eTextDir != enumXFTextDirNone )
+ pAttrList->AddAttribute( "style:writing-mode", GetTextDirName(m_eTextDir) );
+
+ pStream->StartElement( "style:properties" );
+ if( m_pColumns )
+ m_pColumns->ToXml(pStream);
+
+ if( m_pBGImage )
+ m_pBGImage->ToXml(pStream);
+
+ if( m_eSepAlign || m_nSepLengthPercent>0 || m_fSepSpaceAbove>0 || m_fSepSpaceBelow>0 )
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:width", OUString::number(m_fSepWidth) + "cm" );
+ pAttrList->AddAttribute( "style:distance-before-sep", OUString::number(m_fSepSpaceAbove) + "cm" );
+ pAttrList->AddAttribute( "style:distance-after-sep", OUString::number(m_fSepSpaceBelow) + "cm" );
+ pAttrList->AddAttribute( "style:color", m_aSepColor.ToString() );
+ if( m_eSepAlign == enumXFAlignStart )
+ pAttrList->AddAttribute( "style:adjustment", "left" );
+ else if( m_eSepAlign == enumXFAlignCenter )
+ pAttrList->AddAttribute( "style:adjustment", "center" );
+ else if( m_eSepAlign == enumXFAlignEnd )
+ pAttrList->AddAttribute( "style:adjustment", "right" );
+ pAttrList->AddAttribute( "style:rel-width", OUString::number(m_nSepLengthPercent) + "%" );
+ pStream->StartElement( "style:footnote-sep" );
+ pStream->EndElement( "style:footnote-sep" );
+ }
+
+ pStream->EndElement( "style:properties" );
+
+ //header style:
+ if( m_pHeaderStyle )
+ m_pHeaderStyle->ToXml(pStream);
+ //footer style:
+ if( m_pFooterStyle )
+ m_pFooterStyle->ToXml(pStream);
+
+ pStream->EndElement( "style:page-master" );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfparagraph.cxx b/lotuswordpro/source/filter/xfilter/xfparagraph.cxx
new file mode 100644
index 000000000..bc070e36a
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfparagraph.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Paragraph object of OOo, it will output <text:p >...</text:p> element.
+ ************************************************************************/
+#include <xfilter/xfparagraph.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFParagraph::XFParagraph() {}
+
+XFParagraph::~XFParagraph() {}
+
+enumXFContent XFParagraph::GetContentType() { return enumXFContentPara; }
+
+/**
+ * The paragraph object serial function,the output will be like:
+ * <text:p>
+ * <text:span text:style-name="T1">text content</text:span>
+ * text.
+ * <text:span text:style-name="T1">text content</text:span>
+ * </text:p>
+ */
+void XFParagraph::ToXml(IXFStream* pStrm)
+{
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ assert(pAttrList);
+
+ pAttrList->Clear();
+ if (!GetStyleName().isEmpty())
+ pAttrList->AddAttribute("text:style-name", GetStyleName());
+ pStrm->StartElement("text:p");
+
+ XFContentContainer::ToXml(pStrm);
+
+ pStrm->EndElement("text:p");
+}
+
+bool XFParagraph::HasContents() const { return GetCount() > 0; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
new file mode 100644
index 000000000..4e298a248
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
@@ -0,0 +1,461 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Styles for paragraph.
+ * Styles for paragraph may include many style,include font,indent,margin,
+ * shadow,line height,and so on.
+ ************************************************************************/
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xffont.hxx>
+#include <xfilter/xfborders.hxx>
+#include "xftabstyle.hxx"
+#include <xfilter/xfbgimage.hxx>
+#include <xfilter/xfutil.hxx>
+
+XFParaStyle::XFParaStyle()
+ : m_eAlignType(enumXFAlignNone)
+ , m_fTextIndent(0)
+ , m_nFlag(0)
+ , m_bNumberRight(false)
+{
+}
+
+
+XFParaStyle::XFParaStyle(const XFParaStyle& other)
+ : XFStyle(other)
+ , m_eAlignType(other.m_eAlignType)
+ , m_fTextIndent(other.m_fTextIndent)
+ , m_aBackColor(other.m_aBackColor)
+ , m_aMargin(other.m_aMargin)
+ , m_aPadding(other.m_aPadding)
+ , m_pFont(other.m_pFont)
+ , m_aShadow(other.m_aShadow)
+ , m_aDropcap(other.m_aDropcap)
+ , m_aLineHeight(other.m_aLineHeight)
+ , m_aBreaks(other.m_aBreaks)
+ , m_nFlag(other.m_nFlag)
+ , m_bNumberRight(other.m_bNumberRight)
+{
+ if( other.m_pBorders )
+ m_pBorders.reset( new XFBorders(*other.m_pBorders) );
+
+ if( other.m_pBGImage )
+ m_pBGImage.reset( new XFBGImage(*other.m_pBGImage) );
+
+ for (size_t i = 0; i < other.m_aTabs.GetCount(); ++i)
+ {
+ const IXFStyle* pStyle = other.m_aTabs.Item(i);
+ if( pStyle )
+ {
+ const XFTabStyle* pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
+ if( pTabStyle )
+ {
+ std::unique_ptr<XFTabStyle> pCopyStyle(new XFTabStyle(*pTabStyle));
+ m_aTabs.AddStyle(std::move(pCopyStyle));
+ }
+ }
+ }
+}
+
+XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
+{
+ // Check for self-assignment
+ if (this != &other)
+ {
+ // first , clean member
+ m_pBGImage.reset();
+ m_aTabs.Reset();
+
+ m_strParentStyleName = other.m_strParentStyleName;
+ m_nFlag = other.m_nFlag;
+ m_eAlignType = other.m_eAlignType;
+ m_fTextIndent = other.m_fTextIndent;
+ m_bNumberRight = other.m_bNumberRight;
+
+ m_pFont = other.m_pFont;
+
+ if( other.m_pBorders )
+ m_pBorders.reset( new XFBorders(*other.m_pBorders) );
+ else
+ m_pBorders.reset();
+ m_aBackColor = other.m_aBackColor;
+ if( other.m_pBGImage )
+ m_pBGImage.reset( new XFBGImage(*other.m_pBGImage) );
+ else
+ m_pBGImage.reset();
+
+ m_aShadow = other.m_aShadow;
+ m_aMargin = other.m_aMargin;
+ m_aDropcap = other.m_aDropcap;
+ m_aLineHeight = other.m_aLineHeight;
+ m_aPadding = other.m_aPadding;
+ m_aBreaks = other.m_aBreaks;
+
+ for (size_t i=0; i<other.m_aTabs.GetCount(); ++i)
+ {
+ const IXFStyle *pStyle = other.m_aTabs.Item(i);
+ if( pStyle )
+ {
+ const XFTabStyle *pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
+ if( pTabStyle )
+ {
+ std::unique_ptr<XFTabStyle> pCopyStyle(new XFTabStyle(*pTabStyle));
+ m_aTabs.AddStyle(std::move(pCopyStyle));
+ }
+ }
+ }
+ }
+ return *this;
+}
+
+XFParaStyle::~XFParaStyle()
+{
+}
+
+enumXFStyle XFParaStyle::GetStyleFamily()
+{
+ return enumXFStylePara;
+}
+
+void XFParaStyle::SetFont(rtl::Reference<XFFont> const & pFont)
+{
+ m_pFont = pFont;
+}
+
+void XFParaStyle::SetIndent(double indent )
+{
+ m_fTextIndent = indent;
+}
+
+void XFParaStyle::SetMargins(double left, double right, double top, double bottom)
+{
+ if( left != -1 )
+ m_aMargin.SetLeft(left);
+ if( right != -1 )
+ m_aMargin.SetRight(right);
+ if( top != -1 )
+ m_aMargin.SetTop(top);
+ if( bottom != -1 )
+ m_aMargin.SetBottom( bottom );
+}
+
+void XFParaStyle::SetShadow(enumXFShadowPos pos, double offset, XFColor const & color)
+{
+ m_aShadow.SetPosition(pos);
+ m_aShadow.SetOffset(offset);
+ m_aShadow.SetColor(color);
+}
+
+void XFParaStyle::SetBackColor(XFColor const & color)
+{
+ m_aBackColor = color;
+ m_nFlag |= XFPARA_FLAG_BACKCOLOR;
+}
+
+void XFParaStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_pBGImage = std::move(rImage);
+}
+
+void XFParaStyle::SetBorders(XFBorders *pBorders)
+{
+ m_pBorders.reset( pBorders );
+}
+
+void XFParaStyle::SetDropCap(sal_Int16 nLength,
+ sal_Int16 nLines,
+ double fDistance
+ )
+{
+ assert(nLength>=1);
+ assert(nLines>=2);
+ assert(fDistance>=0);
+
+ m_aDropcap.SetCharCount(nLength);
+ m_aDropcap.SetLines(nLines);
+ m_aDropcap.SetDistance(fDistance);
+}
+
+void XFParaStyle::SetLineHeight(enumLHType type, double value)
+{
+ if( type == enumLHNone )
+ {
+ return;
+ }
+ switch(type)
+ {
+ case enumLHHeight:
+ m_aLineHeight.SetHeight(value) ;
+ break;
+ case enumLHLeast:
+ m_aLineHeight.SetLeastHeight(value);
+ break;
+ case enumLHPercent: //perhaps i should redesign the interface here,ohm...
+ m_aLineHeight.SetPercent(static_cast<sal_Int32>(value));
+ break;
+ case enumLHSpace:
+ m_aLineHeight.SetSpace(value*0.5666); //don't known why,just suspect.
+ break;
+ default:
+ break;
+ }
+}
+
+void XFParaStyle::AddTabStyle(enumXFTab type, double len, sal_Unicode leader, sal_Unicode delimiter)
+{
+ std::unique_ptr<XFTabStyle> tab(new XFTabStyle());
+ tab->SetTabType(type);
+ tab->SetLength(len);
+ tab->SetLeaderChar(leader);
+ tab->SetDelimiter(delimiter);
+ m_aTabs.AddStyle(std::move(tab));
+}
+
+/**
+ *Affirm whether two XFParaStyle objects are equal.
+ */
+bool XFParaStyle::Equal(IXFStyle *pStyle)
+{
+ if( this == pStyle )
+ return true;
+ if( !pStyle || pStyle->GetStyleFamily() != enumXFStylePara )
+ return false;
+
+ XFParaStyle *pOther = static_cast<XFParaStyle*>(pStyle);
+
+ if( m_nFlag != pOther->m_nFlag )
+ return false;
+ if( m_strParentStyleName != pOther->m_strParentStyleName )
+ return false;
+ if( m_strMasterPage != pOther->m_strMasterPage )
+ return false;
+ if( m_fTextIndent != pOther->m_fTextIndent )
+ return false;
+ //align:
+ if( m_eAlignType != pOther->m_eAlignType )
+ return false;
+
+ //shadow:
+ if( m_aShadow != pOther->m_aShadow )
+ return false;
+ //margin:
+ if( m_aMargin != pOther->m_aMargin )
+ return false;
+
+ if( m_aPadding != pOther->m_aPadding )
+ return false;
+
+ //dropcap:
+ if( m_aDropcap != pOther->m_aDropcap )
+ return false;
+ //line height:
+ if( m_aLineHeight != pOther->m_aLineHeight )
+ return false;
+ //breaks:
+ if( m_aBreaks != pOther->m_aBreaks )
+ return false;
+ if( m_aTabs != pOther->m_aTabs )
+ return false;
+
+ //font:
+ if( m_pFont.is() )
+ {
+ if( !pOther->m_pFont.is() )
+ return false;
+ if(*m_pFont != *pOther->m_pFont )
+ return false;
+ }
+ else if( pOther->m_pFont.is() )
+ return false;
+
+ //border:
+ if( m_pBorders )
+ {
+ if( !pOther->m_pBorders )
+ return false;
+ if( *m_pBorders != *pOther->m_pBorders )
+ return false;
+ }
+ else if( pOther->m_pBorders )
+ return false;
+
+ if( m_pBGImage )
+ {
+ if( !pOther->m_pBGImage )
+ return false;
+ if( *m_pBGImage != *pOther->m_pBGImage )
+ return false;
+ }
+ else if( pOther->m_pBGImage )
+ return false;//add end
+
+ //number right
+ if ( m_bNumberRight != pOther->m_bNumberRight)
+ return false;
+
+ return true;
+}
+
+void XFParaStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ OUString style = GetStyleName();
+
+ pAttrList->Clear();
+ if( !style.isEmpty() )
+ pAttrList->AddAttribute("style:name",GetStyleName());
+ pAttrList->AddAttribute("style:family", "paragraph");
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+
+ if( !m_strMasterPage.isEmpty() )
+ pAttrList->AddAttribute("style:master-page-name",m_strMasterPage);
+ pStrm->StartElement("style:style");
+
+ //Paragraph properties:
+ pAttrList->Clear();
+
+ //text indent:
+ if( m_fTextIndent )
+ {
+ pAttrList->AddAttribute("fo:text-indent", OUString::number(m_fTextIndent) + "cm" );
+ }
+ //padding:
+ m_aPadding.ToXml(pStrm);
+ //margin:
+ m_aMargin.ToXml(pStrm);
+
+ //text align:
+ if( m_eAlignType != enumXFAlignNone )
+ {
+ pAttrList->AddAttribute("fo:text-align", GetAlignName(m_eAlignType) );
+ }
+ //line number:
+ pAttrList->AddAttribute( "text:number-lines", "true" );
+ pAttrList->AddAttribute( "text:line-number", OUString::number(0) );
+
+ //shadow:
+ m_aShadow.ToXml(pStrm);
+ //borders:
+ if( m_pBorders )
+ m_pBorders->ToXml(pStrm);
+ //line height:
+ m_aLineHeight.ToXml(pStrm);
+
+ //background color:
+ if( m_nFlag&XFPARA_FLAG_BACKCOLOR && m_aBackColor.IsValid() )
+ {
+ pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
+ }
+ //Font properties:
+ if( m_pFont.is() )
+ m_pFont->ToXml(pStrm);
+
+ //page breaks:
+ m_aBreaks.ToXml(pStrm);
+
+ pStrm->StartElement("style:properties");
+
+ //dropcap:
+ m_aDropcap.ToXml(pStrm);
+
+ //tabs:
+ if( m_aTabs.GetCount() > 0 )
+ {
+ pAttrList->Clear();
+ pStrm->StartElement( "style:tab-stops" );
+ m_aTabs.ToXml(pStrm);
+ pStrm->EndElement( "style:tab-stops" );
+ }
+
+ //background color:
+ if( m_pBGImage )
+ m_pBGImage->ToXml(pStrm);
+
+ pStrm->EndElement("style:properties");
+
+ pStrm->EndElement("style:style");
+}
+
+XFDefaultParaStyle::XFDefaultParaStyle()
+{
+ m_fTabDistance = 1.28;
+}
+
+enumXFStyle XFDefaultParaStyle::GetStyleFamily()
+{
+ return enumXFStyleDefaultPara;
+}
+
+void XFDefaultParaStyle::ToXml(IXFStream * pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pAttrList->AddAttribute("style:family", "paragraph");
+ pStrm->StartElement("style:default-style");
+
+ //Paragraph properties:
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute("style:tab-stop-distance", OUString::number(m_fTabDistance) + "cm" );
+
+ pStrm->StartElement("style:properties");
+ pStrm->EndElement("style:properties");
+ pStrm->EndElement("style:default-style");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfrow.cxx b/lotuswordpro/source/filter/xfilter/xfrow.cxx
new file mode 100644
index 000000000..1bdfb8849
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfrow.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table object.
+ ************************************************************************/
+
+#include <sal/config.h>
+
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xfrow.hxx>
+#include <xfilter/xfcell.hxx>
+
+XFRow::XFRow()
+ : m_pOwnerTable(nullptr)
+ , m_nRepeat(0)
+ , m_nRow(0)
+{
+}
+
+XFRow::~XFRow()
+{
+}
+
+void XFRow::AddCell(rtl::Reference<XFCell> const & rCell)
+{
+ if (!rCell)
+ return;
+ sal_Int32 col = m_aCells.size() + 1;
+ rCell->SetCol(col);
+ rCell->SetOwnerRow(this);
+ m_aCells.push_back(rCell);
+}
+
+sal_Int32 XFRow::GetCellCount() const
+{
+ return m_aCells.size();
+}
+
+// 1 based
+XFCell* XFRow::GetCell(sal_Int32 col) const
+{
+ assert(col > 0);
+ size_t nIndex = col - 1;
+ if (nIndex < m_aCells.size())
+ return m_aCells[nIndex].get();
+ return nullptr;
+}
+
+void XFRow::ToXml(IXFStream *pStrm)
+{
+ sal_Int32 lastCol = 0;
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "table:style-name", GetStyleName() );
+ if( m_nRepeat )
+ pAttrList->AddAttribute( "table:number-rows-repeated", OUString::number(m_nRepeat) );
+ pStrm->StartElement( "table:table-row" );
+
+ for (size_t nIndex = 0, nCount = m_aCells.size(); nIndex < nCount; ++nIndex)
+ {
+ XFCell *pCell = m_aCells[nIndex].get();
+ if (!pCell)
+ continue;
+ int col = nIndex + 1;
+ if( col>lastCol+1 )
+ {
+ XFCell *pNULLCell = new XFCell();
+ if( col>lastCol+2 )
+ pNULLCell->SetRepeated(col-lastCol-1);
+ pNULLCell->ToXml(pStrm);
+ }
+ pCell->ToXml(pStrm);
+ lastCol = col;
+ }
+
+ pStrm->EndElement( "table:table-row" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx b/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx
new file mode 100644
index 000000000..99d654da4
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfrowstyle.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table row style, ie. table row height.
+ ************************************************************************/
+#include <xfilter/xfrowstyle.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFRowStyle::XFRowStyle():m_fHeight(0)
+{
+ m_fHeight = 0;
+ m_fMinHeight = 0;
+}
+
+enumXFStyle XFRowStyle::GetStyleFamily()
+{
+ return enumXFStyleTableRow;
+}
+
+void XFRowStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+
+ pAttrList->AddAttribute( "style:family", "table-row" );
+ pStrm->StartElement( "style:style" );
+
+ pAttrList->Clear();
+ if( m_fMinHeight )
+ pAttrList->AddAttribute( "style:min-row-height", OUString::number(m_fMinHeight) + "cm" );
+ else if( m_fHeight )
+ pAttrList->AddAttribute( "style:row-height", OUString::number(m_fHeight) + "cm" );
+
+ if( m_aBackColor.IsValid() )
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfsaxattrlist.cxx b/lotuswordpro/source/filter/xfilter/xfsaxattrlist.cxx
new file mode 100644
index 000000000..aa175d849
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfsaxattrlist.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Document object of the xml filter framework.
+ ************************************************************************/
+#include "xfsaxattrlist.hxx"
+#include <xmloff/attrlist.hxx>
+
+XFSaxAttrList::XFSaxAttrList()
+ : m_xSvAttrList(new SvXMLAttributeList())
+{
+}
+
+XFSaxAttrList::~XFSaxAttrList() {}
+
+void XFSaxAttrList::AddAttribute(const OUString& name, const OUString& value)
+{
+ m_xSvAttrList->AddAttribute(name, value);
+}
+
+void XFSaxAttrList::Clear() { m_xSvAttrList->Clear(); }
+
+css::uno::Reference<css::xml::sax::XAttributeList> XFSaxAttrList::GetAttributeList() const
+{
+ return m_xSvAttrList;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfsaxattrlist.hxx b/lotuswordpro/source/filter/xfilter/xfsaxattrlist.hxx
new file mode 100644
index 000000000..4a727727d
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfsaxattrlist.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Wrapper the attribute list of a xml element.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFSAXATTRLIST_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFSAXATTRLIST_HXX
+
+#include <xfilter/ixfattrlist.hxx>
+#include <rtl/ref.hxx>
+#include <xmloff/attrlist.hxx>
+
+class XFSaxAttrList : public IXFAttrList
+{
+public:
+ XFSaxAttrList();
+
+ virtual ~XFSaxAttrList() override;
+
+public:
+ //Interface ISaxAttributeList:
+ virtual void AddAttribute(const OUString& name, const OUString& value) override;
+
+ virtual void Clear() override;
+
+ css::uno::Reference<css::xml::sax::XAttributeList> GetAttributeList() const;
+
+ friend class XFSaxStream;
+
+private:
+ rtl::Reference<SvXMLAttributeList> m_xSvAttrList;
+};
+
+#endif //XFSAXATTRLIST_INC
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx
new file mode 100644
index 000000000..700161df2
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfsaxstream.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tool for sax writer.
+ ************************************************************************/
+#include <xfilter/xfsaxstream.hxx>
+#include "xfsaxattrlist.hxx"
+
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+using namespace ::cppu;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+
+XFSaxStream::XFSaxStream(Reference<XDocumentHandler> const& xHandler)
+{
+ m_aHandler = xHandler;
+ m_pAttrList.reset(new XFSaxAttrList);
+}
+
+XFSaxStream::~XFSaxStream() {}
+
+void XFSaxStream::StartDocument()
+{
+ if (m_aHandler.is())
+ m_aHandler->startDocument();
+}
+
+void XFSaxStream::EndDocument()
+{
+ if (m_aHandler.is())
+ m_aHandler->endDocument();
+}
+
+void XFSaxStream::StartElement(const OUString& oustr)
+{
+ if (m_aHandler.is())
+ m_aHandler->startElement(oustr, m_pAttrList->GetAttributeList());
+ m_pAttrList->Clear();
+}
+
+void XFSaxStream::EndElement(const OUString& oustr)
+{
+ if (m_aHandler.is())
+ m_aHandler->endElement(oustr);
+
+ if (m_pAttrList)
+ m_pAttrList->Clear();
+}
+
+void XFSaxStream::Characters(const OUString& oustr)
+{
+ if (m_aHandler.is())
+ m_aHandler->characters(oustr);
+}
+
+IXFAttrList* XFSaxStream::GetAttrList() { return m_pAttrList.get(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfsection.cxx b/lotuswordpro/source/filter/xfilter/xfsection.cxx
new file mode 100644
index 000000000..994f9227c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfsection.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Section object.
+ ************************************************************************/
+#include <xfilter/xfsection.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFSection::XFSection() { m_strSectionName = XFGlobal::GenSectionName(); }
+
+XFSection::~XFSection() {}
+
+void XFSection::ToXml(IXFStream* pStrm)
+{
+ assert(!m_strSectionName.isEmpty());
+
+ IXFAttrList* pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ OUString style = GetStyleName();
+ if (!style.isEmpty())
+ pAttrList->AddAttribute("text:style-name", style);
+ //section name
+ if (!m_strSectionName.isEmpty())
+ pAttrList->AddAttribute("text:name", m_strSectionName);
+
+ pStrm->StartElement("text:section");
+ if (!m_strSourceLink.isEmpty())
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute("xlink:href", m_strSourceLink);
+ pAttrList->AddAttribute("text:filter-name", "wordpro");
+ pStrm->StartElement("text:section-source");
+ pStrm->EndElement("text:section-source");
+ }
+
+ XFContentContainer::ToXml(pStrm);
+
+ pStrm->EndElement("text:section");
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx b/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx
new file mode 100644
index 000000000..0bf664d6a
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfsectionstyle.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Section style,whose family is "section"
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfsectionstyle.hxx>
+#include <xfilter/xfcolumns.hxx>
+
+XFSectionStyle::XFSectionStyle()
+{
+ m_fMarginLeft = 0;
+ m_fMarginRight = 0;
+ m_pColumns = nullptr;
+}
+
+XFSectionStyle::~XFSectionStyle()
+{
+}
+
+enumXFStyle XFSectionStyle::GetStyleFamily()
+{
+ return enumXFStyleSection;
+}
+
+void XFSectionStyle::SetMarginLeft(double left)
+{
+ m_fMarginLeft = left;
+}
+
+void XFSectionStyle::SetMarginRight(double right)
+{
+ m_fMarginRight = right;
+}
+
+void XFSectionStyle::SetColumns(XFColumns *pColumns)
+{
+ m_pColumns.reset( pColumns );
+}
+
+void XFSectionStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ pAttrList->AddAttribute( "style:family", "section" );
+
+ pStrm->StartElement( "style:style" );
+
+ pAttrList->Clear();
+ if( m_fMarginLeft != 0 )
+ {
+ pAttrList->AddAttribute( "fo:margin-left", OUString::number(m_fMarginLeft) + "cm" );
+ }
+ if( m_fMarginRight != 0 )
+ {
+ pAttrList->AddAttribute( "fo:margin-right", OUString::number(m_fMarginRight) + "cm" );
+ }
+ if( m_aBackColor.IsValid() )
+ {
+ pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
+ }
+ else
+ {
+ pAttrList->AddAttribute( "fo:background-color", "transparent" );
+ }
+
+ pStrm->StartElement( "style:properties" );
+
+ if( m_pColumns )
+ m_pColumns->ToXml(pStrm);
+
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfshadow.cxx b/lotuswordpro/source/filter/xfilter/xfshadow.cxx
new file mode 100644
index 000000000..a5acfb343
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfshadow.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Shadow object,now only used by paragraph object.
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfshadow.hxx>
+
+XFShadow::XFShadow()
+ : m_ePosition(enumXFShadowNone)
+ , m_fOffset(0.18)
+ , m_aColor(128,128,0)
+{}
+
+OUString XFShadow::ToString()
+{
+ OUString buf;
+ OUString strOff = OUString::number(m_fOffset);
+
+ switch(m_ePosition)
+ {
+ case enumXFShadowRightBottom:
+ buf = m_aColor.ToString() + " " + strOff + "cm " + strOff + "cm";
+ break;
+ case enumXFShadowRightTop:
+ buf = m_aColor.ToString() + " " + strOff + "cm -" + strOff + "cm";
+ break;
+ case enumXFShadowLeftBottom:
+ buf = m_aColor.ToString() + " -" + strOff + "cm " + strOff + "cm";
+ break;
+ case enumXFShadowLeftTop:
+ buf = m_aColor.ToString() + " -" + strOff + "cm -" + strOff + "cm";
+ break;
+ default:
+ buf = m_aColor.ToString();
+ break;
+ }
+
+ return buf;
+}
+
+void XFShadow::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ if( m_ePosition == enumXFShadowNone )
+ return;
+ else
+ pAttrList->AddAttribute( "style:shadow", ToString() );
+}
+
+bool operator==(XFShadow const & s1, XFShadow const & s2)
+{
+ return (s1.m_ePosition == s2.m_ePosition) &&
+ (s1.m_fOffset == s2.m_fOffset) &&
+ (s1.m_aColor == s2.m_aColor);
+}
+
+bool operator!=(XFShadow const & s1, XFShadow const & s2)
+{
+ return !(s1==s2);
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfstyle.cxx b/lotuswordpro/source/filter/xfilter/xfstyle.cxx
new file mode 100644
index 000000000..d6846340e
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfstyle.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Base style object .
+ ************************************************************************/
+#include <xfilter/xfstyle.hxx>
+
+XFStyle::XFStyle()
+{
+}
+
+XFStyle::~XFStyle()
+{
+}
+
+OUString XFStyle::GetStyleName()
+{
+ return m_strStyleName;
+}
+
+void XFStyle::SetStyleName(const OUString& styleName)
+{
+ m_strStyleName = styleName;
+}
+
+OUString XFStyle::GetParentStyleName()
+{
+ return m_strParentStyleName;
+}
+
+void XFStyle::SetParentStyleName(const OUString& styleName)
+{
+ m_strParentStyleName = styleName;
+}
+
+enumXFStyle XFStyle::GetStyleFamily()
+{
+ return enumXFStyleUnknown;
+}
+
+bool XFStyle::Equal(IXFStyle * /*pStyle*/)
+{
+ return false;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
new file mode 100644
index 000000000..c9bcfc3c8
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Font object to serial to xml filter.
+ ************************************************************************/
+#include <xfilter/xfstylecont.hxx>
+#include <xfilter/ixfstyle.hxx>
+#include <xfilter/xffont.hxx>
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xffontfactory.hxx>
+#include <lwpglobalmgr.hxx>
+
+XFStyleContainer::XFStyleContainer(const OUString& strStyleNamePrefix)
+ :m_strStyleNamePrefix(strStyleNamePrefix)
+{
+}
+
+XFStyleContainer::~XFStyleContainer()
+{
+}
+
+void XFStyleContainer::Reset()
+{
+ m_aStyles.clear();
+}
+
+IXFStyleRet XFStyleContainer::AddStyle(std::unique_ptr<IXFStyle> pStyle)
+{
+ IXFStyleRet aRet;
+
+ IXFStyle *pConStyle = nullptr;
+
+ if( !pStyle )
+ return aRet;
+ //no matter we want to delete the style or not,XFFont object should be saved first.
+ ManageStyleFont(pStyle.get());
+
+ if( pStyle->GetStyleName().isEmpty() )
+ pConStyle = FindSameStyle(pStyle.get());
+
+ if( pConStyle )//such a style has exist:
+ {
+ aRet.m_pStyle = pConStyle;
+ aRet.m_bOrigDeleted = true;
+ return aRet;
+ }
+ else
+ {
+ OUString name;
+ if( pStyle->GetStyleName().isEmpty() )
+ {
+ name = m_strStyleNamePrefix + OUString::number(m_aStyles.size()+1);
+ pStyle->SetStyleName(name);
+ }
+ else
+ {
+ name = pStyle->GetStyleName();
+ //for name conflict
+ if(FindStyle( name))
+ {
+ name += OUString::number(m_aStyles.size()+1);
+ pStyle->SetStyleName(name);
+ }
+ }
+
+ //transform the font object to XFFontFactory
+ aRet.m_pStyle = pStyle.get();
+ m_aStyles.push_back(std::move(pStyle));
+ return aRet;
+ }
+}
+
+IXFStyle* XFStyleContainer::FindSameStyle(IXFStyle *pStyle)
+{
+ for (auto const& style : m_aStyles)
+ {
+ assert(style);
+ if( style->Equal(pStyle) )
+ return style.get();
+ }
+
+ return nullptr;
+}
+
+IXFStyle* XFStyleContainer::FindStyle(std::u16string_view name)
+{
+ for (auto const& style : m_aStyles)
+ {
+ assert(style);
+ if( style->GetStyleName() == name )
+ return style.get();
+ }
+
+ return nullptr;
+}
+
+const IXFStyle* XFStyleContainer::Item(size_t index) const
+{
+ assert(index<m_aStyles.size());
+ if (index < m_aStyles.size())
+ {
+ return m_aStyles[index].get();
+ }
+ return nullptr;
+}
+
+void XFStyleContainer::ToXml(IXFStream *pStrm)
+{
+ for (auto const& style : m_aStyles)
+ {
+ assert(style);
+ style->ToXml(pStrm);
+ }
+}
+
+void XFStyleContainer::ManageStyleFont(IXFStyle *pStyle)
+{
+ rtl::Reference<XFFont> pStyleFont;
+ rtl::Reference<XFFont> pFactoryFont;
+
+ if( !pStyle )
+ return;
+
+ if( pStyle->GetStyleFamily() == enumXFStyleText )
+ {
+ XFTextStyle *pTS = static_cast<XFTextStyle*>(pStyle);
+ pStyleFont = pTS->GetFont();
+ if( !pStyleFont.is() )
+ return;
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ XFFontFactory* pFontFactory = pGlobal->GetXFFontFactory();
+ pFactoryFont = pFontFactory->FindSameFont(pStyleFont);
+ //this font has been exists in the factory:
+ if( pFactoryFont.is() )
+ {
+ pTS->SetFont(pFactoryFont);
+ }
+ else
+ {
+ pFontFactory->AddFont(pStyleFont);
+ }
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStylePara )
+ {
+ XFParaStyle *pPS = static_cast<XFParaStyle*>(pStyle);
+ pStyleFont = pPS->GetFont();
+ if( !pStyleFont.is() )
+ return;
+ LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
+ XFFontFactory* pFontFactory = pGlobal->GetXFFontFactory();
+ pFactoryFont = pFontFactory->FindSameFont(pStyleFont);
+ //this font has been exists in the factory:
+ if( pFactoryFont.is() )
+ {
+ pPS->SetFont(pFactoryFont);
+ }
+ else
+ {
+ pFontFactory->AddFont(pStyleFont);
+ }
+ }
+}
+
+bool operator==(XFStyleContainer& b1, XFStyleContainer& b2)
+{
+ if( b1.m_strStyleNamePrefix != b2.m_strStyleNamePrefix )
+ return false;
+ if( b1.m_aStyles.size() != b2.m_aStyles.size() )
+ return false;
+ for( size_t i=0; i<b1.m_aStyles.size(); ++i )
+ {
+ IXFStyle *pS1 = b1.m_aStyles[i].get();
+ IXFStyle *pS2 = b2.m_aStyles[i].get();
+
+ if( pS1 )
+ {
+ if( !pS2 )
+ return false;
+ if( !pS1->Equal(pS2) )
+ return false;
+ }
+ else
+ {
+ if( pS2 )
+ return false;
+ }
+ }
+ return true;
+}
+
+bool operator!=(XFStyleContainer& b1, XFStyleContainer& b2)
+{
+ return !(b1==b2);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
new file mode 100644
index 000000000..7cf97f8a4
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Style manager for the filter.
+ ************************************************************************/
+
+#include <sal/config.h>
+
+#include <xfilter/xfparastyle.hxx>
+#include <xfilter/xfstylemanager.hxx>
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/ixfstyle.hxx>
+
+XFStyleManager::XFStyleManager() : s_aStdArrowStyles( "arrow" ), s_aTextStyles( "T" ),
+ s_aParaStyles( "P" ),s_aListStyles( "L" ),s_aSectionStyles( "Sect" ),
+ s_aPageMasters( "PM" ),s_aMasterpages( "MP" ),s_aDateStyles( "N" ),
+ s_aGraphicsStyles( "fr" ),s_aTableStyles( "table" ),s_aTableCellStyles( "cell" ),
+ s_aTableRowStyles( "row" ),s_aTableColStyles( "col" )
+{
+}
+
+XFStyleManager::~XFStyleManager()
+{
+ Reset();
+}
+
+void XFStyleManager::Reset()
+{
+ s_pOutlineStyle.reset();
+
+ s_aStdTextStyles.Reset();
+ s_aStdParaStyles.Reset();
+ s_aStdStrokeDashStyles.Reset();
+ s_aStdAreaStyles.Reset();
+ s_aStdArrowStyles.Reset();
+ s_aTextStyles.Reset();
+ s_aParaStyles.Reset();
+ s_aListStyles.Reset();
+ s_aSectionStyles.Reset();
+ s_aPageMasters.Reset();
+ s_aMasterpages.Reset();
+ s_aDateStyles.Reset();
+ s_aGraphicsStyles.Reset();
+ s_aConfigManager.Reset();
+ //must clear all static containers.
+ s_aFontDecls.clear();
+}
+
+void XFStyleManager::AddFontDecl(XFFontDecl const & aFontDecl)
+{
+ s_aFontDecls.push_back(aFontDecl);
+}
+
+IXFStyleRet XFStyleManager::AddStyle(std::unique_ptr<IXFStyle> pStyle)
+{
+ IXFStyleRet aRet;
+
+ assert(pStyle);
+ OUString name = pStyle->GetStyleName();
+
+ if( pStyle->GetStyleFamily() == enumXFStyleText )
+ {
+ if( !name.isEmpty() )
+ {
+ aRet = s_aStdTextStyles.AddStyle(std::move(pStyle));
+ }
+ else
+ {
+ aRet = s_aTextStyles.AddStyle(std::move(pStyle));
+ }
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStylePara )
+ {
+ if( !name.isEmpty() )
+ {
+ aRet = s_aStdParaStyles.AddStyle(std::move(pStyle));
+ }
+ else
+ {
+ aRet = s_aParaStyles.AddStyle(std::move(pStyle));
+ }
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleDefaultPara )
+ {
+ aRet = s_aStdParaStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleList )
+ {
+ aRet = s_aListStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleSection )
+ {
+ aRet = s_aSectionStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStylePageMaster )
+ {
+ aRet = s_aPageMasters.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleMasterPage )
+ {
+ //Master page don't need name.
+ aRet = s_aMasterpages.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleDate )
+ {
+ aRet = s_aDateStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleTime )
+ {
+ aRet = s_aDateStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleNumber )
+ {
+ aRet = s_aDateStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStylePercent )
+ {
+ aRet = s_aDateStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleCurrency )
+ {
+ aRet = s_aDateStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleGraphics )
+ {
+ aRet = s_aGraphicsStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleTable )
+ {
+ aRet = s_aTableStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleTableCell )
+ {
+ aRet = s_aTableCellStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleTableRow )
+ {
+ aRet = s_aTableRowStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleTableCol )
+ {
+ aRet = s_aTableColStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleOutline )
+ {
+ s_pOutlineStyle = std::move(pStyle);
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleStrokeDash )
+ {
+ aRet = s_aStdStrokeDashStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleArea )
+ {
+ aRet = s_aStdAreaStyles.AddStyle(std::move(pStyle));
+ }
+ else if( pStyle->GetStyleFamily() == enumXFStyleArrow )
+ {
+ aRet = s_aStdArrowStyles.AddStyle(std::move(pStyle));
+ }
+ else if (pStyle->GetStyleFamily() == enumXFStyleRuby)
+ {
+ aRet = s_aRubyStyles.AddStyle(std::move(pStyle));
+ }
+
+ return aRet;
+}
+
+IXFStyle* XFStyleManager::FindStyle(std::u16string_view name)
+{
+ IXFStyle *pStyle = FindParaStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = FindTextStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aListStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aSectionStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aPageMasters.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aMasterpages.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aDateStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aGraphicsStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aTableStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aTableCellStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aTableRowStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aTableColStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ if(s_pOutlineStyle && s_pOutlineStyle->GetStyleName() == name )
+ return s_pOutlineStyle.get();
+ pStyle = s_aStdStrokeDashStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aStdAreaStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+ pStyle = s_aStdArrowStyles.FindStyle(name);
+ if( pStyle )
+ return pStyle;
+
+ return nullptr;
+}
+
+XFParaStyle* XFStyleManager::FindParaStyle(std::u16string_view name)
+{
+ IXFStyle *pStyle = s_aParaStyles.FindStyle(name);
+ if( pStyle )
+ return static_cast<XFParaStyle*>(pStyle);
+ else
+ return static_cast<XFParaStyle*>(s_aStdParaStyles.FindStyle(name));
+}
+
+XFTextStyle* XFStyleManager::FindTextStyle(std::u16string_view name)
+{
+ IXFStyle *pStyle = s_aTextStyles.FindStyle(name);
+ if( pStyle )
+ return static_cast<XFTextStyle*>(pStyle);
+ else
+ return static_cast<XFTextStyle*>(s_aStdTextStyles.FindStyle(name));
+}
+
+void XFStyleManager::SetLineNumberConfig(XFLineNumberConfig *pLNConf)
+{
+ s_aConfigManager.SetLineNumberConfig(pLNConf);
+}
+
+void XFStyleManager::SetFootnoteConfig(XFFootnoteConfig *pFNConfig)
+{
+ s_aConfigManager.SetFootnoteConfig(pFNConfig);
+}
+
+void XFStyleManager::SetEndnoteConfig(XFEndnoteConfig *pENConfig)
+{
+ s_aConfigManager.SetEndnoteConfig(pENConfig);
+}
+
+void XFStyleManager::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pStrm->StartElement( "office:font-decls" );
+
+ //font declarations:
+ for (const auto & fontDecl : s_aFontDecls)
+ {
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", fontDecl.GetFontName() );
+ pAttrList->AddAttribute( "fo:font-family", fontDecl.GetFontFamily() );
+ pAttrList->AddAttribute( "style:font-pitch", "variable" );
+ pStrm->StartElement( "style:font-decl" );
+ pStrm->EndElement( "style:font-decl" );
+ }
+
+ pStrm->EndElement( "office:font-decls" );
+
+ //office:styles:
+ pAttrList->Clear();
+ pStrm->StartElement( "office:styles" );
+
+ s_aStdParaStyles.ToXml(pStrm);
+ s_aStdTextStyles.ToXml(pStrm);
+ s_aStdStrokeDashStyles.ToXml(pStrm);
+ s_aStdAreaStyles.ToXml(pStrm);
+ s_aStdArrowStyles.ToXml(pStrm);
+ //date,time styles:
+ s_aDateStyles.ToXml(pStrm);
+ s_aConfigManager.ToXml(pStrm);
+ //for optimist.
+ s_aListStyles.ToXml(pStrm);
+
+ if( s_pOutlineStyle )
+ s_pOutlineStyle->ToXml(pStrm);
+
+ pStrm->EndElement( "office:styles" );
+
+ //automatic styles:
+ pAttrList->Clear();
+ pStrm->StartElement( "office:automatic-styles" );
+
+ s_aTableStyles.ToXml(pStrm);
+ s_aTableCellStyles.ToXml(pStrm);
+ s_aTableRowStyles.ToXml(pStrm);
+ s_aTableColStyles.ToXml(pStrm);
+ s_aParaStyles.ToXml(pStrm);
+ s_aTextStyles.ToXml(pStrm);
+ s_aSectionStyles.ToXml(pStrm);
+ s_aPageMasters.ToXml(pStrm);
+ s_aRubyStyles.ToXml(pStrm);
+ //graphics:
+ s_aGraphicsStyles.ToXml(pStrm);
+
+ pStrm->EndElement( "office:automatic-styles" );
+
+ //master:styles
+ pAttrList->Clear();
+ pStrm->StartElement( "office:master-styles" );
+ //masters pages:
+ s_aMasterpages.ToXml(pStrm);
+
+ pStrm->EndElement( "office:master-styles" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftable.cxx b/lotuswordpro/source/filter/xfilter/xftable.cxx
new file mode 100644
index 000000000..976ee8bb9
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftable.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table object.
+ ************************************************************************/
+#include <xfilter/xftable.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xfrow.hxx>
+#include <xfilter/xfglobal.hxx>
+#include <cassert>
+
+XFTable::XFTable()
+{
+ m_strName = XFGlobal::GenTableName();
+ m_bSubTable = false;
+ m_pOwnerCell = nullptr;
+}
+
+XFTable::~XFTable()
+{
+ m_aRows.clear();
+ m_aColumns.clear();
+}
+
+void XFTable::SetColumnStyle(sal_Int32 col, const OUString& style)
+{
+ m_aColumns[col] = style;
+}
+
+bool XFTable::ContainsTable(const XFTable* pTable) const
+{
+ for (auto const& elem : m_aRows)
+ {
+ const XFRow *pRow = elem.second.get();
+
+ for (sal_Int32 i = 0; i < pRow->GetCellCount(); ++i)
+ {
+ const XFCell* pCell = pRow->GetCell(i + 1); //starts at 1, not 0
+ if (const XFTable* pSubTable = pCell->GetSubTable())
+ {
+ if (pSubTable == pTable)
+ return true;
+ if (pSubTable->ContainsTable(pTable))
+ return true;
+ }
+ if (pCell->HierarchyContains(pTable))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void XFTable::AddRow(rtl::Reference<XFRow> const & rRow)
+{
+ assert(rRow);
+
+ for (sal_Int32 i = 0; i < rRow->GetCellCount(); ++i)
+ {
+ XFCell* pFirstCell = rRow->GetCell(i + 1); //starts at 1, not 0
+ if (const XFTable* pSubTable = pFirstCell->GetSubTable())
+ {
+ if (pSubTable == this || pSubTable->ContainsTable(this))
+ throw std::runtime_error("table is a subtable of itself");
+ }
+ if (pFirstCell->HierarchyContains(this))
+ throw std::runtime_error("table is a subtable of itself");
+
+ }
+
+ int row = rRow->GetRow();
+
+ if( row<1 )
+ rRow->SetRow(m_aRows.size()+1);
+
+ row = rRow->GetRow();
+
+ rRow->SetOwnerTable(this);
+ m_aRows[row] = rRow;
+}
+
+void XFTable::AddHeaderRow(XFRow *pRow)
+{
+ if( !pRow)
+ return;
+ if (!m_aHeaderRows.is())
+ return;
+ m_aHeaderRows->Add(pRow);
+}
+
+OUString XFTable::GetTableName()
+{
+ if( m_bSubTable )
+ {
+ return m_pOwnerCell->GetCellName();
+ }
+ else
+ return m_strName;
+}
+
+sal_uInt16 XFTable::GetRowCount()
+{
+ sal_uInt16 rowMax = 0;
+ for (auto const& row : m_aRows)
+ {
+ if (row.first > rowMax)
+ rowMax = row.first;
+ }
+
+ return rowMax;
+}
+
+XFRow* XFTable::GetRow(sal_Int32 row)
+{
+ return m_aRows[row].get();
+}
+
+sal_Int32 XFTable::GetColumnCount()
+{
+ int colMax = -1;
+ for (auto const& column : m_aColumns)
+ {
+ if( column.first>colMax )
+ colMax = column.first;
+ }
+ return colMax;
+}
+
+enumXFContent XFTable::GetContentType()
+{
+ return enumXFContentTable;
+}
+
+void XFTable::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ //sub table shouldn't use table name.
+ if( !m_bSubTable )
+ pAttrList->AddAttribute( "table:name", m_strName);
+
+ if( !GetStyleName().isEmpty() )
+ pAttrList->AddAttribute( "table:style-name", GetStyleName() );
+
+ if( m_bSubTable )
+ pStrm->StartElement( "table:sub-table" );
+ else
+ pStrm->StartElement( "table:table" );
+
+ //output columns:
+ {
+ int lastCol = 0;
+ for (auto const& column : m_aColumns)
+ {
+ sal_Int32 col = column.first;
+ OUString style = m_aColumns[col];
+
+ //default col repeated:
+ if( col >lastCol+1 )
+ {
+ if( col > lastCol + 2 )
+ {
+ if( !m_strDefColStyle.isEmpty() )
+ {
+ pAttrList->AddAttribute( "table:style-name", m_strDefColStyle );
+ }
+ pAttrList->AddAttribute( "table:number-columns-repeated", OUString::number(col-lastCol-1) );
+ }
+ pStrm->StartElement( "table:table-column" );
+ pStrm->EndElement( "table:table-column" );
+ }
+
+ if( !style.isEmpty() )
+ {
+ pAttrList->AddAttribute( "table:style-name", style );
+ }
+ pStrm->StartElement( "table:table-column" );
+ pStrm->EndElement( "table:table-column" );
+ lastCol = col;
+ }
+ }
+
+ if (m_aHeaderRows.is() && m_aHeaderRows->GetCount()>0)
+ {
+ pStrm->StartElement( "table:table-header-rows" );
+ m_aHeaderRows->ToXml(pStrm);
+ pStrm->EndElement( "table:table-header-rows" );
+ }
+ //output rows:
+ {
+ int lastRow = 0;
+
+ for (auto const& elem : m_aRows)
+ {
+ int row = elem.first;
+ XFRow *pRow = elem.second.get();
+
+ //null row repeated:
+ if( row>lastRow+1 )
+ {
+ XFRow *pNullRow = new XFRow();
+ pNullRow->SetStyleName(m_strDefRowStyle);
+ if( row>lastRow+2)
+ pNullRow->SetRepeated(row-lastRow-1);
+ rtl::Reference<XFCell> xCell(new XFCell);
+ xCell->SetStyleName(m_strDefCellStyle);
+ pNullRow->AddCell(xCell);
+ pNullRow->ToXml(pStrm);
+ }
+ pRow->ToXml(pStrm);
+ lastRow = row;
+ }
+ }
+
+ if( m_bSubTable )
+ pStrm->EndElement( "table:sub-table" );
+ else
+ pStrm->EndElement( "table:table" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftablestyle.cxx b/lotuswordpro/source/filter/xfilter/xftablestyle.cxx
new file mode 100644
index 000000000..cf1229f59
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftablestyle.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Table style.
+ ************************************************************************/
+#include <xfilter/xftablestyle.hxx>
+#include <xfilter/xfbgimage.hxx>
+
+XFTableStyle::XFTableStyle()
+ : m_fWidth(2)
+ , m_eAlign(enumXFAlignStart)
+{}
+
+XFTableStyle::~XFTableStyle()
+{
+}
+
+void XFTableStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
+{
+ m_pBGImage = std::move(rImage);
+}
+
+enumXFStyle XFTableStyle::GetStyleFamily()
+{
+ return enumXFStyleTable;
+}
+
+void XFTableStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pAttrList->AddAttribute( "style:family", "table" );
+ pStrm->StartElement( "style:style" );
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:width", OUString::number(m_fWidth) + "cm" );
+ //text align:
+ if( m_eAlign == enumXFAlignStart )
+ {
+ pAttrList->AddAttribute("table:align","left");
+ }
+ else if( m_eAlign == enumXFAlignCenter )
+ {
+ pAttrList->AddAttribute("table:align","center");
+ }
+ else if( m_eAlign == enumXFAlignEnd )
+ {
+ pAttrList->AddAttribute("table:align","right");
+ }
+ else if( m_eAlign == enumXFALignMargins )
+ {
+ pAttrList->AddAttribute("table:align","margins");
+ }
+ //background color:
+ if( m_aBackColor.IsValid() && !m_pBGImage )
+ pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
+ //shadow:
+ m_aShadow.ToXml(pStrm);
+ //margin:
+ m_aMargins.ToXml(pStrm);
+ //breaks:
+ m_aBreaks.ToXml(pStrm);
+
+ pStrm->StartElement( "style:properties" );
+ if( m_pBGImage )
+ m_pBGImage->ToXml(pStrm);
+
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftabstyle.cxx b/lotuswordpro/source/filter/xfilter/xftabstyle.cxx
new file mode 100644
index 000000000..c86d6420f
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftabstyle.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tab style for paragraph.include tab offset and tab char properties.
+ ************************************************************************/
+#include "xftabstyle.hxx"
+#include <xfilter/ixfattrlist.hxx>
+
+XFTabStyle::XFTabStyle()
+ : m_eType(enumXFTabNone)
+ , m_fLength(0)
+{}
+
+void XFTabStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+
+ pAttrList->AddAttribute( "style:position", OUString::number(m_fLength) + "cm" );
+ switch(m_eType)
+ {
+ case enumXFTabLeft:
+ pAttrList->AddAttribute( "style:type", "left" );
+ break;
+ case enumXFTabCenter:
+ pAttrList->AddAttribute( "style:type", "center" );
+ break;
+ case enumXFTabRight:
+ pAttrList->AddAttribute( "style:type", "right" );
+ break;
+ case enumXFTabChar:
+ pAttrList->AddAttribute( "style:type", "char" );
+ break;
+ default:
+ break;
+ }
+ //delimiter:
+ if( m_eType == enumXFTabChar )
+ pAttrList->AddAttribute( "style:char", m_strDelimiter );
+ //leader char:
+ if( !m_strLeader.isEmpty() )
+ pAttrList->AddAttribute( "style:leader-char", m_strLeader );
+
+ pStrm->StartElement( "style:tab-stop" );
+ pStrm->EndElement( "style:tab-stop" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftabstyle.hxx b/lotuswordpro/source/filter/xfilter/xftabstyle.hxx
new file mode 100644
index 000000000..06304d51c
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftabstyle.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Tab style for paragraph.include tab offset and tab char properties.
+ ************************************************************************/
+#ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFTABSTYLE_HXX
+#define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFTABSTYLE_HXX
+
+#include <xfilter/xfstyle.hxx>
+
+class XFTabStyle : public XFStyle
+{
+public:
+ XFTabStyle();
+
+public:
+ void SetTabType(enumXFTab type);
+
+ void SetLength(double len);
+
+ void SetDelimiter(sal_Unicode delimiter);
+
+ void SetLeaderChar(sal_Unicode leader);
+
+ virtual void ToXml(IXFStream* pStrm) override;
+
+private:
+ enumXFTab m_eType;
+ double m_fLength;
+ OUString m_strDelimiter;
+ OUString m_strLeader;
+};
+
+inline void XFTabStyle::SetTabType(enumXFTab type) { m_eType = type; }
+
+inline void XFTabStyle::SetLength(double len) { m_fLength = len; }
+
+inline void XFTabStyle::SetDelimiter(sal_Unicode delimiter)
+{
+ m_strDelimiter = OUString(delimiter);
+}
+
+inline void XFTabStyle::SetLeaderChar(sal_Unicode leader) { m_strLeader = OUString(leader); }
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftextboxstyle.cxx b/lotuswordpro/source/filter/xfilter/xftextboxstyle.cxx
new file mode 100644
index 000000000..a399f4c33
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftextboxstyle.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xftextboxstyle.hxx>
+
+XFTextBoxStyle::XFTextBoxStyle()
+{
+}
+
+XFTextBoxStyle::~XFTextBoxStyle()
+{
+}
+
+enumXFStyle XFTextBoxStyle::GetStyleFamily()
+{
+ return enumXFStyleGraphics;
+}
+
+void XFTextBoxStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pAttrList->AddAttribute( "style:family", "graphics" );
+ //parent style name ignore now.
+ pStrm->StartElement( "style:style" );
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "draw:stroke", "none" );
+ pAttrList->AddAttribute( "svg:stroke-color", "#000000" );
+ pAttrList->AddAttribute( "draw:fill", "none" );
+ pAttrList->AddAttribute( "draw:fill-color", "#ffffff" );
+ pAttrList->AddAttribute( "draw:auto-grow-height", "true" );
+ pAttrList->AddAttribute( "style:run-through", "foreground" );
+ pAttrList->AddAttribute( "style:wrap", "run-through" );
+ pAttrList->AddAttribute( "style:wrap", "run-through" );
+ pAttrList->AddAttribute( "style:number-wrapped-paragraphs", "no-limit" );
+ pAttrList->AddAttribute( "style:wrap-contour", "false" );
+
+ pStrm->StartElement( "style:properties" );
+ pStrm->EndElement( "style:properties" );
+
+ pStrm->EndElement( "style:style" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftextcontent.cxx b/lotuswordpro/source/filter/xfilter/xftextcontent.cxx
new file mode 100644
index 000000000..945b24114
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftextcontent.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <xfilter/xftextcontent.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+
+XFTextContent::XFTextContent(const OUString& text):m_strText(text)
+{
+}
+
+XFTextContent::~XFTextContent()
+{
+}
+
+enumXFContent XFTextContent::GetContentType()
+{
+ return enumXFContentText;
+}
+
+void XFTextContent::SetText(const OUString& text)
+{
+ m_strText = text;
+}
+
+void XFTextContent::ToXml(IXFStream *pStrm)
+{
+// pStrm->Characters(m_strText);
+ OUString sSubString;
+ sal_Int32 nIndex = 0;
+ sal_Int32 nSize = m_strText.getLength();
+ sal_Int32 i,j;
+ for (i=0; i<nSize;)
+ {
+ sSubString = m_strText.copy(i,nSize-i);
+ nIndex = sSubString.indexOf(" ");
+ if (nIndex == -1)
+ {
+ pStrm->Characters(sSubString);
+ return;
+ }
+ else
+ {
+ if (nIndex != 0)
+ pStrm->Characters(sSubString.copy(0,nIndex));
+ for (j=nIndex+1;j<nSize-i;j++)
+ {
+ if (sSubString[j] != ' ')
+ break;
+ }
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "text:c", OUString::number(j-nIndex) );
+ pStrm->StartElement( "text:s" );
+ pStrm->EndElement( "text:s" );
+
+ i+=j;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftextspan.cxx b/lotuswordpro/source/filter/xfilter/xftextspan.cxx
new file mode 100644
index 000000000..14a6874c2
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftextspan.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * An span of text with style.
+ ************************************************************************/
+#include <xfilter/xftextspan.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/xftextcontent.hxx>
+
+XFTextSpan::XFTextSpan()
+{
+
+}
+
+XFTextSpan::XFTextSpan(const OUString& text,
+ const OUString& style
+ )
+{
+ Add(text);
+ SetStyleName(style);
+}
+
+XFTextSpan::~XFTextSpan()
+{
+}
+
+enumXFContent XFTextSpan::GetContentType()
+{
+ return enumXFContentSpan;
+}
+
+void XFTextSpan::Add(XFContent *pContent)
+{
+ m_aContents.emplace_back(pContent);
+}
+
+void XFTextSpan::Add(const OUString& text)
+{
+ XFContent *pText = new XFTextContent(text);
+ Add(pText);
+}
+
+void XFTextSpan::ToXml(IXFStream *pStrm)
+{
+ OUString style = GetStyleName();
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ assert(pAttrList);
+
+ pAttrList->Clear();
+ if( !style.isEmpty() )
+ pAttrList->AddAttribute( "text:style-name", GetStyleName() );
+ pStrm->StartElement( "text:span" );
+
+ for (auto const& content : m_aContents)
+ {
+ XFContent *pContent = content.get();
+ if( pContent )
+ pContent->DoToXml(pStrm);
+ }
+
+ pStrm->EndElement( "text:span" );
+}
+
+void XFTextSpanStart::ToXml(IXFStream *pStrm)
+{
+ OUString style = GetStyleName();
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ assert(pAttrList);
+
+ pAttrList->Clear();
+ if( !style.isEmpty() )
+ pAttrList->AddAttribute( "text:style-name", GetStyleName() );
+ pStrm->StartElement( "text:span" );
+
+ for (auto const& content : m_aContents)
+ {
+ XFContent *pContent = content.get();
+ if( pContent )
+ pContent->DoToXml(pStrm);
+ }
+}
+void XFTextSpanEnd::ToXml(IXFStream *pStrm)
+{
+ for (auto const& content : m_aContents)
+ {
+ XFContent *pContent = content.get();
+ if( pContent )
+ pContent->DoToXml(pStrm);
+ }
+ pStrm->EndElement( "text:span" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftextstyle.cxx b/lotuswordpro/source/filter/xfilter/xftextstyle.cxx
new file mode 100644
index 000000000..e70603ab2
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftextstyle.cxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Style for <text:p> or <text:h> or <text:span>
+ * Now we have only font attributes.
+ ************************************************************************/
+#include <xfilter/xftextstyle.hxx>
+#include <xfilter/ixfattrlist.hxx>
+#include <xfilter/ixfstream.hxx>
+#include <xfilter/xffont.hxx>
+
+XFTextStyle::XFTextStyle() {}
+
+XFTextStyle::~XFTextStyle() {}
+
+void XFTextStyle::SetFont(rtl::Reference<XFFont> const& font) { m_pFont = font; }
+
+bool XFTextStyle::Equal(IXFStyle* pStyle)
+{
+ if (!pStyle || pStyle->GetStyleFamily() != enumXFStyleText)
+ {
+ return false;
+ }
+
+ XFTextStyle* pOther = dynamic_cast<XFTextStyle*>(pStyle);
+ if (!pOther)
+ {
+ return false;
+ }
+
+ if (m_pFont.is())
+ {
+ if (!pOther->m_pFont.is())
+ return false;
+ if (*m_pFont != *pOther->m_pFont)
+ return false;
+ }
+ else if (pOther->m_pFont.is())
+ return false;
+
+ return true;
+}
+
+enumXFStyle XFTextStyle::GetStyleFamily() { return enumXFStyleText; }
+
+void XFTextStyle::ToXml(IXFStream* strm)
+{
+ IXFAttrList* pAttrList = strm->GetAttrList();
+ OUString style = GetStyleName();
+
+ pAttrList->Clear();
+ if (!style.isEmpty())
+ pAttrList->AddAttribute("style:name", GetStyleName());
+ if (!GetParentStyleName().isEmpty())
+ pAttrList->AddAttribute("style:parent-style-name", GetParentStyleName());
+
+ pAttrList->AddAttribute("style:family", "text");
+ strm->StartElement("style:style");
+
+ //Font properties:
+ pAttrList->Clear();
+ //font name:
+ if (m_pFont.is())
+ m_pFont->ToXml(strm);
+
+ strm->StartElement("style:properties");
+ strm->EndElement("style:properties");
+
+ strm->EndElement("style:style");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xftimestyle.cxx b/lotuswordpro/source/filter/xfilter/xftimestyle.cxx
new file mode 100644
index 000000000..95a8e7acb
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xftimestyle.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Time style. The Time format for time field.
+ ************************************************************************/
+
+#include <xfilter/xftimestyle.hxx>
+#include <xfilter/ixfattrlist.hxx>
+
+XFTimePart::XFTimePart()
+{
+ m_nDecimalPos = 0;
+}
+
+void XFTimePart::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ switch(m_ePart)
+ {
+ case enumXFDateHour:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:hours" );
+ pStrm->EndElement( "number:hours" );
+ break;
+ case enumXFDateMinute:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ if( m_nDecimalPos>0 )
+ pAttrList->AddAttribute( "number:decimal-places", OUString::number(m_nDecimalPos) );
+
+ pStrm->StartElement( "number:minutes" );
+ pStrm->EndElement( "number:minutes" );
+ break;
+ case enumXFDateSecond:
+ pAttrList->Clear();
+ if( m_bLongFmt )
+ pAttrList->AddAttribute( "number:style", "long" );
+ pStrm->StartElement( "number:seconds" );
+ pStrm->EndElement( "number:seconds" );
+ break;
+ case enumXFDateText:
+ pAttrList->Clear();
+ pStrm->StartElement( "number:text" );
+ pStrm->Characters( m_strText );
+ pStrm->EndElement( "number:text" );
+ break;
+ default:
+ break;
+ }
+}
+
+XFTimeStyle::XFTimeStyle()
+{
+ m_bAmPm = false;
+ m_bTruncate = true;
+}
+
+XFTimeStyle::~XFTimeStyle()
+{
+}
+
+enumXFStyle XFTimeStyle::GetStyleFamily()
+{
+ return enumXFStyleTime;
+}
+
+void XFTimeStyle::ToXml(IXFStream *pStrm)
+{
+ IXFAttrList *pAttrList = pStrm->GetAttrList();
+
+ pAttrList->Clear();
+ pAttrList->AddAttribute( "style:name", GetStyleName() );
+ if( !GetParentStyleName().isEmpty() )
+ pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
+ pAttrList->AddAttribute( "style:family", "data-style" );
+ if (!m_bTruncate)
+ pAttrList->AddAttribute( "number:truncate-on-overflow", "false" );
+ pStrm->StartElement( "number:time-style" );
+
+ for (auto & part : m_aParts)
+ {
+ part.ToXml(pStrm);
+ }
+ if( m_bAmPm )
+ {
+ pAttrList->Clear();
+ pStrm->StartElement( "number:am-pm" );
+ pStrm->EndElement( "number:am-pm" );
+ }
+ pStrm->EndElement( "number:time-style" );
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfutil.cxx b/lotuswordpro/source/filter/xfilter/xfutil.cxx
new file mode 100644
index 000000000..dd212b21a
--- /dev/null
+++ b/lotuswordpro/source/filter/xfilter/xfutil.cxx
@@ -0,0 +1,391 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: IBM Corporation
+ *
+ * Copyright: 2008 by IBM Corporation
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+/*************************************************************************
+ * @file
+ * Util functions for xml filter.
+ ************************************************************************/
+#include <xfilter/xfutil.hxx>
+
+OUString GetTableColName(sal_Int32 col)
+{
+ int remain = 0;
+ char ch;
+ std::string strOut;
+
+ if( col <= 26 )
+ {
+ ch = 'A' + col -1;
+ strOut += ch;
+ return OUString::createFromAscii(strOut.c_str());
+ }
+
+ while( col>26 )
+ {
+ remain = col%26;
+ col = col/26;
+ ch = 'A' + remain -1;
+ strOut += ch;
+ }
+
+ ch = 'A' + remain -1;
+ strOut += ch;
+ return OUString::createFromAscii(strOut.c_str());
+}
+
+//tool functions:
+OUString GetUnderlineName(enumXFUnderline type)
+{
+ switch(type)
+ {
+ case enumXFUnderlineNone:
+ return "none";
+ case enumXFUnderlineSingle:
+ return "single";
+ case enumXFUnderlineDouble:
+ return "double";
+ case enumXFUnderlineDotted:
+ return "dotted";
+ case enumXFUnderlineDash:
+ return "dash";
+ case enumXFUnderlineLongDash:
+ return "long-dash";
+ case enumXFUnderlineDotDash:
+ return "dot-dash";
+ case enumXFUnderlineDotDotDash:
+ return "dot-dot-dash";
+ case enumXFUnderlineWave:
+ return "wave";
+ case enumXFUnderlineBold:
+ return "bold";
+ case enumXFUnderlineBoldDotted:
+ return "bold-dotted";
+ case enumXFUnderlineBoldDash:
+ return "bold-dash";
+ case enumXFUnderlineBoldLongDash:
+ return "bold-long-dash";
+ case enumXFUnderlineBoldDotDash:
+ return "bold-dot-dash";
+ case enumXFUnderlineBoldDotDotDash:
+ return "bold-dot-dot-dash";
+ case enumXFUnderlineBoldWave:
+ return "bold-wave";
+ case enumXFUnderlineDoubleWave:
+ return "double-wave";
+ case enumXFUnderlineSmallWave:
+ return "small-wave";
+ }
+ return OUString();
+}
+
+OUString GetCrossoutName(enumXFCrossout type)
+{
+ switch(type)
+ {
+ case enumXFCrossoutSignel:
+ return "single-line";
+ case enumXFCrossoutDouble:
+ return "double-line";
+ case enumXFCrossoutThick:
+ return "thick-line";
+ case enumXFCrossoutSlash:
+ return "slash";
+ case enumXFCrossoutX:
+ return "X";
+ default:
+ break;
+ }
+ return OUString();
+}
+
+OUString GetTransformName(enumXFTransform type)
+{
+ switch(type) {
+ case enumXFTransformUpper:
+ return "uppercase";
+ case enumXFTransformLower:
+ return "lowercase";
+ case enumXFTransformCapitalize:
+ return "capitalize";
+ case enumXFTransformSmallCaps:
+ return "small-caps";
+ default:
+ break;
+ }
+ return OUString();
+}
+
+OUString GetTextDirName(enumXFTextDir dir)
+{
+ switch(dir)
+ {
+ case enumXFTextDirLR:
+ return "lr";
+ case enumXFTextDirLR_TB:
+ return "lr-tb";
+ case enumXFTextDirPage:
+ return "page";
+ case enumXFTextDirRL:
+ return "rl";
+ case enumXFTextDirRL_TB:
+ return "rl-tb";
+ case enumXFTextDirTB:
+ return "tb";
+ case enumXFTextDirTB_LR:
+ return "tb-lr";
+ case enumXFTextDirTB_RL:
+ return "tb-rl";
+ default:
+ break;
+ }
+ return OUString();
+}
+
+OUString GetFrameXPos(enumXFFrameXPos pos)
+{
+ switch(pos)
+ {
+ case enumXFFrameXPosLeft:
+ return "left";
+ case enumXFFrameXPosRight:
+ return "right";
+ case enumXFFrameXPosCenter:
+ return "center";
+ case enumXFFrameXPosFromLeft:
+ return "from-left";
+ default:
+ break;
+ }
+ return OUString();
+}
+
+OUString GetFrameXRel(enumXFFrameXRel rel)
+{
+ switch(rel)
+ {
+ case enumXFFrameXRelPage:
+ return "page";
+ case enumXFFrameXRelPageContent:
+ return "page-content";
+ case enumXFFrameXRelPageEndMargin:
+ return "page-end-margin";
+ case enumXFFrameXRelPageStartMargin:
+ return "page-start-margin";
+ case enumXFFrameXRelPara:
+ return "paragraph";
+ case enumXFFrameXRelParaContent:
+ return "paragraph-content";
+ case enumXFFrameXRelParaEndMargin:
+ return "paragraph-end-margin";
+ case enumXFFrameXRelParaStartMargin:
+ return "paragraph-start-margin";
+ case enumXFFrameXRelChar:
+ return "char";
+ case enumXFFrameXRelFrame:
+ return "frame";
+ case enumXFFrameXRelFrameContent:
+ return "frame-content";
+ case enumXFFrameXRelFrameEndMargin:
+ return "frame-end-margin";
+ case enumXFFrameXRelFrameStartMargin:
+ return "frame-start-margin";
+ default:
+ break;
+ }
+ return OUString();
+}
+
+OUString GetFrameYPos(enumXFFrameYPos pos)
+{
+ switch(pos)
+ {
+ case enumXFFrameYPosTop:
+ return "top";
+ case enumXFFrameYPosMiddle:
+ return "middle";
+ case enumXFFrameYPosBottom:
+ return "bottom";
+ case enumXFFrameYPosFromTop:
+ return "from-top";
+ case enumXFFrameYPosBelow:
+ return "below";
+ }
+ return OUString();
+}
+
+OUString GetFrameYRel(enumXFFrameYRel rel)
+{
+ switch(rel)
+ {
+ case enumXFFrameYRelBaseLine:
+ return "baseline";
+ case enumXFFrameYRelChar:
+ return "char";
+ case enumXFFrameYRelFrame:
+ return "frame";
+ case enumXFFrameYRelFrameContent:
+ return "frame-content";
+ case enumXFFrameYRelLine:
+ return "line";
+ case enumXFFrameYRelPage:
+ return "page";
+ case enumXFFrameYRelPageContent:
+ return "page-content";
+ case enumXFFrameYRelPara:
+ return "paragraph";
+ case enumXFFrameYRelParaContent:
+ return "paragraph-content";
+ case enumXFFrameYRelText:
+ return "text";
+ }
+ return OUString();
+}
+
+OUString GetAlignName(enumXFAlignType align)
+{
+ if( align == enumXFAlignStart )
+ return "start";
+ else if( align == enumXFAlignCenter )
+ return "center";
+ else if( align == enumXFAlignEnd )
+ return "end";
+ else if( align == enumXFAlignJustify )
+ return "justify";
+ else if( align == enumXFAlignBottom )
+ return "bottom";
+ else if( align == enumXFAlignTop )
+ return "top";
+ else if( align == enumXFAlignMiddle )
+ return "middle";
+ else if( align == enumXFALignMargins )
+ return "margins";
+
+ return OUString();
+}
+
+OUString GetPageUsageName(enumXFPageUsage usage)
+{
+ OUString sRet;
+ switch(usage)
+ {
+ case enumXFPageUsageAll:
+ sRet = "all";
+ break;
+ case enumXFPageUsageLeft:
+ sRet = "left";
+ break;
+ case enumXFPageUsageRight:
+ sRet = "right";
+ break;
+ case enumXFPageUsageMirror:
+ sRet = "mirrored";
+ break;
+ default:
+ sRet = "mirrored";
+ break;
+ }
+ return sRet;
+}
+
+OUString GetValueType(enumXFValueType type)
+{
+ OUString sRet;
+ switch(type)
+ {
+ case enumXFValueTypeBoolean:
+ sRet = "boolean";
+ break;
+ case enumXFValueTypeCurrency:
+ sRet = "currency";
+ break;
+ case enumXFValueTypeDate:
+ sRet = "date";
+ break;
+ case enumXFValueTypeFloat:
+ sRet = "float";
+ break;
+ case enumXFValueTypePercentage:
+ sRet = "percentage";
+ break;
+ case enumXFValueTypeString:
+ sRet = "string";
+ break;
+ case enumXFValueTypeTime:
+ sRet = "time";
+ break;
+ default:
+ sRet = "mirrored";
+ break;
+ }
+ return sRet;
+}
+
+OUString GetColorMode(enumXFColorMode mode)
+{
+ switch(mode)
+ {
+ case enumXFColorStandard:
+ return "standard";
+ case enumXFColorGreyscale:
+ return "greyscale";
+ case enumXFColorWatermark:
+ return "watermark";
+ case enumXFColorMono:
+ return "mono";
+ }
+ return OUString();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */