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