summaryrefslogtreecommitdiff
path: root/lotuswordpro/source/filter/lwpframelayout.cxx
blob: 45cd52861f3fda38eac3724bffd914b02e1253d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
/* -*- 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
 ************************************************************************/
/*************************************************************************
 * Change History
Mar 2005            Created
 ************************************************************************/
#include "lwpframelayout.hxx"
#include "lwppara.hxx"
#include "xfilter/xfstylemanager.hxx"
#include "xfilter/xfparagraph.hxx"
#include "xfilter/xffloatframe.hxx"
#include "xfilter/xfrubystyle.hxx"
#include "lwppagelayout.hxx"
#include "lwpoleobject.hxx"
#include "lwptablelayout.hxx"
#include "lwpgrfobj.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(XFFrameStyle* pFrameStyle)
{
    ApplyWrapType(pFrameStyle);
    ApplyMargins(pFrameStyle);
    ApplyPadding(pFrameStyle);
    ApplyBorders(pFrameStyle);
    ApplyColumns(pFrameStyle);
    ApplyShadow(pFrameStyle);
    ApplyBackGround(pFrameStyle);
    ApplyWatermark(pFrameStyle);
//  ApplyBackColor(pFrameStyle);
    ApplyProtect(pFrameStyle);
    ApplyTextDir(pFrameStyle);
    ApplyPosType(pFrameStyle);

    pFrameStyle->SetStyleName(m_pLayout->GetName().str());
    XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    m_StyleName = pXFStyleManager->AddStyle(pFrameStyle).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
    LwpVirtualLayout* pParent = m_pLayout->GetParentLayout();
    if (!pParent)
        throw std::runtime_error("missing Parent Layout");
    if(pParent->IsPage()&& pParent->GetParentLayout()->IsPage())
    {
        //for mirror page, problems exist if the parent layout is header or footer layout,
        pParent = pParent->GetParentLayout();
    }
    if(m_pLayout->IsAnchorPage()&& pParent->IsPage())
    {
        //get parent layout
        if(m_pLayout->IsUseOnPage())
        {
            sal_Int32 nPageNo = pParent->GetPageNumber(m_pLayout->GetUsePage());
            if(nPageNo>0)
                m_pLayout->XFConvertFrame(pCont, nPageNo);
        }
        else if(m_pLayout->IsUseOnAllPages())
        {
            sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO);
            sal_Int32 nLast = pParent->GetPageNumber(LAST_LAYOUTPAGENO);
            if(nLast > 0)
                m_pLayout->XFConvertFrame(pCont, nFirst, nLast, true);

        }
        else if(m_pLayout->IsUseOnAllOddPages()||m_pLayout->IsUseOnAllEvenPages())
        {
            sal_Int32 nFirst = pParent->GetPageNumber(FIRST_LAYOUTPAGENO);
            sal_Int32 nLast = pParent->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, false);
                }
            }
        }
    }
    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;
            LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
            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())
            {
                //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)
{
    XFBorders* pBordres = m_pLayout->GetXFBorders();
    if(pBordres)
    {
        pFrameStyle->SetBorders(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->IsProtected())
    {
        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
            {
                LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
                if(pContainer && (pContainer->IsHeader() || pContainer->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;
            eYPos = enumXFFrameYPosBelow;   //below
            eYRel = enumXFFrameYRelChar; //from char
            //set vertical position
            LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
            if(pContainer && pContainer->IsPage())//in page
            {
                //eYPos = enumXFFrameYPosFromTop;
                //eYRel = enumXFFrameYRelPage;
                eYPos = enumXFFrameYPosBelow;
                eYRel = enumXFFrameYRelChar;
            }
            else if(pContainer && pContainer->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)
{
    XFBGImage* pBGImage = m_pLayout->GetXFBGImage();
    if(pBGImage)
    {
        pFrameStyle->SetBackImage(pBGImage);
        //set watermark transparent
         LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*>(m_pLayout->GetWaterMarkLayout());
         LwpBackgroundStuff* pBackgroundStuff = pLay->GetBackgroundStuff();
         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)
{
    XFBGImage* pXFBGImage = m_pLayout->GetFillPattern();
    if (pXFBGImage)
    {
        pFrameStyle->SetBackImage(pXFBGImage);
    }
}

/**
 * @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;
    //page number
    sal_uInt16 nPageNum = 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
            {
                LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
                if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))
                {
                    eAnchor = enumXFAnchorPara;
                    fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
                }
                else
                    eAnchor = enumXFAnchorPage;
            }
            if(m_pLayout->IsAnchorFrame()) //in frame
            {
                eAnchor = enumXFAnchorFrame;
            }
            if(m_pLayout->IsAnchorCell())   //in cell
            {
                //eAnchor = enumXFAnchorChar;
                eAnchor = enumXFAnchorPara;
                LwpMiddleLayout* pContainer = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
                if(pContainer)
                {
                    fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
                }
            }
            break;
        }
        case LwpLayoutRelativityGuts::LAY_PARA_RELATIVE:    //same page as text
        {
            eAnchor = enumXFAnchorChar;
            LwpVirtualLayout* pContainer = m_pLayout->GetContainerLayout();
            if(pContainer && pContainer->IsPage())//in page
            {
                //eAnchor = enumXFAnchorPage;
                eAnchor = enumXFAnchorChar;// to character
            }
            else if(pContainer && pContainer->IsFrame()) //in frame
            {
                eAnchor = enumXFAnchorFrame;
            }
            else if(pContainer && pContainer->IsCell()) //in cell
            {
                //eAnchor = enumXFAnchorChar;
                eAnchor = enumXFAnchorPara;
                fYOffset -= pContainer->GetMarginsValue(MARGIN_TOP);
            }
            else if(pContainer && (pContainer->IsHeader() || pContainer->IsFooter()))//in header or footer
            {
                eAnchor = enumXFAnchorPara;
                fYOffset -= pContainer->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.
            //LwpPara* pPara = static_cast<LwpPara*>(m_pLayout->GetPosition()->obj());
            rtl::Reference<XFFont> pFont = m_pLayout->GetFont();
            if(pFont.is())
            {
                offset = (double)(pFont->GetFontSize())*CM_PER_INCH/POINTS_PER_INCH;
            }
            fYOffset = offset-fYOffset;
            break;
        }
        default:
            break;
    }

    pXFFrame->SetX(fXOffset);
    pXFFrame->SetY(fYOffset);
    pXFFrame->SetAnchorPage(nPageNum);
    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()
{
    //LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(m_pLayout->GetContainerLayout());
    LwpVirtualLayout* pParent = static_cast<LwpVirtualLayout*>(m_pLayout->GetContainerLayout());
    if(pParent)
    {
        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()
{}

LwpFrameLink::~LwpFrameLink()
{}

/**
 * @descr frame link information
 *
 */
void LwpFrameLink::Read(LwpObjectStream* pStrm)
{
    m_PreviousLayout.ReadIndexed(pStrm);
    m_NextLayout.ReadIndexed(pStrm);
    pStrm->SkipExtra();
}

LwpFrameLayout::LwpFrameLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
    : LwpPlacableLayout(objHdr, pStrm), m_pFrame(NULL)
{
}

LwpFrameLayout::~LwpFrameLayout()
{
    delete m_pFrame;
}

/**
 * @descr read frame layout object
 *
 */
void LwpFrameLayout::Read()
{
    LwpPlacableLayout::Read();
    if(LwpFileHeader::m_nFileRevision >= 0x000B)
    {
        if(m_pObjStrm->QuickReaduInt16())
        {
            m_Link.Read(m_pObjStrm);
        }
    }
    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)
    {
        //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)
    {
        XFFrame* pXFFrame = NULL;
        if(nEnd < nStart)
        {
            pXFFrame = new XFFrame();
        }
        else
        {
            pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
        }

        m_pFrame->Parse(pXFFrame, nStart);
        //if it is a link frame, parse contents only once
        if(!HasPreviousLinkLayout())
        {
            rtl::Reference<LwpObject> content = m_Content.obj();
            if (content.is())
            {
                content->XFConvert(pXFFrame);
                //set frame size according to ole size
                ApplyGraphicSize(pXFFrame);
            }
        }
        pCont ->Add(pXFFrame);
    }
}
/**
 * @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
    XFFrameStyle* pFrameStyle = new XFFrameStyle();
    m_pFrame = new LwpFrame(this);
    m_pFrame->RegisterStyle(pFrameStyle);

    //register content style
    rtl::Reference<LwpObject> content = m_Content.obj();
    if (content.is())
    {
        content->SetFoundry(m_pFoundry);
        content->RegisterStyle();
    }

    //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 confict
            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();
    if(rObjectID.IsNull())
        return false;
    return true;
}
/**
 * @descr whether current frame is for water mark. Problem maybe exsits by this method, must be tracking
 *
 */
bool LwpFrameLayout::IsForWaterMark()
{
    if(m_nBuoyancy >=LAY_BUOYLAYER)
    {
        if(!m_Content.IsNull() && (m_Content.obj()->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()
{
    double fActualWidth = 0;
    LwpMiddleLayout* pParent = static_cast<LwpMiddleLayout*>(GetContainerLayout());
    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;
    }

    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 ))
    {
        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 &objHdr, LwpSvStream* pStrm)
    : LwpPlacableLayout(objHdr, pStrm)
    , m_pFrame(NULL)
{

}

LwpGroupLayout::~LwpGroupLayout()
{
    delete m_pFrame;
}
/**
 * @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
    XFFrameStyle* pFrameStyle = new XFFrameStyle();
    m_pFrame = new LwpFrame(this);
    m_pFrame->RegisterStyle(pFrameStyle);

    //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)
    {
        //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)
    {
        XFFrame* pXFFrame = NULL;
        if(nEnd < nStart)
        {
            pXFFrame = new XFFrame();
        }
        else
        {
            pXFFrame = new XFFloatFrame(nStart, nEnd, bAll);
        }

        m_pFrame->Parse(pXFFrame, nStart);

        //add child frame into group
        LwpVirtualLayout* pLayout = static_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
        while(pLayout)
        {
            pLayout->XFConvert(pXFFrame);
            pLayout = static_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
        }

        pCont ->Add(pXFFrame);
    }
}

LwpGroupFrame::LwpGroupFrame(LwpObjectHeader &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 &objHdr, LwpSvStream* pStrm)
    : LwpFrameLayout(objHdr, pStrm)
{
    m_nChars = 1;
    m_nLines = 3;
}

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->Parse(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);
    }
}

LwpStory* LwpDropcapLayout::GetContentStory()
{
    return static_cast<LwpStory*>(m_Content.obj(VO_STORY).get());
}

void LwpDropcapLayout::RegisterStyle(LwpFoundry* pFoundry)
{
    LwpStory* pStory = GetContentStory();
    if (pStory)
    {
        pStory->SetDropcapFlag(true);
        pStory->SetFoundry(pFoundry);
        LwpPara* pPara = static_cast<LwpPara*>(pStory->GetFirstPara().obj().get());
        while(pPara)
        {
            pPara->SetFoundry(pFoundry);
            pPara->RegisterStyle();
            pPara = static_cast<LwpPara*>(pPara->GetNext().obj().get());
        }
    }
}

/**
 * @descr  do nothing
 *
 */
void LwpDropcapLayout::RegisterStyle()
{
}

LwpRubyLayout::LwpRubyLayout(LwpObjectHeader &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);
    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");

    XFRubyStyle* pRubyStyle = 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;
    }
    pRubyStyle->SetAlignment(eType);

    eType = enumXFRubyTop;
    if (m_nPlacement == TOP)
    {
        eType = enumXFRubyTop;
    }
    else if(m_nPlacement == BOTTOM)
    {
        eType =  enumXFRubyBottom;
    }
    pRubyStyle->SetPosition(eType);

    XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
    OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle).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: */