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