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: PropertyMap.hxx,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 ************************************************************************/
30 #ifndef INCLUDED_DMAPPER_PROPERTYMAP_HXX
31 #define INCLUDED_DMAPPER_PROPERTYMAP_HXX
33 #include <rtl/ustring.hxx>
34 #include <com/sun/star/uno/Sequence.hxx>
35 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_
36 #include <com/sun/star/beans/PropertyValue.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/uno/Any.h>
40 #include <PropertyIds.hxx>
41 #include <boost/shared_ptr.hpp>
45 namespace com
{namespace sun
{namespace star
{
54 class XMultiServiceFactory
;
66 namespace writerfilter
{
68 class DomainMapper_Impl
;
77 /*-- 15.06.2006 08:22:33---------------------------------------------------
79 -----------------------------------------------------------------------*/
80 struct PropertyDefinition
85 PropertyDefinition( PropertyIds _eId
, bool _bIsTextProperty
) :
87 bIsTextProperty( _bIsTextProperty
){}
89 bool operator== (const PropertyDefinition
& rDef
) const
90 { return rDef
.eId
== eId
; }
91 bool operator< (const PropertyDefinition
& rDef
) const
92 { return eId
< rDef
.eId
; }
94 typedef std::map
< PropertyDefinition
, ::com::sun::star::uno::Any
> _PropertyMap
;
95 class PropertyMap
: public _PropertyMap
97 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> m_aValues
;
98 //marks context as footnote context - ::text( ) events contain either the footnote character or can be ignored
99 //depending on sprmCSymbol
100 sal_Unicode m_cFootnoteSymbol
; // 0 == invalid
101 sal_Int32 m_nFootnoteFontId
; // negative values are invalid ids
102 ::rtl::OUString m_sFootnoteFontName
;
103 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XFootnote
> m_xFootnote
;
107 virtual ~PropertyMap();
109 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> GetPropertyValues();
110 bool hasEmptyPropertyValues() const {return !m_aValues
.getLength();}
111 /** Add property, usually overwrites already available attributes. It shouldn't overwrite in case of default attributes
113 void Insert( PropertyIds eId
, bool bIsTextProperty
, const ::com::sun::star::uno::Any
& rAny
, bool bOverwrite
= true );
114 using _PropertyMap::insert
;
115 void insert(const boost::shared_ptr
<PropertyMap
> pMap
, bool bOverwrite
= true);
119 if(m_aValues
.getLength())
120 m_aValues
.realloc( 0 );
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XFootnote
>& GetFootnote() const;
124 void SetFootnote( ::com::sun::star::uno::Reference
< ::com::sun::star::text::XFootnote
> xF
) { m_xFootnote
= xF
; }
126 sal_Unicode
GetFootnoteSymbol() const { return m_cFootnoteSymbol
;}
127 void SetFootnoteSymbol(sal_Unicode cSet
) { m_cFootnoteSymbol
= cSet
;}
129 sal_Int32
GetFootnoteFontId() const { return m_nFootnoteFontId
;}
130 void SetFootnoteFontId(sal_Int32 nSet
) { m_nFootnoteFontId
= nSet
;}
132 const ::rtl::OUString
& GetFootnoteFontName() const { return m_sFootnoteFontName
;}
133 void SetFootnoteFontName( const ::rtl::OUString
& rSet
) { m_sFootnoteFontName
= rSet
;}
135 virtual void insertTableProperties( const PropertyMap
* );
138 typedef boost::shared_ptr
<PropertyMap
> PropertyMapPtr
;
140 /*-- 24.07.2006 08:26:33---------------------------------------------------
142 -----------------------------------------------------------------------*/
143 class SectionPropertyMap
: public PropertyMap
146 sal_Int32 nSectionNumber
;
148 //'temporarily' the section page settings are imported as page styles
149 // empty strings mark page settings as not yet imported
151 bool m_bIsFirstSection
;
152 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> m_xStartingRange
;
154 ::rtl::OUString m_sFirstPageStyleName
;
155 ::rtl::OUString m_sFollowPageStyleName
;
156 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_aFirstPageStyle
;
157 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_aFollowPageStyle
;
159 ::com::sun::star::table::BorderLine
* m_pBorderLines
[4];
160 sal_Int32 m_nBorderDistances
[4];
163 sal_Int16 m_nColumnCount
;
164 sal_Int32 m_nColumnDistance
;
165 ::std::vector
< sal_Int32
> m_aColWidth
;
166 ::std::vector
< sal_Int32
> m_aColDistance
;
168 bool m_bSeparatorLineIsOn
;
169 bool m_bEvenlySpaced
;
172 bool m_bPageNoRestart
;
173 sal_Int32 m_nPageNumber
;
174 sal_Int32 m_nBreakType
;
175 sal_Int32 m_nPaperBin
;
176 sal_Int32 m_nFirstPaperBin
;
178 sal_Int32 m_nLeftMargin
;
179 sal_Int32 m_nRightMargin
;
180 sal_Int32 m_nTopMargin
;
181 sal_Int32 m_nBottomMargin
;
182 sal_Int32 m_nHeaderTop
;
183 sal_Int32 m_nHeaderBottom
;
185 sal_Int32 m_nDzaGutter
;
189 sal_Int32 m_nGridLinePitch
;
190 sal_Int32 m_nDxtCharSpace
;
198 void _ApplyProperties( ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xStyle
);
199 ::com::sun::star::uno::Reference
< com::sun::star::text::XTextColumns
> ApplyColumnProperties(
200 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> xFollowPageStyle
);
201 void PrepareHeaderFooterProperties( bool bFirstPage
);
202 bool HasHeader( bool bFirstPage
) const;
203 bool HasFooter( bool bFirstPage
) const;
206 explicit SectionPropertyMap(bool bIsFirstSection
);
207 ~SectionPropertyMap();
216 void SetStart( const ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
>& xRange
)
218 m_xStartingRange
= xRange
;
221 const ::rtl::OUString
& GetPageStyleName( bool bFirst
);
222 void SetPageStyleName( bool bFirst
, const ::rtl::OUString
& rName
);
224 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> GetPageStyle(
225 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>& xStyles
,
226 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xTextFactory
,
229 void SetBorder( BorderPosition ePos
, sal_Int32 nLineDistance
, const ::com::sun::star::table::BorderLine
& rBorderLine
);
231 void SetColumnCount( sal_Int16 nCount
) { m_nColumnCount
= nCount
; }
232 void SetColumnDistance( sal_Int32 nDist
) { m_nColumnDistance
= nDist
; }
233 void AppendColumnWidth( sal_Int32 nWidth
) { m_aColWidth
.push_back( nWidth
); }
234 void AppendColumnSpacing( sal_Int32 nDist
) {m_aColDistance
.push_back( nDist
); }
236 void SetTitlePage( bool bSet
) { m_bTitlePage
= bSet
; }
237 void SetSeparatorLine( bool bSet
) { m_bSeparatorLineIsOn
= bSet
; }
238 void SetEvenlySpaced( bool bSet
) { m_bEvenlySpaced
= bSet
; }
239 void SetLandscape( bool bSet
) { m_bIsLandscape
= bSet
; }
240 void SetPageNoRestart( bool bSet
) { m_bPageNoRestart
= bSet
; }
241 void SetPageNumber( sal_Int32 nSet
) { m_nPageNumber
= nSet
; }
242 void SetBreakType( sal_Int32 nSet
) { m_nBreakType
= nSet
; }
243 void SetPaperBin( sal_Int32 nSet
);
244 void SetFirstPaperBin( sal_Int32 nSet
);
246 void SetLeftMargin( sal_Int32 nSet
) { m_nLeftMargin
= nSet
; }
247 void SetRightMargin( sal_Int32 nSet
) { m_nRightMargin
= nSet
; }
248 void SetTopMargin( sal_Int32 nSet
) { m_nTopMargin
= nSet
; }
249 void SetBottomMargin( sal_Int32 nSet
) { m_nBottomMargin
= nSet
; }
250 void SetHeaderTop( sal_Int32 nSet
) { m_nHeaderTop
= nSet
; }
251 void SetHeaderBottom( sal_Int32 nSet
) { m_nHeaderBottom
= nSet
; }
253 void SetGutterRTL( bool bSet
) { m_bGutterRTL
= bSet
;}
254 void SetDzaGutter( sal_Int32 nSet
) {m_nDzaGutter
= nSet
; }
255 void SetSFBiDi( bool bSet
) { m_bSFBiDi
= bSet
;}
257 void SetGridLinePitch( sal_Int32 nSet
) { m_nGridLinePitch
= nSet
; }
258 void SetDxtCharSpace( sal_Int32 nSet
) { m_nDxtCharSpace
= nSet
; }
260 void SetLnnMod( sal_Int32 nValue
) { m_nLnnMod
= nValue
; }
261 void SetLnc( sal_Int32 nValue
) { m_nLnc
= nValue
; }
262 void SetdxaLnn( sal_Int32 nValue
) { m_ndxaLnn
= nValue
; }
263 void SetLnnMin( sal_Int32 nValue
) { m_nLnnMin
= nValue
; }
265 //determine which style gets the borders
266 void ApplyBorderToPageStyles(
267 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>& xStyles
,
268 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xTextFactory
,
271 void CloseSectionGroup( DomainMapper_Impl
& rDM_Impl
);
274 /*-- 28.12.2007 08:17:34---------------------------------------------------
276 -----------------------------------------------------------------------*/
277 class ParagraphProperties
280 sal_Int32 m_nDropCap
; //drop, margin ST_DropCap
281 sal_Int32 m_nLines
; //number of lines of the drop cap
282 sal_Int32 m_w
; //width
283 sal_Int32 m_h
; //height
284 sal_Int32 m_nWrap
; // from ST_Wrap around, auto, none, notBeside, through, tight
285 sal_Int32 m_hAnchor
; // page, from ST_HAnchor margin, page, text
286 sal_Int32 m_vAnchor
; // around from ST_VAnchor margin, page, text
287 sal_Int32 m_x
; //x-position
289 sal_Int32 m_y
; //y-position
291 sal_Int32 m_hSpace
; //frame padding h
292 sal_Int32 m_vSpace
; //frame padding v
293 sal_Int32 m_hRule
; // from ST_HeightRule exact, atLeast, auto
294 sal_Int32 m_xAlign
; // from ST_XAlign center, inside, left, outside, right
295 sal_Int32 m_yAlign
; // from ST_YAlign bottom, center, inline, inside, outside, top
298 sal_Int8 m_nDropCapLength
; //number of characters
300 ::rtl::OUString m_sParaStyleName
;
302 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> m_xStartingRange
; //start of a frame
303 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> m_xEndingRange
; //end of the frame
306 ParagraphProperties();
307 ParagraphProperties(const ParagraphProperties
&);
308 ~ParagraphProperties();
310 int operator==(const ParagraphProperties
&); //does not compare the starting/ending range, m_sParaStyleName and m_nDropCapLength
312 void SetFrameMode() { m_bFrameMode
= true; }
313 bool IsFrameMode()const { return m_bFrameMode
; }
315 void SetDropCap( sal_Int32 nSet
) { m_nDropCap
= nSet
; }
316 sal_Int32
GetDropCap()const { return m_nDropCap
; }
318 void SetLines( sal_Int32 nSet
) { m_nLines
= nSet
; }
319 sal_Int32
GetLines() const { return m_nLines
; }
321 void Setw( sal_Int32 nSet
) { m_w
= nSet
; }
322 sal_Int32
Getw() const { return m_w
; }
324 void Seth( sal_Int32 nSet
) { m_h
= nSet
; }
325 sal_Int32
Geth() const { return m_h
; }
327 void SetWrap( sal_Int32 nSet
) { m_nWrap
= nSet
; }
328 sal_Int32
GetWrap() const { return m_nWrap
; }
330 void SethAnchor( sal_Int32 nSet
) { m_hAnchor
= nSet
; }
331 sal_Int32
GethAnchor() const { return m_hAnchor
;}
333 void SetvAnchor( sal_Int32 nSet
) { m_vAnchor
= nSet
; }
334 sal_Int32
GetvAnchor() const { return m_vAnchor
; }
336 void Setx( sal_Int32 nSet
) { m_x
= nSet
; m_bxValid
= true;}
337 sal_Int32
Getx() const { return m_x
; }
338 bool IsxValid() const {return m_bxValid
;}
340 void Sety( sal_Int32 nSet
) { m_y
= nSet
; m_byValid
= true;}
341 sal_Int32
Gety()const { return m_y
; }
342 bool IsyValid() const {return m_byValid
;}
344 void SethSpace( sal_Int32 nSet
) { m_hSpace
= nSet
; }
345 sal_Int32
GethSpace()const { return m_hSpace
; }
347 void SetvSpace( sal_Int32 nSet
) { m_vSpace
= nSet
; }
348 sal_Int32
GetvSpace()const { return m_vSpace
; }
350 void SethRule( sal_Int32 nSet
) { m_hRule
= nSet
; }
351 sal_Int32
GethRule() const { return m_hRule
; }
353 void SetxAlign( sal_Int32 nSet
) { m_xAlign
= nSet
; }
354 sal_Int32
GetxAlign()const { return m_xAlign
; }
356 void SetyAlign( sal_Int32 nSet
) { m_yAlign
= nSet
; }
357 sal_Int32
GetyAlign()const { return m_yAlign
; }
359 void SetAnchorLock( bool bSet
) {m_bAnchorLock
= bSet
; }
361 sal_Int8
GetDropCapLength() const { return m_nDropCapLength
;}
362 void SetDropCapLength(sal_Int8 nSet
) { m_nDropCapLength
= nSet
;}
364 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> GetStartingRange() const { return m_xStartingRange
; }
365 void SetStartingRange( ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> xSet
) { m_xStartingRange
= xSet
; }
367 ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> GetEndingRange() const { return m_xEndingRange
; }
368 void SetEndingRange( ::com::sun::star::uno::Reference
< ::com::sun::star::text::XTextRange
> xSet
) { m_xEndingRange
= xSet
; }
370 void SetParaStyleName( const ::rtl::OUString
& rSet
) { m_sParaStyleName
= rSet
;}
371 const ::rtl::OUString
& GetParaStyleName() const { return m_sParaStyleName
;}
375 typedef boost::shared_ptr
<ParagraphProperties
> ParagraphPropertiesPtr
;
376 /*-- 14.06.2007 12:12:34---------------------------------------------------
377 property map of a stylesheet
378 -----------------------------------------------------------------------*/
379 class StyleSheetPropertyMap
: public PropertyMap
, public ParagraphProperties
382 //special table style properties
383 // sal_Int32 mnCT_Spacing_after;
384 sal_Int32 mnCT_Spacing_line
;
385 sal_Int32 mnCT_Spacing_lineRule
;
387 ::rtl::OUString msCT_Fonts_ascii
;
388 bool mbCT_TrPrBase_tblHeader
;
389 sal_Int32 mnCT_TrPrBase_jc
;
390 sal_Int32 mnCT_TcPrBase_vAlign
;
392 sal_Int32 mnCT_TblWidth_w
;
393 sal_Int32 mnCT_TblWidth_type
;
395 // bool mbCT_Spacing_afterSet;
396 bool mbCT_Spacing_lineSet
;
397 bool mbCT_Spacing_lineRuleSet
;
399 bool mbCT_TrPrBase_tblHeaderSet
;
400 bool mbCT_TrPrBase_jcSet
;
401 bool mbCT_TcPrBase_vAlignSet
;
403 bool mbCT_TblWidth_wSet
;
404 bool mbCT_TblWidth_typeSet
;
407 sal_Int16 mnListLevel
;
409 explicit StyleSheetPropertyMap();
410 ~StyleSheetPropertyMap();
412 // void SetCT_Spacing_after( sal_Int32 nSet )
413 // {mnCT_Spacing_after = nSet; mbCT_Spacing_afterSet = true; }
414 void SetCT_Spacing_line( sal_Int32 nSet
)
415 {mnCT_Spacing_line
= nSet
; mbCT_Spacing_lineSet
= true; }
416 void SetCT_Spacing_lineRule( sal_Int32 nSet
)
417 {mnCT_Spacing_lineRule
= nSet
; mbCT_Spacing_lineRuleSet
= true; }
419 void SetCT_Fonts_ascii( const ::rtl::OUString
& rSet
)
420 {msCT_Fonts_ascii
= rSet
; }
421 void SetCT_TrPrBase_tblHeader( bool bSet
)
422 {mbCT_TrPrBase_tblHeader
= bSet
; mbCT_TrPrBase_tblHeaderSet
= true; }
423 void SetCT_TrPrBase_jc( sal_Int32 nSet
)
424 {mnCT_TrPrBase_jc
= nSet
; mbCT_TrPrBase_jcSet
= true; }
425 void SetCT_TcPrBase_vAlign( sal_Int32 nSet
)
426 {mnCT_TcPrBase_vAlign
= nSet
; mbCT_TcPrBase_vAlignSet
= true; }
428 void SetCT_TblWidth_w( sal_Int32 nSet
)
429 { mnCT_TblWidth_w
= nSet
; mbCT_TblWidth_wSet
= true; }
430 void SetCT_TblWidth_type( sal_Int32 nSet
)
431 {mnCT_TblWidth_type
= nSet
; mbCT_TblWidth_typeSet
= true; }
433 // bool GetCT_Spacing_after( sal_Int32& rToFill) const
435 // if( mbCT_Spacing_afterSet )
436 // rToFill = mnCT_Spacing_after;
437 // return mbCT_Spacing_afterSet;
439 bool GetCT_Spacing_line( sal_Int32
& rToFill
) const
441 if( mbCT_Spacing_lineSet
)
442 rToFill
= mnCT_Spacing_line
;
443 return mbCT_Spacing_lineSet
;
445 bool GetCT_Spacing_lineRule(sal_Int32
& rToFill
) const
447 if( mbCT_Spacing_lineRuleSet
)
448 rToFill
= mnCT_Spacing_lineRule
;
449 return mbCT_Spacing_lineRuleSet
;
452 bool GetCT_Fonts_ascii(::rtl::OUString
& rToFill
) const
454 if( msCT_Fonts_ascii
.getLength() > 0 )
455 rToFill
= msCT_Fonts_ascii
;
456 return msCT_Fonts_ascii
.getLength() > 0;
458 bool GetCT_TrPrBase_tblHeader(bool& rToFill
) const
460 if( mbCT_TrPrBase_tblHeaderSet
)
461 rToFill
= mbCT_TrPrBase_tblHeader
;
462 return mbCT_TrPrBase_tblHeaderSet
;
464 bool GetCT_TrPrBase_jc( sal_Int32
& rToFill
)const
466 if( mbCT_TrPrBase_jcSet
)
467 rToFill
= mnCT_TrPrBase_jc
;
468 return mbCT_TrPrBase_jcSet
;
470 bool GetCT_TcPrBase_vAlign( sal_Int32
& rToFill
)const
472 if( mbCT_TcPrBase_vAlignSet
)
473 rToFill
= mnCT_TcPrBase_vAlign
;
474 return mbCT_TcPrBase_vAlignSet
;
476 sal_Int32
GetListId() const { return mnListId
; }
477 void SetListId(sal_Int32 nId
) { mnListId
= nId
; }
479 sal_Int16
GetListLevel() const { return mnListLevel
; }
480 void SetListLevel(sal_Int16 nLevel
) { mnListLevel
= nLevel
; }
483 /*-- 27.12.2007 12:38:06---------------------------------------------------
485 -----------------------------------------------------------------------*/
486 class ParagraphPropertyMap
: public PropertyMap
, public ParagraphProperties
489 explicit ParagraphPropertyMap();
490 ~ParagraphPropertyMap();
493 /*-- 15.02.2008 16:06:52---------------------------------------------------
495 -----------------------------------------------------------------------*/
496 class TablePropertyMap
: public PropertyMap
499 enum TablePropertyMapTarget
501 TablePropertyMapTarget_START
,
502 CELL_MAR_LEFT
= TablePropertyMapTarget_START
,
510 TablePropertyMapTarget_MAX
521 ValidValue m_aValidValues
[TablePropertyMapTarget_MAX
];
524 explicit TablePropertyMap();
527 bool getValue( TablePropertyMapTarget eWhich
, sal_Int32
& nFill
);
528 void setValue( TablePropertyMapTarget eWhich
, sal_Int32 nSet
);
530 virtual void insertTableProperties( const PropertyMap
* );
532 typedef boost::shared_ptr
<TablePropertyMap
> TablePropertyMapPtr
;
533 } //namespace dmapper
534 } //namespace writerfilter