Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "hintids.hxx"
22 : #include <swtypes.hxx>
23 : #include "unomid.h"
24 : #include <com/sun/star/style/LineSpacingMode.hpp>
25 : #include <com/sun/star/style/ParagraphAdjust.hpp>
26 : #include <com/sun/star/style/DropCapFormat.hpp>
27 : #include <com/sun/star/style/LineSpacing.hpp>
28 : #include <com/sun/star/text/RelOrientation.hpp>
29 : #include <com/sun/star/text/VertOrientation.hpp>
30 : #include <com/sun/star/text/HorizontalAdjust.hpp>
31 : #include <com/sun/star/text/DocumentStatistic.hpp>
32 : #include <com/sun/star/text/HoriOrientation.hpp>
33 : #include <com/sun/star/text/HoriOrientationFormat.hpp>
34 : #include <com/sun/star/text/NotePrintMode.hpp>
35 : #include <com/sun/star/text/SizeType.hpp>
36 : #include <com/sun/star/text/VertOrientationFormat.hpp>
37 : #include <com/sun/star/text/WrapTextMode.hpp>
38 : #include <unostyle.hxx>
39 : #include <SwStyleNameMapper.hxx>
40 : #include "paratr.hxx"
41 : #include "charfmt.hxx"
42 : #include "cmdid.h"
43 :
44 : using namespace ::com::sun::star;
45 :
46 2817 : TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
47 3550 : TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
48 20860 : TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
49 2784 : TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
50 :
51 928 : SwFmtDrop::SwFmtDrop()
52 : : SfxPoolItem( RES_PARATR_DROP ),
53 : SwClient( 0 ),
54 : pDefinedIn( 0 ),
55 : nDistance( 0 ),
56 : nReadFmt( USHRT_MAX ),
57 : nLines( 0 ),
58 : nChars( 0 ),
59 928 : bWholeWord( sal_False )
60 : {
61 928 : }
62 :
63 :
64 :
65 17915 : SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
66 : : SfxPoolItem( RES_PARATR_DROP ),
67 : SwClient( rCpy.GetRegisteredInNonConst() ),
68 : pDefinedIn( 0 ),
69 17915 : nDistance( rCpy.GetDistance() ),
70 : nReadFmt( rCpy.nReadFmt ),
71 17915 : nLines( rCpy.GetLines() ),
72 17915 : nChars( rCpy.GetChars() ),
73 71660 : bWholeWord( rCpy.GetWholeWord() )
74 : {
75 17915 : }
76 :
77 :
78 :
79 36791 : SwFmtDrop::~SwFmtDrop()
80 : {
81 36791 : }
82 :
83 :
84 :
85 0 : void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
86 : {
87 : // Rewire
88 0 : if ( GetRegisteredIn() )
89 0 : GetRegisteredInNonConst()->Remove( this );
90 0 : if(pNew)
91 0 : pNew->Add( this );
92 0 : nReadFmt = USHRT_MAX;
93 0 : }
94 :
95 :
96 :
97 0 : void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
98 : {
99 0 : if( pDefinedIn )
100 : {
101 0 : if( !pDefinedIn->ISA( SwFmt ))
102 0 : pDefinedIn->ModifyNotification( this, this );
103 0 : else if( pDefinedIn->GetDepends() &&
104 0 : !pDefinedIn->IsModifyLocked() )
105 : {
106 : // Notify those who are dependend on the format on our own.
107 : // The format itself wouldn't pass on the notify as it does not get past the check.
108 0 : pDefinedIn->ModifyBroadcast( this, this );
109 : }
110 : }
111 0 : }
112 :
113 0 : bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
114 : {
115 0 : return true; // Continue
116 : }
117 :
118 0 : int SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
119 : {
120 : OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "No mathing attributes" );
121 0 : return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
122 0 : nChars == ((SwFmtDrop&)rAttr).GetChars() &&
123 0 : nDistance == ((SwFmtDrop&)rAttr).GetDistance() &&
124 0 : bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
125 0 : GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
126 0 : pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
127 : }
128 :
129 17915 : SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
130 : {
131 17915 : return new SwFmtDrop( *this );
132 : }
133 :
134 18 : bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
135 : {
136 18 : switch(nMemberId&~CONVERT_TWIPS)
137 : {
138 0 : case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
139 0 : case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
140 0 : case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
141 : case MID_DROPCAP_FORMAT:
142 : {
143 6 : style::DropCapFormat aDrop;
144 6 : aDrop.Lines = nLines ;
145 6 : aDrop.Count = nChars ;
146 6 : aDrop.Distance = TWIP_TO_MM100_UNSIGNED(nDistance);
147 6 : rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
148 : }
149 6 : break;
150 : case MID_DROPCAP_WHOLE_WORD:
151 6 : rVal.setValue(&bWholeWord, ::getBooleanCppuType());
152 6 : break;
153 : case MID_DROPCAP_CHAR_STYLE_NAME :
154 : {
155 6 : OUString sName;
156 6 : if(GetCharFmt())
157 0 : sName = SwStyleNameMapper::GetProgName(
158 0 : GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
159 6 : rVal <<= sName;
160 : }
161 6 : break;
162 : }
163 18 : return true;
164 : }
165 :
166 0 : bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
167 : {
168 0 : switch(nMemberId&~CONVERT_TWIPS)
169 : {
170 : case MID_DROPCAP_LINES :
171 : {
172 0 : sal_Int8 nTemp = 0;
173 0 : rVal >>= nTemp;
174 0 : if(nTemp >=1 && nTemp < 0x7f)
175 0 : nLines = (sal_uInt8)nTemp;
176 : }
177 0 : break;
178 : case MID_DROPCAP_COUNT :
179 : {
180 0 : sal_Int16 nTemp = 0;
181 0 : rVal >>= nTemp;
182 0 : if(nTemp >=1 && nTemp < 0x7f)
183 0 : nChars = (sal_uInt8)nTemp;
184 : }
185 0 : break;
186 : case MID_DROPCAP_DISTANCE :
187 : {
188 0 : sal_Int16 nVal = 0;
189 0 : if ( rVal >>= nVal )
190 0 : nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
191 : else
192 0 : return false;
193 0 : break;
194 : }
195 : case MID_DROPCAP_FORMAT:
196 : {
197 0 : if(rVal.getValueType() == ::getCppuType((const style::DropCapFormat*)0))
198 : {
199 0 : const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
200 0 : nLines = pDrop->Lines;
201 0 : nChars = pDrop->Count;
202 0 : nDistance = MM100_TO_TWIP(pDrop->Distance);
203 : }
204 : else {
205 : }
206 : }
207 0 : break;
208 : case MID_DROPCAP_WHOLE_WORD:
209 0 : bWholeWord = *(sal_Bool*)rVal.getValue();
210 0 : break;
211 : case MID_DROPCAP_CHAR_STYLE_NAME :
212 : OSL_FAIL("char format cannot be set in PutValue()!");
213 0 : break;
214 : }
215 0 : return true;
216 : }
217 :
218 : /**
219 : * SwRegisterItem
220 : */
221 :
222 3681 : SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
223 : {
224 3681 : return new SwRegisterItem( *this );
225 : }
226 :
227 : /**
228 : * SwNumRuleItem
229 : */
230 571 : SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
231 : {
232 571 : return new SwNumRuleItem( *this );
233 : }
234 4149 : int SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
235 : {
236 : OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "No matching attributes" );
237 :
238 4149 : return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
239 : }
240 :
241 133 : bool SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
242 : {
243 133 : OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
244 133 : rVal <<= sRet;
245 133 : return true;
246 : }
247 :
248 32 : bool SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
249 : {
250 32 : OUString uName;
251 32 : rVal >>= uName;
252 32 : SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
253 32 : return true;
254 : }
255 :
256 2 : SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
257 : {
258 2 : return new SwParaConnectBorderItem( *this );
259 99 : }
260 :
261 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|