1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PageMasterImportPropMapper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
35 #include "PageMasterImportPropMapper.hxx"
36 #ifndef _XMLOFF_PAGEMASTERPROPMAPPER_HXX
37 #include "PageMasterPropMapper.hxx"
39 #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
40 #include <xmloff/PageMasterStyleMap.hxx>
42 #include <xmloff/maptype.hxx>
43 #include <com/sun/star/table/BorderLine.hpp>
44 #include <com/sun/star/container/XNameContainer.hpp>
45 #include <xmloff/xmlimp.hxx>
47 #define XML_LINE_LEFT 0
48 #define XML_LINE_RIGHT 1
49 #define XML_LINE_TOP 2
50 #define XML_LINE_BOTTOM 3
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::uno
;
54 using namespace ::com::sun::star::container
;
56 PageMasterImportPropertyMapper::PageMasterImportPropertyMapper(
57 const UniReference
< XMLPropertySetMapper
>& rMapper
,
59 SvXMLImportPropertyMapper( rMapper
, rImp
),
64 PageMasterImportPropertyMapper::~PageMasterImportPropertyMapper()
68 sal_Bool
PageMasterImportPropertyMapper::handleSpecialItem(
69 XMLPropertyState
& rProperty
,
70 ::std::vector
< XMLPropertyState
>& rProperties
,
71 const ::rtl::OUString
& rValue
,
72 const SvXMLUnitConverter
& rUnitConverter
,
73 const SvXMLNamespaceMap
& rNamespaceMap
) const
75 sal_Bool bRet
= sal_False
;
76 sal_Int16 nContextID
=
77 getPropertySetMapper()->GetEntryContextId(rProperty
.mnIndex
);
79 if( CTF_PM_REGISTER_STYLE
==nContextID
)
81 ::rtl::OUString
sDisplayName( rImport
.GetStyleDisplayName(
82 XML_STYLE_FAMILY_TEXT_PARAGRAPH
, rValue
) );
83 Reference
< XNameContainer
> xParaStyles
=
84 rImport
.GetTextImport()->GetParaStyles();
85 if( xParaStyles
.is() && xParaStyles
->hasByName( sDisplayName
) )
87 rProperty
.maValue
<<= sDisplayName
;
93 bRet
= SvXMLImportPropertyMapper::handleSpecialItem(
94 rProperty
, rProperties
, rValue
,
95 rUnitConverter
, rNamespaceMap
);
102 void PageMasterImportPropertyMapper::finished(::std::vector
< XMLPropertyState
>& rProperties
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const
104 SvXMLImportPropertyMapper::finished(rProperties
, nStartIndex
, nEndIndex
);
105 XMLPropertyState
* pAllPaddingProperty
= NULL
;
106 XMLPropertyState
* pPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
107 XMLPropertyState
* pNewPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
108 XMLPropertyState
* pAllBorderProperty
= NULL
;
109 XMLPropertyState
* pBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
110 XMLPropertyState
* pNewBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
111 XMLPropertyState
* pAllBorderWidthProperty
= NULL
;
112 XMLPropertyState
* pBorderWidths
[4] = { NULL
, NULL
, NULL
, NULL
};
113 XMLPropertyState
* pAllHeaderPaddingProperty
= NULL
;
114 XMLPropertyState
* pHeaderPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
115 XMLPropertyState
* pHeaderNewPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
116 XMLPropertyState
* pAllHeaderBorderProperty
= NULL
;
117 XMLPropertyState
* pHeaderBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
118 XMLPropertyState
* pHeaderNewBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
119 XMLPropertyState
* pAllHeaderBorderWidthProperty
= NULL
;
120 XMLPropertyState
* pHeaderBorderWidths
[4] = { NULL
, NULL
, NULL
, NULL
};
121 XMLPropertyState
* pAllFooterPaddingProperty
= NULL
;
122 XMLPropertyState
* pFooterPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
123 XMLPropertyState
* pFooterNewPadding
[4] = { NULL
, NULL
, NULL
, NULL
};
124 XMLPropertyState
* pAllFooterBorderProperty
= NULL
;
125 XMLPropertyState
* pFooterBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
126 XMLPropertyState
* pFooterNewBorders
[4] = { NULL
, NULL
, NULL
, NULL
};
127 XMLPropertyState
* pAllFooterBorderWidthProperty
= NULL
;
128 XMLPropertyState
* pFooterBorderWidths
[4] = { NULL
, NULL
, NULL
, NULL
};
129 XMLPropertyState
* pHeaderHeight
= NULL
;
130 XMLPropertyState
* pHeaderMinHeight
= NULL
;
131 XMLPropertyState
* pHeaderDynamic
= NULL
;
132 XMLPropertyState
* pFooterHeight
= NULL
;
133 XMLPropertyState
* pFooterMinHeight
= NULL
;
134 XMLPropertyState
* pFooterDynamic
= NULL
;
135 sal_uInt16 i
; // for the "for" loop
137 ::std::vector
< XMLPropertyState
>::iterator aEnd
= rProperties
.end();
138 for (::std::vector
< XMLPropertyState
>::iterator aIter
= rProperties
.begin(); aIter
!= aEnd
; ++aIter
)
140 XMLPropertyState
*property
= &(*aIter
);
141 sal_Int16 nContextID
= getPropertySetMapper()->GetEntryContextId(property
->mnIndex
);
142 if (property
->mnIndex
>= nStartIndex
&& property
->mnIndex
< nEndIndex
)
146 case CTF_PM_PADDINGALL
: pAllPaddingProperty
= property
; break;
147 case CTF_PM_PADDINGLEFT
: pPadding
[XML_LINE_LEFT
] = property
; break;
148 case CTF_PM_PADDINGRIGHT
: pPadding
[XML_LINE_RIGHT
] = property
; break;
149 case CTF_PM_PADDINGTOP
: pPadding
[XML_LINE_TOP
] = property
; break;
150 case CTF_PM_PADDINGBOTTOM
: pPadding
[XML_LINE_BOTTOM
] = property
; break;
151 case CTF_PM_BORDERALL
: pAllBorderProperty
= property
; break;
152 case CTF_PM_BORDERLEFT
: pBorders
[XML_LINE_LEFT
] = property
; break;
153 case CTF_PM_BORDERRIGHT
: pBorders
[XML_LINE_RIGHT
] = property
; break;
154 case CTF_PM_BORDERTOP
: pBorders
[XML_LINE_TOP
] = property
; break;
155 case CTF_PM_BORDERBOTTOM
: pBorders
[XML_LINE_BOTTOM
] = property
; break;
156 case CTF_PM_BORDERWIDTHALL
: pAllBorderWidthProperty
= property
; break;
157 case CTF_PM_BORDERWIDTHLEFT
: pBorderWidths
[XML_LINE_LEFT
] = property
; break;
158 case CTF_PM_BORDERWIDTHRIGHT
: pBorderWidths
[XML_LINE_RIGHT
] = property
; break;
159 case CTF_PM_BORDERWIDTHTOP
: pBorderWidths
[XML_LINE_TOP
] = property
; break;
160 case CTF_PM_BORDERWIDTHBOTTOM
: pBorderWidths
[XML_LINE_BOTTOM
] = property
; break;
161 case CTF_PM_HEADERPADDINGALL
: pAllHeaderPaddingProperty
= property
; break;
162 case CTF_PM_HEADERPADDINGLEFT
: pHeaderPadding
[XML_LINE_LEFT
] = property
; break;
163 case CTF_PM_HEADERPADDINGRIGHT
: pHeaderPadding
[XML_LINE_RIGHT
] = property
; break;
164 case CTF_PM_HEADERPADDINGTOP
: pHeaderPadding
[XML_LINE_TOP
] = property
; break;
165 case CTF_PM_HEADERPADDINGBOTTOM
: pHeaderPadding
[XML_LINE_BOTTOM
] = property
; break;
166 case CTF_PM_HEADERBORDERALL
: pAllHeaderBorderProperty
= property
; break;
167 case CTF_PM_HEADERBORDERLEFT
: pHeaderBorders
[XML_LINE_LEFT
] = property
; break;
168 case CTF_PM_HEADERBORDERRIGHT
: pHeaderBorders
[XML_LINE_RIGHT
] = property
; break;
169 case CTF_PM_HEADERBORDERTOP
: pHeaderBorders
[XML_LINE_TOP
] = property
; break;
170 case CTF_PM_HEADERBORDERBOTTOM
: pHeaderBorders
[XML_LINE_BOTTOM
] = property
; break;
171 case CTF_PM_HEADERBORDERWIDTHALL
: pAllHeaderBorderWidthProperty
= property
; break;
172 case CTF_PM_HEADERBORDERWIDTHLEFT
: pHeaderBorderWidths
[XML_LINE_LEFT
] = property
; break;
173 case CTF_PM_HEADERBORDERWIDTHRIGHT
: pHeaderBorderWidths
[XML_LINE_RIGHT
] = property
; break;
174 case CTF_PM_HEADERBORDERWIDTHTOP
: pHeaderBorderWidths
[XML_LINE_TOP
] = property
; break;
175 case CTF_PM_HEADERBORDERWIDTHBOTTOM
: pHeaderBorderWidths
[XML_LINE_BOTTOM
] = property
; break;
176 case CTF_PM_FOOTERPADDINGALL
: pAllFooterPaddingProperty
= property
; break;
177 case CTF_PM_FOOTERPADDINGLEFT
: pFooterPadding
[XML_LINE_LEFT
] = property
; break;
178 case CTF_PM_FOOTERPADDINGRIGHT
: pFooterPadding
[XML_LINE_RIGHT
] = property
; break;
179 case CTF_PM_FOOTERPADDINGTOP
: pFooterPadding
[XML_LINE_TOP
] = property
; break;
180 case CTF_PM_FOOTERPADDINGBOTTOM
: pFooterPadding
[XML_LINE_BOTTOM
] = property
; break;
181 case CTF_PM_FOOTERBORDERALL
: pAllFooterBorderProperty
= property
; break;
182 case CTF_PM_FOOTERBORDERLEFT
: pFooterBorders
[XML_LINE_LEFT
] = property
; break;
183 case CTF_PM_FOOTERBORDERRIGHT
: pFooterBorders
[XML_LINE_RIGHT
] = property
; break;
184 case CTF_PM_FOOTERBORDERTOP
: pFooterBorders
[XML_LINE_TOP
] = property
; break;
185 case CTF_PM_FOOTERBORDERBOTTOM
: pFooterBorders
[XML_LINE_BOTTOM
] = property
; break;
186 case CTF_PM_FOOTERBORDERWIDTHALL
: pAllFooterBorderWidthProperty
= property
; break;
187 case CTF_PM_FOOTERBORDERWIDTHLEFT
: pFooterBorderWidths
[XML_LINE_LEFT
] = property
; break;
188 case CTF_PM_FOOTERBORDERWIDTHRIGHT
: pFooterBorderWidths
[XML_LINE_RIGHT
] = property
; break;
189 case CTF_PM_FOOTERBORDERWIDTHTOP
: pFooterBorderWidths
[XML_LINE_TOP
] = property
; break;
190 case CTF_PM_FOOTERBORDERWIDTHBOTTOM
: pFooterBorderWidths
[XML_LINE_BOTTOM
] = property
; break;
191 case CTF_PM_HEADERHEIGHT
: pHeaderHeight
= property
; break;
192 case CTF_PM_HEADERMINHEIGHT
: pHeaderMinHeight
= property
; break;
193 case CTF_PM_FOOTERHEIGHT
: pFooterHeight
= property
; break;
194 case CTF_PM_FOOTERMINHEIGHT
: pFooterMinHeight
= property
; break;
199 for ( i
= 0; i
< 4; i
++)
201 if (pAllPaddingProperty
&& !pPadding
[i
])
202 pNewPadding
[i
] = new XMLPropertyState(pAllPaddingProperty
->mnIndex
+ 1 + i
, pAllPaddingProperty
->maValue
);
203 if (pAllBorderProperty
&& !pBorders
[i
])
205 pNewBorders
[i
] = new XMLPropertyState(pAllBorderProperty
->mnIndex
+ 1 + i
, pAllBorderProperty
->maValue
);
206 pBorders
[i
] = pNewBorders
[i
];
208 if( !pBorderWidths
[i
] )
209 pBorderWidths
[i
] = pAllBorderWidthProperty
;
211 pBorderWidths
[i
]->mnIndex
= -1;
214 table::BorderLine aBorderLine
;
215 pBorders
[i
]->maValue
>>= aBorderLine
;
216 if( pBorderWidths
[i
] )
218 table::BorderLine aBorderLineWidth
;
219 pBorderWidths
[i
]->maValue
>>= aBorderLineWidth
;
220 aBorderLine
.OuterLineWidth
= aBorderLineWidth
.OuterLineWidth
;
221 aBorderLine
.InnerLineWidth
= aBorderLineWidth
.InnerLineWidth
;
222 aBorderLine
.LineDistance
= aBorderLineWidth
.LineDistance
;
223 pBorders
[i
]->maValue
<<= aBorderLine
;
226 if (pAllHeaderPaddingProperty
&& !pHeaderPadding
[i
])
227 pHeaderNewPadding
[i
] = new XMLPropertyState(pAllHeaderPaddingProperty
->mnIndex
+ 1 + i
, pAllHeaderPaddingProperty
->maValue
);
228 if (pAllHeaderBorderProperty
&& !pHeaderBorders
[i
])
229 pHeaderNewBorders
[i
] = new XMLPropertyState(pAllHeaderBorderProperty
->mnIndex
+ 1 + i
, pAllHeaderBorderProperty
->maValue
);
230 if( !pHeaderBorderWidths
[i
] )
231 pHeaderBorderWidths
[i
] = pAllHeaderBorderWidthProperty
;
233 pHeaderBorderWidths
[i
]->mnIndex
= -1;
234 if( pHeaderBorders
[i
] )
236 table::BorderLine aBorderLine
;
237 pHeaderBorders
[i
]->maValue
>>= aBorderLine
;
238 if( pHeaderBorderWidths
[i
] )
240 table::BorderLine aBorderLineWidth
;
241 pHeaderBorderWidths
[i
]->maValue
>>= aBorderLineWidth
;
242 aBorderLine
.OuterLineWidth
= aBorderLineWidth
.OuterLineWidth
;
243 aBorderLine
.InnerLineWidth
= aBorderLineWidth
.InnerLineWidth
;
244 aBorderLine
.LineDistance
= aBorderLineWidth
.LineDistance
;
245 pHeaderBorders
[i
]->maValue
<<= aBorderLine
;
248 if (pAllFooterPaddingProperty
&& !pFooterPadding
[i
])
249 pFooterNewPadding
[i
] = new XMLPropertyState(pAllFooterPaddingProperty
->mnIndex
+ 1 + i
, pAllFooterPaddingProperty
->maValue
);
250 if (pAllFooterBorderProperty
&& !pFooterBorders
[i
])
251 pFooterNewBorders
[i
] = new XMLPropertyState(pAllFooterBorderProperty
->mnIndex
+ 1 + i
, pAllFooterBorderProperty
->maValue
);
252 if( !pFooterBorderWidths
[i
] )
253 pFooterBorderWidths
[i
] = pAllFooterBorderWidthProperty
;
255 pFooterBorderWidths
[i
]->mnIndex
= -1;
256 if( pFooterBorders
[i
] )
258 table::BorderLine aBorderLine
;
259 pFooterBorders
[i
]->maValue
>>= aBorderLine
;
260 if( pFooterBorderWidths
[i
] )
262 table::BorderLine aBorderLineWidth
;
263 pFooterBorderWidths
[i
]->maValue
>>= aBorderLineWidth
;
264 aBorderLine
.OuterLineWidth
= aBorderLineWidth
.OuterLineWidth
;
265 aBorderLine
.InnerLineWidth
= aBorderLineWidth
.InnerLineWidth
;
266 aBorderLine
.LineDistance
= aBorderLineWidth
.LineDistance
;
267 pFooterBorders
[i
]->maValue
<<= aBorderLine
;
274 sal_Bool
bValue(sal_False
);
276 aAny
.setValue( &bValue
, ::getBooleanCppuType() );
277 pHeaderDynamic
= new XMLPropertyState(pHeaderHeight
->mnIndex
+ 2, aAny
);
279 if (pHeaderMinHeight
)
281 sal_Bool
bValue(sal_True
);
283 aAny
.setValue( &bValue
, ::getBooleanCppuType() );
284 pHeaderDynamic
= new XMLPropertyState(pHeaderMinHeight
->mnIndex
+ 1, aAny
);
288 sal_Bool
bValue(sal_False
);
290 aAny
.setValue( &bValue
, ::getBooleanCppuType() );
291 pFooterDynamic
= new XMLPropertyState(pFooterHeight
->mnIndex
+ 2, aAny
);
293 if (pFooterMinHeight
)
295 sal_Bool
bValue(sal_True
);
297 aAny
.setValue( &bValue
, ::getBooleanCppuType() );
298 pFooterDynamic
= new XMLPropertyState(pFooterMinHeight
->mnIndex
+ 1, aAny
);
300 for (i
= 0; i
< 4; i
++)
304 rProperties
.push_back(*pNewPadding
[i
]);
305 delete pNewPadding
[i
];
309 rProperties
.push_back(*pNewBorders
[i
]);
310 delete pNewBorders
[i
];
312 if (pHeaderNewPadding
[i
])
314 rProperties
.push_back(*pHeaderNewPadding
[i
]);
315 delete pHeaderNewPadding
[i
];
317 if (pHeaderNewBorders
[i
])
319 rProperties
.push_back(*pHeaderNewBorders
[i
]);
320 delete pHeaderNewBorders
[i
];
322 if (pFooterNewPadding
[i
])
324 rProperties
.push_back(*pFooterNewPadding
[i
]);
325 delete pFooterNewPadding
[i
];
327 if (pFooterNewBorders
[i
])
329 rProperties
.push_back(*pFooterNewBorders
[i
]);
330 delete pFooterNewBorders
[i
];
335 rProperties
.push_back(*pHeaderDynamic
);
336 delete pHeaderDynamic
;
340 rProperties
.push_back(*pFooterDynamic
);
341 delete pFooterDynamic
;