1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX
29 #define OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX
30 
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
33 #include "oox/drawingml/textcharacterproperties.hxx"
34 #include <com/sun/star/style/NumberingType.hpp>
35 #include "oox/drawingml/textfont.hxx"
36 #include "textspacing.hxx"
37 #include <boost/optional.hpp>
38 
39 namespace com { namespace sun { namespace star {
40     namespace graphic { class XGraphic; }
41 } } }
42 
43 namespace oox { namespace drawingml {
44 
45 class TextParagraphProperties;
46 
47 typedef boost::shared_ptr< TextParagraphProperties > TextParagraphPropertiesPtr;
48 
49 class BulletList
50 {
51 public:
52 	BulletList( );
53 	bool is() const;
54 	void apply( const BulletList& );
55     void pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, PropertyMap& rPropMap ) const;
56 	void setBulletChar( const ::rtl::OUString & sChar );
57 	void setStartAt( sal_Int32 nStartAt ){ mnStartAt <<= static_cast< sal_Int16 >( nStartAt ); }
58 	void setType( sal_Int32 nType );
59 	void setNone( );
60 	void setSuffixParenBoth();
61 	void setSuffixParenRight();
62 	void setSuffixPeriod();
63 	void setSuffixNone();
64 	void setSuffixMinusRight();
65 	void setBulletSize(sal_Int16 nSize);
66 	void setFontSize(sal_Int16 nSize);
67 	void setStyleName( const rtl::OUString& rStyleName ) { maStyleName <<= rStyleName; }
68 	void setGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rXGraphic );
69 
70 	::oox::drawingml::ColorPtr	maBulletColorPtr;
71 	::com::sun::star::uno::Any	mbBulletColorFollowText;
72 	::com::sun::star::uno::Any	mbBulletFontFollowText;
73 	::oox::drawingml::TextFont	maBulletFont;
74 	::com::sun::star::uno::Any	msBulletChar;
75 	::com::sun::star::uno::Any	mnStartAt;
76 	::com::sun::star::uno::Any	mnNumberingType;
77 	::com::sun::star::uno::Any	msNumberingPrefix;
78 	::com::sun::star::uno::Any	msNumberingSuffix;
79 	::com::sun::star::uno::Any	mnSize;
80 	::com::sun::star::uno::Any	mnFontSize;
81 	::com::sun::star::uno::Any	maStyleName;
82 	::com::sun::star::uno::Any  maGraphic;
83 	boost::optional< float >	maFollowFontSize;
84 };
85 
86 class TextParagraphProperties
87 {
88 public:
89 
90 	TextParagraphProperties();
91     ~TextParagraphProperties();
92 
93 	void                                setLevel( sal_Int16 nLevel ) { mnLevel = nLevel; }
94     sal_Int16                           getLevel( ) const { return mnLevel; }
95     PropertyMap&                        getTextParagraphPropertyMap() { return maTextParagraphPropertyMap; }
96     BulletList&                         getBulletList() { return maBulletList; }
97     TextCharacterProperties&            getTextCharacterProperties() { return maTextCharacterProperties; }
98     const TextCharacterProperties&      getTextCharacterProperties() const { return maTextCharacterProperties; }
99 
100     TextSpacing&                        getParaTopMargin() { return maParaTopMargin; }
101     TextSpacing&                        getParaBottomMargin() { return maParaBottomMargin; }
102     boost::optional< sal_Int32 >&       getParaLeftMargin(){ return moParaLeftMargin; }
103     boost::optional< sal_Int32 >&       getFirstLineIndentation(){ return moFirstLineIndentation; }
104 
105     void                                apply( const TextParagraphProperties& rSourceProps );
106     void                                pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
107 											const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet,
108                                                 PropertyMap& rioBulletList, const BulletList* pMasterBuList, sal_Bool bApplyBulletList, float fFontSize ) const;
109 
110     /** Returns the largest character size of this paragraph. If possible the
111         masterstyle should have been applied before, otherwise the character
112         size can be zero and the default value is returned. */
113     float                               getCharHeightPoints( float fDefault ) const;
114 
115 protected:
116 
117     TextCharacterProperties         maTextCharacterProperties;
118     PropertyMap                     maTextParagraphPropertyMap;
119     BulletList                      maBulletList;
120     TextSpacing                     maParaTopMargin;
121     TextSpacing                     maParaBottomMargin;
122     boost::optional< sal_Int32 >    moParaLeftMargin;
123     boost::optional< sal_Int32 >    moFirstLineIndentation;
124     sal_Int16                       mnLevel;
125 };
126 
127 } }
128 
129 #endif  //  OOX_DRAWINGML_TEXTPARAGRAPHPROPERTIES_HXX
130