xref: /aoo42x/main/sw/source/core/para/paratr.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "hintids.hxx"
28cdf0e10cSrcweir #include <swtypes.hxx>
29cdf0e10cSrcweir #include "unomid.h"
30cdf0e10cSrcweir #include <com/sun/star/style/LineSpacingMode.hpp>
31cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
32cdf0e10cSrcweir #include <com/sun/star/style/DropCapFormat.hpp>
33cdf0e10cSrcweir #include <com/sun/star/style/LineSpacing.hpp>
34cdf0e10cSrcweir #include <com/sun/star/text/RelOrientation.hpp>
35cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
36cdf0e10cSrcweir #include <com/sun/star/text/HorizontalAdjust.hpp>
37cdf0e10cSrcweir #include <com/sun/star/text/DocumentStatistic.hpp>
38cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
39cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientationFormat.hpp>
40cdf0e10cSrcweir #include <com/sun/star/text/NotePrintMode.hpp>
41cdf0e10cSrcweir #include <com/sun/star/text/SizeType.hpp>
42cdf0e10cSrcweir #include <com/sun/star/text/VertOrientationFormat.hpp>
43cdf0e10cSrcweir #include <com/sun/star/text/WrapTextMode.hpp>
44cdf0e10cSrcweir #include <unostyle.hxx>
45cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
46cdf0e10cSrcweir #include "errhdl.hxx"
47cdf0e10cSrcweir #include "paratr.hxx"
48cdf0e10cSrcweir #include "charfmt.hxx"
49cdf0e10cSrcweir #include "cmdid.h"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::com::sun::star;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
54cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
55cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
56cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir |*    Beschreibung		Methoden von SwFmtDrop
60cdf0e10cSrcweir |*    Ersterstellung	MS  19.02.91
61cdf0e10cSrcweir |*    Letzte Aenderung	JP 08.08.94
62cdf0e10cSrcweir *************************************************************************/
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
SwFmtDrop()66cdf0e10cSrcweir SwFmtDrop::SwFmtDrop()
67cdf0e10cSrcweir 	: SfxPoolItem( RES_PARATR_DROP ),
68cdf0e10cSrcweir 	SwClient( 0 ),
69cdf0e10cSrcweir 	pDefinedIn( 0 ),
70cdf0e10cSrcweir 	nDistance( 0 ),
71cdf0e10cSrcweir 	nReadFmt( USHRT_MAX ),
72cdf0e10cSrcweir 	nLines( 0 ),
73cdf0e10cSrcweir 	nChars( 0 ),
74cdf0e10cSrcweir 	bWholeWord( sal_False )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
SwFmtDrop(const SwFmtDrop & rCpy)80cdf0e10cSrcweir SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
81cdf0e10cSrcweir 	: SfxPoolItem( RES_PARATR_DROP ),
82cdf0e10cSrcweir 	SwClient( rCpy.GetRegisteredInNonConst() ),
83cdf0e10cSrcweir 	pDefinedIn( 0 ),
84cdf0e10cSrcweir 	nDistance( rCpy.GetDistance() ),
85cdf0e10cSrcweir 	nReadFmt( rCpy.nReadFmt ),
86cdf0e10cSrcweir 	nLines( rCpy.GetLines() ),
87cdf0e10cSrcweir 	nChars( rCpy.GetChars() ),
88cdf0e10cSrcweir 	bWholeWord( rCpy.GetWholeWord() )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
~SwFmtDrop()94cdf0e10cSrcweir SwFmtDrop::~SwFmtDrop()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
SetCharFmt(SwCharFmt * pNew)100cdf0e10cSrcweir void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	//Ummelden
103cdf0e10cSrcweir 	if ( GetRegisteredIn() )
104cdf0e10cSrcweir 		GetRegisteredInNonConst()->Remove( this );
105cdf0e10cSrcweir     if(pNew)
106cdf0e10cSrcweir         pNew->Add( this );
107cdf0e10cSrcweir 	nReadFmt = USHRT_MAX;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
Modify(const SfxPoolItem *,const SfxPoolItem *)112cdf0e10cSrcweir void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	if( pDefinedIn )
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		if( !pDefinedIn->ISA( SwFmt ))
117cdf0e10cSrcweir 			pDefinedIn->ModifyNotification( this, this );
118cdf0e10cSrcweir 		else if( pDefinedIn->GetDepends() &&
119cdf0e10cSrcweir 				!pDefinedIn->IsModifyLocked() )
120cdf0e10cSrcweir 		{
121cdf0e10cSrcweir 			// selbst den Abhaengigen vom Format bescheid sagen. Das
122cdf0e10cSrcweir 			// Format selbst wuerde es nicht weitergeben, weil es ueber
123cdf0e10cSrcweir 			// die Abpruefung nicht hinauskommt.
124cdf0e10cSrcweir             pDefinedIn->ModifyBroadcast( this, this );
125cdf0e10cSrcweir 		}
126cdf0e10cSrcweir 	}
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
GetInfo(SfxPoolItem &) const129cdf0e10cSrcweir sal_Bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	return sal_True;    // weiter
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rAttr) const134cdf0e10cSrcweir int SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
137cdf0e10cSrcweir 	return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
138cdf0e10cSrcweir 			 nChars == ((SwFmtDrop&)rAttr).GetChars() &&
139cdf0e10cSrcweir 			 nDistance ==  ((SwFmtDrop&)rAttr).GetDistance() &&
140cdf0e10cSrcweir 			 bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
141cdf0e10cSrcweir 			 GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
142cdf0e10cSrcweir 			 pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
Clone(SfxItemPool *) const145cdf0e10cSrcweir SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	return new SwFmtDrop( *this );
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const150cdf0e10cSrcweir sal_Bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	switch(nMemberId&~CONVERT_TWIPS)
153cdf0e10cSrcweir 	{
154cdf0e10cSrcweir         case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
155cdf0e10cSrcweir         case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
156cdf0e10cSrcweir         case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
157cdf0e10cSrcweir 		case MID_DROPCAP_FORMAT:
158cdf0e10cSrcweir 		{
159cdf0e10cSrcweir 		 	style::DropCapFormat aDrop;
160cdf0e10cSrcweir 			aDrop.Lines	= nLines   ;
161cdf0e10cSrcweir 			aDrop.Count	= nChars   ;
162cdf0e10cSrcweir 			aDrop.Distance	= TWIP_TO_MM100_UNSIGNED(nDistance);
163cdf0e10cSrcweir 			rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir 		break;
166cdf0e10cSrcweir 		case MID_DROPCAP_WHOLE_WORD:
167cdf0e10cSrcweir 			rVal.setValue(&bWholeWord, ::getBooleanCppuType());
168cdf0e10cSrcweir 		break;
169cdf0e10cSrcweir 		case MID_DROPCAP_CHAR_STYLE_NAME :
170cdf0e10cSrcweir 		{
171cdf0e10cSrcweir 			rtl::OUString sName;
172cdf0e10cSrcweir 			if(GetCharFmt())
173cdf0e10cSrcweir 				sName = SwStyleNameMapper::GetProgName(
174cdf0e10cSrcweir 						GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
175cdf0e10cSrcweir 			rVal <<= sName;
176cdf0e10cSrcweir 		}
177cdf0e10cSrcweir 		break;
178cdf0e10cSrcweir 	}
179cdf0e10cSrcweir 	return sal_True;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)182cdf0e10cSrcweir sal_Bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	switch(nMemberId&~CONVERT_TWIPS)
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir         case MID_DROPCAP_LINES :
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             sal_Int8 nTemp = 0;
189cdf0e10cSrcweir             rVal >>= nTemp;
190cdf0e10cSrcweir             if(nTemp >=1 && nTemp < 0x7f)
191cdf0e10cSrcweir                 nLines = (sal_uInt8)nTemp;
192cdf0e10cSrcweir         }
193cdf0e10cSrcweir         break;
194cdf0e10cSrcweir         case MID_DROPCAP_COUNT :
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             sal_Int16 nTemp = 0;
197cdf0e10cSrcweir             rVal >>= nTemp;
198cdf0e10cSrcweir             if(nTemp >=1 && nTemp < 0x7f)
199cdf0e10cSrcweir                 nChars = (sal_uInt8)nTemp;
200cdf0e10cSrcweir         }
201cdf0e10cSrcweir         break;
202cdf0e10cSrcweir         case MID_DROPCAP_DISTANCE :
203cdf0e10cSrcweir         {
204cdf0e10cSrcweir             sal_Int16 nVal = 0;
205cdf0e10cSrcweir             if ( rVal >>= nVal )
206cdf0e10cSrcweir                 nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
207cdf0e10cSrcweir             else
208cdf0e10cSrcweir                 return sal_False;
209cdf0e10cSrcweir             break;
210cdf0e10cSrcweir         }
211cdf0e10cSrcweir 		case MID_DROPCAP_FORMAT:
212cdf0e10cSrcweir 		{
213cdf0e10cSrcweir 			if(rVal.getValueType()  == ::getCppuType((const style::DropCapFormat*)0))
214cdf0e10cSrcweir 			{
215cdf0e10cSrcweir 				const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
216cdf0e10cSrcweir 				nLines 		= pDrop->Lines;
217cdf0e10cSrcweir 				nChars 		= pDrop->Count;
218cdf0e10cSrcweir 				nDistance 	= MM100_TO_TWIP(pDrop->Distance);
219cdf0e10cSrcweir 			}
220cdf0e10cSrcweir 			else {
221cdf0e10cSrcweir 				//exception( wrong_type)
222cdf0e10cSrcweir 				;
223cdf0e10cSrcweir             }
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 		break;
226cdf0e10cSrcweir 		case MID_DROPCAP_WHOLE_WORD:
227cdf0e10cSrcweir 			bWholeWord = *(sal_Bool*)rVal.getValue();
228cdf0e10cSrcweir 		break;
229cdf0e10cSrcweir 		case MID_DROPCAP_CHAR_STYLE_NAME :
230cdf0e10cSrcweir 			DBG_ERROR("char format cannot be set in PutValue()!");
231cdf0e10cSrcweir 		break;
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 	return sal_True;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // class SwRegisterItem -------------------------------------------------
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
Clone(SfxItemPool *) const239cdf0e10cSrcweir SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	return new SwRegisterItem( *this );
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir // class SwNumRuleItem -------------------------------------------------
Clone(SfxItemPool *) const245cdf0e10cSrcweir SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
246cdf0e10cSrcweir {
247cdf0e10cSrcweir 	return new SwNumRuleItem( *this );
248cdf0e10cSrcweir }
operator ==(const SfxPoolItem & rAttr) const249cdf0e10cSrcweir int SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
252cdf0e10cSrcweir     // --> OD 2008-03-04 #refactorlists# - removed <pDefinedIn>
253cdf0e10cSrcweir     return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
254cdf0e10cSrcweir     // <--
255cdf0e10cSrcweir }
256cdf0e10cSrcweir /* -----------------------------27.06.00 11:05--------------------------------
257cdf0e10cSrcweir 
258cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8) const259cdf0e10cSrcweir sal_Bool    SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
260cdf0e10cSrcweir {
261cdf0e10cSrcweir 	rtl::OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
262cdf0e10cSrcweir 	rVal <<= sRet;
263cdf0e10cSrcweir 	return sal_True;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir /* -----------------------------27.06.00 11:05--------------------------------
266cdf0e10cSrcweir 
267cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8)268cdf0e10cSrcweir sal_Bool    SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	rtl::OUString uName;
271cdf0e10cSrcweir 	rVal >>= uName;
272cdf0e10cSrcweir 	SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
273cdf0e10cSrcweir 	return sal_True;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir /* -----------------19.05.2003 10:44-----------------
276cdf0e10cSrcweir 
277cdf0e10cSrcweir  --------------------------------------------------*/
Clone(SfxItemPool *) const278cdf0e10cSrcweir SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
279cdf0e10cSrcweir {
280cdf0e10cSrcweir     return new SwParaConnectBorderItem( *this );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 
285