diff options
Diffstat (limited to 'sw/source/ui/utlui')
32 files changed, 15622 insertions, 0 deletions
diff --git a/sw/source/ui/utlui/attrdesc.cxx b/sw/source/ui/utlui/attrdesc.cxx new file mode 100644 index 000000000000..1b4dcc90f82d --- /dev/null +++ b/sw/source/ui/utlui/attrdesc.cxx @@ -0,0 +1,1350 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <svl/itemiter.hxx> +#include <vcl/svapp.hxx> +#include <editeng/itemtype.hxx> +#include <svtools/grfmgr.hxx> +#include <unotools/intlwrapper.hxx> +#include <comphelper/processfactory.hxx> +#include <fmtanchr.hxx> +#include <fmtfsize.hxx> +#include <fmtinfmt.hxx> +#include <fchrfmt.hxx> +#include <fmtautofmt.hxx> +#include <fmtsrnd.hxx> +#include <fmtornt.hxx> +#include <fmtlsplt.hxx> +#include <fmtrowsplt.hxx> +#include <fmtpdsc.hxx> +#include <fmtclds.hxx> +#include <fmteiro.hxx> +#include <fmturl.hxx> +#include <fmthdft.hxx> +#include <fmtcnct.hxx> +#include <fmtline.hxx> +#include <tgrditem.hxx> +#include <hfspacingitem.hxx> +#include <fmtruby.hxx> +#include <paratr.hxx> +#include <grfatr.hxx> +#include <pagedesc.hxx> +#include <charfmt.hxx> +#include <fmtcol.hxx> +#include <tox.hxx> +#ifndef _ATTRDESC_HRC +#include <attrdesc.hrc> +#endif +#include <fmtftntx.hxx> +#include <fmtfollowtextflow.hxx> + + +using namespace com::sun::star; + + +TYPEINIT2(SwFmtCharFmt,SfxPoolItem,SwClient); + +// erfrage die Attribut-Beschreibung +void SwAttrSet::GetPresentation( + SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + String &rText ) const +{ +static sal_Char __READONLY_DATA sKomma[] = ", "; + + rText.Erase(); + String aStr; + if( Count() ) + { + SfxItemIter aIter( *this ); + const IntlWrapper rInt( ::comphelper::getProcessServiceFactory(), + GetAppLanguage() ); + while( sal_True ) + { + aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric, + ePresMetric, aStr, + &rInt ); + if( rText.Len() && aStr.Len() ) + rText += String::CreateFromAscii(sKomma); + rText += aStr; + if( aIter.IsAtEnd() ) + break; + aIter.NextItem(); + } + } +} + +// ATT_CHARFMT ********************************************* + + +SfxItemPresentation SwFmtCharFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + const SwCharFmt *pCharFmt = GetCharFmt(); + if ( pCharFmt ) + { + String aStr; + rText = SW_RESSTR(STR_CHARFMT ); + pCharFmt->GetPresentation( ePres, eCoreUnit, ePresUnit, aStr ); + rText += '('; + rText += aStr; + rText += ')'; + } + else + rText = SW_RESSTR( STR_NO_CHARFMT ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +// ATT_AUTOFMT ********************************************* + + +SfxItemPresentation SwFmtAutoFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText.Erase(); //TODO + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +// ATT_INETFMT ********************************************* + + +SfxItemPresentation SwFmtINetFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = GetValue(); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtRuby::GetPresentation( SfxItemPresentation ePres, + SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, + String &rText, const IntlWrapper* /*pIntl*/ ) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = aEmptyStr; + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +/************************************************************************* +|* class SwFmtDrop +*************************************************************************/ + + +SfxItemPresentation SwFmtDrop::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText.Erase(); + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( GetLines() > 1 ) + { + if ( GetChars() > 1 ) + { + rText = String::CreateFromInt32( GetChars() ); + rText += ' '; + } + rText += SW_RESSTR( STR_DROP_OVER ); + rText += ' '; + rText += String::CreateFromInt32( GetLines() ); + rText += ' '; + rText += SW_RESSTR( STR_DROP_LINES ); + } + else + rText = SW_RESSTR( STR_NO_DROP_LINES ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +/************************************************************************* +|* class SwRegisterItem +*************************************************************************/ + + +SfxItemPresentation SwRegisterItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = GetValue() ? STR_REGISTER_ON : STR_REGISTER_OFF; + rText = SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +/************************************************************************* +|* class SwNumRuleItem +*************************************************************************/ + + +SfxItemPresentation SwNumRuleItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if( GetValue().Len() ) + (((rText = SW_RESSTR( STR_NUMRULE_ON )) += + '(' ) += GetValue() ) += ')'; + else + rText = SW_RESSTR( STR_NUMRULE_OFF ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} +/************************************************************************* +|* class SwParaConnectBorderItem +*************************************************************************/ + +SfxItemPresentation SwParaConnectBorderItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + XubString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = GetValue() ? STR_CONNECT_BORDER_ON : STR_CONNECT_BORDER_OFF; + rText = SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + + +/****************************************************************************** + * Frame-Attribute: + ******************************************************************************/ + + +SfxItemPresentation SwFmtFrmSize::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + String& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + { + rText.Erase(); + break; + } + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = SW_RESSTR( STR_FRM_WIDTH ); + rText += ' '; + if ( GetWidthPercent() ) + { + rText += String::CreateFromInt32(GetWidthPercent()); + rText += '%'; + } + else + { + rText += ::GetMetricText( GetWidth(), eCoreUnit, ePresUnit, pIntl ); + rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + if ( ATT_VAR_SIZE != GetHeightSizeType() ) + { + rText += ','; + rText += ' '; + const sal_uInt16 nId = ATT_FIX_SIZE == eFrmHeightType ? + STR_FRM_FIXEDHEIGHT : STR_FRM_MINHEIGHT; + rText += SW_RESSTR( nId ); + rText += ' '; + if ( GetHeightPercent() ) + { + rText += String::CreateFromInt32(GetHeightPercent()); + rText += '%'; + } + else + { + rText += ::GetMetricText( GetHeight(), eCoreUnit, ePresUnit, pIntl ); + rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//Kopfzeile, fuer Seitenformate +//Client von FrmFmt das den Header beschreibt. + + +SfxItemPresentation SwFmtHeader::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + const sal_uInt16 nId = GetHeaderFmt() ? STR_HEADER : STR_NO_HEADER; + rText = SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//Fusszeile, fuer Seitenformate +//Client von FrmFmt das den Footer beschreibt. + + +SfxItemPresentation SwFmtFooter::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + const sal_uInt16 nId = GetFooterFmt() ? STR_FOOTER : STR_NO_FOOTER; + rText = SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +SfxItemPresentation SwFmtSurround::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( (SwSurround)GetValue() ) + { + case SURROUND_NONE: + nId = STR_SURROUND_NONE; + break; + case SURROUND_THROUGHT: + nId = STR_SURROUND_THROUGHT; + break; + case SURROUND_PARALLEL: + nId = STR_SURROUND_PARALLEL; + break; + case SURROUND_IDEAL: + nId = STR_SURROUND_IDEAL; + break; + case SURROUND_LEFT: + nId = STR_SURROUND_LEFT; + break; + case SURROUND_RIGHT: + nId = STR_SURROUND_RIGHT; + break; + default:;//prevent warning + } + if ( nId ) + rText = SW_RESSTR( nId ); + + if ( IsAnchorOnly() ) + { + rText += ' '; + rText += SW_RESSTR( STR_SURROUND_ANCHORONLY ); + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +//VertOrientation, wie und woran orientiert -- +// sich der FlyFrm in der Vertikalen ----------- + + +SfxItemPresentation SwFmtVertOrient::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + String& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( GetVertOrient() ) + { + case text::VertOrientation::NONE: + { + rText += SW_RESSTR( STR_POS_Y ); + rText += ' '; + rText += ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ); + rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + break; + case text::VertOrientation::TOP: + nId = STR_VERT_TOP; + break; + case text::VertOrientation::CENTER: + nId = STR_VERT_CENTER; + break; + case text::VertOrientation::BOTTOM: + nId = STR_VERT_BOTTOM; + break; + case text::VertOrientation::LINE_TOP: + nId = STR_LINE_TOP; + break; + case text::VertOrientation::LINE_CENTER: + nId = STR_LINE_CENTER; + break; + case text::VertOrientation::LINE_BOTTOM: + nId = STR_LINE_BOTTOM; + break; + default:;//prevent warning + } + if ( nId ) + rText += SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//HoriOrientation, wie und woran orientiert -- +// sich der FlyFrm in der Hoizontalen ---------- + + +SfxItemPresentation SwFmtHoriOrient::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + String& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( GetHoriOrient() ) + { + case text::HoriOrientation::NONE: + { + rText += SW_RESSTR( STR_POS_X ); + rText += ' '; + rText += ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ); + rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + break; + case text::HoriOrientation::RIGHT: + nId = STR_HORI_RIGHT; + break; + case text::HoriOrientation::CENTER: + nId = STR_HORI_CENTER; + break; + case text::HoriOrientation::LEFT: + nId = STR_HORI_LEFT; + break; + case text::HoriOrientation::INSIDE: + nId = STR_HORI_INSIDE; + break; + case text::HoriOrientation::OUTSIDE: + nId = STR_HORI_OUTSIDE; + break; + case text::HoriOrientation::FULL: + nId = STR_HORI_FULL; + break; + default:;//prevent warning + } + if ( nId ) + rText += SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//FlyAnchor, Anker des Freifliegenden Rahmen ---- + + +SfxItemPresentation SwFmtAnchor::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( GetAnchorId() ) + { + case FLY_AT_PARA: + nId = STR_FLY_AT_PARA; + break; + case FLY_AS_CHAR: + nId = STR_FLY_AS_CHAR; + break; + case FLY_AT_PAGE: + nId = STR_FLY_AT_PAGE; + break; + default:;//prevent warning + } + if ( nId ) + rText += SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +SfxItemPresentation SwFmtPageDesc::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + const SwPageDesc *pPageDesc = GetPageDesc(); + if ( pPageDesc ) + rText = pPageDesc->GetName(); + else + rText = SW_RESSTR( STR_NO_PAGEDESC ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//Der ColumnDescriptor -------------------------- + + +SfxItemPresentation SwFmtCol::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nCnt = GetNumCols(); + if ( nCnt > 1 ) + { + rText = String::CreateFromInt32(nCnt); + rText += ' '; + rText += SW_RESSTR( STR_COLUMNS ); + if ( COLADJ_NONE != GetLineAdj() ) + { + sal_uInt16 nWdth = sal_uInt16(GetLineWidth()); + rText += ' '; + rText += SW_RESSTR( STR_LINE_WIDTH ); + rText += ' '; + rText += ::GetMetricText( nWdth, eCoreUnit, + SFX_MAPUNIT_POINT, pIntl ); + } + } + else + rText.Erase(); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//URL's und Maps + + +SfxItemPresentation SwFmtURL::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText.Erase(); + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( pMap ) + rText.AppendAscii( RTL_CONSTASCII_STRINGPARAM("Client-Map")); + if ( sURL.Len() ) + { + if ( pMap ) + rText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" - ")); + rText.AppendAscii( RTL_CONSTASCII_STRINGPARAM("URL: ")); + rText += sURL; + if ( bIsServerMap ) + rText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" (Server-Map)")); + } + if ( sTargetFrameName.Len() ) + { + rText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(", Target: ")); + rText += sTargetFrameName; + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +//SwFmtEditInReadonly + + +SfxItemPresentation SwFmtEditInReadonly::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText.Erase(); + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( GetValue() ) + rText = SW_RESSTR(STR_EDIT_IN_READONLY); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +SfxItemPresentation SwFmtLayoutSplit::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( GetValue() ) + rText = SW_RESSTR(STR_LAYOUT_SPLIT); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtRowSplit::GetPresentation +( + SfxItemPresentation /*ePres*/, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& /*rText*/, + const IntlWrapper* /*pIntl*/ +) const +{ + return SFX_ITEM_PRESENTATION_NONE; +} + + +SfxItemPresentation SwFmtFtnEndAtTxtEnd::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + break; + + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + switch( GetValue() ) + { + case FTNEND_ATPGORDOCEND: +// rText = SW_RESSTR( STR_LAYOUT_FTN ); + break; + + case FTNEND_ATTXTEND: + break; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + { +// String sPrefix; +// String sSuffix; +// SvxNumberType aFmt; +// sal_uInt16 nOffset; +// rText += + } + break; + } + } + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + return ePres; +} + +SfxItemPresentation SwFmtChain::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( GetPrev() || GetNext() ) + { + rText = SW_RESSTR(STR_CONNECT1); + if ( GetPrev() ) + { + rText += GetPrev()->GetName(); + if ( GetNext() ) + rText += SW_RESSTR(STR_CONNECT2); + } + if ( GetNext() ) + rText += GetNext()->GetName(); + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + + +SfxItemPresentation SwFmtLineNumber::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( IsCount() ) + rText += SW_RESSTR(STR_LINECOUNT); + else + rText += SW_RESSTR(STR_DONTLINECOUNT); + if ( GetStartValue() ) + { + rText += ' '; + rText += SW_RESSTR(STR_LINCOUNT_START); + rText += String::CreateFromInt32(GetStartValue()); + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwTextGridItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + + switch ( GetGridType() ) + { + case GRID_NONE : + nId = STR_GRID_NONE; + break; + case GRID_LINES_ONLY : + nId = STR_GRID_LINES_ONLY; + break; + case GRID_LINES_CHARS : + nId = STR_GRID_LINES_CHARS; + break; + } + if ( nId ) + rText += SW_RESSTR( nId ); + return ePres; + } + default:;//prevent warning + } + + return SFX_ITEM_PRESENTATION_NONE; +} + + +//SwHeaderAndFooterEatSpacingItem + + +SfxItemPresentation SwHeaderAndFooterEatSpacingItem::GetPresentation +( + SfxItemPresentation /*ePres*/, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + String& /*rText*/, + const IntlWrapper* /*pIntl*/ +) const +{ +// rText.Erase(); +// switch ( ePres ) +// { +// case SFX_ITEM_PRESENTATION_NONE: +// rText.Erase(); +// break; +// case SFX_ITEM_PRESENTATION_NAMELESS: +// case SFX_ITEM_PRESENTATION_COMPLETE: +// { +// if ( GetValue() ) +// rText = SW_RESSTR(STR_EDIT_IN_READONLY); +// return ePres; +// } +// } + return SFX_ITEM_PRESENTATION_NONE; +} + + +// ---------------------- Grafik-Attribute -------------------------- + +SfxItemPresentation SwMirrorGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String& rText, const IntlWrapper* /*pIntl*/ ) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId; + switch( GetValue() ) + { + case RES_MIRROR_GRAPH_DONT: nId = STR_NO_MIRROR; break; + case RES_MIRROR_GRAPH_VERT: nId = STR_VERT_MIRROR; break; + case RES_MIRROR_GRAPH_HOR: nId = STR_HORI_MIRROR; break; + case RES_MIRROR_GRAPH_BOTH: nId = STR_BOTH_MIRROR; break; + default: nId = 0; break; + } + if ( nId ) + { + rText = SW_RESSTR( nId ); + if (bGrfToggle) + rText += SW_RESSTR( STR_MIRROR_TOGGLE ); + } + } + break; + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + + +SfxItemPresentation SwRotationGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + rText = SW_RESSTR( STR_ROTATION ); + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromInt32( GetValue() )) += '\xB0'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwLuminanceGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + rText = SW_RESSTR( STR_LUMINANCE ); + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromInt32( GetValue() )) += '%'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwContrastGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + rText = SW_RESSTR( STR_CONTRAST ); + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromInt32( GetValue() )) += '%'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwChannelGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + { + sal_uInt16 nId; + switch ( Which() ) + { + case RES_GRFATR_CHANNELR: nId = STR_CHANNELR; break; + case RES_GRFATR_CHANNELG: nId = STR_CHANNELG; break; + case RES_GRFATR_CHANNELB: nId = STR_CHANNELB; break; + default: nId = 0; break; + } + if( nId ) + rText = SW_RESSTR( nId ); + else if( rText.Len() ) + rText.Erase(); + } + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromInt32( GetValue() )) += '%'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwGammaGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + rText = SW_RESSTR( STR_GAMMA ); + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromDouble( GetValue() )) += '%'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwInvertGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + rText.Erase(); + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + { + sal_uInt16 nId = 0 != GetValue() ? STR_INVERT : STR_INVERT_NOT; + rText = SW_RESSTR( nId ); + } + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + return ePres; +} + +SfxItemPresentation SwTransparencyGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + rText = SW_RESSTR( STR_TRANSPARENCY ); + else if( rText.Len() ) + rText.Erase(); + ( rText += UniString::CreateFromInt32( GetValue() )) += '%'; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText.Erase(); + break; + } + return ePres; +} + +SfxItemPresentation SwDrawModeGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + String &rText, const IntlWrapper* /*pIntl*/) const +{ + rText.Erase(); + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + { + sal_uInt16 nId; + switch ( GetValue() ) + { + + case GRAPHICDRAWMODE_GREYS: nId = STR_DRAWMODE_GREY; break; + case GRAPHICDRAWMODE_MONO: nId = STR_DRAWMODE_BLACKWHITE; break; + case GRAPHICDRAWMODE_WATERMARK: nId = STR_DRAWMODE_WATERMARK; break; + default: nId = STR_DRAWMODE_STD; break; + } + (rText = SW_RESSTR( STR_DRAWMODE ) ) += SW_RESSTR( nId ); + } + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + return ePres; +} + +SfxItemPresentation SwFmtFollowTextFlow::GetPresentation( SfxItemPresentation ePres, + SfxMapUnit /*eCoreMetric*/, + SfxMapUnit /*ePresMetric*/, + String &rText, + const IntlWrapper* /*pIntl*/ ) const +{ + rText.Erase(); + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + break; + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = GetValue() ? STR_FOLLOW_TEXT_FLOW : STR_DONT_FOLLOW_TEXT_FLOW; + rText = SW_RESSTR( nId ); + } + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + return ePres; +} + diff --git a/sw/source/ui/utlui/attrdesc.hrc b/sw/source/ui/utlui/attrdesc.hrc new file mode 100644 index 000000000000..1f2c5d34fa37 --- /dev/null +++ b/sw/source/ui/utlui/attrdesc.hrc @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _ATTRDESC_HRC +#define _ATTRDESC_HRC + +#include "rcid.hrc" + +#define STR_DROP_OVER (RC_ATTR_BEGIN + 1) +#define STR_DROP_LINES (RC_ATTR_BEGIN + 2) +#define STR_NO_DROP_LINES (RC_ATTR_BEGIN + 3) +#define STR_NO_PAGEDESC (RC_ATTR_BEGIN + 4) +#define STR_NO_MIRROR (RC_ATTR_BEGIN + 5) +#define STR_VERT_MIRROR (RC_ATTR_BEGIN + 6) +#define STR_HORI_MIRROR (RC_ATTR_BEGIN + 7) +#define STR_BOTH_MIRROR (RC_ATTR_BEGIN + 8) +#define STR_CHARFMT (RC_ATTR_BEGIN + 9) +#define STR_NO_CHARFMT (RC_ATTR_BEGIN + 10) +#define STR_FOOTER (RC_ATTR_BEGIN + 11) +#define STR_NO_FOOTER (RC_ATTR_BEGIN + 12) +#define STR_HEADER (RC_ATTR_BEGIN + 13) +#define STR_NO_HEADER (RC_ATTR_BEGIN + 14) +#define STR_SURROUND_NONE (RC_ATTR_BEGIN + 15) +#define STR_SURROUND_THROUGHT (RC_ATTR_BEGIN + 16) +#define STR_SURROUND_PARALLEL (RC_ATTR_BEGIN + 17) +#define STR_SURROUND_COLUMN (RC_ATTR_BEGIN + 18) +#define STR_SURROUND_LEFT (RC_ATTR_BEGIN + 19) +#define STR_SURROUND_RIGHT (RC_ATTR_BEGIN + 20) +#define STR_SURROUND_INSIDE (RC_ATTR_BEGIN + 21) +#define STR_SURROUND_OUTSIDE (RC_ATTR_BEGIN + 22) +#define STR_FRM_WIDTH (RC_ATTR_BEGIN + 23) +#define STR_FRM_FIXEDHEIGHT (RC_ATTR_BEGIN + 24) +#define STR_FRM_MINHEIGHT (RC_ATTR_BEGIN + 25) +#define STR_FLY_AT_PARA (RC_ATTR_BEGIN + 26) +#define STR_FLY_AS_CHAR (RC_ATTR_BEGIN + 27) +#define STR_FLY_AT_PAGE (RC_ATTR_BEGIN + 28) +#define STR_POS_X (RC_ATTR_BEGIN + 29) +#define STR_POS_Y (RC_ATTR_BEGIN + 30) +#define STR_VERT_TOP (RC_ATTR_BEGIN + 31) +#define STR_VERT_CENTER (RC_ATTR_BEGIN + 32) +#define STR_VERT_BOTTOM (RC_ATTR_BEGIN + 33) +#define STR_HORI_RIGHT (RC_ATTR_BEGIN + 34) +#define STR_HORI_CENTER (RC_ATTR_BEGIN + 35) +#define STR_HORI_LEFT (RC_ATTR_BEGIN + 36) +#define STR_HORI_INSIDE (RC_ATTR_BEGIN + 37) +#define STR_HORI_OUTSIDE (RC_ATTR_BEGIN + 38) +#define STR_HORI_FULL (RC_ATTR_BEGIN + 39) +#define STR_COLUMNS (RC_ATTR_BEGIN + 40) +#define STR_LINE_WIDTH (RC_ATTR_BEGIN + 41) +#define STR_MAX_FTN_HEIGHT (RC_ATTR_BEGIN + 42) +#define STR_SURROUND_IDEAL (RC_ATTR_BEGIN + 43) +#define STR_LINE_TOP (RC_ATTR_BEGIN + 44) +#define STR_LINE_CENTER (RC_ATTR_BEGIN + 45) +#define STR_LINE_BOTTOM (RC_ATTR_BEGIN + 46) +#define STR_REGISTER_ON (RC_ATTR_BEGIN + 47) +#define STR_REGISTER_OFF (RC_ATTR_BEGIN + 48) +#define STR_SURROUND_ANCHORONLY (RC_ATTR_BEGIN + 49) +#define STR_EDIT_IN_READONLY (RC_ATTR_BEGIN + 50) +#define STR_LAYOUT_SPLIT (RC_ATTR_BEGIN + 51) +#define STR_NUMRULE_ON (RC_ATTR_BEGIN + 52) +#define STR_NUMRULE_OFF (RC_ATTR_BEGIN + 53) +#define STR_CONNECT1 (RC_ATTR_BEGIN + 54) +#define STR_CONNECT2 (RC_ATTR_BEGIN + 55) +#define STR_MIRROR_TOGGLE (RC_ATTR_BEGIN + 56) +#define STR_LINECOUNT (RC_ATTR_BEGIN + 57) +#define STR_DONTLINECOUNT (RC_ATTR_BEGIN + 58) +#define STR_LINCOUNT_START (RC_ATTR_BEGIN + 59) + +#define STR_LUMINANCE (RC_ATTR_BEGIN + 60) +#define STR_CHANNELR (RC_ATTR_BEGIN + 61) +#define STR_CHANNELG (RC_ATTR_BEGIN + 62) +#define STR_CHANNELB (RC_ATTR_BEGIN + 63) +#define STR_CONTRAST (RC_ATTR_BEGIN + 64) +#define STR_GAMMA (RC_ATTR_BEGIN + 65) +#define STR_TRANSPARENCY (RC_ATTR_BEGIN + 66) +#define STR_INVERT (RC_ATTR_BEGIN + 67) +#define STR_INVERT_NOT (RC_ATTR_BEGIN + 68) +#define STR_DRAWMODE (RC_ATTR_BEGIN + 69) +#define STR_DRAWMODE_STD (RC_ATTR_BEGIN + 70) +#define STR_DRAWMODE_GREY (RC_ATTR_BEGIN + 71) +#define STR_DRAWMODE_BLACKWHITE (RC_ATTR_BEGIN + 72) +#define STR_DRAWMODE_WATERMARK (RC_ATTR_BEGIN + 73) +#define STR_ROTATION (RC_ATTR_BEGIN + 74) +#define STR_GRID_NONE (RC_ATTR_BEGIN + 75) +#define STR_GRID_LINES_ONLY (RC_ATTR_BEGIN + 76) +#define STR_GRID_LINES_CHARS (RC_ATTR_BEGIN + 77) +#define STR_FOLLOW_TEXT_FLOW (RC_ATTR_BEGIN + 78) +#define STR_DONT_FOLLOW_TEXT_FLOW (RC_ATTR_BEGIN + 79) +#define STR_CONNECT_BORDER_ON (RC_ATTR_BEGIN + 80) +#define STR_CONNECT_BORDER_OFF (RC_ATTR_BEGIN + 81) + + +#define ATTR_ACT_END STR_CONNECT_BORDER_OFF + +#if ATTR_ACT_END > RC_ATTR_END +#error Resource-Id Ueberlauf in #file, #line +#endif + +#endif diff --git a/sw/source/ui/utlui/attrdesc.src b/sw/source/ui/utlui/attrdesc.src new file mode 100644 index 000000000000..809af110da6f --- /dev/null +++ b/sw/source/ui/utlui/attrdesc.src @@ -0,0 +1,384 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "globals.hrc" +#include "attrdesc.hrc" +/*--------------------------------------------------------------------- + Strings fuer textuelle Attribute + ---------------------------------------------------------------------*/ +String STR_DROP_OVER +{ + /* ### ACHTUNG: Neuer Text in Resource? Initialen über : Initialen ³ber */ + Text [ en-US ] = "Drop Caps over" ; +}; +String STR_DROP_LINES +{ + Text [ en-US ] = "rows" ; +}; +String STR_NO_DROP_LINES +{ + Text [ en-US ] = "No Drop Caps" ; +}; +String STR_NO_PAGEDESC +{ + Text [ en-US ] = "No page break" ; +}; +String STR_NO_MIRROR +{ + Text [ en-US ] = "Don't mirror" ; +}; +String STR_VERT_MIRROR +{ + Text [ en-US ] = "Flip vertically" ; +}; +String STR_HORI_MIRROR +{ + Text [ en-US ] = "Flip horizontal" ; +}; +String STR_BOTH_MIRROR +{ + Text [ en-US ] = "Horizontal and Vertical Flip" ; +}; +String STR_MIRROR_TOGGLE +{ + Text [ en-US ] = "+ mirror horizontal on even pages" ; +}; +String STR_CHARFMT +{ + Text [ en-US ] = "Character Style" ; +}; +String STR_NO_CHARFMT +{ + Text [ en-US ] = "No Character Style" ; +}; +String STR_FOOTER +{ + /* ### ACHTUNG: Neuer Text in Resource? Fußzeile : Fu˜zeile */ + Text [ en-US ] = "Footer" ; +}; +String STR_NO_FOOTER +{ + /* ### ACHTUNG: Neuer Text in Resource? keine Fußzeile : keine Fu˜zeile */ + Text [ en-US ] = "No footer" ; +}; +String STR_HEADER +{ + Text [ en-US ] = "Header" ; +}; +String STR_NO_HEADER +{ + Text [ en-US ] = "No header" ; +}; +String STR_SURROUND_IDEAL +{ + Text [ en-US ] = "Optimal wrap" ; +}; +String STR_SURROUND_NONE +{ + Text [ en-US ] = "No wrap" ; +}; +String STR_SURROUND_THROUGHT +{ + Text [ en-US ] = "Through" ; +}; +String STR_SURROUND_PARALLEL +{ + Text [ en-US ] = "Parallel wrap" ; +}; +String STR_SURROUND_COLUMN +{ + Text [ en-US ] = "Column Wrap" ; +}; +String STR_SURROUND_LEFT +{ + Text [ en-US ] = "Left wrap" ; +}; +String STR_SURROUND_RIGHT +{ + Text [ en-US ] = "Right wrap" ; +}; +String STR_SURROUND_INSIDE +{ + Text [ en-US ] = "Inner wrap" ; +}; +String STR_SURROUND_OUTSIDE +{ + /* ### ACHTUNG: Neuer Text in Resource? Umlauf außen : Umlauf au˜en */ + Text [ en-US ] = "Outer wrap" ; +}; +String STR_SURROUND_ANCHORONLY +{ + Text [ en-US ] = "(Anchor only)" ; +}; +String STR_FRM_WIDTH +{ + Text [ en-US ] = "Width:" ; +}; +String STR_FRM_FIXEDHEIGHT +{ + /* ### ACHTUNG: Neuer Text in Resource? feste Höhe: : feste H÷he: */ + Text [ en-US ] = "Fixed height:" ; +}; +String STR_FRM_MINHEIGHT +{ + /* ### ACHTUNG: Neuer Text in Resource? min. Höhe: : min. H÷he: */ + Text [ en-US ] = "Min. height:" ; +}; +String STR_FLY_AT_PARA +{ + Text [ en-US ] = "to paragraph" ; +}; +String STR_FLY_AS_CHAR +{ + Text [ en-US ] = "to character" ; +}; +String STR_FLY_AT_PAGE +{ + Text [ en-US ] = "to page" ; +}; +String STR_POS_X +{ + Text [ en-US ] = "X Coordinate:" ; +}; +String STR_POS_Y +{ + Text [ en-US ] = "Y Coordinate:" ; +}; +String STR_VERT_TOP +{ + Text [ en-US ] = "at top" ; +}; +String STR_VERT_CENTER +{ + Text [ en-US ] = "Centered vertically" ; +}; +String STR_VERT_BOTTOM +{ + Text [ en-US ] = "at bottom" ; +}; +String STR_LINE_TOP +{ + Text [ en-US ] = "Top of line" ; +}; +String STR_LINE_CENTER +{ + Text [ en-US ] = "Line centered" ; +}; +String STR_LINE_BOTTOM +{ + Text [ en-US ] = "Bottom of line" ; +}; +String STR_REGISTER_ON +{ + Text [ en-US ] = "Register-true" ; +}; +String STR_REGISTER_OFF +{ + Text [ en-US ] = "Not register-true" ; +}; +String STR_HORI_RIGHT +{ + Text [ en-US ] = "at the right" ; +}; +String STR_HORI_CENTER +{ + Text [ en-US ] = "Centered horizontally" ; +}; +String STR_HORI_LEFT +{ + Text [ en-US ] = "at the left" ; +}; +String STR_HORI_INSIDE +{ + Text [ en-US ] = "inside" ; +}; +String STR_HORI_OUTSIDE +{ + /* ### ACHTUNG: Neuer Text in Resource? außen : au˜en */ + Text [ en-US ] = "outside" ; +}; +String STR_HORI_FULL +{ + Text [ en-US ] = "Full width" ; +}; +String STR_COLUMNS +{ + Text [ en-US ] = "Columns" ; +}; +String STR_LINE_WIDTH +{ + Text [ en-US ] = "Separator Width:" ; +}; +String STR_MAX_FTN_HEIGHT +{ + /* ### ACHTUNG: Neuer Text in Resource? max. Fußnotenbereich: : max. Fu˜notenbereich: */ + Text [ en-US ] = "Max. footnote area:" ; +}; +String STR_EDIT_IN_READONLY +{ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im Schreibeschütztem Dokument */ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im Schreibeschütztem Dokument */ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im Schreibeschütztem Dokument */ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im Schreibeschütztem Dokument */ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im Schreibeschütztem Dokument */ + /* ### ACHTUNG: Neuer Text in Resource? editierbar im schreibgeschütztem Dokument : editierbar im schreibgesch³tztem Dokument */ + Text [ en-US ] = "Editable in read-only document" ; +}; +String STR_LAYOUT_SPLIT +{ + Text [ en-US ] = "Split" ; +}; +String STR_NUMRULE_ON +{ + Text [ en-US ] = "Numbering" ; +}; +String STR_NUMRULE_OFF +{ + Text [ en-US ] = "no numbering" ; +}; +String STR_CONNECT1 +{ + Text [ en-US ] = "linked to " ; +}; +String STR_CONNECT2 +{ + Text [ en-US ] = "and " ; +}; +String STR_LINECOUNT +{ + Text [ en-US ] = "Count lines" ; +}; +String STR_DONTLINECOUNT +{ + Text [ en-US ] = "don't count lines" ; +}; +String STR_LINCOUNT_START +{ + Text [ en-US ] = "restart line count with: " ; +}; + +String STR_LUMINANCE +{ + Text [ en-US ] = "Brightness: "; +}; + +String STR_CHANNELR +{ + Text [ en-US ] = "Red: "; +}; + +String STR_CHANNELG +{ + Text [ en-US ] = "Green: "; +}; + +String STR_CHANNELB +{ + Text [ en-US ] = "Blue: "; +}; + +String STR_CONTRAST +{ + Text [ en-US ] = "Contrast: "; +}; + +String STR_GAMMA +{ + Text [ en-US ] = "Gamma: "; +}; + +String STR_TRANSPARENCY +{ + Text [ en-US ] = "Transparency: "; +}; + +String STR_INVERT +{ + Text [ en-US ] = "Invert"; +}; +String STR_INVERT_NOT +{ + Text [ en-US ] = "do not invert"; +}; + +String STR_DRAWMODE +{ + Text [ en-US ] = "Graphics mode: "; +}; + +String STR_DRAWMODE_STD +{ + Text [ en-US ] = "Standard"; +}; +String STR_DRAWMODE_GREY +{ + Text [ en-US ] = "Grayscales"; +}; +String STR_DRAWMODE_BLACKWHITE +{ + Text [ en-US ] = "Black & White"; +}; +String STR_DRAWMODE_WATERMARK +{ + Text [ en-US ] = "Watermark"; +}; +String STR_ROTATION +{ + Text [ en-US ] = "Rotation"; +}; + +String STR_GRID_NONE +{ + Text [ en-US ] = "No grid"; +}; + +String STR_GRID_LINES_ONLY +{ + Text [ en-US ] = "Grid (lines only)"; +}; + +String STR_GRID_LINES_CHARS +{ + Text [ en-US ] = "Grid (lines and characters)"; +}; +String STR_FOLLOW_TEXT_FLOW +{ + Text [ en-US ] = "Follow text flow"; +}; +String STR_DONT_FOLLOW_TEXT_FLOW +{ + Text [ en-US ] = "Do not follow text flow"; +}; +String STR_CONNECT_BORDER_ON +{ + Text [ en-US ] = "Merge borders"; +}; +String STR_CONNECT_BORDER_OFF +{ + Text [ en-US ] = "Do not merge borders"; +}; + diff --git a/sw/source/ui/utlui/bookctrl.cxx b/sw/source/ui/utlui/bookctrl.cxx new file mode 100644 index 000000000000..5b112f84ba0d --- /dev/null +++ b/sw/source/ui/utlui/bookctrl.cxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include "hintids.hxx" + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_USHORTS +#include <svl/svstdarr.hxx> +#endif +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <sfx2/dispatch.hxx> +#ifndef _EVENT_HXX //autogen +#include <vcl/event.hxx> +#endif +#ifndef _STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif +#ifndef _MENU_HXX //autogen +#include <vcl/menu.hxx> +#endif +#include "cmdid.h" +#include "errhdl.hxx" +#include "swmodule.hxx" +#include "wrtsh.hxx" +#include "IMark.hxx" +#include "bookctrl.hxx" +#include <map> + +SFX_IMPL_STATUSBAR_CONTROL( SwBookmarkControl, SfxStringItem ); + +// class BookmarkPopup_Impl -------------------------------------------------- + +class BookmarkPopup_Impl : public PopupMenu +{ +public: + BookmarkPopup_Impl(); + + sal_uInt16 GetCurId() const { return nCurId; } + +private: + sal_uInt16 nCurId; + + virtual void Select(); +}; + +// ----------------------------------------------------------------------- + +BookmarkPopup_Impl::BookmarkPopup_Impl() : + PopupMenu(), + nCurId(USHRT_MAX) +{ +} + +// ----------------------------------------------------------------------- + +void BookmarkPopup_Impl::Select() +{ + nCurId = GetCurItemId(); +} + +// class SvxZoomStatusBarControl ------------------------------------------ + +SwBookmarkControl::SwBookmarkControl( sal_uInt16 _nSlotId, + sal_uInt16 _nId, + StatusBar& rStb ) : + SfxStatusBarControl( _nSlotId, _nId, rStb ) +{ +} + +// ----------------------------------------------------------------------- + +SwBookmarkControl::~SwBookmarkControl() +{ +} + +// ----------------------------------------------------------------------- + +void SwBookmarkControl::StateChanged( + sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) +{ + if( eState != SFX_ITEM_AVAILABLE || pState->ISA( SfxVoidItem ) ) + GetStatusBar().SetItemText( GetId(), String() ); + else if ( pState->ISA( SfxStringItem ) ) + { + sPageNumber = ((SfxStringItem*)pState)->GetValue(); + GetStatusBar().SetItemText( GetId(), sPageNumber ); + } +} + +// ----------------------------------------------------------------------- + +void SwBookmarkControl::Paint( const UserDrawEvent& ) +{ + GetStatusBar().SetItemText( GetId(), sPageNumber ); +} + +// ----------------------------------------------------------------------- + +void SwBookmarkControl::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && + GetStatusBar().GetItemText( GetId() ).Len() ) + { + CaptureMouse(); + BookmarkPopup_Impl aPop; + SwWrtShell* pWrtShell = ::GetActiveWrtShell(); + if( pWrtShell && pWrtShell->getIDocumentMarkAccess()->getMarksCount() > 0 ) + { + IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); + IDocumentMarkAccess::const_iterator_t ppBookmarkStart = pMarkAccess->getBookmarksBegin(); + sal_uInt16 nPopupId = 1; + ::std::map<sal_Int32, sal_uInt16> aBookmarkIdx; + for(IDocumentMarkAccess::const_iterator_t ppBookmark = ppBookmarkStart; + ppBookmark != pMarkAccess->getBookmarksEnd(); + ppBookmark++) + { + if(IDocumentMarkAccess::BOOKMARK == IDocumentMarkAccess::GetType(**ppBookmark)) + { + aPop.InsertItem( nPopupId, ppBookmark->get()->GetName() ); + aBookmarkIdx[nPopupId] = static_cast<sal_uInt16>(ppBookmark - ppBookmarkStart); + nPopupId++; + } + } + aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); + sal_uInt16 nCurrId = aPop.GetCurId(); + if( nCurrId != USHRT_MAX) + { + SfxUInt16Item aBookmark( FN_STAT_BOOKMARK, aBookmarkIdx[nCurrId] ); + SfxViewFrame::Current()->GetDispatcher()->Execute( FN_STAT_BOOKMARK, + SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, + &aBookmark, 0L ); + } + } + ReleaseMouse(); + } +} diff --git a/sw/source/ui/utlui/condedit.cxx b/sw/source/ui/utlui/condedit.cxx new file mode 100644 index 000000000000..ed2379dae8b1 --- /dev/null +++ b/sw/source/ui/utlui/condedit.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +// include --------------------------------------------------------------- + + +#include <sot/formats.hxx> + +#ifndef _CONDEDIT_HXX +#include <condedit.hxx> +#endif +#include <svx/dbaexchange.hxx> +using namespace ::svx; +using ::rtl::OUString; +using namespace ::com::sun::star::uno; +#define DB_DD_DELIM 0x0b + +// STATIC DATA ----------------------------------------------------------- + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +ConditionEdit::ConditionEdit( Window* pParent, const ResId& rResId ) + : Edit( pParent, rResId ), + DropTargetHelper( this ), + bBrackets( sal_True ), bEnableDrop( sal_True ) +{ +} + +/*-------------------------------------------------------------------- + Beschreibung: Drop moeglich, bzw Format bekannt? + --------------------------------------------------------------------*/ + +sal_Int8 ConditionEdit::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) +{ + return OColumnTransferable::canExtractColumnDescriptor + ( GetDataFlavorExVector(), + CTF_COLUMN_DESCRIPTOR ) + ? DND_ACTION_COPY + : DND_ACTION_NONE; +} + +sal_Int8 ConditionEdit::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + sal_Int8 nRet = DND_ACTION_NONE; + if( bEnableDrop ) + { + String sTxt; + TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); + + DataFlavorExVector& rVector = aData.GetDataFlavorExVector(); + if(OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR)) + { + ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor( + aData); + String sDBName; + if (bBrackets) + sDBName += '['; + OUString sTmp; + sTmp = aColDesc.getDataSource(); + sDBName += String(sTmp); + sDBName += '.'; + + aColDesc[daCommand] >>= sTmp; + sDBName += String(sTmp); + sDBName += '.'; + + aColDesc[daColumnName] >>= sTmp; + sDBName += String(sTmp); + if (bBrackets) + sDBName += ']'; + + SetText( sDBName ); + nRet = DND_ACTION_COPY; + } + } + return nRet; +} + + diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx new file mode 100644 index 000000000000..62ceb3860fe6 --- /dev/null +++ b/sw/source/ui/utlui/content.cxx @@ -0,0 +1,3250 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_STRINGSDTOR +#include <svl/svstdarr.hxx> +#endif +#include <svl/urlbmk.hxx> +#include <tools/urlobj.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/help.hxx> +#include <sot/formats.hxx> +#include <vcl/sound.hxx> +#include <uiitems.hxx> +#include <fmtinfmt.hxx> +#include <txtinet.hxx> +#include <fmtfld.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <errhdl.hxx> +#include <docsh.hxx> +#include <content.hxx> +#include <frmfmt.hxx> +#include <fldbas.hxx> +#include <txtatr.hxx> +#include <IMark.hxx> +#include <section.hxx> +#include <tox.hxx> +#define NAVIPI_CXX +#include <navipi.hxx> +#include <navicont.hxx> +#include <navicfg.hxx> +#include <edtwin.hxx> +#include <doc.hxx> +#include <unotools.hxx> +#include <crsskip.hxx> +#include <cmdid.h> +#include <helpid.h> +#include <navipi.hrc> +#include <utlui.hrc> +#include <misc.hrc> +#include <comcore.hrc> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> +#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/text/XBookmarksSupplier.hpp> +#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <dcontact.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdview.hxx> +#include <vcl/scrbar.hxx> +#include <comcore.hrc> +#include <SwRewriter.hxx> +#include <hints.hxx> +#include <numrule.hxx> +#include <swundo.hxx> +#include <ndtxt.hxx> +#include <PostItMgr.hxx> +#include <postithelper.hxx> +#include <redline.hxx> +#include <docary.hxx> + +#include "swabstdlg.hxx" +#include "globals.hrc" +#include <unomid.h> + + +#define CTYPE_CNT 0 +#define CTYPE_CTT 1 + +using namespace ::std; +using namespace ::com::sun::star; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; + + +#define NAVI_BOOKMARK_DELIM (sal_Unicode)1 + +/*************************************************************************** + +***************************************************************************/ + +typedef SwContent* SwContentPtr; +SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0,4) +SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr) + +sal_Bool SwContentTree::bIsInDrag = sal_False; + + +namespace +{ + static sal_Bool lcl_IsContent(SvLBoxEntry* pEntry) + { + return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT; + } + + + static sal_Bool lcl_IsContentType(SvLBoxEntry* pEntry) + { + return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT; + } + + + static sal_Bool lcl_FindShell(SwWrtShell* pShell) + { + sal_Bool bFound = sal_False; + SwView *pView = SwModule::GetFirstView(); + while (pView) + { + if(pShell == &pView->GetWrtShell()) + { + bFound = sal_True; + break; + } + pView = SwModule::GetNextView(pView); + } + return bFound; + } + + static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark) + { + return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK; + } +} + +/*************************************************************************** + Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhalstyp +***************************************************************************/ + + +SwContent::SwContent(const SwContentType* pCnt, const String& rName, long nYPos) : + SwTypeNumber(CTYPE_CNT), + pParent(pCnt), + sContentName(rName), + nYPosition(nYPos), + bInvisible(sal_False) +{ +} + + +sal_uInt8 SwTypeNumber::GetTypeId() +{ + return nTypeId; +} + +SwTypeNumber::~SwTypeNumber() +{ +} + +sal_Bool SwContent::IsProtect() const +{ + return sal_False; +} + +sal_Bool SwPostItContent::IsProtect() const +{ + if (mbPostIt) + return pFld->IsProtect(); + else + return false; +} + +sal_Bool SwURLFieldContent::IsProtect() const +{ + return pINetAttr->IsProtect(); +} + +SwGraphicContent::~SwGraphicContent() +{ +} +SwTOXBaseContent::~SwTOXBaseContent() +{ +} + +/*************************************************************************** + Beschreibung: Inhaltstyp, kennt seine Inhalte und die WrtShell +***************************************************************************/ + + +SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) : + SwTypeNumber(CTYPE_CTT), + pWrtShell(pShell), + pMember(0), + sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)), + sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)), + nMemberCount(0), + nContentType(nType), + nOutlineLevel(nLevel), + bMemberFilled(sal_False), + bDataValid(sal_False), + bEdit(sal_False), + bDelete(sal_True) +{ + Init(); +} + +/*************************************************************************** + Beschreibung: Initialisierung +***************************************************************************/ + + +void SwContentType::Init(sal_Bool* pbInvalidateWindow) +{ + // wenn sich der MemberCount aendert ... + sal_uInt16 nOldMemberCount = nMemberCount; + nMemberCount = 0; + switch(nContentType) + { + case CONTENT_TYPE_OUTLINE : + { + sTypeToken = C2S(pMarkToOutline); + sal_uInt16 nOutlineCount = nMemberCount = + static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()); + if(nOutlineLevel < MAXLEVEL) + { + for(sal_uInt16 j = 0; j < nOutlineCount; j++) + { + if(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(j) > nOutlineLevel ) + nMemberCount --; + } + } + bDelete = sal_False; + } + break; + + case CONTENT_TYPE_TABLE : + sTypeToken = C2S(pMarkToTable); + nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True); + bEdit = sal_True; + break; + + case CONTENT_TYPE_FRAME : + case CONTENT_TYPE_GRAPHIC : + case CONTENT_TYPE_OLE : + { + FlyCntType eType = FLYCNTTYPE_FRM; + sTypeToken = C2S(pMarkToFrame); + if(nContentType == CONTENT_TYPE_OLE) + { + eType = FLYCNTTYPE_OLE; + sTypeToken = C2S(pMarkToOLE); + } + else if(nContentType == CONTENT_TYPE_GRAPHIC) + { + eType = FLYCNTTYPE_GRF; + sTypeToken = C2S(pMarkToGraphic); + } + nMemberCount = pWrtShell->GetFlyCount(eType); + bEdit = sal_True; + } + break; + case CONTENT_TYPE_BOOKMARK: + { + IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); + nMemberCount = static_cast<sal_uInt16>(count_if( + pMarkAccess->getBookmarksBegin(), + pMarkAccess->getBookmarksEnd(), + &lcl_IsUiVisibleBookmark)); + sTypeToken = aEmptyStr; + bEdit = sal_True; + } + break; + case CONTENT_TYPE_REGION : + { + SwContentArr* pOldMember = 0; + sal_uInt16 nOldRegionCount = 0; + sal_Bool bInvalidate = sal_False; + if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + { + pOldMember = pMember; + nOldRegionCount = pOldMember->Count(); + pMember = new SwContentArr; + } + const Point aNullPt; + nMemberCount = pWrtShell->GetSectionFmtCount(); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwSectionFmt* pFmt; + SectionType eTmpType; + if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() && + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + const String& rSectionName = + pFmt->GetSection()->GetSectionName(); + sal_uInt8 nLevel = 0; + SwSectionFmt* pParentFmt = pFmt->GetParent(); + while(pParentFmt) + { + nLevel++; + pParentFmt = pParentFmt->GetParent(); + } + + SwContent* pCnt = new SwRegionContent(this, rSectionName, + nLevel, + pFmt->FindLayoutRect( sal_False, &aNullPt ).Top()); + + SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); + if( !pFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->Insert(pCnt);//, pMember->Count()); + + sal_uInt16 nPos = pMember->Count() - 1; + if(nOldRegionCount > nPos && + (pOldMember->GetObject(nPos))->IsInvisible() + != pCnt->IsInvisible()) + bInvalidate = sal_True; + } + } + nMemberCount = pMember->Count(); + sTypeToken = C2S(pMarkToRegion); + bEdit = sal_True; + bDelete = sal_False; + if(pOldMember) + { + pOldMember->DeleteAndDestroy(0, pOldMember->Count()); + delete pOldMember; + if(pbInvalidateWindow && bInvalidate) + *pbInvalidateWindow = sal_True; + } + } + break; + case CONTENT_TYPE_INDEX: + { + nMemberCount = pWrtShell->GetTOXCount(); + bEdit = sal_True; + bDelete = sal_False; + } + break; + case CONTENT_TYPE_REFERENCE: + { + nMemberCount = pWrtShell->GetRefMarks( 0 ); + bDelete = sal_False; + } + break; + case CONTENT_TYPE_URLFIELD: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + pMember->DeleteAndDestroy(0, pMember->Count()); + + SwGetINetAttrs aArr; + nMemberCount = pWrtShell->GetINetAttrs( aArr ); + for( sal_uInt16 n = 0; n < nMemberCount; ++n ) + { + SwGetINetAttr* p = aArr[ n ]; + SwURLFieldContent* pCnt = new SwURLFieldContent( + this, + p->sText, + INetURLObject::decode( + p->rINetAttr.GetINetFmt().GetValue(), + INET_HEX_ESCAPE, + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + &p->rINetAttr, + n ); + pMember->Insert( pCnt );//, n ); + } + bEdit = sal_True; + nOldMemberCount = nMemberCount; + bDelete = sal_False; + } + break; + case CONTENT_TYPE_POSTIT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + pMember->DeleteAndDestroy(0, pMember->Count()); + + SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); + if (aMgr) + { + for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) + { + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit + { + SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + String sEntry = aFmtFld->GetFld()->GetPar2(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + (const SwFmtFld*)aFmtFld, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + /* + // this code can be used once we want redline comments in the margin + else // redcomment + { + SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster()); + if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) ) + { + String sEntry = pRedline->GetComment(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, // hier steht der Text + pRedline, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + */ + } + } + // + sTypeToken = aEmptyStr; + bEdit = sal_True; + nOldMemberCount = nMemberCount; + } + break; + case CONTENT_TYPE_DRAWOBJECT: + { + sTypeToken = aEmptyStr; + nMemberCount = 0; + SdrModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel(); + if(pModel) + { + SdrPage* pPage = pModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + for( sal_uInt32 i=0; i< nCount; i++ ) + { + SdrObject* pTemp = pPage->GetObj(i); + // --> OD 2006-03-09 #i51726# - all drawing objects can be named now +// if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len()) + if ( pTemp->GetName().Len() ) + // <-- + nMemberCount++; + } + } + } + break; + } + // ... dann koennen die Daten auch nicht mehr gueltig sein + // abgesehen von denen, die schon korrigiert wurden, dann ist + // nOldMemberCount doch nicht so old + if( nOldMemberCount != nMemberCount ) + bDataValid = sal_False; +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +SwContentType::~SwContentType() +{ + delete pMember; +} + +/*************************************************************************** + Beschreibung: Inhalt liefern, dazu gfs. die Liste fuellen +***************************************************************************/ + + +const SwContent* SwContentType::GetMember(sal_uInt16 nIndex) +{ + if(!bDataValid || !pMember) + { + FillMemberList(); + } + if(nIndex < pMember->Count()) + return pMember->GetObject(nIndex); + else + return 0; + +} + + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentType::Invalidate() +{ + bDataValid = sal_False; +} + +/*************************************************************************** + Beschreibung: Liste der Inhalte fuellen +***************************************************************************/ + + +void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged) +{ + SwContentArr* pOldMember = 0; + int nOldMemberCount = -1; + SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); + if(pMember && pbLevelOrVisibiblityChanged) + { + pOldMember = pMember; + nOldMemberCount = pOldMember->Count(); + pMember = new SwContentArr; + *pbLevelOrVisibiblityChanged = sal_False; + } + else if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + pMember->DeleteAndDestroy(0, pMember->Count()); + switch(nContentType) + { + case CONTENT_TYPE_OUTLINE : + { + sal_uInt16 nOutlineCount = nMemberCount = + static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()); + + sal_uInt16 nPos = 0; + for (sal_uInt16 i = 0; i < nOutlineCount; ++i) + { + const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i); + if(nLevel >= nOutlineLevel ) + nMemberCount--; + else + { + String aEntry(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i)); + aEntry.EraseLeadingChars(); + SwNavigationPI::CleanEntry( aEntry ); + SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel, + pWrtShell->IsOutlineMovable( i ), nPos ); + pMember->Insert(pCnt);//, nPos); + // bei gleicher Anzahl und vorhandenem pOldMember wird die + // alte mit der neuen OutlinePos verglichen + // cast fuer Win16 + if(nOldMemberCount > (int)nPos && + ((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel) + *pbLevelOrVisibiblityChanged = sal_True; + + nPos++; + } + } + + } + break; + + case CONTENT_TYPE_TABLE : + { + DBG_ASSERT(nMemberCount == + pWrtShell->GetTblFrmFmtCount(sal_True), + "MemberCount differiert"); + Point aNullPt; + nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, sal_True); + String sTblName( rTblFmt.GetName() ); + + SwContent* pCnt = new SwContent(this, sTblName, + rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() ); + if( !rTblFmt.GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + + pMember->Insert(pCnt);//, i); + + if(nOldMemberCount > (int)i && + (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible()) + *pbLevelOrVisibiblityChanged = sal_True; + } + } + break; + case CONTENT_TYPE_OLE : + case CONTENT_TYPE_FRAME : + case CONTENT_TYPE_GRAPHIC : + { + FlyCntType eType = FLYCNTTYPE_FRM; + if(nContentType == CONTENT_TYPE_OLE) + eType = FLYCNTTYPE_OLE; + else if(nContentType == CONTENT_TYPE_GRAPHIC) + eType = FLYCNTTYPE_GRF; + DBG_ASSERT(nMemberCount == pWrtShell->GetFlyCount(eType), + "MemberCount differiert"); + Point aNullPt; + nMemberCount = pWrtShell->GetFlyCount(eType); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType); + String sFrmName = pFrmFmt->GetName(); + + SwContent* pCnt; + if(CONTENT_TYPE_GRAPHIC == nContentType) + { + String sLink; + pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt); + pCnt = new SwGraphicContent(this, sFrmName, + INetURLObject::decode( sLink, INET_HEX_ESCAPE, + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top()); + } + else + { + pCnt = new SwContent(this, sFrmName, + pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() ); + } + if( !pFrmFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->Insert(pCnt);//, i); + if(nOldMemberCount > (int)i && + (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible()) + *pbLevelOrVisibiblityChanged = sal_True; + } + } + break; + case CONTENT_TYPE_BOOKMARK: + { + IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); + for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); + ppBookmark != pMarkAccess->getBookmarksEnd(); + ppBookmark++) + { + if(lcl_IsUiVisibleBookmark(*ppBookmark)) + { + const String& rBkmName = ppBookmark->get()->GetName(); + //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert + SwContent* pCnt = new SwContent(this, rBkmName, 0); + pMember->Insert(pCnt);//, pMember->Count()); + } + } + } + break; + case CONTENT_TYPE_REGION : + { + const Point aNullPt; + nMemberCount = pWrtShell->GetSectionFmtCount(); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwSectionFmt* pFmt; + SectionType eTmpType; + if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() && + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + String sSectionName = pFmt->GetSection()->GetSectionName(); + + sal_uInt8 nLevel = 0; + SwSectionFmt* pParentFmt = pFmt->GetParent(); + while(pParentFmt) + { + nLevel++; + pParentFmt = pParentFmt->GetParent(); + } + + SwContent* pCnt = new SwRegionContent(this, sSectionName, + nLevel, + pFmt->FindLayoutRect( sal_False, &aNullPt ).Top()); + if( !pFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->Insert(pCnt);//, pMember->Count()); + + sal_uInt16 nPos = pMember->Count() - 1; + if(nOldMemberCount > nPos && + (pOldMember->GetObject(nPos))->IsInvisible() + != pCnt->IsInvisible()) + *pbLevelOrVisibiblityChanged = sal_True; + } + } + nMemberCount = pMember->Count(); + } + break; + case CONTENT_TYPE_REFERENCE: + { + SvStringsDtor aRefMarks; + nMemberCount = pWrtShell->GetRefMarks( &aRefMarks ); + + for(sal_uInt16 i=0; i<nMemberCount; i++) + { + //Referenzen nach Alphabet sortiert + SwContent* pCnt = new SwContent( + this, *aRefMarks.GetObject(i), 0); + pMember->Insert(pCnt);//, i); + } + } + break; + case CONTENT_TYPE_URLFIELD: + { + SwGetINetAttrs aArr; + nMemberCount = pWrtShell->GetINetAttrs( aArr ); + for( sal_uInt16 n = 0; n < nMemberCount; ++n ) + { + SwGetINetAttr* p = aArr[ n ]; + SwURLFieldContent* pCnt = new SwURLFieldContent( + this, + p->sText, + INetURLObject::decode( + p->rINetAttr.GetINetFmt().GetValue(), + INET_HEX_ESCAPE, + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + &p->rINetAttr, + n ); + pMember->Insert( pCnt );//, n ); + } + } + break; + case CONTENT_TYPE_INDEX: + { + + sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount(); + for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ ) + { + const SwTOXBase* pBase = pWrtShell->GetTOX( nTox ); + String sTOXNm( pBase->GetTOXName() ); + + SwContent* pCnt = new SwTOXBaseContent( + this, sTOXNm, nTox, *pBase); + + if( !pBase->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + + pMember->Insert( pCnt );//, nTox ); + sal_uInt16 nPos = pMember->Count() - 1; + if(nOldMemberCount > nPos && + (pOldMember->GetObject(nPos))->IsInvisible() + != pCnt->IsInvisible()) + *pbLevelOrVisibiblityChanged = sal_True; + } + } + break; + case CONTENT_TYPE_POSTIT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + pMember->DeleteAndDestroy(0, pMember->Count()); + SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); + if (aMgr) + { + for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) + { + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit + { + SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + String sEntry = aFmtFld->GetFld()->GetPar2(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + (const SwFmtFld*)aFmtFld, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + /* this code can be used once we want redline comments in the margin + else // redcomment + { + SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster()); + if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) ) + { + String sEntry = pRedline->GetComment(); + RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + pRedline, + nMemberCount); + pMember->Insert(pCnt); + nMemberCount++; + } + } + */ + } + } + // + } + break; + case CONTENT_TYPE_DRAWOBJECT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(pMember->Count()) + pMember->DeleteAndDestroy(0, pMember->Count()); + + IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess(); + SdrModel* pModel = pIDDMA->GetDrawModel(); + if(pModel) + { + SdrPage* pPage = pModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + for( sal_uInt32 i=0; i< nCount; i++ ) + { + SdrObject* pTemp = pPage->GetObj(i); + // --> OD 2006-03-09 #i51726# - all drawing objects can be named now +// if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len()) + if ( pTemp->GetName().Len() ) + // <-- + { + SwContact* pContact = (SwContact*)pTemp->GetUserCall(); + long nYPos = 0; + const Point aNullPt; + if(pContact && pContact->GetFmt()) + nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top(); + SwContent* pCnt = new SwContent( + this, + pTemp->GetName(), + nYPos); + if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer())) + pCnt->SetInvisible(); + pMember->Insert(pCnt); + nMemberCount++; + if(nOldMemberCount > (int)i && + (pOldMember->GetObject((sal_uInt16)i))->IsInvisible() != pCnt->IsInvisible()) + *pbLevelOrVisibiblityChanged = sal_True; + } + } + } + } + break; + } + bDataValid = sal_True; + if(pOldMember) + pOldMember->DeleteAndDestroy(0, pOldMember->Count()); + +} + +/*************************************************************************** + Beschreibung: TreeListBox fuer Inhaltsanzeige +***************************************************************************/ + + +SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) : + SvTreeListBox( pParent, rResId ), + + sSpace(C2S(" ")), + + sRemoveIdx(SW_RES(ST_REMOVE_INDEX)), + sUpdateIdx(SW_RES(ST_UPDATE)), + sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)), + sRename(SW_RES(ST_RENAME)), + sReadonlyIdx(SW_RES(ST_READONLY_IDX)), + sInvisible(SW_RES(ST_INVISIBLE)), + + sPostItShow(SW_RES(ST_POSTIT_SHOW)), + sPostItHide(SW_RES(ST_POSTIT_HIDE)), + sPostItDelete(SW_RES(ST_POSTIT_DELETE)), + + pHiddenShell(0), + pActiveShell(0), + pConfig(SW_MOD()->GetNavigationConfig()), + + nActiveBlock(0), + nHiddenBlock(0), + + nRootType(USHRT_MAX), + nLastSelType(USHRT_MAX), + nOutlineLevel(MAXLEVEL), + + bIsActive(sal_True), + bIsConstant(sal_False), + bIsHidden(sal_False), + bDocChgdInDragging(sal_False), + bIsInternalDrag(sal_False), + bIsRoot(sal_False), + bIsIdleClear(sal_False), + bIsLastReadOnly(sal_False), + bIsOutlineMoveable(sal_True), + bViewHasChanged(sal_False), + bIsImageListInitialized(sal_False) +{ + sal_uInt16 i; + + SetHelpId(HID_NAVIGATOR_TREELIST); + + SetNodeDefaultImages(); + SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl)); + SetDragDropMode(SV_DRAGDROP_APP_COPY); + for( i = 0; i < CONTENT_TYPE_MAX; i++) + { + aActiveContentArr[i] = 0; + aHiddenContentArr[i] = 0; + } + for( i = 0; i < CONTEXT_COUNT; i++ ) + { + aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST); + } + nActiveBlock = pConfig->GetActiveBlock(); + aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate)); + aUpdTimer.SetTimeout(1000); + Clear(); + EnableContextMenuHandling(); + SetStyle( GetStyle() | WB_QUICK_SEARCH ); +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +SwContentTree::~SwContentTree() +{ + Clear(); // vorher gfs. Inhaltstypen loeschen + bIsInDrag = sal_False; +} + +/*************************************************************************** + Drag&Drop methods +***************************************************************************/ + +void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel ) +{ + if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE ) + { + ReleaseMouse(); + + TransferDataContainer* pContainer = new TransferDataContainer; + uno::Reference< + datatransfer::XTransferable > xRef( pContainer ); + + sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK; + if( FillTransferData( *pContainer, nDragMode )) + { + SwContentTree::SetInDrag(sal_True); + pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() ); + } + } + else + SvTreeListBox::StartDrag( nAction, rPosPixel ); +} + +void SwContentTree::DragFinished( sal_Int8 nAction ) +{ + //to prevent the removing of the selected entry in external drag and drop + // the drag action mustn't be MOVE + SvTreeListBox::DragFinished( bIsInternalDrag ? nAction : DND_ACTION_COPY ); + SwContentTree::SetInDrag(sal_False); + bIsInternalDrag = sal_False; +} + +/*************************************************************************** + Beschreibung: QueryDrop wird im Navigator ausgefuehrt +***************************************************************************/ +sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + sal_Int8 nRet = DND_ACTION_NONE; + if( bIsRoot ) + { + if( bIsOutlineMoveable ) + nRet = SvTreeListBox::AcceptDrop( rEvt ); + } + else if( !bIsInDrag ) + nRet = GetParentWindow()->AcceptDrop( rEvt ); + return nRet; +} + +/*************************************************************************** + Beschreibung: Drop wird im Navigator ausgefuehrt +***************************************************************************/ +sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + if( bIsRoot ) + return SvTreeListBox::ExecuteDrop( rEvt ); + return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt); +} + + +/*************************************************************************** + Beschreibung: Handler fuer Dragging und ContextMenu +***************************************************************************/ +PopupMenu* SwContentTree::CreateContextMenu( void ) +{ + PopupMenu* pPop = new PopupMenu; + PopupMenu* pSubPop1 = new PopupMenu; + PopupMenu* pSubPop2 = new PopupMenu; + PopupMenu* pSubPop3 = new PopupMenu; + PopupMenu* pSubPop4 = new PopupMenu; // Edit + + sal_uInt16 i; + for(i = 1; i <= MAXLEVEL; i++ ) + { + pSubPop1->InsertItem( i + 100, String::CreateFromInt32(i)); + } + pSubPop1->CheckItem(100 + nOutlineLevel); + for(i=0; i < 3; i++ ) + { + pSubPop2->InsertItem( i + 201, aContextStrings[ + ST_HYPERLINK - ST_CONTEXT_FIRST + i]); + } + pSubPop2->CheckItem( 201 + + GetParentWindow()->GetRegionDropMode()); + //Liste der offenen Dateien einfuegen + sal_uInt16 nId = 301; + const SwView* pActiveView = ::GetActiveView(); + SwView *pView = SwModule::GetFirstView(); + while (pView) + { + String sInsert = pView->GetDocShell()->GetTitle(); + if(pView == pActiveView) + { + sInsert += '('; + sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST]; + sInsert += ')'; + } + pSubPop3->InsertItem(nId, sInsert); + if(bIsConstant && pActiveShell == &pView->GetWrtShell()) + pSubPop3->CheckItem(nId); + pView = SwModule::GetNextView(pView); + nId++; + } + pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]); + if(pHiddenShell) + { + String sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle(); + sHiddenEntry += C2S(" ( "); + sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST]; + sHiddenEntry += C2S(" )"); + pSubPop3->InsertItem(nId, sHiddenEntry); + } + + if(bIsActive) + pSubPop3->CheckItem( --nId ); + else if(bIsHidden) + pSubPop3->CheckItem( nId ); + + pPop->InsertItem( 1, aContextStrings[ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]); + pPop->InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]); + pPop->InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]); + //jetzt noch bearbeiten + SvLBoxEntry* pEntry = 0; + //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen + if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr()) + && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry)) + { + const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent(); + const sal_uInt16 nContentType = pContType->GetType(); + sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly(); + sal_Bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible(); + sal_Bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect(); + sal_Bool bEditable = pContType->IsEditable() && + ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); + sal_Bool bDeletable = pContType->IsDeletable() && + ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); + sal_Bool bRenamable = bEditable && !bReadonly && + (CONTENT_TYPE_TABLE == nContentType || + CONTENT_TYPE_FRAME == nContentType || + CONTENT_TYPE_GRAPHIC == nContentType || + CONTENT_TYPE_OLE == nContentType || + CONTENT_TYPE_BOOKMARK == nContentType || + CONTENT_TYPE_REGION == nContentType|| + CONTENT_TYPE_INDEX == nContentType); + + if(!bReadonly && (bEditable || bDeletable)) + { + sal_Bool bSubPop4 = sal_False; + if(CONTENT_TYPE_INDEX == nContentType) + { + bSubPop4 = sal_True; + pSubPop4->InsertItem(401, sRemoveIdx); + pSubPop4->InsertItem(402, sUpdateIdx); + + const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase(); + if(!pBase->IsTOXBaseInReadonly()) + pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); + pSubPop4->InsertItem(405, sReadonlyIdx); + + pSubPop4->CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase)); + pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); + } + else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly) + { + bSubPop4 = sal_True; + pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); + pSubPop4->InsertItem(404, sUnprotTbl); + sal_Bool bFull = sal_False; + String sTblName = ((SwContent*)pEntry->GetUserData())->GetName(); + sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull ); + pSubPop4->EnableItem(403, !bFull ); + pSubPop4->EnableItem(404, bProt ); + pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); + } + else if(bEditable || bDeletable) + { + + if(bEditable && bDeletable) + { + pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); + pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); + bSubPop4 = sal_True; + } + else if(bEditable) + pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); + else if(bDeletable) + { + pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); + } + } + //Rename object + if(bRenamable) + { + if(bSubPop4) + pSubPop4->InsertItem(502, sRename); + else + pPop->InsertItem(502, sRename); + } + + if(bSubPop4) + { + pPop->InsertItem(4, pContType->GetSingleName()); + pPop->SetPopupMenu(4, pSubPop4); + } + } + } + else if( pEntry ) + { + SwContentType* pType = (SwContentType*)pEntry->GetUserData(); + if ( (pType->GetType() == CONTENT_TYPE_POSTIT) && (!pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) ) + { + pSubPop4->InsertItem(600, sPostItShow ); + pSubPop4->InsertItem(601, sPostItHide ); + pSubPop4->InsertItem(602, sPostItDelete ); + /* + pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort")); + PopupMenu* pMenuSort = new PopupMenu; + pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position")); + pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author")); + pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date")); + pSubPop4->SetPopupMenu(603, pMenuSort); + */ + pPop->InsertItem(4, pType->GetSingleName()); + pPop->SetPopupMenu(4, pSubPop4); + } + } + + pPop->SetPopupMenu( 1, pSubPop1 ); + pPop->SetPopupMenu( 2, pSubPop2 ); + pPop->SetPopupMenu( 3, pSubPop3 ); + return pPop; + +} +/*************************************************************************** + Beschreibung: Einrueckung fuer outlines (und sections) +***************************************************************************/ + + +long SwContentTree::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab) +{ + sal_uInt16 nLevel = 0; + if(lcl_IsContent(pEntry)) + { + nLevel++; + SwContent* pCnt = (SwContent *) pEntry->GetUserData(); + const SwContentType* pParent; + if(pCnt && 0 != (pParent = pCnt->GetParent())) + { + if(pParent->GetType() == CONTENT_TYPE_OUTLINE) + nLevel = nLevel + ((SwOutlineContent*)pCnt)->GetOutlineLevel(); + else if(pParent->GetType() == CONTENT_TYPE_REGION) + nLevel = nLevel + ((SwRegionContent*)pCnt)->GetRegionLevel(); + } + } + sal_uInt16 nBasis = bIsRoot ? 0 : 5; + return nLevel * 10 + nBasis + pTab->GetPos(); //empirisch ermittelt +} + +/*************************************************************************** + Beschreibung: Inhalte werden erst auf Anforderung in die Box eingefuegt +***************************************************************************/ + + +void SwContentTree::RequestingChilds( SvLBoxEntry* pParent ) +{ + // ist es ein Inhaltstyp? + if(lcl_IsContentType(pParent)) + { + if(!pParent->HasChilds()) + { + DBG_ASSERT(pParent->GetUserData(), "keine UserData?"); + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + + sal_uInt16 nCount = pCntType->GetMemberCount(); + for(sal_uInt16 i = 0; i < nCount; i++) + { + const SwContent* pCnt = pCntType->GetMember(i); + if(pCnt) + { + String sEntry = pCnt->GetName(); + if(!sEntry.Len()) + sEntry = sSpace; + InsertEntry(sEntry, pParent, + sal_False, LIST_APPEND, (void*)pCnt); + } + + } + } + } +} +/*************************************************************************** + Beschreibung: Expand - Zustand fuer Inhaltstypen merken +***************************************************************************/ + + +sal_Bool SwContentTree::Expand( SvLBoxEntry* pParent ) +{ + if(!bIsRoot) + { + if(lcl_IsContentType(pParent)) + { + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition + if(bIsActive || bIsConstant) + { + nActiveBlock |= nOr; + pConfig->SetActiveBlock(nActiveBlock); + } + else + nHiddenBlock |= nOr; + } + } + return SvTreeListBox::Expand(pParent); +} +/*************************************************************************** + Beschreibung: Collapse - Zustand fuer Inhaltstypen merken +***************************************************************************/ + + +sal_Bool SwContentTree::Collapse( SvLBoxEntry* pParent ) +{ + sal_Bool bRet; + if(!bIsRoot) + { + if(lcl_IsContentType(pParent)) + { + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + sal_uInt16 nAnd = 1 << pCntType->GetType(); + nAnd = ~nAnd; + if(bIsActive || bIsConstant) + { + nActiveBlock &= nAnd; + pConfig->SetActiveBlock(nActiveBlock); + } + else + nHiddenBlock &= nAnd; + } + bRet = SvTreeListBox::Collapse(pParent); + } + else + bRet = sal_False; + return bRet; +} + + +/*************************************************************************** + Beschreibung: Auch auf Doppelclick wird zunaechst nur aufgeklappt +***************************************************************************/ + + +IMPL_LINK( SwContentTree, ContentDoubleClickHdl, SwContentTree *, EMPTYARG ) +{ + SvLBoxEntry* pEntry = GetCurEntry(); + // ist es ein Inhaltstyp? + DBG_ASSERT(pEntry, "kein aktueller Eintrag!"); + if(pEntry) + { + if(lcl_IsContentType(pEntry)) + RequestingChilds(pEntry); + else if(bIsActive || bIsConstant) + { + if(bIsConstant) + { + pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop(); + } + //Inhaltstyp anspringen: + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + DBG_ASSERT( pCnt, "keine UserData"); + GotoContent(pCnt); + if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME) + pActiveShell->EnterStdMode(); + } + } + return 0; +} + +/*************************************************************************** + Beschreibung: Anzeigen der Datei +***************************************************************************/ + + +void SwContentTree::Display( sal_Bool bActive ) +{ + if(!bIsImageListInitialized) + { + sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; + aEntryImages = ImageList(SW_RES(nResId)); + bIsImageListInitialized = sal_True; + } + // erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder + // zu selektieren -> die UserDaten sind hier nicht mehr gueltig! + SvLBoxEntry* pOldSelEntry = FirstSelected(); + String sEntryName; // Name des Eintrags + sal_uInt16 nEntryRelPos = 0; // rel. Pos zu seinem Parent + sal_uInt32 nOldEntryCount = GetEntryCount(); + sal_Int32 nOldScrollPos = 0; + if(pOldSelEntry) + { + ScrollBar* pVScroll = GetVScroll(); + if(pVScroll && pVScroll->IsVisible()) + nOldScrollPos = pVScroll->GetThumbPos(); + + sEntryName = GetEntryText(pOldSelEntry); + if(GetParent(pOldSelEntry)) + { + nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(GetParent(pOldSelEntry))); + } + } + Clear(); + SetUpdateMode( sal_False ); + if(bActive && !bIsConstant && !bIsActive) + bIsActive = bActive; + bIsHidden = !bActive; + SwWrtShell* pShell = GetWrtShell(); + sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True; + if(bReadOnly != bIsLastReadOnly) + { + bIsLastReadOnly = bReadOnly; + sal_Bool bDisable = pShell == 0 || bReadOnly; + SwNavigationPI* pNavi = GetParentWindow(); + pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable); + pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable); + } + if(pShell) + { + SvLBoxEntry* pSelEntry = 0; + if(nRootType == USHRT_MAX) + { + for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE; + nCntType <= CONTENT_TYPE_DRAWOBJECT; nCntType++ ) + { + SwContentType** ppContentT = bActive ? + &aActiveContentArr[nCntType] : + &aHiddenContentArr[nCntType]; + if(!*ppContentT) + (*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel ); + + + String sEntry = (*ppContentT)->GetName(); + SvLBoxEntry* pEntry; + const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType); + sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount(); + pEntry = InsertEntry(sEntry, rImage, rImage, + 0, bChOnDemand, LIST_APPEND, (*ppContentT)); + if(nCntType == nLastSelType) + pSelEntry = pEntry; + sal_Int32 nExpandOptions = bIsActive || bIsConstant ? + nActiveBlock : + nHiddenBlock; + if(nExpandOptions & (1 << nCntType)) + { + Expand(pEntry); + if(nEntryRelPos && nCntType == nLastSelType) + { + // jetzt vielleicht noch ein Child selektieren + SvLBoxEntry* pChild = pEntry; + SvLBoxEntry* pTemp = 0; + sal_uInt16 nPos = 1; + while(0 != (pChild = Next(pChild))) + { + // der alte Text wird leicht bevorzugt + if(sEntryName == GetEntryText(pChild) || + nPos == nEntryRelPos ) + { + pSelEntry = pChild; + break; + } + pTemp = pChild; + nPos++; + } + if(!pSelEntry || lcl_IsContentType(pSelEntry)) + pSelEntry = pTemp; + } + + } + } + if(pSelEntry) + { + MakeVisible(pSelEntry); + Select(pSelEntry); + } + else + nOldScrollPos = 0; + } + else + { + SwContentType** ppRootContentT = bActive ? + &aActiveContentArr[nRootType] : + &aHiddenContentArr[nRootType]; + if(!(*ppRootContentT)) + (*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel ); + const Image& rImage = aEntryImages.GetImage(20000 + nRootType); + SvLBoxEntry* pParent = InsertEntry( + (*ppRootContentT)->GetName(), rImage, rImage, + 0, sal_False, LIST_APPEND, *ppRootContentT); + + for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ ) + { + const SwContent* pCnt = (*ppRootContentT)->GetMember(i); + if(pCnt) + { + String sEntry = pCnt->GetName(); + if(!sEntry.Len()) + sEntry = sSpace; + InsertEntry( sEntry, pParent, + sal_False, LIST_APPEND, (void*)pCnt); + } + } + Expand(pParent); + if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive ) + { + //feststellen, wo der Cursor steht + const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL); + SvLBoxEntry* pEntry = First(); + + while( 0 != (pEntry = Next(pEntry)) ) + { + if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos) + { + MakeVisible(pEntry); + Select(pEntry); + } + } + + } + else + { + // jetzt vielleicht noch ein Child selektieren + SvLBoxEntry* pChild = pParent; + SvLBoxEntry* pTemp = 0; + sal_uInt16 nPos = 1; + while(0 != (pChild = Next(pChild))) + { + // der alte Text wird leicht bevorzugt + if(sEntryName == GetEntryText(pChild) || + nPos == nEntryRelPos ) + { + pSelEntry = pChild; + break; + } + pTemp = pChild; + nPos++; + } + if(!pSelEntry) + pSelEntry = pTemp; + if(pSelEntry) + { + MakeVisible(pSelEntry); + Select(pSelEntry); + } + } + } + } + SetUpdateMode( sal_True ); + ScrollBar* pVScroll = GetVScroll(); + if(GetEntryCount() == nOldEntryCount && + nOldScrollPos && pVScroll && pVScroll->IsVisible() + && pVScroll->GetThumbPos() != nOldScrollPos) + { + sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos; + ScrollOutputArea( (short)nDelta ); + } + +} + +/*************************************************************************** + Beschreibung: Im Clear muessen auch die ContentTypes geloescht werden +***************************************************************************/ + + +void SwContentTree::Clear() +{ + SetUpdateMode(sal_False); + SvTreeListBox::Clear(); + SetUpdateMode(sal_True); +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + +sal_Bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, + sal_Int8& rDragMode ) +{ + SwWrtShell* pWrtShell = GetWrtShell(); + DBG_ASSERT(pWrtShell, "keine Shell!"); + SvLBoxEntry* pEntry = GetCurEntry(); + if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell) + return sal_False; + String sEntry; + SwContent* pCnt = ((SwContent*)pEntry->GetUserData()); + + sal_uInt16 nActType = pCnt->GetParent()->GetType(); + String sUrl; + sal_Bool bOutline = sal_False; + String sOutlineText; + switch( nActType ) + { + case CONTENT_TYPE_OUTLINE: + { + sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos(); + DBG_ASSERT(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(), + "outlinecnt veraendert"); + + // #100738# make sure outline may actually be copied + if( pWrtShell->IsOutlineCopyable( nPos ) ) + { + const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule(); + const SwTxtNode* pTxtNd = + pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos); + if( pTxtNd && pOutlRule && pTxtNd->IsNumbered()) + { + SwNumberTree::tNumberVector aNumVector = + pTxtNd->GetNumberVector(); + for( sal_Int8 nLevel = 0; + nLevel <= pTxtNd->GetActualListLevel(); + nLevel++ ) + { + sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel]; + nVal ++; + nVal = nVal - pOutlRule->Get(nLevel).GetStart(); + sEntry += String::CreateFromInt32( nVal ); + sEntry += '.'; + } + } + sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false); + sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true); + bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable(); + bOutline = sal_True; + } + } + break; + case CONTENT_TYPE_POSTIT: + case CONTENT_TYPE_INDEX: + case CONTENT_TYPE_REFERENCE : + // koennen weder als URL noch als Bereich eingefuegt werden + break; + case CONTENT_TYPE_URLFIELD: + sUrl = ((SwURLFieldContent*)pCnt)->GetURL(); + // kein break; + case CONTENT_TYPE_OLE: + case CONTENT_TYPE_GRAPHIC: + if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE) + break; + else + rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK ); + default: + sEntry = GetEntryText(pEntry); + } + + sal_Bool bRet = sal_False; + if(sEntry.Len()) + { + const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell(); + if(!sUrl.Len()) + { + if(pDocShell->HasName()) + { + SfxMedium* pMedium = pDocShell->GetMedium(); + sUrl = pMedium->GetURLObject().GetURLNoMark(); + // nur, wenn primaer ein Link eingefuegt werden soll + bRet = sal_True; + } + else if( nActType == CONTENT_TYPE_REGION || + nActType == CONTENT_TYPE_BOOKMARK ) + { + // fuer Bereich und Textmarken ist ein Link auch ohne + // Dateiname ins eigene Dokument erlaubt + bRet = sal_True; + } + else if(bIsConstant && + ( !::GetActiveView() || + pActiveShell != ::GetActiveView()->GetWrtShellPtr())) + { + // Urls von inaktiven Views ohne Dateinamen koennen auch nicht + // gedraggt werden + bRet = sal_False; + } + else + { + bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE; + rDragMode = DND_ACTION_MOVE; + } + + const String& rToken = pCnt->GetParent()->GetTypeToken(); + sUrl += '#'; + sUrl += sEntry; + if(rToken.Len()) + { + sUrl += cMarkSeperator; + sUrl += rToken; + } + } + else + bRet = sal_True; + + if( bRet ) + { + //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer + if(bOutline) + sEntry = sOutlineText; + + { + NaviContentBookmark aBmk( sUrl, sEntry, + GetParentWindow()->GetRegionDropMode(), + pDocShell); + aBmk.Copy( rTransfer ); + } + + // fuer fremde DocShells muss eine INetBookmark + // dazugeliefert werden + if( pDocShell->HasName() ) + { + INetBookmark aBkmk( sUrl, sEntry ); + rTransfer.CopyINetBookmark( aBkmk ); + } + } + } + return bRet; +} +/*************************************************************************** + Beschreibung: Umschalten der Anzeige auf Root +***************************************************************************/ + + +sal_Bool SwContentTree::ToggleToRoot() +{ + if(!bIsRoot) + { + SvLBoxEntry* pEntry = GetCurEntry(); + const SwContentType* pCntType; + if(pEntry) + { + if(lcl_IsContentType(pEntry)) + pCntType = (SwContentType*)pEntry->GetUserData(); + else + pCntType = ((SwContent*)pEntry->GetUserData())->GetParent(); + nRootType = pCntType->GetType(); + bIsRoot = sal_True; + Display(bIsActive || bIsConstant); + } + } + else + { + nRootType = USHRT_MAX; + bIsRoot = sal_False; + FindActiveTypeAndRemoveUserData(); + Display(bIsActive || bIsConstant); + } + pConfig->SetRootType( nRootType ); + GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot); + return bIsRoot; +} + +/*************************************************************************** + Beschreibung: Angezeigten Inhalt auf Gueltigkeit pruefen +***************************************************************************/ + + +sal_Bool SwContentTree::HasContentChanged() +{ +/* + -Parallel durch das lokale Array und die Treelistbox laufen. + -Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen + und der Contenttype wird als UserData neu gesetzt. + - ist der Root-Modus aktiv, wird nur dieser aktualisiert, + fuer die nicht angezeigten Inhaltstypen gilt: + die Memberliste wird geloescht und der Membercount aktualisiert + Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden + Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch + gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt. + +*/ + + sal_Bool bRepaint = sal_False; + sal_Bool bInvalidate = sal_False; + + if(!bIsActive && ! bIsConstant) + { + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + if(aActiveContentArr[i]) + aActiveContentArr[i]->Invalidate(); + } + } + else if(bIsRoot) + { + sal_Bool bOutline = sal_False; + SvLBoxEntry* pEntry = First(); + if(!pEntry) + bRepaint = sal_True; + else + { + sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType(); + bOutline = nRootType == CONTENT_TYPE_OUTLINE; + SwContentType* pArrType = aActiveContentArr[nType]; + if(!pArrType) + bRepaint = sal_True; + else + { + sal_uInt16 nSelLevel = USHRT_MAX; + + SvLBoxEntry* pFirstSel; + if(bOutline && + 0 != ( pFirstSel = FirstSelected()) && + lcl_IsContent(pFirstSel)) + { + nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel(); + SwWrtShell* pSh = GetWrtShell(); + sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); + bRepaint |= nOutlinePos != USHRT_MAX && + pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel; + } + + pArrType->Init(&bInvalidate); + pArrType->FillMemberList(); + pEntry->SetUserData((void*)pArrType); + if(!bRepaint) + { + if(GetChildCount(pEntry) != pArrType->GetMemberCount()) + bRepaint = sal_True; + else + { + sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + pEntry = Next(pEntry); + const SwContent* pCnt = pArrType->GetMember(j); + pEntry->SetUserData((void*)pCnt); + String sEntryText = GetEntryText(pEntry); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && !pCnt->GetName().Len())) + bRepaint = sal_True; + } + } + } + } + } + if( !bRepaint && bOutline ) + { + //feststellen, wo der Cursor steht + const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); + SvLBoxEntry* pFirstEntry = First(); + + while( 0 != (pFirstEntry = Next(pFirstEntry)) ) + { + if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos) + { + if(FirstSelected() != pFirstEntry) + { + Select(pFirstEntry); + MakeVisible(pFirstEntry); + } + } + } + + } + + } + else + { + SvLBoxEntry* pEntry = First(); + while ( pEntry ) + { + sal_Bool bNext = sal_True; // mindestens ein Next muss sein + SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData(); + sal_uInt16 nType = pTreeType->GetType(); + sal_uInt16 nTreeCount = pTreeType->GetMemberCount(); + SwContentType* pArrType = aActiveContentArr[nType]; + if(!pArrType) + bRepaint = sal_True; + else + { + pArrType->Init(&bInvalidate); + pEntry->SetUserData((void*)pArrType); + if(IsExpanded(pEntry)) + { + sal_Bool bLevelOrVisibiblityChanged = sal_False; + // bLevelOrVisibiblityChanged is set if outlines have changed their level + // or if the visibility of objects (frames, sections, tables) has changed + // i.e. in header/footer + pArrType->FillMemberList(&bLevelOrVisibiblityChanged); + if(bLevelOrVisibiblityChanged) + bInvalidate = sal_True; + sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); + if(bLevelOrVisibiblityChanged) + bInvalidate = sal_True; + + if(nChildCount != pArrType->GetMemberCount()) + bRepaint = sal_True; + else + { + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + pEntry = Next(pEntry); + bNext = sal_False; + const SwContent* pCnt = pArrType->GetMember(j); + pEntry->SetUserData((void*)pCnt); + String sEntryText = GetEntryText(pEntry); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && !pCnt->GetName().Len())) + bRepaint = sal_True; + } + } + + } + else if(pEntry->HasChilds()) + { + //war der Eintrag einmal aufgeklappt, dann muessen auch + // die unsichtbaren Eintraege geprueft werden. + // zumindest muessen die Userdaten aktualisiert werden + sal_Bool bLevelOrVisibiblityChanged = sal_False; + // bLevelOrVisibiblityChanged is set if outlines have changed their level + // or if the visibility of objects (frames, sections, tables) has changed + // i.e. in header/footer + pArrType->FillMemberList(&bLevelOrVisibiblityChanged); + sal_Bool bRemoveChildren = sal_False; + sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); + if( nChildCount != pArrType->GetMemberCount() ) + { + bRemoveChildren = sal_True; + } + else + { + SvLBoxEntry* pChild = FirstChild(pEntry); + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + const SwContent* pCnt = pArrType->GetMember(j); + pChild->SetUserData((void*)pCnt); + String sEntryText = GetEntryText(pChild); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && !pCnt->GetName().Len())) + bRemoveChildren = sal_True; + pChild = Next(pChild); + } + } + if(bRemoveChildren) + { + SvLBoxEntry* pChild = FirstChild(pEntry); + SvLBoxEntry* pRemove = pChild; + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + pChild = Next(pRemove); + GetModel()->Remove(pRemove); + pRemove = pChild; + } + } + if(!nChildCount) + { + pEntry->EnableChildsOnDemand(sal_False); + InvalidateEntry(pEntry); + } + + } + else if((nTreeCount != 0) + != (pArrType->GetMemberCount()!=0)) + { + bRepaint = sal_True; + } + } + //hier muss noch der naechste Root-Entry gefunden werden + while( pEntry && (bNext || GetParent(pEntry ) )) + { + pEntry = Next(pEntry); + bNext = sal_False; + } + } + } + if(!bRepaint && bInvalidate) + Invalidate(); + return bRepaint; +} + +/*************************************************************************** + Beschreibung: Bevor alle Daten geloescht werden, soll noch der letzte + * aktive Eintrag festgestellt werden. Dann werden die + * UserData geloescht +***************************************************************************/ +void SwContentTree::FindActiveTypeAndRemoveUserData() +{ + SvLBoxEntry* pEntry = FirstSelected(); + if(pEntry) + { + // wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root + // die Gueltigkeit der UserData garantiert werden + SvLBoxEntry* pParent; + while(0 != (pParent = GetParent(pEntry))) + pEntry = pParent; + if(pEntry->GetUserData() && lcl_IsContentType(pEntry)) + nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType(); + } +// else +// nLastSelType = USHRT_MAX; + pEntry = First(); + while(pEntry) + { + pEntry->SetUserData(0); + pEntry = Next(pEntry); + } +} + +/*************************************************************************** + Beschreibung: Nachdem ein File auf den Navigator gedroppt wurde, + wird die neue Shell gesetzt +***************************************************************************/ + + +void SwContentTree::SetHiddenShell(SwWrtShell* pSh) +{ + pHiddenShell = pSh; + bIsHidden = sal_True; + bIsActive = bIsConstant = sal_False; + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aHiddenContentArr[i]); + } + Display(bIsActive); + + GetParentWindow()->UpdateListBox(); +} +/*************************************************************************** + Beschreibung: Dokumentwechsel - neue Shell setzen +***************************************************************************/ + + +void SwContentTree::SetActiveShell(SwWrtShell* pSh) +{ + if(bIsInternalDrag) + bDocChgdInDragging = sal_True; + sal_Bool bClear = pActiveShell != pSh; + if(bIsActive && bClear) + { + pActiveShell = pSh; + FindActiveTypeAndRemoveUserData(); + Clear(); + } + else if(bIsConstant) + { + if(!lcl_FindShell(pActiveShell)) + { + pActiveShell = pSh; + bIsActive = sal_True; + bIsConstant = sal_False; + bClear = sal_True; + } + } + // nur wenn es die aktive View ist, wird das Array geloescht und + // die Anzeige neu gefuellt + if(bIsActive && bClear) + { + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aActiveContentArr[i]); + } + Display(sal_True); + } +} + +/*************************************************************************** + Beschreibung: Eine offene View als aktiv festlegen +***************************************************************************/ + + +void SwContentTree::SetConstantShell(SwWrtShell* pSh) +{ + pActiveShell = pSh; + bIsActive = sal_False; + bIsConstant = sal_True; + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aActiveContentArr[i]); + } + Display(sal_True); +} +/*************************************************************************** + Beschreibung: Kommandos des Navigators ausfuehren +***************************************************************************/ + + +void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier) +{ + sal_Bool nMove = sal_False; + switch( nCmd ) + { + case FN_ITEM_DOWN: + case FN_ITEM_UP: nMove = sal_True; + case FN_ITEM_LEFT: + case FN_ITEM_RIGHT: + if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() && + (bIsActive || + (bIsConstant && pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr()))) + { + SwWrtShell* pShell = GetWrtShell(); + sal_Int8 nActOutlineLevel = nOutlineLevel; + sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel); + SvLBoxEntry* pFirstEntry = FirstSelected(); + if (pFirstEntry && lcl_IsContent(pFirstEntry)) + { + if((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) || + ((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType() + == CONTENT_TYPE_OUTLINE) + { + nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos(); + } + } + if ( nActPos < USHRT_MAX && + ( !nMove || pShell->IsOutlineMovable( nActPos )) ) + { + pShell->StartAllAction(); + pShell->GotoOutline( nActPos); // Falls Textselektion != BoxSelektion + pShell->Push(); + pShell->MakeOutlineSel( nActPos, nActPos, + bModifier); + if( nMove ) + { + short nDir = nCmd == FN_ITEM_UP ? -1 : 1; + if( !bModifier && ((nDir == -1 && nActPos > 0) || + (nDir == 1 && nActPos < GetEntryCount() - 2 )) ) + { + pShell->MoveOutlinePara( nDir ); + //Cursor wieder an die aktuelle Position setzen + pShell->GotoOutline( nActPos + nDir); + } + else if(bModifier) + { + sal_uInt16 nActEndPos = nActPos; + SvLBoxEntry* pEntry = pFirstEntry; + sal_uInt16 nActLevel = ((SwOutlineContent*) + pFirstEntry->GetUserData())->GetOutlineLevel(); + pEntry = Next(pEntry); + while( pEntry && CONTENT_TYPE_OUTLINE == + ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() ) + { + if(nActLevel >= ((SwOutlineContent*) + pEntry->GetUserData())->GetOutlineLevel()) + break; + pEntry = Next(pEntry); + nActEndPos++; + } + sal_uInt16 nDest; + if(nDir == 1) + { + //Wenn der letzte Eintrag bewegt werden soll + //ist Schluss + if(pEntry && CONTENT_TYPE_OUTLINE == + ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()) + { + // pEntry zeigt jetzt auf den + // dem letzten sel. Eintrag folgenden E. + nDest = nActEndPos; + nDest++; + //hier muss der uebernaechste Eintrag + //gefunden werden. Die Selektion muss davor eingefuegt + //werden + while(pEntry ) + { + pEntry = Next(pEntry); + // nDest++ darf nur ausgefuehrt werden, + // wenn pEntry != 0 + if(pEntry && nDest++ && + ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()|| + CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())) + { + nDest--; + break; + } + } + nDir = nDest - nActEndPos; + //wenn kein Eintrag gefunden wurde, der der Bedingung + //fuer das zuvor Einfuegen entspricht, muss etwas weniger + //geschoben werden + } + else + nDir = 0; + } + else + { + nDest = nActPos; + pEntry = pFirstEntry; + while(pEntry && nDest ) + { + nDest--; + pEntry = Prev(pEntry); + if(pEntry && + (nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()|| + CONTENT_TYPE_OUTLINE != + ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())) + { + break; + } + } + nDir = nDest - nActPos; + } + if(nDir) + { + pShell->MoveOutlinePara( nDir ); + //Cursor wieder an die aktuelle Position setzen + pShell->GotoOutline( nActPos + nDir); + } + } + } + else + { + if( pShell->IsProtectedOutlinePara() ) + Sound::Beep(); //konnte nicht umgestuft werden + else + pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 ); + } + + pShell->ClearMark(); + pShell->Pop(sal_False); //Cursor steht jetzt wieder an der akt. Ueberschrift + pShell->EndAllAction(); + if(aActiveContentArr[CONTENT_TYPE_OUTLINE]) + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(sal_True); + if(!bIsRoot) + { + const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); + SvLBoxEntry* pFirst = First(); + + while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) + { + if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos) + { + Select(pFirst); + MakeVisible(pFirst); + } + } + } + } + else + Sound::Beep(); //konnte nicht verschoben werden + } + } +} +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentTree::ShowTree() +{ + aUpdTimer.Start(); + SvTreeListBox::Show(); +} + +/*************************************************************************** + Beschreibung: zusammengefaltet wird nicht geidlet +***************************************************************************/ + + +void SwContentTree::HideTree() +{ + aUpdTimer.Stop(); + SvTreeListBox::Hide(); +} + +/*************************************************************************** + Beschreibung: Kein Idle mit Focus oder waehrend des Dragging +***************************************************************************/ + + +IMPL_LINK( SwContentTree, TimerUpdate, Timer*, EMPTYARG) +{ + // kein Update waehrend D&D + // Viewabfrage, da der Navigator zu spaet abgeraeumt wird + SwView* pView = GetParentWindow()->GetCreateView(); + if( (!HasFocus() || bViewHasChanged) && + !bIsInDrag && !bIsInternalDrag && pView && + pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() ) + { + bViewHasChanged = sal_False; + bIsIdleClear = sal_False; + SwWrtShell* pActShell = pView->GetWrtShellPtr(); + if( bIsConstant && !lcl_FindShell( pActiveShell ) ) + { + SetActiveShell(pActShell); + GetParentWindow()->UpdateListBox(); + } + + if(bIsActive && pActShell != GetWrtShell()) + SetActiveShell(pActShell); + else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) && + HasContentChanged()) + { + FindActiveTypeAndRemoveUserData(); + Display(sal_True); + } + } + else if(!pView && bIsActive && !bIsIdleClear) + { + if(pActiveShell) + SetActiveShell(0); + Clear(); + bIsIdleClear = sal_True; + } + return 0; +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +DragDropMode SwContentTree::NotifyStartDrag( + TransferDataContainer& rContainer, + SvLBoxEntry* pEntry ) +{ + DragDropMode eMode = (DragDropMode)0; + if( bIsActive && nRootType == CONTENT_TYPE_OUTLINE && + GetModel()->GetAbsPos( pEntry ) > 0 + && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly()) + eMode = GetDragDropMode(); + else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName()) + eMode = SV_DRAGDROP_APP_COPY; + + sal_Int8 nDragMode; + FillTransferData( rContainer, nDragMode ); + bDocChgdInDragging = sal_False; + bIsInternalDrag = sal_True; + return eMode; +} + + +/*************************************************************************** + Beschreibung : Nach dem Drag wird der aktuelle Absatz m i t + Childs verschoben +***************************************************************************/ + + +sal_Bool SwContentTree::NotifyMoving( SvLBoxEntry* pTarget, + SvLBoxEntry* pEntry, SvLBoxEntry*& , sal_uLong& ) +{ + if(!bDocChgdInDragging) + { + sal_uInt16 nTargetPos = 0; + sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos(); + if(!lcl_IsContent(pTarget)) + nTargetPos = USHRT_MAX; + else + nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos(); + if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt + nTargetPos != USHRT_MAX) + { + SvLBoxEntry* pNext = Next(pTarget); + if(pNext) + nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1; + else + nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1; + + } + + DBG_ASSERT( pEntry && + lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" ); + GetParentWindow()->MoveOutline( nSourcePos, + nTargetPos, + sal_True); + + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(sal_True); + } + //TreeListBox wird aus dem Dokument neu geladen + return sal_False; +} +/*************************************************************************** + Beschreibung : Nach dem Drag wird der aktuelle Absatz o h n e + Childs verschoben +***************************************************************************/ + + +sal_Bool SwContentTree::NotifyCopying( SvLBoxEntry* pTarget, + SvLBoxEntry* pEntry, SvLBoxEntry*& , sal_uLong& ) +{ + if(!bDocChgdInDragging) + { + sal_uInt16 nTargetPos = 0; + sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos(); + if(!lcl_IsContent(pTarget)) + nTargetPos = USHRT_MAX; + else + nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos(); + + if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt + nTargetPos != USHRT_MAX) + { + SvLBoxEntry* pNext = Next(pTarget); + if(pNext) + nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1; + else + nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1; + + } + + + DBG_ASSERT( pEntry && + lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" ); + GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, sal_False); + + //TreeListBox wird aus dem Dokument neu geladen + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(sal_True); + } + return sal_False; +} + +/*************************************************************************** + Beschreibung: Kein Drop vor den ersten Eintrag - es ist ein SwContentType +***************************************************************************/ + +sal_Bool SwContentTree::NotifyAcceptDrop( SvLBoxEntry* pEntry) +{ + return pEntry != 0; +} + + +/*************************************************************************** + Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt, + * dann soll die Basisfunktion des Controls gerufen werden +***************************************************************************/ +void SwContentTree::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Point aPos( rMEvt.GetPosPixel()); + SvLBoxEntry* pEntry = GetEntry( aPos, sal_True ); + if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) + Control::MouseButtonDown( rMEvt ); + else + SvTreeListBox::MouseButtonDown( rMEvt ); +} + +/*************************************************************************** + Beschreibung: sofort aktualisieren +***************************************************************************/ + + +void SwContentTree::GetFocus() +{ + SwView* pActView = GetParentWindow()->GetCreateView(); + if(pActView) + { + SwWrtShell* pActShell = pActView->GetWrtShellPtr(); + if(bIsConstant && !lcl_FindShell(pActiveShell)) + { + SetActiveShell(pActShell); + } + + if(bIsActive && pActShell != GetWrtShell()) + SetActiveShell(pActShell); + else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) && + HasContentChanged()) + { + Display(sal_True); + } + } + else if(bIsActive) + Clear(); + SvTreeListBox::GetFocus(); +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentTree::KeyInput(const KeyEvent& rEvent) +{ + const KeyCode aCode = rEvent.GetKeyCode(); + if(aCode.GetCode() == KEY_RETURN) + { + SvLBoxEntry* pEntry = FirstSelected(); + if ( pEntry ) + { + switch(aCode.GetModifier()) + { + case KEY_MOD2: + // Boxen umschalten + GetParentWindow()->ToggleTree(); + break; + case KEY_MOD1: + // RootModus umschalten + ToggleToRoot(); + break; + case 0: + if(lcl_IsContentType(pEntry)) + { + IsExpanded(pEntry) ? + Collapse(pEntry) : + Expand(pEntry); + } + else + ContentDoubleClickHdl(0); + break; + } + } + } + else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier()) + { + SvLBoxEntry* pEntry = FirstSelected(); + if(pEntry && + lcl_IsContent(pEntry) && + ((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() && + !pActiveShell->GetView().GetDocShell()->IsReadOnly()) + { + EditEntry(pEntry, EDIT_MODE_DELETE); + bViewHasChanged = sal_True; + GetParentWindow()->UpdateListBox(); + TimerUpdate(&aUpdTimer); + GrabFocus(); + } + } + else + SvTreeListBox::KeyInput(rEvent); + +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentTree::RequestHelp( const HelpEvent& rHEvt ) +{ + sal_Bool bCallBase = sal_True; + if( rHEvt.GetMode() & HELPMODE_QUICK ) + { + Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); + SvLBoxEntry* pEntry = GetEntry( aPos ); + if( pEntry ) + { + sal_uInt16 nType; + sal_Bool bBalloon = sal_False; + sal_Bool bContent = sal_False; + void* pUserData = pEntry->GetUserData(); + if(lcl_IsContentType(pEntry)) + nType = ((SwContentType*)pUserData)->GetType(); + else + { + nType = ((SwContent*)pUserData)->GetParent()->GetType(); + bContent = sal_True; + } + String sEntry; + sal_Bool bRet = sal_False; + if(bContent) + { + switch( nType ) + { + case CONTENT_TYPE_URLFIELD: + sEntry = ((SwURLFieldContent*)pUserData)->GetURL(); + bRet = sal_True; + break; + + case CONTENT_TYPE_POSTIT: + sEntry = ((SwPostItContent*)pUserData)->GetName(); + bRet = sal_True; + if(Help::IsBalloonHelpEnabled()) + bBalloon = sal_True; + break; + case CONTENT_TYPE_OUTLINE: + sEntry = ((SwOutlineContent*)pUserData)->GetName(); + bRet = sal_True; + break; + case CONTENT_TYPE_GRAPHIC: + sEntry = ((SwGraphicContent*)pUserData)->GetLink(); +#if OSL_DEBUG_LEVEL > 1 + sEntry += ' '; + sEntry += String::CreateFromInt32( + ((SwGraphicContent*)pUserData)->GetYPos()); +#endif + bRet = sal_True; + break; +#if OSL_DEBUG_LEVEL > 1 + case CONTENT_TYPE_TABLE: + case CONTENT_TYPE_FRAME: + sEntry = String::CreateFromInt32( + ((SwContent*)pUserData)->GetYPos() ); + bRet = sal_True; + break; +#endif + } + if(((SwContent*)pUserData)->IsInvisible()) + { + if(sEntry.Len()) + sEntry += C2S(", "); + sEntry += sInvisible; + bRet = sal_True; + } + } + else + { + sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount(); + sEntry = String::CreateFromInt32(nMemberCount); + sEntry += ' '; + sEntry += nMemberCount == 1 + ? ((SwContentType*)pUserData)->GetSingleName() + : ((SwContentType*)pUserData)->GetName(); + bRet = sal_True; + } + if(bRet) + { + SvLBoxTab* pTab; + SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); + if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA()) + { + aPos = GetEntryPosition( pEntry ); + + aPos.X() = GetTabPos( pEntry, pTab ); + Size aSize( pItem->GetSize( this, pEntry ) ); + + if((aPos.X() + aSize.Width()) > GetSizePixel().Width()) + aSize.Width() = GetSizePixel().Width() - aPos.X(); + + aPos = OutputToScreenPixel(aPos); + Rectangle aItemRect( aPos, aSize ); + if(bBalloon) + { + aPos.X() += aSize.Width(); + Help::ShowBalloon( this, aPos, aItemRect, sEntry ); + } + else + Help::ShowQuickHelp( this, aItemRect, sEntry, + QUICKHELP_LEFT|QUICKHELP_VCENTER ); + bCallBase = sal_False; + } + } + else + { + Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 ); + bCallBase = sal_False; + } + } + } + if( bCallBase ) + Window::RequestHelp( rHEvt ); +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) +{ + SvLBoxEntry* pFirst = FirstSelected(); + switch( nSelectedPopupEntry ) + { + //Outlinelevel + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + case 108: + case 109: + case 110: + nSelectedPopupEntry -= 100; + if(nOutlineLevel != nSelectedPopupEntry ) + SetOutlineLevel((sal_Int8)nSelectedPopupEntry); + break; + case 201: + case 202: + case 203: + GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201); + break; + case 401: + case 402: + EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX); + break; + // Eintrag bearbeiten + case 403: + EditEntry(pFirst, EDIT_MODE_EDIT); + break; + case 404: + EditEntry(pFirst, EDIT_UNPROTECT_TABLE); + break; + case 405 : + { + const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData()) + ->GetTOXBase(); + pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase)); + } + break; + case 4: + break; + case 501: + EditEntry(pFirst, EDIT_MODE_DELETE); + break; + case 502 : + EditEntry(pFirst, EDIT_MODE_RENAME); + break; + case 600: + pActiveShell->GetView().GetPostItMgr()->Show(); + break; + case 601: + pActiveShell->GetView().GetPostItMgr()->Hide(); + break; + case 602: + { + pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0); + pActiveShell->GetView().GetPostItMgr()->Delete(); + break; + } + //Anzeige + default: // nSelectedPopupEntry > 300 + if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400) + { + nSelectedPopupEntry -= 300; + SwView *pView = SwModule::GetFirstView(); + while (pView) + { + nSelectedPopupEntry --; + if(nSelectedPopupEntry == 0) + { + SetConstantShell(&pView->GetWrtShell()); + break; + } + pView = SwModule::GetNextView(pView); + } + if(nSelectedPopupEntry) + { + bViewHasChanged = bIsActive = nSelectedPopupEntry == 1; + bIsConstant = sal_False; + Display(nSelectedPopupEntry == 1); + } + } + } + GetParentWindow()->UpdateListBox(); +} + +/*************************************************************************** + Beschreibung: +***************************************************************************/ + + +void SwContentTree::SetOutlineLevel(sal_uInt8 nSet) +{ + nOutlineLevel = nSet; + pConfig->SetOutlineLevel( nOutlineLevel ); + SwContentType** ppContentT = bIsActive ? + &aActiveContentArr[CONTENT_TYPE_OUTLINE] : + &aHiddenContentArr[CONTENT_TYPE_OUTLINE]; + if(*ppContentT) + { + (*ppContentT)->SetOutlineLevel(nOutlineLevel); + (*ppContentT)->Init(); + } + Display(bIsActive); +} + +/*************************************************************************** + Beschreibung: Moduswechsel: gedropptes Doc anzeigen +***************************************************************************/ + + +void SwContentTree::ShowHiddenShell() +{ + if(pHiddenShell) + { + bIsConstant = sal_False; + bIsActive = sal_False; + Display(sal_False); + } +} + +/*************************************************************************** + Beschreibung: Moduswechsel: aktive Sicht anzeigen +***************************************************************************/ + + +void SwContentTree::ShowActualView() +{ + bIsActive = sal_True; + bIsConstant = sal_False; + Display(sal_True); + GetParentWindow()->UpdateListBox(); +} + +/*-----------------20.11.96 13.34------------------- + Beschreibung: Hier sollen die Buttons zum Verschieben von + Outlines en-/disabled werden +--------------------------------------------------*/ + +sal_Bool SwContentTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) +{ + if(!pEntry) + return sal_False; + sal_Bool bEnable = sal_False; + SvLBoxEntry* pParentEntry = GetParent(pEntry); + if(!bIsLastReadOnly && (!IsVisible() || + ((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry) || + (lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)))) + bEnable = sal_True; + SwNavigationPI* pNavi = GetParentWindow(); + pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , bEnable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable); + pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable); + + return SvTreeListBox::Select(pEntry, bSelect); +} + +/*-----------------27.11.96 12.56------------------- + +--------------------------------------------------*/ + +void SwContentTree::SetRootType(sal_uInt16 nType) +{ + nRootType = nType; + bIsRoot = sal_True; + pConfig->SetRootType( nRootType ); +} + +/*-----------------10.01.97 12.19------------------- + +--------------------------------------------------*/ + +void SwContentType::RemoveNewline(String& rEntry) +{ + sal_Unicode* pStr = rEntry.GetBufferAccess(); + for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr ) + { + if( *pStr == 10 || *pStr == 13 ) + *pStr = 0x20; + } +} + +/*-----------------14.01.97 16.38------------------- + +--------------------------------------------------*/ + +void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) +{ + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + GotoContent(pCnt); + sal_uInt16 nType = pCnt->GetParent()->GetType(); + sal_uInt16 nSlot = 0; + + uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird; + switch(nType) + { + case CONTENT_TYPE_TABLE : + if(nMode == EDIT_UNPROTECT_TABLE) + { + pActiveShell->GetView().GetDocShell()-> + GetDoc()->UnProtectCells( pCnt->GetName()); + } + else if(nMode == EDIT_MODE_DELETE) + { + pActiveShell->StartAction(); + String sTable = SW_RES(STR_TABLE_NAME); + SwRewriter aRewriterTableName; + aRewriterTableName.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE)); + aRewriterTableName.AddRule(UNDO_ARG2, pCnt->GetName()); + aRewriterTableName.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE)); + sTable = aRewriterTableName.Apply(sTable); + + SwRewriter aRewriter; + aRewriter.AddRule(UNDO_ARG1, sTable); + pActiveShell->StartUndo(UNDO_DELETE, &aRewriter); + pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL); + pActiveShell->DeleteRow(); + pActiveShell->EndUndo(); + pActiveShell->EndAction(); + } + else if(nMode == EDIT_MODE_RENAME) + { + uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY); + xNameAccess = xTables->getTextTables(); + } + else + nSlot = FN_FORMAT_TABLE_DLG; + break; + + case CONTENT_TYPE_GRAPHIC : + if(nMode == EDIT_MODE_DELETE) + { + pActiveShell->DelRight(); + } + else if(nMode == EDIT_MODE_RENAME) + { + uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); + xNameAccess = xGraphics->getGraphicObjects(); + uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); + xSecond = xFrms->getTextFrames(); + uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); + xThird = xObjs->getEmbeddedObjects(); + } + else + nSlot = FN_FORMAT_GRAFIC_DLG; + break; + + case CONTENT_TYPE_FRAME : + case CONTENT_TYPE_OLE : + if(nMode == EDIT_MODE_DELETE) + { + pActiveShell->DelRight(); + } + else if(nMode == EDIT_MODE_RENAME) + { + uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); + uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); + if(CONTENT_TYPE_FRAME == nType) + { + xNameAccess = xFrms->getTextFrames(); + xSecond = xObjs->getEmbeddedObjects(); + } + else + { + xNameAccess = xObjs->getEmbeddedObjects(); + xSecond = xFrms->getTextFrames(); + } + uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); + xThird = xGraphics->getGraphicObjects(); + } + else + nSlot = FN_FORMAT_FRAME_DLG; + break; + case CONTENT_TYPE_BOOKMARK : + if(nMode == EDIT_MODE_DELETE) + { + IDocumentMarkAccess* const pMarkAccess = pActiveShell->getIDocumentMarkAccess(); + pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) ); + } + else if(nMode == EDIT_MODE_RENAME) + { + uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + uno::Reference< text::XBookmarksSupplier > xBkms(xModel, uno::UNO_QUERY); + xNameAccess = xBkms->getBookmarks(); + } + else + nSlot = FN_INSERT_BOOKMARK; + break; + + case CONTENT_TYPE_REGION : + if(nMode == EDIT_MODE_RENAME) + { + uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + uno::Reference< text::XTextSectionsSupplier > xSects(xModel, uno::UNO_QUERY); + xNameAccess = xSects->getTextSections(); + } + else + nSlot = FN_EDIT_REGION; + break; + + case CONTENT_TYPE_URLFIELD: + nSlot = FN_EDIT_HYPERLINK; + break; + case CONTENT_TYPE_REFERENCE: + nSlot = FN_EDIT_FIELD; + break; + + case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); + if(nMode == EDIT_MODE_DELETE) + { + if (((SwPostItContent*)pCnt)->IsPostIt()) + { + pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0); + pActiveShell->DelRight(); + } + /* + // this code can be used once we want redline comments in the margin + else + { + SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline()); + if (pComment) + pComment->Delete(); + } + */ + } + else + { + if (((SwPostItContent*)pCnt)->IsPostIt()) + nSlot = FN_POSTIT; + else + nSlot = FN_REDLINE_COMMENT; + } + break; + case CONTENT_TYPE_INDEX: + { + const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase(); + switch(nMode) + { + case EDIT_MODE_EDIT: + if(pBase) + { + SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase); + pActiveShell->GetView().GetViewFrame()-> + GetDispatcher()->Execute(FN_INSERT_MULTI_TOX, + SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0L); + + } + break; + case EDIT_MODE_RMV_IDX: + case EDIT_MODE_DELETE: + { + if( pBase ) + pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode); + } + break; + case EDIT_MODE_UPD_IDX: + case EDIT_MODE_RENAME: + { + Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); + Reference< XDocumentIndexesSupplier > xIndexes(xModel, UNO_QUERY); + Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes()); + Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY); + if(EDIT_MODE_RENAME == nMode) + xNameAccess = xLocalNameAccess; + else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName())) + { + Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName()); + Reference< XDocumentIndex> xIdx; + if(aIdx >>= xIdx) + xIdx->update(); + } + } + break; + } + } + break; + case CONTENT_TYPE_DRAWOBJECT : + if(EDIT_MODE_DELETE == nMode) + nSlot = SID_DELETE; + break; + } + if(nSlot) + pActiveShell->GetView().GetViewFrame()-> + GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON); + else if(xNameAccess.is()) + { + uno::Any aObj = xNameAccess->getByName(pCnt->GetName()); + uno::Reference< uno::XInterface > xTmp; + aObj >>= xTmp; + uno::Reference< container::XNamed > xNamed(xTmp, uno::UNO_QUERY); + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg( this, xNamed, xNameAccess, DLG_RENAME_XNAMED ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if(xSecond.is()) + pDlg->SetAlternativeAccess( xSecond, xThird); + + String sForbiddenChars; + if(CONTENT_TYPE_BOOKMARK == nType) + { + sForbiddenChars = C2S("/\\@:*?\";,.#"); + } + else if(CONTENT_TYPE_TABLE == nType) + { + sForbiddenChars = C2S(" .<>"); + } + pDlg->SetForbiddenChars(sForbiddenChars); + pDlg->Execute(); + delete pDlg; + } +} + +/*-----------------14.01.97 16.53------------------- + +--------------------------------------------------*/ + +void SwContentTree::GotoContent(SwContent* pCnt) +{ + pActiveShell->EnterStdMode(); + + sal_Bool bSel = sal_False; + sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); + switch(nJumpType) + { + case CONTENT_TYPE_OUTLINE : + { + pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos()); + } + break; + case CONTENT_TYPE_TABLE : + { + pActiveShell->GotoTable(pCnt->GetName()); + } + break; + case CONTENT_TYPE_FRAME : + case CONTENT_TYPE_GRAPHIC : + case CONTENT_TYPE_OLE : + { + if(pActiveShell->GotoFly(pCnt->GetName())) + bSel = sal_True; + } + break; + case CONTENT_TYPE_BOOKMARK: + { + pActiveShell->GotoMark(pCnt->GetName()); + } + break; + case CONTENT_TYPE_REGION : + { + pActiveShell->GotoRegion(pCnt->GetName()); + } + break; + case CONTENT_TYPE_URLFIELD: + { + if(pActiveShell->GotoINetAttr( + *((SwURLFieldContent*)pCnt)->GetINetAttr() )) + { + pActiveShell->Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False); + pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True ); + } + + } + break; + case CONTENT_TYPE_REFERENCE: + { + pActiveShell->GotoRefMark(pCnt->GetName()); + } + break; + case CONTENT_TYPE_INDEX: + { + if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName())) + pActiveShell->GotoPrevTOXBase(&pCnt->GetName()); + } + break; + case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); + if (((SwPostItContent*)pCnt)->IsPostIt()) + pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); + else + pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline( + pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData())); + + break; + case CONTENT_TYPE_DRAWOBJECT: + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + if (pDrawView) + { + pDrawView->SdrEndTextEdit(); + pDrawView->UnmarkAll(); + SdrModel* _pModel = pActiveShell->getIDocumentDrawModelAccess()->GetDrawModel(); + SdrPage* pPage = _pModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + for( sal_uInt32 i=0; i< nCount; i++ ) + { + SdrObject* pTemp = pPage->GetObj(i); + // --> OD 2006-03-09 #i51726# - all drawing objects can be named now +// if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName()) + if ( pTemp->GetName() == pCnt->GetName() ) + // <-- + { + SdrPageView* pPV = pDrawView->GetSdrPageView(); + if( pPV ) + { + pDrawView->MarkObj( pTemp, pPV ); + } + } + } + } + } + break; + } + if(bSel) + { + pActiveShell->HideCrsr(); + pActiveShell->EnterSelFrmMode(); + } + SwView& rView = pActiveShell->GetView(); + rView.StopShellTimer(); + rView.GetPostItMgr()->SetActiveSidebarWin(0); + rView.GetEditWin().GrabFocus(); +} +/*-----------------06.02.97 19.14------------------- + Jetzt nochtdie passende text::Bookmark +--------------------------------------------------*/ + +NaviContentBookmark::NaviContentBookmark() + : + nDocSh(0), + nDefDrag( REGION_MODE_NONE ) +{ +} + +/*-----------------06.02.97 20.12------------------- + +--------------------------------------------------*/ + +NaviContentBookmark::NaviContentBookmark( const String &rUrl, + const String& rDesc, + sal_uInt16 nDragType, + const SwDocShell* pDocSh ) : + aUrl( rUrl ), + aDescr(rDesc), + nDocSh((long)pDocSh), + nDefDrag( nDragType ) +{ +} + +void NaviContentBookmark::Copy( TransferDataContainer& rData ) const +{ + rtl_TextEncoding eSysCSet = gsl_getSystemTextEncoding(); + + ByteString sStr( aUrl, eSysCSet ); + sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); + sStr += ByteString( aDescr, eSysCSet ); + sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); + sStr += ByteString::CreateFromInt32( nDefDrag ); + sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); + sStr += ByteString::CreateFromInt32( nDocSh ); + rData.CopyByteString( SOT_FORMATSTR_ID_SONLK, sStr ); +} + +sal_Bool NaviContentBookmark::Paste( TransferableDataHelper& rData ) +{ + String sStr; + sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr ); + if( bRet ) + { + xub_StrLen nPos = 0; + aUrl = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ); + aDescr = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ); + nDefDrag= (sal_uInt16)sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32(); + nDocSh = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32(); + } + return bRet; +} + + +/* -----------------------------09.12.99 13:50-------------------------------- + + ---------------------------------------------------------------------------*/ +class SwContentLBoxString : public SvLBoxString +{ +public: + SwContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, + const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {} + + virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, + SvLBoxEntry* pEntry); +}; + +/* -----------------------------09.12.99 13:49-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwContentTree::InitEntry(SvLBoxEntry* pEntry, + const XubString& rStr ,const Image& rImg1,const Image& rImg2, + SvLBoxButtonKind eButtonKind) +{ + sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2" + SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); + SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite ); + SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() ); + pEntry->ReplaceItem( pStr, nColToHilite ); +} +/* -----------------------------09.12.99 13:49-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, + SvLBoxEntry* pEntry ) +{ + if(lcl_IsContent(pEntry) && + ((SwContent *)pEntry->GetUserData())->IsInvisible()) + { + //* pCont = (SwContent*)pEntry->GetUserData(); + Font aOldFont( rDev.GetFont()); + Font aFont(aOldFont); + Color aCol( COL_LIGHTGRAY ); + aFont.SetColor( aCol ); + rDev.SetFont( aFont ); + rDev.DrawText( rPos, GetText() ); + rDev.SetFont( aOldFont ); + } + else + SvLBoxString::Paint( rPos, rDev, nFlags, pEntry); +} +/* -----------------------------06.05.2002 10:20------------------------------ + + ---------------------------------------------------------------------------*/ +void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; + aEntryImages = ImageList(SW_RES(nResId)); + FindActiveTypeAndRemoveUserData(); + Display(sal_True); + } + SvTreeListBox::DataChanged( rDCEvt ); +} + + diff --git a/sw/source/ui/utlui/glbltree.cxx b/sw/source/ui/utlui/glbltree.cxx new file mode 100644 index 000000000000..2b7efb0037b5 --- /dev/null +++ b/sw/source/ui/utlui/glbltree.cxx @@ -0,0 +1,1523 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_STRINGSDTOR +#include <svl/svstdarr.hxx> +#endif +#include <vcl/msgbox.hxx> +#include <svl/stritem.hxx> +#include <sfx2/fcontnr.hxx> +#include <sfx2/linkmgr.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/urihelper.hxx> +#include <sfx2/docfile.hxx> +#include <vcl/help.hxx> +#include <sot/filelist.hxx> +#include <svl/eitem.hxx> +#include <svl/urlbmk.hxx> +#include <svtools/filter.hxx> +#include <sfx2/docinsert.hxx> +#include <sfx2/filedlghelper.hxx> + +#include <sfx2/app.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <errhdl.hxx> +#include <docsh.hxx> +#include <content.hxx> +#include <edglbldc.hxx> +#include <section.hxx> +#include <tox.hxx> +#include <cnttab.hxx> +#define NAVIPI_CXX +#include <navipi.hxx> +#include <navicont.hxx> +#include <edtwin.hxx> +#include <uitool.hxx> + +#include <cmdid.h> +#include <helpid.h> +#ifndef _NAVIPI_HRC +#include <navipi.hrc> +#endif +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif +#ifndef _COMCORE_HRC +#include <comcore.hrc> +#endif +#include <globals.hrc> +#include "swabstdlg.hxx" + +using namespace ::com::sun::star::uno; +using ::rtl::OUString; + + +// Kontextmenue fuer GlobalTree +#define CTX_INSERT_ANY_INDEX 10 +//#define CTX_INSERT_CNTIDX 11 +//#define CTX_INSERT_USRIDX 12 +#define CTX_INSERT_FILE 11 +#define CTX_INSERT_NEW_FILE 12 +#define CTX_INSERT_TEXT 13 + +#define CTX_UPDATE_SEL 20 +#define CTX_UPDATE_INDEX 21 +#define CTX_UPDATE_LINK 22 +#define CTX_UPDATE_ALL 23 + +#define CTX_UPDATE 1 +#define CTX_INSERT 2 +#define CTX_EDIT 3 +#define CTX_DELETE 4 +#define CTX_EDIT_LINK 5 + +#define GLOBAL_UPDATE_TIMEOUT 2000 + +// Flags fuer PopupMenu-enable/disable +#define ENABLE_INSERT_IDX 0x0001 +#define ENABLE_INSERT_FILE 0x0002 +#define ENABLE_INSERT_TEXT 0x0004 +#define ENABLE_EDIT 0x0008 +#define ENABLE_DELETE 0x0010 +#define ENABLE_UPDATE 0x0020 +#define ENABLE_UPDATE_SEL 0x0040 +#define ENABLE_EDIT_LINK 0x0080 + +// TabPos nach links schieben +#define GLBL_TABPOS_SUB 5 + +const SfxObjectShell* SwGlobalTree::pShowShell = 0; +static const char* __FAR_DATA aHelpForMenu[] = +{ + 0, // + HID_GLBLTREE_UPDATE, //CTX_UPDATE + HID_GLBLTREE_INSERT, //CTX_INSERT + HID_GLBLTREE_EDIT, //CTX_EDIT + HID_GLBLTREE_DEL, //CTX_DELETE + HID_GLBLTREE_EDIT_LINK, //CTX_EDIT_LINK + 0, // + 0, // + 0, // + 0, // + HID_GLBLTREE_INS_IDX, //CTX_INSERT_ANY_INDEX + HID_GLBLTREE_INS_FILE, //CTX_INSERT_FILE + HID_GLBLTREE_INS_NEW_FILE, //CTX_INSERT_NEW_FILE + HID_GLBLTREE_INS_TEXT, //CTX_INSERT_TEXT + 0, // + 0, // + 0, // + 0, // + 0, // + 0, // + HID_GLBLTREE_UPD_SEL, //CTX_UPDATE_SEL + HID_GLBLTREE_UPD_IDX, //CTX_UPDATE_INDEX + HID_GLBLTREE_UPD_LINK, //CTX_UPDATE_LINK + HID_GLBLTREEUPD_ALL //CTX_UPDATE_ALL +}; + +/************************************************************************/ +/* */ +/************************************************************************/ +/* -----------------------------24.08.00 12:04-------------------------------- + + ---------------------------------------------------------------------------*/ +class SwGlobalFrameListener_Impl : public SfxListener +{ + sal_Bool bValid; +public: + SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) : + bValid(sal_True) + { + StartListening(rFrame); + } + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + sal_Bool IsValid() const {return bValid;} +}; +/* -----------------------------24.08.00 12:05-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) +{ + if( rHint.ISA(SfxSimpleHint) && + (((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING)) + bValid = sal_False; +} + +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +SwGlobalTree::SwGlobalTree(Window* pParent, const ResId& rResId) : + + SvTreeListBox(pParent, rResId), + + pActiveShell ( NULL ), + pEmphasisEntry ( NULL ), + pDDSource ( NULL ), + pSwGlblDocContents ( NULL ), + pDefParentWin ( NULL ), + pDocContent ( NULL ), + pDocInserter ( NULL ), + + bIsInternalDrag ( sal_False ), + bLastEntryEmphasis ( sal_False ), + bIsImageListInitialized ( sal_False ) + +{ + SetDragDropMode(SV_DRAGDROP_APP_COPY | + SV_DRAGDROP_CTRL_MOVE | + SV_DRAGDROP_ENABLE_TOP ); + + aUpdateTimer.SetTimeout(GLOBAL_UPDATE_TIMEOUT); + aUpdateTimer.SetTimeoutHdl(LINK(this, SwGlobalTree, Timeout)); + aUpdateTimer.Start(); + for(sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++) + { + aContextStrings[i] = SW_RESSTR(i+ ST_GLOBAL_CONTEXT_FIRST); + } + SetHelpId(HID_NAVIGATOR_GLOB_TREELIST); + SelectHdl(); + SetDoubleClickHdl(LINK(this, SwGlobalTree, DoubleClickHdl)); + EnableContextMenuHandling(); +} + +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +SwGlobalTree::~SwGlobalTree() +{ + delete pSwGlblDocContents; + delete pDocInserter; +} + +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + sal_Int8 nRet = DND_ACTION_NONE; + SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); + if(pEmphasisEntry) + { + ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); + pEmphasisEntry = 0; + } + else if(bLastEntryEmphasis && pLast) + { + ImplShowTargetEmphasis( pLast, sal_False); + } + + SvLBoxEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel); + if( bIsInternalDrag ) + { + SvLBoxEntry* pDummy = 0; + sal_uLong nInsertionPos = LIST_APPEND; + NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos ); + } + else + { + TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); + + String sFileName; + const SwGlblDocContent* pCnt = pDropEntry ? + (const SwGlblDocContent*)pDropEntry->GetUserData() : + 0; + if( aData.HasFormat( FORMAT_FILE_LIST )) + { + nRet = rEvt.mnAction; + SwGlblDocContents* pTempContents = new SwGlblDocContents; + int nAbsContPos = pDropEntry ? + (int) GetModel()->GetAbsPos(pDropEntry): + - 1; + sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); + + // Daten holen + FileList aFileList; + aData.GetFileList( FORMAT_FILE_LIST, aFileList ); + for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; ) + { + sFileName = aFileList.GetFile(n); + InsertRegion(pCnt, &sFileName); + // nach dem Einfuegen muss die Liste der Contents neu + // geholt werden, um nicht auf einem alten Content zu + // arbeiten + if(n) + { + pActiveShell->GetGlobalDocContent(*pTempContents); + // wenn das file erfolgreich eingefuegt wurde, + // dann muss auch der naechste Content geholt werden + if(nEntryCount < pTempContents->Count()) + { + nEntryCount++; + nAbsContPos++; + pCnt = pTempContents->GetObject( static_cast< sal_uInt16 >(nAbsContPos) ); + } + } + } + delete pTempContents; + } + else if( 0 != (sFileName = + SwNavigationPI::CreateDropFileName( aData )).Len()) + { + INetURLObject aTemp(sFileName); + GraphicDescriptor aDesc(aTemp); + if( !aDesc.Detect() ) // keine Grafiken annehmen + { + nRet = rEvt.mnAction; + InsertRegion(pCnt, &sFileName); + } + } + } + bLastEntryEmphasis = sal_False; + return nRet; + +} +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + sal_Int8 nRet = rEvt.mnAction; + + //initiate scrolling + GetDropTarget( rEvt.maPosPixel ); + SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); + if( rEvt.mbLeaving ) + { + if( pEmphasisEntry ) + { + ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); + pEmphasisEntry = 0; + } + else if(bLastEntryEmphasis && pLast) + { + ImplShowTargetEmphasis( pLast, sal_False); + } + bLastEntryEmphasis = sal_False; + } + else + { + SvLBoxEntry* pDropEntry = GetEntry( rEvt.maPosPixel ); + if(bIsInternalDrag) + { + if( pDDSource != pDropEntry ) + nRet = rEvt.mnAction; + } + else if( IsDropFormatSupported( FORMAT_FILE ) || + IsDropFormatSupported( FORMAT_STRING ) || + IsDropFormatSupported( FORMAT_FILE_LIST ) || + IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || + IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| + IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) || + IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || + IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || + IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )) + nRet = DND_ACTION_LINK; + + if(pEmphasisEntry && pEmphasisEntry != pDropEntry) + ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); + else if(pLast && bLastEntryEmphasis && pDropEntry) + { + ImplShowTargetEmphasis( pLast, sal_False); + bLastEntryEmphasis = sal_False; + } + + if(pDropEntry) + ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet ); + else if(pLast) + { + ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet ); + bLastEntryEmphasis = sal_True; + } + pEmphasisEntry = pDropEntry; + } + return nRet; +} +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +PopupMenu* SwGlobalTree::CreateContextMenu() +{ + PopupMenu* pPop = 0; + if(pActiveShell && + !pActiveShell->GetView().GetDocShell()->IsReadOnly()) + { + sal_uInt16 nEnableFlags = GetEnableFlags(); + pPop = new PopupMenu; + PopupMenu* pSubPop1 = new PopupMenu; + PopupMenu* pSubPop2 = new PopupMenu; + + for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++) + { + pSubPop2->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] ); + pSubPop2->SetHelpId(i, aHelpForMenu[i]); + } + pSubPop2->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL)); + + pSubPop1->InsertItem(CTX_INSERT_ANY_INDEX, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST]); + pSubPop1->SetHelpId(CTX_INSERT_ANY_INDEX, aHelpForMenu[CTX_INSERT_ANY_INDEX]); + pSubPop1->InsertItem(CTX_INSERT_FILE, aContextStrings[ST_FILE - ST_GLOBAL_CONTEXT_FIRST]); + pSubPop1->SetHelpId(CTX_INSERT_FILE, aHelpForMenu[CTX_INSERT_FILE]); + pSubPop1->InsertItem(CTX_INSERT_NEW_FILE, aContextStrings[ST_NEW_FILE - ST_GLOBAL_CONTEXT_FIRST]); + pSubPop1->SetHelpId(CTX_INSERT_NEW_FILE, aHelpForMenu[CTX_INSERT_NEW_FILE]); + pSubPop1->InsertItem(CTX_INSERT_TEXT, aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST]); + pSubPop1->SetHelpId(CTX_INSERT_TEXT, aHelpForMenu[CTX_INSERT_TEXT]); + + + pPop->InsertItem(CTX_UPDATE, aContextStrings[ST_UPDATE - ST_GLOBAL_CONTEXT_FIRST]); + pPop->SetHelpId(CTX_UPDATE, aHelpForMenu[CTX_UPDATE]); + pPop->InsertItem(CTX_EDIT, aContextStrings[ST_EDIT_CONTENT - ST_GLOBAL_CONTEXT_FIRST]); + pPop->SetHelpId(CTX_EDIT, aHelpForMenu[CTX_EDIT]); + if(nEnableFlags&ENABLE_EDIT_LINK) + { + pPop->InsertItem(CTX_EDIT_LINK, aContextStrings[ST_EDIT_LINK - ST_GLOBAL_CONTEXT_FIRST]); + pPop->SetHelpId(CTX_EDIT_LINK, aHelpForMenu[CTX_EDIT_LINK]); + } + pPop->InsertItem(CTX_INSERT, aContextStrings[ST_INSERT - ST_GLOBAL_CONTEXT_FIRST]); + pPop->SetHelpId(CTX_INSERT, aHelpForMenu[CTX_INSERT]); + pPop->InsertSeparator() ; + pPop->InsertItem(CTX_DELETE, aContextStrings[ST_DELETE - ST_GLOBAL_CONTEXT_FIRST]); + pPop->SetHelpId(CTX_DELETE, aHelpForMenu[CTX_DELETE]); + + //evtl. disablen + pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); + pSubPop1->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT)); + pSubPop1->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); + pSubPop1->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); + + pPop->EnableItem(CTX_UPDATE, 0 != (nEnableFlags & ENABLE_UPDATE)); + pPop->EnableItem(CTX_INSERT, 0 != (nEnableFlags & ENABLE_INSERT_IDX)); + pPop->EnableItem(CTX_EDIT, 0 != (nEnableFlags & ENABLE_EDIT)); + pPop->EnableItem(CTX_DELETE, 0 != (nEnableFlags & ENABLE_DELETE)); + + + pPop->SetPopupMenu( CTX_INSERT, pSubPop1 ); + pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 ); + } + return pPop; +} +/*-----------------16.06.97 10:41------------------- + +--------------------------------------------------*/ +void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox) +{ + sal_uInt16 nEnableFlags = GetEnableFlags(); + if(FN_GLOBAL_OPEN == nTbxId) + { + PopupMenu *pMenu = new PopupMenu; + for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; i++) + { + pMenu->InsertItem( i, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST - CTX_INSERT_ANY_INDEX + i] ); + pMenu->SetHelpId(i, aHelpForMenu[i] ); + } + pMenu->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); +// pMenu->EnableItem(CTX_INSERT_CNTIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); +// pMenu->EnableItem(CTX_INSERT_USRIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); + pMenu->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT)); + pMenu->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); + pMenu->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); + pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl)); + pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft()); + delete pMenu; + pBox->EndSelection(); + pBox->Invalidate(); + } + else if(FN_GLOBAL_UPDATE == nTbxId) + { + PopupMenu *pMenu = new PopupMenu; + for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++) + { + pMenu->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] ); + pMenu->SetHelpId(i, aHelpForMenu[i] ); + } + pMenu->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL)); + pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl)); + pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft()); + delete pMenu; + pBox->EndSelection(); + pBox->Invalidate(); + } +} +/*-----------------16.06.97 11:02------------------- + +--------------------------------------------------*/ +sal_uInt16 SwGlobalTree::GetEnableFlags() const +{ + SvLBoxEntry* pEntry = FirstSelected(); + sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount(); + sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); + SvLBoxEntry* pPrevEntry = pEntry ? Prev(pEntry) : 0; + + sal_uInt16 nRet = 0; + if(nSelCount == 1 || !nEntryCount) + nRet |= ENABLE_INSERT_IDX|ENABLE_INSERT_FILE; + if(nSelCount == 1) + { + nRet |= ENABLE_EDIT; + if( ((SwGlblDocContent*)pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN && + (!pPrevEntry || ((SwGlblDocContent*)pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN)) + nRet |= ENABLE_INSERT_TEXT; + if( GLBLDOC_SECTION == ((SwGlblDocContent*)pEntry->GetUserData())->GetType() ) + nRet |= ENABLE_EDIT_LINK; + } + else if(!nEntryCount) + { + nRet |= ENABLE_INSERT_TEXT; + } + if(nEntryCount) + nRet |= ENABLE_UPDATE|ENABLE_DELETE; + if(nSelCount) + nRet |= ENABLE_UPDATE_SEL; + return nRet; +} + +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +void SwGlobalTree::RequestHelp( const HelpEvent& rHEvt ) +{ + sal_Bool bParent = sal_True; + Update(sal_True); + Display(sal_True); + if( rHEvt.GetMode() & HELPMODE_QUICK ) + { + Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); + SvLBoxEntry* pEntry = GetEntry( aPos ); + const SwGlblDocContent* pCont = pEntry ? + (const SwGlblDocContent*)pEntry->GetUserData() : 0; + if( pCont && GLBLDOC_SECTION == pCont->GetType()) + { + bParent = sal_False; + SvLBoxTab* pTab; + SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); + if(pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA()) + { + const SwSection* pSect = pCont->GetSection(); + String sEntry = pSect->GetLinkFileName().GetToken(0, sfx2::cTokenSeperator); + if(!pSect->IsConnectFlag()) + sEntry.Insert(aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST], 0 ); + Point aEntryPos = GetEntryPosition( pEntry ); + + aEntryPos.X() = GetTabPos( pEntry, pTab ); + Size aSize( pItem->GetSize( this, pEntry ) ); + + if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width()) + aSize.Width() = GetSizePixel().Width() - aEntryPos.X(); + + aEntryPos = OutputToScreenPixel(aEntryPos); + Rectangle aItemRect( aEntryPos, aSize ); + if(Help::IsBalloonHelpEnabled()) + { + aEntryPos.X() += aSize.Width(); + Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry ); + } + else + Help::ShowQuickHelp( this, aItemRect, sEntry, + QUICKHELP_LEFT|QUICKHELP_VCENTER ); + } + } + } + + if(bParent) + SvTreeListBox::RequestHelp(rHEvt); +} +/*-----------------16.06.97 16:15------------------- + +--------------------------------------------------*/ +void SwGlobalTree::SelectHdl() +{ + + sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount(); + SvLBoxEntry* pSel = FirstSelected(); + sal_uInt16 nAbsPos = pSel ? (sal_uInt16)GetModel()->GetAbsPos(pSel) : 0; + SwNavigationPI* pNavi = GetParentWindow(); + sal_Bool bReadonly = !pActiveShell || + pActiveShell->GetView().GetDocShell()->IsReadOnly(); + pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_EDIT, nSelCount == 1 && !bReadonly); + pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_OPEN, nSelCount <= 1 && !bReadonly); + pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_UPDATE, GetEntryCount() > 0 && !bReadonly); + pNavi->aGlobalToolBox.EnableItem(FN_ITEM_UP, + nSelCount == 1 && nAbsPos && !bReadonly); + pNavi->aGlobalToolBox.EnableItem(FN_ITEM_DOWN, + nSelCount == 1 && nAbsPos < ((sal_uInt16)GetEntryCount()) - 1 && !bReadonly); + +} +/*-----------------16.06.97 16:15------------------- + +--------------------------------------------------*/ +void SwGlobalTree::DeselectHdl() +{ + SelectHdl(); +} + +/*-----------------17.06.97 13:11------------------- + +--------------------------------------------------*/ +DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& , + SvLBoxEntry* pEntry ) +{ + bIsInternalDrag = sal_True; + pDDSource = pEntry; + return SV_DRAGDROP_CTRL_MOVE; +} + +/*-----------------21.06.97 12:44------------------- + +--------------------------------------------------*/ +long SwGlobalTree::GetTabPos( SvLBoxEntry*, SvLBoxTab* pTab) +{ + return pTab->GetPos() - GLBL_TABPOS_SUB; +} + +/*-----------------12.06.97 09:38------------------- + +--------------------------------------------------*/ +sal_Bool SwGlobalTree::NotifyMoving( SvLBoxEntry* pTarget, + SvLBoxEntry* pSource, + SvLBoxEntry*&, + sal_uLong& + ) +{ + SvTreeList* _pModel = GetModel(); + sal_uInt16 nSource = (sal_uInt16) _pModel->GetAbsPos(pSource); + sal_uInt16 nDest = pTarget ? (sal_uInt16) _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->Count(); + + if( pActiveShell->MoveGlobalDocContent( + *pSwGlblDocContents, nSource, nSource + 1, nDest ) && + Update( sal_False )) + Display(); + return sal_False; +} +/*-----------------12.06.97 09:39------------------- + +--------------------------------------------------*/ +sal_Bool SwGlobalTree::NotifyCopying( SvLBoxEntry* /*pTarget*/, + SvLBoxEntry* /*pEntry*/, + SvLBoxEntry*& /*rpNewParent*/, + sal_uLong& /*rNewChildPos*/ + ) +{ + return sal_False; +} +/*-----------------12.06.97 09:39------------------- + +--------------------------------------------------*/ +sal_Bool SwGlobalTree::NotifyAcceptDrop( SvLBoxEntry* pEntry) +{ + return pEntry != 0; +} +/*-----------------12.06.97 09:39------------------- + +--------------------------------------------------*/ +void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt ) +{ + if( 1 == GetSelectionCount() ) + SvTreeListBox::StartDrag( nAction, rPt ); +} +/*-----------------12.06.97 09:39------------------- + +--------------------------------------------------*/ +void SwGlobalTree::DragFinished( sal_Int8 nAction ) +{ + SvTreeListBox::DragFinished( nAction ); + bIsInternalDrag = sal_False; +} + +/*************************************************************************** + Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt, + * dann soll die Basisfunktion des Controls gerufen werden +***************************************************************************/ +void SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Point aPos( rMEvt.GetPosPixel()); + SvLBoxEntry* pEntry = GetEntry( aPos, sal_True ); + if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) + Control::MouseButtonDown( rMEvt ); + else + SvTreeListBox::MouseButtonDown( rMEvt ); +} + +/*-----------------12.06.97 13:08------------------- + +--------------------------------------------------*/ +void SwGlobalTree::GetFocus() +{ + if(Update( sal_False )) + Display(); + SvTreeListBox::GetFocus(); +} + +/*-----------------12.06.97 12:34------------------- + +--------------------------------------------------*/ +void SwGlobalTree::KeyInput(const KeyEvent& rKEvt) +{ + const KeyCode aCode = rKEvt.GetKeyCode(); + if(aCode.GetCode() == KEY_RETURN) + { + switch(aCode.GetModifier()) + { + case KEY_MOD2: + // Boxen umschalten + GetParentWindow()->ToggleTree(); + break; + } + } + else + SvTreeListBox::KeyInput(rKEvt); +} + +/*-----------------17.06.97 11:59------------------- + +--------------------------------------------------*/ +void SwGlobalTree::Clear() +{ + pEmphasisEntry = 0; + SvTreeListBox::Clear(); +} +/*-----------------12.06.97 12:38------------------- + +--------------------------------------------------*/ +void SwGlobalTree::Display(sal_Bool bOnlyUpdateUserData) +{ + if(!bIsImageListInitialized) + { + sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; + aEntryImages = ImageList(SW_RES(nResId)); + bIsImageListInitialized = sal_True; + } + sal_uInt16 nCount = pSwGlblDocContents->Count(); + if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->Count()) + { + SvLBoxEntry* pEntry = First(); + for( sal_uInt16 i = 0; i < nCount; i++) + { + SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i); + pEntry->SetUserData(pCont); + pEntry = Next(pEntry); + } + } + else + { + SetUpdateMode( sal_False ); + SvLBoxEntry* pOldSelEntry = FirstSelected(); + String sEntryName; // Name des Eintrags + sal_uInt16 nSelPos = USHRT_MAX; + if(pOldSelEntry) + { + sEntryName = GetEntryText(pOldSelEntry); + nSelPos = (sal_uInt16)GetModel()->GetAbsPos(pOldSelEntry); + } + Clear(); + if(!pSwGlblDocContents) + Update( sal_False ); + + SvLBoxEntry* pSelEntry = 0; + for( sal_uInt16 i = 0; i < nCount; i++) + { + SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i); + String sEntry; + Image aImage; + switch( pCont->GetType() ) + { + case GLBLDOC_UNKNOWN: + { + sEntry = aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST]; + aImage = aEntryImages.GetImage(SID_SW_START + GLOBAL_CONTENT_TEXT); + } + break; + case GLBLDOC_TOXBASE: + { + const SwTOXBase* pBase = pCont->GetTOX(); + sEntry = pBase->GetTitle(); + aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX); + } + break; + case GLBLDOC_SECTION: + { + const SwSection* pSect = pCont->GetSection(); + sEntry = pSect->GetSectionName(); + aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION); + } + break; + } + SvLBoxEntry* pEntry = InsertEntry(sEntry, aImage, aImage, + 0, sal_False, LIST_APPEND, pCont); + if(sEntry == sEntryName) + { + pSelEntry = pEntry; + } + } + if(pSelEntry) + { + Select(pSelEntry); + } + else if(nSelPos != USHRT_MAX && nSelPos < nCount) + { + Select(GetEntry(nSelPos)); + } + else if(nCount) + Select(First()); + else + SelectHdl(); + SetUpdateMode( sal_True ); + } +} + +/*-----------------13.06.97 10:32------------------- + +--------------------------------------------------*/ +void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const String* pFileName ) +{ + Sequence< OUString > aFileNames; + if ( !pFileName ) + { + pDefParentWin = Application::GetDefDialogParent(); + Application::SetDefDialogParent( this ); + if ( pDocInserter ) + delete pDocInserter; + pDocInserter = new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter"), true ); + pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) ); + } + else if ( pFileName->Len() ) + { + aFileNames.realloc(1); + INetURLObject aFileName; + aFileName.SetSmartURL( *pFileName ); + aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE ); + InsertRegion( pCont, aFileNames ); + } +} + +/*-----------------18.06.97 12:42------------------- + +--------------------------------------------------*/ +void SwGlobalTree::EditContent(const SwGlblDocContent* pCont ) +{ + sal_uInt16 nSlot = 0; + switch( pCont->GetType() ) + { + case GLBLDOC_UNKNOWN: + pActiveShell->GetView().GetEditWin().GrabFocus(); + break; + case GLBLDOC_TOXBASE: + { + const SwTOXBase* pBase = pCont->GetTOX(); + if(pBase) + nSlot = FN_INSERT_MULTI_TOX; + } + break; + case GLBLDOC_SECTION: + { + OpenDoc(pCont); + + nSlot = 0; + pCont = 0; + } + break; + } + if(pCont) + GotoContent(pCont); + if(nSlot) + { + pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot); + if(Update( sal_False )) + Display(); + } +} + +/*-----------------13.06.97 14:22------------------- + +--------------------------------------------------*/ +IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu) +{ + ExcecuteContextMenuAction( pMenu->GetCurItemId()); + return sal_True; +} +/* -----------------26.08.2003 11:57----------------- + + --------------------------------------------------*/ +void SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) +//IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu) +{ +// sal_uInt16 nId = pMenu->GetCurItemId(); + SvLBoxEntry* pEntry = FirstSelected(); + SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0; + // wird waehrend des Dialogs ein RequestHelp gerufen, + // dann geht der Content verloren. Deshalb wird hier eine + // Kopie angelegt, in der nur die DocPos richtig gesetzt ist. + SwGlblDocContent* pContCopy = 0; + if(pCont) + pContCopy = new SwGlblDocContent(pCont->GetDocPos()); + SfxDispatcher& rDispatch = *pActiveShell->GetView().GetViewFrame()->GetDispatcher(); + sal_uInt16 nSlot = 0; + bool bDeleteContentCopy = true; + switch( nSelectedPopupEntry ) + { + case CTX_UPDATE_SEL: + { + // zwei Durchlaeufe: zuerst die Bereiche, dann die Verzeichnisse + // aktualisieren + SvLBoxEntry* pSelEntry = FirstSelected(); + while( pSelEntry ) + { + SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData(); + if(GLBLDOC_SECTION == pContent->GetType() && + pContent->GetSection()->IsConnected()) + { + ((SwSection*)pContent->GetSection())->UpdateNow(); + } + + pSelEntry = NextSelected(pSelEntry); + } + pSelEntry = FirstSelected(); + while( pSelEntry ) + { + SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData(); + if(GLBLDOC_TOXBASE == pContent->GetType()) + pActiveShell->UpdateTableOf(*pContent->GetTOX()); + pSelEntry = NextSelected(pSelEntry); + } + + } + break; + case CTX_UPDATE_INDEX: + { + nSlot = FN_UPDATE_TOX; + } + break; + case CTX_UPDATE_LINK: + case CTX_UPDATE_ALL: + { + pActiveShell->GetLinkManager().UpdateAllLinks(sal_True); + if(CTX_UPDATE_ALL == nSelectedPopupEntry) + nSlot = FN_UPDATE_TOX; + pCont = 0; + } + break; + case CTX_EDIT: + { + DBG_ASSERT(pCont, "Edit ohne Entry ? " ); + EditContent(pCont); + } + break; + case CTX_EDIT_LINK: + { + DBG_ASSERT(pCont, "Edit ohne Entry ? " ); + SfxStringItem aName(FN_EDIT_REGION, + pCont->GetSection()->GetSectionName()); + rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L); + } + break; + case CTX_DELETE: + { + // sind mehrere Eintraege selektiert, dann muss nach jedem delete + // das Array neu gefuellt werden. Damit man sich nichts merken muss, + // beginnt das Loeschen am Ende + SvLBoxEntry* pSelEntry = LastSelected(); + SwGlblDocContents* pTempContents = 0; + pActiveShell->StartAction(); + while(pSelEntry) + { + pActiveShell->DeleteGlobalDocContent( + pTempContents ? *pTempContents : *pSwGlblDocContents, + (sal_uInt16)GetModel()->GetAbsPos(pSelEntry)); + pSelEntry = PrevSelected(pSelEntry); + if(pSelEntry) + { + pTempContents = new SwGlblDocContents; + pActiveShell->GetGlobalDocContent(*pTempContents); + } + } + delete pTempContents; + pActiveShell->EndAction(); + pCont = 0; + } + break; + case CTX_INSERT_ANY_INDEX: +// case CTX_INSERT_CNTIDX: +// case CTX_INSERT_USRIDX: + { + if(pContCopy) + { + SfxItemSet aSet(pActiveShell->GetView().GetPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FRM_SIZE, RES_FRM_SIZE, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + RES_LR_SPACE, RES_LR_SPACE, + FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE, + 0); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet fail!"); + AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX, + this, aSet, + *pActiveShell, + 0, + USHRT_MAX, + sal_True); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if(RET_OK == pDlg->Execute()) + { + SwTOXDescription& rDesc = pDlg->GetTOXDescription( + pDlg->GetCurrentTOXType()); + SwTOXMgr aMgr(pActiveShell); + SwTOXBase* pToInsert = 0; + if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet())) + pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert ); + } + pCont = 0; + delete pDlg; + } + } + break; + case CTX_INSERT_FILE: + { + bDeleteContentCopy = false; + pDocContent = pContCopy; + InsertRegion( pContCopy ); + pCont = NULL; + } + break; + case CTX_INSERT_NEW_FILE: + { + SfxViewFrame* pGlobFrm = pActiveShell->GetView().GetViewFrame(); + SwGlobalFrameListener_Impl aFrmListener(*pGlobFrm); + + sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : (sal_uLong)-1; + // neues Dok anlegen + SfxStringItem aFactory(SID_NEWDOCDIRECT, + SwDocShell::Factory().GetFilterContainer()->GetName()); + + const SfxFrameItem* pItem = (SfxFrameItem*) + rDispatch.Execute(SID_NEWDOCDIRECT, + SFX_CALLMODE_SYNCHRON, &aFactory, 0L); + + // sichern unter + SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0; + SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0; + if( pFrame ) + { + const SfxBoolItem* pBool = (const SfxBoolItem*) + pFrame->GetDispatcher()->Execute( + SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON ); + SfxObjectShell& rObj = *pFrame->GetObjectShell(); + const SfxMedium* pMedium = rObj.GetMedium(); + String sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)); + // Bereich mit dem Dok-Namen einfuegen + // eigenes Dok in den Vordergrund + + if(aFrmListener.IsValid() && sNewFile.Len()) + { + pGlobFrm->ToTop(); + // durch das Update sind die Eintraege invalid + if(nEntryPos != (sal_uLong)-1) + { + Update( sal_False ); + Display(); + Select(GetModel()->GetEntryAtAbsPos(nEntryPos)); + pEntry = FirstSelected(); + pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0; + } + else + { + pEntry = 0; + pCont = 0; + } + if(pBool->GetValue()) + { + InsertRegion(pCont, &sNewFile); + pFrame->ToTop(); + } + else + pFrame->GetDispatcher()->Execute(SID_CLOSEWIN, + SFX_CALLMODE_SYNCHRON); + } + else + { + pFrame->ToTop(); + return; + } + } + } + break; + case CTX_INSERT_TEXT: + { + if(pCont) + pActiveShell->InsertGlobalDocContent(*pCont); + else + { + pActiveShell->SplitNode(); // leeres Dokument + pActiveShell->Up( sal_False, 1 ); + } + pActiveShell->GetView().GetEditWin().GrabFocus(); + } + break; + case CTX_UPDATE: + pCont = 0; + break; + default:; + // hier passiert nichts + } + if(pCont) + GotoContent(pCont); + if(nSlot) + rDispatch.Execute(nSlot); + if(Update( sal_False )) + Display(); + if ( bDeleteContentCopy ) + delete pContCopy; + else + bDeleteContentCopy = true; +// return sal_True; +} + +/*-----------------16.06.97 07:57------------------- + +--------------------------------------------------*/ +IMPL_LINK( SwGlobalTree, Timeout, Timer*, EMPTYARG ) +{ + if(!HasFocus() && Update( sal_False )) + Display(); + return 0; +} + +/*-----------------13.06.97 16:56------------------- + +--------------------------------------------------*/ +void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont) +{ + pActiveShell->EnterStdMode(); + + switch( pCont->GetType() ) + { + case GLBLDOC_UNKNOWN: + pActiveShell->GotoGlobalDocContent(*pCont); + break; + case GLBLDOC_TOXBASE: + { + String sName = pCont->GetTOX()->GetTOXName(); + if (!pActiveShell->GotoNextTOXBase(&sName)) + pActiveShell->GotoPrevTOXBase(&sName); + } + break; + case GLBLDOC_SECTION: + break; + } + +} +/*-----------------16.06.97 07:42------------------- + +--------------------------------------------------*/ +void SwGlobalTree::ShowTree() +{ + aUpdateTimer.Start(); + SvTreeListBox::Show(); +} +/*-----------------16.06.97 07:42------------------- + +--------------------------------------------------*/ +void SwGlobalTree::HideTree() +{ + aUpdateTimer.Stop(); + SvTreeListBox::Hide(); +} +/*-----------------18.06.97 10:02------------------- + +--------------------------------------------------*/ +void SwGlobalTree::ExecCommand(sal_uInt16 nCmd) +{ + SvLBoxEntry* pEntry = FirstSelected(); + DBG_ASSERT(pEntry, "gleich knallt's"); + if(FN_GLOBAL_EDIT == nCmd) + { + const SwGlblDocContent* pCont = (const SwGlblDocContent*) + pEntry->GetUserData(); + EditContent(pCont); + } + else + { + if(GetSelectionCount() == 1) + { + sal_Bool bMove = sal_False; + sal_uInt16 nSource = (sal_uInt16)GetModel()->GetAbsPos(pEntry); + sal_uInt16 nDest = nSource; + switch(nCmd) + { + case FN_ITEM_DOWN: + { + sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); + bMove = nEntryCount > nSource + 1; + nDest+= 2; + } + break; + case FN_ITEM_UP: + { + if(nSource) + bMove = 0 != nSource; + nDest--; + } + break; + } + if( bMove && pActiveShell->MoveGlobalDocContent( + *pSwGlblDocContents, nSource, nSource + 1, nDest ) && + Update( sal_False )) + Display(); + } + } +} + +/*-----------------16.06.97 07:43------------------- + +--------------------------------------------------*/ +sal_Bool SwGlobalTree::Update(sal_Bool bHard) +{ + SwView* pActView = GetParentWindow()->GetCreateView(); + sal_Bool bRet = sal_False; + if(pActView && pActView->GetWrtShellPtr()) + { + const SwWrtShell* pOldShell = pActiveShell; + pActiveShell = pActView->GetWrtShellPtr(); + if(pActiveShell != pOldShell) + { + delete pSwGlblDocContents; + pSwGlblDocContents = 0; + } + if(!pSwGlblDocContents) + { + pSwGlblDocContents = new SwGlblDocContents; + bRet = sal_True; + pActiveShell->GetGlobalDocContent(*pSwGlblDocContents); + } + else + { + sal_Bool bCopy = sal_False; + SwGlblDocContents* pTempContents = new SwGlblDocContents; + pActiveShell->GetGlobalDocContent(*pTempContents); + if(pTempContents->Count() != pSwGlblDocContents->Count() || + pTempContents->Count() != GetEntryCount()) + { + bRet = sal_True; + bCopy = sal_True; + } + else + { + for(sal_uInt16 i = 0; i < pTempContents->Count() && !bCopy; i++) + { + SwGlblDocContent* pLeft = pTempContents->GetObject(i); + SwGlblDocContent* pRight = pSwGlblDocContents->GetObject(i); + GlobalDocContentType eType = pLeft->GetType(); + SvLBoxEntry* pEntry = GetEntry(i); + String sTemp = GetEntryText(pEntry); + if ( + eType != pRight->GetType() || + ( + eType == GLBLDOC_SECTION && + pLeft->GetSection()->GetSectionName() != sTemp + ) || + ( + eType == GLBLDOC_TOXBASE && + pLeft->GetTOX()->GetTitle() != sTemp + ) + ) + { + bCopy = bRet = sal_True; + } + } + } + if(bCopy || bHard) + { + sal_uInt16 i; + + pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count()); + for( i = 0; i < pTempContents->Count(); i++) + { + pSwGlblDocContents->Insert(pTempContents->GetObject(i)); + } + for( i = pTempContents->Count(); i; i--) + pTempContents->Remove(i - 1); + + } + delete pTempContents; + } + + } + else + { + Clear(); + if(pSwGlblDocContents) + pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count()); + } + // hier muss noch eine Veraenderungspruefung rein! + return bRet; +} + +/*-----------------25.06.97 16:20------------------- + +--------------------------------------------------*/ +void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont) +{ + String sFileName(pCont->GetSection()->GetLinkFileName().GetToken(0, + sfx2::cTokenSeperator)); + sal_Bool bFound = sal_False; + const SfxObjectShell* pCurr = SfxObjectShell::GetFirst(); + while( !bFound && pCurr ) + { + if(pCurr->GetMedium() && + String(pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)) == sFileName) + { + bFound = sal_True; + SwGlobalTree::SetShowShell(pCurr); + Application::PostUserEvent( STATIC_LINK( + this, SwGlobalTree, ShowFrameHdl ) ); + pCurr = 0; + } + else + pCurr = SfxObjectShell::GetNext(*pCurr); + } + if(!bFound) + { + SfxStringItem aURL(SID_FILE_NAME, + sFileName); + SfxBoolItem aReadOnly(SID_DOC_READONLY, sal_False); + SfxStringItem aTargetFrameName( SID_TARGETNAME, String::CreateFromAscii("_blank") ); + SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle()); + pActiveShell->GetView().GetViewFrame()->GetDispatcher()-> + Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, + &aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L); + } +} + +/*-----------------25.06.97 16:08------------------- + +--------------------------------------------------*/ +IMPL_LINK( SwGlobalTree, DoubleClickHdl, SwGlobalTree *, EMPTYARG ) +{ + SvLBoxEntry* pEntry = GetCurEntry(); + SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); + if(pCont->GetType() == GLBLDOC_SECTION) + OpenDoc(pCont); + else + { + GotoContent(pCont); + pActiveShell->GetView().GetEditWin().GrabFocus(); + } + return 0; +} + +/*-----------------07.10.97 08:09------------------- + +--------------------------------------------------*/ +IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG) +{ + if(SwGlobalTree::GetShowShell()) + SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop(); + SwGlobalTree::SetShowShell(0); + return 0; +} +/* -----------------04.11.98 10:43------------------- + * + * --------------------------------------------------*/ +void SwGlobalTree::InitEntry(SvLBoxEntry* pEntry, + const XubString& rStr ,const Image& rImg1,const Image& rImg2, + SvLBoxButtonKind eButtonKind) +{ + sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2" + SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); + SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite ); + SwLBoxString* pStr = new SwLBoxString( pEntry, 0, pCol->GetText() ); + pEntry->ReplaceItem( pStr, nColToHilite ); +} +/* -----------------04.11.98 10:39------------------- + * + * --------------------------------------------------*/ + +void SwLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, + SvLBoxEntry* pEntry ) +{ + SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); + const SwSection* pSect; + if(pCont->GetType() == GLBLDOC_SECTION && + !(pSect = pCont->GetSection())->IsConnectFlag() ) + { + Font aOldFont( rDev.GetFont()); + Font aFont(aOldFont); + Color aCol( COL_LIGHTRED ); + aFont.SetColor( aCol ); + rDev.SetFont( aFont ); + rDev.DrawText( rPos, GetText() ); + rDev.SetFont( aOldFont ); + } + else + SvLBoxString::Paint( rPos, rDev, nFlags, pEntry); +} +/* -----------------------------06.05.2002 10:20------------------------------ + + ---------------------------------------------------------------------------*/ +void SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; + aEntryImages = ImageList(SW_RES(nResId)); + Update(sal_True); + } + SvTreeListBox::DataChanged( rDCEvt ); +} + +void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles ) +{ + sal_Int32 nFiles = _rFiles.getLength(); + if ( nFiles ) + { + sal_Bool bMove = sal_False; + if ( !_pContent ) + { + SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); + _pContent = (SwGlblDocContent*)pLast->GetUserData(); + bMove = sal_True; + } + String sFilePassword; + sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); + const OUString* pFileNames = _rFiles.getConstArray(); + SwWrtShell& rSh = GetParentWindow()->GetCreateView()->GetWrtShell(); + rSh.StartAction(); + // after insertion of the first new content the 'pCont' parameter becomes invalid + // find the index of the 'anchor' content to always use a current anchor content + sal_uInt16 nAnchorContent = pSwGlblDocContents->Count() - 1; + if ( !bMove ) + { + for( sal_uInt16 nContent = 0; nContent < pSwGlblDocContents->Count(); ++nContent ) + { + if( *_pContent == *pSwGlblDocContents->GetObject( nContent ) ) + { + nAnchorContent = nContent; + break; + } + } + } + SwGlblDocContents aTempContents; + for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile ) + { + //update the global document content after each inserted document + rSh.GetGlobalDocContent(aTempContents); + SwGlblDocContent* pAnchorContent = 0; + DBG_ASSERT(aTempContents.Count() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed"); + if ( aTempContents.Count() > (nAnchorContent + nFile) ) + pAnchorContent = aTempContents.GetObject(nAnchorContent + (sal_uInt16)nFile); + else + pAnchorContent = aTempContents.GetObject(aTempContents.Count() - 1); + String sFileName(pFileNames[nFile]); + INetURLObject aFileUrl; + aFileUrl.SetSmartURL( sFileName ); + String sSectionName(String(aFileUrl.GetLastName( + INetURLObject::DECODE_UNAMBIGUOUS)).GetToken(0, + sfx2::cTokenSeperator)); + sal_uInt16 nSectCount = rSh.GetSectionFmtCount(); + String sTempSectionName(sSectionName); + sal_uInt16 nAddNumber = 0; + sal_uInt16 nCount = 0; + // evtl : und Index anhaengen, wenn der Bereichsname schon vergeben ist + while ( nCount < nSectCount ) + { + const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount); + if ((rFmt.GetSection()->GetSectionName() == sTempSectionName) + && rFmt.IsInNodesArr()) + { + nCount = 0; + nAddNumber++; + sTempSectionName = sSectionName; + sTempSectionName += ':'; + sTempSectionName += String::CreateFromInt32( nAddNumber ); + } + else + nCount++; + } + + if ( nAddNumber ) + sSectionName = sTempSectionName; + + SwSectionData aSectionData(CONTENT_SECTION, sSectionName); + aSectionData.SetProtectFlag(true); + aSectionData.SetHidden(false); + + aSectionData.SetLinkFileName(sFileName); + aSectionData.SetType(FILE_LINK_SECTION); + aSectionData.SetLinkFilePassword( sFilePassword ); + + rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData ); + } + if ( bMove ) + { + Update( sal_False ); + rSh.MoveGlobalDocContent( + *pSwGlblDocContents, nEntryCount, nEntryCount + (sal_uInt16)nFiles, nEntryCount - (sal_uInt16)nFiles ); + } + rSh.EndAction(); + Update( sal_False ); + Display(); + } +} + +IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) +{ + Application::SetDefDialogParent( pDefParentWin ); + if ( ERRCODE_NONE == _pFileDlg->GetError() ) + { + SfxMediumList* pMedList = pDocInserter->CreateMediumList(); + if ( pMedList ) + { + Sequence< OUString >aFileNames( pMedList->Count() ); + OUString* pFileNames = aFileNames.getArray(); + SfxMedium* pMed = pMedList->First(); + sal_Int32 nPos = 0; + while ( pMed ) + { + String sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); + sFileName += sfx2::cTokenSeperator; + sFileName += pMed->GetFilter()->GetFilterName(); + sFileName += sfx2::cTokenSeperator; + pFileNames[nPos++] = sFileName; + pMed = pMedList->Next(); + } + delete pMedList; + InsertRegion( pDocContent, aFileNames ); + DELETEZ( pDocContent ); + } + } + return 0; +} + diff --git a/sw/source/ui/utlui/gloslst.cxx b/sw/source/ui/utlui/gloslst.cxx new file mode 100644 index 000000000000..3d80e55e1ace --- /dev/null +++ b/sw/source/ui/utlui/gloslst.cxx @@ -0,0 +1,514 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + + +#define _SVSTDARR_STRINGSDTOR +#define _SVSTDARR_STRINGSISORTDTOR +#define _SVSTDARR_STRINGS +#include <svl/svstdarr.hxx> +#include <tools/urlobj.hxx> +#include <vcl/dialog.hxx> +#include <vcl/msgbox.hxx> +#ifndef _SV_BUTTON_HXX //autogen +#include <vcl/button.hxx> +#endif +#ifndef _FIXED_HXX //autogen +#include <vcl/fixed.hxx> +#endif +#include <vcl/lstbox.hxx> +#ifndef SVTOOLS_FSTATHELPER_HXX +#include <svl/fstathelper.hxx> +#endif +#include <unotools/pathoptions.hxx> +#include <unotools/transliterationwrapper.hxx> +#include <swtypes.hxx> +#include <swmodule.hxx> +#include <shellio.hxx> +#include <initui.hxx> +#include <glosdoc.hxx> +#include <gloslst.hxx> +#include <swunohelper.hxx> + +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif +#ifndef _GLOSLST_HRC +#include <gloslst.hrc> +#endif + + +#define STRING_DELIM (char)0x0A +#define GLOS_TIMEOUT 30000 // alle 30 s updaten +#define FIND_MAX_GLOS 20 + + +struct TripleString +{ + String sGroup; + String sBlock; + String sShort; +}; + +typedef TripleString* TripleStringPtr; +SV_DECL_PTRARR_DEL( TripleStrings, TripleStringPtr, 0, 4 ) +SV_IMPL_PTRARR( TripleStrings, TripleStringPtr ) + +class SwGlossDecideDlg : public ModalDialog +{ + OKButton aOk; + CancelButton aCancel; + HelpButton aHelp; + ListBox aListLB; + FixedLine aFL; + + DECL_LINK(DoubleClickHdl, ListBox*); + DECL_LINK(SelectHdl, ListBox*); + + public: + SwGlossDecideDlg(Window* pParent); + ListBox& GetListBox() {return aListLB;} +}; + +/*-----------------21.01.97 13.25------------------- + +--------------------------------------------------*/ + +SwGlossDecideDlg::SwGlossDecideDlg(Window* pParent) : + ModalDialog(pParent, SW_RES(DLG_GLOSSARY_DECIDE_DLG)), + aOk(this, SW_RES(PB_OK)), + aCancel(this, SW_RES(PB_CANCEL)), + aHelp(this, SW_RES(PB_HELP)), + aListLB(this, SW_RES(LB_LIST)), + aFL(this, SW_RES(FL_GLOSS)) +{ + FreeResource(); + aListLB.SetDoubleClickHdl(LINK(this, SwGlossDecideDlg, DoubleClickHdl)); + aListLB.SetSelectHdl(LINK(this, SwGlossDecideDlg, SelectHdl)); +} + +/*-----------------21.01.97 13.25------------------- + +--------------------------------------------------*/ + +IMPL_LINK(SwGlossDecideDlg, DoubleClickHdl, ListBox*, EMPTYARG) +{ + EndDialog(RET_OK); + return 0; +} +/*-----------------21.01.97 13.29------------------- + +--------------------------------------------------*/ + +IMPL_LINK(SwGlossDecideDlg, SelectHdl, ListBox*, EMPTYARG) +{ + aOk.Enable(LISTBOX_ENTRY_NOTFOUND != aListLB.GetSelectEntryPos()); + return 0; +} + +/******************************************************************** + +********************************************************************/ + + +SwGlossaryList::SwGlossaryList() : + bFilled(sal_False) +{ + SvtPathOptions aPathOpt; + sPath = aPathOpt.GetAutoTextPath(); + SetTimeout(GLOS_TIMEOUT); +} + +/******************************************************************** + +********************************************************************/ + + +SwGlossaryList::~SwGlossaryList() +{ + ClearGroups(); +} + +/******************************************************************** + * Wenn der GroupName bereits bekannt ist, dann wird nur + * rShortName gefuellt, sonst wird rGroupName ebenfals gesetzt und + * bei Bedarf nach der richtigen Gruppe gefragt +********************************************************************/ + + +sal_Bool SwGlossaryList::GetShortName(const String& rLongName, + String& rShortName, String& rGroupName ) +{ + if(!bFilled) + Update(); + + TripleStrings aTripleStrings; + + sal_uInt16 nCount = aGroupArr.Count(); + sal_uInt16 nFound = 0; + for(sal_uInt16 i = 0; i < nCount; i++ ) + { + AutoTextGroup* pGroup = aGroupArr.GetObject(i); + if(!rGroupName.Len() || rGroupName == pGroup->sName) + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + String sLong = pGroup->sLongNames.GetToken(j, STRING_DELIM); + if((rLongName == sLong)) + { + TripleString* pTriple = new TripleString; + pTriple->sGroup = pGroup->sName; + pTriple->sBlock = sLong; + pTriple->sShort = pGroup->sShortNames.GetToken(j, STRING_DELIM); + aTripleStrings.Insert(pTriple, nFound++); + } + } + } + + sal_Bool bRet = sal_False; + nCount = aTripleStrings.Count(); + if(1 == nCount ) + { + TripleString* pTriple = aTripleStrings[0]; + rShortName = pTriple->sShort; + rGroupName = pTriple->sGroup; + bRet = sal_True; + } + else if(1 < nCount) + { + SwGlossDecideDlg aDlg(0); + String sTitle = aDlg.GetText(); + sTitle += ' '; + sTitle += aTripleStrings[0]->sBlock; + aDlg.SetText(sTitle); + + ListBox& rLB = aDlg.GetListBox(); + for(sal_uInt16 i = 0; i < nCount; i++ ) + rLB.InsertEntry(aTripleStrings[i]->sGroup.GetToken(0, GLOS_DELIM)); + + rLB.SelectEntryPos(0); + if(RET_OK == aDlg.Execute() && + LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectEntryPos()) + { + TripleString* pTriple = aTripleStrings[rLB.GetSelectEntryPos()]; + rShortName = pTriple->sShort; + rGroupName = pTriple->sGroup; + bRet = sal_True; + } + else + bRet = sal_False; + } + return bRet; +} + +/******************************************************************** + +********************************************************************/ + + +sal_uInt16 SwGlossaryList::GetGroupCount() +{ + if(!bFilled) + Update(); + return aGroupArr.Count(); +} + +/******************************************************************** + +********************************************************************/ + + +String SwGlossaryList::GetGroupName(sal_uInt16 nPos, sal_Bool bNoPath, String* pTitle) +{ + DBG_ASSERT(aGroupArr.Count() > nPos, "Gruppe nicht vorhanden"); + String sRet(aEmptyStr); + if(nPos < aGroupArr.Count()) + { + AutoTextGroup* pGroup = aGroupArr.GetObject(nPos); + sRet = pGroup->sName; + if(bNoPath) + sRet = sRet.GetToken(0, GLOS_DELIM); + if(pTitle) + *pTitle = pGroup->sTitle; + } + return sRet; + +} + +/******************************************************************** + +********************************************************************/ + + +sal_uInt16 SwGlossaryList::GetBlockCount(sal_uInt16 nGroup) +{ + DBG_ASSERT(aGroupArr.Count() > nGroup, "Gruppe nicht vorhanden"); + if(nGroup < aGroupArr.Count()) + { + AutoTextGroup* pGroup = aGroupArr.GetObject(nGroup); + return pGroup->nCount; + } + return 0; +} + +/******************************************************************** + +********************************************************************/ + + +String SwGlossaryList::GetBlockName(sal_uInt16 nGroup, sal_uInt16 nBlock, String& rShortName) +{ + DBG_ASSERT(aGroupArr.Count() > nGroup, "Gruppe nicht vorhanden"); + if(nGroup < aGroupArr.Count()) + { + AutoTextGroup* pGroup = aGroupArr.GetObject(nGroup); + rShortName = pGroup->sShortNames.GetToken(nBlock, STRING_DELIM); + return pGroup->sLongNames.GetToken(nBlock, STRING_DELIM); + } + return aEmptyStr; +} + +/******************************************************************** + +********************************************************************/ + + +void SwGlossaryList::Update() +{ + if(!IsActive()) + Start(); + + SvtPathOptions aPathOpt; + String sTemp( aPathOpt.GetAutoTextPath() ); + if(sTemp != sPath) + { + sPath = sTemp; + bFilled = sal_False; + ClearGroups(); + } + SwGlossaries* pGlossaries = ::GetGlossaries(); + const SvStrings* pPathArr = pGlossaries->GetPathArray(); + String sExt( SwGlossaries::GetExtension() ); + if(!bFilled) + { + sal_uInt16 nGroupCount = pGlossaries->GetGroupCnt(); + for(sal_uInt16 i = 0; i < nGroupCount; i++) + { + String sGrpName = pGlossaries->GetGroupName(i); + sal_uInt16 nPath = (sal_uInt16)sGrpName.GetToken(1, GLOS_DELIM).ToInt32(); + if(nPath < pPathArr->Count()) + { + AutoTextGroup* pGroup = new AutoTextGroup; + pGroup->sName = sGrpName; + + FillGroup(pGroup, pGlossaries); + String sName = *(*pPathArr)[nPath]; + sName += INET_PATH_TOKEN; + sName += pGroup->sName.GetToken(0, GLOS_DELIM); + sName += sExt; + + FStatHelper::GetModifiedDateTimeOfFile( sName, + &pGroup->aDateModified, + &pGroup->aDateModified ); + + aGroupArr.Insert( pGroup, i ); + } + } + bFilled = sal_True; + } + else + { + for(sal_uInt16 nPath = 0; nPath < pPathArr->Count(); nPath++) + { + SvStringsDtor aFoundGroupNames; + SvStrings aFiles( 16, 16 ); + SvPtrarr aDateTimeArr( 16, 16 ); + + SWUnoHelper::UCB_GetFileListOfFolder( *(*pPathArr)[nPath], aFiles, + &sExt, &aDateTimeArr ); + for( sal_uInt16 nFiles = 0, nFEnd = aFiles.Count(); + nFiles < nFEnd; ++nFiles ) + { + String* pTitle = aFiles[ nFiles ]; + ::DateTime* pDT = (::DateTime*) aDateTimeArr[ nFiles ]; + + String sName( pTitle->Copy( 0, pTitle->Len() - sExt.Len() )); + + aFoundGroupNames.Insert( new String(sName), + aFoundGroupNames.Count()); + sName += GLOS_DELIM; + sName += String::CreateFromInt32( nPath ); + AutoTextGroup* pFound = FindGroup( sName ); + if( !pFound ) + { + pFound = new AutoTextGroup; + pFound->sName = sName; + FillGroup( pFound, pGlossaries ); + pFound->aDateModified = *pDT; + + aGroupArr.Insert(pFound, aGroupArr.Count()); + } + else if( pFound->aDateModified < *pDT ) + { + FillGroup(pFound, pGlossaries); + pFound->aDateModified = *pDT; + } + + // don't need any more these pointers + delete pTitle; + delete pDT; + } + + sal_uInt16 nArrCount = aGroupArr.Count(); + for( sal_uInt16 i = nArrCount; i; --i) + { + // evtl. geloeschte Gruppen entfernen + AutoTextGroup* pGroup = aGroupArr.GetObject(i - 1); + sal_uInt16 nGroupPath = (sal_uInt16)pGroup->sName.GetToken( 1, + GLOS_DELIM).ToInt32(); + // nur die Gruppen werden geprueft, die fuer den + // aktuellen Teilpfad registriert sind + if(nGroupPath == nPath) + { + sal_Bool bFound = sal_False; + String sCompareGroup = pGroup->sName.GetToken(0, GLOS_DELIM); + for( sal_uInt16 j = 0; j < aFoundGroupNames.Count() && !bFound; ++j) + { + bFound = sCompareGroup == *aFoundGroupNames[j]; + } + if(!bFound) + { + aGroupArr.Remove(i - 1); + delete pGroup; + } + } + } + } + } +} + +/******************************************************************** + +********************************************************************/ + + +void SwGlossaryList::Timeout() +{ + // nur, wenn eine SwView den Fokus hat, wird automatisch upgedated + if(::GetActiveView()) + Update(); +} + +/******************************************************************** + +********************************************************************/ + + +AutoTextGroup* SwGlossaryList::FindGroup(const String& rGroupName) +{ + for(sal_uInt16 i = 0; i < aGroupArr.Count(); i++) + { + AutoTextGroup* pRet = aGroupArr.GetObject(i); + if(pRet->sName == rGroupName) + return pRet; + } + return 0; +} + +/******************************************************************** + +********************************************************************/ + + +void SwGlossaryList::FillGroup(AutoTextGroup* pGroup, SwGlossaries* pGlossaries) +{ + SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(pGroup->sName); + pGroup->nCount = pBlock ? pBlock->GetCount() : 0; + pGroup->sLongNames = pGroup->sShortNames = aEmptyStr; + if(pBlock) + pGroup->sTitle = pBlock->GetName(); + + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + pGroup->sLongNames += pBlock->GetLongName(j); + pGroup->sLongNames += STRING_DELIM; + pGroup->sShortNames += pBlock->GetShortName(j); + pGroup->sShortNames += STRING_DELIM; + } + pGlossaries->PutGroupDoc(pBlock); +} + +/******************************************************************** + Alle (nicht mehr als FIND_MAX_GLOS) gefunden Bausteine mit + passendem Anfang zurueckgeben +********************************************************************/ + +sal_Bool SwGlossaryList::HasLongName(const String& rBegin, SvStringsISortDtor* pLongNames ) +{ + if(!bFilled) + Update(); + sal_uInt16 nFound = 0; + sal_uInt16 nCount = aGroupArr.Count(); + sal_uInt16 nBeginLen = rBegin.Len(); + const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); + + for(sal_uInt16 i = 0; i < nCount; i++ ) + { + AutoTextGroup* pGroup = aGroupArr.GetObject(i); + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + String sBlock = pGroup->sLongNames.GetToken(j, STRING_DELIM); + if( rSCmp.isEqual( sBlock.Copy(0, nBeginLen), rBegin ) && + nBeginLen + 1 < sBlock.Len()) + { + String* pBlock = new String(sBlock); + pLongNames->Insert(pBlock); + nFound++; + if(FIND_MAX_GLOS == nFound) + break; + } + } + } + return nFound > 0; +} + +/******************************************************************** + +********************************************************************/ +void SwGlossaryList::ClearGroups() +{ + sal_uInt16 nCount = aGroupArr.Count(); + for( sal_uInt16 i = 0; i < nCount; ++i ) + delete aGroupArr.GetObject( i ); + + aGroupArr.Remove( 0, nCount ); + bFilled = sal_False; +} + + diff --git a/sw/source/ui/utlui/gloslst.hrc b/sw/source/ui/utlui/gloslst.hrc new file mode 100644 index 000000000000..6c89f1c5ac9c --- /dev/null +++ b/sw/source/ui/utlui/gloslst.hrc @@ -0,0 +1,38 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _INITUI_HRC +#define _INITUI_HRC + +#define FL_GLOSS 1 +#define PB_OK 2 +#define PB_HELP 3 +#define PB_CANCEL 4 +#define LB_LIST 5 + +#endif + diff --git a/sw/source/ui/utlui/gloslst.src b/sw/source/ui/utlui/gloslst.src new file mode 100644 index 000000000000..d4140fc64d80 --- /dev/null +++ b/sw/source/ui/utlui/gloslst.src @@ -0,0 +1,109 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "globals.hrc" +#include "utlui.hrc" +#include "helpid.h" +#include "gloslst.hrc" + +ModalDialog DLG_GLOSSARY_DECIDE_DLG +{ + HelpID = HID_DLG_GLOSS_DECIDE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 161 , 67 ) ; + Text [ en-US ] = "Select AutoText:" ; + Moveable = TRUE ; + FixedLine FL_GLOSS + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 93 , 8 ) ; + Text [ en-US ] = "AutoText - Group" ; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 105 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 105 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 105 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + }; + ListBox LB_LIST + { + HelpID = "sw:ListBox:DLG_GLOSSARY_DECIDE_DLG:LB_LIST"; + Pos = MAP_APPFONT ( 12 , 15 ) ; + Size = MAP_APPFONT ( 81 , 40 ) ; + TabStop = TRUE ; + Border = TRUE ; + }; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/source/ui/utlui/initui.cxx b/sw/source/ui/utlui/initui.cxx new file mode 100644 index 000000000000..565b32339792 --- /dev/null +++ b/sw/source/ui/utlui/initui.cxx @@ -0,0 +1,307 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <unotools/localedatawrapper.hxx> +#include <viewsh.hxx> +#include <initui.hxx> +#include <edtwin.hxx> +#include <shellres.hxx> +#include <fldbas.hxx> +#include <glosdoc.hxx> +#include <gloslst.hxx> + +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif +#ifndef _INITUI_HRC +#include <initui.hrc> +#endif +#ifndef _COMCORE_HRC +#include <comcore.hrc> +#endif +#include <authfld.hxx> +#ifndef _DBMGR_HXX +#include <dbmgr.hxx> +#endif +#include <unotools/syslocale.hxx> + +#include <unomid.h> + +/*-------------------------------------------------------------------- + Beschreibung: globale Pointer + --------------------------------------------------------------------*/ + +SwGlossaries* pGlossaries = 0; + +// Liefert alle benoetigten Pfade. Wird durch UI initialisiert +SwGlossaryList* pGlossaryList = 0; + +String* pOldGrfCat = 0; +String* pOldTabCat = 0; +String* pOldFrmCat = 0; +String* pOldDrwCat = 0; +String* pCurrGlosGroup = 0; + +String* GetOldGrfCat() +{ + return pOldGrfCat; +} +String* GetOldTabCat() +{ + return pOldTabCat; +} +String* GetOldFrmCat() +{ + return pOldFrmCat; +} +String* GetOldDrwCat() +{ + return pOldDrwCat; +} +String* GetCurrGlosGroup() +{ + return pCurrGlosGroup; +} +void SetCurrGlosGroup(String* pStr) +{ + pCurrGlosGroup = pStr; +} + +SvStringsDtor* pDBNameList = 0; + +SvStringsDtor* pAuthFieldNameList = 0; +SvStringsDtor* pAuthFieldTypeList = 0; + +/*-------------------------------------------------------------------- + Beschreibung: UI beenden + --------------------------------------------------------------------*/ + +void _FinitUI() +{ + SwNewDBMgr::RemoveDbtoolsClient(); + delete ViewShell::GetShellRes(); + ViewShell::SetShellRes( 0 ); + + SwEditWin::_FinitStaticData(); + + DELETEZ(pGlossaries); + + delete SwFieldType::pFldNames; + + delete pOldGrfCat; + delete pOldTabCat; + delete pOldFrmCat; + delete pOldDrwCat; + delete pCurrGlosGroup; + delete pDBNameList; + delete pGlossaryList; + delete pAuthFieldNameList; + delete pAuthFieldTypeList; + + +} +/*-------------------------------------------------------------------- + Beschreibung: Initialisierung + --------------------------------------------------------------------*/ + + +void _InitUI() +{ + // ShellResource gibt der CORE die Moeglichkeit mit Resourcen zu arbeiten + ViewShell::SetShellRes( new ShellResource ); + pDBNameList = new SvStringsDtor( 5, 5 ); + SwEditWin::_InitStaticData(); +} + + +ShellResource::ShellResource() + : Resource( SW_RES(RID_SW_SHELLRES) ), + aPostItAuthor( SW_RES( STR_POSTIT_AUTHOR ) ), + aPostItPage( SW_RES( STR_POSTIT_PAGE ) ), + aPostItLine( SW_RES( STR_POSTIT_LINE ) ), + + aCalc_Syntax( SW_RES( STR_CALC_SYNTAX ) ), + aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ), + aCalc_Brack( SW_RES( STR_CALC_BRACK ) ), + aCalc_Pow( SW_RES( STR_CALC_POW ) ), + aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ), + aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ), + aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ), + aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ), + aCalc_Error( SW_RES( STR_CALC_ERROR ) ), + + aGetRefFld_Up( SW_RES( STR_GETREFFLD_UP ) ), + aGetRefFld_Down( SW_RES( STR_GETREFFLD_DOWN ) ), + // --> OD 2007-09-13 #i81002# + aGetRefFld_RefItemNotFound( SW_RES( STR_GETREFFLD_REFITEMNOTFOUND ) ), + // <-- + aStrAllPageHeadFoot( SW_RES( STR_ALLPAGE_HEADFOOT ) ), + aStrNone( SW_RES( STR_TEMPLATE_NONE )), + aFixedStr( SW_RES( STR_FIELD_FIXED )), + sDurationFormat( SW_RES( STR_DURATION_FORMAT )), + + aTOXIndexName( SW_RES(STR_TOI)), + aTOXUserName( SW_RES(STR_TOU)), + aTOXContentName( SW_RES(STR_TOC)), + aTOXIllustrationsName( SW_RES(STR_TOX_ILL)), + aTOXObjectsName( SW_RES(STR_TOX_OBJ)), + aTOXTablesName( SW_RES(STR_TOX_TBL)), + aTOXAuthoritiesName( SW_RES(STR_TOX_AUTH)), + aHyperlinkClick( SW_RES( STR_HYPERLINK_CLICK)), + pAutoFmtNameLst(0), + sPageDescFirstName( SW_RES(STR_PAGEDESC_FIRSTNAME)), + sPageDescFollowName( SW_RES(STR_PAGEDESC_FOLLOWNAME)), + sPageDescName( SW_RES(STR_PAGEDESC_NAME)) +{ + const sal_uInt16 nCount = FLD_DOCINFO_END - FLD_DOCINFO_BEGIN; + + KeyCode aCode( KEY_SPACE ); + KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 ); + String aModStr( aModifiedCode.GetName() ); + aModStr.SearchAndReplace( aCode.GetName(), String() ); + aModStr.SearchAndReplaceAllAscii( "+", String() ); + aHyperlinkClick.SearchAndReplaceAllAscii( "%s", aModStr ); + + for(sal_uInt16 i = 0; i < nCount; ++i) + { + String* pNew = new SW_RESSTR(FLD_DOCINFO_BEGIN + i); + aDocInfoLst.Insert(pNew, aDocInfoLst.Count()); + } + + FreeResource(); +} + +ShellResource::~ShellResource() +{ + if( pAutoFmtNameLst ) + delete pAutoFmtNameLst, pAutoFmtNameLst = 0; +} + +String ShellResource::GetPageDescName( sal_uInt16 nNo, sal_Bool bIsFirst, sal_Bool bFollow ) +{ + String sRet( bIsFirst ? sPageDescFirstName + : bFollow ? sPageDescFollowName + : sPageDescName ); + sRet.SearchAndReplaceAscii( "$(ARG1)", String::CreateFromInt32( nNo )); + return sRet; +} + + +SwGlossaries* GetGlossaries() +{ + if (!pGlossaries) + pGlossaries = new SwGlossaries; + return (pGlossaries); +} + +sal_Bool HasGlossaryList() +{ + return pGlossaryList != 0; +} + +SwGlossaryList* GetGlossaryList() +{ + if(!pGlossaryList) + pGlossaryList = new SwGlossaryList(); + + return pGlossaryList; +} + +struct ImpAutoFmtNameListLoader : public Resource +{ + ImpAutoFmtNameListLoader( SvStringsDtor& rLst ); +}; + +void ShellResource::_GetAutoFmtNameLst() const +{ + SvStringsDtor** ppLst = (SvStringsDtor**)&pAutoFmtNameLst; + *ppLst = new SvStringsDtor( STR_AUTOFMTREDL_END ); + ImpAutoFmtNameListLoader aTmp( **ppLst ); +} + +ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( SvStringsDtor& rLst ) + : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) ) +{ + for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n ) + { + String* p = new String( ResId( n + 1, *pSwResMgr) ); + if(STR_AUTOFMTREDL_TYPO == n) + { +#ifdef WNT + //fuer Windows Sonderbehandlung, da MS hier ein paar Zeichen im Dialogfont vergessen hat + p->SearchAndReplace(C2S("%1"), C2S(",,")); + p->SearchAndReplace(C2S("%2"), C2S("''")); +#else + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData(); + //unter richtigen Betriebssystemen funktioniert es auch so + p->SearchAndReplace(C2S("%1"), rLclD.getDoubleQuotationMarkStart()); + p->SearchAndReplace(C2S("%2"), rLclD.getDoubleQuotationMarkEnd()); +#endif + } + rLst.Insert( p, n ); + } + FreeResource(); +} +/* -----------------16.09.99 12:28------------------- + + --------------------------------------------------*/ +const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType) +{ + if(!pAuthFieldNameList) + { + pAuthFieldNameList = new SvStringsDtor(AUTH_FIELD_END, 1); + for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++) + { + String* pTmp = new String(SW_RES(STR_AUTH_FIELD_START + i)); + pAuthFieldNameList->Insert(pTmp, pAuthFieldNameList->Count()); + } + } + return *pAuthFieldNameList->GetObject( static_cast< sal_uInt16 >(eType) ); +} +/* -----------------16.09.99 12:29------------------- + + --------------------------------------------------*/ +const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType) +{ + if(!pAuthFieldTypeList) + { + pAuthFieldTypeList = new SvStringsDtor(AUTH_TYPE_END, 1); + for(sal_uInt16 i = 0; i < AUTH_TYPE_END; i++) + pAuthFieldTypeList->Insert( + new String(SW_RES(STR_AUTH_TYPE_START + i)), + pAuthFieldTypeList->Count()); + } + return *pAuthFieldTypeList->GetObject( static_cast< sal_uInt16 >(eType) ); +} + + + diff --git a/sw/source/ui/utlui/initui.hrc b/sw/source/ui/utlui/initui.hrc new file mode 100644 index 000000000000..367091fbd443 --- /dev/null +++ b/sw/source/ui/utlui/initui.hrc @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _INITUI_HRC +#define _INITUI_HRC + +#define BMP_FRAME_ANCHOR 1 +#define BMP_FRAME_DRAG_ANCHOR 2 + +// lokale Resourcen fuer die Shells: +#define STR_POSTIT_PAGE 1 +#define STR_POSTIT_AUTHOR 2 +#define STR_CALC_SYNTAX 3 +#define STR_CALC_ZERODIV 4 +#define STR_CALC_BRACK 5 +#define STR_CALC_POW 6 +#define STR_CALC_VARNFND 7 +#define STR_CALC_OVERFLOW 8 +#define STR_CALC_WRONGTIME 9 +#define STR_CALC_DEFAULT 10 +#define STR_CALC_ERROR 11 +#define STR_GETREFFLD_UP 12 +#define STR_GETREFFLD_DOWN 13 +#define STR_ALLPAGE_HEADFOOT 14 +#define STR_TEMPLATE_NONE 15 +#define STR_POSTIT_LINE 16 +#define STR_FIELD_FIXED 17 +#define STR_TOI 18 +#define STR_TOU 19 +#define STR_TOC 20 +#define STR_TOX_ILL 21 +#define STR_TOX_OBJ 22 +#define STR_TOX_TBL 23 +#define STR_TOX_AUTH 24 +#define STR_PAGEDESC_NAME 25 +#define STR_PAGEDESC_FIRSTNAME 26 +#define STR_PAGEDESC_FOLLOWNAME 27 +#define STR_HYPERLINK_CLICK 28 +#define STR_GETREFFLD_REFITEMNOTFOUND 29 +#define STR_DURATION_FORMAT 30 +#endif + diff --git a/sw/source/ui/utlui/initui.src b/sw/source/ui/utlui/initui.src new file mode 100644 index 000000000000..3b08e771a309 --- /dev/null +++ b/sw/source/ui/utlui/initui.src @@ -0,0 +1,519 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "globals.hrc" +#include "utlui.hrc" +#include "helpid.h" +#include "initui.hrc" + +/*--------------------------------------------------------------------- + Fehler Calculator + ---------------------------------------------------------------------*/ +Resource RID_SW_SHELLRES +{ + String STR_POSTIT_PAGE + { + Text [ en-US ] = "Page" ; + }; + String STR_POSTIT_LINE + { + Text [ en-US ] = "Line" ; + }; + String STR_POSTIT_AUTHOR + { + Text [ en-US ] = "Author" ; + }; + String STR_CALC_SYNTAX + { + Text [ en-US ] = "** Syntax Error **" ; + }; + String STR_CALC_ZERODIV + { + Text [ en-US ] = "** Division by zero **" ; + }; + String STR_CALC_BRACK + { + Text [ en-US ] = "** Wrong use of brackets **" ; + }; + String STR_CALC_POW + { + Text [ en-US ] = "** Square function overflow **" ; + /* ### ACHTUNG: Neuer Text in Resource? ** Überlauf in Quadratfunktion ** : ** šberlauf in Quadratfunktion ** */ + }; + String STR_CALC_VARNFND + { + Text [ en-US ] = "** Variable not found **" ; + }; + String STR_CALC_OVERFLOW + { + Text [ en-US ] = "** Overflow **" ; + /* ### ACHTUNG: Neuer Text in Resource? ** Überlauf ** : ** šberlauf ** */ + }; + String STR_CALC_WRONGTIME + { + Text [ en-US ] = "** Wrong time format **" ; + }; + String STR_CALC_DEFAULT + { + Text [ en-US ] = "** Error **" ; + }; + String STR_CALC_ERROR + { + Text [ en-US ] = "** Expression is faulty **" ; + }; + String STR_GETREFFLD_UP + { + Text [ en-US ] = "above" ; + }; + String STR_GETREFFLD_DOWN + { + Text [ en-US ] = "below" ; + }; + String STR_GETREFFLD_REFITEMNOTFOUND + { + Text [ en-US ] = "Error: Reference source not found" ; + }; + String STR_ALLPAGE_HEADFOOT + { + Text [ en-US ] = "All" ; + }; + String STR_TEMPLATE_NONE + { + Text [ en-US ] = "None" ; + }; + String STR_FIELD_FIXED + { + Text [ en-US ] = "(fixed)" ; + }; + String STR_DURATION_FORMAT + { + Text [en-US] = " Y: %1 M: %2 D: %3 H: %4 M: %5 S: %6"; + }; + String STR_TOI + { + Text [ en-US ] = "Alphabetical Index" ; + }; + + String STR_TOU + { + Text [ en-US ] = "User-Defined" ; + }; + + String STR_TOC + { + Text [ en-US ] = "Table of Contents" ; + }; + + String STR_TOX_AUTH + { + Text [ en-US ] = "Bibliography"; + }; + String STR_TOX_TBL + { + Text [ en-US ] = "Index of Tables"; + }; + String STR_TOX_OBJ + { + Text [ en-US ] = "Table of Objects"; + }; + String STR_TOX_ILL + { + Text [ en-US ] = "Illustration Index"; + }; + String STR_HYPERLINK_CLICK + { + Text [ en-US ] = "%s-click to open hyperlink"; + }; + + + // SubType DocInfo + // + String FLD_DOCINFO_TITEL + { + Text [ en-US ] = "Title" ; + }; + String FLD_DOCINFO_THEMA + { + Text [ en-US ] = "Subject" ; + }; + String FLD_DOCINFO_KEYS + { + /* ### ACHTUNG: Neuer Text in Resource? Schlüsselwörter : Schl³sselw÷rter */ + Text [ en-US ] = "Keywords" ; + }; + String FLD_DOCINFO_COMMENT + { + Text [ en-US ] = "Comments" ; + }; + String FLD_DOCINFO_CREATE + { + Text [ en-US ] = "Created" ; + }; + String FLD_DOCINFO_CHANGE + { + Text [ en-US ] = "Modified" ; + }; + String FLD_DOCINFO_PRINT + { + Text [ en-US ] = "Last printed" ; + }; + String FLD_DOCINFO_DOCNO + { + Text [ en-US ] = "Revision number" ; + }; + String FLD_DOCINFO_EDIT + { + Text [ en-US ] = "Total editing time" ; + }; + BITMAP BMP_FRAME_ANCHOR { FILE = "anchor.bmp" ; }; + BITMAP BMP_FRAME_DRAG_ANCHOR { FILE = "danchor.bmp" ; }; + + String STR_PAGEDESC_NAME + { + Text [ en-US ] = "Convert $(ARG1)"; + }; + String STR_PAGEDESC_FIRSTNAME + { + Text [ en-US ] = "First convert $(ARG1)"; + }; + String STR_PAGEDESC_FOLLOWNAME + { + Text [ en-US ] = "Next convert $(ARG1)"; + }; +}; + +String STR_AUTH_TYPE_ARTICLE +{ + Text [ en-US ] = "Article"; +}; +String STR_AUTH_TYPE_BOOK +{ + Text [ en-US ] = "Book"; +}; +String STR_AUTH_TYPE_BOOKLET +{ + Text [ en-US ] = "Brochures"; +}; +String STR_AUTH_TYPE_CONFERENCE +{ + Text [ en-US ] = "Conference proceedings"; +}; +String STR_AUTH_TYPE_INBOOK +{ + Text [ en-US ] = "Book excerpt"; +}; +String STR_AUTH_TYPE_INCOLLECTION +{ + Text [ en-US ] = "Book excerpt with title"; +}; +String STR_AUTH_TYPE_INPROCEEDINGS +{ + Text [ en-US ] = "Conference proceedings"; +}; +String STR_AUTH_TYPE_JOURNAL +{ + Text [ en-US ] = "Journal"; +}; +String STR_AUTH_TYPE_MANUAL +{ + Text [ en-US ] = "Techn. documentation"; +}; +String STR_AUTH_TYPE_MASTERSTHESIS +{ + Text [ en-US ] = "Thesis"; +}; +String STR_AUTH_TYPE_MISC +{ + Text [ en-US ] = "Miscellaneous"; +}; +String STR_AUTH_TYPE_PHDTHESIS +{ + Text [ en-US ] = "Dissertation"; +}; +String STR_AUTH_TYPE_PROCEEDINGS +{ + Text [ en-US ] = "Conference proceedings"; +}; +String STR_AUTH_TYPE_TECHREPORT +{ + Text [ en-US ] = "Research report"; +}; +String STR_AUTH_TYPE_UNPUBLISHED +{ + Text [ en-US ] = "Unpublished"; +}; +String STR_AUTH_TYPE_EMAIL +{ + Text [ en-US ] = "e-mail"; +}; +String STR_AUTH_TYPE_WWW +{ + Text [ en-US ] = "WWW document"; +}; +String STR_AUTH_TYPE_CUSTOM1 +{ + Text [ en-US ] = "User-defined1"; +}; +String STR_AUTH_TYPE_CUSTOM2 +{ + Text [ en-US ] = "User-defined2"; +}; +String STR_AUTH_TYPE_CUSTOM3 +{ + Text [ en-US ] = "User-defined3"; +}; +String STR_AUTH_TYPE_CUSTOM4 +{ + Text [ en-US ] = "User-defined4"; +}; +String STR_AUTH_TYPE_CUSTOM5 +{ + Text [ en-US ] = "User-defined5"; +}; + +String STR_AUTH_FIELD_IDENTIFIER +{ + Text [ en-US ] = "Short name"; +}; +String STR_AUTH_FIELD_AUTHORITY_TYPE +{ + Text [ en-US ] = "Type"; +}; +String STR_AUTH_FIELD_ADDRESS +{ + Text [ en-US ] = "Address"; +}; +String STR_AUTH_FIELD_ANNOTE +{ + Text [ en-US ] = "Annotation"; +}; +String STR_AUTH_FIELD_AUTHOR +{ + Text [ en-US ] = "Author(s)"; +}; +String STR_AUTH_FIELD_BOOKTITLE +{ + Text [ en-US ] = "Book title"; +}; +String STR_AUTH_FIELD_CHAPTER +{ + Text [ en-US ] = "Chapter"; +}; +String STR_AUTH_FIELD_EDITION +{ + Text [ en-US ] = "Edition"; +}; +String STR_AUTH_FIELD_EDITOR +{ + Text [ en-US ] = "Editor"; +}; +String STR_AUTH_FIELD_HOWPUBLISHED +{ + Text [ en-US ] = "Publication type"; +}; +String STR_AUTH_FIELD_INSTITUTION +{ + Text [ en-US ] = "Institution"; +}; +String STR_AUTH_FIELD_JOURNAL +{ + Text [ en-US ] = "Journal"; +}; +String STR_AUTH_FIELD_MONTH +{ + Text [ en-US ] = "Month"; +}; +String STR_AUTH_FIELD_NOTE +{ + Text [ en-US ] = "Note"; +}; +String STR_AUTH_FIELD_NUMBER +{ + Text [ en-US ] = "Number"; +}; +String STR_AUTH_FIELD_ORGANIZATIONS +{ + Text [ en-US ] = "Organization"; +}; +String STR_AUTH_FIELD_PAGES +{ + Text [ en-US ] = "Page(s)"; +}; +String STR_AUTH_FIELD_PUBLISHER +{ + Text [ en-US ] = "Publisher"; +}; +String STR_AUTH_FIELD_SCHOOL +{ + Text [ en-US ] = "University"; +}; +String STR_AUTH_FIELD_SERIES +{ + Text [ en-US ] = "Series"; +}; +String STR_AUTH_FIELD_TITLE +{ + Text [ en-US ] = "Title"; +}; +String STR_AUTH_FIELD_TYPE +{ + Text [ en-US ] = "Type of report"; +}; +String STR_AUTH_FIELD_VOLUME +{ + Text [ en-US ] = "Volume"; +}; +String STR_AUTH_FIELD_YEAR +{ + Text [ en-US ] = "Year"; +}; +String STR_AUTH_FIELD_URL +{ + Text [ en-US ] = "URL"; +}; +String STR_AUTH_FIELD_CUSTOM1 +{ + Text [ en-US ] = "User-defined1"; +}; +String STR_AUTH_FIELD_CUSTOM2 +{ + Text [ en-US ] = "User-defined2"; +}; +String STR_AUTH_FIELD_CUSTOM3 +{ + Text [ en-US ] = "User-defined3"; +}; +String STR_AUTH_FIELD_CUSTOM4 +{ + Text [ en-US ] = "User-defined4"; +}; +String STR_AUTH_FIELD_CUSTOM5 +{ + Text [ en-US ] = "User-defined5"; +}; +String STR_AUTH_FIELD_ISBN +{ + Text [ en-US ] = "ISBN"; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/source/ui/utlui/navicfg.cxx b/sw/source/ui/utlui/navicfg.cxx new file mode 100644 index 000000000000..2edc5e9d8f71 --- /dev/null +++ b/sw/source/ui/utlui/navicfg.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <swtypes.hxx> // fuer Pathfinder +#include <navicfg.hxx> +#include <swcont.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <unomid.h> + +using namespace ::utl; +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +/* -----------------------------08.09.00 16:30-------------------------------- + + ---------------------------------------------------------------------------*/ +Sequence<OUString> SwNavigationConfig::GetPropertyNames() +{ + static const char* aPropNames[] = + { + "RootType", //0 + "SelectedPosition", //1 + "OutlineLevel", //2 + "InsertMode", //3 + "ActiveBlock", //4 + "ShowListBox", //5 + "GlobalDocMode" //6 + }; + const int nCount = 7; + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + { + pNames[i] = OUString::createFromAscii(aPropNames[i]); + } + return aNames; +} +/*-----------------13.11.96 11.03------------------- + +--------------------------------------------------*/ + +SwNavigationConfig::SwNavigationConfig() : + utl::ConfigItem(C2U("Office.Writer/Navigator")), + nRootType(0xffff), + nSelectedPos(0), + nOutlineLevel(MAXLEVEL), + nRegionMode(REGION_MODE_NONE), + nActiveBlock(0), + bIsSmall(sal_False), + bIsGlobalActive(sal_True) +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); +// EnableNotification(aNames); + const Any* pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case 0: pValues[nProp] >>= nRootType; break; + case 1: pValues[nProp] >>= nSelectedPos; break; + case 2: pValues[nProp] >>= nOutlineLevel; break; + case 3: pValues[nProp] >>= nRegionMode; break; + case 4: pValues[nProp] >>= nActiveBlock; break; + case 5: bIsSmall = *(sal_Bool*)pValues[nProp].getValue(); break; + case 6: bIsGlobalActive = *(sal_Bool*)pValues[nProp].getValue(); break; + } + } + } + } +} +/* -----------------------------08.09.00 16:35-------------------------------- + + ---------------------------------------------------------------------------*/ +SwNavigationConfig::~SwNavigationConfig() +{} +/* -----------------------------08.09.00 16:35-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwNavigationConfig::Commit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + const Type& rType = ::getBooleanCppuType(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= nRootType; break; + case 1: pValues[nProp] <<= nSelectedPos; break; + case 2: pValues[nProp] <<= nOutlineLevel; break; + case 3: pValues[nProp] <<= nRegionMode; break; + case 4: pValues[nProp] <<= nActiveBlock; break; + case 5: pValues[nProp].setValue(&bIsSmall, rType); break; + case 6: pValues[nProp].setValue(&bIsGlobalActive, rType); break; + } + } + PutProperties(aNames, aValues); +} + +void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} + + diff --git a/sw/source/ui/utlui/navipi.cxx b/sw/source/ui/utlui/navipi.cxx new file mode 100644 index 000000000000..d88ecdf6be73 --- /dev/null +++ b/sw/source/ui/utlui/navipi.cxx @@ -0,0 +1,1558 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + + +#define NAVIPI_CXX + +#include <string> // HACK: prevent conflict between STLPORT and Workshop headers +#include <tools/list.hxx> +#include <svl/urlbmk.hxx> +#include <svl/stritem.hxx> +#include <svtools/filter.hxx> +#include <svl/urihelper.hxx> +#include <sot/formats.hxx> +#include <sot/filelist.hxx> +#include <sfx2/event.hxx> +#include <sfx2/imgmgr.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/dockwin.hxx> +#include <vcl/toolbox.hxx> +#include <swtypes.hxx> // fuer Pathfinder +#include <errhdl.hxx> +#include <swmodule.hxx> +#ifndef _VIEW_HXX +#include <view.hxx> +#endif +#include <navicfg.hxx> +#include <wrtsh.hxx> +#ifndef _DOCSH_HXX +#include <docsh.hxx> +#endif +#include <actctrl.hxx> +#include <IMark.hxx> +#include <navipi.hxx> +#include <content.hxx> +#include <workctrl.hxx> +#include <section.hxx> +#include <edtwin.hxx> +#include <sfx2/app.hxx> +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#ifndef _HELPID_H +#include <helpid.h> +#endif +#ifndef _RIBBAR_HRC +#include <ribbar.hrc> +#endif +#ifndef _NAVIPI_HRC +#include <navipi.hrc> +#endif +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif + +#include "access.hrc" + +#include <unomid.h> + + +#define PAGE_CHANGE_TIMEOUT 1000 //Timeout fuer Seitenwechsel + +#define JUMP_TYPE_TBL 0 +#define JUMP_TYPE_FRM 1 +#define JUMP_TYPE_GRF 2 +#define JUMP_TYPE_REG 3 +#define JUMP_TYPE_BKM 4 + +// Version fuer Konfiguration + +#define NAVI_VERSION0 0 +#define NAVI_VERSION1 1 +#define NAVI_VERSION2 2 // bIsGlobalActive + +#define NAVI_CONFIG_VERSION NAVI_VERSION2 + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; + +SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView ) + +/*------------------------------------------------------------------------ + Bechreibung: Steuerzeichen aus dem Outline-Entry filtern +------------------------------------------------------------------------*/ + +void SwNavigationPI::CleanEntry( String& rEntry ) +{ + sal_uInt16 i = rEntry.Len(); + if( i ) + for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr ) + if( *pStr == 10 || *pStr == 9 ) + *pStr = 0x20; +} +/*------------------------------------------------------------------------ + Beschreibung: Ausfuehrung der Drag-Operation + mit und ohne Childs +------------------------------------------------------------------------*/ + +void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, + sal_Bool bWithChilds) +{ + SwView *pView = GetCreateView(); + SwWrtShell &rSh = pView->GetWrtShell(); + if(nTarget < nSource || nTarget == USHRT_MAX) + nTarget ++; + if ( rSh.IsOutlineMovable( nSource )) + { + + short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ; + rSh.GotoOutline(nSource); + if (bWithChilds) + rSh.MakeOutlineSel(nSource, nSource, sal_True); + // Die selektierten Children zaehlen bei der Bewegung vorwaerts nicht mit + sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL); + if(bWithChilds && nMove > 1 && + nLastOutlinePos < nTarget) + { + if(!rSh.IsCrsrPtAtEnd()) + rSh.SwapPam(); + nMove -= nLastOutlinePos - nSource; + } + if(!bWithChilds || nMove < 1 || nLastOutlinePos < nTarget ) + rSh.MoveOutlinePara( nMove ); + rSh.ClearMark(); + rSh.GotoOutline( nSource + nMove); + FillBox(); + } + +} + + +/*------------------------------------------------------------------------ + Beschreibung: Nach Goto einen Status Rahmenselektion aufheben +------------------------------------------------------------------------*/ + + +void lcl_UnSelectFrm(SwWrtShell *pSh) +{ + if (pSh->IsFrmSelected()) + { + pSh->UnSelectFrm(); + pSh->LeaveSelFrmMode(); + } +} + +/*------------------------------------------------------------------------ + Beschreibung: Select der Documentanzeige +------------------------------------------------------------------------*/ + + +IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox ) +{ + int nEntryIdx = pBox->GetSelectEntryPos(); + SwView *pView ; + pView = SwModule::GetFirstView(); + while (nEntryIdx-- && pView) + { + pView = SwModule::GetNextView(pView); + } + if(!pView) + { + nEntryIdx == 0 ? + aContentTree.ShowHiddenShell(): + aContentTree.ShowActualView(); + + + } + else + { + aContentTree.SetConstantShell(pView->GetWrtShellPtr()); + } + return 0; +} + +/*------------------------------------------------------------------------ + Beschreibung: Fuellen der ListBox fuer Outline Sicht oder Dokumente + Der PI wird auf volle Groesse gesetzt +------------------------------------------------------------------------*/ + + +void SwNavigationPI::FillBox() +{ + if(pContentWrtShell) + { + aContentTree.SetHiddenShell( pContentWrtShell ); + aContentTree.Display( sal_False ); + } + else + { + SwView *pView = GetCreateView(); + if(!pView) + { + aContentTree.SetActiveShell(0); + } + else if( pView != pActContView) + { + SwWrtShell* pWrtShell = pView->GetWrtShellPtr(); + aContentTree.SetActiveShell(pWrtShell); + } + else + aContentTree.Display( sal_True ); + pActContView = pView; + } +} + + +void SwNavigationPI::UsePage(SwWrtShell *pSh) +{ + if (!pSh) + { + SwView *pView = GetCreateView(); + pSh = pView ? &pView->GetWrtShell() : 0; + GetPageEdit().SetValue(1); + } + if (pSh) + { + const sal_uInt16 nPageCnt = pSh->GetPageCnt(); + sal_uInt16 nPhyPage, nVirPage; + pSh->GetPageNum(nPhyPage, nVirPage); + + GetPageEdit().SetMax(nPageCnt); + GetPageEdit().SetLast(nPageCnt); + GetPageEdit().SetValue(nPhyPage); + } +} + +/*------------------------------------------------------------------------ + Beschreibung: SelectHandler der Toolboxen +------------------------------------------------------------------------*/ + + +IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox ) +{ + const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); + SwView *pView = GetCreateView(); + if (!pView) + return 1; + SwWrtShell &rSh = pView->GetWrtShell(); + //MouseModifier fuer Outline-Move besorgen + + //Standard: Unterebenen werden mitgenommen + // mit Ctrl Unterebenen nicht mitnehmen + sal_Bool bOutlineWithChilds = ( KEY_MOD1 != pBox->GetModifier()); + int nFuncId = 0; + sal_Bool bFocusToDoc = sal_False; + switch (nCurrItemId) + { + case FN_UP: + case FN_DOWN: + { + // #i75416# move the execution of the search to an asynchronously called static link + bool* pbNext = new bool( FN_DOWN == nCurrItemId ); + Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext ); + } + break; + case FN_SHOW_ROOT: + { + aContentTree.ToggleToRoot(); + } + break; + case FN_SHOW_CONTENT_BOX: + case FN_SELECT_CONTENT: + if(pContextWin->GetFloatingWindow()) + { + if(_IsZoomedIn() ) + { + _ZoomOut(); + } + else + { + _ZoomIn(); + } + } + return sal_True; + //break; + // Funktionen, die eine direkte Aktion ausloesen + + case FN_SELECT_FOOTER: + { + rSh.MoveCrsr(); + const sal_uInt16 eType = rSh.GetFrmType(0,sal_False); + if (eType & FRMTYPE_FOOTER) + { + if (rSh.EndPg()) + nFuncId = FN_END_OF_PAGE; + } + else if (rSh.GotoFooterTxt()) + nFuncId = FN_TO_FOOTER; + bFocusToDoc = sal_True; + } + break; + case FN_SELECT_HEADER: + { + rSh.MoveCrsr(); + const sal_uInt16 eType = rSh.GetFrmType(0,sal_False); + if (eType & FRMTYPE_HEADER) + { + if (rSh.SttPg()) + nFuncId = FN_START_OF_PAGE; + } + else if (rSh.GotoHeaderTxt()) + nFuncId = FN_TO_HEADER; + bFocusToDoc = sal_True; + } + break; + case FN_SELECT_FOOTNOTE: + { + rSh.MoveCrsr(); + const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_False); + // aus Fussnote zum Anker springen + if (eFrmType & FRMTYPE_FOOTNOTE) + { + if (rSh.GotoFtnAnchor()) + nFuncId = FN_FOOTNOTE_TO_ANCHOR; + } + // andernfalls zuerst zum Fussnotentext springen; geht + // dies nicht, zur naechten Fussnote; geht auch dies + // nicht, zur vorhergehenden Fussnote + else + { + if (rSh.GotoFtnTxt()) + nFuncId = FN_FOOTNOTE_TO_ANCHOR; + else if (rSh.GotoNextFtnAnchor()) + nFuncId = FN_NEXT_FOOTNOTE; + else if (rSh.GotoPrevFtnAnchor()) + nFuncId = FN_PREV_FOOTNOTE; + } + bFocusToDoc = sal_True; + } + break; + + case FN_SELECT_SET_AUTO_BOOKMARK: + MakeMark(); + break; + case FN_ITEM_DOWN: + case FN_ITEM_UP: + case FN_ITEM_LEFT: + case FN_ITEM_RIGHT: + case FN_GLOBAL_EDIT: + { + if(IsGlobalMode()) + aGlobalTree.ExecCommand(nCurrItemId); + else + aContentTree.ExecCommand(nCurrItemId, bOutlineWithChilds); + } + break; + case FN_GLOBAL_SWITCH: + { + ToggleTree(); + pConfig->SetGlobalActive(IsGlobalMode()); + } + break; + case FN_GLOBAL_SAVE_CONTENT: + { + sal_Bool bSave = rSh.IsGlblDocSaveLinks(); + rSh.SetGlblDocSaveLinks( !bSave ); + pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave ); + } + break; + } + + if (nFuncId) + { + lcl_UnSelectFrm(&rSh); + } + if(bFocusToDoc) + pView->GetEditWin().GrabFocus(); + return sal_True; +} +/*------------------------------------------------------------------------ + Beschreibung: ClickHandler der Toolboxen +------------------------------------------------------------------------*/ + + +IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox ) +{ + const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); + switch (nCurrItemId) + { + case FN_GLOBAL_UPDATE: + case FN_GLOBAL_OPEN: + { + aGlobalTree.TbxMenuHdl(nCurrItemId, pBox); + } + break; + } + + return sal_True; +} + +/*-----------------13.07.04 ------------------- + ----------------------------------------------*/ + +IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox ) +{ + const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); + switch (nCurrItemId) + { + case FN_CREATE_NAVIGATION: + { + CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), sal_True); + } + break; + + case FN_DROP_REGION: + { + static const char* aHIDs[] = + { + HID_NAVI_DRAG_HYP, + HID_NAVI_DRAG_LINK, + HID_NAVI_DRAG_COPY, + }; + PopupMenu *pMenu = new PopupMenu; + for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++) + { + pMenu->InsertItem( i + 1, aContextArr[i] ); + pMenu->SetHelpId(i + 1, aHIDs[i]); + } + pMenu->CheckItem( nRegionMode + 1 ); + pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); + pBox->SetItemDown( nCurrItemId, sal_True ); + pMenu->Execute( pBox, + pBox->GetItemRect(FN_DROP_REGION), + POPUPMENU_EXECUTE_DOWN ); + pBox->SetItemDown( nCurrItemId, sal_False ); + pBox->EndSelection(); + delete pMenu; + pBox->Invalidate(); + } + break; + case FN_OUTLINE_LEVEL: + { + PopupMenu *pMenu = new PopupMenu; + for (sal_uInt16 i = 101; i <= 100 + MAXLEVEL; i++) + { + pMenu->InsertItem( i, String::CreateFromInt32(i - 100) ); + pMenu->SetHelpId( i, HID_NAVI_OUTLINES ); + } + pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 ); + pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); + pBox->SetItemDown( nCurrItemId, sal_True ); + pMenu->Execute( pBox, + pBox->GetItemRect(FN_OUTLINE_LEVEL), + POPUPMENU_EXECUTE_DOWN ); + pBox->SetItemDown( nCurrItemId, sal_False ); + delete pMenu; + pBox->EndSelection(); + pBox->Invalidate(); + } + break; + } + return sal_True; +} + +/*-----------------13.07.04 ------------------- +--------------------------------------------------*/ + +SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) : + SwHelpToolBox(pParent, rResId) +{} +/*-----------------19.06.97 09:09------------------- + +--------------------------------------------------*/ +void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt) +{ + if(rEvt.GetButtons() == MOUSE_LEFT && + FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel())) + { + ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), sal_False); + } + else + SwHelpToolBox::MouseButtonDown(rEvt); +} +/* -----------------------------12.03.2002 16:55------------------------------ + + ---------------------------------------------------------------------------*/ +void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, sal_Bool bSetFocus) +{ +// SfxBindings& rBind = GetCreateView()->GetViewFrame()->GetBindings(); +// rBind.ENTERREGISTRATIONS(); + Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface(); + SwScrollNaviPopup* pPopup = new + SwScrollNaviPopup(FN_SCROLL_NAVIGATION, + xFrame ); +// rBind.LEAVEREGISTRATIONS(); + + Rectangle aRect(rRect); + Point aT1 = aRect.TopLeft(); + aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1))); + aRect.SetPos(aT1); + pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF); + SetPopupWindow( pPopup ); + if(bSetFocus) + { + pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF); + pPopup->GrabFocus(); + } +} + +/*-----------------19.06.97 10:12------------------- + +--------------------------------------------------*/ +void SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt ) +{ + sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel())); + if( FN_UP == nItemId || FN_DOWN == nItemId ) + { + SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId))); + } + SwHelpToolBox::RequestHelp(rHEvt); +} + +/*------------------------------------------------------------------------ + Beschreibung: Action-Handler Edit; wechselt auf die Seite, wenn + nicht Gliederungssicht angeschaltet ist. +------------------------------------------------------------------------*/ + + +IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit ) +{ + SwView *pView = GetCreateView(); + if (pView) + { + if(aPageChgTimer.IsActive()) + aPageChgTimer.Stop(); + pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), sal_True); + pCreateView->GetEditWin().GrabFocus(); + pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE); + } + return 0; +} + +/*------------------------------------------------------------------------ + Beschreibung: Falls die Seite eingestellt werden kann, wird hier + das Maximum gesetzt. +------------------------------------------------------------------------*/ + + +IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit ) +{ + SwView *pView = GetCreateView(); + if (!pView) + return 0; + SwWrtShell &rSh = pView->GetWrtShell(); + + const sal_uInt16 nPageCnt = rSh.GetPageCnt(); + pEdit->SetMax(nPageCnt); + pEdit->SetLast(nPageCnt); + return 0; +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +sal_Bool SwNavigationPI::Close() +{ + SfxViewFrame* pVFrame = pCreateView->GetViewFrame(); + pVFrame->GetBindings().Invalidate(SID_NAVIGATOR); + pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR); + return sal_True; +} + +/*------------------------------------------------------------------------ + Beschreibung: Setzen einer automatischen Marke +------------------------------------------------------------------------*/ + + +void SwNavigationPI::MakeMark() +{ + SwView *pView = GetCreateView(); + if (!pView) return; + SwWrtShell &rSh = pView->GetWrtShell(); + IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); + + // collect and sort navigator reminder names + ::std::vector< ::rtl::OUString > vNavMarkNames; + for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + ppMark != pMarkAccess->getMarksEnd(); + ppMark++) + if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER ) + vNavMarkNames.push_back(ppMark->get()->GetName()); + ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end()); + + // we are maxed out and delete one + // nAutoMarkIdx rotates through the available MarkNames + // this assumes that IDocumentMarkAccess generates Names in ascending order + if(vNavMarkNames.size() == MAX_MARKS) + pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx])); + + rSh.SetBookmark(KeyCode(), ::rtl::OUString(), ::rtl::OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER); + SwView::SetActMark( nAutoMarkIdx ); + + if(++nAutoMarkIdx == MAX_MARKS) + nAutoMarkIdx = 0; +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::GotoPage() +{ + if ( pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp()) + _ZoomIn(); + if(IsGlobalMode()) + ToggleTree(); + UsePage(0); + GetPageEdit().GrabFocus(); +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::_ZoomOut() +{ + if (_IsZoomedIn()) + { + FloatingWindow* pFloat = pContextWin->GetFloatingWindow(); + bIsZoomedIn = sal_False; + Size aSz(GetOutputSizePixel()); + aSz.Height() = nZoomOut; + Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel(); + ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size( + aMinOutSizePixel.Width(),nZoomOutInit)); + pFloat->SetOutputSizePixel(aSz); + FillBox(); + if(IsGlobalMode()) + { + aGlobalTree.ShowTree(); + } + else + { + aContentTree.ShowTree(); + aDocListBox.Show(); + } + SvLBoxEntry* pFirst = aContentTree.FirstSelected(); + if(pFirst) + aContentTree.Select(pFirst, sal_True); // toolbox enablen + pConfig->SetSmall( sal_False ); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX); + } +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::_ZoomIn() +{ + FloatingWindow* pFloat = pContextWin->GetFloatingWindow(); + if (pFloat && + (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp()))) + { + aContentTree.HideTree(); + aDocListBox.Hide(); + aGlobalTree.HideTree(); + bIsZoomedIn = sal_True; + Size aSz(GetOutputSizePixel()); + if( aSz.Height() > nZoomIn ) + nZoomOut = ( short ) aSz.Height(); + + aSz.Height() = nZoomIn; + Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel(); + ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size( + aMinOutSizePixel.Width(), aSz.Height())); + pFloat->SetOutputSizePixel(aSz); + SvLBoxEntry* pFirst = aContentTree.FirstSelected(); + if(pFirst) + aContentTree.Select(pFirst, sal_True); // toolbox enablen + pConfig->SetSmall( sal_True ); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_False); + } +} +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::Resize() +{ + Window* pParent = GetParent(); + FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow(); + Size aNewSize; + if( !_IsZoomedIn() ) + { + //change the minimum width depending on the dock status + Size aMinOutSizePixel = ((SfxDockingWindow*)pParent)->GetMinOutputSizePixel(); + if( pFloat) + { + aNewSize = pFloat->GetOutputSizePixel(); + aMinOutSizePixel.Width() = nWishWidth; + aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit; + } + else + { + aNewSize = pParent->GetOutputSizePixel(); + aMinOutSizePixel.Width() = 0; + aMinOutSizePixel.Height() = 0; + } + ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(aMinOutSizePixel); + + const Point aPos = aContentTree.GetPosPixel(); + Point aLBPos = aDocListBox.GetPosPixel(); + long nDist = aPos.X(); + aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist); + aNewSize.Width() -= 2 * nDist; + aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist; + aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() ); + + Size aDocLBSz = aDocListBox.GetSizePixel(); + aDocLBSz.Width() = aNewSize.Width(); + if(aNewSize.Height() < 0) + aDocLBSz.Height() = 0; + else + aDocLBSz.Height() = nDocLBIniHeight; + aContentTree.SetSizePixel(aNewSize); + // GlobalTree faengt weiter oben an und reicht bis ganz unten + aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y()); + aGlobalTree.SetSizePixel(aNewSize); + aDocListBox.SetPosSizePixel( aLBPos.X(), aLBPos.Y(), + aDocLBSz.Width(), aDocLBSz.Height(), + WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH); + + } +} + + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings, + SfxChildWindowContext* pCw, + Window* pParent) : + + Window( pParent, SW_RES(DLG_NAVIGATION_PI)), + SfxControllerItem( SID_DOCFULLNAME, *_pBindings ), + + aContentToolBox(this, SW_RES(TB_CONTENT)), + aGlobalToolBox(this, SW_RES(TB_GLOBAL)), + aContentImageList(SW_RES(IL_CONTENT)), + aContentImageListH(SW_RES(ILH_CONTENT)), + aContentTree(this, SW_RES(TL_CONTENT)), + aGlobalTree(this, SW_RES(TL_GLOBAL)), + aDocListBox(this, SW_RES(LB_DOCS)), + + pxObjectShell(0), + pContentView(0), + pContentWrtShell(0), + pActContView(0), + pCreateView(0), + pPopupWindow(0), + pFloatingWindow(0), + + pContextWin(pCw), + + pConfig(SW_MOD()->GetNavigationConfig()), + rBindings(*_pBindings), + + nWishWidth(0), + nAutoMarkIdx(1), + nRegionMode(REGION_MODE_NONE), + + bSmallMode(sal_False), + bIsZoomedIn(sal_False), + bPageCtrlsVisible(sal_False), + bGlobalMode(sal_False) +{ + GetCreateView(); + InitImageList(); + + aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX ); + aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX); + aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX ); + + nDocLBIniHeight = aDocListBox.GetSizePixel().Height(); + nZoomOutInit = nZoomOut = Resource::ReadShortRes(); + + //NumericField in die Toolbox einfuegen + NumEditAction* pEdit = new NumEditAction( + &aContentToolBox, SW_RES(NF_PAGE )); + pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction)); + pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus)); + pEdit->SetModifyHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); + pEdit->SetAccessibleName(pEdit->GetQuickHelpText()); + bPageCtrlsVisible = sal_True; + +// Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SHOW_ROOT); +// sal_uInt16 nWidth = 2 * (sal_uInt16)aFirstRect.Left(); + //doppelte Separatoren sind nicht erlaubt, also muss + //die passende Groesse anders ermittelt werden + Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE); + Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER); + sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left()); + + Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() ); + pEdit->SetSizePixel(aItemWinSize); + aContentToolBox.InsertSeparator(4); + aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4); + aContentToolBox.InsertSeparator(4); + aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16); + aContentToolBox.ShowItem( FN_PAGENUMBER ); + + for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++ ) + { + aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i); + aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i); + } + aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW); + FreeResource(); + + + const Size& rOutSize = GetOutputSizePixel(); + + nZoomIn = (short)rOutSize.Height(); + + // Make sure the toolbox has a size that fits all its contents + Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() ); + aContentToolBox.SetOutputSizePixel( aContentToolboxSize ); + + // position listbox below toolbar and add some space + long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4; + + //Der linke und rechte Rand um die Toolboxen soll gleich sein + nWishWidth = aContentToolboxSize.Width(); + nWishWidth += 2 * aContentToolBox.GetPosPixel().X(); + + FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow(); + Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0); + ((SfxDockingWindow*)pParent)->SetMinOutputSizePixel(aMinSize); + SetOutputSizePixel( Size( nWishWidth, nZoomOutInit)); + Size aTmpParentSize(((SfxDockingWindow*)pParent)->GetSizePixel()); + if( + ( + aTmpParentSize.Width() < aMinSize.Width() || + aTmpParentSize.Height() < aMinSize.Height() + ) + && + ((SfxDockingWindow*)pParent)->GetFloatingWindow() && + !((SfxDockingWindow*)pParent)->GetFloatingWindow()->IsRollUp() + ) + ((SfxDockingWindow*)pParent)->SetOutputSizePixel(aMinSize); + + aContentTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); + aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT| + WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE ); + aContentTree.SetSpaceBetweenEntries(3); + aContentTree.SetSelectionMode( SINGLE_SELECTION ); + aContentTree.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | + SV_DRAGDROP_CTRL_COPY | + SV_DRAGDROP_ENABLE_TOP ); + aContentTree.EnableAsyncDrag(sal_True); + aContentTree.ShowTree(); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_True); + +// TreeListBox fuer Globaldokument + aGlobalTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); + aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION ); + aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT| + WB_CLIPCHILDREN|WB_HSCROLL ); + Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel()); + aGlobalToolBox.SetSizePixel(aGlblSize); + +// Handler + + Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl); + aContentToolBox.SetSelectHdl( aLk ); + aGlobalToolBox.SetSelectHdl( aLk ); + aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI, + DocListBoxSelectHdl)); + aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) ); + aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) ); + aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) ); + aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) ); + aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, sal_True); + + Font aFont(GetFont()); + aFont.SetWeight(WEIGHT_NORMAL); + GetPageEdit().SetFont(aFont); + aFont = aContentTree.GetFont(); + aFont.SetWeight(WEIGHT_NORMAL); + aContentTree.SetFont(aFont); + aGlobalTree.SetFont(aFont); + + StartListening(*SFX_APP()); + if ( pCreateView ) + StartListening(*pCreateView); + SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); + pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); + pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); + + aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY ); + aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY ); + aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY ); + + if(IsGlobalDoc()) + { + SwView *pActView = GetCreateView(); + aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, + pActView->GetWrtShellPtr()->IsGlblDocSaveLinks()); + if(pConfig->IsGlobalActive()) + ToggleTree(); + aGlobalTree.GrabFocus(); + } + else + aContentTree.GrabFocus(); + UsePage(0); + aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl)); + aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT); + + aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT)); + aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL)); + aDocListBox.SetAccessibleName(aStatusArr[3]); +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +SwNavigationPI::~SwNavigationPI() +{ + if(IsGlobalDoc() && !IsGlobalMode()) + { + SwView *pView = GetCreateView(); + SwWrtShell &rSh = pView->GetWrtShell(); + if( !rSh.IsAllProtect() ) + pView->GetDocShell()->SetReadOnlyUI(sal_False); + } + + EndListening(*SFX_APP()); + + SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); + pImgMan->ReleaseToolBox(&aContentToolBox); + pImgMan->ReleaseToolBox(&aGlobalToolBox); + delete aContentToolBox.GetItemWindow(FN_PAGENUMBER); + aContentToolBox.Clear(); + if(pxObjectShell) + { + if(pxObjectShell->Is()) + (*pxObjectShell)->DoClose(); + delete pxObjectShell; + } + delete pPopupWindow; + delete pFloatingWindow; + + if ( IsBound() ) + rBindings.Release(*this); +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow ) +{ + pPopupWindow = pWindow; + pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl )); + pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow )); +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +IMPL_LINK( SwNavigationPI, PopupModeEndHdl, void *, EMPTYARG ) +{ + if ( pPopupWindow->IsVisible() ) + { + // Replace floating window with popup window and destroy + // floating window instance. + delete pFloatingWindow; + pFloatingWindow = pPopupWindow; + pPopupWindow = 0; + } + else + { + // Popup window has been closed by the user. No replacement, instance + // will destroy itself. + pPopupWindow = 0; + } + + return 1; +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow ) +{ + if ( pWindow == pFloatingWindow ) + pFloatingWindow = 0; + else + pPopupWindow = 0; + + return 1; +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, + const SfxPoolItem* /*pState*/ ) +{ + if(nSID == SID_DOCFULLNAME) + { + SwView *pActView = GetCreateView(); + if(pActView) + { + SwWrtShell* pWrtShell = pActView->GetWrtShellPtr(); + aContentTree.SetActiveShell(pWrtShell); + sal_Bool bGlobal = IsGlobalDoc(); + aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal); + if( (!bGlobal && IsGlobalMode()) || + (!IsGlobalMode() && pConfig->IsGlobalActive()) ) + { + ToggleTree(); + } + if(bGlobal) + { + aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks()); + } + } + else + { + aContentTree.SetActiveShell(0); + } + UpdateListBox(); + } +} + +/*------------------------------------------------------------------------ + Bechreibung: NumericField aus der Toolbox holen +------------------------------------------------------------------------*/ + +NumEditAction& SwNavigationPI::GetPageEdit() +{ + return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER); +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +SfxChildAlignment SwNavigationPI::CheckAlignment + ( + SfxChildAlignment eActAlign, + SfxChildAlignment eAlign + ) +{ +SfxChildAlignment eRetAlign; + + if(_IsZoomedIn()) + eRetAlign = SFX_ALIGN_NOALIGNMENT; + else + switch (eAlign) + { + case SFX_ALIGN_BOTTOM: + case SFX_ALIGN_LOWESTBOTTOM: + case SFX_ALIGN_HIGHESTBOTTOM: + eRetAlign = eActAlign; + break; + + case SFX_ALIGN_TOP: + case SFX_ALIGN_HIGHESTTOP: + case SFX_ALIGN_LOWESTTOP: + case SFX_ALIGN_LEFT: + case SFX_ALIGN_RIGHT: + case SFX_ALIGN_FIRSTLEFT: + case SFX_ALIGN_LASTLEFT: + case SFX_ALIGN_FIRSTRIGHT: + case SFX_ALIGN_LASTRIGHT: + eRetAlign = eAlign; + break; + + default: + eRetAlign = eAlign; + break; + } + return eRetAlign; + +} + +/*-------------------------------------------------------------------- + Beschreibung: Benachrichtigung bei geaenderter DocInfo + --------------------------------------------------------------------*/ + +void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint ) +{ + if(&rBrdc == pCreateView) + { + if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING) + { + pCreateView = 0; + } + } + else + { + if(rHint.ISA(SfxEventHint)) + { + if( pxObjectShell && + ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP) + { + DELETEZ(pxObjectShell); + } + else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC) + { + + SwView *pActView = GetCreateView(); + if(pActView) + { + SwWrtShell* pWrtShell = pActView->GetWrtShellPtr(); + aContentTree.SetActiveShell(pWrtShell); + if(aGlobalTree.IsVisible()) + { + if(aGlobalTree.Update( sal_False )) + aGlobalTree.Display(); + else + // wenn kein Update notwendig, dann zumindest painten + // wg. der roten Eintraege fuer broken links + aGlobalTree.Invalidate(); + } + } + } + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu ) +{ + sal_uInt16 nMenuId = pMenu->GetCurItemId(); + if(nMenuId != USHRT_MAX) + { + if(nMenuId < 100) + SetRegionDropMode( --nMenuId); + else + aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) ); + } + return 0; +} + + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SwNavigationPI::UpdateListBox() +{ + aDocListBox.SetUpdateMode(sal_False); + aDocListBox.Clear(); + SwView *pActView = GetCreateView(); + sal_Bool bDisable = pActView == 0; + SwView *pView = SwModule::GetFirstView(); + sal_uInt16 nCount = 0; + sal_uInt16 nAct = 0; + sal_uInt16 nConstPos = 0; + const SwView* pConstView = aContentTree.IsConstantView() && + aContentTree.GetActiveWrtShell() ? + &aContentTree.GetActiveWrtShell()->GetView(): + 0; + while (pView) + { + SfxObjectShell* pDoc = pView->GetDocShell(); + // pb: #i53333# don't show help pages here + if ( !pDoc->IsHelpDocument() ) + { + String sEntry = pDoc->GetTitle(); + sEntry += C2S(" ("); + if (pView == pActView) + { + nAct = nCount; + sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST]; + } + else + sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST]; + sEntry += ')'; + aDocListBox.InsertEntry(sEntry); + + + if (pConstView && pView == pConstView) + nConstPos = nCount; + + nCount++; + } + pView = SwModule::GetNextView(pView); + } + aDocListBox.InsertEntry(aStatusArr[3]); //"Aktives Fenster" + nCount++; + + if(aContentTree.GetHiddenWrtShell()) + { + String sEntry = aContentTree.GetHiddenWrtShell()->GetView(). + GetDocShell()->GetTitle(); + sEntry += C2S(" ("); + sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST]; + sEntry += ')'; + aDocListBox.InsertEntry(sEntry); + bDisable = sal_False; + } + if(aContentTree.IsActiveView()) + { + //entweder den Namen des akt. Docs oder "Aktives Dokument" + sal_uInt16 nTmp = pActView ? nAct : --nCount; + aDocListBox.SelectEntryPos( nTmp ); + } + else if(aContentTree.IsHiddenView()) + { + aDocListBox.SelectEntryPos(nCount); + } + else + aDocListBox.SelectEntryPos(nConstPos); + + aDocListBox.Enable( !bDisable ); + aDocListBox.SetUpdateMode(sal_True); +} + +/*-----------------16.06.97 15:05------------------- + +--------------------------------------------------*/ + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem) +{ + const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem ); + if( pFrameItem ) + { + SfxViewFrame* pFrame = pFrameItem->GetFrame(); + if(pFrame) + { + aContentTree.Clear(); + pContentView = PTR_CAST(SwView, pFrame->GetViewShell()); + DBG_ASSERT(pContentView, "keine SwView"); + if(pContentView) + pContentWrtShell = pContentView->GetWrtShellPtr(); + else + pContentWrtShell = 0; + pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell()); + FillBox(); + aContentTree.Update(); + } + } + return 0; +} + +String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData ) +{ + String sFileName; + sal_uLong nFmt; + if( rData.HasFormat( nFmt = FORMAT_FILE_LIST )) + { + FileList aFileList; + rData.GetFileList( nFmt, aFileList ); + sFileName = aFileList.GetFile( 0 ); + } + else if( rData.HasFormat( nFmt = FORMAT_STRING ) || + rData.HasFormat( nFmt = FORMAT_FILE ) || + rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME )) + rData.GetString( nFmt, sFileName ); + else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) || + rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| + rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) || + rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || + rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR )) + { + INetBookmark aBkmk( aEmptyStr, aEmptyStr ); + rData.GetINetBookmark( nFmt, aBkmk ); + sFileName = aBkmk.GetURL(); + } + if( sFileName.Len() ) + { + sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE ); + } + return sFileName; +} + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) +{ + return ( !aContentTree.IsInDrag() && + ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) || + aContentTree.IsDropFormatSupported( FORMAT_STRING ) || + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) || + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || + aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME ))) + ? DND_ACTION_COPY + : DND_ACTION_NONE; +} + +sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); + sal_Int8 nRet = DND_ACTION_NONE; + String sFileName; + if( !aContentTree.IsInDrag() && + 0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() ) + { + INetURLObject aTemp( sFileName ); + GraphicDescriptor aDesc( aTemp ); + if( !aDesc.Detect() ) // keine Grafiken annehmen + { + if( STRING_NOTFOUND == sFileName.Search('#') + && (!sContentFileName.Len() || sContentFileName != sFileName )) + { + nRet = rEvt.mnAction; + sFileName.EraseTrailingChars( char(0) ); + sContentFileName = sFileName; + if(pxObjectShell) + { + aContentTree.SetHiddenShell( 0 ); + (*pxObjectShell)->DoClose(); + DELETEZ( pxObjectShell); + } + SfxStringItem aFileItem(SID_FILE_NAME, sFileName ); + String sOptions = C2S("HRC"); + SfxStringItem aOptionsItem( SID_OPTIONS, sOptions ); + SfxLinkItem aLink( SID_DONELINK, + LINK( this, SwNavigationPI, DoneLink ) ); + GetActiveView()->GetViewFrame()->GetDispatcher()->Execute( + SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, + &aFileItem, &aOptionsItem, &aLink, 0L ); + } + } + } + return nRet; +} + +/*-----------------27.11.96 13.00------------------- + +--------------------------------------------------*/ + +void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode) +{ + nRegionMode = nNewMode; + pConfig->SetRegionMode( nRegionMode ); + + sal_uInt16 nDropId = FN_DROP_REGION; + if(nRegionMode == REGION_MODE_LINK) + nDropId = FN_DROP_REGION_LINK; + else if(nRegionMode == REGION_MODE_EMBEDDED) + nDropId = FN_DROP_REGION_COPY; + + ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() + ? aContentImageListH : aContentImageList; + + aContentToolBox.SetItemImage( FN_DROP_REGION, + rImgLst.GetImage(nDropId)); +} + + +/*-----------------12.06.97 09:47------------------- + +--------------------------------------------------*/ + +sal_Bool SwNavigationPI::ToggleTree() +{ + sal_Bool bRet = sal_True; + sal_Bool bGlobalDoc = IsGlobalDoc(); + if(!IsGlobalMode() && bGlobalDoc) + { + SetUpdateMode(sal_False); + if(_IsZoomedIn()) + _ZoomOut(); + aGlobalTree.ShowTree(); + aGlobalToolBox.Show(); + aContentTree.HideTree(); + aContentToolBox.Hide(); + aDocListBox.Hide(); + SetGlobalMode(sal_True); + SetUpdateMode(sal_True); + } + else + { + aGlobalTree.HideTree(); + aGlobalToolBox.Hide(); + if(!_IsZoomedIn()) + { + aContentTree.ShowTree(); + aContentToolBox.Show(); + aDocListBox.Show(); + } + bRet = sal_False; + SetGlobalMode(sal_False); + } + return bRet; +} + +/*-----------------13.06.97 09:42------------------- + +--------------------------------------------------*/ +sal_Bool SwNavigationPI::IsGlobalDoc() const +{ + sal_Bool bRet = sal_False; + SwView *pView = GetCreateView(); + if(pView) + { + SwWrtShell &rSh = pView->GetWrtShell(); + bRet = rSh.IsGlobalDoc(); + } + return bRet; +} +/* -----------------26.10.98 08:10------------------- + * + * --------------------------------------------------*/ +IMPL_LINK( SwNavigationPI, ChangePageHdl, Timer*, EMPTYARG ) +{ + EditAction(&GetPageEdit()); + GetPageEdit().GrabFocus(); + return 0; +} +/* -----------------26.10.98 08:14------------------- + * + * --------------------------------------------------*/ +IMPL_LINK( SwNavigationPI, PageEditModifyHdl, Edit*, EMPTYARG ) +{ + if(aPageChgTimer.IsActive()) + aPageChgTimer.Stop(); + aPageChgTimer.Start(); + return 0; +} + +/* -----------------------------23.04.01 07:34-------------------------------- + + ---------------------------------------------------------------------------*/ +SwView* SwNavigationPI::GetCreateView() const +{ + if(!pCreateView) + { + SwView* pView = SwModule::GetFirstView(); + while(pView) + { + if(&pView->GetViewFrame()->GetBindings() == &rBindings) + { + ((SwNavigationPI*)this)->pCreateView = pView; + ((SwNavigationPI*)this)->StartListening(*pCreateView); + break; + } + pView = SwModule::GetNextView(pView); + } + } + return pCreateView; +} + + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +SwNavigationChild::SwNavigationChild( Window* pParent, + sal_uInt16 nId, + SfxBindings* _pBindings, + SfxChildWinInfo* pInfo ) + : SfxChildWindowContext( nId ) +{ + SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent ); + SetWindow( pNavi ); + _pBindings->Invalidate(SID_NAVIGATOR); + String sExtra = pInfo->aExtraString; + + SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); + + sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() ); + if( nRootType < CONTENT_TYPE_MAX ) + { + pNavi->aContentTree.SetRootType(nRootType); + pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, sal_True); + } + pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); + pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) ); + + if(GetFloatingWindow() && pNaviConfig->IsSmall()) + { + pNavi->_ZoomIn(); + } +} +/* -----------------------------06.05.2002 10:06------------------------------ + + ---------------------------------------------------------------------------*/ +void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + InitImageList(); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aBgColor = rStyleSettings.GetFaceColor(); + Wallpaper aBack( aBgColor ); + SetBackground( aBack ); + } +} +/* -----------------------------06.05.2002 10:07------------------------------ + + ---------------------------------------------------------------------------*/ +void SwNavigationPI::InitImageList() +{ + sal_uInt16 k; + + ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ? + aContentImageListH : aContentImageList; + for( k = 0; k < aContentToolBox.GetItemCount(); k++) + aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k), + rImgLst.GetImage(aContentToolBox.GetItemId(k))); + + for( k = 0; k < aGlobalToolBox.GetItemCount(); k++) + aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k), + rImgLst.GetImage(aGlobalToolBox.GetItemId(k))); + + sal_uInt16 nDropId = FN_DROP_REGION; + if(nRegionMode == REGION_MODE_LINK) + nDropId = FN_DROP_REGION_LINK; + else if(nRegionMode == REGION_MODE_EMBEDDED) + nDropId = FN_DROP_REGION_COPY; + aContentToolBox.SetItemImage( FN_DROP_REGION, + rImgLst.GetImage(nDropId)); +} + diff --git a/sw/source/ui/utlui/navipi.hrc b/sw/source/ui/utlui/navipi.hrc new file mode 100644 index 000000000000..70fd1dc6e14a --- /dev/null +++ b/sw/source/ui/utlui/navipi.hrc @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#define TB_1 1 +#define TB_2 2 +#define TB_3 3 +#define TB_4 4 +#define BT_UP 5 +#define BT_DOWN 6 +#define IL_CONTENT 7 +#define ILH_CONTENT 8 +#define FT_PAGE 10 +#define ED_PAGE 11 +#define LB_SELECT 22 +#define TL_SELECT 23 +#define TB_PAGE_TEXT 41 +#define TB_PAGE_COUNT 42 +#define TB_CONTENT 50 +#define TL_CONTENT 51 +#define LB_DOCS 53 +#define NF_PAGE 54 +#define TL_GLOBAL 55 +#define TB_GLOBAL 56 + +//------------------------------------------------------------------- +// Strings fuer Kontextmenue des ContentTree +#define ST_CONTEXT_FIRST 60 +#define ST_OUTLINE_LEVEL ST_CONTEXT_FIRST +#define ST_DRAGMODE (ST_CONTEXT_FIRST + 1) +#define ST_HYPERLINK (ST_CONTEXT_FIRST + 2) +#define ST_LINK_REGION (ST_CONTEXT_FIRST + 3) +#define ST_COPY_REGION (ST_CONTEXT_FIRST + 4) +#define ST_DISPLAY (ST_CONTEXT_FIRST + 5) +#define ST_ACTIVE_VIEW (ST_CONTEXT_FIRST + 6) +#define ST_STATUS_FIRST 67 +#define ST_HIDDEN (ST_STATUS_FIRST ) +#define ST_ACTIVE (ST_STATUS_FIRST + 1) +#define ST_INACTIVE (ST_STATUS_FIRST + 2) +#define ST_MISC 70 +#define ST_EDIT_ENTRY ST_MISC +#define ST_DELETE_ENTRY (ST_MISC + 1) + +#define ST_GLOBAL_CONTEXT_FIRST (ST_DELETE_ENTRY + 1) +#define ST_UPDATE (ST_GLOBAL_CONTEXT_FIRST ) +#define ST_EDIT_CONTENT (ST_GLOBAL_CONTEXT_FIRST + 1) +#define ST_INSERT (ST_GLOBAL_CONTEXT_FIRST + 2) +#define ST_INDEX (ST_GLOBAL_CONTEXT_FIRST + 3) +#define ST_FILE (ST_GLOBAL_CONTEXT_FIRST + 4) +#define ST_NEW_FILE (ST_GLOBAL_CONTEXT_FIRST + 5) +#define ST_TEXT (ST_GLOBAL_CONTEXT_FIRST + 6) +#define ST_DELETE (ST_GLOBAL_CONTEXT_FIRST + 7) +#define ST_UPDATE_SEL (ST_GLOBAL_CONTEXT_FIRST + 8) +#define ST_UPDATE_INDEX (ST_GLOBAL_CONTEXT_FIRST + 9) +#define ST_UPDATE_LINK (ST_GLOBAL_CONTEXT_FIRST +10) +#define ST_UPDATE_ALL (ST_GLOBAL_CONTEXT_FIRST +11) +#define ST_BROKEN_LINK (ST_GLOBAL_CONTEXT_FIRST +12) +#define ST_EDIT_LINK (ST_GLOBAL_CONTEXT_FIRST +13) + +#define ST_REMOVE_INDEX (ST_GLOBAL_CONTEXT_FIRST +30) +#define ST_REMOVE_TBL_PROTECTION (ST_GLOBAL_CONTEXT_FIRST +31) +#define ST_RENAME (ST_GLOBAL_CONTEXT_FIRST +32) +#define ST_READONLY_IDX (ST_GLOBAL_CONTEXT_FIRST +33) +#define ST_INVISIBLE (ST_GLOBAL_CONTEXT_FIRST +34) + +#define ST_POSTIT_SHOW (ST_GLOBAL_CONTEXT_FIRST +35) +#define ST_POSTIT_HIDE (ST_GLOBAL_CONTEXT_FIRST +36) +#define ST_POSTIT_DELETE (ST_GLOBAL_CONTEXT_FIRST +37) diff --git a/sw/source/ui/utlui/navipi.src b/sw/source/ui/utlui/navipi.src new file mode 100644 index 000000000000..fde6b82f139b --- /dev/null +++ b/sw/source/ui/utlui/navipi.src @@ -0,0 +1,549 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "cmdid.h" +#include "utlui.hrc" +#include "navipi.hrc" +#include "helpid.h" +#include "access.hrc" + +Window DLG_NAVIGATION_PI +{ + HelpID = HID_NAVIGATION_PI ; + OutputSize = TRUE ; + DialogControl = TRUE ; + SVLook = TRUE ; + // Size = MAP_PIXEL( 235, 195 ); + // ZoomInOutputSize = MAP_PIXEL(235, 56); + Size = MAP_PIXEL ( 282 , 59 ) ; + // Closeable = TRUE ; + // Zoomable = TRUE ; + // Moveable = TRUE ; + // ZoomIn = FALSE; + Hide = TRUE ; + // HideWhenDeactivate = TRUE ; + // Sizeable = TRUE ; + // EnableResizing = TRUE ; + // Dockable = TRUE ; + // Sizeable = TRUE ; + Text [ en-US ] = "Navigator" ; + ExtraData = + { + 198; + }; + /************************************************************************************ + Toolbox ab 323 x +************************************************************************************/ +#define NAVI_IDLIST \ + IdList = \ + { \ + FN_UP ; \ + FN_DOWN ; \ + FN_SELECT_HEADER ; \ + FN_SELECT_FOOTER ; \ + FN_SELECT_FOOTNOTE ; \ + FN_SHOW_CONTENT_BOX ; \ + FN_SHOW_ROOT ; \ + FN_ITEM_UP ; \ + FN_ITEM_DOWN ; \ + FN_ITEM_LEFT ; \ + FN_ITEM_RIGHT ; \ + FN_DROP_REGION ; \ + FN_OUTLINE_LEVEL ; \ + FN_SELECT_SET_AUTO_BOOKMARK ; \ + FN_DROP_REGION_LINK ; \ + FN_DROP_REGION_COPY ; \ + FN_GLOBAL_SWITCH ; \ + FN_GLOBAL_EDIT ; \ + FN_GLOBAL_UPDATE ; \ + FN_GLOBAL_OPEN ; \ + FN_GLOBAL_SAVE_CONTENT ; \ + FN_CREATE_NAVIGATION ; \ + }; \ + IdCount = { 21 ; }; + + ImageList IL_CONTENT + { + Prefix = "sc"; + MaskColor = IMAGE_MASK_COLOR ; + NAVI_IDLIST + }; + ImageList ILH_CONTENT + { + Prefix = "sch"; + MaskColor = IMAGE_MASK_COLOR ; + NAVI_IDLIST + }; + Toolbox TB_CONTENT + { + Pos = MAP_PIXEL ( 5 , 5 ) ; + Size = MAP_PIXEL ( 300 , 47 ) ; + LineCount = 2 ; + ItemList = + { + ToolBoxItem + { + Identifier = FN_GLOBAL_SWITCH ; + HelpID = HID_NAVI_TBX17 ; + Text [ en-US ] = "Toggle" ; + }; + ToolBoxItem + { + Identifier = FN_CREATE_NAVIGATION ; + HelpID = HID_NAVI_TBX24 ; + Text [ en-US ] = "Navigation" ; + DropDown = TRUE ; + }; + ToolBoxItem + { + Identifier = FN_UP ; + // ItemBitmap = Bitmap { File = "navup.bmp"; }; + HelpID = HID_NAVI_TBX2 ; + /* ### ACHTUNG: Neuer Text in Resource? Rückwärts : R³ckwõrts */ + Text [ en-US ] = "Back" ; + }; + ToolBoxItem + { + Identifier = FN_DOWN ; + // ItemBitmap = Bitmap { File = "navdn.bmp"; }; + HelpID = HID_NAVI_TBX3 ; + /* ### ACHTUNG: Neuer Text in Resource? Vorwärts : Vorwõrts */ + Text [ en-US ] = "Forward" ; + }; + ToolBoxItem + { + Identifier = FN_DROP_REGION ; + HelpID = HID_NAVI_TBX4 ; + /* ### ACHTUNG: Neuer Text in Resource? Modus für Drag & Drop auswählen : Modus f³r Drag & Drop auswõhlen */ + DropDown = TRUE ; + Text [ en-US ] = "Drag Mode" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_UP ; + // ItemBitmap = Bitmap { File = "navchup.bmp"; }; + HelpID = HID_NAVI_TBX5 ; + Text [ en-US ] = "Promote Chapter" ; + //HelpText[english_us-wrong] = "Move chapter down";//"Move chapter up" + }; + ToolBoxItem + { + Identifier = FN_ITEM_DOWN ; + // ItemBitmap = Bitmap { File = "navchdn.bmp"; }; + HelpID = HID_NAVI_TBX6 ; + Text [ en-US ] = "Demote Chapter" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_BREAK ; + }; + ToolBoxItem + { + Identifier = FN_SHOW_CONTENT_BOX ; + HelpID = HID_NAVI_TBX7 ; + Text [ en-US ] = "List Box On/Off" ; + }; + ToolBoxItem + { + Identifier = FN_SHOW_ROOT ; + HelpID = HID_NAVI_TBX8 ; + Text [ en-US ] = "Content View" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_SET_AUTO_BOOKMARK ; + HelpID = HID_NAVI_TBX9 ; + // ItemBitmap = Bitmap { File = "navstmp.bmp"; }; + Text [ en-US ] = "Set Reminder" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_HEADER ; + // ItemBitmap = Bitmap { File = "navhead.bmp"; }; + HelpID = HID_NAVI_TBX10 ; + Text [ en-US ] = "Header" ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_FOOTER ; + // ItemBitmap = Bitmap { File = "navfoot.bmp"; }; + HelpID = HID_NAVI_TBX11 ; + /* ### ACHTUNG: Neuer Text in Resource? Fußzeile : Fu˜zeile */ + Text [ en-US ] = "Footer" ; + /* ### ACHTUNG: Neuer Text in Resource? Springen zur Fußzeile : Springen zur Fu˜zeile */ + }; + ToolBoxItem + { + Identifier = FN_SELECT_FOOTNOTE ; + // ItemBitmap = Bitmap { File = "navnote.bmp"; }; + HelpID = HID_NAVI_TBX12 ; + Text [ en-US ] = "Anchor<->Text" ; + /* ### ACHTUNG: Neuer Text in Resource? Springen zwischen Fußnotenankern und dem Fußnotentext : Springen zwischen Fu˜notenankern und dem Fu˜notentext */ + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_OUTLINE_LEVEL ; + HelpID = HID_NAVI_TBX13 ; + /* ### ACHTUNG: Neuer Text in Resource? Angezeigte Überschriftenebenen : Angezeigte šberschriftenebenen */ + Text [ en-US ] = "Heading Levels Shown" ; + DropDown = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_LEFT ; + HelpID = HID_NAVI_TBX14 ; + // ItemBitmap = Bitmap { File = "navchlf.bmp"; }; + Text [ en-US ] = "Promote Level" ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_RIGHT ; + // ItemBitmap = Bitmap { File = "navchrg.bmp"; }; + HelpID = HID_NAVI_TBX15 ; + Text [ en-US ] = "Demote Level" ; + }; + }; + }; + ToolBox TB_GLOBAL + { + Pos = MAP_PIXEL ( 5 , 5 ) ; + Size = MAP_PIXEL ( 300 , 47 ) ; + LineCount = 1 ; + Hide = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = FN_GLOBAL_SWITCH ; + HelpID = HID_NAVI_TBX17 ; + Text [ en-US ] = "Toggle" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_GLOBAL_EDIT ; + HelpID = HID_NAVI_TBX18 ; + Text [ en-US ] = "Edit" ; + }; + ToolBoxItem + { + Identifier = FN_GLOBAL_UPDATE ; + HelpID = HID_NAVI_TBX19 ; + Text [ en-US ] = "Update" ; + }; + ToolBoxItem + { + Identifier = FN_GLOBAL_OPEN ; + HelpID = HID_NAVI_TBX20 ; + /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */ + Text [ en-US ] = "Insert" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_GLOBAL_SAVE_CONTENT ; + HelpID = HID_NAVI_TBX21 ; + Text [ en-US ] = "Save Contents as well" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_UP ; + HelpID = HID_NAVI_TBX22 ; + /* ### ACHTUNG: Neuer Text in Resource? Nach oben verschieben : Nach unten verschieben */ + Text [ en-US ] = "Move Up" ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_DOWN ; + HelpID = HID_NAVI_TBX23 ; + /* ### ACHTUNG: Neuer Text in Resource? Nach unten verschieben : Nach oben verschieben */ + Text [ en-US ] = "Move Down" ; + }; + }; + }; + /* TreeListBox */ + Control TL_CONTENT + { + HelpID = HID_NAVI_CONTENT ; + Border = TRUE ; + Pos = MAP_PIXEL ( 5 , 62 ) ; + Size = MAP_PIXEL ( 274 , 112 ) ; + TabStop = TRUE ; + ClipChildren = TRUE ; + Hide = TRUE ; + }; + Control TL_GLOBAL + { + HelpID = HID_NAVI_GLOBAL ; + Border = TRUE ; + Pos = MAP_PIXEL ( 5 , 34 ) ; + Size = MAP_PIXEL ( 274 , 112 ) ; + TabStop = TRUE ; + ClipChildren = TRUE ; + Hide = TRUE ; + }; + ListBox LB_DOCS + { + Border = TRUE ; + Pos = MAP_PIXEL ( 5 , 115 ) ; + Size = MAP_APPFONT ( 150 , 50 ) ; + DropDown = TRUE ; + }; + NumericField NF_PAGE + { + Border = TRUE ; + Pos = MAP_PIXEL ( 50 , 29 ) ; + Size = MAP_PIXEL ( 34 , 20 ) ; + TabStop = TRUE ; + Left = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + First = 1 ; + // Outline als Default + Maximum = 5 ; + Last = 5 ; + Value = 5 ; + }; + String ST_OUTLINE_LEVEL + { + Text [ en-US ] = "Outline Level" ; + }; + String ST_DRAGMODE + { + Text [ en-US ] = "Drag Mode" ; + }; + String ST_HYPERLINK + { + /* ### ACHTUNG: Neuer Text in Resource? Als Hyperlink einfügen : Als Hyperlink einf³gen */ + Text [ en-US ] = "Insert as Hyperlink" ; + }; + String ST_LINK_REGION + { + /* ### ACHTUNG: Neuer Text in Resource? Als Verknüpfung einfügen : Als Verkn³pfung einf³gen */ + Text [ en-US ] = "Insert as Link" ; + }; + String ST_COPY_REGION + { + /* ### ACHTUNG: Neuer Text in Resource? Als Kopie einfügen : Als Kopie einf³gen */ + Text [ en-US ] = "Insert as Copy" ; + }; + String ST_DISPLAY + { + Text [ en-US ] = "Display" ; + }; + String ST_ACTIVE_VIEW + { + Text [ en-US ] = "Active Window" ; + }; + String ST_HIDDEN + { + Text [ en-US ] = "hidden" ; + }; + String ST_ACTIVE + { + Text [ en-US ] = "active" ; + }; + String ST_INACTIVE + { + Text [ en-US ] = "inactive" ; + }; + String ST_EDIT_ENTRY + { + Text [ en-US ] = "Edit..." ; + }; + String ST_UPDATE + { + Text [ en-US ] = "~Update" ; + }; + String ST_EDIT_CONTENT + { + Text [ en-US ] = "Edit" ; + }; + String ST_EDIT_LINK + { + Text [ en-US ] = "Edit link"; + }; + String ST_INSERT + { + /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */ + Text [ en-US ] = "Insert" ; + }; + String ST_INDEX + { + Text [ en-US ] = "~Index"; + }; + String ST_FILE + { + Text [ en-US ] = "File" ; + }; + String ST_NEW_FILE + { + Text [ en-US ] = "New Document" ; + }; + String ST_TEXT + { + Text [ en-US ] = "Text" ; + }; + String ST_DELETE + { + /* ### ACHTUNG: Neuer Text in Resource? Löschen : L÷schen */ + Text [ en-US ] = "Delete" ; + }; + String ST_DELETE_ENTRY + { + Text [ en-US ] = "~Delete" ; + }; + String ST_UPDATE_SEL + { + Text [ en-US ] = "Selection" ; + }; + String ST_UPDATE_INDEX + { + Text [ en-US ] = "Indexes" ; + }; + String ST_UPDATE_LINK + { + /* ### ACHTUNG: Neuer Text in Resource? Verknüpfungen : Verkn³pfungen */ + Text [ en-US ] = "Links" ; + }; + String ST_UPDATE_ALL + { + Text [ en-US ] = "All" ; + }; + String ST_REMOVE_INDEX + { + Text [ en-US ] = "~Remove Index" ; + }; + String ST_REMOVE_TBL_PROTECTION + { + Text [ en-US ] = "~Unprotect" ; + }; + String ST_INVISIBLE + { + Text [ en-US ] = "hidden"; + }; + String ST_BROKEN_LINK + { + Text [ en-US ] = "File not found: "; + }; + String ST_RENAME + { + Text [ en-US ] = "~Rename"; + }; + String ST_READONLY_IDX + { + Text [ en-US ] = "Read-~only"; + }; + String ST_POSTIT_SHOW + { + Text [ en-US ] = "Show All"; + }; + String ST_POSTIT_HIDE + { + Text [ en-US ] = "Hide All"; + }; + String ST_POSTIT_DELETE + { + Text [ en-US ] = "Delete All"; + }; +}; +#define NAVI_ENTRY_IDS \ + IdList = \ + { \ + 20000 ; \ + 20001 ; \ + 20002 ; \ + 20003 ; \ + 20004 ; \ + 20005 ; \ + 20006 ; \ + 20007 ; \ + 20008 ; \ + 20009 ; \ + 20010 ; \ + 20011 ; \ + }; \ + IdCount = { 12 ; }; + + + +ImageList IMG_NAVI_ENTRYBMP +{ + Prefix = "nc"; + MaskColor = IMAGE_MASK_COLOR ; + NAVI_ENTRY_IDS +}; + +ImageList IMG_NAVI_ENTRYBMPH +{ + Prefix = "nch"; + MaskColor = IMAGE_MASK_COLOR ; + NAVI_ENTRY_IDS +}; + +//IAccessibility2 Implementation 2009----- +String STR_ACCESS_TL_GLOBAL +{ + Text [ en-US ] = "Global View"; +}; +String STR_ACCESS_TL_CONTENT +{ + Text [ en-US ] = "Content View"; +}; +//-----IAccessibility2 Implementation 2009 + diff --git a/sw/source/ui/utlui/numfmtlb.cxx b/sw/source/ui/utlui/numfmtlb.cxx new file mode 100644 index 000000000000..03b3d58ec5a7 --- /dev/null +++ b/sw/source/ui/utlui/numfmtlb.cxx @@ -0,0 +1,549 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <hintids.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> +#include <editeng/unolingu.hxx> +#include <unotools/localedatawrapper.hxx> +#include <i18npool/lang.h> +#ifndef _ZFORMAT_HXX //autogen +#define _ZFORLIST_DECLARE_TABLE +#include <svl/zformat.hxx> +#endif +#include <svl/eitem.hxx> +#include <svx/svxids.hrc> +#include <svx/numinf.hxx> +#include <vcl/msgbox.hxx> +#include <svx/flagsdef.hxx> +#include <svl/itemset.hxx> +#include <docsh.hxx> +#include <swtypes.hxx> +#include <swmodule.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <numfmtlb.hxx> +#include <utlui.hrc> +#include "swabstdlg.hxx" +#include "dialog.hrc" +#include <unomid.h> +#include <sfx2/viewfrm.hxx> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; + + +// STATIC DATA ----------------------------------------------------------- + +/*-------------------------------------------------------------------- + Beschreibung: + nFormatType: Formate dieses Typs anzeigen + nDefFmt: Dieses Format selektieren und ggf vorher + einfuegen + --------------------------------------------------------------------*/ + +NumFormatListBox::NumFormatListBox( Window* pWin, const ResId& rResId, + short nFormatType, sal_uLong nDefFmt, + sal_Bool bUsrFmts ) : + ListBox ( pWin, rResId ), + nCurrFormatType (-1), + nStdEntry (0), + bOneArea (sal_False), + nDefFormat (nDefFmt), + pVw (0), + pOwnFormatter (0), + bShowLanguageControl(sal_False), + bUseAutomaticLanguage(sal_True) +{ + Init(nFormatType, bUsrFmts); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +NumFormatListBox::NumFormatListBox( Window* pWin, SwView* pView, + const ResId& rResId, short nFormatType, + sal_uLong nDefFmt, sal_Bool bUsrFmts ) : + ListBox ( pWin, rResId ), + nCurrFormatType (-1), + nStdEntry (0), + bOneArea (sal_False), + nDefFormat (nDefFmt), + pVw (pView), + pOwnFormatter (0), + bShowLanguageControl(sal_False), + bUseAutomaticLanguage(sal_True) +{ + Init(nFormatType, bUsrFmts); +} + +/* -----------------15.06.98 11:29------------------- + * + * --------------------------------------------------*/ + +void NumFormatListBox::Init(short nFormatType, sal_Bool bUsrFmts) +{ + SwView *pView = GetView(); + + if (pView) + eCurLanguage = pView->GetWrtShell().GetCurLang(); + else + eCurLanguage = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); + + if (bUsrFmts == sal_False) + { + Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); + pOwnFormatter = new SvNumberFormatter(xMSF, eCurLanguage); + } + + SetFormatType(nFormatType); + SetDefFormat(nDefFormat); + + SetSelectHdl(LINK(this, NumFormatListBox, SelectHdl)); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +NumFormatListBox::~NumFormatListBox() +{ + if (pOwnFormatter) + delete pOwnFormatter; +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +SwView* NumFormatListBox::GetView() +{ + if( pVw ) + return pVw; + return ::GetActiveView(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void NumFormatListBox::SetFormatType(const short nFormatType) +{ + if (nCurrFormatType == -1 || + (nCurrFormatType & nFormatType) == 0) // Es gibt Mischformate, wie z.B. DateTime + { + SvNumberFormatter* pFormatter; + + if( pOwnFormatter ) + pFormatter = pOwnFormatter; + else + { + SwView *pView = GetView(); + DBG_ASSERT(pView, "no view found"); + if(!pView) + return; + SwWrtShell &rSh = pView->GetWrtShell(); + pFormatter = rSh.GetNumberFormatter(); + } + + Clear(); // Alle Eintraege in der Listbox entfernen + + NfIndexTableOffset eOffsetStart = NF_NUMBER_START; + NfIndexTableOffset eOffsetEnd = NF_NUMBER_START; + + switch( nFormatType ) + { + case NUMBERFORMAT_NUMBER: + eOffsetStart=NF_NUMBER_START; + eOffsetEnd=NF_NUMBER_END; + break; + + case NUMBERFORMAT_PERCENT: + eOffsetStart=NF_PERCENT_START; + eOffsetEnd=NF_PERCENT_END; + break; + + case NUMBERFORMAT_CURRENCY: + eOffsetStart=NF_CURRENCY_START; + eOffsetEnd=NF_CURRENCY_END; + break; + + case NUMBERFORMAT_DATETIME: + eOffsetStart=NF_DATE_START; + eOffsetEnd=NF_TIME_END; + break; + + case NUMBERFORMAT_DATE: + eOffsetStart=NF_DATE_START; + eOffsetEnd=NF_DATE_END; + break; + + case NUMBERFORMAT_TIME: + eOffsetStart=NF_TIME_START; + eOffsetEnd=NF_TIME_END; + break; + + case NUMBERFORMAT_SCIENTIFIC: + eOffsetStart=NF_SCIENTIFIC_START; + eOffsetEnd=NF_SCIENTIFIC_END; + break; + + case NUMBERFORMAT_FRACTION: + eOffsetStart=NF_FRACTION_START; + eOffsetEnd=NF_FRACTION_END; + break; + + case NUMBERFORMAT_LOGICAL: + eOffsetStart=NF_BOOLEAN; + eOffsetEnd=NF_BOOLEAN; + break; + + case NUMBERFORMAT_TEXT: + eOffsetStart=NF_TEXT; + eOffsetEnd=NF_TEXT; + break; + + case NUMBERFORMAT_ALL: + eOffsetStart=NF_NUMERIC_START; + eOffsetEnd = NfIndexTableOffset( NF_INDEX_TABLE_ENTRIES - 1 ); + break; + + default: + DBG_ERROR("what a format?"); + break; + } + + const SvNumberformat* pFmt; + sal_uInt16 nPos, i = 0; + sal_uLong nFormat; + Color* pCol; + double fVal = GetDefValue( nFormatType ); + String sValue; + + sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( + NF_NUMBER_SYSTEM, eCurLanguage ); + sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex( + NF_DATE_SYSTEM_SHORT, eCurLanguage ); + sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex( + NF_DATE_SYSTEM_LONG, eCurLanguage ); + + for( long nIndex = eOffsetStart; nIndex <= eOffsetEnd; ++nIndex ) + { + nFormat = pFormatter->GetFormatIndex( + (NfIndexTableOffset)nIndex, eCurLanguage ); + pFmt = pFormatter->GetEntry( nFormat ); + + if( nFormat == pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, + eCurLanguage ) + || ((SvNumberformat*)pFmt)->GetOutputString( fVal, sValue, &pCol ) + || nFormatType == NUMBERFORMAT_UNDEFINED ) + sValue = pFmt->GetFormatstring(); + else if( nFormatType == NUMBERFORMAT_TEXT ) + { + String sTxt(C2S("\"ABC\"")); + pFormatter->GetOutputString( sTxt, nFormat, sValue, &pCol); + } + + if (nFormat != nSysNumFmt && + nFormat != nSysShortDateFmt && + nFormat != nSysLongDateFmt) + { + nPos = InsertEntry( sValue ); + SetEntryData( nPos, (void*)nFormat ); + + if( nFormat == pFormatter->GetStandardFormat( + nFormatType, eCurLanguage ) ) + nStdEntry = i; + ++i; + } + } + + if (!pOwnFormatter) + { + nPos = InsertEntry(SW_RESSTR( STR_DEFINE_NUMBERFORMAT )); + SetEntryData( nPos, NULL ); + } + + SelectEntryPos( nStdEntry ); + + nCurrFormatType = nFormatType; + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt) +{ + if (nDefFmt == ULONG_MAX) + { + nDefFormat = nDefFmt; + return; + } + + SvNumberFormatter* pFormatter; + if (pOwnFormatter) + pFormatter = pOwnFormatter; + else + { + SwView *pView = GetView(); + DBG_ASSERT(pView, "no view found"); + if(!pView) + return; + SwWrtShell &rSh = pView->GetWrtShell(); + pFormatter = rSh.GetNumberFormatter(); + } + + short nType = pFormatter->GetType(nDefFmt); + + SetFormatType(nType); + + sal_uLong nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefFmt, eCurLanguage); + + for (sal_uInt16 i = 0; i < GetEntryCount(); i++) + { + if (nFormat == (sal_uLong)GetEntryData(i)) + { + SelectEntryPos(i); + nStdEntry = i; + nDefFormat = GetFormat(); + return; + } + } + + // Kein Eintrag gefunden: + double fValue = GetDefValue(nType); + String sValue; + Color* pCol = 0; + + if (nType == NUMBERFORMAT_TEXT) + { + String sTxt(C2S("\"ABC\"")); + pFormatter->GetOutputString(sTxt, nDefFmt, sValue, &pCol); + } + else + pFormatter->GetOutputString(fValue, nDefFmt, sValue, &pCol); + + sal_uInt16 nPos = 0; + while ((sal_uLong)GetEntryData(nPos) == ULONG_MAX) + nPos++; + +// + sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_SYSTEM, eCurLanguage); + sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_SHORT, eCurLanguage); + sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, eCurLanguage); + sal_Bool bSysLang = sal_False; + if( eCurLanguage == GetAppLanguage() ) + bSysLang = sal_True; + sal_uLong nNumFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysNumFmt, LANGUAGE_SYSTEM ); + sal_uLong nShortDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysShortDateFmt, LANGUAGE_SYSTEM ); + sal_uLong nLongDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysLongDateFmt, LANGUAGE_SYSTEM ); + + if ( + nDefFmt == nSysNumFmt || + nDefFmt == nSysShortDateFmt || + nDefFmt == nSysLongDateFmt || + ( + bSysLang && + ( + nDefFmt == nNumFormatForLanguage || + nDefFmt == nShortDateFormatForLanguage || + nDefFmt == nLongDateFormatForLanguage + ) + ) + ) + { + sValue += String(SW_RES(RID_STR_SYSTEM)); + } + + nPos = InsertEntry(sValue, nPos); // Als ersten numerischen Eintrag einfuegen + SetEntryData(nPos, (void*)nDefFmt); + SelectEntryPos(nPos); + nDefFormat = GetFormat(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_uLong NumFormatListBox::GetFormat() const +{ + sal_uInt16 nPos = GetSelectEntryPos(); + + return (sal_uLong)GetEntryData(nPos); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox ) +{ + sal_uInt16 nPos = pBox->GetSelectEntryPos(); + String sDefine(SW_RES( STR_DEFINE_NUMBERFORMAT )); + SwView *pView = GetView(); + + if( pView && nPos == pBox->GetEntryCount() - 1 && + pBox->GetEntry( nPos ) == sDefine ) + { + SwWrtShell &rSh = pView->GetWrtShell(); + SvNumberFormatter* pFormatter = rSh.GetNumberFormatter(); + + SfxItemSet aCoreSet( rSh.GetAttrPool(), + SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, + SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO, + SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, + SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, + SID_ATTR_NUMBERFORMAT_ADD_AUTO, SID_ATTR_NUMBERFORMAT_ADD_AUTO, + 0 ); + + double fValue = GetDefValue( nCurrFormatType); + + sal_uLong nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage); + aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormat )); + + aCoreSet.Put( SvxNumberInfoItem( pFormatter, fValue, + SID_ATTR_NUMBERFORMAT_INFO ) ); + + if( (NUMBERFORMAT_DATE | NUMBERFORMAT_TIME) & nCurrFormatType ) + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, bOneArea)); + + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, !bShowLanguageControl)); + aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, bUseAutomaticLanguage)); + + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aCoreSet, + GetView()->GetViewFrame()->GetFrame().GetFrameInterface(), + RC_DLG_SWNUMFMTDLG ); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + if (RET_OK == pDlg->Execute()) + { + const SfxPoolItem* pItem = pView->GetDocShell()-> + GetItem( SID_ATTR_NUMBERFORMAT_INFO ); + + if( pItem && 0 != ((SvxNumberInfoItem*)pItem)->GetDelCount() ) + { + const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)pItem)->GetDelArray(); + + for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pItem)->GetDelCount(); i++ ) + pFormatter->DeleteEntry( pDelArr[i] ); + } + + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + if( SFX_ITEM_SET == pOutSet->GetItemState( + SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem )) + { + sal_uInt32 nNumberFormat = ((SfxUInt32Item*)pItem)->GetValue(); + // oj #105473# change order of calls + const SvNumberformat* pFmt = pFormatter->GetEntry(nNumberFormat); + if( pFmt ) + eCurLanguage = pFmt->GetLanguage(); + // SetDefFormat uses eCurLanguage to look for if this format already in the list + SetDefFormat(nNumberFormat); + } + if( bShowLanguageControl && SFX_ITEM_SET == pOutSet->GetItemState( + SID_ATTR_NUMBERFORMAT_ADD_AUTO, sal_False, &pItem )) + { + bUseAutomaticLanguage = ((const SfxBoolItem*)pItem)->GetValue(); + } + } + else + SetDefFormat(nFormat); + + delete pDlg; + } + return 0; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +double NumFormatListBox::GetDefValue(const short nFormatType) const +{ + double fDefValue = 0.0; + + switch (nFormatType) + { + case NUMBERFORMAT_DATE: + case NUMBERFORMAT_DATE|NUMBERFORMAT_TIME: + fDefValue = SVX_NUMVAL_DATE; + break; + + case NUMBERFORMAT_TIME: + fDefValue = SVX_NUMVAL_TIME; + break; +/* { + String sValue("31.8.1997 16:57:34"); + sal_uLong nFormat = pFormatter->GetStandardFormat(nFormatType, LANGUAGE_GERMAN); + pFormatter->IsNumberFormat( sValue, nFormat, fDefValue ); + } + break;*/ + + case NUMBERFORMAT_TEXT: + case NUMBERFORMAT_UNDEFINED: + fDefValue = 0; + break; + + case NUMBERFORMAT_CURRENCY: + fDefValue = SVX_NUMVAL_CURRENCY; + break; + + case NUMBERFORMAT_PERCENT: + fDefValue = SVX_NUMVAL_PERCENT; + break; + + case NUMBERFORMAT_LOGICAL: + fDefValue = SVX_NUMVAL_BOOLEAN; + break; + + default: + fDefValue = SVX_NUMVAL_STANDARD; + break; + } + + return fDefValue; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void NumFormatListBox::Clear() +{ + ListBox::Clear(); + nCurrFormatType = -1; +} + diff --git a/sw/source/ui/utlui/poolfmt.src b/sw/source/ui/utlui/poolfmt.src new file mode 100644 index 000000000000..a1d0fcbcfe76 --- /dev/null +++ b/sw/source/ui/utlui/poolfmt.src @@ -0,0 +1,766 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "poolfmt.hrc" + + // ----------------- + // Format-Namen + // ----------------- +String STR_POOLCHR_FOOTNOTE +{ + Text [ en-US ] = "Footnote Characters" ; +}; +String STR_POOLCHR_PAGENO +{ + Text [ en-US ] = "Page Number" ; +}; +String STR_POOLCHR_LABEL +{ + Text [ en-US ] = "Caption Characters" ; +}; +String STR_POOLCHR_DROPCAPS +{ + Text [ en-US ] = "Drop Caps" ; +}; +String STR_POOLCHR_NUM_LEVEL +{ + Text [ en-US ] = "Numbering Symbols" ; +}; +String STR_POOLCHR_BUL_LEVEL +{ + Text [ en-US ] = "Bullets" ; +}; +String STR_POOLCHR_INET_NORMAL +{ + Text [ en-US ] = "Internet Link" ; +}; +String STR_POOLCHR_INET_VISIT +{ + Text [ en-US ] = "Visited Internet Link" ; +}; +String STR_POOLCHR_JUMPEDIT +{ + Text [ en-US ] = "Placeholder" ; +}; +String STR_POOLCHR_TOXJUMP +{ + Text [ en-US ] = "Index Link" ; +}; +String STR_POOLCHR_ENDNOTE +{ + Text [ en-US ] = "Endnote Characters" ; +}; +String STR_POOLPAGE_LANDSCAPE +{ + Text [ en-US ] = "Landscape" ; +}; +String STR_POOLCHR_LINENUM +{ + Text [ en-US ] = "Line numbering" ; +}; +String STR_POOLCHR_IDX_MAIN_ENTRY +{ + Text [ en-US ] = "Main index entry"; +}; +String STR_POOLCHR_FOOTNOTE_ANCHOR +{ + Text [ en-US ] = "Footnote anchor"; +}; +String STR_POOLCHR_ENDNOTE_ANCHOR +{ + Text [ en-US ] = "Endnote anchor"; +}; + + // Zeichenvorlagen fuer HTML +String STR_POOLCHR_HTML_EMPHASIS +{ + Text [ en-US ] = "Emphasis" ; +}; +String STR_POOLCHR_HTML_CITIATION +{ + Text [ en-US ] = "Quotation" ; +}; +String STR_POOLCHR_HTML_STRONG +{ + Text [ en-US ] = "Strong Emphasis" ; +}; +String STR_POOLCHR_HTML_CODE +{ + Text [ en-US ] = "Source Text" ; +}; +String STR_POOLCHR_HTML_SAMPLE +{ + Text [ en-US ] = "Example" ; +}; +String STR_POOLCHR_HTML_KEYBOARD +{ + Text [ en-US ] = "User Entry" ; +}; +String STR_POOLCHR_HTML_VARIABLE +{ + Text [ en-US ] = "Variable" ; +}; +String STR_POOLCHR_HTML_DEFINSTANCE +{ + Text [ en-US ] = "Definition" ; +}; +String STR_POOLCHR_HTML_TELETYPE +{ + Text [ en-US ] = "Teletype" ; +}; + +// Rahmenvorlagen +String STR_POOLFRM_FRAME +{ + Text [ en-US ] = "Frame" ; +}; +String STR_POOLFRM_GRAPHIC +{ + Text [ en-US ] = "Graphics" ; +}; +String STR_POOLFRM_OLE +{ + Text [ en-US ] = "OLE" ; +}; +String STR_POOLFRM_FORMEL +{ + Text [ en-US ] = "Formula" ; +}; +String STR_POOLFRM_MARGINAL +{ + Text [ en-US ] = "Marginalia" ; +}; +String STR_POOLFRM_WATERSIGN +{ + Text [ en-US ] = "Watermark" ; +}; +String STR_POOLFRM_LABEL +{ + Text [ en-US ] = "Labels" ; +}; + // ----------------- + // Vorlagen-Namen + // ----------------- +String STR_POOLCOLL_STANDARD +{ + Text [ en-US ] = "Default" ; +}; +String STR_POOLCOLL_TEXT +{ + Text [ en-US ] = "Text body" ; +}; +String STR_POOLCOLL_TEXT_IDENT +{ + Text [ en-US ] = "First line indent" ; +}; +String STR_POOLCOLL_TEXT_NEGIDENT +{ + Text [ en-US ] = "Hanging indent" ; +}; +String STR_POOLCOLL_TEXT_MOVE +{ + Text [ en-US ] = "Text body indent" ; +}; +String STR_POOLCOLL_GREETING +{ + Text [ en-US ] = "Complimentary close" ; +}; +String STR_POOLCOLL_SIGNATURE +{ + Text [ en-US ] = "Signature" ; +}; +String STR_POOLCOLL_HEADLINE_BASE +{ + Text [ en-US ] = "Heading" ; +}; +String STR_POOLCOLL_NUMBUL_BASE +{ + Text [ en-US ] = "List" ; +}; +String STR_POOLCOLL_REGISTER_BASE +{ + Text [ en-US ] = "Index" ; +}; +String STR_POOLCOLL_CONFRONTATION +{ + Text [ en-US ] = "List Indent" ; +}; +String STR_POOLCOLL_MARGINAL +{ + Text [ en-US ] = "Marginalia" ; +}; +String STR_POOLCOLL_HEADLINE1 +{ + Text [ en-US ] = "Heading 1" ; +}; +String STR_POOLCOLL_HEADLINE2 +{ + Text [ en-US ] = "Heading 2" ; +}; +String STR_POOLCOLL_HEADLINE3 +{ + Text [ en-US ] = "Heading 3" ; +}; +String STR_POOLCOLL_HEADLINE4 +{ + Text [ en-US ] = "Heading 4" ; +}; +String STR_POOLCOLL_HEADLINE5 +{ + Text [ en-US ] = "Heading 5" ; +}; +String STR_POOLCOLL_HEADLINE6 +{ + Text [ en-US ] = "Heading 6" ; +}; +String STR_POOLCOLL_HEADLINE7 +{ + Text [ en-US ] = "Heading 7" ; +}; +String STR_POOLCOLL_HEADLINE8 +{ + Text [ en-US ] = "Heading 8" ; +}; +String STR_POOLCOLL_HEADLINE9 +{ + Text [ en-US ] = "Heading 9" ; +}; +String STR_POOLCOLL_HEADLINE10 +{ + Text [ en-US ] = "Heading 10" ; +}; +String STR_POOLCOLL_NUM_LEVEL1S +{ + Text [ en-US ] = "Numbering 1 Start" ; +}; +String STR_POOLCOLL_NUM_LEVEL1 +{ + Text [ en-US ] = "Numbering 1" ; +}; +String STR_POOLCOLL_NUM_LEVEL1E +{ + Text [ en-US ] = "Numbering 1 End" ; +}; +String STR_POOLCOLL_NUM_NONUM1 +{ + Text [ en-US ] = "Numbering 1 Cont." ; +}; +String STR_POOLCOLL_NUM_LEVEL2S +{ + Text [ en-US ] = "Numbering 2 Start" ; +}; +String STR_POOLCOLL_NUM_LEVEL2 +{ + Text [ en-US ] = "Numbering 2" ; +}; +String STR_POOLCOLL_NUM_LEVEL2E +{ + Text [ en-US ] = "Numbering 2 End" ; +}; +String STR_POOLCOLL_NUM_NONUM2 +{ + Text [ en-US ] = "Numbering 2 Cont." ; +}; +String STR_POOLCOLL_NUM_LEVEL3S +{ + Text [ en-US ] = "Numbering 3 Start" ; +}; +String STR_POOLCOLL_NUM_LEVEL3 +{ + Text [ en-US ] = "Numbering 3" ; +}; +String STR_POOLCOLL_NUM_LEVEL3E +{ + Text [ en-US ] = "Numbering 3 End" ; +}; +String STR_POOLCOLL_NUM_NONUM3 +{ + Text [ en-US ] = "Numbering 3 Cont." ; +}; +String STR_POOLCOLL_NUM_LEVEL4S +{ + Text [ en-US ] = "Numbering 4 Start" ; +}; +String STR_POOLCOLL_NUM_LEVEL4 +{ + Text [ en-US ] = "Numbering 4" ; +}; +String STR_POOLCOLL_NUM_LEVEL4E +{ + Text [ en-US ] = "Numbering 4 End" ; +}; +String STR_POOLCOLL_NUM_NONUM4 +{ + Text [ en-US ] = "Numbering 4 Cont." ; +}; +String STR_POOLCOLL_NUM_LEVEL5S +{ + Text [ en-US ] = "Numbering 5 Start" ; +}; +String STR_POOLCOLL_NUM_LEVEL5 +{ + Text [ en-US ] = "Numbering 5" ; +}; +String STR_POOLCOLL_NUM_LEVEL5E +{ + Text [ en-US ] = "Numbering 5 End" ; +}; +String STR_POOLCOLL_NUM_NONUM5 +{ + Text [ en-US ] = "Numbering 5 Cont." ; +}; +String STR_POOLCOLL_BUL_LEVEL1S +{ + Text [ en-US ] = "List 1 Start" ; +}; +String STR_POOLCOLL_BUL_LEVEL1 +{ + Text [ en-US ] = "List 1" ; +}; +String STR_POOLCOLL_BUL_LEVEL1E +{ + Text [ en-US ] = "List 1 End" ; +}; +String STR_POOLCOLL_BUL_NONUM1 +{ + Text [ en-US ] = "List 1 Cont." ; +}; +String STR_POOLCOLL_BUL_LEVEL2S +{ + Text [ en-US ] = "List 2 Start" ; +}; +String STR_POOLCOLL_BUL_LEVEL2 +{ + Text [ en-US ] = "List 2" ; +}; +String STR_POOLCOLL_BUL_LEVEL2E +{ + Text [ en-US ] = "List 2 End" ; +}; +String STR_POOLCOLL_BUL_NONUM2 +{ + Text [ en-US ] = "List 2 Cont." ; +}; +String STR_POOLCOLL_BUL_LEVEL3S +{ + Text [ en-US ] = "List 3 Start" ; +}; +String STR_POOLCOLL_BUL_LEVEL3 +{ + Text [ en-US ] = "List 3" ; +}; +String STR_POOLCOLL_BUL_LEVEL3E +{ + Text [ en-US ] = "List 3 End" ; +}; +String STR_POOLCOLL_BUL_NONUM3 +{ + Text [ en-US ] = "List 3 Cont." ; +}; +String STR_POOLCOLL_BUL_LEVEL4S +{ + Text [ en-US ] = "List 4 Start" ; +}; +String STR_POOLCOLL_BUL_LEVEL4 +{ + Text [ en-US ] = "List 4" ; +}; +String STR_POOLCOLL_BUL_LEVEL4E +{ + Text [ en-US ] = "List 4 End" ; +}; +String STR_POOLCOLL_BUL_NONUM4 +{ + Text [ en-US ] = "List 4 Cont." ; +}; +String STR_POOLCOLL_BUL_LEVEL5S +{ + Text [ en-US ] = "List 5 Start" ; +}; +String STR_POOLCOLL_BUL_LEVEL5 +{ + Text [ en-US ] = "List 5" ; +}; +String STR_POOLCOLL_BUL_LEVEL5E +{ + Text [ en-US ] = "List 5 End" ; +}; +String STR_POOLCOLL_BUL_NONUM5 +{ + Text [ en-US ] = "List 5 Cont." ; +}; +String STR_POOLCOLL_HEADER +{ + Text [ en-US ] = "Header" ; +}; +String STR_POOLCOLL_HEADERL +{ + Text [ en-US ] = "Header left" ; +}; +String STR_POOLCOLL_HEADERR +{ + Text [ en-US ] = "Header right" ; +}; +String STR_POOLCOLL_FOOTER +{ + Text [ en-US ] = "Footer" ; +}; +String STR_POOLCOLL_FOOTERL +{ + Text [ en-US ] = "Footer left" ; +}; +String STR_POOLCOLL_FOOTERR +{ + Text [ en-US ] = "Footer right" ; +}; +String STR_POOLCOLL_TABLE +{ + Text [ en-US ] = "Table Contents" ; +}; +String STR_POOLCOLL_TABLE_HDLN +{ + Text [ en-US ] = "Table Heading" ; +}; +String STR_POOLCOLL_FRAME +{ + Text [ en-US ] = "Frame contents" ; +}; +String STR_POOLCOLL_FOOTNOTE +{ + Text [ en-US ] = "Footnote" ; +}; +String STR_POOLCOLL_ENDNOTE +{ + Text [ en-US ] = "Endnote" ; +}; +String STR_POOLCOLL_LABEL +{ + Text [ en-US ] = "Caption" ; +}; +String STR_POOLCOLL_LABEL_ABB +{ + Text [ en-US ] = "Illustration" ; +}; +String STR_POOLCOLL_LABEL_TABLE +{ + Text [ en-US ] = "Table" ; +}; +String STR_POOLCOLL_LABEL_FRAME +{ + Text [ en-US ] = "Text" ; +}; +String STR_POOLCOLL_LABEL_DRAWING +{ + Text [ en-US ] = "Drawing"; +}; +String STR_POOLCOLL_JAKETADRESS +{ + Text [ en-US ] = "Addressee" ; +}; +String STR_POOLCOLL_SENDADRESS +{ + Text [ en-US ] = "Sender" ; +}; +String STR_POOLCOLL_TOX_IDXH +{ + Text [ en-US ] = "Index Heading" ; +}; +String STR_POOLCOLL_TOX_IDX1 +{ + Text [ en-US ] = "Index 1" ; +}; +String STR_POOLCOLL_TOX_IDX2 +{ + Text [ en-US ] = "Index 2" ; +}; +String STR_POOLCOLL_TOX_IDX3 +{ + Text [ en-US ] = "Index 3" ; +}; +String STR_POOLCOLL_TOX_IDXBREAK +{ + Text [ en-US ] = "Index Separator" ; +}; +String STR_POOLCOLL_TOX_CNTNTH +{ + Text [ en-US ] = "Contents Heading" ; +}; +String STR_POOLCOLL_TOX_CNTNT1 +{ + Text [ en-US ] = "Contents 1" ; +}; +String STR_POOLCOLL_TOX_CNTNT2 +{ + Text [ en-US ] = "Contents 2" ; +}; +String STR_POOLCOLL_TOX_CNTNT3 +{ + Text [ en-US ] = "Contents 3" ; +}; +String STR_POOLCOLL_TOX_CNTNT4 +{ + Text [ en-US ] = "Contents 4" ; +}; +String STR_POOLCOLL_TOX_CNTNT5 +{ + Text [ en-US ] = "Contents 5" ; +}; +String STR_POOLCOLL_TOX_CNTNT6 +{ + Text [ en-US ] = "Contents 6" ; +}; +String STR_POOLCOLL_TOX_CNTNT7 +{ + Text [ en-US ] = "Contents 7" ; +}; +String STR_POOLCOLL_TOX_CNTNT8 +{ + Text [ en-US ] = "Contents 8" ; +}; +String STR_POOLCOLL_TOX_CNTNT9 +{ + Text [ en-US ] = "Contents 9" ; +}; +String STR_POOLCOLL_TOX_CNTNT10 +{ + Text [ en-US ] = "Contents 10" ; +}; +String STR_POOLCOLL_TOX_USERH +{ + Text [ en-US ] = "User Index Heading" ; +}; +String STR_POOLCOLL_TOX_USER1 +{ + Text [ en-US ] = "User Index 1" ; +}; +String STR_POOLCOLL_TOX_USER2 +{ + Text [ en-US ] = "User Index 2" ; +}; +String STR_POOLCOLL_TOX_USER3 +{ + Text [ en-US ] = "User Index 3" ; +}; +String STR_POOLCOLL_TOX_USER4 +{ + Text [ en-US ] = "User Index 4" ; +}; +String STR_POOLCOLL_TOX_USER5 +{ + Text [ en-US ] = "User Index 5" ; +}; +String STR_POOLCOLL_TOX_USER6 +{ + Text [ en-US ] = "User Index 6" ; +}; +String STR_POOLCOLL_TOX_USER7 +{ + Text [ en-US ] = "User Index 7" ; +}; +String STR_POOLCOLL_TOX_USER8 +{ + Text [ en-US ] = "User Index 8" ; +}; +String STR_POOLCOLL_TOX_USER9 +{ + Text [ en-US ] = "User Index 9" ; +}; +String STR_POOLCOLL_TOX_USER10 +{ + Text [ en-US ] = "User Index 10" ; +}; +String STR_POOLCOLL_TOX_ILLUSH +{ + Text [ en-US ] = "Illustration Index Heading"; +}; +String STR_POOLCOLL_TOX_ILLUS1 +{ + Text [ en-US ] = "Illustration Index 1"; +}; +String STR_POOLCOLL_TOX_OBJECTH +{ + Text [ en-US ] = "Object index heading"; +}; +String STR_POOLCOLL_TOX_OBJECT1 +{ + Text [ en-US ] = "Object index 1"; +}; +String STR_POOLCOLL_TOX_TABLESH +{ + Text [ en-US ] = "Table index heading"; +}; +String STR_POOLCOLL_TOX_TABLES1 +{ + Text [ en-US ] = "Table index 1"; +}; +String STR_POOLCOLL_TOX_AUTHORITIESH +{ + Text [ en-US ] = "Bibliography Heading"; +}; +String STR_POOLCOLL_TOX_AUTHORITIES1 +{ + Text [ en-US ] = "Bibliography 1"; +}; + +String STR_POOLCOLL_DOC_TITEL +{ + Text [ en-US ] = "Title" ; +}; +String STR_POOLCOLL_DOC_SUBTITEL +{ + Text [ en-US ] = "Subtitle" ; +}; +String STR_POOLCOLL_HTML_BLOCKQUOTE +{ + Text [ en-US ] = "Quotations" ; +}; +String STR_POOLCOLL_HTML_PRE +{ + Text [ en-US ] = "Preformatted Text" ; +}; +String STR_POOLCOLL_HTML_HR +{ + Text [ en-US ] = "Horizontal Line" ; +}; +String STR_POOLCOLL_HTML_DD +{ + Text [ en-US ] = "List Contents" ; +}; +String STR_POOLCOLL_HTML_DT +{ + Text [ en-US ] = "List Heading" ; +}; +//page style names +String STR_POOLPAGE_STANDARD +{ + Text [ en-US ] = "Default" ; +}; +String STR_POOLPAGE_FIRST +{ + Text [ en-US ] = "First Page" ; +}; +String STR_POOLPAGE_LEFT +{ + Text [ en-US ] = "Left Page" ; +}; +String STR_POOLPAGE_RIGHT +{ + Text [ en-US ] = "Right Page" ; +}; +String STR_POOLPAGE_JAKET +{ + Text [ en-US ] = "Envelope" ; +}; +String STR_POOLPAGE_REGISTER +{ + Text [ en-US ] = "Index" ; +}; +String STR_POOLPAGE_HTML +{ + Text [ en-US ] = "HTML" ; +}; +String STR_POOLPAGE_FOOTNOTE +{ + Text [ en-US ] = "Footnote" ; +}; +String STR_POOLPAGE_ENDNOTE +{ + Text [ en-US ] = "Endnote" ; +}; +/* + Numerierungs Regeln +*/ +String STR_POOLNUMRULE_NUM1 +{ + Text [ en-US ] = "Numbering 1" ; +}; +String STR_POOLNUMRULE_NUM2 +{ + Text [ en-US ] = "Numbering 2" ; +}; +String STR_POOLNUMRULE_NUM3 +{ + Text [ en-US ] = "Numbering 3" ; +}; +String STR_POOLNUMRULE_NUM4 +{ + Text [ en-US ] = "Numbering 4" ; +}; +String STR_POOLNUMRULE_NUM5 +{ + Text [ en-US ] = "Numbering 5" ; +}; +String STR_POOLNUMRULE_BUL1 +{ + Text [ en-US ] = "List 1" ; +}; +String STR_POOLNUMRULE_BUL2 +{ + Text [ en-US ] = "List 2" ; +}; +String STR_POOLNUMRULE_BUL3 +{ + Text [ en-US ] = "List 3" ; +}; +String STR_POOLNUMRULE_BUL4 +{ + Text [ en-US ] = "List 4" ; +}; +String STR_POOLNUMRULE_BUL5 +{ + Text [ en-US ] = "List 5" ; +}; + +String STR_POOLCHR_RUBYTEXT +{ + Text [ en-US ] = "Rubies"; +}; +//IAccessibility2 Implementation 2009----- +String STR_COLUMN_VALUESET_ITEM0 +{ + Text [ en-US ] = "1 column"; +}; +String STR_COLUMN_VALUESET_ITEM1 +{ + Text [ en-US ] = "2 columns with equal size"; +}; +String STR_COLUMN_VALUESET_ITEM2 +{ + Text [ en-US ] = "3 columns with equal size"; +}; +String STR_COLUMN_VALUESET_ITEM3 +{ + Text [ en-US ] = "2 columns with different size (left > right)"; +}; +String STR_COLUMN_VALUESET_ITEM4 +{ + Text [ en-US ] = "2 columns with different size (left < right)"; +}; +//-----IAccessibility2 Implementation 2009 +String STR_POOLCHR_VERT_NUM +{ + Text [ en-US ] = "Vertical Numbering Symbols"; +}; diff --git a/sw/source/ui/utlui/prcntfld.cxx b/sw/source/ui/utlui/prcntfld.cxx new file mode 100644 index 000000000000..f439c1fe1139 --- /dev/null +++ b/sw/source/ui/utlui/prcntfld.cxx @@ -0,0 +1,370 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +// include --------------------------------------------------------------- + + +#include "prcntfld.hxx" + +// STATIC DATA ----------------------------------------------------------- + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +PercentField::PercentField( Window* pWin, const ResId& rResId ) : + MetricField ( pWin, rResId ), + + nOldMax (0), + nOldMin (0), + nLastPercent(-1), + nLastValue (-1), + eOldUnit (FUNIT_NONE), + bLockAutoCalculation(sal_False) +{ + + nOldSpinSize = GetSpinSize(); + nRefValue = DenormalizePercent(MetricField::GetMax(FUNIT_TWIP)); + nOldDigits = GetDecimalDigits(); + SetCustomUnitText('%'); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::SetRefValue(sal_Int64 nValue) +{ + sal_Int64 nRealValue = GetRealValue(eOldUnit); + + nRefValue = nValue; + + if (!bLockAutoCalculation && (GetUnit() == FUNIT_CUSTOM)) + SetPrcntValue(nRealValue, eOldUnit); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::ShowPercent(sal_Bool bPercent) +{ + if ((bPercent && GetUnit() == FUNIT_CUSTOM) || + (!bPercent && GetUnit() != FUNIT_CUSTOM)) + return; + + sal_Int64 nOldValue; + + if (bPercent) + { + sal_Int64 nAktWidth, nPercent; + + nOldValue = GetValue(); + + eOldUnit = GetUnit(); + nOldDigits = GetDecimalDigits(); + nOldMin = GetMin(); + nOldMax = GetMax(); + nOldSpinSize = GetSpinSize(); + nOldBaseValue = GetBaseValue(); + SetUnit(FUNIT_CUSTOM); + SetDecimalDigits( 0 ); + + nAktWidth = ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + // Um 0.5 Prozent aufrunden + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + + MetricField::SetMin(Max(static_cast< sal_Int64 >(1), nPercent)); + MetricField::SetMax(100); + SetSpinSize(5); + MetricField::SetBaseValue(0); + if (nOldValue != nLastValue) + { + nAktWidth = ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + MetricFormatter::SetValue(nPercent); + nLastPercent = nPercent; + nLastValue = nOldValue; + } + else + MetricFormatter::SetValue(nLastPercent); +// SetValue(100, FUNIT_CUSTOM); + } + else + { + sal_Int64 nOldPercent = GetValue(FUNIT_CUSTOM); + + nOldValue = Convert(GetValue(), GetUnit(), eOldUnit); + + SetUnit(eOldUnit); + SetDecimalDigits(nOldDigits); + MetricField::SetMin(nOldMin); + MetricField::SetMax(nOldMax); + SetSpinSize(nOldSpinSize); + MetricField::SetBaseValue(nOldBaseValue); + + if (nOldPercent != nLastPercent) + { + SetPrcntValue(nOldValue, eOldUnit); + nLastPercent = nOldPercent; + nLastValue = nOldValue; + } + else + SetPrcntValue(nLastValue, eOldUnit); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void PercentField::SetValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + MetricFormatter::SetValue(nNewValue, eInUnit); +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void PercentField::SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + if (GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM) + MetricFormatter::SetValue(Convert(nNewValue, eInUnit, GetUnit())); + + else + { + // Ausgangswert ueberschreiben, nicht spaeter restaurieren + sal_Int64 nPercent, nAktWidth; + if(eInUnit == FUNIT_TWIP) + { + nAktWidth = ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP); + } + else + { + sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit); + nAktWidth = ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + } + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + MetricFormatter::SetValue(nPercent); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit ) +{ + if (GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM) + MetricField::SetUserValue(Convert(nNewValue, eInUnit, GetUnit()),FUNIT_NONE); + + else + { + // Ausgangswert ueberschreiben, nicht spaeter restaurieren + sal_Int64 nPercent, nAktWidth; + if(eInUnit == FUNIT_TWIP) + { + nAktWidth = ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP); + } + else + { + sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit); + nAktWidth = ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + } + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + MetricField::SetUserValue(nPercent,FUNIT_NONE); + } + +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + if (GetUnit() == FUNIT_CUSTOM) + nOldBaseValue = ConvertValue(nNewValue, 0, nOldDigits, eInUnit, eOldUnit); + else + MetricField::SetBaseValue(nNewValue, eInUnit); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::GetValue( FieldUnit eOutUnit ) +{ + return Convert(MetricField::GetValue(), GetUnit(), eOutUnit); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::SetMin(sal_Int64 nNewMin, FieldUnit eInUnit) +{ + if (GetUnit() != FUNIT_CUSTOM) + MetricField::SetMin(nNewMin, eInUnit); + else + { + if (eInUnit == FUNIT_NONE) + eInUnit = eOldUnit; + nOldMin = Convert(nNewMin, eInUnit, eOldUnit); + + sal_Int64 nPercent = Convert(nNewMin, eInUnit, FUNIT_CUSTOM); + MetricField::SetMin(Max( static_cast< sal_Int64 >(1), nPercent)); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void PercentField::SetMax(sal_Int64 nNewMax, FieldUnit eInUnit) +{ + if (GetUnit() != FUNIT_CUSTOM) + MetricField::SetMax(nNewMax, eInUnit); + else + { + if (eInUnit == FUNIT_NONE) + eInUnit = eOldUnit; +// SetRefValue(Convert(nNewMax, eInUnit, FUNIT_TWIP)); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::NormalizePercent(sal_Int64 nValue) +{ + if (GetUnit() != FUNIT_CUSTOM) + nValue = MetricField::Normalize(nValue); + else + nValue = nValue * ImpPower10(nOldDigits); + + return nValue; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::DenormalizePercent(sal_Int64 nValue) +{ + if (GetUnit() != FUNIT_CUSTOM) + nValue = MetricField::Denormalize(nValue); + else + { + sal_Int64 nFactor = ImpPower10(nOldDigits); + nValue = ((nValue+(nFactor/2)) / nFactor); + } + + return nValue; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Bool PercentField::IsValueModified() +{ + if (GetUnit() == FUNIT_CUSTOM) + return sal_True; + else + return MetricField::IsValueModified(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::ImpPower10( sal_uInt16 n ) +{ + sal_uInt16 i; + sal_Int64 nValue = 1; + + for ( i=0; i < n; i++ ) + nValue *= 10; + + return nValue; +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::GetRealValue(FieldUnit eOutUnit) +{ + if (GetUnit() != FUNIT_CUSTOM) + return GetValue(eOutUnit); + else + return Convert(GetValue(), GetUnit(), eOutUnit); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) +{ + if (eInUnit == eOutUnit || + (eInUnit == FUNIT_NONE && eOutUnit == GetUnit()) || + (eOutUnit == FUNIT_NONE && eInUnit == GetUnit())) + return nValue; + + if (eInUnit == FUNIT_CUSTOM) + { + // Umrechnen in Metrik + sal_Int64 nTwipValue = (nRefValue * nValue + 50) / 100; + + if (eOutUnit == FUNIT_TWIP) // Nur wandeln, wenn unbedingt notwendig + return NormalizePercent(nTwipValue); + else + return ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FUNIT_TWIP, eOutUnit); + } + + if (eOutUnit == FUNIT_CUSTOM) + { + // Umrechnen in Prozent + sal_Int64 nAktWidth; + nValue = DenormalizePercent(nValue); + + if (eInUnit == FUNIT_TWIP) // Nur wandeln, wenn unbedingt notwendig + nAktWidth = nValue; + else + nAktWidth = ConvertValue(nValue, 0, nOldDigits, eInUnit, FUNIT_TWIP); + // Um 0.5 Prozent runden + return ((nAktWidth * 1000) / nRefValue + 5) / 10; + } + + return ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit); +} + + diff --git a/sw/source/ui/utlui/shdwcrsr.cxx b/sw/source/ui/utlui/shdwcrsr.cxx new file mode 100644 index 000000000000..58acbd39d8ec --- /dev/null +++ b/sw/source/ui/utlui/shdwcrsr.cxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <com/sun/star/text/HoriOrientation.hpp> +#include <vcl/window.hxx> + +#include "swtypes.hxx" +#include "shdwcrsr.hxx" + +using namespace ::com::sun::star; + + +SwShadowCursor::~SwShadowCursor() +{ + if( USHRT_MAX != nOldMode ) + DrawCrsr( aOldPt, nOldHeight, nOldMode ); +} + +void SwShadowCursor::SetPos( const Point& rPt, long nHeight, sal_uInt16 nMode ) +{ + Point aPt( pWin->LogicToPixel( rPt )); + nHeight = pWin->LogicToPixel( Size( 0, nHeight )).Height(); + if( aOldPt != aPt || nOldHeight != nHeight || nOldMode != nMode ) + { + if( USHRT_MAX != nOldMode ) + DrawCrsr( aOldPt, nOldHeight, nOldMode ); + + DrawCrsr( aPt, nHeight, nMode ); + nOldMode = nMode; + nOldHeight = nHeight; + aOldPt = aPt; + } +} + +void SwShadowCursor::DrawTri( const Point& rPt, long nHeight, sal_Bool bLeft ) +{ + long nLineDiff = ( nHeight / 2 ); + long nLineDiffHalf = nLineDiff / 2; + + // Punkt oben + Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3), + rPt.Y() + nLineDiffHalf ); + // Punkt unten + Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 ); + long nDiff = bLeft ? -1 : 1; + while( aPt1.Y() <= aPt2.Y() ) + { + pWin->DrawLine( aPt1, aPt2 ); + aPt1.Y()++, aPt2.Y()--; + aPt2.X() = aPt1.X() += nDiff; + } +} + +void SwShadowCursor::DrawCrsr( const Point& rPt, long nHeight, sal_uInt16 nMode ) +{ + nHeight = (((nHeight / 4)+1) * 4) + 1; + + pWin->Push(); + + pWin->SetMapMode( MAP_PIXEL ); + pWin->SetRasterOp( ROP_XOR ); + + pWin->SetLineColor( Color( aCol.GetColor() ^ COL_WHITE ) ); + + // 1. der Strich: + pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1), + Point( rPt.X(), rPt.Y() - 2 + nHeight )); + + // 2. das Dreieck + if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Pfeil nach rechts + DrawTri( rPt, nHeight, sal_False ); + if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Pfeil nach links + DrawTri( rPt, nHeight, sal_True ); + + pWin->Pop(); +} + +void SwShadowCursor::Paint() +{ + if( USHRT_MAX != nOldMode ) + DrawCrsr( aOldPt, nOldHeight, nOldMode ); +} + +Rectangle SwShadowCursor::GetRect() const +{ + long nH = nOldHeight; + Point aPt( aOldPt ); + + nH = (((nH / 4)+1) * 4) + 1; + long nWidth = nH / 4 + 3 + 1; + + Size aSz( nWidth, nH ); + + if( text::HoriOrientation::RIGHT == nOldMode ) + aPt.X() -= aSz.Width(); + else if( text::HoriOrientation::CENTER == nOldMode ) + { + aPt.X() -= aSz.Width(); + aSz.Width() *= 2; + } + + return pWin->PixelToLogic( Rectangle( aPt, aSz ) ); +} + + + + diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx new file mode 100644 index 000000000000..94363dfbbbcf --- /dev/null +++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx @@ -0,0 +1,143 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" +#ifdef SW_DLLIMPLEMENTATION +#undef SW_DLLIMPLEMENTATION +#endif + + +#include <swtypes.hxx> +#include <globals.hrc> +#include <misc.hrc> + +#include <utlui.hrc> +#include <unotools.hrc> +#include <unoprnms.hxx> +#include <tools/debug.hxx> +#include <vcl/msgbox.hxx> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/view/XScreenCursor.hpp> +#include <com/sun/star/view/DocumentZoomType.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <comphelper/processfactory.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/stritem.hxx> +#include <shellio.hxx> +#include <docsh.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <swmodule.hxx> +#include <unocrsr.hxx> + +#include "swrenamexnameddlg.hxx" + + +using namespace ::com::sun::star; +using ::rtl::OUString; + +SwRenameXNamedDlg::SwRenameXNamedDlg( Window* pWin, + uno::Reference< container::XNamed > & xN, + uno::Reference< container::XNameAccess > & xNA ) : + ModalDialog(pWin, SW_RES(DLG_RENAME_XNAMED)), + aNameFL(this, SW_RES(FL_NAME)), + aNewNameFT(this, SW_RES(FT_NEW_NAME)), + aNewNameED(this, SW_RES(ED_NEW_NAME)), + aOk(this, SW_RES(PB_OK)), + aCancel(this, SW_RES(PB_CANCEL)), + aHelp(this, SW_RES(PB_HELP)), + xNamed(xN), + xNameAccess(xNA) +{ + FreeResource(); + sRemoveWarning = String(SW_RES(STR_REMOVE_WARNING)); + + String sTmp(GetText()); + aNewNameED.SetText(xNamed->getName()); + aNewNameED.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX)); + sTmp += String(xNamed->getName()); + SetText(sTmp); + + aOk.SetClickHdl(LINK(this, SwRenameXNamedDlg, OkHdl)); + aNewNameED.SetModifyHdl(LINK(this, SwRenameXNamedDlg, ModifyHdl)); + aOk.Enable(sal_False); +} +/* -----------------09.06.99 15:34------------------- + * + * --------------------------------------------------*/ +IMPL_LINK(SwRenameXNamedDlg, OkHdl, OKButton*, EMPTYARG) +{ + try + { + xNamed->setName(aNewNameED.GetText()); + } + catch(uno::RuntimeException&) + { + DBG_ERROR("Name wurde nicht geaendert"); + } + EndDialog(RET_OK); + return 0; +} +/* -----------------09.06.99 15:48------------------- + * + * --------------------------------------------------*/ +IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, NoSpaceEdit*, pEdit) +{ + String sTmp(pEdit->GetText()); + + // prevent from pasting illegal characters + sal_uInt16 nLen = sTmp.Len(); + String sMsg; + for(sal_uInt16 i = 0; i < pEdit->GetForbiddenChars().Len(); i++) + { + sal_uInt16 nTmpLen = sTmp.Len(); + sTmp.EraseAllChars(pEdit->GetForbiddenChars().GetChar(i)); + if(sTmp.Len() != nTmpLen) + sMsg += pEdit->GetForbiddenChars().GetChar(i); + } + if(sTmp.Len() != nLen) + { + pEdit->SetText(sTmp); + String sWarning(sRemoveWarning); + sWarning += sMsg; + InfoBox(this, sWarning).Execute(); + } + + aOk.Enable(sTmp.Len() && !xNameAccess->hasByName(sTmp) + && (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp)) + && (!xThirdAccess.is() || !xThirdAccess->hasByName(sTmp)) + ); + return 0; +} diff --git a/sw/source/ui/utlui/textcontrolcombo.cxx b/sw/source/ui/utlui/textcontrolcombo.cxx new file mode 100644 index 000000000000..629d527ca872 --- /dev/null +++ b/sw/source/ui/utlui/textcontrolcombo.cxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include "textcontrolcombo.hxx" + + +TextControlCombo::TextControlCombo( Window* _pParent, const ResId& _rResId, + Control& _rCtrl, FixedText& _rFTbefore, FixedText& _rFTafter ) + :Window ( _pParent, _rResId ) + ,mrCtrl ( _rCtrl ) + ,mrFTbefore ( _rFTbefore ) + ,mrFTafter ( _rFTafter ) +{ +} + +TextControlCombo::~TextControlCombo() +{ +} + +void TextControlCombo::Arrange( FixedText& _rFTcomplete, sal_Bool /*bShow*/ ) +{ + Point aBasePos( GetPosPixel() ); + Size aMetricVals( GetSizePixel() ); + + long nTextHeight = _rFTcomplete.GetSizePixel().Height(); + long nCtrlHeight = mrCtrl.GetSizePixel().Height(); + + // calc y positions / center vertical + long nYFT = aBasePos.Y(); + long nYCtrl = nYFT; + if( nCtrlHeight > nTextHeight ) + nYFT += aMetricVals.Height(); + else + nYCtrl += aMetricVals.Height(); + + // separate text parts + const String aReplStr( RTL_CONSTASCII_STRINGPARAM( "%POSITION_OF_CONTROL" ) ); + String aTxtBefore( _rFTcomplete.GetText() ); + String aTxtAfter; + xub_StrLen nReplPos = aTxtBefore.Search( aReplStr ); + if( nReplPos != STRING_NOTFOUND ) + { + xub_StrLen nStrStartAfter = nReplPos + aReplStr.Len(); + aTxtAfter = String( aTxtBefore, nStrStartAfter, aTxtBefore.Len() - nStrStartAfter ); + aTxtBefore.Erase( nReplPos ); + } + + // arrange and fill Fixed Texts + long nX = aBasePos.X(); + long nWidth = GetTextWidth( aTxtBefore ); + + mrFTbefore.SetText( aTxtBefore ); + mrFTbefore.SetPosSizePixel( nX, nYFT, nWidth, nTextHeight ); + + nX += nWidth; + nX += aMetricVals.Width(); + mrCtrl.SetPosPixel( Point( nX, nYCtrl ) ); + + nX += mrCtrl.GetSizePixel().Width(); + nX += aMetricVals.Width(); + mrFTafter.SetText( aTxtAfter ); + mrFTafter.SetPosSizePixel( nX, nYFT, GetTextWidth( aTxtAfter ), nTextHeight ); + + _rFTcomplete.Hide(); + + Show(); + + Window::Hide(); +} + +void TextControlCombo::Show( sal_Bool _bVisible, sal_uInt16 _nFlags ) +{ + mrCtrl.Show( _bVisible, _nFlags ); + mrFTbefore.Show( _bVisible, _nFlags ); + mrFTafter.Show( _bVisible, _nFlags ); +} + +void TextControlCombo::Enable( sal_Bool _bEnable, sal_Bool _bChild ) +{ + mrCtrl.Enable( _bEnable, _bChild ); + mrFTbefore.Enable( _bEnable, _bChild ); + mrFTafter.Enable( _bEnable, _bChild ); +} + + diff --git a/sw/source/ui/utlui/tmplctrl.cxx b/sw/source/ui/utlui/tmplctrl.cxx new file mode 100644 index 000000000000..bcae8fa9cd24 --- /dev/null +++ b/sw/source/ui/utlui/tmplctrl.cxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +// include --------------------------------------------------------------- + + +#include <svl/style.hxx> +#ifndef _MENU_HXX //autogen +#include <vcl/menu.hxx> +#endif +#include <svl/stritem.hxx> +#include <sfx2/dispatch.hxx> +#ifndef _STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif + +#include "wrtsh.hxx" +#include "view.hxx" +#include "swmodule.hxx" +#include "cmdid.h" +#include "docsh.hxx" +#include "tmplctrl.hxx" + + +// STATIC DATA ----------------------------------------------------------- + + +SFX_IMPL_STATUSBAR_CONTROL( SwTemplateControl, SfxStringItem ); + +// class TemplatePopup_Impl -------------------------------------------------- + +class TemplatePopup_Impl : public PopupMenu +{ +public: + TemplatePopup_Impl(); + + sal_uInt16 GetCurId() const { return nCurId; } + +private: + sal_uInt16 nCurId; + + virtual void Select(); +}; + +// ----------------------------------------------------------------------- + +TemplatePopup_Impl::TemplatePopup_Impl() : + PopupMenu(), + nCurId(USHRT_MAX) +{ +} + +// ----------------------------------------------------------------------- + +void TemplatePopup_Impl::Select() +{ + nCurId = GetCurItemId(); +} + +// class SvxZoomStatusBarControl ------------------------------------------ + +SwTemplateControl::SwTemplateControl( sal_uInt16 _nSlotId, + sal_uInt16 _nId, + StatusBar& rStb ) : + SfxStatusBarControl( _nSlotId, _nId, rStb ) +{ +} + +// ----------------------------------------------------------------------- + +SwTemplateControl::~SwTemplateControl() +{ +} + +// ----------------------------------------------------------------------- + +void SwTemplateControl::StateChanged( + sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) +{ + if( eState != SFX_ITEM_AVAILABLE || pState->ISA( SfxVoidItem ) ) + GetStatusBar().SetItemText( GetId(), String() ); + else if ( pState->ISA( SfxStringItem ) ) + { + sTemplate = ((SfxStringItem*)pState)->GetValue(); + GetStatusBar().SetItemText( GetId(), sTemplate ); + } +} + +// ----------------------------------------------------------------------- + +void SwTemplateControl::Paint( const UserDrawEvent& ) +{ + GetStatusBar().SetItemText( GetId(), sTemplate ); +} + +// ----------------------------------------------------------------------- + +void SwTemplateControl::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && + GetStatusBar().GetItemText( GetId() ).Len() ) + { + CaptureMouse(); + TemplatePopup_Impl aPop; + { + SwView* pView = ::GetActiveView(); + SwWrtShell* pWrtShell; + if( pView && 0 != (pWrtShell = pView->GetWrtShellPtr()) && + !pWrtShell->SwCrsrShell::HasSelection()&& + !pWrtShell->IsSelFrmMode() && + !pWrtShell->IsObjSelected()) + { + SfxStyleSheetBasePool* pPool = pView->GetDocShell()-> + GetStyleSheetPool(); + pPool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); + if( pPool->Count() > 1 ) + { + sal_uInt16 nCount = 0; + SfxStyleSheetBase* pStyle = pPool->First(); + while( pStyle ) + { + nCount++; + aPop.InsertItem( nCount, pStyle->GetName() ); + pStyle = pPool->Next(); + } + + aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); + sal_uInt16 nCurrId = aPop.GetCurId(); + if( nCurrId != USHRT_MAX) + { + // sieht etwas umstaendlich aus, anders geht's aber nicht + pStyle = pPool->operator[]( nCurrId - 1 ); + SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() ); + pWrtShell->GetView().GetViewFrame()->GetDispatcher()->Execute( + FN_SET_PAGE_STYLE, + SFX_CALLMODE_SLOT|SFX_CALLMODE_RECORD, + &aStyle, 0L ); + } + } + } + } + ReleaseMouse(); + } +} + + + diff --git a/sw/source/ui/utlui/uiitems.cxx b/sw/source/ui/utlui/uiitems.cxx new file mode 100644 index 000000000000..b539adea4353 --- /dev/null +++ b/sw/source/ui/utlui/uiitems.cxx @@ -0,0 +1,324 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <editeng/itemtype.hxx> +#include <unosett.hxx> + +#include "swtypes.hxx" +#include "cmdid.h" +#include "uiitems.hxx" + +#include "utlui.hrc" +#include "attrdesc.hrc" +#ifndef _UNOMID_H +#include <unomid.h> +#endif +#include <numrule.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +// Breitenangaben der Fussnotenlinien, mit TabPage abstimmen +static const sal_uInt16 __FAR_DATA nFtnLines[] = { + 0, + 10, + 50, + 80, + 100, + 150 +}; + +#define FTN_LINE_STYLE_COUNT 5 + + +SwPageFtnInfoItem::SwPageFtnInfoItem( const sal_uInt16 nId, SwPageFtnInfo& rInfo) : + SfxPoolItem( nId ), + aFtnInfo(rInfo) +{ +} + + +SwPageFtnInfoItem::SwPageFtnInfoItem( const SwPageFtnInfoItem& rItem ) : + SfxPoolItem( rItem ), + aFtnInfo(rItem.GetPageFtnInfo()) +{ +} + + + SwPageFtnInfoItem::~SwPageFtnInfoItem() +{ +} + + +SfxPoolItem* SwPageFtnInfoItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwPageFtnInfoItem( *this ); +} + + +int SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const +{ + DBG_ASSERT( Which() == rAttr.Which(), "keine gleichen Attribute" ); + return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo()); +} + + +SfxItemPresentation SwPageFtnInfoItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + String& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nHght = (sal_uInt16) GetPageFtnInfo().GetHeight(); + if ( nHght ) + { + rText = SW_RESSTR( STR_MAX_FTN_HEIGHT ); + rText += ' '; + rText += ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl ); + rText += ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + return ePres; + } + default:; //prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} +/* -----------------------------26.04.01 12:25-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const +{ + sal_Bool bRet = sal_True; + switch(nMemberId & ~CONVERT_TWIPS) + { + case MID_FTN_HEIGHT : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetHeight());break; + case MID_LINE_WEIGHT : rVal <<= (sal_Int16)TWIP_TO_MM100_UNSIGNED(aFtnInfo.GetLineWidth());break; + case MID_LINE_COLOR : rVal <<= (sal_Int32)aFtnInfo.GetLineColor().GetColor();break; + case MID_LINE_RELWIDTH : + { + Fraction aTmp( 100, 1 ); + aTmp *= aFtnInfo.GetWidth(); + rVal <<= (sal_Int8)(long)aTmp; + } + break; + case MID_LINE_ADJUST : rVal <<= (sal_Int16)aFtnInfo.GetAdj();break;//text::HorizontalAdjust + case MID_LINE_TEXT_DIST : rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetTopDist());break; + case MID_LINE_FOOTNOTE_DIST: rVal <<= (sal_Int32)TWIP_TO_MM100(aFtnInfo.GetBottomDist());break; + default: + bRet = sal_False; + } + return bRet; +} +/* -----------------------------26.04.01 12:26-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId) +{ + sal_Int32 nSet32 = 0; + sal_Bool bRet = sal_True; + switch(nMemberId & ~CONVERT_TWIPS) + { + case MID_LINE_COLOR : + rVal >>= nSet32; + aFtnInfo.SetLineColor(nSet32); + break; + case MID_FTN_HEIGHT: + case MID_LINE_TEXT_DIST : + case MID_LINE_FOOTNOTE_DIST: + rVal >>= nSet32; + if(nSet32 < 0) + bRet = sal_False; + else + { + nSet32 = MM100_TO_TWIP(nSet32); + switch(nMemberId & ~CONVERT_TWIPS) + { + case MID_FTN_HEIGHT: aFtnInfo.SetHeight(nSet32); break; + case MID_LINE_TEXT_DIST: aFtnInfo.SetTopDist(nSet32);break; + case MID_LINE_FOOTNOTE_DIST: aFtnInfo.SetBottomDist(nSet32);break; + } + } + break; + case MID_LINE_WEIGHT : + { + sal_Int16 nSet = 0; + rVal >>= nSet; + if(nSet >= 0) + aFtnInfo.SetLineWidth(MM100_TO_TWIP(nSet)); + else + bRet = sal_False; + } + break; + case MID_LINE_RELWIDTH : + { + sal_Int8 nSet = 0; + rVal >>= nSet; + if(nSet < 0) + bRet = sal_False; + else + aFtnInfo.SetWidth(Fraction(nSet, 100)); + } + break; + case MID_LINE_ADJUST : + { + sal_Int16 nSet = 0; + rVal >>= nSet; + if(nSet >= 0 && nSet < 3) //text::HorizontalAdjust + aFtnInfo.SetAdj((SwFtnAdj)nSet); + else + bRet = sal_False; + } + break; + default: + bRet = sal_False; + } + return bRet; +} + +SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) : + SfxPoolItem( nId ), + pMisc(pPtr) +{ +} + +/*-------------------------------------------------------------------- + Beschreibung: Copy-Konstruktor + --------------------------------------------------------------------*/ + + +SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem ) +{ + pMisc = rItem.pMisc; +} + +/*-------------------------------------------------------------------- + Beschreibung: Clonen + --------------------------------------------------------------------*/ + + +SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwPtrItem( *this ); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +int SwPtrItem::operator==( const SfxPoolItem& rAttr ) const +{ + DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); + const SwPtrItem& rItem = (SwPtrItem&)rAttr; + return ( pMisc == rItem.pMisc ); +} + + +/*-----------------12.11.97 12:55------------------------------- + SwUINumRuleItem fuer die NumTabPages der FormatNumRule/Stylisten +---------------------------------------------------------------*/ +SwUINumRuleItem::SwUINumRuleItem( const SwNumRule& rRul, const sal_uInt16 nId ) + : SfxPoolItem( nId ), pRule( new SwNumRule( rRul ) ) +{ +} + +SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem ) + : SfxPoolItem( rItem ), + pRule( new SwNumRule( *rItem.pRule )) +{ +} + + SwUINumRuleItem::~SwUINumRuleItem() +{ + delete pRule; +} + + +SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwUINumRuleItem( *this ); +} + +int SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const +{ + DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); + return *pRule == *((SwUINumRuleItem&)rAttr).pRule; +} + +sal_Bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const +{ + uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule); + rVal.setValue(&xRules, ::getCppuType((uno::Reference< container::XIndexReplace>*)0)); + return sal_True; +} +sal_Bool SwUINumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) +{ + uno::Reference< container::XIndexReplace> xRulesRef; + if(rVal >>= xRulesRef) + { + uno::Reference< lang::XUnoTunnel > xTunnel(xRulesRef, uno::UNO_QUERY); + SwXNumberingRules* pSwXRules = xTunnel.is() ? reinterpret_cast<SwXNumberingRules*>( + xTunnel->getSomething(SwXNumberingRules::getUnoTunnelId())) : 0; + if(pSwXRules) + { + *pRule = *pSwXRules->GetNumRule(); + } + } + return sal_True; +} +/* -----------------17.06.98 17:43------------------- + * + * --------------------------------------------------*/ +SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16 _nWhich, sal_uInt16 nValue) : + SfxUInt16Item(_nWhich, nValue) +{ +} +/* -----------------17.06.98 17:44------------------- + * + * --------------------------------------------------*/ +SfxPoolItem* SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwBackgroundDestinationItem(Which(), GetValue()); +} + + + diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx new file mode 100644 index 000000000000..9ccb68c3bef4 --- /dev/null +++ b/sw/source/ui/utlui/uitool.cxx @@ -0,0 +1,775 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include <hintids.hxx> + +#include <tools/datetime.hxx> +#include <vcl/svapp.hxx> +#include <unotools/collatorwrapper.hxx> +#include <svl/urihelper.hxx> +#include <svl/stritem.hxx> +#include <unotools/syslocale.hxx> +#include <sfx2/app.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> +#include <editeng/pmdlitem.hxx> +#ifndef _SVX_TSTPITEM_HXX //autogen +#include <editeng/tstpitem.hxx> +#endif +#include <editeng/boxitem.hxx> +#include <editeng/sizeitem.hxx> +#include <svx/pageitem.hxx> +#include <editeng/lrspitem.hxx> +#include <svl/style.hxx> +#ifndef _VCL_LSTBOX_HXX //autogen +#include <vcl/lstbox.hxx> +#endif +#include <unotools/localedatawrapper.hxx> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <comphelper/processfactory.hxx> +#include <sfx2/viewfrm.hxx> +#include <fmtornt.hxx> +#include <tabcol.hxx> +#include <edtwin.hxx> +#include <fmtfsize.hxx> +#include <fmthdft.hxx> +#include <fmtpdsc.hxx> +#include <wview.hxx> +#include <uiitems.hxx> +#ifndef _DOCSH_HXX +#include <docsh.hxx> +#endif +#include <wrtsh.hxx> +#include <swmodule.hxx> +#ifndef _VIEW_HXX +#include <view.hxx> +#endif +#include <uitool.hxx> +#include <frmatr.hxx> +#include <paratr.hxx> +#include <fmtcol.hxx> +#include <poolfmt.hxx> +#include "usrpref.hxx" + +#ifndef _ERROR_H +#include <error.h> +#endif +#ifndef _CMDID_H +#include <cmdid.h> +#endif +#ifndef _GLOBALS_HRC +#include <globals.hrc> +#endif +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif +#include <doc.hxx> +#include <docary.hxx> +#include <charfmt.hxx> +#include <SwStyleNameMapper.hxx> +// 50 cm 28350 +// +#define MAXHEIGHT 28350 +#define MAXWIDTH 28350 + +using namespace ::com::sun::star; +/*-------------------------------------------------------------------- + Beschreibung: Allgemeine List von StringPointern + --------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------- + Beschreibung: Metric umschalten + --------------------------------------------------------------------*/ + + +void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit) +{ + SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP)); + SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP)); + + rCtrl.SetUnit(eUnit); + + rCtrl.SetMin(nMin, FUNIT_TWIP); + rCtrl.SetMax(nMax, FUNIT_TWIP); +} + +/*-------------------------------------------------------------------- + Beschreibung: Boxinfo-Attribut setzen + --------------------------------------------------------------------*/ + + +void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) +{ + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + const SfxPoolItem *pBoxInfo; + if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, + sal_True, &pBoxInfo)) + aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; + + // Tabellenvariante, wenn mehrere Tabellenzellen selektiert + rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert + aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1); + // Abstandsfeld immer anzeigen + aBoxInfo.SetDist ((sal_Bool) sal_True); + // Minimalgroesse in Tabellen und Absaetzen setzen + aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)); + // Default-Abstand immer setzen + aBoxInfo.SetDefDist (MIN_BORDER_DIST); + // Einzelne Linien koennen nur in Tabellen DontCare-Status haben + aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode()); + + rSet.Put(aBoxInfo); +} + +/*-------------------------------------------------------------------- + Beschreibung: Header Footer fuellen + --------------------------------------------------------------------*/ + + +void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet) +{ + SwAttrSet aSet(pFmt->GetAttrSet()); + aSet.Put(rSet); + + const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE); + const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC); + + // Groesse umsetzen + // + SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE, + rSize.GetSize().Width(), + rSize.GetSize().Height()); + aSet.Put(aFrmSize); + pFmt->SetFmtAttr(aSet); +} + +/*-------------------------------------------------------------------- + Beschreibung: PageDesc <-> in Sets wandeln und zurueck + --------------------------------------------------------------------*/ + + +void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) +{ + SwFrmFmt& rMaster = rPageDesc.GetMaster(); + + // alle allgemeinen Rahmen-Attribute uebertragen + // + rMaster.SetFmtAttr(rSet); + + // PageData + // + if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET) + { + const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE); + + sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage(); + if(nUse & 0x04) + nUse |= 0x03; + if(nUse) + rPageDesc.SetUseOn( (UseOnPage) nUse ); + rPageDesc.SetLandscape(rPageItem.IsLandscape()); + SvxNumberType aNumType; + aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) ); + rPageDesc.SetNumType(aNumType); + } + // Groesse + // + if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET) + { + const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE); + SwFmtFrmSize aSize(ATT_FIX_SIZE); + aSize.SetSize(rSizeItem.GetSize()); + rMaster.SetFmtAttr(aSize); + } + // Kopzeilen-Attribute auswerten + // + const SfxPoolItem* pItem; + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET, + sal_False, &pItem ) ) + { + const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet(); + const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON); + + if(rHeaderOn.GetValue()) + { + // Werte uebernehmen + if(!rMaster.GetHeader().IsActive()) + rMaster.SetFmtAttr(SwFmtHeader(sal_True)); + + // Das Headerformat rausholen und anpassen + // + SwFmtHeader aHeaderFmt(rMaster.GetHeader()); + SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt(); + ASSERT(pHeaderFmt != 0, "kein HeaderFormat"); + + ::FillHdFt(pHeaderFmt, rHeaderSet); + + rPageDesc.ChgHeaderShare(((const SfxBoolItem&) + rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); + } + else + { // Header ausschalten + // + if(rMaster.GetHeader().IsActive()) + { + rMaster.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False))); + rPageDesc.ChgHeaderShare(sal_False); + } + } + } + + // Fusszeilen-Attribute auswerten + // + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET, + sal_False, &pItem ) ) + { + const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet(); + const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON); + + if(rFooterOn.GetValue()) + { + // Werte uebernehmen + if(!rMaster.GetFooter().IsActive()) + rMaster.SetFmtAttr(SwFmtFooter(sal_True)); + + // Das Footerformat rausholen und anpassen + // + SwFmtFooter aFooterFmt(rMaster.GetFooter()); + SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt(); + ASSERT(pFooterFmt != 0, "kein FooterFormat"); + + ::FillHdFt(pFooterFmt, rFooterSet); + + rPageDesc.ChgFooterShare(((const SfxBoolItem&) + rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); + } + else + { // Footer ausschalten + // + if(rMaster.GetFooter().IsActive()) + { + rMaster.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False))); + rPageDesc.ChgFooterShare(sal_False); + } + } + } + + // Fussnoten + // + if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO, + sal_False, &pItem ) ) + rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() ); + + + // + // Columns + // + + // Registerhaltigkeit + + if(SFX_ITEM_SET == rSet.GetItemState( + SID_SWREGISTER_MODE, sal_False, &pItem)) + { + sal_Bool bSet = ((const SfxBoolItem*)pItem)->GetValue(); + if(!bSet) + rPageDesc.SetRegisterFmtColl(0); + else if(SFX_ITEM_SET == rSet.GetItemState( + SID_SWREGISTER_COLLECTION, sal_False, &pItem)) + { + const String& rColl = ((const SfxStringItem*)pItem)->GetValue(); + SwDoc& rDoc = *rMaster.GetDoc(); + SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl ); + if( !pColl ) + { + sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); + if( USHRT_MAX != nId ) + pColl = rDoc.GetTxtCollFromPool( nId ); + else + pColl = rDoc.MakeTxtFmtColl( rColl, + (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() ); + } + if( pColl ) + pColl->SetFmtAttr( SwRegisterItem ( sal_True )); + rPageDesc.SetRegisterFmtColl( pColl ); + } + } +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + + +void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) +{ + const SwFrmFmt& rMaster = rPageDesc.GetMaster(); + + // Seitendaten + // + SvxPageItem aPageItem(SID_ATTR_PAGE); + aPageItem.SetDescName(rPageDesc.GetName()); + aPageItem.SetPageUsage(rPageDesc.GetUseOn()); + aPageItem.SetLandscape(rPageDesc.GetLandscape()); + aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType()); + rSet.Put(aPageItem); + + // Groesse + SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize()); + rSet.Put(aSizeItem); + + // Maximale Groesse + SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT)); + rSet.Put(aMaxSizeItem); + + // Raender, Umrandung und das andere Zeug + // + rSet.Put(rMaster.GetAttrSet()); + + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + const SfxPoolItem *pBoxInfo; + if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, + sal_True, &pBoxInfo) ) + aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; + + aBoxInfo.SetTable( sal_False ); + // Abstandsfeld immer anzeigen + aBoxInfo.SetDist( sal_True); + // Minimalgroesse in Tabellen und Absaetzen setzen + aBoxInfo.SetMinDist( sal_False ); + // Default-Abstand immer setzen + aBoxInfo.SetDefDist( MIN_BORDER_DIST ); + // Einzelne Linien koennen nur in Tabellen DontCare-Status haben + aBoxInfo.SetValid( VALID_DISABLE ); + rSet.Put( aBoxInfo ); + + + SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, aEmptyStr); + if(rPageDesc.GetFollow()) + aFollow.SetValue(rPageDesc.GetFollow()->GetName()); + rSet.Put(aFollow); + + // Header + // + if(rMaster.GetHeader().IsActive()) + { + const SwFmtHeader &rHeaderFmt = rMaster.GetHeader(); + const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt(); + ASSERT(pHeaderFmt != 0, kein HeaderFormat.); + + // HeaderInfo, Raender, Hintergrund, Umrandung + // + SfxItemSet aHeaderSet( *rSet.GetPool(), + SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0); + + // dynamische oder feste Hoehe + // + SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True); + aHeaderSet.Put(aOn); + + const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize(); + const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType(); + SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE); + aHeaderSet.Put(aDynamic); + + // Links gleich rechts + // + SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared()); + aHeaderSet.Put(aShared); + + // Groesse + SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); + aHeaderSet.Put(aSize); + + // Rahmen-Attribute umschaufeln + // + aHeaderSet.Put(pHeaderFmt->GetAttrSet()); + aHeaderSet.Put( aBoxInfo ); + + // SetItem erzeugen + // + SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet); + rSet.Put(aSetItem); + } + + // Footer + if(rMaster.GetFooter().IsActive()) + { + const SwFmtFooter &rFooterFmt = rMaster.GetFooter(); + const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt(); + ASSERT(pFooterFmt != 0, kein FooterFormat.); + + // FooterInfo, Raender, Hintergrund, Umrandung + // + SfxItemSet aFooterSet( *rSet.GetPool(), + SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0); + + // dynamische oder feste Hoehe + // + SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True); + aFooterSet.Put(aOn); + + const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize(); + const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType(); + SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE); + aFooterSet.Put(aDynamic); + + // Links gleich rechts + // + SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared()); + aFooterSet.Put(aShared); + + // Groesse + SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); + aFooterSet.Put(aSize); + + // Rahmen-Attribute umschaufeln + // + aFooterSet.Put(pFooterFmt->GetAttrSet()); + aFooterSet.Put( aBoxInfo ); + + // SetItem erzeugen + // + SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet); + rSet.Put(aSetItem); + } + + // Fussnoten einbauen + // + SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo(); + SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo); + rSet.Put(aFtnItem); + + // Registerhaltigkeit + + const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl(); + SwRegisterItem aReg(pCol != 0); + aReg.SetWhich(SID_SWREGISTER_MODE); + rSet.Put(aReg); + if(pCol) + rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName())); + +} + + +/*-------------------------------------------------------------------- + Beschreibung: DefaultTabs setzen + --------------------------------------------------------------------*/ + + +void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs) +{ + if( rTabs.Count() ) + return; + { + SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT ); + rTabs.Insert( aSwTabStop ); + } +} + +/*-------------------------------------------------------------------- + Beschreibung: Abstand zwischen zwei Tabs + --------------------------------------------------------------------*/ + + +sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs) +{ + sal_uInt16 nDefDist; + if( rTabs.Count() ) + nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() ); + else + nDefDist = 1134; // 2cm + return nDefDist; +} + + +// erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese +void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) +{ + const SfxPoolItem* pItem; + SwFmtPageDesc aPgDesc; + + sal_Bool bChanged = sal_False; + // Seitennummer + if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, sal_False, &pItem)) + { + aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue()); + bChanged = sal_True; + } + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, sal_False, &pItem )) + { + const String& rDescName = ((SvxPageModelItem*)pItem)->GetValue(); + if( rDescName.Len() ) // kein Name -> PageDesc ausschalten! + { + // nur loeschen, wenn PageDesc eingschaltet wird! + rSet.ClearItem( RES_BREAK ); + SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName( + rDescName, sal_True ); + if( pDesc ) + pDesc->Add( &aPgDesc ); + } + rSet.ClearItem( SID_ATTR_PARA_MODEL ); + bChanged = sal_True; + } + else + { + SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC ); + rShell.GetCurAttr( aCoreSet ); + if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) + { + if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) + { + ((SwFmtPageDesc*)pItem)->GetPageDesc()->Add(&aPgDesc); + } + } + } + + + if(bChanged) + rSet.Put( aPgDesc ); +} + + +// erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese +void SwToSfxPageDescAttr( SfxItemSet& rCoreSet ) +{ + const SfxPoolItem* pItem = 0; + String aName; + sal_uInt16 nPageNum = 0; + sal_Bool bPut = sal_True; + switch( rCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) + { + case SFX_ITEM_SET: + { + if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) + { + aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName(); + nPageNum = ((SwFmtPageDesc*)pItem)->GetNumOffset(); + } + rCoreSet.ClearItem( RES_PAGEDESC ); + // Seitennummer + } + break; + + case SFX_ITEM_AVAILABLE: + break; + + default: + bPut = sal_False; + } + SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, nPageNum ); + rCoreSet.Put( aPageNum ); + + if(bPut) + rCoreSet.Put( SvxPageModelItem( aName, sal_True, SID_ATTR_PARA_MODEL ) ); +} + +/*-------------------------------------------------------------------- + Beschreibung: Metric ermitteln + --------------------------------------------------------------------*/ + + +FieldUnit GetDfltMetric(sal_Bool bWeb) +{ + return SW_MOD()->GetUsrPref(bWeb)->GetMetric(); +} + +/*-------------------------------------------------------------------- + Beschreibung: Metric ermitteln + --------------------------------------------------------------------*/ + + +void SetDfltMetric( FieldUnit eMetric, sal_Bool bWeb ) +{ + SW_MOD()->ApplyUserMetric(eMetric, bWeb); +} + +/*-----------------09.04.98 16:58------------------- + +--------------------------------------------------*/ +sal_uInt16 InsertStringSorted(const String& rEntry, ListBox& rToFill, sal_uInt16 nOffset ) +{ + sal_uInt16 i = nOffset; + CollatorWrapper& rCaseColl = ::GetAppCaseCollator(); + + for( ; i < rToFill.GetEntryCount(); i++ ) + { + if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry )) + break; + } + return rToFill.InsertEntry(rEntry, i); +} +void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, sal_Bool bSorted, sal_Bool bWithDefault) +{ + sal_Bool bHasOffset = rToFill.GetEntryCount() > 0; + SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool(); + pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL); + SwDoc* pDoc = pDocSh->GetDoc(); + const SfxStyleSheetBase* pBase = pPool->First(); + String sStandard; + SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard ); + while(pBase) + { + if(bWithDefault || pBase->GetName() != sStandard) + { + sal_uInt16 nPos; + if(bSorted) + nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset ); + else + nPos = rToFill.InsertEntry(pBase->GetName()); + long nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + rToFill.SetEntryData( nPos, (void*) (nPoolId)); + } + pBase = pPool->Next(); + } + // non-pool styles + const SwCharFmts* pFmts = pDoc->GetCharFmts(); + for(sal_uInt16 i = 0; i < pFmts->Count(); i++) + { + const SwCharFmt* pFmt = (*pFmts)[i]; + if(pFmt->IsDefault()) + continue; + const String& rName = pFmt->GetName(); + if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND) + { + sal_uInt16 nPos; + if(bSorted) + nPos = InsertStringSorted(rName, rToFill, bHasOffset ); + else + nPos = rToFill.InsertEntry(rName); + long nPoolId = USHRT_MAX; + rToFill.SetEntryData( nPos, (void*) (nPoolId)); + } + } +}; + +/* -----------------27.04.98 08:26------------------- + * + * --------------------------------------------------*/ +SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent, + SwWrtShell* pSh ) +{ + //Die Breite zu besorgen ist etwas komplizierter. + SwTwips nWidth = 0; + const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient(); + switch(eOri) + { + case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break; + case text::HoriOrientation::LEFT_AND_WIDTH: + case text::HoriOrientation::LEFT: + case text::HoriOrientation::RIGHT: + case text::HoriOrientation::CENTER: + nWidth = pFmt->GetFrmSize().GetWidth(); + break; + default: + { + if(pSh) + { + const SwFrmFmt *pFlyFmt; + if ( 0 == (pFlyFmt = pSh->GetFlyFrmFmt()) ) + { + nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width(); + } + else + { + nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width(); + } + } + else + { + DBG_ERROR("wo soll die Breite denn herkommen?"); + } + const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace(); + nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft()); + } + } + if (pPercent) + *pPercent = pFmt->GetFrmSize().GetWidthPercent(); + return nWidth; +} + +/*------------------------------------------------------------------------*/ + +String GetAppLangDateTimeString( const DateTime& rDT ) +{ + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData(); + String sRet( rAppLclData.getDate( rDT )); + ( sRet += ' ' ) += rAppLclData.getTime( rDT, sal_False, sal_False ); + return sRet; +} + +/*-- 26.01.2006 08:06:33--------------------------------------------------- + + -----------------------------------------------------------------------*/ +bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId ) +{ + bool bRet = false; + sal_uInt16 nItemCount = rMenu.GetItemCount(); + String sCommand; + for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) + { + PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) ); + if(pPopup) + { + sCommand = pPopup->GetItemCommand(nId); + if(sCommand.Len()) + break; + } + } + if(sCommand.Len()) + { + uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame().GetFrameInterface(); + uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY ); + util::URL aURL; + aURL.Complete = sCommand; + uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY ); + xTrans->parseStrict( aURL ); + uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); + if( xDisp.is() ) + { + uno::Sequence< beans::PropertyValue > aSeq; + xDisp->dispatch( aURL, aSeq ); + bRet = true; + } + } + return bRet; +} diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx new file mode 100644 index 000000000000..42df7d4a8dac --- /dev/null +++ b/sw/source/ui/utlui/unotools.cxx @@ -0,0 +1,522 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include <swtypes.hxx> +#include <globals.hrc> +#include <misc.hrc> + +#include <utlui.hrc> +#include <unotools.hrc> +#include <unotools.hxx> +#include <unoprnms.hxx> +#include <tools/debug.hxx> +#include <vcl/msgbox.hxx> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/view/XScreenCursor.hpp> +#include <com/sun/star/view/DocumentZoomType.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <comphelper/processfactory.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/stritem.hxx> +#include <shellio.hxx> +#include <docsh.hxx> +#include <view.hxx> +#include <wrtsh.hxx> +#include <swmodule.hxx> +#include <TextCursorHelper.hxx> +#include <unocrsr.hxx> +#include <doc.hxx> + +#include <unomid.h> + + +using namespace ::com::sun::star; +using ::rtl::OUString; + +const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl"; +const sal_Char cFactory[] = "private:factory/swriter"; +/************************************************************************ + +************************************************************************/ + +sal_Bool SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_True; + +/* -----------------27.07.99 15:26------------------- + + --------------------------------------------------*/ +SwOneExampleFrame::SwOneExampleFrame( Window& rWin, + sal_uInt32 nFlags, + const Link* pInitializedLink, + String* pURL ) : + aTopWindow( rWin.GetParent(), 0, this ), + rWindow(rWin), + aMenuRes(SW_RES(RES_FRMEX_MENU)), + + pModuleView(SW_MOD()->GetView()), + + nStyleFlags(nFlags), + bIsInitialized(sal_False), + bServiceAvailable(sal_False) +{ + if(pURL && pURL->Len()) + sArgumentURL = *pURL; + + aTopWindow.SetPaintTransparent(sal_True); + aTopWindow.SetPosSizePixel(rWin.GetPosPixel(), rWin.GetSizePixel()); + aTopWindow.SetZOrder( &rWin, WINDOW_ZORDER_FIRST ); + + if( pInitializedLink ) + aInitializedLink = *pInitializedLink; + + // the controller is asynchronously set + aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl)); +// aLoadedTimer.SetTimeout(500); + aLoadedTimer.SetTimeout(200); + + rWin.Enable(sal_False); + CreateControl(); + + aTopWindow.Show(); +} + +/* -----------------------------08.12.99 13:44-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwOneExampleFrame::CreateErrorMessage(Window* pParent) +{ + if(SwOneExampleFrame::bShowServiceNotAvailableMessage) + { + String sInfo(SW_RES(STR_SERVICE_UNAVAILABLE)); + sInfo += C2S(cFrameControl); + InfoBox(pParent, sInfo).Execute(); + SwOneExampleFrame::bShowServiceNotAvailableMessage = sal_False; + } +} +/* -----------------27.07.99 15:26------------------- + + --------------------------------------------------*/ +SwOneExampleFrame::~SwOneExampleFrame() +{ + DisposeControl(); +} +/* -----------------------------21.12.00 10:16-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwOneExampleFrame::CreateControl() +{ + if(_xControl.is()) + return ; + uno::Reference< lang::XMultiServiceFactory > + xMgr = comphelper::getProcessServiceFactory(); + uno::Reference< uno::XInterface > xInst = xMgr->createInstance( C2U("com.sun.star.frame.FrameControl") ); + _xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY); + if(_xControl.is()) + { + uno::Reference< awt::XWindowPeer > xParent( rWindow.GetComponentInterface() ); + + uno::Reference< awt::XToolkit > xToolkit( xMgr->createInstance( C2U("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY ); + if(xToolkit.is()) + { + _xControl->createPeer( xToolkit, xParent ); + + uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); + xWin->setVisible( sal_False ); + Size aWinSize(rWindow.GetOutputSizePixel()); + xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE ); + + uno::Reference< beans::XPropertySet > xPrSet(xInst, uno::UNO_QUERY); + uno::Any aURL; + // + // create new doc + String sTempURL = C2S(cFactory); + if(sArgumentURL.Len()) + sTempURL = sArgumentURL; + aURL <<= OUString(sTempURL); + + uno::Sequence<beans::PropertyValue> aSeq(3); + beans::PropertyValue* pValues = aSeq.getArray(); + pValues[0].Name = C2U("ReadOnly"); + sal_Bool bTrue = sal_True; + pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType()); + pValues[1].Name = C2U("OpenFlags"); + pValues[1].Value <<= C2U("-RB"); + pValues[2].Name = C2U("Referer"); + pValues[2].Value <<= C2U("private:user"); + uno::Any aArgs; + aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0)); + + xPrSet->setPropertyValue( C2U("LoaderArguments"), aArgs ); + //save and set readonly??? + + xPrSet->setPropertyValue(C2U("ComponentURL"), aURL); + + aLoadedTimer.Start(); + bServiceAvailable = sal_True; + } + } +} + + +/* -----------------------------21.12.00 10:16-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwOneExampleFrame::DisposeControl() +{ + _xCursor = 0; + if(_xControl.is()) + _xControl->dispose(); + _xControl = 0; + _xModel = 0; + _xController = 0; +} +/* -----------------27.07.99 15:26------------------- + + --------------------------------------------------*/ +IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer ) +{ + if(!_xControl.is()) + return 0; + + // now get the model + uno::Reference< beans::XPropertySet > xPrSet(_xControl, uno::UNO_QUERY); + uno::Any aFrame = xPrSet->getPropertyValue(C2U("Frame")); + uno::Reference< frame::XFrame > xFrm; + aFrame >>= xFrm; + + uno::Reference< beans::XPropertySet > xPropSet( xFrm, uno::UNO_QUERY ); + if ( xPropSet.is() ) + { + try + { + uno::Reference< frame::XLayoutManager > xLayoutManager; + uno::Any aValue = xPropSet->getPropertyValue(C2U("LayoutManager")); + aValue >>= xLayoutManager; + if ( xLayoutManager.is() ) + xLayoutManager->setVisible( sal_False ); + } + catch ( uno::Exception& ) + { + } + } + + _xController = xFrm->getController(); + if(_xController.is()) + { + _xModel = _xController->getModel(); + //now the ViewOptions should be set properly + uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); + + sal_Bool bTrue = sal_True; + sal_Bool bFalse = sal_False; + uno::Any aTrueSet( &bTrue, ::getBooleanCppuType() ); + uno::Any aFalseSet( &bFalse, ::getBooleanCppuType() ); + + if( !bIsInitialized ) + { + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_BREAKS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_DRAWINGS )), aTrueSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_FIELD_COMMANDS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_GRAPHICS )), aTrueSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HIDDEN_TEXT )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_RULER )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_PARA_BREAKS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_PROTECTED_SPACES )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_SOFT_HYPHENS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_SPACES )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABLES )), aTrueSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_TABSTOPS )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_RULER )), aFalseSet); + + if(0 ==(nStyleFlags&EX_SHOW_ONLINE_LAYOUT)) + { + uno::Any aZoom; + aZoom <<= (sal_Int16)view::DocumentZoomType::PAGE_WIDTH_EXACT; + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); + } + else + { + uno::Any aZoom; + aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); + + sal_Int16 nZoomValue = 50; + if(EX_SHOW_BUSINESS_CARDS == nStyleFlags) + { + nZoomValue = 80; + } + aZoom <<= nZoomValue; + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom); + } + // set onlinelayout property behind setting the zoom + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_ONLINE_LAYOUT)), + (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) ? aTrueSet : aFalseSet ); + bIsInitialized = sal_True; + } + + uno::Reference< text::XTextDocument > xDoc(_xModel, uno::UNO_QUERY); + uno::Reference< text::XText > xText = xDoc->getText(); + _xCursor = xText->createTextCursor(); + uno::Reference< beans::XPropertySet > xCrsrProp(_xCursor, uno::UNO_QUERY); + uno::Any aPageStyle = xCrsrProp->getPropertyValue( + C2U(SW_PROP_NAME_STR(UNO_NAME_PAGE_STYLE_NAME))); + OUString sPageStyle; + aPageStyle >>= sPageStyle; + + uno::Reference< style::XStyleFamiliesSupplier > xSSupp( xDoc, uno::UNO_QUERY); + uno::Reference< container::XNameAccess > xStyles = xSSupp->getStyleFamilies(); + uno::Any aPFamily = xStyles->getByName( C2U("PageStyles" ) ); + uno::Reference< container::XNameContainer > xPFamily; + + if( 0 == (EX_SHOW_DEFAULT_PAGE == nStyleFlags) + && (aPFamily >>= xPFamily) && sPageStyle.getLength() ) + { + uno::Any aPStyle = xPFamily->getByName( sPageStyle ); + uno::Reference< style::XStyle > xPStyle; + aPStyle >>= xPStyle; + uno::Reference< beans::XPropertySet > xPProp(xPStyle, uno::UNO_QUERY); + uno::Any aSize = xPProp->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SIZE))); + awt::Size aPSize; + aSize >>= aPSize; + //TODO: set page width to card width + aPSize.Width = 10000; + aSize.setValue(&aPSize, ::getCppuType((awt::Size*)0)); + xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SIZE)), aSize); + + uno::Any aZero; aZero <<= (sal_Int32)0; + xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LEFT_MARGIN)), aZero); + xPProp->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_RIGHT_MARGIN)), aZero); + } + + // can only be done here - the SFX changes the ScrollBar values + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_HORI_SCROLL_BAR )), aFalseSet); + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SHOW_VERT_SCROLL_BAR )), aFalseSet); + + if( aInitializedLink.IsSet() ) + { + rWindow.Enable(sal_False, sal_True); + //rWindow.Enable(sal_True, sal_False); + aInitializedLink.Call(this); + } + + uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY); + uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY); + if(xScrCrsr.is()) + xScrCrsr->screenUp(); + + uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); + xWin->setVisible( sal_True ); + rWindow.Show(); + + uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY); + if( xTunnel.is() ) + { + OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>( xTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() )); + if( pCrsr ) + { + SwEditShell* pSh = pCrsr->GetDoc()->GetEditShell(); + if( pSh->ActionCount() ) + { + pSh->EndAllAction(); + pSh->UnlockPaint(); + } + } + } + + SW_MOD()->SetView(pModuleView); + } + else + pTimer->Start(); + return 0; +} +/* -----------------------------27.12.99 09:59-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwOneExampleFrame::ClearDocument( sal_Bool bStartUpdateTimer ) +{ + uno::Reference< lang::XUnoTunnel> xTunnel( _xCursor, uno::UNO_QUERY); + if( xTunnel.is() ) + { + OTextCursorHelper* pCrsr = reinterpret_cast<OTextCursorHelper*>(xTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId()) ); + if( pCrsr ) + { + SwDoc* pDoc = pCrsr->GetDoc(); + SwEditShell* pSh = pDoc->GetEditShell(); + pSh->LockPaint(); + pSh->StartAllAction(); + pDoc->ClearDoc(); + + if( aLoadedTimer.IsActive() || !bStartUpdateTimer ) + { + pSh->EndAllAction(); + pSh->UnlockPaint(); + } + if( bStartUpdateTimer ) + aLoadedTimer.Start(); + } + else + { + _xCursor->gotoStart(sal_False); + _xCursor->gotoEnd(sal_True); + _xCursor->setString(OUString()); + } + } +} +/* -----------------------------15.12.99 11:09-------------------------------- + + ---------------------------------------------------------------------------*/ +static const sal_Int16 nZoomValues[] = +{ + 20, + 40, + 50, + 75, + 100 +}; +//--------------------------------------------------------------------------- +#define ITEM_UP 100 +#define ITEM_DOWN 200 +#define ITEM_ZOOM 300 + +void SwOneExampleFrame::CreatePopup(const Point& rPt) +{ + PopupMenu aPop; + PopupMenu aSubPop1; + ResStringArray& rArr = aMenuRes.GetMenuArray(); + + aPop.InsertItem(ITEM_UP, rArr.GetString(rArr.FindIndex(ST_MENU_UP ))); + aPop.InsertItem(ITEM_DOWN, rArr.GetString(rArr.FindIndex(ST_MENU_DOWN ))); + + Link aSelLk = LINK(this, SwOneExampleFrame, PopupHdl ); + aPop.SetSelectHdl(aSelLk); + if(EX_SHOW_ONLINE_LAYOUT == nStyleFlags) + { + aPop.InsertItem(ITEM_ZOOM, rArr.GetString(rArr.FindIndex(ST_MENU_ZOOM ))); + + uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); + + uno::Any aZoom = xViewProps->getPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE))); + sal_Int16 nZoom = 0; + aZoom >>= nZoom; + + for(sal_uInt16 i = 0; i < 5; i++ ) + { + String sTemp; + sTemp = String::CreateFromInt32(nZoomValues[i]); + sTemp += String::CreateFromAscii(" %"); + aSubPop1.InsertItem( ITEM_ZOOM + i + 1, sTemp); + if(nZoom == nZoomValues[i]) + aSubPop1.CheckItem(ITEM_ZOOM + i + 1); + } + aPop.SetPopupMenu( ITEM_ZOOM, &aSubPop1 ); + aSubPop1.SetSelectHdl(aSelLk); + } + aPop.Execute( &aTopWindow, rPt ); + +} +/* -----------------------------15.12.99 11:09-------------------------------- + + ---------------------------------------------------------------------------*/ +IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu ) +{ + sal_uInt16 nId = pMenu->GetCurItemId(); + if( nId > ITEM_ZOOM && nId < ITEM_ZOOM + 100 ) + { + sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1]; + uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xViewProps = xSettings->getViewSettings(); + + uno::Any aZoom; + aZoom <<= nZoom; + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_VALUE)), aZoom); + aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; + xViewProps->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ZOOM_TYPE)), aZoom); + } + else if(ITEM_UP == nId || ITEM_DOWN == nId) + { + uno::Reference< text::XTextViewCursorSupplier > xCrsrSupp(_xController, uno::UNO_QUERY); + uno::Reference< view::XScreenCursor > xScrCrsr(xCrsrSupp->getViewCursor(), uno::UNO_QUERY); + if(ITEM_UP == nId) + xScrCrsr->screenUp(); + else + xScrCrsr->screenDown(); + } + return 0; +}; +/* -----------------------------15.12.99 10:37-------------------------------- + + ---------------------------------------------------------------------------*/ +SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, WinBits nBits, + SwOneExampleFrame* pFrame) : + Window(pParent, nBits), + pExampleFrame(pFrame) +{ +} +/* -----------------------------15.12.99 09:57-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwFrmCtrlWindow::Command( const CommandEvent& rCEvt ) +{ + switch ( rCEvt.GetCommand() ) + { + case COMMAND_CONTEXTMENU: + { + //#125881# quickly clicking crashes because the control is not fully initialized + if(pExampleFrame->GetController().is()) + pExampleFrame->CreatePopup(rCEvt.GetMousePosPixel()); + } + break; + case COMMAND_WHEEL: + case COMMAND_STARTAUTOSCROLL: + case COMMAND_AUTOSCROLL: + break; + default:; + } +} +/* -----------------------------15.12.99 12:57-------------------------------- + + ---------------------------------------------------------------------------*/ +MenuResource::MenuResource(const ResId& rResId) : + Resource(rResId), + aMenuArray(ResId(1,*rResId.GetResMgr())) +{ + FreeResource(); +} + diff --git a/sw/source/ui/utlui/unotools.hrc b/sw/source/ui/utlui/unotools.hrc new file mode 100644 index 000000000000..d68577036830 --- /dev/null +++ b/sw/source/ui/utlui/unotools.hrc @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _UNOTOOLS_HRC +#define _UNOTOOLS_HRC + +#define FT_NEW_NAME 1 +#define ED_NEW_NAME 2 +#define FL_NAME 3 +#define PB_OK 4 +#define PB_HELP 5 +#define PB_CANCEL 6 + +#define ST_MENU_ZOOM 1 +#define ST_MENU_UP 2 +#define ST_MENU_DOWN 3 + +#endif diff --git a/sw/source/ui/utlui/unotools.src b/sw/source/ui/utlui/unotools.src new file mode 100644 index 000000000000..ac203d035cd6 --- /dev/null +++ b/sw/source/ui/utlui/unotools.src @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include <unotools.hrc> +#include <utlui.hrc> +#include <globals.hrc> +#include <helpid.h> + +ModalDialog DLG_RENAME_XNAMED +{ + HelpID = HID_RENAME_XNAMED ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 220 , 60 ) ; + Moveable = TRUE ; + FixedText FT_NEW_NAME + { + Pos = MAP_APPFONT ( 12 , 15 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + Text [ en-US ] = "New name"; + }; + Edit ED_NEW_NAME + { + HelpID = "sw:Edit:DLG_RENAME_XNAMED:ED_NEW_NAME"; + Pos = MAP_APPFONT ( 65 , 13 ) ; + Size = MAP_APPFONT ( 87 , 12 ) ; + Border = TRUE; + }; + FixedLine FL_NAME + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 152 , 8 ) ; + Text [ en-US ] = "Change name"; + }; + OKButton PB_OK + { + Pos = MAP_APPFONT ( 164 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + DefButton = TRUE ; + }; + CancelButton PB_CANCEL + { + Pos = MAP_APPFONT ( 164 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + }; + HelpButton PB_HELP + { + Pos = MAP_APPFONT ( 164 , 43 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + Group = TRUE ; + }; + Text [ en-US ] = "Rename object: "; +}; +String STR_SERVICE_UNAVAILABLE +{ + Text [ en-US ] = "The following service is not available: "; +}; +Resource RES_FRMEX_MENU +{ + StringArray 1 + { + ItemList [ en-US ] = + { + < "~Zoom" ; ST_MENU_ZOOM; > ; + < "~Upwards" ; ST_MENU_UP; > ; + < "Do~wnwards" ; ST_MENU_DOWN; > ; + }; + }; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/source/ui/utlui/utlui.src b/sw/source/ui/utlui/utlui.src new file mode 100644 index 000000000000..dfa3e07f9053 --- /dev/null +++ b/sw/source/ui/utlui/utlui.src @@ -0,0 +1,478 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "globals.hrc" +#include "utlui.hrc" +#include "helpid.h" +#include "comcore.hrc" + + +Resource RID_SHELLRES_AUTOFMTSTRS +{ + String STR_AUTOFMTREDL_DEL_EMPTY_PARA+1 + { + Text [ en-US ] = "Remove empty paragraphs" ; + }; + String STR_AUTOFMTREDL_USE_REPLACE+1 + { + Text [ en-US ] = "Use replacement table" ; + }; + String STR_AUTOFMTREDL_CPTL_STT_WORD+1 + { + Text [ en-US ] = "Correct TWo INitial CApitals" ; + }; + String STR_AUTOFMTREDL_CPTL_STT_SENT+1 + { + Text [ en-US ] = "Capitalize first letter of sentences" ; + }; + String STR_AUTOFMTREDL_TYPO+1 + { + Text [ en-US ] = "Replace \"standard\" quotes with %1 \bcustom%2 quotes" ; + }; + String STR_AUTOFMTREDL_USER_STYLE+1 + { + Text [ en-US ] = "Replace Custom Styles" ; + }; + String STR_AUTOFMTREDL_BULLET+1 + { + Text [ en-US ] = "Bullets replaced"; + }; + String STR_AUTOFMTREDL_UNDER+1 + { + Text [ en-US ] = "Automatic _underline_"; + }; + String STR_AUTOFMTREDL_BOLD+1 + { + Text [ en-US ] = "Automatic *bold*"; + }; + String STR_AUTOFMTREDL_FRACTION+1 + { + Text [ en-US ] = "Replace 1/2 ... with ½ ..." ; + }; + String STR_AUTOFMTREDL_DETECT_URL+1 + { + Text [ en-US ] = "URL recognition" ; + }; + String STR_AUTOFMTREDL_DASH+1 + { + Text [ en-US ] = "Replace dashes" ; + }; + String STR_AUTOFMTREDL_ORDINAL+1 + { + Text [ en-US ] = "Replace 1st... with 1^st..." ; + }; + String STR_AUTOFMTREDL_RIGHT_MARGIN+1 + { + Text [ en-US ] = "Combine single line paragraphs"; + }; + + String STR_AUTOFMTREDL_SET_TMPL_TEXT +1 + { + Text [ en-US ] = "Set \"Text body\" Style"; + }; + String STR_AUTOFMTREDL_SET_TMPL_INDENT +1 + { + Text [ en-US ] = "Set \"Text body indent\" Style"; + }; + String STR_AUTOFMTREDL_SET_TMPL_NEG_INDENT +1 + { + Text [ en-US ] = "Set \"Hanging indent\" Style"; + }; + String STR_AUTOFMTREDL_SET_TMPL_TEXT_INDENT +1 + { + Text [ en-US ] = "Set \"Text body indent\" Style"; + }; + String STR_AUTOFMTREDL_SET_TMPL_HEADLINE +1 + { + Text [ en-US ] = "Set \"Heading $(ARG1)\" Style"; + }; + String STR_AUTOFMTREDL_SET_NUMBULET +1 + { + Text [ en-US ] = "Set \"Bullet\" or \"Numbering\" Style"; + }; + + String STR_AUTOFMTREDL_DEL_MORELINES +1 + { + Text [ en-US ] = "Combine paragraphs"; + }; + String STR_AUTOFMTREDL_NON_BREAK_SPACE +1 + { + Text [ en-US ] = "Add non breaking space"; + }; + +}; + +/*--------------------------------------------------------------------- + Diverses + ---------------------------------------------------------------------*/ +String STR_EVENT_OBJECT_SELECT +{ + Text [ en-US ] = "Click object" ; +}; +String STR_EVENT_START_INS_GLOSSARY +{ + Text [ en-US ] = "Before inserting AutoText"; +}; +String STR_EVENT_END_INS_GLOSSARY +{ + Text [ en-US ] = "After inserting AutoText"; +}; +String STR_EVENT_MOUSEOVER_OBJECT +{ + Text [ en-US ] = "Mouse over object" ; +}; +String STR_EVENT_MOUSECLICK_OBJECT +{ + Text [ en-US ] = "Trigger hyperlink" ; +}; +String STR_EVENT_MOUSEOUT_OBJECT +{ + Text [ en-US ] = "Mouse leaves object" ; +}; +String STR_EVENT_IMAGE_LOAD +{ + Text [ en-US ] = "Graphics load successful" ; +}; +String STR_EVENT_IMAGE_ABORT +{ + Text [ en-US ] = "Graphics load terminated" ; +}; +String STR_EVENT_IMAGE_ERROR +{ + Text [ en-US ] = "Graphics load faulty" ; +}; +String STR_EVENT_FRM_KEYINPUT_A +{ + Text [ en-US ] = "Input of alphanumeric characters" ; +}; +String STR_EVENT_FRM_KEYINPUT_NOA +{ + Text [ en-US ] = "Input of non-alphanumeric characters" ; +}; +String STR_EVENT_FRM_RESIZE +{ + Text [ en-US ] = "Resize frame" ; +}; +String STR_EVENT_FRM_MOVE +{ + Text [ en-US ] = "Move frame" ; +}; +String STR_CONTENT_TYPE_OUTLINE +{ + Text [ en-US ] = "Headings" ; +}; +String STR_CONTENT_TYPE_TABLE +{ + Text [ en-US ] = "Tables" ; +}; +String STR_CONTENT_TYPE_FRAME +{ + Text [ en-US ] = "Text frames" ; +}; +String STR_CONTENT_TYPE_GRAPHIC +{ + Text [ en-US ] = "Graphics" ; +}; +String STR_CONTENT_TYPE_OLE +{ + Text [ en-US ] = "OLE objects" ; +}; +String STR_CONTENT_TYPE_BOOKMARK +{ + Text [ en-US ] = "Bookmarks" ; +}; +String STR_CONTENT_TYPE_REGION +{ + Text [ en-US ] = "Sections" ; +}; +String STR_CONTENT_TYPE_URLFIELD +{ + Text [ en-US ] = "Hyperlinks" ; +}; +String STR_CONTENT_TYPE_REFERENCE +{ + Text [ en-US ] = "References" ; +}; +String STR_CONTENT_TYPE_INDEX +{ + Text [ en-US ] = "Indexes" ; +}; +String STR_CONTENT_TYPE_DRAWOBJECT +{ + Text [ en-US ] = "Draw objects" ; +}; +String STR_CONTENT_TYPE_POSTIT +{ + Text [ en-US ] = "Comments" ; +}; +String STR_CONTENT_TYPE_SINGLE_OUTLINE +{ + Text [ en-US ] = "Heading" ; +}; +String STR_CONTENT_TYPE_SINGLE_TABLE +{ + Text [ en-US ] = "Table" ; +}; +String STR_CONTENT_TYPE_SINGLE_FRAME +{ + Text [ en-US ] = "Text frame" ; +}; +String STR_CONTENT_TYPE_SINGLE_GRAPHIC +{ + Text [ en-US ] = "Graphics" ; +}; +String STR_CONTENT_TYPE_SINGLE_OLE +{ + Text [ en-US ] = "OLE object" ; +}; +String STR_CONTENT_TYPE_SINGLE_BOOKMARK +{ + Text [ en-US ] = "Bookmark" ; +}; +String STR_CONTENT_TYPE_SINGLE_REGION +{ + Text [ en-US ] = "Section" ; +}; +String STR_CONTENT_TYPE_SINGLE_URLFIELD +{ + Text [ en-US ] = "Hyperlink" ; +}; +String STR_CONTENT_TYPE_SINGLE_REFERENCE +{ + Text [ en-US ] = "Reference" ; +}; +String STR_CONTENT_TYPE_SINGLE_INDEX +{ + Text [ en-US ] = "Index" ; +}; +String STR_CONTENT_TYPE_SINGLE_POSTIT +{ + Text [ en-US ] = "Comment" ; +}; +String STR_CONTENT_TYPE_SINGLE_DRAWOBJECT +{ + Text [ en-US ] = "Draw object" ; +}; +String STR_DEFINE_NUMBERFORMAT +{ + Text [ en-US ] = "Additional formats..." ; +}; +String RID_STR_SYSTEM +{ + Text [ en-US ] = "[System]"; +}; +String STR_MULT_INTERACT_SPELL_WARN +{ + Text [ en-US ] = "The interactive spellcheck is already active\nin a different document"; +}; +String STR_MULT_INTERACT_HYPH_WARN +{ + Text [ en-US ] = "The interactive hyphenation is already active\nin a different document"; +}; +String STR_SPELL_TITLE +{ + Text [ en-US ] = "Spellcheck"; +}; +String STR_HYPH_TITLE +{ + Text [ en-US ] = "Hyphenation"; +}; + +#define IMGLIST_IDS\ + IdList = \ + { \ + IMG_COLLAPSE;\ + IMG_EXPAND ;\ + IMG_DB ;\ + IMG_DBTABLE ;\ + IMG_DBQUERY ;\ + }; \ + IdCount = 5 + +ImageList ILIST_DB_DLG +{ + Prefix = "sx"; + MaskColor = IMAGE_MASK_COLOR; + IMGLIST_IDS; +}; + +ImageList ILIST_DB_DLG_HC +{ + Prefix = "sxh"; + MaskColor = IMAGE_MASK_COLOR ; + IMGLIST_IDS; +}; + +Image IMG_ONE_LEFT_HC +{ + ImageBitmap = Bitmap + { + File = "one_left_h.bmp" ; + }; + MaskColor = IMAGE_MASK_COLOR ; +}; + +Image IMG_ONE_RIGHT_HC +{ + ImageBitmap = Bitmap + { + File = "one_right_h.bmp" ; + }; + MaskColor = IMAGE_MASK_COLOR ; +}; + +Image IMG_ALL_LEFT_HC +{ + ImageBitmap = Bitmap + { + File = "all_left_h.bmp" ; + }; + MaskColor = IMAGE_MASK_COLOR ; +}; + +Image IMG_ALL_RIGHT_HC +{ + ImageBitmap = Bitmap + { + File = "all_right_h.bmp" ; + }; + MaskColor = IMAGE_MASK_COLOR ; +}; + + +Image IMG_VIEWLAYOUT_AUTOMATIC +{ + ImageBitmap = Bitmap + { + File = "twopages_11x25.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE +{ + ImageBitmap = Bitmap + { + File = "twopages_a_11x25.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; + +Image IMG_VIEWLAYOUT_BOOKMODE +{ + ImageBitmap = Bitmap + { + File = "doublepage_11x23.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_BOOKMODE_ACTIVE +{ + ImageBitmap = Bitmap + { + File = "doublepage_a_11x23.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; + +Image IMG_VIEWLAYOUT_SINGLECOLUMN +{ + ImageBitmap = Bitmap + { + File = "emptypage_11x15.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE +{ + ImageBitmap = Bitmap + { + File = "emptypage_a_11x15.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; + +Image IMG_VIEWLAYOUT_AUTOMATIC_HC +{ + ImageBitmap = Bitmap + { + File = "twopages_11x25_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE_HC +{ + ImageBitmap = Bitmap + { + File = "twopages_a_11x25_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; + +Image IMG_VIEWLAYOUT_BOOKMODE_HC +{ + ImageBitmap = Bitmap + { + File = "doublepage_11x23_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_BOOKMODE_ACTIVE_HC +{ + ImageBitmap = Bitmap + { + File = "doublepage_a_11x23_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_SINGLECOLUMN_HC +{ + ImageBitmap = Bitmap + { + File = "emptypage_11x15_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; +Image IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE_HC +{ + ImageBitmap = Bitmap + { + File = "emptypage_a_11x15_h.png" ; + }; + MaskColor = IMAGE_MASK_COLOR; +}; + + + +String STR_HYPERCTRL_SEL +{ + Text [ en-US ] = "SEL"; +}; +String STR_HYPERCTRL_HYP +{ + Text [ en-US ] = "HYP"; +}; + diff --git a/sw/source/ui/utlui/viewlayoutctrl.cxx b/sw/source/ui/utlui/viewlayoutctrl.cxx new file mode 100644 index 000000000000..1b755391c319 --- /dev/null +++ b/sw/source/ui/utlui/viewlayoutctrl.cxx @@ -0,0 +1,209 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +// include --------------------------------------------------------------- +#include <viewlayoutctrl.hxx> + +#ifndef _STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif +#include <vcl/image.hxx> +#include <svl/eitem.hxx> +#include <svx/viewlayoutitem.hxx> +#ifndef _UTLUI_HRC +#include <utlui.hrc> +#endif +#include <swtypes.hxx> // fuer Pathfinder + +// STATIC DATA ----------------------------------------------------------- + +SFX_IMPL_STATUSBAR_CONTROL( SwViewLayoutControl, SvxViewLayoutItem ); + +// ----------------------------------------------------------------------- + +const long nImageWidthSingle = 15; +const long nImageWidthAuto = 25; +const long nImageWidthBook = 23; +const long nImageWidthSum = 63; +const long nImageHeight = 11; + +// ----------------------------------------------------------------------- + +struct SwViewLayoutControl::SwViewLayoutControl_Impl +{ + sal_uInt16 mnState; // 0 = single, 1 = auto, 2 = book, 3 = none + Image maImageSingleColumn; + Image maImageSingleColumn_Active; + Image maImageAutomatic; + Image maImageAutomatic_Active; + Image maImageBookMode; + Image maImageBookMode_Active; +}; + +// class SwViewLayoutControl ------------------------------------------ + +SwViewLayoutControl::SwViewLayoutControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : + SfxStatusBarControl( _nSlotId, _nId, rStb ), + mpImpl( new SwViewLayoutControl_Impl ) +{ + mpImpl->mnState = 0; + + const sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode(); + mpImpl->maImageSingleColumn = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN_HC) : SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN) ); + mpImpl->maImageSingleColumn_Active = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE_HC) : SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE) ); + mpImpl->maImageAutomatic = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_HC) : SW_RES(IMG_VIEWLAYOUT_AUTOMATIC) ); + mpImpl->maImageAutomatic_Active = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE_HC) : SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE) ); + mpImpl->maImageBookMode = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_BOOKMODE_HC) : SW_RES(IMG_VIEWLAYOUT_BOOKMODE) ); + mpImpl->maImageBookMode_Active = Image( bHC ? SW_RES(IMG_VIEWLAYOUT_BOOKMODE_ACTIVE_HC) : SW_RES(IMG_VIEWLAYOUT_BOOKMODE_ACTIVE) ); +} + +// ----------------------------------------------------------------------- + +SwViewLayoutControl::~SwViewLayoutControl() +{ + delete mpImpl; +} + +// ----------------------------------------------------------------------- + +void SwViewLayoutControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) +{ + if ( SFX_ITEM_AVAILABLE != eState || pState->ISA( SfxVoidItem ) ) + GetStatusBar().SetItemText( GetId(), String() ); + else + { + DBG_ASSERT( pState->ISA( SvxViewLayoutItem ), "invalid item type" ); + const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem*>( pState )->GetValue(); + const bool bBookMode = static_cast<const SvxViewLayoutItem*>( pState )->IsBookMode(); + + // SingleColumn Mode + if ( 1 == nColumns ) + mpImpl->mnState = 0; + // Automatic Mode + else if ( 0 == nColumns ) + mpImpl->mnState = 1; + // Book Mode + else if ( bBookMode && 2 == nColumns ) + mpImpl->mnState = 2; + else + mpImpl->mnState = 3; + } + + if ( GetStatusBar().AreItemsVisible() ) + GetStatusBar().SetItemData( GetId(), 0 ); // force repaint +} + +// ----------------------------------------------------------------------- + +void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) +{ + OutputDevice* pDev = rUsrEvt.GetDevice(); + Rectangle aRect = rUsrEvt.GetRect(); + Color aOldLineColor = pDev->GetLineColor(); + Color aOldFillColor = pDev->GetFillColor(); + + //pDev->SetLineColor(); + //pDev->SetFillColor( pDev->GetBackground().GetColor() ); + + const bool bSingleColumn = 0 == mpImpl->mnState; + const bool bAutomatic = 1 == mpImpl->mnState; + const bool bBookMode = 2 == mpImpl->mnState; + + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + const long nYOffset = (aRect.GetHeight() - nImageHeight)/2; + + aRect.Left() = aRect.Left() + nXOffset; + aRect.Top() = aRect.Top() + nYOffset; + + // draw single column image: + pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn ); + + // draw automatic image: + aRect.Left() += nImageWidthSingle; + pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic ); + + // draw bookmode image: + aRect.Left() += nImageWidthAuto; + pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode ); + + // draw separators + //aRect = rUsrEvt.GetRect(); + //aRect.Left() += nImageWidth; + //aRect.setWidth( 1 ); + //pDev->DrawRect( aRect ); + //aRect.Left() += nImageWidth; + //pDev->DrawRect( aRect ); + + //pDev->SetLineColor( aOldLineColor ); + //pDev->SetFillColor( aOldFillColor ); +} + +sal_Bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt ) +{ + const Rectangle aRect = getControlRect(); + const Point aPoint = rEvt.GetPosPixel(); + const long nXDiff = aPoint.X() - aRect.Left(); + + sal_uInt16 nColumns = 1; + bool bBookMode = false; + + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + + if ( nXDiff < nXOffset + nImageWidthSingle ) + { + mpImpl->mnState = 0; // single + nColumns = 1; + } + else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) + { + mpImpl->mnState = 1; // auto + nColumns = 0; + } + else + { + mpImpl->mnState = 2; // book + nColumns = 2; + bBookMode = true; + } + + // commit state change + SvxViewLayoutItem aViewLayout( nColumns, bBookMode ); + + ::com::sun::star::uno::Any a; + aViewLayout.QueryValue( a ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ViewLayout" )); + aArgs[0].Value = a; + + execute( aArgs ); + + return sal_True; +} diff --git a/sw/source/ui/utlui/zoomctrl.cxx b/sw/source/ui/utlui/zoomctrl.cxx new file mode 100644 index 000000000000..13cc237812d6 --- /dev/null +++ b/sw/source/ui/utlui/zoomctrl.cxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + + +#include "hintids.hxx" + +#ifndef _STATUS_HXX //autogen +#include <vcl/status.hxx> +#endif +#include <sfx2/app.hxx> +#include <svl/stritem.hxx> +#include <svx/zoomitem.hxx> + +#include "swtypes.hxx" +#include "zoomctrl.hxx" + + +SFX_IMPL_STATUSBAR_CONTROL( SwZoomControl, SvxZoomItem ); + + +SwZoomControl::SwZoomControl( sal_uInt16 _nSlotId, + sal_uInt16 _nId, + StatusBar& rStb ) : + SvxZoomStatusBarControl( _nSlotId, _nId, rStb ) +{ +} + +// ----------------------------------------------------------------------- + +SwZoomControl::~SwZoomControl() +{ +} + +// ----------------------------------------------------------------------- + +void SwZoomControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState ) +{ + if(SFX_ITEM_AVAILABLE == eState && pState->ISA( SfxStringItem )) + { + sPreviewZoom = ((const SfxStringItem*)pState)->GetValue(); + GetStatusBar().SetItemText( GetId(), sPreviewZoom ); + } + else + { + sPreviewZoom = aEmptyStr; + SvxZoomStatusBarControl::StateChanged(nSID, eState, pState); + } +} + +// ----------------------------------------------------------------------- + +void SwZoomControl::Paint( const UserDrawEvent& rUsrEvt ) +{ + if(!sPreviewZoom.Len()) + SvxZoomStatusBarControl::Paint(rUsrEvt); + else + GetStatusBar().SetItemText( GetId(), sPreviewZoom ); +} + +// ----------------------------------------------------------------------- + +void SwZoomControl::Command( const CommandEvent& rCEvt ) +{ + if(!sPreviewZoom.Len()) + SvxZoomStatusBarControl::Command(rCEvt); +} + + + + |