Branch data 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 : : #include <tools/urlobj.hxx>
21 : : #include <vcl/msgbox.hxx>
22 : : #include <svl/eitem.hxx>
23 : : #include <vcl/svapp.hxx>
24 : : #include <unotools/localedatawrapper.hxx>
25 : : #include <unotools/cmdoptions.hxx>
26 : : #include <comphelper/processfactory.hxx>
27 : : #include <svl/urihelper.hxx>
28 : : #include <unotools/useroptions.hxx>
29 : : #include <svtools/imagemgr.hxx>
30 : : #include <tools/datetime.hxx>
31 : :
32 : : #include <memory>
33 : :
34 : : #include <comphelper/string.hxx>
35 : : #include <com/sun/star/security/DocumentSignatureInformation.hpp>
36 : : #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
37 : : #include <unotools/syslocale.hxx>
38 : : #include <rtl/math.hxx>
39 : : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
40 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
41 : : #include <com/sun/star/beans/XPropertyContainer.hpp>
42 : : #include <com/sun/star/util/DateTime.hpp>
43 : : #include <com/sun/star/util/Date.hpp>
44 : : #include <com/sun/star/util/Time.hpp>
45 : : #include <com/sun/star/util/Duration.hpp>
46 : : #include <com/sun/star/document/XDocumentProperties.hpp>
47 : :
48 : : #include <vcl/timer.hxx>
49 : : #include "sfx2/dinfdlg.hxx"
50 : : #include "sfx2/securitypage.hxx"
51 : : #include "sfxresid.hxx"
52 : : #include "dinfedt.hxx"
53 : : #include <sfx2/frame.hxx>
54 : : #include <sfx2/viewfrm.hxx>
55 : : #include <sfx2/request.hxx>
56 : : #include <sfx2/passwd.hxx>
57 : : #include <sfx2/filedlghelper.hxx>
58 : : #include "helper.hxx"
59 : : #include <sfx2/objsh.hxx>
60 : : #include <sfx2/docfile.hxx>
61 : : #include <comphelper/storagehelper.hxx>
62 : : #include <comphelper/string.hxx>
63 : :
64 : : #include <sfx2/sfx.hrc>
65 : : #include "dinfdlg.hrc"
66 : : #include "sfxlocal.hrc"
67 : : #include <dialog.hrc>
68 : : #include <vcl/help.hxx>
69 : :
70 : : #include <algorithm>
71 : :
72 : : using namespace ::com::sun::star;
73 : : using namespace ::com::sun::star::lang;
74 : : using namespace ::com::sun::star::ui::dialogs;
75 : : using namespace ::com::sun::star::uno;
76 : :
77 : 0 : struct CustomProperty
78 : : {
79 : : ::rtl::OUString m_sName;
80 : : com::sun::star::uno::Any m_aValue;
81 : :
82 : 0 : CustomProperty( const ::rtl::OUString& sName,
83 : : const com::sun::star::uno::Any& rValue ) :
84 : 0 : m_sName( sName ), m_aValue( rValue ) {}
85 : :
86 : : inline bool operator==( const CustomProperty& rProp )
87 : : { return m_sName.equals( rProp.m_sName ) && m_aValue == rProp.m_aValue; }
88 : : };
89 : :
90 : : static
91 : 0 : bool operator==(const util::DateTime &i_rLeft, const util::DateTime &i_rRight)
92 : : {
93 : : return i_rLeft.Year == i_rRight.Year
94 : : && i_rLeft.Month == i_rRight.Month
95 : : && i_rLeft.Day == i_rRight.Day
96 : : && i_rLeft.Hours == i_rRight.Hours
97 : : && i_rLeft.Minutes == i_rRight.Minutes
98 : : && i_rLeft.Seconds == i_rRight.Seconds
99 [ # # ][ # # ]: 0 : && i_rLeft.HundredthSeconds == i_rRight.HundredthSeconds;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
100 : : }
101 : :
102 : : // STATIC DATA -----------------------------------------------------------
103 [ # # ][ # # ]: 245 : TYPEINIT1_AUTOFACTORY(SfxDocumentInfoItem, SfxStringItem);
[ # # ]
104 : :
105 : : const sal_uInt16 HI_NAME = 1;
106 : : const sal_uInt16 HI_TYPE = 2;
107 : : const sal_uInt16 HI_VALUE = 3;
108 : : const sal_uInt16 HI_ACTION = 4;
109 : :
110 : : static const char DOCUMENT_SIGNATURE_MENU_CMD[] = "Signature";
111 : :
112 : : //------------------------------------------------------------------------
113 : : String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes = sal_True, sal_Bool bSmartExtraBytes = sal_False );
114 : 0 : String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes, sal_Bool bSmartExtraBytes )
115 : : {
116 [ # # ]: 0 : String aUnitStr = rtl::OUString(' ');
117 [ # # ][ # # ]: 0 : aUnitStr += SfxResId(STR_BYTES).toString();
[ # # ]
118 : 0 : sal_uIntPtr nSize1 = nSize;
119 : 0 : sal_uIntPtr nSize2 = nSize1;
120 : 0 : sal_uIntPtr nMega = 1024 * 1024;
121 : 0 : sal_uIntPtr nGiga = nMega * 1024;
122 : 0 : double fSize = nSize;
123 : 0 : int nDec = 0;
124 : 0 : sal_Bool bGB = sal_False;
125 : :
126 [ # # ][ # # ]: 0 : if ( nSize1 >= 10000 && nSize1 < nMega )
127 : : {
128 : 0 : nSize1 /= 1024;
129 [ # # ]: 0 : aUnitStr = ' ';
130 [ # # ][ # # ]: 0 : aUnitStr += SfxResId(STR_KB).toString();
[ # # ]
131 : 0 : fSize /= 1024;
132 : 0 : nDec = 0;
133 : : }
134 [ # # ][ # # ]: 0 : else if ( nSize1 >= nMega && nSize1 < nGiga )
135 : : {
136 : 0 : nSize1 /= nMega;
137 [ # # ]: 0 : aUnitStr = ' ';
138 [ # # ][ # # ]: 0 : aUnitStr += SfxResId(STR_MB).toString();
[ # # ]
139 : 0 : fSize /= nMega;
140 : 0 : nDec = 2;
141 : : }
142 [ # # ]: 0 : else if ( nSize1 >= nGiga )
143 : : {
144 : 0 : nSize1 /= nGiga;
145 [ # # ]: 0 : aUnitStr = ' ';
146 [ # # ][ # # ]: 0 : aUnitStr += SfxResId(STR_GB).toString();
[ # # ]
147 : 0 : bGB = sal_True;
148 : 0 : fSize /= nGiga;
149 : 0 : nDec = 3;
150 : : }
151 [ # # ]: 0 : const SvtSysLocale aSysLocale;
152 [ # # ]: 0 : const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
153 [ # # ][ # # ]: 0 : String aSizeStr( rLocaleWrapper.getNum( nSize1, 0 ) );
154 [ # # ]: 0 : aSizeStr += aUnitStr;
155 [ # # ][ # # ]: 0 : if ( bExtraBytes && ( nSize1 < nSize2 ) )
156 : : {
157 : : aSizeStr = ::rtl::math::doubleToUString( fSize,
158 : : rtl_math_StringFormat_F, nDec,
159 [ # # ][ # # ]: 0 : rLocaleWrapper.getNumDecimalSep()[0] );
160 [ # # ]: 0 : aSizeStr += aUnitStr;
161 : :
162 [ # # ][ # # ]: 0 : aSizeStr += DEFINE_CONST_UNICODE(" (");
[ # # ]
163 [ # # ][ # # ]: 0 : aSizeStr += rLocaleWrapper.getNum( nSize2, 0 );
164 [ # # ]: 0 : aSizeStr += ' ';
165 [ # # ][ # # ]: 0 : aSizeStr += SfxResId(STR_BYTES).toString();
[ # # ]
166 [ # # ]: 0 : aSizeStr += ')';
167 : : }
168 [ # # ][ # # ]: 0 : else if ( bGB && bSmartExtraBytes )
169 : : {
170 : 0 : nSize1 = nSize / nMega;
171 [ # # ][ # # ]: 0 : aSizeStr = DEFINE_CONST_UNICODE(" (");
[ # # ]
172 [ # # ][ # # ]: 0 : aSizeStr += rLocaleWrapper.getNum( nSize1, 0 );
173 [ # # ]: 0 : aSizeStr += aUnitStr;
174 [ # # ]: 0 : aSizeStr += ')';
175 : : }
176 [ # # ][ # # ]: 0 : return aSizeStr;
177 : : }
178 : :
179 : 0 : String ConvertDateTime_Impl( const String& rName,
180 : : const util::DateTime& uDT, const LocaleDataWrapper& rWrapper )
181 : : {
182 : 0 : Date aD(uDT.Day, uDT.Month, uDT.Year);
183 [ # # ]: 0 : Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
184 [ # # ]: 0 : const String pDelim ( DEFINE_CONST_UNICODE( ", "));
185 [ # # ][ # # ]: 0 : String aStr( rWrapper.getDate( aD ) );
186 [ # # ]: 0 : aStr += pDelim;
187 [ # # ][ # # ]: 0 : aStr += rWrapper.getTime( aT, sal_True, sal_False );
188 [ # # ][ # # ]: 0 : rtl::OUString aAuthor = comphelper::string::stripStart(rName, ' ');
189 [ # # ]: 0 : if (!aAuthor.isEmpty())
190 : : {
191 [ # # ]: 0 : aStr += pDelim;
192 [ # # ]: 0 : aStr += aAuthor;
193 : : }
194 [ # # ]: 0 : return aStr;
195 : : }
196 : :
197 : : //------------------------------------------------------------------------
198 : :
199 : 0 : SfxDocumentInfoItem::SfxDocumentInfoItem()
200 : : : SfxStringItem()
201 : : , m_AutoloadDelay(0)
202 : : , m_AutoloadURL()
203 : : , m_isAutoloadEnabled(sal_False)
204 : : , m_DefaultTarget()
205 : : , m_TemplateName()
206 : : , m_Author()
207 : : , m_CreationDate()
208 : : , m_ModifiedBy()
209 : : , m_ModificationDate()
210 : : , m_PrintedBy()
211 : : , m_PrintDate()
212 : : , m_EditingCycles(0)
213 : : , m_EditingDuration(0)
214 : : , m_Description()
215 : : , m_Keywords()
216 : : , m_Subject()
217 : : , m_Title()
218 : : , m_bHasTemplate( sal_True )
219 : : , m_bDeleteUserData( sal_False )
220 [ # # ]: 0 : , m_bUseUserData( sal_True )
221 : : {
222 : 0 : }
223 : :
224 : : //------------------------------------------------------------------------
225 : :
226 : 0 : SfxDocumentInfoItem::SfxDocumentInfoItem( const String& rFile,
227 : : const uno::Reference<document::XDocumentProperties>& i_xDocProps,
228 : : sal_Bool bIs )
229 : : : SfxStringItem( SID_DOCINFO, rFile )
230 [ # # ][ # # ]: 0 : , m_AutoloadDelay( i_xDocProps->getAutoloadSecs() )
231 [ # # ]: 0 : , m_AutoloadURL( i_xDocProps->getAutoloadURL() )
232 : 0 : , m_isAutoloadEnabled( (m_AutoloadDelay > 0) || !m_AutoloadURL.isEmpty() )
233 [ # # ]: 0 : , m_DefaultTarget( i_xDocProps->getDefaultTarget() )
234 [ # # ]: 0 : , m_TemplateName( i_xDocProps->getTemplateName() )
235 [ # # ]: 0 : , m_Author( i_xDocProps->getAuthor() )
236 [ # # ]: 0 : , m_CreationDate( i_xDocProps->getCreationDate() )
237 [ # # ]: 0 : , m_ModifiedBy( i_xDocProps->getModifiedBy() )
238 [ # # ]: 0 : , m_ModificationDate( i_xDocProps->getModificationDate() )
239 [ # # ]: 0 : , m_PrintedBy( i_xDocProps->getPrintedBy() )
240 [ # # ]: 0 : , m_PrintDate( i_xDocProps->getPrintDate() )
241 [ # # ][ # # ]: 0 : , m_EditingCycles( i_xDocProps->getEditingCycles() )
242 [ # # ][ # # ]: 0 : , m_EditingDuration( i_xDocProps->getEditingDuration() )
243 [ # # ]: 0 : , m_Description( i_xDocProps->getDescription() )
244 : : , m_Keywords( ::comphelper::string::convertCommaSeparated(
245 [ # # ]: 0 : i_xDocProps->getKeywords()) )
246 [ # # ]: 0 : , m_Subject( i_xDocProps->getSubject() )
247 [ # # ]: 0 : , m_Title( i_xDocProps->getTitle() )
248 : : , m_bHasTemplate( sal_True )
249 : : , m_bDeleteUserData( sal_False )
250 [ # # ]: 0 : , m_bUseUserData( bIs )
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
251 : : {
252 : : try
253 : : {
254 [ # # ][ # # ]: 0 : Reference< beans::XPropertyContainer > xContainer = i_xDocProps->getUserDefinedProperties();
255 [ # # ]: 0 : if ( xContainer.is() )
256 : : {
257 [ # # ]: 0 : Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY );
258 [ # # ][ # # ]: 0 : const Sequence< beans::Property > lProps = xSet->getPropertySetInfo()->getProperties();
[ # # ][ # # ]
259 : 0 : const beans::Property* pProps = lProps.getConstArray();
260 : 0 : sal_Int32 nCount = lProps.getLength();
261 [ # # ]: 0 : for ( sal_Int32 i = 0; i < nCount; ++i )
262 : : {
263 : : // "fix" property? => not a custom property => ignore it!
264 [ # # ]: 0 : if (!(pProps[i].Attributes &
265 : 0 : ::com::sun::star::beans::PropertyAttribute::REMOVABLE))
266 : : {
267 : : DBG_ASSERT(false, "non-removable user-defined property?");
268 : 0 : continue;
269 : : }
270 : :
271 [ # # ][ # # ]: 0 : uno::Any aValue = xSet->getPropertyValue(pProps[i].Name);
272 [ # # ]: 0 : CustomProperty* pProp = new CustomProperty( pProps[i].Name, aValue );
273 [ # # ]: 0 : m_aCustomProperties.push_back( pProp );
274 [ # # ]: 0 : }
275 [ # # ]: 0 : }
276 : : }
277 [ # # ]: 0 : catch ( Exception& ) {}
278 : 0 : }
279 : :
280 : : //------------------------------------------------------------------------
281 : :
282 : 0 : SfxDocumentInfoItem::SfxDocumentInfoItem( const SfxDocumentInfoItem& rItem )
283 : : : SfxStringItem( rItem )
284 : 0 : , m_AutoloadDelay( rItem.getAutoloadDelay() )
285 : : , m_AutoloadURL( rItem.getAutoloadURL() )
286 : 0 : , m_isAutoloadEnabled( rItem.isAutoloadEnabled() )
287 : : , m_DefaultTarget( rItem.getDefaultTarget() )
288 : : , m_TemplateName( rItem.getTemplateName() )
289 : : , m_Author( rItem.getAuthor() )
290 : : , m_CreationDate( rItem.getCreationDate() )
291 : : , m_ModifiedBy( rItem.getModifiedBy() )
292 : : , m_ModificationDate( rItem.getModificationDate() )
293 : : , m_PrintedBy( rItem.getPrintedBy() )
294 : : , m_PrintDate( rItem.getPrintDate() )
295 : 0 : , m_EditingCycles( rItem.getEditingCycles() )
296 : 0 : , m_EditingDuration( rItem.getEditingDuration() )
297 : : , m_Description( rItem.getDescription() )
298 : : , m_Keywords( rItem.getKeywords() )
299 : : , m_Subject( rItem.getSubject() )
300 : : , m_Title( rItem.getTitle() )
301 : : , m_bHasTemplate( rItem.m_bHasTemplate )
302 : : , m_bDeleteUserData( rItem.m_bDeleteUserData )
303 [ # # ]: 0 : , m_bUseUserData( rItem.m_bUseUserData )
304 : : {
305 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < rItem.m_aCustomProperties.size(); i++ )
306 : : {
307 : 0 : CustomProperty* pProp = new CustomProperty( rItem.m_aCustomProperties[i]->m_sName,
308 [ # # ]: 0 : rItem.m_aCustomProperties[i]->m_aValue );
309 [ # # ]: 0 : m_aCustomProperties.push_back( pProp );
310 : : }
311 : 0 : }
312 : :
313 : : //------------------------------------------------------------------------
314 : 0 : SfxDocumentInfoItem::~SfxDocumentInfoItem()
315 : : {
316 [ # # ]: 0 : ClearCustomProperties();
317 [ # # ]: 0 : }
318 : :
319 : : //------------------------------------------------------------------------
320 : 0 : SfxPoolItem* SfxDocumentInfoItem::Clone( SfxItemPool * ) const
321 : : {
322 [ # # ]: 0 : return new SfxDocumentInfoItem( *this );
323 : : }
324 : :
325 : : //------------------------------------------------------------------------
326 : 0 : int SfxDocumentInfoItem::operator==( const SfxPoolItem& rItem) const
327 : : {
328 [ # # ][ # # ]: 0 : if (!(rItem.Type() == Type() && SfxStringItem::operator==(rItem)))
[ # # ]
329 : 0 : return false;
330 : 0 : const SfxDocumentInfoItem& rInfoItem(static_cast<const SfxDocumentInfoItem&>(rItem));
331 : :
332 : : return
333 : : m_AutoloadDelay == rInfoItem.m_AutoloadDelay &&
334 : 0 : m_AutoloadURL == rInfoItem.m_AutoloadURL &&
335 : : m_isAutoloadEnabled == rInfoItem.m_isAutoloadEnabled &&
336 : 0 : m_DefaultTarget == rInfoItem.m_DefaultTarget &&
337 : 0 : m_Author == rInfoItem.m_Author &&
338 : 0 : m_CreationDate == rInfoItem.m_CreationDate &&
339 : 0 : m_ModifiedBy == rInfoItem.m_ModifiedBy &&
340 : 0 : m_ModificationDate == rInfoItem.m_ModificationDate &&
341 : 0 : m_PrintedBy == rInfoItem.m_PrintedBy &&
342 : 0 : m_PrintDate == rInfoItem.m_PrintDate &&
343 : : m_EditingCycles == rInfoItem.m_EditingCycles &&
344 : : m_EditingDuration == rInfoItem.m_EditingDuration &&
345 : 0 : m_Description == rInfoItem.m_Description &&
346 : 0 : m_Keywords == rInfoItem.m_Keywords &&
347 : 0 : m_Subject == rInfoItem.m_Subject &&
348 : 0 : m_Title == rInfoItem.m_Title &&
349 : 0 : m_aCustomProperties.size() == rInfoItem.m_aCustomProperties.size() &&
350 : : std::equal(m_aCustomProperties.begin(), m_aCustomProperties.end(),
351 [ # # # # ]: 0 : rInfoItem.m_aCustomProperties.begin());
[ # # # #
# # # # #
# # # # #
# # ][ # # ]
[ # # # #
# # # # #
# # # ]
[ # # ]
352 : : }
353 : :
354 : : //------------------------------------------------------------------------
355 : 0 : void SfxDocumentInfoItem::resetUserData(const ::rtl::OUString & i_rAuthor)
356 : : {
357 : 0 : setAuthor(i_rAuthor);
358 [ # # ]: 0 : DateTime now( DateTime::SYSTEM );
359 : : setCreationDate( util::DateTime(
360 : 0 : now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
361 : 0 : now.GetDay(), now.GetMonth(), now.GetYear() ) );
362 : 0 : setModifiedBy(::rtl::OUString());
363 : 0 : setPrintedBy(::rtl::OUString());
364 : 0 : setModificationDate(util::DateTime());
365 : 0 : setPrintDate(util::DateTime());
366 : 0 : setEditingDuration(0);
367 : 0 : setEditingCycles(1);
368 : 0 : }
369 : :
370 : : //------------------------------------------------------------------------
371 : 0 : void SfxDocumentInfoItem::UpdateDocumentInfo(
372 : : const uno::Reference<document::XDocumentProperties>& i_xDocProps,
373 : : bool i_bDoNotUpdateUserDefined) const
374 : : {
375 [ # # ]: 0 : if (isAutoloadEnabled()) {
376 : 0 : i_xDocProps->setAutoloadSecs(getAutoloadDelay());
377 [ # # ]: 0 : i_xDocProps->setAutoloadURL(getAutoloadURL());
378 : : } else {
379 : 0 : i_xDocProps->setAutoloadSecs(0);
380 [ # # ]: 0 : i_xDocProps->setAutoloadURL(::rtl::OUString());
381 : : }
382 [ # # ]: 0 : i_xDocProps->setDefaultTarget(getDefaultTarget());
383 [ # # ]: 0 : i_xDocProps->setAuthor(getAuthor());
384 [ # # ]: 0 : i_xDocProps->setCreationDate(getCreationDate());
385 [ # # ]: 0 : i_xDocProps->setModifiedBy(getModifiedBy());
386 [ # # ]: 0 : i_xDocProps->setModificationDate(getModificationDate());
387 [ # # ]: 0 : i_xDocProps->setPrintedBy(getPrintedBy());
388 [ # # ]: 0 : i_xDocProps->setPrintDate(getPrintDate());
389 : 0 : i_xDocProps->setEditingCycles(getEditingCycles());
390 : 0 : i_xDocProps->setEditingDuration(getEditingDuration());
391 [ # # ]: 0 : i_xDocProps->setDescription(getDescription());
392 : 0 : i_xDocProps->setKeywords(
393 [ # # ][ # # ]: 0 : ::comphelper::string::convertCommaSeparated(getKeywords()));
[ # # ]
394 [ # # ]: 0 : i_xDocProps->setSubject(getSubject());
395 [ # # ][ # # ]: 0 : i_xDocProps->setTitle(getTitle());
396 : :
397 : : // this is necessary in case of replaying a recorded macro:
398 : : // in this case, the macro may contain the 4 old user-defined DocumentInfo
399 : : // fields, but not any of the DocumentInfo properties;
400 : : // as a consequence, most of the UserDefined properties of the
401 : : // DocumentProperties would be summarily deleted here, which does not
402 : : // seem like a good idea.
403 [ # # ]: 0 : if (i_bDoNotUpdateUserDefined)
404 : 0 : return;
405 : :
406 : : try
407 : : {
408 [ # # ][ # # ]: 0 : Reference< beans::XPropertyContainer > xContainer = i_xDocProps->getUserDefinedProperties();
409 [ # # ]: 0 : Reference < beans::XPropertySet > xSet( xContainer, UNO_QUERY );
410 [ # # ][ # # ]: 0 : Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo();
411 [ # # ][ # # ]: 0 : const Sequence< beans::Property > lProps = xSetInfo->getProperties();
412 : 0 : const beans::Property* pProps = lProps.getConstArray();
413 : 0 : sal_Int32 nCount = lProps.getLength();
414 [ # # ]: 0 : for ( sal_Int32 j = 0; j < nCount; ++j )
415 : : {
416 [ # # ]: 0 : if ((pProps[j].Attributes &
417 : : ::com::sun::star::beans::PropertyAttribute::REMOVABLE))
418 : : {
419 [ # # ][ # # ]: 0 : xContainer->removeProperty( pProps[j].Name );
420 : : }
421 : : }
422 : :
423 [ # # ]: 0 : for ( sal_uInt32 k = 0; k < m_aCustomProperties.size(); ++k )
424 : : {
425 : : try
426 : : {
427 [ # # ]: 0 : xContainer->addProperty( m_aCustomProperties[k]->m_sName,
428 [ # # ]: 0 : beans::PropertyAttribute::REMOVABLE, m_aCustomProperties[k]->m_aValue );
429 : : }
430 [ # # ]: 0 : catch ( Exception& )
431 : : {
432 : : SAL_WARN( "sfx2.dialog", "SfxDocumentInfoItem::updateDocumentInfo(): exception while adding custom properties" );
433 : : }
434 [ # # ][ # # ]: 0 : }
435 : : }
436 : 0 : catch ( Exception& )
437 : : {
438 : : SAL_WARN( "sfx2.dialog", "SfxDocumentInfoItem::updateDocumentInfo(): exception while removing custom properties" );
439 : : }
440 : : }
441 : :
442 : : //------------------------------------------------------------------------
443 : 0 : sal_Bool SfxDocumentInfoItem::IsDeleteUserData() const
444 : : {
445 : 0 : return m_bDeleteUserData;
446 : : }
447 : :
448 : 0 : void SfxDocumentInfoItem::SetDeleteUserData( sal_Bool bSet )
449 : : {
450 : 0 : m_bDeleteUserData = bSet;
451 : 0 : }
452 : :
453 : 0 : sal_Bool SfxDocumentInfoItem::IsUseUserData() const
454 : : {
455 : 0 : return m_bUseUserData;
456 : : }
457 : :
458 : 0 : void SfxDocumentInfoItem::SetUseUserData( sal_Bool bSet )
459 : : {
460 : 0 : m_bUseUserData = bSet;
461 : 0 : }
462 : :
463 : 0 : std::vector< CustomProperty* > SfxDocumentInfoItem::GetCustomProperties() const
464 : : {
465 : 0 : std::vector< CustomProperty* > aRet;
466 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < m_aCustomProperties.size(); i++ )
467 : : {
468 : 0 : CustomProperty* pProp = new CustomProperty( m_aCustomProperties[i]->m_sName,
469 [ # # ]: 0 : m_aCustomProperties[i]->m_aValue );
470 [ # # ]: 0 : aRet.push_back( pProp );
471 : : }
472 : :
473 : 0 : return aRet;
474 : : }
475 : :
476 : 0 : void SfxDocumentInfoItem::ClearCustomProperties()
477 : : {
478 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < m_aCustomProperties.size(); i++ )
479 [ # # ]: 0 : delete m_aCustomProperties[i];
480 : 0 : m_aCustomProperties.clear();
481 : 0 : }
482 : :
483 : 0 : void SfxDocumentInfoItem::AddCustomProperty( const ::rtl::OUString& sName, const Any& rValue )
484 : : {
485 [ # # ]: 0 : CustomProperty* pProp = new CustomProperty( sName, rValue );
486 [ # # ]: 0 : m_aCustomProperties.push_back( pProp );
487 : 0 : }
488 : :
489 : 0 : bool SfxDocumentInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const
490 : : {
491 [ # # ]: 0 : String aValue;
492 : 0 : sal_Int32 nValue = 0;
493 : 0 : sal_Bool bValue = sal_False;
494 : 0 : sal_Bool bIsInt = sal_False;
495 : 0 : sal_Bool bIsString = sal_False;
496 : 0 : nMemberId &= ~CONVERT_TWIPS;
497 [ # # # # : 0 : switch ( nMemberId )
# # # # #
# # ]
498 : : {
499 : : case MID_DOCINFO_USEUSERDATA:
500 [ # # ]: 0 : bValue = IsUseUserData();
501 : 0 : break;
502 : : case MID_DOCINFO_DELETEUSERDATA:
503 [ # # ]: 0 : bValue = IsDeleteUserData();
504 : 0 : break;
505 : : case MID_DOCINFO_AUTOLOADENABLED:
506 : 0 : bValue = isAutoloadEnabled();
507 : 0 : break;
508 : : case MID_DOCINFO_AUTOLOADSECS:
509 : 0 : bIsInt = sal_True;
510 : 0 : nValue = getAutoloadDelay();
511 : 0 : break;
512 : : case MID_DOCINFO_AUTOLOADURL:
513 : 0 : bIsString = sal_True;
514 [ # # ]: 0 : aValue = getAutoloadURL();
515 : 0 : break;
516 : : case MID_DOCINFO_DEFAULTTARGET:
517 : 0 : bIsString = sal_True;
518 [ # # ]: 0 : aValue = getDefaultTarget();
519 : 0 : break;
520 : : case MID_DOCINFO_DESCRIPTION:
521 : 0 : bIsString = sal_True;
522 [ # # ]: 0 : aValue = getDescription();
523 : 0 : break;
524 : : case MID_DOCINFO_KEYWORDS:
525 : 0 : bIsString = sal_True;
526 [ # # ]: 0 : aValue = getKeywords();
527 : 0 : break;
528 : : case MID_DOCINFO_SUBJECT:
529 : 0 : bIsString = sal_True;
530 [ # # ]: 0 : aValue = getSubject();
531 : 0 : break;
532 : : case MID_DOCINFO_TITLE:
533 : 0 : bIsString = sal_True;
534 [ # # ]: 0 : aValue = getTitle();
535 : 0 : break;
536 : : default:
537 : : OSL_FAIL("Wrong MemberId!");
538 : 0 : return sal_False;
539 : : }
540 : :
541 [ # # ]: 0 : if ( bIsString )
542 [ # # ][ # # ]: 0 : rVal <<= ::rtl::OUString( aValue );
543 [ # # ]: 0 : else if ( bIsInt )
544 [ # # ]: 0 : rVal <<= nValue;
545 : : else
546 [ # # ]: 0 : rVal <<= bValue;
547 [ # # ]: 0 : return true;
548 : : }
549 : :
550 : 0 : bool SfxDocumentInfoItem::PutValue( const Any& rVal, sal_uInt8 nMemberId )
551 : : {
552 : 0 : ::rtl::OUString aValue;
553 : 0 : sal_Int32 nValue=0;
554 : 0 : sal_Bool bValue = sal_False;
555 : 0 : bool bRet = false;
556 : 0 : nMemberId &= ~CONVERT_TWIPS;
557 [ # # # # : 0 : switch ( nMemberId )
# # # # #
# # ]
558 : : {
559 : : case MID_DOCINFO_USEUSERDATA:
560 : 0 : bRet = (rVal >>= bValue);
561 [ # # ]: 0 : if ( bRet )
562 [ # # ]: 0 : SetUseUserData( bValue );
563 : 0 : break;
564 : : case MID_DOCINFO_DELETEUSERDATA:
565 : : // QUESTION: deleting user data was done here; seems to be superfluous!
566 : 0 : bRet = (rVal >>= bValue);
567 [ # # ]: 0 : if ( bRet )
568 [ # # ]: 0 : SetDeleteUserData( bValue );
569 : 0 : break;
570 : : case MID_DOCINFO_AUTOLOADENABLED:
571 : 0 : bRet = (rVal >>= bValue);
572 [ # # ]: 0 : if ( bRet )
573 : 0 : setAutoloadEnabled(bValue);
574 : 0 : break;
575 : : case MID_DOCINFO_AUTOLOADSECS:
576 : 0 : bRet = (rVal >>= nValue);
577 [ # # ]: 0 : if ( bRet )
578 : 0 : setAutoloadDelay(nValue);
579 : 0 : break;
580 : : case MID_DOCINFO_AUTOLOADURL:
581 : 0 : bRet = (rVal >>= aValue);
582 [ # # ]: 0 : if ( bRet )
583 : 0 : setAutoloadURL(aValue);
584 : 0 : break;
585 : : case MID_DOCINFO_DEFAULTTARGET:
586 : 0 : bRet = (rVal >>= aValue);
587 [ # # ]: 0 : if ( bRet )
588 : 0 : setDefaultTarget(aValue);
589 : 0 : break;
590 : : case MID_DOCINFO_DESCRIPTION:
591 : 0 : bRet = (rVal >>= aValue);
592 [ # # ]: 0 : if ( bRet )
593 : 0 : setDescription(aValue);
594 : 0 : break;
595 : : case MID_DOCINFO_KEYWORDS:
596 : 0 : bRet = (rVal >>= aValue);
597 [ # # ]: 0 : if ( bRet )
598 : 0 : setKeywords(aValue);
599 : 0 : break;
600 : : case MID_DOCINFO_SUBJECT:
601 : 0 : bRet = (rVal >>= aValue);
602 [ # # ]: 0 : if ( bRet )
603 : 0 : setSubject(aValue);
604 : 0 : break;
605 : : case MID_DOCINFO_TITLE:
606 : 0 : bRet = (rVal >>= aValue);
607 [ # # ]: 0 : if ( bRet )
608 : 0 : setTitle(aValue);
609 : 0 : break;
610 : : default:
611 : : OSL_FAIL("Wrong MemberId!");
612 : 0 : return false;
613 : : }
614 : :
615 : 0 : return bRet;
616 : : }
617 : :
618 : : //------------------------------------------------------------------------
619 : 0 : SfxDocumentDescPage::SfxDocumentDescPage( Window * pParent, const SfxItemSet& rItemSet ) :
620 : :
621 : : SfxTabPage( pParent, SfxResId( TP_DOCINFODESC ), rItemSet ),
622 : :
623 : : aTitleFt ( this, SfxResId( FT_TITLE ) ),
624 : : aTitleEd ( this, SfxResId( ED_TITLE ) ),
625 : : aThemaFt ( this, SfxResId( FT_THEMA ) ),
626 : : aThemaEd ( this, SfxResId( ED_THEMA ) ),
627 : : aKeywordsFt ( this, SfxResId( FT_KEYWORDS ) ),
628 : : aKeywordsEd ( this, SfxResId( ED_KEYWORDS ) ),
629 : : aCommentFt ( this, SfxResId( FT_COMMENT ) ),
630 : : aCommentEd ( this, SfxResId( ED_COMMENT ) ),
631 : :
632 [ # # ][ # # ]: 0 : pInfoItem ( NULL )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
633 : :
634 : : {
635 [ # # ]: 0 : FreeResource();
636 : 0 : }
637 : :
638 : : //------------------------------------------------------------------------
639 : 0 : SfxTabPage *SfxDocumentDescPage::Create(Window *pParent, const SfxItemSet &rItemSet)
640 : : {
641 [ # # ]: 0 : return new SfxDocumentDescPage(pParent, rItemSet);
642 : : }
643 : :
644 : : //------------------------------------------------------------------------
645 : 0 : sal_Bool SfxDocumentDescPage::FillItemSet(SfxItemSet &rSet)
646 : : {
647 : : // Test whether a change is present
648 : 0 : const sal_Bool bTitleMod = aTitleEd.IsModified();
649 : 0 : const sal_Bool bThemeMod = aThemaEd.IsModified();
650 : 0 : const sal_Bool bKeywordsMod = aKeywordsEd.IsModified();
651 [ # # ]: 0 : const sal_Bool bCommentMod = aCommentEd.IsModified();
652 [ # # ][ # # ]: 0 : if ( !( bTitleMod || bThemeMod || bKeywordsMod || bCommentMod ) )
[ # # ][ # # ]
653 : : {
654 : 0 : return sal_False;
655 : : }
656 : :
657 : : // Generating the output data
658 : 0 : const SfxPoolItem* pItem = NULL;
659 : 0 : SfxDocumentInfoItem* pInfo = NULL;
660 : 0 : SfxTabDialog* pDlg = GetTabDialog();
661 : 0 : const SfxItemSet* pExSet = NULL;
662 : :
663 [ # # ]: 0 : if ( pDlg )
664 : 0 : pExSet = pDlg->GetExampleSet();
665 : :
666 [ # # ][ # # ]: 0 : if ( pExSet && SFX_ITEM_SET != pExSet->GetItemState( SID_DOCINFO, sal_True, &pItem ) )
[ # # ][ # # ]
667 : 0 : pInfo = pInfoItem;
668 [ # # ]: 0 : else if ( pItem )
669 [ # # ][ # # ]: 0 : pInfo = new SfxDocumentInfoItem( *(const SfxDocumentInfoItem *)pItem );
670 : :
671 [ # # ]: 0 : if ( !pInfo )
672 : : {
673 : : SAL_WARN( "sfx2.dialog", "SfxDocumentDescPage::FillItemSet(): no item found" );
674 : 0 : return sal_False;
675 : : }
676 : :
677 [ # # ]: 0 : if ( bTitleMod )
678 : : {
679 [ # # ][ # # ]: 0 : pInfo->setTitle( aTitleEd.GetText() );
[ # # ]
680 : : }
681 [ # # ]: 0 : if ( bThemeMod )
682 : : {
683 [ # # ][ # # ]: 0 : pInfo->setSubject( aThemaEd.GetText() );
[ # # ]
684 : : }
685 [ # # ]: 0 : if ( bKeywordsMod )
686 : : {
687 [ # # ][ # # ]: 0 : pInfo->setKeywords( aKeywordsEd.GetText() );
[ # # ]
688 : : }
689 [ # # ]: 0 : if ( bCommentMod )
690 : : {
691 [ # # ][ # # ]: 0 : pInfo->setDescription( aCommentEd.GetText() );
[ # # ]
692 : : }
693 [ # # ][ # # ]: 0 : rSet.Put( SfxDocumentInfoItem( *pInfo ) );
[ # # ]
694 [ # # ]: 0 : if ( pInfo != pInfoItem )
695 : : {
696 [ # # ][ # # ]: 0 : delete pInfo;
697 : : }
698 : :
699 : 0 : return sal_True;
700 : : }
701 : :
702 : : //------------------------------------------------------------------------
703 : 0 : void SfxDocumentDescPage::Reset(const SfxItemSet &rSet)
704 : : {
705 : 0 : pInfoItem = &(SfxDocumentInfoItem &)rSet.Get(SID_DOCINFO);
706 : :
707 [ # # ][ # # ]: 0 : aTitleEd.SetText( pInfoItem->getTitle() );
[ # # ]
708 [ # # ][ # # ]: 0 : aThemaEd.SetText( pInfoItem->getSubject() );
[ # # ]
709 [ # # ][ # # ]: 0 : aKeywordsEd.SetText( pInfoItem->getKeywords() );
[ # # ]
710 [ # # ][ # # ]: 0 : aCommentEd.SetText( pInfoItem->getDescription() );
[ # # ]
711 : :
712 : 0 : SFX_ITEMSET_ARG( &rSet, pROItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
713 [ # # ][ # # ]: 0 : if ( pROItem && pROItem->GetValue() )
[ # # ]
714 : : {
715 : 0 : aTitleEd.SetReadOnly( sal_True );
716 : 0 : aThemaEd.SetReadOnly( sal_True );
717 : 0 : aKeywordsEd.SetReadOnly( sal_True );
718 : 0 : aCommentEd.SetReadOnly( sal_True );
719 : : }
720 : 0 : }
721 : :
722 : : //------------------------------------------------------------------------
723 : : namespace
724 : : {
725 : 0 : String GetDateTimeString( sal_Int32 _nDate, sal_Int32 _nTime )
726 : : {
727 [ # # ][ # # ]: 0 : LocaleDataWrapper aWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
[ # # ][ # # ]
728 : :
729 : 0 : Date aDate( _nDate );
730 : 0 : Time aTime( _nTime );
731 [ # # ][ # # ]: 0 : String aStr( aWrapper.getDate( aDate ) );
732 [ # # ]: 0 : aStr.AppendAscii( ", " );
733 [ # # ][ # # ]: 0 : aStr += aWrapper.getTime( aTime );
734 [ # # ]: 0 : return aStr;
735 : : }
736 : :
737 : : // copy from xmlsecurity/source/dialog/resourcemanager.cxx
738 : 0 : String GetContentPart( const String& _rRawString, const String& _rPartId )
739 : : {
740 : 0 : String s;
741 : :
742 [ # # ]: 0 : xub_StrLen nContStart = _rRawString.Search( _rPartId );
743 [ # # ]: 0 : if ( nContStart != STRING_NOTFOUND )
744 : : {
745 : 0 : nContStart = nContStart + _rPartId.Len();
746 : 0 : ++nContStart; // now it's start of content, directly after Id
747 : :
748 [ # # ]: 0 : xub_StrLen nContEnd = _rRawString.Search( sal_Unicode( ',' ), nContStart );
749 : :
750 [ # # ][ # # ]: 0 : s = String( _rRawString, nContStart, nContEnd - nContStart );
[ # # ]
751 : : }
752 : :
753 : 0 : return s;
754 : : }
755 : : }
756 : :
757 : 0 : SfxDocumentPage::SfxDocumentPage( Window* pParent, const SfxItemSet& rItemSet ) :
758 : :
759 : : SfxTabPage( pParent, SfxResId( TP_DOCINFODOC ), rItemSet ),
760 : :
761 : : aBmp1 ( this, SfxResId( BMP_FILE_1 ) ),
762 : : aNameED ( this, SfxResId( ED_FILE_NAME ) ),
763 : : aChangePassBtn ( this, SfxResId( BTN_CHANGE_PASS ) ),
764 : :
765 : : aLine1FL ( this, SfxResId( FL_FILE_1 ) ),
766 : : aTypeFT ( this, SfxResId( FT_FILE_TYP ) ),
767 : : aShowTypeFT ( this, SfxResId( FT_FILE_SHOW_TYP ) ),
768 : : aReadOnlyCB ( this, SfxResId( CB_FILE_READONLY ) ),
769 : : aFileFt ( this, SfxResId( FT_FILE ) ),
770 : : aFileValFt ( this, SfxResId( FT_FILE_VAL ) ),
771 : : aSizeFT ( this, SfxResId( FT_FILE_SIZE ) ),
772 : : aShowSizeFT ( this, SfxResId( FT_FILE_SHOW_SIZE ) ),
773 : :
774 : : aLine2FL ( this, SfxResId( FL_FILE_2 ) ),
775 : : aCreateFt ( this, SfxResId( FT_CREATE ) ),
776 : : aCreateValFt ( this, SfxResId( FT_CREATE_VAL ) ),
777 : : aChangeFt ( this, SfxResId( FT_CHANGE ) ),
778 : : aChangeValFt ( this, SfxResId( FT_CHANGE_VAL ) ),
779 : : aSignedFt ( this, SfxResId( FT_SIGNED ) ),
780 : : aSignedValFt ( this, SfxResId( FT_SIGNED_VAL ) ),
781 : : aSignatureBtn ( this, SfxResId( BTN_SIGNATURE ) ),
782 : : aPrintFt ( this, SfxResId( FT_PRINT ) ),
783 : : aPrintValFt ( this, SfxResId( FT_PRINT_VAL ) ),
784 : : aTimeLogFt ( this, SfxResId( FT_TIMELOG ) ),
785 : : aTimeLogValFt ( this, SfxResId( FT_TIMELOG_VAL ) ),
786 : : aDocNoFt ( this, SfxResId( FT_DOCNO ) ),
787 : : aDocNoValFt ( this, SfxResId( FT_DOCNO_VAL ) ),
788 : : aUseUserDataCB ( this, SfxResId( CB_USE_USERDATA ) ),
789 : : aDeleteBtn ( this, SfxResId( BTN_DELETE ) ),
790 : :
791 : : aLine3FL ( this, SfxResId( FL_FILE_3 ) ),
792 : : aTemplFt ( this, SfxResId( FT_TEMPL ) ),
793 : : aTemplValFt ( this, SfxResId( FT_TEMPL_VAL ) ),
794 : :
795 : : aUnknownSize ( SfxResId( STR_UNKNOWNSIZE ).toString() ),
796 : : aMultiSignedStr ( SfxResId( STR_MULTSIGNED ).toString() ),
797 : :
798 : : bEnableUseUserData ( sal_False ),
799 [ # # ][ # # ]: 0 : bHandleDelete ( sal_False )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
800 : :
801 : : {
802 [ # # ][ # # ]: 0 : aNameED.SetAccessibleName( SfxResId( EDIT_FILE_NAME ).toString() );
[ # # ][ # # ]
[ # # ]
803 [ # # ]: 0 : FreeResource();
804 [ # # ]: 0 : ImplUpdateSignatures();
805 [ # # ]: 0 : ImplCheckPasswordState();
806 [ # # ]: 0 : aChangePassBtn.SetClickHdl( LINK( this, SfxDocumentPage, ChangePassHdl ) );
807 [ # # ]: 0 : aSignatureBtn.SetClickHdl( LINK( this, SfxDocumentPage, SignatureHdl ) );
808 [ # # ]: 0 : aDeleteBtn.SetClickHdl( LINK( this, SfxDocumentPage, DeleteHdl ) );
809 : :
810 : : // Get the max size needed for the 'Change Password', 'Signature' and 'Delete' buttons
811 : : // and set their size according to this max size to get perfect aligment
812 [ # # ][ # # ]: 0 : long nTxtW = ( aChangePassBtn.GetTextWidth( aChangePassBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH );
[ # # ]
813 [ # # ][ # # ]: 0 : nTxtW = Max( ( aSignatureBtn.GetTextWidth( aSignatureBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH ), nTxtW);
[ # # ]
814 [ # # ][ # # ]: 0 : nTxtW = Max( ( aDeleteBtn.GetTextWidth( aDeleteBtn.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH ), nTxtW);
[ # # ]
815 : :
816 : : // New size and position for the 'Change Password' button
817 [ # # ]: 0 : Size aNewSize = aChangePassBtn.GetSizePixel();
818 : 0 : long nDelta = nTxtW - aNewSize.Width();
819 : 0 : aNewSize.Width() = nTxtW;
820 [ # # ]: 0 : aChangePassBtn.SetSizePixel( aNewSize );
821 [ # # ]: 0 : Point aNewPos = aChangePassBtn.GetPosPixel();
822 : 0 : aNewPos.X() -= nDelta;
823 [ # # ]: 0 : aChangePassBtn.SetPosPixel( aNewPos );
824 : :
825 : : // Calculate the space between the bmp image and the 'Change password' button
826 : 0 : nDelta = aNewPos.X() - IMPL_EXTRA_BUTTON_WIDTH / 2 \
827 [ # # ][ # # ]: 0 : - ( aBmp1.GetPosPixel().X() + aBmp1.GetSizePixel().Width() );
828 : :
829 : : // Reduces the filename field size if space size is not large enough
830 [ # # ]: 0 : aNewSize = aNameED.GetSizePixel();
831 [ # # ]: 0 : if ( nDelta - aNewSize.Width() < IMPL_EXTRA_BUTTON_WIDTH )
832 : : {
833 : 0 : aNewSize.Width() -= IMPL_EXTRA_BUTTON_WIDTH - ( nDelta - aNewSize.Width() );
834 [ # # ]: 0 : aNameED.SetSizePixel( aNewSize );
835 : : }
836 : :
837 : : // Centers the filename field in the space
838 [ # # ]: 0 : aNewPos = aNameED.GetPosPixel();
839 : 0 : nDelta -= aNewSize.Width();
840 [ # # ][ # # ]: 0 : aNewPos.X() = aBmp1.GetPosPixel().X() + aBmp1.GetSizePixel().Width() + nDelta / 2;
841 [ # # ]: 0 : aNameED.SetPosPixel( aNewPos );
842 : :
843 : : // New size and position for the 'Signature' button
844 [ # # ]: 0 : aNewSize = aSignatureBtn.GetSizePixel();
845 : 0 : nDelta = nTxtW - aNewSize.Width();
846 : 0 : aNewSize.Width() = nTxtW;
847 [ # # ]: 0 : aSignatureBtn.SetSizePixel( aNewSize );
848 [ # # ]: 0 : aNewPos = aSignatureBtn.GetPosPixel();
849 : 0 : aNewPos.X() -= nDelta;
850 [ # # ]: 0 : aSignatureBtn.SetPosPixel( aNewPos );
851 : :
852 : : // New size for the signature field
853 [ # # ]: 0 : aNewSize = aSignedValFt.GetSizePixel();
854 : 0 : aNewSize.Width() -= nDelta;
855 [ # # ]: 0 : aSignedValFt.SetSizePixel( aNewSize );
856 : :
857 : : // New size and position for the 'Delete' button
858 [ # # ]: 0 : aNewSize = aDeleteBtn.GetSizePixel();
859 : 0 : nDelta = nTxtW - aNewSize.Width();
860 : 0 : aNewSize.Width() = nTxtW;
861 [ # # ]: 0 : aDeleteBtn.SetSizePixel( aNewSize );
862 [ # # ]: 0 : aNewPos = aDeleteBtn.GetPosPixel();
863 : 0 : aNewPos.X() -= nDelta;
864 [ # # ]: 0 : aDeleteBtn.SetPosPixel( aNewPos );
865 : :
866 : : // [i96288] Check if the document signature command is enabled
867 : : // on the main list enable/disable the pushbutton accordingly
868 [ # # ]: 0 : SvtCommandOptions aCmdOptions;
869 [ # # ]: 0 : if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,
870 [ # # ][ # # ]: 0 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( DOCUMENT_SIGNATURE_MENU_CMD ) ) ) )
871 [ # # ][ # # ]: 0 : aSignatureBtn.Disable();
872 : 0 : }
873 : :
874 : : //------------------------------------------------------------------------
875 : :
876 : 0 : IMPL_LINK_NOARG(SfxDocumentPage, DeleteHdl)
877 : : {
878 [ # # ]: 0 : String aName;
879 [ # # ][ # # ]: 0 : if ( bEnableUseUserData && aUseUserDataCB.IsChecked() )
[ # # ][ # # ]
880 [ # # ][ # # ]: 0 : aName = SvtUserOptions().GetFullName();
[ # # ][ # # ]
881 [ # # ][ # # ]: 0 : LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
[ # # ][ # # ]
882 [ # # ]: 0 : DateTime now( DateTime::SYSTEM );
883 : : util::DateTime uDT(
884 : 0 : now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
885 : 0 : now.GetDay(), now.GetMonth(), now.GetYear() );
886 [ # # ][ # # ]: 0 : aCreateValFt.SetText( ConvertDateTime_Impl( aName, uDT, aLocaleWrapper ) );
[ # # ]
887 [ # # ]: 0 : XubString aEmpty;
888 [ # # ]: 0 : aChangeValFt.SetText( aEmpty );
889 [ # # ]: 0 : aPrintValFt.SetText( aEmpty );
890 : 0 : const Time aTime( 0 );
891 [ # # ][ # # ]: 0 : aTimeLogValFt.SetText( aLocaleWrapper.getDuration( aTime ) );
[ # # ][ # # ]
892 [ # # ][ # # ]: 0 : aDocNoValFt.SetText(rtl::OUString('1'));
[ # # ]
893 : 0 : bHandleDelete = sal_True;
894 [ # # ][ # # ]: 0 : return 0;
[ # # ]
895 : : }
896 : :
897 : 0 : IMPL_LINK_NOARG(SfxDocumentPage, SignatureHdl)
898 : : {
899 : 0 : SfxObjectShell* pDoc = SfxObjectShell::Current();
900 [ # # ]: 0 : if( pDoc )
901 : : {
902 : 0 : pDoc->SignDocumentContent();
903 : :
904 : 0 : ImplUpdateSignatures();
905 : : }
906 : :
907 : 0 : return 0;
908 : : }
909 : :
910 : 0 : IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl)
911 : : {
912 : 0 : SfxObjectShell* pShell = SfxObjectShell::Current();
913 : : do
914 : : {
915 [ # # ]: 0 : if (!pShell)
916 : : break;
917 [ # # ]: 0 : SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
918 [ # # ]: 0 : if (!pMedSet)
919 : : break;
920 [ # # ]: 0 : const SfxFilter* pFilter = pShell->GetMedium()->GetFilter();
921 [ # # ]: 0 : if (!pFilter)
922 : : break;
923 : :
924 : 0 : rtl::OUString aDocName;
925 [ # # ]: 0 : sfx2::RequestPassword(pFilter, aDocName, pMedSet);
926 [ # # ]: 0 : pShell->SetModified(true);
927 : : }
928 : : while (false);
929 : 0 : return 0;
930 : : }
931 : :
932 : 0 : void SfxDocumentPage::ImplUpdateSignatures()
933 : : {
934 : 0 : SfxObjectShell* pDoc = SfxObjectShell::Current();
935 [ # # ]: 0 : if ( pDoc )
936 : : {
937 : 0 : SfxMedium* pMedium = pDoc->GetMedium();
938 [ # # ][ # # ]: 0 : if ( pMedium && !pMedium->GetName().isEmpty() && pMedium->GetStorage().is() )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
939 : : {
940 : : Reference< security::XDocumentDigitalSignatures > xD(
941 [ # # ][ # # ]: 0 : comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
[ # # ][ # # ]
[ # # ]
942 : :
943 [ # # ]: 0 : if ( xD.is() )
944 : : {
945 [ # # ]: 0 : String s;
946 [ # # ]: 0 : Sequence< security::DocumentSignatureInformation > aInfos;
947 [ # # ]: 0 : aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(),
948 [ # # ][ # # ]: 0 : uno::Reference< io::XInputStream >() );
[ # # ][ # # ]
949 [ # # ]: 0 : if ( aInfos.getLength() > 1 )
950 [ # # ]: 0 : s = aMultiSignedStr;
951 [ # # ]: 0 : else if ( aInfos.getLength() == 1 )
952 : : {
953 : 0 : rtl::OUString aCN_Id("CN");
954 [ # # ]: 0 : const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ];
955 [ # # ][ # # ]: 0 : s = GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime );
[ # # ]
956 [ # # ]: 0 : s.AppendAscii( ", " );
957 [ # # ][ # # ]: 0 : s += GetContentPart( rInfo.Signer->getSubjectName(), aCN_Id );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
958 : : }
959 [ # # ][ # # ]: 0 : aSignedValFt.SetText( s );
[ # # ]
960 : 0 : }
961 : : }
962 : : }
963 : 0 : }
964 : :
965 : 0 : void SfxDocumentPage::ImplCheckPasswordState()
966 : : {
967 : 0 : SfxObjectShell* pShell = SfxObjectShell::Current();
968 : : do
969 : : {
970 [ # # ]: 0 : if (!pShell)
971 : : break;
972 [ # # ]: 0 : SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
973 [ # # ]: 0 : if (!pMedSet)
974 : : break;
975 [ # # ][ # # ]: 0 : SFX_ITEMSET_ARG( pMedSet, pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False);
976 [ # # ]: 0 : uno::Sequence< beans::NamedValue > aEncryptionData;
977 [ # # ]: 0 : if (pEncryptionDataItem)
978 [ # # ]: 0 : pEncryptionDataItem->GetValue() >>= aEncryptionData;
979 : : else
980 : : break;
981 : :
982 [ # # ]: 0 : if (!aEncryptionData.getLength())
983 : : break;
984 [ # # ]: 0 : aChangePassBtn.Enable();
985 [ # # ][ # # ]: 0 : return;
986 : : }
987 : : while (false);
988 : 0 : aChangePassBtn.Disable();
989 : : }
990 : :
991 : : //------------------------------------------------------------------------
992 : :
993 : 0 : SfxTabPage* SfxDocumentPage::Create( Window* pParent, const SfxItemSet& rItemSet )
994 : : {
995 [ # # ]: 0 : return new SfxDocumentPage( pParent, rItemSet );
996 : : }
997 : :
998 : : //------------------------------------------------------------------------
999 : :
1000 : 0 : void SfxDocumentPage::EnableUseUserData()
1001 : : {
1002 : 0 : bEnableUseUserData = sal_True;
1003 : 0 : aUseUserDataCB.Show();
1004 : 0 : aDeleteBtn.Show();
1005 : 0 : }
1006 : :
1007 : : //------------------------------------------------------------------------
1008 : :
1009 : 0 : sal_Bool SfxDocumentPage::FillItemSet( SfxItemSet& rSet )
1010 : : {
1011 : 0 : sal_Bool bRet = sal_False;
1012 : :
1013 [ # # ][ # # : 0 : if ( !bHandleDelete && bEnableUseUserData &&
# # # # #
# ][ # # ]
1014 : 0 : aUseUserDataCB.GetState() != aUseUserDataCB.GetSavedValue() &&
1015 : 0 : GetTabDialog() && GetTabDialog()->GetExampleSet() )
1016 : : {
1017 : 0 : const SfxItemSet* pExpSet = GetTabDialog()->GetExampleSet();
1018 : : const SfxPoolItem* pItem;
1019 : :
1020 [ # # ][ # # ]: 0 : if ( pExpSet && SFX_ITEM_SET == pExpSet->GetItemState( SID_DOCINFO, sal_True, &pItem ) )
[ # # ][ # # ]
1021 : : {
1022 : 0 : SfxDocumentInfoItem* pInfoItem = (SfxDocumentInfoItem*)pItem;
1023 : 0 : sal_Bool bUseData = ( STATE_CHECK == aUseUserDataCB.GetState() );
1024 [ # # ]: 0 : pInfoItem->SetUseUserData( bUseData );
1025 [ # # ][ # # ]: 0 : rSet.Put( SfxDocumentInfoItem( *pInfoItem ) );
[ # # ]
1026 : 0 : bRet = sal_True;
1027 : : }
1028 : : }
1029 : :
1030 [ # # ]: 0 : if ( bHandleDelete )
1031 : : {
1032 : 0 : const SfxItemSet* pExpSet = GetTabDialog()->GetExampleSet();
1033 : : const SfxPoolItem* pItem;
1034 [ # # ][ # # ]: 0 : if ( pExpSet && SFX_ITEM_SET == pExpSet->GetItemState( SID_DOCINFO, sal_True, &pItem ) )
[ # # ][ # # ]
1035 : : {
1036 : 0 : SfxDocumentInfoItem* pInfoItem = (SfxDocumentInfoItem*)pItem;
1037 [ # # ][ # # ]: 0 : sal_Bool bUseAuthor = bEnableUseUserData && aUseUserDataCB.IsChecked();
[ # # ]
1038 [ # # ]: 0 : SfxDocumentInfoItem newItem( *pInfoItem );
1039 : : newItem.resetUserData( bUseAuthor
1040 : : ? SvtUserOptions().GetFullName()
1041 [ # # ][ # # ]: 0 : : ::rtl::OUString() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1042 [ # # ]: 0 : pInfoItem->SetUseUserData( STATE_CHECK == aUseUserDataCB.GetState() );
1043 [ # # ]: 0 : newItem.SetUseUserData( STATE_CHECK == aUseUserDataCB.GetState() );
1044 : :
1045 [ # # ]: 0 : newItem.SetDeleteUserData( sal_True );
1046 [ # # ]: 0 : rSet.Put( newItem );
1047 [ # # ]: 0 : bRet = sal_True;
1048 : : }
1049 : : }
1050 : :
1051 [ # # ][ # # ]: 0 : if ( aNameED.IsModified() && aNameED.GetText().Len() )
[ # # ][ # # ]
[ # # # # ]
1052 : : {
1053 [ # # ][ # # ]: 0 : rSet.Put( SfxStringItem( ID_FILETP_TITLE, aNameED.GetText() ) );
[ # # ]
1054 : 0 : bRet = sal_True;
1055 : : }
1056 : :
1057 : : if ( /* aReadOnlyCB.IsModified() */ sal_True )
1058 : : {
1059 [ # # ]: 0 : rSet.Put( SfxBoolItem( ID_FILETP_READONLY, aReadOnlyCB.IsChecked() ) );
1060 : 0 : bRet = sal_True;
1061 : : }
1062 : :
1063 : 0 : return bRet;
1064 : : }
1065 : :
1066 : : //------------------------------------------------------------------------
1067 : :
1068 : 0 : void SfxDocumentPage::Reset( const SfxItemSet& rSet )
1069 : : {
1070 : : // Determine the document information
1071 : : const SfxDocumentInfoItem *pInfoItem =
1072 [ # # ]: 0 : &(const SfxDocumentInfoItem &)rSet.Get(SID_DOCINFO);
1073 : :
1074 : : // template data
1075 [ # # ]: 0 : if ( pInfoItem->HasTemplate() )
1076 [ # # ][ # # ]: 0 : aTemplValFt.SetText( pInfoItem->getTemplateName() );
[ # # ]
1077 : : else
1078 : : {
1079 [ # # ]: 0 : aTemplFt.Hide();
1080 [ # # ]: 0 : aTemplValFt.Hide();
1081 : : }
1082 : :
1083 : : // determine file name
1084 [ # # ]: 0 : String aFile( pInfoItem->GetValue() );
1085 [ # # ]: 0 : String aFactory( aFile );
1086 [ # # ][ # # ]: 0 : if ( aFile.Len() > 2 && aFile.GetChar(0) == '[' )
[ # # ]
1087 : : {
1088 [ # # ]: 0 : sal_uInt16 nPos = aFile.Search( ']' );
1089 [ # # ][ # # ]: 0 : aFactory = aFile.Copy( 1, nPos-1 );
[ # # ]
1090 [ # # ][ # # ]: 0 : aFile = aFile.Copy( nPos+1 );
[ # # ]
1091 : : }
1092 : :
1093 : : // determine name
1094 [ # # ]: 0 : String aName;
1095 : 0 : const SfxPoolItem* pItem = 0;
1096 [ # # ][ # # ]: 0 : if ( SFX_ITEM_SET != rSet.GetItemState( ID_FILETP_TITLE, sal_False, &pItem ) )
1097 : : {
1098 [ # # ][ # # ]: 0 : INetURLObject aURL(aFile);
1099 [ # # ][ # # ]: 0 : aName = aURL.GetName( INetURLObject::DECODE_WITH_CHARSET );
1100 [ # # ][ # # ]: 0 : if ( !aName.Len() || aURL.GetProtocol() == INET_PROT_PRIVATE )
[ # # ]
1101 [ # # ][ # # ]: 0 : aName = SfxResId( STR_NONAME ).toString();
[ # # ]
1102 [ # # ][ # # ]: 0 : aNameED.SetReadOnly( sal_True );
1103 : : }
1104 : : else
1105 : : {
1106 : : DBG_ASSERT( pItem->IsA( TYPE( SfxStringItem ) ), "SfxDocumentPage:<SfxStringItem> expected" );
1107 [ # # ]: 0 : aName = ( ( SfxStringItem* ) pItem )->GetValue();
1108 : : }
1109 [ # # ]: 0 : aNameED.SetText( aName );
1110 [ # # ]: 0 : aNameED.ClearModifyFlag();
1111 : :
1112 : : // determine RO-Flag
1113 [ # # ][ # # ]: 0 : if ( SFX_ITEM_UNKNOWN == rSet.GetItemState( ID_FILETP_READONLY, sal_False, &pItem )
[ # # ][ # # ]
1114 : 0 : || !pItem )
1115 [ # # ]: 0 : aReadOnlyCB.Hide();
1116 : : else
1117 [ # # ]: 0 : aReadOnlyCB.Check( ( (SfxBoolItem*)pItem )->GetValue() );
1118 : :
1119 : : // determine context symbol
1120 [ # # ]: 0 : INetURLObject aURL;
1121 : 0 : aURL.SetSmartProtocol( INET_PROT_FILE );
1122 [ # # ][ # # ]: 0 : aURL.SetSmartURL( aFactory);
1123 [ # # ][ # # ]: 0 : const String& rMainURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
1124 [ # # ][ # # ]: 0 : aBmp1.SetImage( SvFileInformationManager::GetImage( aURL, sal_True ) );
[ # # ]
1125 : :
1126 : : // determine size and type
1127 [ # # ]: 0 : String aSizeText( aUnknownSize );
1128 [ # # ]: 0 : if ( aURL.GetProtocol() == INET_PROT_FILE )
1129 [ # # ][ # # ]: 0 : aSizeText = CreateSizeText( SfxContentHelper::GetSize( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1130 [ # # ]: 0 : aShowSizeFT.SetText( aSizeText );
1131 : :
1132 [ # # ][ # # ]: 0 : String aDescription = SvFileInformationManager::GetDescription( INetURLObject(rMainURL) );
[ # # ][ # # ]
1133 [ # # ]: 0 : if ( aDescription.Len() == 0 )
1134 [ # # ][ # # ]: 0 : aDescription = SfxResId( STR_SFX_NEWOFFICEDOC ).toString();
[ # # ]
1135 [ # # ]: 0 : aShowTypeFT.SetText( aDescription );
1136 : :
1137 : : // determine location
1138 [ # # ][ # # ]: 0 : aURL.SetSmartURL( aFile);
1139 [ # # ]: 0 : if ( aURL.GetProtocol() == INET_PROT_FILE )
1140 : : {
1141 [ # # ]: 0 : INetURLObject aPath( aURL );
1142 [ # # ]: 0 : aPath.setFinalSlash();
1143 [ # # ]: 0 : aPath.removeSegment();
1144 : : // we know it's a folder -> don't need the final slash, but it's better for WB_PATHELLIPSIS
1145 [ # # ]: 0 : aPath.removeFinalSlash();
1146 [ # # ][ # # ]: 0 : String aText( aPath.PathToFileName() ); //! (pb) MaxLen?
1147 [ # # ][ # # ]: 0 : aFileValFt.SetText( aText );
[ # # ]
1148 : : }
1149 [ # # ]: 0 : else if ( aURL.GetProtocol() != INET_PROT_PRIVATE )
1150 [ # # ][ # # ]: 0 : aFileValFt.SetText( aURL.GetPartBeforeLastName() );
[ # # ][ # # ]
1151 : :
1152 : : // handle access data
1153 [ # # ]: 0 : sal_Bool m_bUseUserData = pInfoItem->IsUseUserData();
1154 [ # # ][ # # ]: 0 : LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
[ # # ][ # # ]
1155 : : aCreateValFt.SetText( ConvertDateTime_Impl( pInfoItem->getAuthor(),
1156 [ # # ][ # # ]: 0 : pInfoItem->getCreationDate(), aLocaleWrapper ) );
[ # # ][ # # ]
[ # # ]
1157 : 0 : util::DateTime aTime( pInfoItem->getModificationDate() );
1158 [ # # ]: 0 : if ( aTime.Month > 0 )
1159 : : aChangeValFt.SetText( ConvertDateTime_Impl(
1160 [ # # ][ # # ]: 0 : pInfoItem->getModifiedBy(), aTime, aLocaleWrapper ) );
[ # # ][ # # ]
[ # # ]
1161 : 0 : aTime = pInfoItem->getPrintDate();
1162 [ # # ]: 0 : if ( aTime.Month > 0 )
1163 : : aPrintValFt.SetText( ConvertDateTime_Impl( pInfoItem->getPrintedBy(),
1164 [ # # ][ # # ]: 0 : aTime, aLocaleWrapper ) );
[ # # ][ # # ]
[ # # ]
1165 : 0 : const long nTime = pInfoItem->getEditingDuration();
1166 [ # # ]: 0 : if ( m_bUseUserData )
1167 : : {
1168 [ # # ]: 0 : const Time aT( nTime/3600, (nTime%3600)/60, nTime%60 );
1169 [ # # ][ # # ]: 0 : aTimeLogValFt.SetText( aLocaleWrapper.getDuration( aT ) );
[ # # ][ # # ]
1170 : : aDocNoValFt.SetText( String::CreateFromInt32(
1171 [ # # ][ # # ]: 0 : pInfoItem->getEditingCycles() ) );
[ # # ]
1172 : : }
1173 : :
1174 : 0 : TriState eState = (TriState)m_bUseUserData;
1175 : :
1176 [ # # ]: 0 : if ( STATE_DONTKNOW == eState )
1177 [ # # ]: 0 : aUseUserDataCB.EnableTriState( sal_True );
1178 : :
1179 [ # # ]: 0 : aUseUserDataCB.SetState( eState );
1180 : 0 : aUseUserDataCB.SaveValue();
1181 [ # # ]: 0 : aUseUserDataCB.Enable( bEnableUseUserData );
1182 : 0 : bHandleDelete = sal_False;
1183 [ # # ][ # # ]: 0 : aDeleteBtn.Enable( bEnableUseUserData );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1184 : 0 : }
1185 : :
1186 : : //------------------------------------------------------------------------
1187 : 0 : SfxInternetPage::SfxInternetPage( Window* pParent, const SfxItemSet& rItemSet ) :
1188 : :
1189 : : SfxTabPage( pParent, SfxResId( TP_DOCINFORELOAD ), rItemSet ),
1190 : :
1191 : : aRBNoAutoUpdate ( this, SfxResId( RB_NOAUTOUPDATE ) ),
1192 : :
1193 : : aRBReloadUpdate ( this, SfxResId( RB_RELOADUPDATE ) ),
1194 : :
1195 : : aRBForwardUpdate ( this, SfxResId( RB_FORWARDUPDATE ) ),
1196 : : aFTEvery ( this, SfxResId( FT_EVERY ) ),
1197 : : aNFReload ( this, SfxResId( ED_RELOAD ) ),
1198 : : aFTReloadSeconds ( this, SfxResId( FT_RELOADSECS ) ),
1199 : : aFTAfter ( this, SfxResId( FT_AFTER ) ),
1200 : : aNFAfter ( this, SfxResId( ED_FORWARD ) ),
1201 : : aFTAfterSeconds ( this, SfxResId( FT_FORWARDSECS ) ),
1202 : : aFTURL ( this, SfxResId( FT_URL ) ),
1203 : : aEDForwardURL ( this, SfxResId( ED_URL ) ),
1204 : : aPBBrowseURL ( this, SfxResId( PB_BROWSEURL ) ),
1205 : : aFTFrame ( this, SfxResId( FT_FRAME ) ),
1206 : : aCBFrame ( this, SfxResId( CB_FRAME ) ),
1207 : :
1208 : : aForwardErrorMessg ( SfxResId(STR_FORWARD_ERRMSSG).toString() ),
1209 : : pInfoItem ( NULL ),
1210 : : pFileDlg ( NULL ),
1211 [ # # ][ # # ]: 0 : eState ( S_Init )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1212 : :
1213 : : {
1214 [ # # ]: 0 : FreeResource();
1215 [ # # ]: 0 : pInfoItem = &( SfxDocumentInfoItem& ) rItemSet.Get( SID_DOCINFO );
1216 [ # # ]: 0 : TargetList aList;
1217 [ # # ]: 0 : SfxViewFrame* pFrame = SfxViewFrame::Current();
1218 [ # # ]: 0 : if ( pFrame )
1219 : : {
1220 [ # # ]: 0 : pFrame = pFrame->GetTopViewFrame();
1221 [ # # ]: 0 : if ( pFrame )
1222 : : {
1223 [ # # ]: 0 : pFrame->GetTargetList( aList );
1224 : :
1225 : : String* pObj;
1226 [ # # ]: 0 : for ( size_t nPos = aList.size() ; nPos ; )
1227 : : {
1228 [ # # ]: 0 : pObj = aList[ --nPos ];
1229 [ # # ]: 0 : aCBFrame.InsertEntry( *pObj );
1230 [ # # ][ # # ]: 0 : delete pObj;
1231 : : }
1232 : : }
1233 : : }
1234 : :
1235 [ # # ]: 0 : aRBNoAutoUpdate.SetClickHdl( LINK( this, SfxInternetPage, ClickHdlNoUpdate ) );
1236 [ # # ]: 0 : aRBReloadUpdate.SetClickHdl( LINK( this, SfxInternetPage, ClickHdlReload ) );
1237 [ # # ]: 0 : aRBForwardUpdate.SetClickHdl( LINK( this, SfxInternetPage, ClickHdlForward ) );
1238 [ # # ]: 0 : aPBBrowseURL.SetClickHdl( LINK( this, SfxInternetPage, ClickHdlBrowseURL ) );
1239 : :
1240 [ # # ][ # # ]: 0 : aForwardErrorMessg.SearchAndReplaceAscii( "%PLACEHOLDER%", aRBForwardUpdate.GetText() );
[ # # ]
1241 : :
1242 [ # # ]: 0 : ChangeState( S_NoUpdate );
1243 : 0 : }
1244 : :
1245 : : //------------------------------------------------------------------------
1246 [ # # ][ # # ]: 0 : SfxInternetPage::~SfxInternetPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1247 : : {
1248 [ # # ][ # # ]: 0 : delete pFileDlg;
1249 [ # # ]: 0 : }
1250 : :
1251 : : //------------------------------------------------------------------------
1252 : 0 : void SfxInternetPage::ChangeState( STATE eNewState )
1253 : : {
1254 : : DBG_ASSERT( eNewState != S_Init, "*SfxInternetPage::ChangeState(): new state init is supposed to not work here!" );
1255 : :
1256 [ # # ]: 0 : if ( eState == eNewState )
1257 : 0 : return;
1258 : :
1259 [ # # # # : 0 : switch ( eState )
# ]
1260 : : {
1261 : : case S_Init:
1262 : 0 : EnableNoUpdate( sal_True );
1263 : 0 : EnableReload( sal_False );
1264 : 0 : EnableForward( sal_False );
1265 : 0 : break;
1266 : : case S_NoUpdate:
1267 : 0 : EnableNoUpdate( sal_False );
1268 [ # # ]: 0 : if( eNewState == S_Reload )
1269 : 0 : EnableReload( sal_True );
1270 : : else
1271 : 0 : EnableForward( sal_True );
1272 : 0 : break;
1273 : : case S_Reload:
1274 : 0 : EnableReload( sal_False );
1275 [ # # ]: 0 : if( eNewState == S_NoUpdate )
1276 : 0 : EnableNoUpdate( sal_True );
1277 : : else
1278 : 0 : EnableForward( sal_True );
1279 : 0 : break;
1280 : : case S_Forward:
1281 : 0 : EnableForward( sal_False );
1282 [ # # ]: 0 : if( eNewState == S_NoUpdate )
1283 : 0 : EnableNoUpdate( sal_True );
1284 : : else
1285 : 0 : EnableReload( sal_True );
1286 : 0 : break;
1287 : : default:
1288 : : OSL_FAIL( "*SfxInternetPage::SetState(): unhandled state!" );
1289 : : }
1290 : :
1291 : 0 : eState = eNewState;
1292 : : }
1293 : :
1294 : : //------------------------------------------------------------------------
1295 : :
1296 : 0 : void SfxInternetPage::EnableNoUpdate( sal_Bool bEnable )
1297 : : {
1298 [ # # ]: 0 : if ( bEnable )
1299 : 0 : aRBNoAutoUpdate.Check();
1300 : 0 : }
1301 : :
1302 : : //------------------------------------------------------------------------
1303 : :
1304 : 0 : void SfxInternetPage::EnableReload( sal_Bool bEnable )
1305 : : {
1306 : 0 : aFTEvery.Enable( bEnable );
1307 : 0 : aNFReload.Enable( bEnable );
1308 : 0 : aFTReloadSeconds.Enable( bEnable );
1309 : :
1310 [ # # ]: 0 : if ( bEnable )
1311 : 0 : aRBReloadUpdate.Check();
1312 : 0 : }
1313 : :
1314 : : //------------------------------------------------------------------------
1315 : :
1316 : 0 : void SfxInternetPage::EnableForward( sal_Bool bEnable )
1317 : : {
1318 : 0 : aFTAfter.Enable( bEnable );
1319 : 0 : aNFAfter.Enable( bEnable );
1320 : 0 : aFTAfterSeconds.Enable( bEnable );
1321 : 0 : aFTURL.Enable( bEnable );
1322 : 0 : aEDForwardURL.Enable( bEnable );
1323 : 0 : aPBBrowseURL.Enable( bEnable );
1324 : 0 : aFTFrame.Enable( bEnable );
1325 : 0 : aCBFrame.Enable( bEnable );
1326 : :
1327 [ # # ]: 0 : if ( bEnable )
1328 : 0 : aRBForwardUpdate.Check();
1329 : 0 : }
1330 : :
1331 : : //------------------------------------------------------------------------
1332 : :
1333 : 0 : IMPL_LINK( SfxInternetPage, ClickHdlNoUpdate, Control*, pCtrl )
1334 : : {
1335 : : (void)pCtrl; //unused
1336 : 0 : ChangeState( S_NoUpdate );
1337 : 0 : return 0;
1338 : : }
1339 : :
1340 : : //------------------------------------------------------------------------
1341 : :
1342 : 0 : IMPL_LINK( SfxInternetPage, ClickHdlReload, Control*, pCtrl )
1343 : : {
1344 : : (void)pCtrl; //unused
1345 : 0 : ChangeState( S_Reload );
1346 : 0 : return 0;
1347 : : }
1348 : :
1349 : : //------------------------------------------------------------------------
1350 : :
1351 : 0 : IMPL_LINK( SfxInternetPage, ClickHdlForward, Control*, pCtrl )
1352 : : {
1353 : : (void)pCtrl; //unused
1354 : 0 : ChangeState( S_Forward );
1355 : 0 : return 0;
1356 : : }
1357 : :
1358 : : //------------------------------------------------------------------------
1359 : :
1360 : 0 : IMPL_LINK_NOARG(SfxInternetPage, ClickHdlBrowseURL)
1361 : : {
1362 [ # # ]: 0 : if ( !pFileDlg )
1363 : : pFileDlg = new sfx2::FileDialogHelper(
1364 [ # # ]: 0 : TemplateDescription::FILEOPEN_SIMPLE, 0 );
1365 [ # # ]: 0 : pFileDlg->SetDisplayDirectory( aEDForwardURL.GetText() );
1366 [ # # ]: 0 : pFileDlg->StartExecuteModal( LINK( this, SfxInternetPage, DialogClosedHdl ) );
1367 : :
1368 : 0 : return 0;
1369 : : }
1370 : :
1371 : : //------------------------------------------------------------------------
1372 : :
1373 : 0 : IMPL_LINK_NOARG(SfxInternetPage, DialogClosedHdl)
1374 : : {
1375 : : DBG_ASSERT( pFileDlg, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
1376 : :
1377 [ # # ]: 0 : if ( ERRCODE_NONE == pFileDlg->GetError() )
1378 [ # # ]: 0 : aEDForwardURL.SetText( pFileDlg->GetPath() );
1379 : :
1380 : 0 : return 0;
1381 : : }
1382 : :
1383 : : //------------------------------------------------------------------------
1384 : :
1385 : 0 : sal_Bool SfxInternetPage::FillItemSet( SfxItemSet& rSet )
1386 : : {
1387 : 0 : const SfxPoolItem* pItem = NULL;
1388 : 0 : SfxDocumentInfoItem* pInfo = NULL;
1389 : 0 : SfxTabDialog* pDlg = GetTabDialog();
1390 : 0 : const SfxItemSet* pExSet = NULL;
1391 : :
1392 [ # # ]: 0 : if ( pDlg )
1393 : 0 : pExSet = pDlg->GetExampleSet();
1394 : :
1395 [ # # ][ # # ]: 0 : if ( pExSet && SFX_ITEM_SET != pExSet->GetItemState( SID_DOCINFO, sal_True, &pItem ) )
[ # # ][ # # ]
1396 : 0 : pInfo = pInfoItem;
1397 [ # # ]: 0 : else if ( pItem )
1398 [ # # ][ # # ]: 0 : pInfo = new SfxDocumentInfoItem( *(const SfxDocumentInfoItem*)pItem );
1399 : :
1400 [ # # ]: 0 : if ( !pInfo )
1401 : : {
1402 : : SAL_WARN( "sfx2.dialog", "SfxInternetPage::FillItemSet(): no item found" );
1403 : 0 : return sal_False;
1404 : : }
1405 : :
1406 : : DBG_ASSERT( eState != S_Init, "*SfxInternetPage::FillItemSet(): state init is not acceptable at this point!" );
1407 : :
1408 : 0 : sal_Bool bEnableReload = sal_False;
1409 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1410 : 0 : ::std::auto_ptr< String > aURL( NULL );
1411 : 0 : ::std::auto_ptr< String > aFrame( NULL );
1412 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1413 : 0 : sal_uIntPtr nDelay = 0;
1414 : :
1415 [ # # # # ]: 0 : switch ( eState )
1416 : : {
1417 : : case S_NoUpdate:
1418 : 0 : break;
1419 : : case S_Reload:
1420 : 0 : bEnableReload = sal_True;
1421 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1422 [ # # ][ # # ]: 0 : aURL = ::std::auto_ptr< String >( new String() );
[ # # ]
1423 [ # # ][ # # ]: 0 : aFrame = ::std::auto_ptr< String >( new String() );
[ # # ]
1424 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1425 [ # # ]: 0 : nDelay = static_cast<sal_uIntPtr>(aNFReload.GetValue());
1426 : 0 : break;
1427 : : case S_Forward:
1428 : : DBG_ASSERT( aEDForwardURL.GetText().Len(), "+SfxInternetPage::FillItemSet(): empty URL should be not possible for forward option!" );
1429 : :
1430 : 0 : bEnableReload = sal_True;
1431 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1432 [ # # ][ # # ]: 0 : aURL = ::std::auto_ptr< String >( new String( URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), aEDForwardURL.GetText(), URIHelper::GetMaybeFileHdl(), true ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1433 [ # # ][ # # ]: 0 : aFrame = ::std::auto_ptr< String >( new String( aCBFrame.GetText() ) );
[ # # ]
1434 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1435 [ # # ]: 0 : nDelay = static_cast<sal_uIntPtr>(aNFAfter.GetValue());
1436 : 0 : break;
1437 : : default:
1438 : 0 : break;
1439 : : }
1440 : :
1441 : 0 : pInfo->setAutoloadEnabled( bEnableReload );
1442 : :
1443 [ # # ]: 0 : if ( bEnableReload )
1444 : : {
1445 [ # # ]: 0 : pInfo->setAutoloadURL( *aURL.get() );
1446 [ # # ]: 0 : pInfo->setDefaultTarget( *aFrame.get() );
1447 : 0 : pInfo->setAutoloadDelay( nDelay );
1448 : : }
1449 : :
1450 [ # # ]: 0 : rSet.Put( *pInfo );
1451 [ # # ]: 0 : if ( pInfo != pInfoItem )
1452 [ # # ][ # # ]: 0 : delete pInfo;
1453 [ # # ][ # # ]: 0 : return sal_True;
1454 : : }
1455 : :
1456 : : //------------------------------------------------------------------------
1457 : 0 : SfxTabPage *SfxInternetPage::Create( Window* pParent, const SfxItemSet& rItemSet )
1458 : : {
1459 [ # # ]: 0 : return new SfxInternetPage(pParent, rItemSet);
1460 : : }
1461 : :
1462 : : //------------------------------------------------------------------------
1463 : 0 : void SfxInternetPage::Reset( const SfxItemSet& rSet )
1464 : : {
1465 : 0 : pInfoItem = &( SfxDocumentInfoItem& ) rSet.Get( SID_DOCINFO );
1466 : 0 : SFX_ITEMSET_ARG( &rSet, pURLItem, SfxStringItem, SID_BASEURL, sal_False );
1467 : : DBG_ASSERT( pURLItem, "No BaseURL provided for InternetTabPage!" );
1468 [ # # ]: 0 : if ( pURLItem )
1469 : 0 : aBaseURL = pURLItem->GetValue();
1470 : :
1471 : 0 : STATE eNewState = S_NoUpdate;
1472 : :
1473 [ # # ]: 0 : if ( pInfoItem->isAutoloadEnabled() )
1474 : : {
1475 [ # # ]: 0 : const String& rURL = pInfoItem->getAutoloadURL();
1476 : :
1477 [ # # ]: 0 : if( rURL.Len() )
1478 : : {
1479 [ # # ]: 0 : aNFAfter.SetValue( pInfoItem->getAutoloadDelay() );
1480 [ # # ]: 0 : aEDForwardURL.SetText( rURL );
1481 [ # # ][ # # ]: 0 : aCBFrame.SetText( pInfoItem->getDefaultTarget() );
[ # # ]
1482 : 0 : eNewState = S_Forward;
1483 : : }
1484 : : else
1485 : : {
1486 [ # # ]: 0 : aNFReload.SetValue( pInfoItem->getAutoloadDelay() );
1487 : 0 : eNewState = S_Reload;
1488 : 0 : }
1489 : : }
1490 : :
1491 : 0 : ChangeState( eNewState );
1492 : :
1493 : 0 : SFX_ITEMSET_ARG( &rSet, pROItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
1494 [ # # ][ # # ]: 0 : if ( pROItem && pROItem->GetValue() )
[ # # ]
1495 : : {
1496 : 0 : aRBNoAutoUpdate.Disable();
1497 : 0 : aRBReloadUpdate.Disable();
1498 : 0 : aRBForwardUpdate.Disable();
1499 : 0 : aNFReload.Disable();
1500 : 0 : aNFAfter.Disable();
1501 : 0 : aEDForwardURL.Disable();
1502 : 0 : aPBBrowseURL.Disable();
1503 : 0 : aCBFrame.Disable();
1504 : 0 : aFTEvery.Disable();
1505 : 0 : aFTReloadSeconds.Disable();
1506 : 0 : aFTAfter.Disable();
1507 : 0 : aFTAfterSeconds.Disable();
1508 : 0 : aFTURL.Disable();
1509 : 0 : aFTFrame.Disable();
1510 : : }
1511 : 0 : }
1512 : :
1513 : : //------------------------------------------------------------------------
1514 : 0 : int SfxInternetPage::DeactivatePage( SfxItemSet* /*pSet*/ )
1515 : : {
1516 : 0 : int nRet = LEAVE_PAGE;
1517 : :
1518 [ # # ][ # # ]: 0 : if ( eState == S_Forward && !aEDForwardURL.GetText().Len() )
[ # # ][ # # ]
[ # # # # ]
1519 : : {
1520 [ # # ]: 0 : ErrorBox aErrBox( this, WB_OK, aForwardErrorMessg );
1521 [ # # ]: 0 : aErrBox.Execute();
1522 : :
1523 [ # # ]: 0 : nRet = KEEP_PAGE;
1524 : : }
1525 : :
1526 : 0 : return nRet;
1527 : : }
1528 : :
1529 : : //------------------------------------------------------------------------
1530 : 0 : SfxDocumentInfoDialog::SfxDocumentInfoDialog( Window* pParent,
1531 : : const SfxItemSet& rItemSet ) :
1532 : :
1533 [ # # ]: 0 : SfxTabDialog( 0, pParent, SfxResId( SID_DOCINFO ), &rItemSet )
1534 : :
1535 : : {
1536 [ # # ]: 0 : FreeResource();
1537 : :
1538 : : const SfxDocumentInfoItem* pInfoItem =
1539 [ # # ]: 0 : &(const SfxDocumentInfoItem &)rItemSet.Get( SID_DOCINFO );
1540 : :
1541 : : #ifdef DBG_UTIL
1542 : : SFX_ITEMSET_ARG( &rItemSet, pURLItem, SfxStringItem, SID_BASEURL, sal_False );
1543 : : DBG_ASSERT( pURLItem, "No BaseURL provided for InternetTabPage!" );
1544 : : #endif
1545 : :
1546 : : // Determine the Titels
1547 : 0 : const SfxPoolItem* pItem = 0;
1548 [ # # ]: 0 : String aTitle( GetText() );
1549 [ # # ]: 0 : if ( SFX_ITEM_SET !=
1550 [ # # ]: 0 : rItemSet.GetItemState( SID_EXPLORER_PROPS_START, sal_False, &pItem ) )
1551 : : {
1552 : : // File name
1553 [ # # ]: 0 : String aFile( pInfoItem->GetValue() );
1554 : :
1555 [ # # ]: 0 : INetURLObject aURL;
1556 : 0 : aURL.SetSmartProtocol( INET_PROT_FILE );
1557 [ # # ][ # # ]: 0 : aURL.SetSmartURL( aFile);
1558 [ # # ]: 0 : if ( INET_PROT_PRIV_SOFFICE != aURL.GetProtocol() )
1559 : : {
1560 [ # # ][ # # ]: 0 : String aLastName( aURL.GetLastName() );
1561 [ # # ]: 0 : if ( aLastName.Len() )
1562 [ # # ]: 0 : aTitle += aLastName;
1563 : : else
1564 [ # # ][ # # ]: 0 : aTitle += aFile;
1565 : : }
1566 : : else
1567 [ # # ][ # # ]: 0 : aTitle += SfxResId( STR_NONAME ).toString();
[ # # ][ # # ]
[ # # ]
1568 : : }
1569 : : else
1570 : : {
1571 : : DBG_ASSERT( pItem->IsA( TYPE( SfxStringItem ) ),
1572 : : "SfxDocumentInfoDialog:<SfxStringItem> expected" );
1573 [ # # ]: 0 : aTitle += ( ( SfxStringItem* ) pItem )->GetValue();
1574 : : }
1575 [ # # ]: 0 : SetText( aTitle );
1576 : :
1577 : : // Property Pages
1578 [ # # ]: 0 : AddTabPage(TP_DOCINFODESC, SfxDocumentDescPage::Create, 0);
1579 [ # # ]: 0 : AddTabPage(TP_DOCINFODOC, SfxDocumentPage::Create, 0);
1580 [ # # ]: 0 : AddTabPage(TP_CUSTOMPROPERTIES, SfxCustomPropertiesPage::Create, 0);
1581 [ # # ]: 0 : AddTabPage(TP_DOCINFORELOAD, SfxInternetPage::Create, 0);
1582 [ # # ][ # # ]: 0 : AddTabPage(TP_DOCINFOSECURITY, SfxSecurityPage::Create, 0);
1583 : 0 : }
1584 : :
1585 : : // -----------------------------------------------------------------------
1586 : :
1587 : 0 : void SfxDocumentInfoDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
1588 : : {
1589 [ # # ]: 0 : if ( TP_DOCINFODOC == nId )
1590 : 0 : ( (SfxDocumentPage&)rPage ).EnableUseUserData();
1591 : 0 : }
1592 : :
1593 : : // class CustomPropertiesYesNoButton -------------------------------------
1594 : :
1595 : 0 : CustomPropertiesYesNoButton::CustomPropertiesYesNoButton( Window* pParent, const ResId& rResId ) :
1596 : : Control( pParent, rResId ),
1597 : 0 : m_aYesButton( this, ResId( RB_PROPERTY_YES, *rResId.GetResMgr() ) ),
1598 [ # # ][ # # ]: 0 : m_aNoButton ( this, ResId( RB_PROPERTY_NO, *rResId.GetResMgr() ) )
1599 : : {
1600 [ # # ]: 0 : FreeResource();
1601 [ # # ]: 0 : Wallpaper aWall( Color( COL_TRANSPARENT ) );
1602 [ # # ]: 0 : SetBackground( aWall );
1603 [ # # ]: 0 : SetBorderStyle( WINDOW_BORDER_MONO );
1604 [ # # ]: 0 : CheckNo();
1605 [ # # ]: 0 : m_aYesButton.SetBackground( aWall );
1606 [ # # ][ # # ]: 0 : m_aNoButton.SetBackground( aWall );
1607 : 0 : }
1608 : : class DurationDialog_Impl : public ModalDialog
1609 : : {
1610 : : FixedLine aDurationFL;
1611 : :
1612 : : OKButton aOKPB;
1613 : : CancelButton aCancelPB;
1614 : : HelpButton aHelpPB;
1615 : :
1616 : : CheckBox aNegativeCB;
1617 : : FixedText aYearFT;
1618 : : NumericField aYearNF;
1619 : : FixedText aMonthFT;
1620 : : NumericField aMonthNF;
1621 : : FixedText aDayFT;
1622 : : NumericField aDayNF;
1623 : : FixedText aHourFT;
1624 : : NumericField aHourNF;
1625 : : FixedText aMinuteFT;
1626 : : NumericField aMinuteNF;
1627 : : FixedText aSecondFT;
1628 : : NumericField aSecondNF;
1629 : : FixedText aMSecondFT;
1630 : : NumericField aMSecondNF;
1631 : :
1632 : : public:
1633 : :
1634 : : DurationDialog_Impl( Window* pParent, const util::Duration& rDuration );
1635 : : ~DurationDialog_Impl();
1636 : :
1637 : : util::Duration GetDuration() const;
1638 : : };
1639 : :
1640 : 0 : DurationDialog_Impl::DurationDialog_Impl(
1641 : : Window* pParent, const util::Duration& rDuration)
1642 : : : ModalDialog( pParent, SfxResId( RID_EDIT_DURATIONS ) ),
1643 : : aDurationFL(this, SfxResId( FL_DURATION )),
1644 : : aOKPB( this, SfxResId( PB_OK )),
1645 : : aCancelPB( this, SfxResId( PB_CANCEL )),
1646 : : aHelpPB( this, SfxResId( PB_HELP )),
1647 : : aNegativeCB(this, SfxResId( CB_NEGATIVE )),
1648 : : aYearFT( this, SfxResId( FT_YEAR )),
1649 : : aYearNF( this, SfxResId( ED_YEAR )),
1650 : : aMonthFT( this, SfxResId( FT_MONTH )),
1651 : : aMonthNF( this, SfxResId( ED_MONTH )),
1652 : : aDayFT( this, SfxResId( FT_DAY )),
1653 : : aDayNF( this, SfxResId( ED_DAY )),
1654 : : aHourFT( this, SfxResId( FT_HOUR )),
1655 : : aHourNF( this, SfxResId( ED_HOUR )),
1656 : : aMinuteFT( this, SfxResId( FT_MINUTE )),
1657 : : aMinuteNF( this, SfxResId( ED_MINUTE )),
1658 : : aSecondFT( this, SfxResId( FT_SECOND )),
1659 : : aSecondNF( this, SfxResId( ED_SECOND )),
1660 : : aMSecondFT( this, SfxResId( FT_MSECOND )),
1661 [ # # ][ # # ]: 0 : aMSecondNF( this, SfxResId( ED_MSECOND ))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1662 : : {
1663 [ # # ]: 0 : FreeResource();
1664 [ # # ]: 0 : aNegativeCB.Check(rDuration.Negative);
1665 [ # # ]: 0 : aYearNF.SetValue(rDuration.Years);
1666 [ # # ]: 0 : aMonthNF.SetValue(rDuration.Months );
1667 [ # # ]: 0 : aDayNF.SetValue(rDuration.Days );
1668 [ # # ]: 0 : aHourNF.SetValue(rDuration.Hours );
1669 [ # # ]: 0 : aMinuteNF.SetValue(rDuration.Minutes);
1670 [ # # ]: 0 : aSecondNF.SetValue(rDuration.Seconds);
1671 [ # # ]: 0 : aMSecondNF.SetValue(rDuration.MilliSeconds);
1672 : 0 : }
1673 : :
1674 [ # # ][ # # ]: 0 : DurationDialog_Impl::~DurationDialog_Impl()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1675 : : {
1676 [ # # ]: 0 : }
1677 : :
1678 : 0 : util::Duration DurationDialog_Impl::GetDuration() const
1679 : : {
1680 : 0 : util::Duration aRet;
1681 : 0 : aRet.Negative = aNegativeCB.IsChecked();
1682 : 0 : aRet.Years = aYearNF.GetValue();
1683 : 0 : aRet.Months = aMonthNF.GetValue( );
1684 : 0 : aRet.Days = aDayNF.GetValue( );
1685 : 0 : aRet.Hours = aHourNF.GetValue( );
1686 : 0 : aRet.Minutes = aMinuteNF.GetValue();
1687 : 0 : aRet.Seconds = aSecondNF.GetValue();
1688 : 0 : aRet.MilliSeconds = aMSecondNF.GetValue();
1689 : 0 : return aRet;
1690 : : }
1691 : :
1692 : 0 : CustomPropertiesDurationField::CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
1693 : 0 : Edit( pParent, rResId ), m_pLine( pLine )
1694 : :
1695 : : {
1696 [ # # ]: 0 : SetDuration( util::Duration(false, 0, 0, 0, 0, 0, 0, 0) );
1697 : 0 : }
1698 : :
1699 : 0 : CustomPropertiesDurationField::~CustomPropertiesDurationField()
1700 : : {
1701 [ # # ]: 0 : }
1702 : :
1703 : 0 : void CustomPropertiesDurationField::RequestHelp( const HelpEvent& rHEvt )
1704 : : {
1705 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_QUICK )
1706 : : {
1707 [ # # ]: 0 : Size aSize( GetSizePixel() );
1708 [ # # ][ # # ]: 0 : Rectangle aItemRect( rHEvt.GetMousePosPixel(), aSize );
1709 [ # # ][ # # ]: 0 : if (Help::IsBalloonHelpEnabled())
1710 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), GetText() );
[ # # ][ # # ]
1711 : : else
1712 : 0 : Help::ShowQuickHelp( this, aItemRect, GetText(),
1713 [ # # ][ # # ]: 0 : QUICKHELP_LEFT|QUICKHELP_VCENTER );
[ # # ]
1714 : : }
1715 : 0 : }
1716 : :
1717 : 0 : void CustomPropertiesDurationField::SetDuration( const util::Duration& rDuration )
1718 : : {
1719 : 0 : m_aDuration = rDuration;
1720 [ # # ][ # # ]: 0 : String sText(rDuration.Negative ? rtl::OUString('-') : rtl::OUString('+'));
1721 [ # # ]: 0 : sText += m_pLine->m_sDurationFormat;
1722 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%1"), String::CreateFromInt32( rDuration.Years ) );
[ # # ][ # # ]
[ # # ]
1723 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%2"), String::CreateFromInt32( rDuration.Months ) );
[ # # ][ # # ]
[ # # ]
1724 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%3"), String::CreateFromInt32( rDuration.Days ) );
[ # # ][ # # ]
[ # # ]
1725 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%4"), String::CreateFromInt32( rDuration.Hours ) );
[ # # ][ # # ]
[ # # ]
1726 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%5"), String::CreateFromInt32( rDuration.Minutes) );
[ # # ][ # # ]
[ # # ]
1727 [ # # ][ # # ]: 0 : sText.SearchAndReplace(rtl::OUString("%6"), String::CreateFromInt32( rDuration.Seconds) );
[ # # ][ # # ]
[ # # ]
1728 [ # # ][ # # ]: 0 : SetText( sText );
1729 : 0 : }
1730 : :
1731 : 0 : CustomPropertiesEditButton::CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
1732 : 0 : PushButton( pParent, rResId ), m_pLine( pLine )
1733 : : {
1734 [ # # ]: 0 : SetClickHdl( LINK( this, CustomPropertiesEditButton, ClickHdl ));
1735 : 0 : }
1736 : :
1737 : 0 : CustomPropertiesEditButton::~CustomPropertiesEditButton()
1738 : : {
1739 [ # # ]: 0 : }
1740 : :
1741 : 0 : IMPL_LINK_NOARG(CustomPropertiesEditButton, ClickHdl)
1742 : : {
1743 [ # # ]: 0 : DurationDialog_Impl* pDurationDlg = new DurationDialog_Impl( this, m_pLine->m_aDurationField.GetDuration() );
1744 [ # # ]: 0 : if ( RET_OK == pDurationDlg->Execute() )
1745 [ # # ]: 0 : m_pLine->m_aDurationField.SetDuration( pDurationDlg->GetDuration() );
1746 [ # # ]: 0 : delete pDurationDlg;
1747 : 0 : return 1;
1748 : : }
1749 : : //--------------------------------------------------------------------------
1750 : 0 : void CustomPropertiesYesNoButton::Resize()
1751 : : {
1752 [ # # ]: 0 : const long nWidth = GetSizePixel().Width();
1753 [ # # ][ # # ]: 0 : const long n3Width = LogicToPixel( Size( 3, 3 ), MAP_APPFONT ).Width();
[ # # ]
1754 : 0 : const long nNewWidth = ( nWidth / 2 ) - n3Width - 2;
1755 [ # # ]: 0 : Size aSize = m_aYesButton.GetSizePixel();
1756 : 0 : const long nDelta = aSize.Width() - nNewWidth;
1757 : 0 : aSize.Width() = nNewWidth;
1758 [ # # ]: 0 : m_aYesButton.SetSizePixel( aSize );
1759 [ # # ]: 0 : Point aPos = m_aNoButton.GetPosPixel();
1760 : 0 : aPos.X() -= nDelta;
1761 [ # # ]: 0 : m_aNoButton.SetPosSizePixel( aPos, aSize );
1762 : 0 : }
1763 : :
1764 : : // struct CustomPropertyLine ---------------------------------------------
1765 : 0 : CustomPropertyLine::CustomPropertyLine( Window* pParent ) :
1766 : : m_aNameBox ( pParent, SfxResId( SFX_CB_PROPERTY_NAME ) ),
1767 : : m_aTypeBox ( pParent, SfxResId( SFX_LB_PROPERTY_TYPE ), this ),
1768 : : m_aValueEdit ( pParent, SfxResId( SFX_ED_PROPERTY_VALUE ), this ),
1769 : : m_aDateField ( pParent, SfxResId( SFX_FLD_DATE), this),
1770 : : m_aTimeField ( pParent, SfxResId( SFX_FLD_TIME), this),
1771 : : m_sDurationFormat( SfxResId( SFX_ST_DURATION_FORMAT ).toString() ),
1772 : : m_aDurationField( pParent, SfxResId( SFX_FLD_DURATION), this),
1773 : : m_aEditButton( pParent, SfxResId( SFX_PB_EDIT ), this),
1774 : : m_aYesNoButton ( pParent, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
1775 : : m_aRemoveButton ( pParent, SfxResId( SFX_PB_PROPERTY_REMOVE ), this ),
1776 : : m_bIsRemoved ( false ),
1777 [ # # ][ # # ]: 0 : m_bTypeLostFocus( false )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1778 : :
1779 : : {
1780 [ # # ]: 0 : m_aTimeField.SetExtFormat( EXTTIMEF_24H_LONG );
1781 [ # # ]: 0 : m_aDateField.SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY );
1782 : :
1783 [ # # ][ # # ]: 0 : m_aRemoveButton.SetModeImage( SfxResId( SFX_IMG_PROPERTY_REMOVE ) );
[ # # ][ # # ]
1784 : 0 : }
1785 : :
1786 : 0 : void CustomPropertyLine::SetRemoved()
1787 : : {
1788 : : DBG_ASSERT( !m_bIsRemoved, "CustomPropertyLine::SetRemoved(): line already removed" );
1789 : 0 : m_bIsRemoved = true;
1790 : 0 : m_aNameBox.Hide();
1791 : 0 : m_aTypeBox.Hide();
1792 : 0 : m_aValueEdit.Hide();
1793 : 0 : m_aDateField.Hide();
1794 : 0 : m_aTimeField.Hide();
1795 : 0 : m_aDurationField.Hide();
1796 : 0 : m_aEditButton.Hide();
1797 : 0 : m_aYesNoButton.Hide();
1798 : 0 : m_aRemoveButton.Hide();
1799 : 0 : }
1800 : :
1801 : : // class CustomPropertiesWindow ------------------------------------------
1802 : 0 : CustomPropertiesWindow::CustomPropertiesWindow( Window* pParent, const ResId& rResId ) :
1803 : :
1804 : : Window( pParent, rResId ),
1805 : : m_aNameBox ( this, SfxResId( SFX_CB_PROPERTY_NAME ) ),
1806 : : m_aTypeBox ( this, SfxResId( SFX_LB_PROPERTY_TYPE ) ),
1807 : : m_aValueEdit ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ),
1808 : : m_aDateField ( this, SfxResId( SFX_FLD_DATE) ),
1809 : : m_aTimeField ( this, SfxResId( SFX_FLD_TIME) ),
1810 : : m_aDurationField( this, SfxResId( SFX_FLD_DURATION) ),
1811 : : m_aEditButton( this, SfxResId( SFX_PB_EDIT )),
1812 : : m_aYesNoButton ( this, SfxResId( SFX_WIN_PROPERTY_YESNO ) ),
1813 : : m_aRemoveButton ( this, SfxResId( SFX_PB_PROPERTY_REMOVE ) ),
1814 : : m_nScrollPos (0),
1815 : : m_aNumberFormatter( ::comphelper::getProcessServiceFactory(),
1816 [ # # ][ # # ]: 0 : Application::GetSettings().GetLanguage() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1817 : :
1818 : : {
1819 [ # # ]: 0 : m_aEditLoseFocusTimer.SetTimeout( 300 );
1820 [ # # ]: 0 : m_aEditLoseFocusTimer.SetTimeoutHdl( LINK( this, CustomPropertiesWindow, EditTimeoutHdl ) );
1821 [ # # ]: 0 : m_aBoxLoseFocusTimer.SetTimeout( 300 );
1822 [ # # ]: 0 : m_aBoxLoseFocusTimer.SetTimeoutHdl( LINK( this, CustomPropertiesWindow, BoxTimeoutHdl ) );
1823 : :
1824 : 0 : ResMgr* pResMgr = rResId.GetResMgr();
1825 [ # # ][ # # ]: 0 : m_aNameBox.SetAccessibleName( ResId( STR_HEADER_NAME, *pResMgr ).toString() );
[ # # ][ # # ]
1826 [ # # ][ # # ]: 0 : m_aTypeBox.SetAccessibleName( ResId( STR_HEADER_TYPE, *pResMgr ).toString() );
[ # # ][ # # ]
1827 [ # # ][ # # ]: 0 : m_aValueEdit.SetAccessibleName( ResId( STR_HEADER_VALUE, *pResMgr ).toString() );
[ # # ][ # # ]
1828 : 0 : }
1829 : :
1830 [ # # ][ # # ]: 0 : CustomPropertiesWindow::~CustomPropertiesWindow()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1831 : : {
1832 [ # # ]: 0 : m_aEditLoseFocusTimer.Stop();
1833 [ # # ]: 0 : m_aBoxLoseFocusTimer.Stop();
1834 [ # # ]: 0 : ClearAllLines();
1835 [ # # ]: 0 : }
1836 : :
1837 : 0 : IMPL_LINK( CustomPropertiesWindow, TypeHdl, CustomPropertiesTypeBox*, pBox )
1838 : : {
1839 : 0 : sal_Int64 nType = sal_Int64( (long)pBox->GetEntryData( pBox->GetSelectEntryPos() ) );
1840 : 0 : CustomPropertyLine* pLine = pBox->GetLine();
1841 [ # # ][ # # ]: 0 : pLine->m_aValueEdit.Show( (CUSTOM_TYPE_TEXT == nType) || (CUSTOM_TYPE_NUMBER == nType) );
1842 [ # # ][ # # ]: 0 : pLine->m_aDateField.Show( (CUSTOM_TYPE_DATE == nType) || (CUSTOM_TYPE_DATETIME == nType) );
1843 : 0 : pLine->m_aTimeField.Show( CUSTOM_TYPE_DATETIME == nType );
1844 : 0 : pLine->m_aDurationField.Show( CUSTOM_TYPE_DURATION == nType );
1845 : 0 : pLine->m_aEditButton.Show( CUSTOM_TYPE_DURATION == nType );
1846 : 0 : pLine->m_aYesNoButton.Show( CUSTOM_TYPE_BOOLEAN == nType );
1847 : : //adjust positions of date and time controls
1848 [ # # ]: 0 : if ( nType == CUSTOM_TYPE_DATE )
1849 [ # # ][ # # ]: 0 : pLine->m_aDateField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel());
1850 [ # # ]: 0 : else if ( nType == CUSTOM_TYPE_DATETIME)
1851 : : {
1852 : 0 : pLine->m_aDateField.SetPosSizePixel( pLine->m_aDatePos, pLine->m_aDateTimeSize );
1853 : 0 : pLine->m_aTimeField.SetPosSizePixel(pLine->m_aTimePos, pLine->m_aDateTimeSize );
1854 : : }
1855 : :
1856 : 0 : return 0;
1857 : : }
1858 : :
1859 : 0 : IMPL_LINK( CustomPropertiesWindow, RemoveHdl, CustomPropertiesRemoveButton*, pButton )
1860 : : {
1861 : 0 : CustomPropertyLine* pLine = pButton->GetLine();
1862 : : std::vector< CustomPropertyLine* >::iterator pFound =
1863 [ # # ]: 0 : std::find( m_aCustomPropertiesLines.begin(), m_aCustomPropertiesLines.end(), pLine );
1864 [ # # ][ # # ]: 0 : if ( pFound != m_aCustomPropertiesLines.end() )
1865 : : {
1866 : 0 : pLine = *pFound;
1867 [ # # ]: 0 : pLine->SetRemoved();
1868 [ # # ]: 0 : std::vector< CustomPropertyLine* >::iterator pIter = pFound + 1;
1869 : 0 : const long nDelta = GetLineHeight();
1870 [ # # ][ # # ]: 0 : for ( ; pIter != m_aCustomPropertiesLines.end(); ++pIter )
1871 : : {
1872 : 0 : pLine = *pIter;
1873 [ # # ]: 0 : if ( pLine->m_bIsRemoved )
1874 : 0 : continue;
1875 : :
1876 : : Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit,
1877 : : &pLine->m_aDateField, &pLine->m_aTimeField,
1878 : : &pLine->m_aDurationField, &pLine->m_aEditButton,
1879 : 0 : &pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL };
1880 : 0 : Window** pCurrent = pWindows;
1881 [ # # ]: 0 : while ( *pCurrent )
1882 : : {
1883 [ # # ]: 0 : Point aPos = (*pCurrent)->GetPosPixel();
1884 : 0 : aPos.Y() -= nDelta;
1885 [ # # ]: 0 : (*pCurrent)->SetPosPixel( aPos );
1886 : 0 : pCurrent++;
1887 : : }
1888 : : }
1889 : : }
1890 : :
1891 [ # # ]: 0 : m_aRemovedHdl.Call(0);
1892 : 0 : return 0;
1893 : : }
1894 : :
1895 : 0 : IMPL_LINK( CustomPropertiesWindow, EditLoseFocusHdl, CustomPropertiesEdit*, pEdit )
1896 : : {
1897 [ # # ]: 0 : if ( pEdit )
1898 : : {
1899 : 0 : CustomPropertyLine* pLine = pEdit->GetLine();
1900 [ # # ]: 0 : if ( !pLine->m_bTypeLostFocus )
1901 : : {
1902 : 0 : m_pCurrentLine = pLine;
1903 : 0 : m_aEditLoseFocusTimer.Start();
1904 : : }
1905 : : else
1906 : 0 : pLine->m_bTypeLostFocus = false;
1907 : : }
1908 : 0 : return 0;
1909 : : }
1910 : :
1911 : 0 : IMPL_LINK( CustomPropertiesWindow, BoxLoseFocusHdl, CustomPropertiesTypeBox*, pBox )
1912 : : {
1913 [ # # ]: 0 : if ( pBox )
1914 : : {
1915 : 0 : m_pCurrentLine = pBox->GetLine();
1916 : 0 : m_aBoxLoseFocusTimer.Start();
1917 : : }
1918 : :
1919 : 0 : return 0;
1920 : : }
1921 : :
1922 : 0 : IMPL_LINK_NOARG(CustomPropertiesWindow, EditTimeoutHdl)
1923 : : {
1924 : 0 : ValidateLine( m_pCurrentLine, false );
1925 : 0 : return 0;
1926 : : }
1927 : :
1928 : 0 : IMPL_LINK_NOARG(CustomPropertiesWindow, BoxTimeoutHdl)
1929 : : {
1930 : 0 : ValidateLine( m_pCurrentLine, true );
1931 : 0 : return 0;
1932 : : }
1933 : :
1934 : 0 : bool CustomPropertiesWindow::IsLineValid( CustomPropertyLine* pLine ) const
1935 : : {
1936 : 0 : bool bIsValid = true;
1937 : 0 : pLine->m_bTypeLostFocus = false;
1938 : : sal_Int64 nType = sal_Int64(
1939 [ # # ][ # # ]: 0 : (long)pLine->m_aTypeBox.GetEntryData( pLine->m_aTypeBox.GetSelectEntryPos() ) );
1940 [ # # ]: 0 : String sValue = pLine->m_aValueEdit.GetText();
1941 [ # # ]: 0 : if ( sValue.Len() == 0 )
1942 : 0 : return true;
1943 : :
1944 : 0 : sal_uInt32 nIndex = 0xFFFFFFFF;
1945 [ # # ]: 0 : if ( CUSTOM_TYPE_NUMBER == nType )
1946 : : nIndex = const_cast< SvNumberFormatter& >(
1947 [ # # ]: 0 : m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
1948 [ # # ]: 0 : else if ( CUSTOM_TYPE_DATE == nType )
1949 : : nIndex = const_cast< SvNumberFormatter& >(
1950 [ # # ]: 0 : m_aNumberFormatter).GetFormatIndex( NF_DATE_SYS_DDMMYYYY );
1951 : :
1952 [ # # ]: 0 : if ( nIndex != 0xFFFFFFFF )
1953 : : {
1954 : 0 : sal_uInt32 nTemp = nIndex;
1955 : 0 : double fDummy = 0.0;
1956 : : bIsValid = const_cast< SvNumberFormatter& >(
1957 [ # # ]: 0 : m_aNumberFormatter ).IsNumberFormat( sValue, nIndex, fDummy ) != sal_False;
1958 [ # # ][ # # ]: 0 : if ( bIsValid && nTemp != nIndex )
1959 : : // sValue is a number but the format doesn't match the index
1960 : 0 : bIsValid = false;
1961 : : }
1962 : :
1963 [ # # ]: 0 : return bIsValid;
1964 : : }
1965 : :
1966 : 0 : void CustomPropertiesWindow::ValidateLine( CustomPropertyLine* pLine, bool bIsFromTypeBox )
1967 : : {
1968 [ # # ]: 0 : if ( !IsLineValid( pLine ) )
1969 : : {
1970 [ # # ]: 0 : if ( bIsFromTypeBox ) // LoseFocus of TypeBox
1971 : 0 : pLine->m_bTypeLostFocus = true;
1972 : 0 : Window* pParent = GetParent()->GetParent();
1973 [ # # ][ # # ]: 0 : if ( QueryBox( pParent, SfxResId( SFX_QB_WRONG_TYPE ) ).Execute() == RET_OK )
[ # # ][ # # ]
1974 : 0 : pLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)CUSTOM_TYPE_TEXT ) );
1975 : : else
1976 : 0 : pLine->m_aValueEdit.GrabFocus();
1977 : : }
1978 : 0 : }
1979 : :
1980 : 0 : void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar )
1981 : : {
1982 : : DBG_ASSERT( pHeaderBar, "CustomPropertiesWindow::InitControls(): invalid headerbar" );
1983 : : DBG_ASSERT( pScrollBar, "CustomPropertiesWindow::InitControls(): invalid scrollbar" );
1984 : :
1985 [ # # ]: 0 : m_aNameBox.Hide();
1986 [ # # ]: 0 : m_aTypeBox.Hide();
1987 [ # # ]: 0 : m_aValueEdit.Hide();
1988 [ # # ]: 0 : m_aDateField.Hide();
1989 [ # # ]: 0 : m_aTimeField.Hide();
1990 [ # # ]: 0 : m_aDurationField.Hide();
1991 [ # # ]: 0 : m_aEditButton.Hide();
1992 [ # # ]: 0 : m_aYesNoButton.Hide();
1993 [ # # ]: 0 : m_aRemoveButton.Hide();
1994 : :
1995 : 0 : const long nOffset = 4;
1996 [ # # ]: 0 : const long nScrollBarWidth = pScrollBar->GetSizePixel().Width();
1997 [ # # ]: 0 : const long nButtonWidth = m_aRemoveButton.GetSizePixel().Width() + nScrollBarWidth + nOffset;
1998 [ # # ]: 0 : long nTypeWidth = m_aTypeBox.CalcMinimumSize().Width() + ( 2 * nOffset );
1999 [ # # ]: 0 : long nFullWidth = pHeaderBar->GetSizePixel().Width();
2000 : 0 : long nItemWidth = ( nFullWidth - nTypeWidth - nButtonWidth ) / 2;
2001 [ # # ]: 0 : pHeaderBar->SetItemSize( HI_NAME, nItemWidth );
2002 [ # # ]: 0 : pHeaderBar->SetItemSize( HI_TYPE, nTypeWidth );
2003 [ # # ]: 0 : pHeaderBar->SetItemSize( HI_VALUE, nItemWidth );
2004 [ # # ]: 0 : pHeaderBar->SetItemSize( HI_ACTION, nButtonWidth );
2005 : :
2006 : 0 : Window* pWindows[] = { &m_aNameBox, &m_aTypeBox, &m_aValueEdit, &m_aRemoveButton, NULL };
2007 : 0 : Window** pCurrent = pWindows;
2008 : 0 : sal_uInt16 nPos = 0;
2009 [ # # ]: 0 : while ( *pCurrent )
2010 : : {
2011 [ # # ][ # # ]: 0 : Rectangle aRect = pHeaderBar->GetItemRect( pHeaderBar->GetItemId( nPos++ ) );
2012 [ # # ]: 0 : Size aSize = (*pCurrent)->GetSizePixel();
2013 [ # # ]: 0 : Point aPos = (*pCurrent)->GetPosPixel();
2014 : 0 : long nWidth = aRect.getWidth() - nOffset;
2015 [ # # ]: 0 : if ( *pCurrent == &m_aRemoveButton )
2016 [ # # ]: 0 : nWidth -= pScrollBar->GetSizePixel().Width();
2017 : 0 : aSize.Width() = nWidth;
2018 : 0 : aPos.X() = aRect.getX() + ( nOffset / 2 );
2019 [ # # ]: 0 : (*pCurrent)->SetPosSizePixel( aPos, aSize );
2020 : :
2021 [ # # ]: 0 : if ( *pCurrent == &m_aValueEdit )
2022 : : {
2023 : 0 : Point aDurationPos( aPos );
2024 [ # # ]: 0 : m_aDurationField.SetPosPixel( aDurationPos );
2025 : 0 : Size aDurationSize(aSize);
2026 [ # # ]: 0 : aDurationSize.Width() -= (m_aEditButton.GetSizePixel().Width() + 3 );
2027 [ # # ]: 0 : m_aDurationField.SetSizePixel(aDurationSize);
2028 [ # # ]: 0 : aDurationPos.X() = aPos.X() - m_aEditButton.GetSizePixel().Width() + aSize.Width();
2029 [ # # ]: 0 : m_aEditButton.SetPosPixel(aDurationPos);
2030 [ # # ]: 0 : aSize = m_aYesNoButton.GetSizePixel();
2031 [ # # ]: 0 : aPos = m_aYesNoButton.GetPosPixel();
2032 : 0 : aSize.Width() = nWidth;
2033 : 0 : aPos.X() = aRect.getX() + ( nOffset / 2 );
2034 [ # # ]: 0 : m_aYesNoButton.SetPosSizePixel( aPos, aSize );
2035 : 0 : aSize.Width() /= 2;
2036 : 0 : aSize.Width() -= 2;
2037 [ # # ]: 0 : m_aDateField.SetPosSizePixel( aPos, aSize );
2038 : 0 : aPos.X() += aSize.Width() + 4;
2039 [ # # ]: 0 : m_aTimeField.SetPosSizePixel( aPos, aSize );
2040 : : }
2041 : :
2042 : 0 : pCurrent++;
2043 : : }
2044 : :
2045 : : m_nLineHeight =
2046 [ # # ][ # # ]: 0 : ( m_aRemoveButton.GetPosPixel().Y() * 2 ) + m_aRemoveButton.GetSizePixel().Height();
2047 : 0 : }
2048 : :
2049 : 0 : sal_uInt16 CustomPropertiesWindow::GetVisibleLineCount() const
2050 : : {
2051 : 0 : sal_uInt16 nCount = 0;
2052 : 0 : std::vector< CustomPropertyLine* >::const_iterator pIter;
2053 [ # # ][ # # ]: 0 : for ( pIter = m_aCustomPropertiesLines.begin();
2054 : 0 : pIter != m_aCustomPropertiesLines.end(); ++pIter )
2055 : : {
2056 : 0 : CustomPropertyLine* pLine = *pIter;
2057 [ # # ]: 0 : if ( !pLine->m_bIsRemoved )
2058 : 0 : nCount++;
2059 : : }
2060 : 0 : return nCount;
2061 : : }
2062 : :
2063 : 0 : void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
2064 : : {
2065 [ # # ][ # # ]: 0 : CustomPropertyLine* pNewLine = new CustomPropertyLine( this );
2066 [ # # ]: 0 : pNewLine->m_aTypeBox.SetSelectHdl( LINK( this, CustomPropertiesWindow, TypeHdl ) );
2067 [ # # ]: 0 : pNewLine->m_aRemoveButton.SetClickHdl( LINK( this, CustomPropertiesWindow, RemoveHdl ) );
2068 [ # # ]: 0 : pNewLine->m_aValueEdit.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, EditLoseFocusHdl ) );
2069 : : //add lose focus handlers of date/time fields
2070 : :
2071 [ # # ]: 0 : pNewLine->m_aTypeBox.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, BoxLoseFocusHdl ) );
2072 : :
2073 [ # # ][ # # ]: 0 : pNewLine->m_aNameBox.SetAccessibleName(m_aNameBox.GetAccessibleName());
[ # # ]
2074 [ # # ][ # # ]: 0 : pNewLine->m_aTypeBox.SetAccessibleName(m_aTypeBox.GetAccessibleName());
[ # # ]
2075 [ # # ][ # # ]: 0 : pNewLine->m_aValueEdit.SetAccessibleName(m_aValueEdit.GetAccessibleName());
[ # # ]
2076 : :
2077 [ # # ]: 0 : long nPos = GetVisibleLineCount() * GetLineHeight();
2078 [ # # ]: 0 : m_aCustomPropertiesLines.push_back( pNewLine );
2079 : : Window* pWindows[] = { &m_aNameBox, &m_aTypeBox, &m_aValueEdit,
2080 : : &m_aDateField, &m_aTimeField,
2081 : : &m_aDurationField, &m_aEditButton,
2082 : 0 : &m_aYesNoButton, &m_aRemoveButton, NULL };
2083 : : Window* pNewWindows[] =
2084 : : { &pNewLine->m_aNameBox, &pNewLine->m_aTypeBox, &pNewLine->m_aValueEdit,
2085 : : &pNewLine->m_aDateField, &pNewLine->m_aTimeField,
2086 : : &pNewLine->m_aDurationField, &pNewLine->m_aEditButton,
2087 : 0 : &pNewLine->m_aYesNoButton, &pNewLine->m_aRemoveButton, NULL };
2088 : 0 : Window** pCurrent = pWindows;
2089 : 0 : Window** pNewCurrent = pNewWindows;
2090 [ # # ]: 0 : while ( *pCurrent )
2091 : : {
2092 [ # # ]: 0 : Size aSize = (*pCurrent)->GetSizePixel();
2093 [ # # ]: 0 : Point aPos = (*pCurrent)->GetPosPixel();
2094 : 0 : aPos.Y() += nPos;
2095 : 0 : aPos.Y() += m_nScrollPos;
2096 [ # # ]: 0 : (*pNewCurrent)->SetPosSizePixel( aPos, aSize );
2097 [ # # ]: 0 : (*pNewCurrent)->Show();
2098 : 0 : pCurrent++;
2099 : 0 : pNewCurrent++;
2100 : : }
2101 : :
2102 [ # # ]: 0 : pNewLine->m_aDatePos = pNewLine->m_aDateField.GetPosPixel();
2103 [ # # ]: 0 : pNewLine->m_aTimePos = pNewLine->m_aTimeField.GetPosPixel();
2104 [ # # ]: 0 : pNewLine->m_aDateTimeSize = pNewLine->m_aDateField.GetSizePixel();
2105 : :
2106 : 0 : double nTmpValue = 0;
2107 : 0 : bool bTmpValue = false;
2108 : 0 : ::rtl::OUString sTmpValue;
2109 : 0 : util::DateTime aTmpDateTime;
2110 : 0 : util::Date aTmpDate;
2111 : 0 : util::Duration aTmpDuration;
2112 [ # # ]: 0 : SvtSysLocale aSysLocale;
2113 [ # # ]: 0 : const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
2114 [ # # ][ # # ]: 0 : pNewLine->m_aNameBox.SetText( sName );
[ # # ]
2115 : 0 : sal_IntPtr nType = CUSTOM_TYPE_UNKNOWN;
2116 [ # # ]: 0 : String sValue;
2117 : :
2118 [ # # ]: 0 : if ( rAny >>= nTmpValue )
2119 : : {
2120 [ # # ]: 0 : sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
2121 [ # # ]: 0 : m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue );
2122 [ # # ]: 0 : pNewLine->m_aValueEdit.SetText( sValue );
2123 : 0 : nType = CUSTOM_TYPE_NUMBER;
2124 : : }
2125 [ # # ]: 0 : else if ( rAny >>= bTmpValue )
2126 : : {
2127 [ # # ][ # # ]: 0 : sValue = ( bTmpValue ? rLocaleWrapper.getTrueWord() : rLocaleWrapper.getFalseWord() );
[ # # ][ # # ]
2128 : 0 : nType = CUSTOM_TYPE_BOOLEAN;
2129 : : }
2130 [ # # ]: 0 : else if ( rAny >>= sTmpValue )
2131 : : {
2132 [ # # ][ # # ]: 0 : pNewLine->m_aValueEdit.SetText( sTmpValue );
[ # # ]
2133 : 0 : nType = CUSTOM_TYPE_TEXT;
2134 : : }
2135 [ # # ][ # # ]: 0 : else if ( rAny >>= aTmpDate )
2136 : : {
2137 : 0 : nType = CUSTOM_TYPE_DATE;
2138 [ # # ]: 0 : pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) );
2139 : :
2140 : : }
2141 [ # # ][ # # ]: 0 : else if ( rAny >>= aTmpDuration )
2142 : : {
2143 : 0 : nType = CUSTOM_TYPE_DURATION;
2144 [ # # ]: 0 : pNewLine->m_aDurationField.SetDuration( aTmpDuration );
2145 : : }
2146 [ # # ][ # # ]: 0 : else if ( rAny >>= aTmpDateTime )
2147 : : {
2148 [ # # ]: 0 : pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
2149 [ # # ][ # # ]: 0 : pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.HundredthSeconds ) );
2150 : :
2151 : 0 : nType = CUSTOM_TYPE_DATETIME;
2152 : : }
2153 : :
2154 [ # # ]: 0 : if ( nType != CUSTOM_TYPE_UNKNOWN )
2155 : : {
2156 [ # # ]: 0 : if ( CUSTOM_TYPE_BOOLEAN == nType )
2157 : : {
2158 [ # # ]: 0 : if ( bTmpValue )
2159 [ # # ]: 0 : pNewLine->m_aYesNoButton.CheckYes();
2160 : : else
2161 [ # # ]: 0 : pNewLine->m_aYesNoButton.CheckNo();
2162 : : }
2163 [ # # ][ # # ]: 0 : pNewLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)nType ) );
2164 : : }
2165 : :
2166 [ # # ]: 0 : TypeHdl( &pNewLine->m_aTypeBox );
2167 [ # # ][ # # ]: 0 : pNewLine->m_aNameBox.GrabFocus();
[ # # ]
2168 : 0 : }
2169 : :
2170 : 0 : bool CustomPropertiesWindow::AreAllLinesValid() const
2171 : : {
2172 : 0 : bool bRet = true;
2173 : 0 : std::vector< CustomPropertyLine* >::const_iterator pIter;
2174 [ # # ][ # # ]: 0 : for ( pIter = m_aCustomPropertiesLines.begin();
2175 : 0 : pIter != m_aCustomPropertiesLines.end(); ++pIter )
2176 : : {
2177 : 0 : CustomPropertyLine* pLine = *pIter;
2178 [ # # ][ # # ]: 0 : if ( !IsLineValid( pLine ) )
2179 : : {
2180 : 0 : bRet = false;
2181 : 0 : break;
2182 : : }
2183 : : }
2184 : :
2185 : 0 : return bRet;
2186 : : }
2187 : :
2188 : 0 : void CustomPropertiesWindow::ClearAllLines()
2189 : : {
2190 : 0 : std::vector< CustomPropertyLine* >::iterator pIter;
2191 [ # # ][ # # ]: 0 : for ( pIter = m_aCustomPropertiesLines.begin();
2192 : 0 : pIter != m_aCustomPropertiesLines.end(); ++pIter )
2193 : : {
2194 : 0 : CustomPropertyLine* pLine = *pIter;
2195 [ # # ]: 0 : pLine->SetRemoved();
2196 [ # # ][ # # ]: 0 : delete pLine;
2197 : : }
2198 : 0 : m_aCustomPropertiesLines.clear();
2199 : 0 : m_nScrollPos = 0;
2200 : 0 : }
2201 : :
2202 : 0 : void CustomPropertiesWindow::DoScroll( sal_Int32 nNewPos )
2203 : : {
2204 : 0 : m_nScrollPos += nNewPos;
2205 : 0 : std::vector< CustomPropertyLine* >::iterator pIter;
2206 [ # # ][ # # ]: 0 : for ( pIter = m_aCustomPropertiesLines.begin();
2207 : 0 : pIter != m_aCustomPropertiesLines.end(); ++pIter )
2208 : : {
2209 : 0 : CustomPropertyLine* pLine = *pIter;
2210 [ # # ]: 0 : if ( pLine->m_bIsRemoved )
2211 : 0 : continue;
2212 : :
2213 : : Window* pWindows[] = { &pLine->m_aNameBox, &pLine->m_aTypeBox, &pLine->m_aValueEdit, &pLine->m_aDateField, &pLine->m_aTimeField,
2214 : 0 : &pLine->m_aDurationField, &pLine->m_aEditButton, &pLine->m_aYesNoButton, &pLine->m_aRemoveButton, NULL };
2215 : 0 : Window** pCurrent = pWindows;
2216 [ # # ]: 0 : while ( *pCurrent )
2217 : : {
2218 [ # # ]: 0 : Point aPos = (*pCurrent)->GetPosPixel();
2219 : 0 : aPos.Y() += nNewPos;
2220 [ # # ]: 0 : (*pCurrent)->SetPosPixel( aPos );
2221 : 0 : pCurrent++;
2222 : : }
2223 : : }
2224 : 0 : }
2225 : :
2226 : 0 : Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() const
2227 : : {
2228 [ # # ]: 0 : Sequence< beans::PropertyValue > aPropertiesSeq( m_aCustomPropertiesLines.size() );
2229 : 0 : sal_Int32 i = 0;
2230 : 0 : std::vector< CustomPropertyLine* >::const_iterator pIter;
2231 [ # # ][ # # ]: 0 : for ( pIter = m_aCustomPropertiesLines.begin();
2232 : 0 : pIter != m_aCustomPropertiesLines.end(); ++pIter, ++i )
2233 : : {
2234 : 0 : CustomPropertyLine* pLine = *pIter;
2235 [ # # ]: 0 : if ( pLine->m_bIsRemoved )
2236 : 0 : continue;
2237 : :
2238 [ # # ]: 0 : String sPropertyName = pLine->m_aNameBox.GetText();
2239 [ # # ]: 0 : if ( sPropertyName.Len() > 0 )
2240 : : {
2241 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Name = sPropertyName;
2242 : : sal_Int64 nType = sal_Int64(
2243 [ # # ][ # # ]: 0 : (long)pLine->m_aTypeBox.GetEntryData( pLine->m_aTypeBox.GetSelectEntryPos() ) );
2244 [ # # ]: 0 : if ( CUSTOM_TYPE_NUMBER == nType )
2245 : : {
2246 : 0 : double nValue = 0;
2247 : : sal_uInt32 nIndex = const_cast< SvNumberFormatter& >(
2248 [ # # ]: 0 : m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
2249 : : sal_Bool bIsNum = const_cast< SvNumberFormatter& >( m_aNumberFormatter ).
2250 [ # # ][ # # ]: 0 : IsNumberFormat( pLine->m_aValueEdit.GetText(), nIndex, nValue );
[ # # ]
2251 [ # # ]: 0 : if ( bIsNum )
2252 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= makeAny( nValue );
[ # # ]
2253 : : }
2254 [ # # ]: 0 : else if ( CUSTOM_TYPE_BOOLEAN == nType )
2255 : : {
2256 : 0 : bool bValue = pLine->m_aYesNoButton.IsYesChecked();
2257 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= makeAny( bValue );
[ # # ]
2258 : : }
2259 [ # # ]: 0 : else if ( CUSTOM_TYPE_DATETIME == nType )
2260 : : {
2261 [ # # ]: 0 : Date aTmpDate = pLine->m_aDateField.GetDate();
2262 [ # # ]: 0 : Time aTmpTime = pLine->m_aTimeField.GetTime();
2263 : 0 : util::DateTime aDateTime(aTmpTime.Get100Sec(), aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(),
2264 : 0 : aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear() );
2265 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= aDateTime;
2266 : : }
2267 [ # # ]: 0 : else if ( CUSTOM_TYPE_DURATION == nType )
2268 : : {
2269 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= pLine->m_aDurationField.GetDuration();
2270 : : }
2271 [ # # ]: 0 : else if ( CUSTOM_TYPE_DATE == nType )
2272 : : {
2273 [ # # ]: 0 : Date aTmpDate = pLine->m_aDateField.GetDate();
2274 : 0 : util::Date aDate(aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear());
2275 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= aDate;
2276 : :
2277 : : }
2278 : : else
2279 : : {
2280 [ # # ][ # # ]: 0 : ::rtl::OUString sValue( pLine->m_aValueEdit.GetText() );
[ # # ]
2281 [ # # ][ # # ]: 0 : aPropertiesSeq[i].Value <<= makeAny( sValue );
[ # # ]
2282 : : }
2283 : : }
2284 [ # # ]: 0 : }
2285 : :
2286 : 0 : return aPropertiesSeq;
2287 : : }
2288 : :
2289 : : // class CustomPropertiesControl -----------------------------------------
2290 : 0 : CustomPropertiesControl::CustomPropertiesControl( Window* pParent, const ResId& rResId ) :
2291 : :
2292 : : Control( pParent, rResId ),
2293 : :
2294 : : m_aHeaderBar ( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
2295 : 0 : m_aPropertiesWin( this, ResId( WIN_PROPERTIES, *rResId.GetResMgr() ) ),
2296 : 0 : m_aVertScroll ( this, ResId( SB_VERTICAL, *rResId.GetResMgr() ) ),
2297 : :
2298 [ # # # # : 0 : m_nThumbPos ( 0 )
# # ]
2299 : :
2300 : : {
2301 [ # # ][ # # ]: 0 : m_aPropertiesWin.SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
[ # # ]
2302 : 0 : m_aVertScroll.EnableDrag();
2303 [ # # ]: 0 : m_aVertScroll.Show();
2304 : 0 : long nWidth = GetOutputSizePixel().Width();
2305 [ # # ][ # # ]: 0 : m_aHeaderBar.SetPosSizePixel( Point(), Size( nWidth, m_aVertScroll.GetPosPixel().Y() ) );
2306 : 0 : const HeaderBarItemBits nHeadBits = HIB_VCENTER | HIB_FIXED | HIB_FIXEDPOS | HIB_LEFT;
2307 : 0 : nWidth = nWidth / 4;
2308 : 0 : ResMgr* pResMgr = rResId.GetResMgr();
2309 [ # # ][ # # ]: 0 : m_aHeaderBar.InsertItem( HI_NAME, ResId( STR_HEADER_NAME, *pResMgr ).toString(), nWidth, nHeadBits );
[ # # ][ # # ]
2310 [ # # ][ # # ]: 0 : m_aHeaderBar.InsertItem( HI_TYPE, ResId( STR_HEADER_TYPE, *pResMgr ).toString(), nWidth, nHeadBits );
[ # # ][ # # ]
2311 [ # # ][ # # ]: 0 : m_aHeaderBar.InsertItem( HI_VALUE, ResId( STR_HEADER_VALUE, *pResMgr ).toString(), nWidth, nHeadBits );
[ # # ][ # # ]
2312 [ # # ][ # # ]: 0 : m_aHeaderBar.InsertItem( HI_ACTION, ResId( STR_HEADER_ACTION, *pResMgr ).toString(), nWidth, nHeadBits );
[ # # ][ # # ]
2313 [ # # ]: 0 : m_aHeaderBar.Show();
2314 : :
2315 [ # # ]: 0 : FreeResource();
2316 : :
2317 [ # # ]: 0 : XubString sTEST = m_aHeaderBar.GetItemText( HI_NAME );
2318 : :
2319 [ # # ]: 0 : m_aPropertiesWin.InitControls( &m_aHeaderBar, &m_aVertScroll );
2320 [ # # ]: 0 : m_aPropertiesWin.SetRemovedHdl( LINK( this, CustomPropertiesControl, RemovedHdl ) );
2321 : :
2322 [ # # ]: 0 : m_aVertScroll.SetRangeMin( 0 );
2323 : 0 : sal_Int32 nScrollOffset = m_aPropertiesWin.GetLineHeight();
2324 [ # # ]: 0 : sal_Int32 nVisibleEntries = m_aPropertiesWin.GetSizePixel().Height() / nScrollOffset;
2325 [ # # ]: 0 : m_aVertScroll.SetRangeMax( nVisibleEntries );
2326 : 0 : m_aVertScroll.SetPageSize( nVisibleEntries - 1 );
2327 [ # # ]: 0 : m_aVertScroll.SetVisibleSize( nVisibleEntries );
2328 : :
2329 [ # # ]: 0 : Point aPos = m_aHeaderBar.GetPosPixel();
2330 [ # # ]: 0 : Size aSize = m_aHeaderBar.GetSizePixel();
2331 [ # # ]: 0 : aPos = m_aVertScroll.GetPosPixel();
2332 [ # # ]: 0 : aSize = m_aVertScroll.GetSizePixel();
2333 : :
2334 [ # # ]: 0 : Link aScrollLink = LINK( this, CustomPropertiesControl, ScrollHdl );
2335 [ # # ]: 0 : m_aVertScroll.SetScrollHdl( aScrollLink );
2336 : 0 : }
2337 : :
2338 [ # # ][ # # ]: 0 : CustomPropertiesControl::~CustomPropertiesControl()
[ # # ]
2339 : : {
2340 [ # # ]: 0 : }
2341 : :
2342 : 0 : IMPL_LINK( CustomPropertiesControl, ScrollHdl, ScrollBar*, pScrollBar )
2343 : : {
2344 : 0 : sal_Int32 nOffset = m_aPropertiesWin.GetLineHeight();
2345 : 0 : nOffset *= ( m_nThumbPos - pScrollBar->GetThumbPos() );
2346 : 0 : m_nThumbPos = pScrollBar->GetThumbPos();
2347 : 0 : m_aPropertiesWin.DoScroll( nOffset );
2348 : 0 : return 0;
2349 : : }
2350 : :
2351 : 0 : IMPL_LINK_NOARG(CustomPropertiesControl, RemovedHdl)
2352 : : {
2353 : 0 : m_aVertScroll.SetRangeMax( m_aPropertiesWin.GetVisibleLineCount() + 1 );
2354 [ # # ][ # # ]: 0 : if ( m_aPropertiesWin.GetOutputSizePixel().Height() < m_aPropertiesWin.GetVisibleLineCount() * m_aPropertiesWin.GetLineHeight() )
2355 : 0 : m_aVertScroll.DoScrollAction ( SCROLL_LINEUP );
2356 : 0 : return 0;
2357 : : }
2358 : :
2359 : 0 : void CustomPropertiesControl::AddLine( const ::rtl::OUString& sName, Any& rAny, bool bInteractive )
2360 : : {
2361 : 0 : m_aPropertiesWin.AddLine( sName, rAny );
2362 : 0 : m_aVertScroll.SetRangeMax( m_aPropertiesWin.GetVisibleLineCount() + 1 );
2363 [ # # ][ # # ]: 0 : if ( bInteractive && m_aPropertiesWin.GetOutputSizePixel().Height() < m_aPropertiesWin.GetVisibleLineCount() * m_aPropertiesWin.GetLineHeight() )
[ # # ]
[ # # # # ]
[ # # ]
2364 : 0 : m_aVertScroll.DoScroll( m_aPropertiesWin.GetVisibleLineCount() + 1 );
2365 : 0 : }
2366 : :
2367 : : // class SfxCustomPropertiesPage -----------------------------------------
2368 : 0 : SfxCustomPropertiesPage::SfxCustomPropertiesPage( Window* pParent, const SfxItemSet& rItemSet ) :
2369 : :
2370 : : SfxTabPage( pParent, SfxResId( TP_CUSTOMPROPERTIES ), rItemSet ),
2371 : : m_aPropertiesCtrl ( this, SfxResId( CTRL_PROPERTIES ) ),
2372 : : m_aAddBtn ( this, SfxResId( BTN_ADD ) ),
2373 [ # # ][ # # ]: 0 : m_aPropertiesFT ( this, SfxResId( FT_PROPERTIES ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2374 : :
2375 : : {
2376 [ # # ]: 0 : FreeResource();
2377 : :
2378 [ # # ]: 0 : m_aAddBtn.SetClickHdl( LINK( this, SfxCustomPropertiesPage, AddHdl ) );
2379 : 0 : }
2380 : :
2381 : 0 : IMPL_LINK_NOARG(SfxCustomPropertiesPage, AddHdl)
2382 : : {
2383 : 0 : Any aAny;
2384 [ # # ]: 0 : m_aPropertiesCtrl.AddLine( ::rtl::OUString(), aAny, true );
2385 : 0 : return 0;
2386 : : }
2387 : :
2388 : 0 : sal_Bool SfxCustomPropertiesPage::FillItemSet( SfxItemSet& rSet )
2389 : : {
2390 : 0 : sal_Bool bModified = sal_False;
2391 : 0 : const SfxPoolItem* pItem = NULL;
2392 : 0 : SfxDocumentInfoItem* pInfo = NULL;
2393 : 0 : bool bMustDelete = false;
2394 : :
2395 [ # # ][ # # ]: 0 : if ( GetTabDialog() && GetTabDialog()->GetExampleSet() )
[ # # ]
2396 : : {
2397 [ # # ]: 0 : if ( SFX_ITEM_SET !=
2398 [ # # ]: 0 : GetTabDialog()->GetExampleSet()->GetItemState( SID_DOCINFO, sal_True, &pItem ) )
2399 [ # # ]: 0 : pInfo = &( SfxDocumentInfoItem& )rSet.Get( SID_DOCINFO );
2400 : : else
2401 : : {
2402 : 0 : bMustDelete = true;
2403 [ # # ][ # # ]: 0 : pInfo = new SfxDocumentInfoItem( *( const SfxDocumentInfoItem* ) pItem );
2404 : : }
2405 : : }
2406 : :
2407 [ # # ]: 0 : if ( pInfo )
2408 : : {
2409 [ # # ]: 0 : pInfo->ClearCustomProperties();
2410 [ # # ]: 0 : Sequence< beans::PropertyValue > aPropertySeq = m_aPropertiesCtrl.GetCustomProperties();
2411 : 0 : sal_Int32 i = 0, nCount = aPropertySeq.getLength();
2412 [ # # ]: 0 : for ( ; i < nCount; ++i )
2413 : : {
2414 [ # # ][ # # ]: 0 : if ( !aPropertySeq[i].Name.isEmpty() )
2415 [ # # ][ # # ]: 0 : pInfo->AddCustomProperty( aPropertySeq[i].Name, aPropertySeq[i].Value );
[ # # ]
2416 [ # # ]: 0 : }
2417 : : }
2418 : :
2419 : 0 : bModified = sal_True; //!!!
2420 [ # # ]: 0 : if ( bModified )
2421 [ # # ]: 0 : rSet.Put( *pInfo );
2422 [ # # ]: 0 : if ( bMustDelete )
2423 [ # # ][ # # ]: 0 : delete pInfo;
2424 : 0 : return bModified;
2425 : : }
2426 : :
2427 : 0 : void SfxCustomPropertiesPage::Reset( const SfxItemSet& rItemSet )
2428 : : {
2429 [ # # ]: 0 : m_aPropertiesCtrl.ClearAllLines();
2430 [ # # ]: 0 : const SfxDocumentInfoItem* pInfoItem = &(const SfxDocumentInfoItem &)rItemSet.Get(SID_DOCINFO);
2431 [ # # ]: 0 : std::vector< CustomProperty* > aCustomProps = pInfoItem->GetCustomProperties();
2432 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < aCustomProps.size(); i++ )
2433 : : {
2434 [ # # ]: 0 : m_aPropertiesCtrl.AddLine( aCustomProps[i]->m_sName, aCustomProps[i]->m_aValue, false );
2435 : 0 : }
2436 : 0 : }
2437 : :
2438 : 0 : int SfxCustomPropertiesPage::DeactivatePage( SfxItemSet* /*pSet*/ )
2439 : : {
2440 : 0 : int nRet = LEAVE_PAGE;
2441 [ # # ]: 0 : if ( !m_aPropertiesCtrl.AreAllLinesValid() )
2442 : 0 : nRet = KEEP_PAGE;
2443 : 0 : return nRet;
2444 : : }
2445 : :
2446 : 0 : SfxTabPage* SfxCustomPropertiesPage::Create( Window* pParent, const SfxItemSet& rItemSet )
2447 : : {
2448 [ # # ]: 0 : return new SfxCustomPropertiesPage( pParent, rItemSet );
2449 : : }
2450 : :
2451 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|