diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-05-26 17:43:14 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-05-27 11:13:02 +0200 |
commit | 35029b250318b3a4f02cef5194abdd3f68311c43 (patch) | |
tree | 5026ab2dab620dcdcae84e574483ce3c325e5a78 /sw/source/uibase/utlui | |
parent | f8d26c68e48e52265d4f20a1527bf52828c046ad (diff) |
sw: move sw/source/core/uibase to sw/source/uibase
It's too confusing to have UI code inside of core; the important part is
that it's separated from the optional UI code in swui library.
Change-Id: I640a52723d5802faf08f3b8eaa03cd937fd93449
Diffstat (limited to 'sw/source/uibase/utlui')
27 files changed, 13231 insertions, 0 deletions
diff --git a/sw/source/uibase/utlui/attrdesc.cxx b/sw/source/uibase/utlui/attrdesc.cxx new file mode 100644 index 000000000000..6c3889384182 --- /dev/null +++ b/sw/source/uibase/utlui/attrdesc.cxx @@ -0,0 +1,1248 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <i18nutil/unicode.hxx> +#include <svl/itemiter.hxx> +#include <vcl/svapp.hxx> +#include <vcl/settings.hxx> + +#include <editeng/itemtype.hxx> +#include <svtools/grfmgr.hxx> +#include <unotools/intlwrapper.hxx> +#include <comphelper/processfactory.hxx> +#include <rtl/ustrbuf.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> +#include <attrdesc.hrc> +#include <fmtftntx.hxx> +#include <fmtfollowtextflow.hxx> + +using namespace com::sun::star; + +TYPEINIT2(SwFmtCharFmt,SfxPoolItem,SwClient); + +// query the attribute descriptions +void SwAttrSet::GetPresentation( + SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText ) const +{ + static sal_Char const sComma[] = ", "; + + rText = OUString(); + OUString aStr; + if( Count() ) + { + SfxItemIter aIter( *this ); + const IntlWrapper rInt( ::comphelper::getProcessComponentContext(), + GetAppLanguageTag() ); + while( true ) + { + aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric, + ePresMetric, aStr, + &rInt ); + if( rText.getLength() && aStr.getLength() ) + rText += OUString(sComma); + rText += aStr; + if( aIter.IsAtEnd() ) + break; + aIter.NextItem(); + } + } +} + +SfxItemPresentation SwFmtCharFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + const SwCharFmt *pCharFmt = GetCharFmt(); + if ( pCharFmt ) + { + OUString aStr; + rText = OUString( SW_RESSTR( STR_CHARFMT ) ); + pCharFmt->GetPresentation( ePres, eCoreUnit, ePresUnit, aStr ); + rText = rText + "(" + aStr + ")"; + } + else + rText = OUString( SW_RESSTR( STR_NO_CHARFMT ) ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtAutoFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = OUString(); //TODO + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtINetFmt::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString &rText, const IntlWrapper* /*pIntl*/ ) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = OUString(); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtDrop::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText = OUString(); + 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 = OUString::number( GetChars() ) + " "; + } + rText = rText + + OUString( SW_RESSTR( STR_DROP_OVER ) ) + + " " + + OUString::number( GetLines() ) + + " " + + OUString( SW_RESSTR( STR_DROP_LINES ) ); + } + else + rText = SW_RESSTR( STR_NO_DROP_LINES ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwRegisterItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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; +} + +SfxItemPresentation SwNumRuleItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + return SFX_ITEM_PRESENTATION_NONE; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if( !GetValue().isEmpty() ) + rText = SW_RESSTR( STR_NUMRULE_ON ) + + "(" + GetValue() + ")"; + else + rText = SW_RESSTR( STR_NUMRULE_OFF ); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwParaConnectBorderItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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, + OUString& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + { + rText = OUString(); + break; + } + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + rText = SW_RESSTR( STR_FRM_WIDTH ) + " "; + if ( GetWidthPercent() ) + { + rText = rText + unicode::formatPercent(GetWidthPercent(), + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText = rText + ::GetMetricText( GetWidth(), eCoreUnit, ePresUnit, pIntl ) + + " " + ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + if ( ATT_VAR_SIZE != GetHeightSizeType() ) + { + const sal_uInt16 nId = ATT_FIX_SIZE == m_eFrmHeightType ? + STR_FRM_FIXEDHEIGHT : STR_FRM_MINHEIGHT; + rText = rText + ", " + SW_RESSTR( nId ) + " "; + if ( GetHeightPercent() ) + { + rText = rText + unicode::formatPercent(GetHeightPercent(), + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText = OUString( ::GetMetricText( GetHeight(), eCoreUnit, ePresUnit, pIntl ) ) + + " " + ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//Header for page formats. +//Client of FrmFmt which describes the header. + +SfxItemPresentation SwFmtHeader::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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; +} + +//Footer for page formats. +//Client of FrmFmt which describes the footer. + +SfxItemPresentation SwFmtFooter::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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, how and by what orientate the FlyFrm in the vertical? + +SfxItemPresentation SwFmtVertOrient::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + OUString& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( GetVertOrient() ) + { + case text::VertOrientation::NONE: + { + rText = rText + SW_RESSTR( STR_POS_Y ) + " " + + ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ) + + " " + ::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, how and by what orientate the FlyFrm in the horizontal? + +SfxItemPresentation SwFmtHoriOrient::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + OUString& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nId = 0; + switch ( GetHoriOrient() ) + { + case text::HoriOrientation::NONE: + { + rText = rText + SW_RESSTR( STR_POS_X ) + " " + + ::GetMetricText( GetPos(), eCoreUnit, ePresUnit, pIntl ) + + " " + ::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, Anchor of the free-flying frame + +SfxItemPresentation SwFmtAnchor::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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; +} + +//The ColumnDescriptor + +SfxItemPresentation SwFmtCol::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + sal_uInt16 nCnt = GetNumCols(); + if ( nCnt > 1 ) + { + rText = OUString(nCnt) + " " + SW_RESSTR( STR_COLUMNS ); + if ( COLADJ_NONE != GetLineAdj() ) + { + sal_uInt16 nWdth = sal_uInt16(GetLineWidth()); + rText = rText + " " + SW_RESSTR( STR_LINE_WIDTH ) + " " + + ::GetMetricText( nWdth, eCoreUnit, + SFX_MAPUNIT_POINT, pIntl ); + } + } + else + rText = OUString(); + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +//URL's and maps + +SfxItemPresentation SwFmtURL::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText = OUString(); + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + break; + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + if ( pMap ) + rText += "Client-Map"; + if ( !sURL.isEmpty() ) + { + if ( pMap ) + rText += " - "; + rText = rText + "URL: " + sURL; + if ( bIsServerMap ) + rText += " (Server-Map)"; + } + if ( !sTargetFrameName.isEmpty() ) + { + rText = rText + ", Target: " + sTargetFrameName; + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtEditInReadonly::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + rText = OUString(); + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString& /*rText*/, + const IntlWrapper* /*pIntl*/ +) const +{ + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwFmtFtnEndAtTxtEnd::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + break; + + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + { + switch( GetValue() ) + { + case FTNEND_ATPGORDOCEND: + break; + + case FTNEND_ATTXTEND: + break; + + case FTNEND_ATTXTEND_OWNNUMSEQ: + break; + } + } + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + return ePres; +} + +SfxItemPresentation SwFmtChain::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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) + + OUString::number( GetStartValue() ); + } + return ePres; + } + default:;//prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +SfxItemPresentation SwTextGridItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& rText, + const IntlWrapper* /*pIntl*/ +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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; +} + +SfxItemPresentation SwHeaderAndFooterEatSpacingItem::GetPresentation +( + SfxItemPresentation /*ePres*/, + SfxMapUnit /*eCoreUnit*/, + SfxMapUnit /*ePresUnit*/, + OUString& /*rText*/, + const IntlWrapper* /*pIntl*/ +) const +{ + return SFX_ITEM_PRESENTATION_NONE; +} + +// Graphic attributes + +SfxItemPresentation SwMirrorGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString& 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 = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwRotationGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &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.getLength() ) + rText = OUString(); + rText = rText + OUString::number( GetValue() ) + "\xB0"; + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwLuminanceGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &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.getLength() ) + rText = OUString(); + rText = rText + unicode::formatPercent(GetValue(), + Application::GetSettings().GetUILanguageTag()); + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwContrastGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &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.getLength() ) + rText = OUString(); + rText = rText + unicode::formatPercent(GetValue(), + Application::GetSettings().GetUILanguageTag()); + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwChannelGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &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.getLength() ) + rText = OUString(); + } + else if( rText.getLength() ) + rText = OUString(); + rText = rText + unicode::formatPercent(GetValue(), + Application::GetSettings().GetUILanguageTag()); + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwGammaGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &rText, const IntlWrapper* /*pIntl*/) const +{ + OUStringBuffer aText; + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + aText.append(SW_RESSTR(STR_GAMMA)); + aText.append(unicode::formatPercent(GetValue(), + Application::GetSettings().GetUILanguageTag())); + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + break; + } + rText = aText.makeStringAndClear(); + return ePres; +} + +SfxItemPresentation SwInvertGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &rText, const IntlWrapper* /*pIntl*/) const +{ + rText = OUString(); + switch( ePres ) + { + case SFX_ITEM_PRESENTATION_NAMELESS: + case SFX_ITEM_PRESENTATION_COMPLETE: + if( SFX_ITEM_PRESENTATION_COMPLETE == ePres ) + { + sal_uInt16 nId = 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*/, + OUString &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.getLength() ) + rText = OUString(); + rText = rText + unicode::formatPercent(GetValue(), + Application::GetSettings().GetUILanguageTag()); + break; + + default: + ePres = SFX_ITEM_PRESENTATION_NONE; + rText = OUString(); + break; + } + return ePres; +} + +SfxItemPresentation SwDrawModeGrf::GetPresentation( + SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/, + OUString &rText, const IntlWrapper* /*pIntl*/) const +{ + rText = OUString(); + 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*/, + OUString &rText, + const IntlWrapper* /*pIntl*/ ) const +{ + rText = OUString(); + 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; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/attrdesc.hrc b/sw/source/uibase/utlui/attrdesc.hrc new file mode 100644 index 000000000000..5f8f5b683657 --- /dev/null +++ b/sw/source/uibase/utlui/attrdesc.hrc @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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 overflow in #file, #line +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/attrdesc.src b/sw/source/uibase/utlui/attrdesc.src new file mode 100644 index 000000000000..cd14d9e6add0 --- /dev/null +++ b/sw/source/uibase/utlui/attrdesc.src @@ -0,0 +1,363 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "globals.hrc" +#include "attrdesc.hrc" + +// Strings for textual attributes. + +String STR_DROP_OVER +{ + 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 +{ + Text [ en-US ] = "Footer" ; +}; +String STR_NO_FOOTER +{ + 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 +{ + 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 +{ + Text [ en-US ] = "Fixed height:" ; +}; +String STR_FRM_MINHEIGHT +{ + 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 +{ + 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 +{ + Text [ en-US ] = "Max. footnote area:" ; +}; +String STR_EDIT_IN_READONLY +{ + 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"; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/bookctrl.cxx b/sw/source/uibase/utlui/bookctrl.cxx new file mode 100644 index 000000000000..65d8d090bd8a --- /dev/null +++ b/sw/source/uibase/utlui/bookctrl.cxx @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "hintids.hxx" + +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/event.hxx> +#include <vcl/status.hxx> +#include <vcl/menu.hxx> +#include "cmdid.h" +#include "swmodule.hxx" +#include "wrtsh.hxx" +#include "IMark.hxx" +#include "bookctrl.hxx" +#include <map> + +SFX_IMPL_STATUSBAR_CONTROL( SwBookmarkControl, SfxStringItem ); + +class BookmarkPopup_Impl : public PopupMenu +{ +public: + BookmarkPopup_Impl(); + + sal_uInt16 GetCurId() const { return nCurId; } + +private: + sal_uInt16 nCurId; + + virtual void Select() SAL_OVERRIDE; +}; + +BookmarkPopup_Impl::BookmarkPopup_Impl() : + PopupMenu(), + nCurId(USHRT_MAX) +{ +} + +void BookmarkPopup_Impl::Select() +{ + nCurId = GetCurItemId(); +} + +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(), OUString() ); + 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() ).isEmpty() ) + { + CaptureMouse(); + BookmarkPopup_Impl aPop; + SwWrtShell* pWrtShell = ::GetActiveWrtShell(); + if( pWrtShell && pWrtShell->getIDocumentMarkAccess()->getAllMarksCount() > 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(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/condedit.cxx b/sw/source/uibase/utlui/condedit.cxx new file mode 100644 index 000000000000..5aa7ff1abb0b --- /dev/null +++ b/sw/source/uibase/utlui/condedit.cxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sot/formats.hxx> + +#include <condedit.hxx> +#include <svx/dbaexchange.hxx> +#include <vcl/builder.hxx> + +using namespace ::svx; +using namespace ::com::sun::star::uno; + +ConditionEdit::ConditionEdit(Window* pParent, WinBits nStyle) + : Edit(pParent, nStyle) + , DropTargetHelper(this) + , bBrackets(true) + , bEnableDrop(true) +{ +} + +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeConditionEdit(Window *pParent, VclBuilder::stringmap &rMap) +{ + VclBuilder::ensureDefaultWidthChars(rMap); + return new ConditionEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK); +} + +// Drop possible, respectively format known? + +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 ) + { + TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); + + DataFlavorExVector& rVector = aData.GetDataFlavorExVector(); + if(OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR)) + { + ODataAccessDescriptor aColDesc = OColumnTransferable::extractColumnDescriptor( + aData); + OUString sDBName; + if (bBrackets) + sDBName += "["; + OUString sTmp; + sTmp = aColDesc.getDataSource(); + sDBName += sTmp; + sDBName += "."; + + aColDesc[daCommand] >>= sTmp; + sDBName += sTmp; + sDBName += "."; + + aColDesc[daColumnName] >>= sTmp; + sDBName += sTmp; + if (bBrackets) + sDBName += "]"; + + SetText( sDBName ); + nRet = DND_ACTION_COPY; + } + } + return nRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx new file mode 100644 index 000000000000..2e2e2a139ac6 --- /dev/null +++ b/sw/source/uibase/utlui/content.cxx @@ -0,0 +1,3524 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <comphelper/string.hxx> +#include <svl/urlbmk.hxx> +#include <osl/thread.h> +#include <tools/urlobj.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/help.hxx> +#include <vcl/settings.hxx> +#include <sot/formats.hxx> +#include <uiitems.hxx> +#include <fmtinfmt.hxx> +#include <txtinet.hxx> +#include <fmtfld.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <view.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> +#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 <SwRewriter.hxx> +#include <hints.hxx> +#include <numrule.hxx> +#include <swundo.hxx> +#include <ndtxt.hxx> +#include <fmtcntnt.hxx> +#include <PostItMgr.hxx> +#include <postithelper.hxx> +#include <redline.hxx> +#include <docary.hxx> +#include <o3tl/sorted_vector.hxx> +#include <svtools/treelistentry.hxx> + +#include "swabstdlg.hxx" +#include "globals.hrc" +#include <unomid.h> + +#include "navmgr.hxx" + +#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 + +class SwContentArr + : public o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>, + o3tl::find_partialorder_ptrequals> +{ +public: + ~SwContentArr() { DeleteAndDestroyAll(); } +}; + +bool SwContentTree::bIsInDrag = false; + +namespace +{ + static bool lcl_IsContent(const SvTreeListEntry* pEntry) + { + return ((const SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT; + } + + static bool lcl_IsContentType(const SvTreeListEntry* pEntry) + { + return ((const SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT; + } + + static bool lcl_FindShell(SwWrtShell* pShell) + { + bool bFound = false; + SwView *pView = SwModule::GetFirstView(); + while (pView) + { + if(pShell == &pView->GetWrtShell()) + { + bFound = true; + break; + } + pView = SwModule::GetNextView(pView); + } + return bFound; + } + + static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark) + { + return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK; + } +} + +// Content, contains names and reference at the content type. + +SwContent::SwContent(const SwContentType* pCnt, const OUString& rName, long nYPos) : + SwTypeNumber(CTYPE_CNT), + pParent(pCnt), + sContentName(rName), + nYPosition(nYPos), + bInvisible(false) +{ +} + +sal_uInt8 SwTypeNumber::GetTypeId() const +{ + return nTypeId; +} + +SwTypeNumber::~SwTypeNumber() +{ +} + +bool SwContent::IsProtect() const +{ + return false; +} + +bool SwPostItContent::IsProtect() const +{ + if (mbPostIt) + return pFld->IsProtect(); + else + return false; +} + +bool SwURLFieldContent::IsProtect() const +{ + return pINetAttr->IsProtect(); +} + +SwGraphicContent::~SwGraphicContent() +{ +} + +SwTOXBaseContent::~SwTOXBaseContent() +{ +} + +// Content type, knows it's contents and the 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), + bDataValid(false), + bEdit(false), + bDelete(true) +{ + Init(); +} + +void SwContentType::Init(bool* pbInvalidateWindow) +{ + // if the MemberCount is changing ... + sal_uInt16 nOldMemberCount = nMemberCount; + nMemberCount = 0; + switch(nContentType) + { + case CONTENT_TYPE_OUTLINE : + { + sTypeToken = "outline"; + 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 = false; + } + break; + + case CONTENT_TYPE_TABLE : + sTypeToken = "table"; + nMemberCount = pWrtShell->GetTblFrmFmtCount(true); + bEdit = true; + break; + + case CONTENT_TYPE_FRAME : + case CONTENT_TYPE_GRAPHIC : + case CONTENT_TYPE_OLE : + { + FlyCntType eType = FLYCNTTYPE_FRM; + sTypeToken = "frame"; + if(nContentType == CONTENT_TYPE_OLE) + { + eType = FLYCNTTYPE_OLE; + sTypeToken = "ole"; + } + else if(nContentType == CONTENT_TYPE_GRAPHIC) + { + eType = FLYCNTTYPE_GRF; + sTypeToken = "graphic"; + } + nMemberCount = pWrtShell->GetFlyCount(eType); + bEdit = 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 = OUString(); + bEdit = true; + } + break; + case CONTENT_TYPE_REGION : + { + SwContentArr* pOldMember = 0; + sal_uInt16 nOldRegionCount = 0; + bool bInvalidate = false; + if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + { + pOldMember = pMember; + nOldRegionCount = pOldMember->size(); + 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 OUString& 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( false, &aNullPt ).Top()); + + SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); + if( !pFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->insert(pCnt); + + sal_uInt16 nPos = pMember->size() - 1; + if(nOldRegionCount > nPos && + ((*pOldMember)[nPos])->IsInvisible() + != pCnt->IsInvisible()) + bInvalidate = true; + } + } + nMemberCount = pMember->size(); + sTypeToken = "region"; + bEdit = true; + bDelete = false; + if(pOldMember) + { + pOldMember->DeleteAndDestroyAll(); + delete pOldMember; + if(pbInvalidateWindow && bInvalidate) + *pbInvalidateWindow = true; + } + } + break; + case CONTENT_TYPE_INDEX: + { + nMemberCount = pWrtShell->GetTOXCount(); + bEdit = true; + bDelete = false; + } + break; + case CONTENT_TYPE_REFERENCE: + { + nMemberCount = pWrtShell->GetRefMarks( 0 ); + bDelete = false; + } + break; + case CONTENT_TYPE_URLFIELD: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + pMember->DeleteAndDestroyAll(); + + 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(), + '%', + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + &p->rINetAttr, + n ); + pMember->insert( pCnt ); + } + bEdit = true; + nOldMemberCount = nMemberCount; + bDelete = false; + } + break; + case CONTENT_TYPE_POSTIT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + pMember->DeleteAndDestroyAll(); + + SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); + if (aMgr) + { + for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) + { + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit + { + const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + OUString sEntry = aFmtFld->GetField()->GetPar2(); + sEntry = RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + aFmtFld, + nMemberCount); + pMember->insert(pCnt); + nMemberCount++; + } + } + } + } + sTypeToken = OUString(); + bEdit = true; + nOldMemberCount = nMemberCount; + } + break; + case CONTENT_TYPE_DRAWOBJECT: + { + sTypeToken = OUString(); + 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); + // #i51726# - all drawing objects can be named now + if (!pTemp->GetName().isEmpty()) + nMemberCount++; + } + } + } + break; + } + // ... then, the data can also no longer be valid, + // apart from those which have already been corrected, + // then nOldMemberCount is nevertheless not so old. + if( nOldMemberCount != nMemberCount ) + bDataValid = false; +} + +SwContentType::~SwContentType() +{ + delete pMember; +} + +// Deliver content, for that if necessary fill the list + +const SwContent* SwContentType::GetMember(sal_uInt16 nIndex) +{ + if(!bDataValid || !pMember) + { + FillMemberList(); + } + if(nIndex < pMember->size()) + return (*pMember)[nIndex]; + else + return 0; + +} + +void SwContentType::Invalidate() +{ + bDataValid = false; +} + +// Fill the List of contents + +void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged) +{ + SwContentArr* pOldMember = 0; + int nOldMemberCount = -1; + SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); + if(pMember && pbLevelOrVisibilityChanged) + { + pOldMember = pMember; + nOldMemberCount = pOldMember->size(); + pMember = new SwContentArr; + *pbLevelOrVisibilityChanged = false; + } + else if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + pMember->DeleteAndDestroyAll(); + 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 + { + OUString aEntry(comphelper::string::stripStart( + pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i), ' ')); + aEntry = SwNavigationPI::CleanEntry(aEntry); + SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel, + pWrtShell->IsOutlineMovable( i ), nPos ); + pMember->insert(pCnt);//, nPos); + // with the same number and existing "pOldMember" the + // old one is compared with the new OutlinePos. + // cast for Win16 + if(nOldMemberCount > (int)nPos && + ((SwOutlineContent*)(*pOldMember)[nPos])->GetOutlineLevel() != nLevel) + *pbLevelOrVisibilityChanged = true; + + nPos++; + } + } + + } + break; + + case CONTENT_TYPE_TABLE : + { + OSL_ENSURE(nMemberCount == pWrtShell->GetTblFrmFmtCount(true), + "MemberCount differs"); + Point aNullPt; + nMemberCount = pWrtShell->GetTblFrmFmtCount(true); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, true); + const OUString sTblName( rTblFmt.GetName() ); + + SwContent* pCnt = new SwContent(this, sTblName, + rTblFmt.FindLayoutRect(false, &aNullPt).Top() ); + if( !rTblFmt.GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + + pMember->insert(pCnt); + + if(nOldMemberCount > (int)i && + (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible()) + *pbLevelOrVisibilityChanged = 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; + OSL_ENSURE(nMemberCount == pWrtShell->GetFlyCount(eType), + "MemberCount differs"); + Point aNullPt; + nMemberCount = pWrtShell->GetFlyCount(eType); + for(sal_uInt16 i = 0; i < nMemberCount; i++) + { + const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType); + const OUString sFrmName = pFrmFmt->GetName(); + + SwContent* pCnt; + if(CONTENT_TYPE_GRAPHIC == nContentType) + { + OUString sLink; + pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt); + pCnt = new SwGraphicContent(this, sFrmName, + INetURLObject::decode( sLink, '%', + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + pFrmFmt->FindLayoutRect(false, &aNullPt).Top()); + } + else + { + pCnt = new SwContent(this, sFrmName, + pFrmFmt->FindLayoutRect(false, &aNullPt).Top() ); + } + if( !pFrmFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->insert(pCnt); + if(nOldMemberCount > (int)i && + (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible()) + *pbLevelOrVisibilityChanged = 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 OUString& rBkmName = ppBookmark->get()->GetName(); + //nYPos from 0 -> text::Bookmarks will be sorted alphabetically + SwContent* pCnt = new SwContent(this, rBkmName, 0); + pMember->insert(pCnt); + } + } + } + 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 ) + { + OUString 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( false, &aNullPt ).Top()); + if( !pFmt->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + pMember->insert(pCnt); + + sal_uInt16 nPos = pMember->size() - 1; + if(nOldMemberCount > nPos && + (*pOldMember)[nPos]->IsInvisible() + != pCnt->IsInvisible()) + *pbLevelOrVisibilityChanged = true; + } + } + nMemberCount = pMember->size(); + } + break; + case CONTENT_TYPE_REFERENCE: + { + std::vector<OUString> aRefMarks; + nMemberCount = pWrtShell->GetRefMarks( &aRefMarks ); + + for(std::vector<OUString>::const_iterator i = aRefMarks.begin(); i != aRefMarks.end(); ++i) + { + // References sorted alphabetically + SwContent* pCnt = new SwContent(this, *i, 0); + pMember->insert(pCnt); + } + } + 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(), + '%', + INetURLObject::DECODE_UNAMBIGUOUS, + RTL_TEXTENCODING_UTF8 ), + &p->rINetAttr, + n ); + pMember->insert( pCnt ); + } + } + 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 ); + OUString sTOXNm( pBase->GetTOXName() ); + + SwContent* pCnt = new SwTOXBaseContent( + this, sTOXNm, nTox, *pBase); + + if( !pBase->GetInfo( aAskItem ) && + !aAskItem.pObject ) // not visible + pCnt->SetInvisible(); + + pMember->insert( pCnt ); + sal_uInt16 nPos = pMember->size() - 1; + if(nOldMemberCount > nPos && + (*pOldMember)[nPos]->IsInvisible() + != pCnt->IsInvisible()) + *pbLevelOrVisibilityChanged = true; + } + } + break; + case CONTENT_TYPE_POSTIT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + pMember->DeleteAndDestroyAll(); + SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); + if (aMgr) + { + for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) + { + if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit + { + const SwFmtFld* aFmtFld = static_cast<const SwFmtFld*>((*i)->GetBroadCaster()); + if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && + (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) + { + OUString sEntry = aFmtFld->GetField()->GetPar2(); + sEntry = RemoveNewline(sEntry); + SwPostItContent* pCnt = new SwPostItContent( + this, + sEntry, + aFmtFld, + nMemberCount); + pMember->insert(pCnt); + nMemberCount++; + } + } + } + } + } + break; + case CONTENT_TYPE_DRAWOBJECT: + { + nMemberCount = 0; + if(!pMember) + pMember = new SwContentArr; + else if(!pMember->empty()) + pMember->DeleteAndDestroyAll(); + + 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); + // #i51726# - all drawing objects can be named now + if (!pTemp->GetName().isEmpty()) + { + SwContact* pContact = (SwContact*)pTemp->GetUserCall(); + long nYPos = 0; + const Point aNullPt; + if(pContact && pContact->GetFmt()) + nYPos = pContact->GetFmt()->FindLayoutRect(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)[i]->IsInvisible() != pCnt->IsInvisible() ) + *pbLevelOrVisibilityChanged = true; + } + } + } + } + break; + } + bDataValid = true; + if(pOldMember) + pOldMember->DeleteAndDestroyAll(); + +} + +// TreeListBox for content indicator + +SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) : + SvTreeListBox( pParent, rResId ), + + sSpace(OUString(" ")), + + 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(true), + bIsConstant(false), + bIsHidden(false), + bDocChgdInDragging(false), + bIsInternalDrag(false), + bIsRoot(false), + bIsIdleClear(false), + bIsLastReadOnly(false), + bIsOutlineMoveable(true), + bViewHasChanged(false), + bIsImageListInitialized(false), + bIsKeySpace(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 ); +} + +SwContentTree::~SwContentTree() +{ + Clear(); // If applicable erase content types previously. + bIsInDrag = false; +} + +OUString SwContentTree::GetEntryAltText( SvTreeListEntry* pEntry ) const +{ + if( pEntry == NULL) + return OUString(); + + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + if( pCnt == NULL || pCnt->GetParent() == NULL) + return OUString(); + + sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); + SdrObject* pTemp; + + switch(nJumpType) + { + case CONTENT_TYPE_DRAWOBJECT: + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + if (pDrawView) + { + SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); + SdrPage* pPage = pDrawModel->GetPage(0); + const sal_uInt32 nCount = pPage->GetObjCount(); + for( sal_uInt32 i=0; i< nCount; i++ ) + { + pTemp = pPage->GetObj(i); + sal_uInt16 nCmpId; + switch( pTemp->GetObjIdentifier() ) + { + case OBJ_GRUP: + case OBJ_TEXT: + case OBJ_TEXTEXT: + case OBJ_wegFITTEXT: + case OBJ_LINE: + case OBJ_RECT: + //caoxueqin added custom shape + case OBJ_CUSTOMSHAPE: + //end 2005/08/05 + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + case OBJ_CAPTION: + nCmpId = OBJ_GRUP; + break; + default: + nCmpId = pTemp->GetObjIdentifier(); + } + if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName()) + { + return pTemp->GetTitle(); + } + //Commented End + } + } + } + break; + case CONTENT_TYPE_GRAPHIC : + { + if( pActiveShell && pActiveShell->GetDoc() ) + { + const SwFlyFrmFmt* pFrmFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); + if( pFrmFmt ) + { +// SwNodeIndex aIdx( *(pFrmFmt->GetCntnt().GetCntntIdx()), 1 ); +// const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode(); +// if( pGrfNd ) +// return pGrfNd->GetAlternateText(); + return pFrmFmt->GetObjTitle(); + } + } + } + break; + case CONTENT_TYPE_OLE : + case CONTENT_TYPE_FRAME : + { + //Can't find the GetAlternateText function. Need to verify again. + const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); + if( pFlyFmt ) + return pFlyFmt->/*GetAlternateText*/GetName(); + } + break; + } + return OUString(); +} + +OUString SwContentTree::GetEntryLongDescription( SvTreeListEntry* pEntry ) const +{ + if( pEntry == NULL) + return OUString(); + + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + if( pCnt == NULL || pCnt->GetParent() == NULL) + return OUString(); + + sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); + SdrObject* pTemp; + + switch(nJumpType) + { + case CONTENT_TYPE_DRAWOBJECT: + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + if (pDrawView) + { + SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); + SdrPage* pPage = pDrawModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + for( sal_uInt32 i=0; i< nCount; i++ ) + { + pTemp = pPage->GetObj(i); + sal_uInt16 nCmpId; + switch( pTemp->GetObjIdentifier() ) + { + case OBJ_GRUP: + case OBJ_TEXT: + case OBJ_TEXTEXT: + case OBJ_wegFITTEXT: + case OBJ_LINE: + case OBJ_RECT: + //caoxueqin added custom shape + case OBJ_CUSTOMSHAPE: + //end 2005/08/05 + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + case OBJ_CAPTION: + nCmpId = OBJ_GRUP; + break; + default: + nCmpId = pTemp->GetObjIdentifier(); + } + if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName()) + { + return pTemp->GetDescription(); + } + //Commented End + } + } + } + break; + case CONTENT_TYPE_GRAPHIC : + case CONTENT_TYPE_OLE : + case CONTENT_TYPE_FRAME : + { + //Can't find the function "GetLongDescription". Need to verify again. + const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); + if( pFlyFmt ) + return pFlyFmt->GetDescription(); + } + break; + } + return OUString(); +} + +// 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(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(false); + bIsInternalDrag = false; +} + +// QueryDrop will be executed in the navigator + +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; +} + +// Drop will be executed in the navigator + +static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent* pContent) +{ + void* key = 0; + if( pTree && pContent ) + { + SwWrtShell* pShell = pTree->GetWrtShell(); + sal_Int32 nPos = pContent->GetYPos(); + if( nPos ) + { + key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ); + } + } + return key; +} + +sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + SvTreeListEntry* pEntry = pTargetEntry; + if( pEntry && ( nRootType == CONTENT_TYPE_OUTLINE ) && lcl_IsContent( pEntry ) ) + { + SwOutlineContent* pOutlineContent = ( SwOutlineContent* )( pEntry->GetUserData() ); + if( pOutlineContent ) + { + void* key = lcl_GetOutlineKey(this, pOutlineContent); + if( !mOutLineNodeMap[key] ) + { + while( pEntry->HasChildren() ) + { + SvTreeListEntry* pChildEntry = FirstChild( pEntry ); + while( pChildEntry ) + { + pEntry = pChildEntry; + pChildEntry = NextSibling( pChildEntry ); + } + } + pTargetEntry = pEntry; + } + } + } + if( bIsRoot ) + return SvTreeListBox::ExecuteDrop( rEvt ); + return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt); +} + +// Handler for Dragging and 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, OUString::number(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()); + // Insert the list of the open files + sal_uInt16 nId = 301; + const SwView* pActiveView = ::GetActiveView(); + SwView *pView = SwModule::GetFirstView(); + while (pView) + { + OUString 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) + { + OUString sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle(); + sHiddenEntry += " ( "; + sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST]; + sHiddenEntry += " )"; + 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]); + // Now edit + SvTreeListEntry* pEntry = 0; + // Edit only if the shown content is coming from the current view. + if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr()) + && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry)) + { + const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent(); + const sal_uInt16 nContentType = pContType->GetType(); + bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly(); + bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible(); + bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect(); + bool bEditable = pContType->IsEditable() && + ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); + bool bDeletable = pContType->IsDeletable() && + ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); + 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)) + { + bool bSubPop4 = false; + if(CONTENT_TYPE_INDEX == nContentType) + { + bSubPop4 = 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 = true; + pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); + pSubPop4->InsertItem(404, sUnprotTbl); + bool bFull = false; + OUString sTblName = ((SwContent*)pEntry->GetUserData())->GetName(); + 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 = 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 ); + pPop->InsertItem(4, pType->GetSingleName()); + pPop->SetPopupMenu(4, pSubPop4); + } + } + + pPop->SetPopupMenu( 1, pSubPop1 ); + pPop->SetPopupMenu( 2, pSubPop2 ); + pPop->SetPopupMenu( 3, pSubPop3 ); + return pPop; + +} + +// Indentation for outlines (and sections) + +sal_IntPtr SwContentTree::GetTabPos( SvTreeListEntry* 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(); //determined empirically +} + +// Content will be integrated into the Box only on demand. + +void SwContentTree::RequestingChildren( SvTreeListEntry* pParent ) +{ + // Is this a content type? + if(lcl_IsContentType(pParent)) + { + if(!pParent->HasChildren()) + { + OSL_ENSURE(pParent->GetUserData(), "no UserData?"); + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + + sal_uInt16 nCount = pCntType->GetMemberCount(); + // Add for outline plus/minus + if(pCntType->GetType() == CONTENT_TYPE_OUTLINE) + { + SvTreeListEntry* pChild = 0; + for(sal_uInt16 i = 0; i < nCount; i++) + { + const SwContent* pCnt = pCntType->GetMember(i); + if(pCnt) + { + sal_uInt16 nLevel = ((SwOutlineContent*)pCnt)->GetOutlineLevel(); + OUString sEntry = pCnt->GetName(); + if(sEntry.isEmpty()) + sEntry = sSpace; + if(!pChild || (nLevel == 0)) + pChild = InsertEntry(sEntry, pParent, + false, TREELIST_APPEND,(void*)pCnt); + else + { + //back search parent. + if(((SwOutlineContent*)pCntType->GetMember(i-1))->GetOutlineLevel() < nLevel) + pChild = InsertEntry(sEntry, pChild, + false, TREELIST_APPEND, (void*)pCnt); + else + { + pChild = Prev(pChild); + while(pChild && + lcl_IsContent(pChild) && + !(((SwOutlineContent*)pChild->GetUserData())->GetOutlineLevel() < nLevel) + ) + { + pChild = Prev(pChild); + } + if(pChild) + pChild = InsertEntry(sEntry, pChild, + false, TREELIST_APPEND, (void*)pCnt); + } + } + } + } + } + else + { + for(sal_uInt16 i = 0; i < nCount; i++) + { + const SwContent* pCnt = pCntType->GetMember(i); + if(pCnt) + { + OUString sEntry = pCnt->GetName(); + if (sEntry.isEmpty()) + sEntry = sSpace; + SvTreeListEntry* pChild = InsertEntry(sEntry, pParent, + false, TREELIST_APPEND, (void*)pCnt); + + //If object is marked , the corresponding entry is set true, + //else the corresponding entry is set false . + SdrObject * pObj = GetDrawingObjectsByContent(pCnt); + if(pChild) + pChild->SetMarked(false); + if(pObj) + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + SdrPageView* pPV = pDrawView->/*GetPageViewPvNum*/GetSdrPageView(/*0*/); + if( pPV ) + { + bool Marked = pDrawView->IsObjMarked(pObj); + if(Marked) + { + //sEntry += String::CreateFromAscii(" *"); + pChild->SetMarked(true); + } + + } + } + } + } + } + } + } +} + +//Get drawing Objects by content . +SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt) +{ + SdrObject *pRetObj = NULL; + sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); + switch(nJumpType) + { + case CONTENT_TYPE_DRAWOBJECT: + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + if (pDrawView) + { + SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); + SdrPage* pPage = pDrawModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + + for( sal_uInt32 i=0; i< nCount; i++ ) + { + SdrObject* pTemp = pPage->GetObj(i); + if( pTemp->GetName() == pCnt->GetName()) + { + pRetObj = pTemp; + break; + } + } + } + break; + } + default: + pRetObj = NULL; + } + return pRetObj; +} + +// Expand - Remember the state for content types. + +bool SwContentTree::Expand( SvTreeListEntry* pParent ) +{ + if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) || + (nRootType == CONTENT_TYPE_OUTLINE)) + { + 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; + if((pCntType->GetType() == CONTENT_TYPE_OUTLINE)) + { + std::map< void*, bool > mCurrOutLineNodeMap; + + SwWrtShell* pShell = GetWrtShell(); + bool bBool = SvTreeListBox::Expand(pParent); + SvTreeListEntry* pChild = Next(pParent); + while(pChild && lcl_IsContent(pChild) && pParent->HasChildren()) + { + if(pChild->HasChildren()) + { + sal_Int32 nPos = ((SwContent*)pChild->GetUserData())->GetYPos(); + void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ); + mCurrOutLineNodeMap.insert(std::map<void*, bool>::value_type( key, false ) ); + std::map<void*, bool>::iterator iter = mOutLineNodeMap.find( key ); + if( iter != mOutLineNodeMap.end() && mOutLineNodeMap[key]) + { + mCurrOutLineNodeMap[key] = true; + SvTreeListBox::Expand(pChild); + } + } + pChild = Next(pChild); + } + mOutLineNodeMap = mCurrOutLineNodeMap; + return bBool; + } + + } + else if( lcl_IsContent(pParent) ) + { + SwWrtShell* pShell = GetWrtShell(); + sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos(); + void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ); + mOutLineNodeMap[key] = true; + } + } + return SvTreeListBox::Expand(pParent); +} + +// Collapse - Remember the state for content types. + +bool SwContentTree::Collapse( SvTreeListEntry* pParent ) +{ + bool bRet(false); + if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) || + (nRootType == CONTENT_TYPE_OUTLINE)) + { + if(lcl_IsContentType(pParent)) + { + if(bIsRoot) + return bRet = false; + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + sal_uInt16 nAnd = 1 << pCntType->GetType(); + nAnd = ~nAnd; + if(bIsActive || bIsConstant) + { + nActiveBlock &= nAnd; + pConfig->SetActiveBlock(nActiveBlock); + } + else + nHiddenBlock &= nAnd; + } + else if( lcl_IsContent(pParent) ) + { + SwWrtShell* pShell = GetWrtShell(); + sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos(); + void* key = (void*)pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ); + mOutLineNodeMap[key] = false; + } + bRet = SvTreeListBox::Collapse(pParent); + } + else + bRet = SvTreeListBox::Collapse(pParent); + return bRet; +} + +// Also on double click will be initially opened only. + +IMPL_LINK_NOARG(SwContentTree, ContentDoubleClickHdl) +{ + SvTreeListEntry* pEntry = GetCurEntry(); + // Is it a content type? + OSL_ENSURE(pEntry, "no current entry!"); + if(pEntry) + { + if(lcl_IsContentType(pEntry) && !pEntry->HasChildren()) + RequestingChildren(pEntry); + else if(!lcl_IsContentType(pEntry) && (bIsActive || bIsConstant)) + { + if(bIsConstant) + { + pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop(); + } + //Jump to content type: + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + OSL_ENSURE( pCnt, "no UserData"); + GotoContent(pCnt); + if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME) + pActiveShell->EnterStdMode(); + } + } + return 0; +} + +// Show the file + +void SwContentTree::Display( bool bActive ) +{ + if(!bIsImageListInitialized) + { + aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP)); + + if ( GetDPIScaleFactor() > 1 ) + { + for (short i = 0; i < aEntryImages.GetImageCount(); i++) + { + OUString rImageName = aEntryImages.GetImageName(i); + BitmapEx b = aEntryImages.GetImage(rImageName).GetBitmapEx(); + //Use Lanczos because it looks better with circles / diagonals + b.Scale(GetDPIScaleFactor(), GetDPIScaleFactor(), BMP_SCALE_LANCZOS); + aEntryImages.ReplaceImage(rImageName, Image(b)); + } + } + bIsImageListInitialized = true; + } + // First read the selected entry to select it later again if necessary + // -> the user data here are no longer valid! + SvTreeListEntry* pOldSelEntry = FirstSelected(); + OUString sEntryName; // Name of the entry + sal_uInt16 nEntryRelPos = 0; // relative position to their parent + sal_uInt32 nOldEntryCount = GetEntryCount(); + sal_Int32 nOldScrollPos = 0; + if(pOldSelEntry) + { + ScrollBar* pVScroll = GetVScroll(); + if(pVScroll && pVScroll->IsVisible()) + nOldScrollPos = pVScroll->GetThumbPos(); + + sEntryName = GetEntryText(pOldSelEntry); + SvTreeListEntry* pParantEntry = pOldSelEntry; + while( GetParent(pParantEntry)) + { + pParantEntry = GetParent(pParantEntry); + } + if(GetParent(pOldSelEntry)) + { + nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(pParantEntry)); + } + } + Clear(); + SetUpdateMode( false ); + if(bActive && !bIsConstant && !bIsActive) + bIsActive = bActive; + bIsHidden = !bActive; + SwWrtShell* pShell = GetWrtShell(); + bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True; + if(bReadOnly != bIsLastReadOnly) + { + bIsLastReadOnly = bReadOnly; + 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) + { + SvTreeListEntry* 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 ); + + OUString sEntry = (*ppContentT)->GetName(); + SvTreeListEntry* pEntry; + const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType); + bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount(); + pEntry = InsertEntry(sEntry, rImage, rImage, + 0, bChOnDemand, TREELIST_APPEND, (*ppContentT)); + if(nCntType == nLastSelType) + pSelEntry = pEntry; + sal_Int32 nExpandOptions = bIsActive || bIsConstant ? + nActiveBlock : + nHiddenBlock; + if(nExpandOptions & (1 << nCntType)) + { + Expand(pEntry); + if(nEntryRelPos && nCntType == nLastSelType) + { + // Now maybe select a additional child + SvTreeListEntry* pChild = pEntry; + SvTreeListEntry* pTemp = 0; + sal_uInt16 nPos = 1; + while(0 != (pChild = Next(pChild))) + { + // The old text will be slightly favored + 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); + SvTreeListEntry* pParent = InsertEntry( + (*ppRootContentT)->GetName(), rImage, rImage, + 0, false, TREELIST_APPEND, *ppRootContentT); + + if(nRootType != CONTENT_TYPE_OUTLINE) + { + for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ ) + { + const SwContent* pCnt = (*ppRootContentT)->GetMember(i); + if(pCnt) + { + OUString sEntry = pCnt->GetName(); + if(sEntry.isEmpty()) + sEntry = sSpace; + InsertEntry( sEntry, pParent, + false, TREELIST_APPEND, (void*)pCnt); + } + } + } + else + RequestingChildren(pParent); + Expand(pParent); + if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive ) + { + // find out where the cursor is + const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL); + SvTreeListEntry* pEntry = First(); + + while( 0 != (pEntry = Next(pEntry)) ) + { + if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos) + { + MakeVisible(pEntry); + Select(pEntry); + } + } + + } + else + { + // Now maybe select a additional child + SvTreeListEntry* pChild = pParent; + SvTreeListEntry* pTemp = 0; + sal_uInt16 nPos = 1; + while(0 != (pChild = Next(pChild))) + { + // The old text will be slightly favored + if(sEntryName == GetEntryText(pChild) || + nPos == nEntryRelPos ) + { + pSelEntry = pChild; + break; + } + pTemp = pChild; + nPos++; + } + if(!pSelEntry) + pSelEntry = pTemp; + if(pSelEntry) + { + MakeVisible(pSelEntry); + Select(pSelEntry); + } + } + } + } + SetUpdateMode( true ); + ScrollBar* pVScroll = GetVScroll(); + if(GetEntryCount() == nOldEntryCount && + nOldScrollPos && pVScroll && pVScroll->IsVisible() + && pVScroll->GetThumbPos() != nOldScrollPos) + { + sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos; + ScrollOutputArea( (short)nDelta ); + } + +} + +// In the Clear the content types have to be deleted, also. + +void SwContentTree::Clear() +{ + SetUpdateMode(false); + SvTreeListBox::Clear(); + SetUpdateMode(true); +} + +bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, + sal_Int8& rDragMode ) +{ + SwWrtShell* pWrtShell = GetWrtShell(); + OSL_ENSURE(pWrtShell, "no Shell!"); + SvTreeListEntry* pEntry = GetCurEntry(); + if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell) + return false; + OUString sEntry; + SwContent* pCnt = ((SwContent*)pEntry->GetUserData()); + + sal_uInt16 nActType = pCnt->GetParent()->GetType(); + OUString sUrl; + bool bOutline = false; + OUString sOutlineText; + switch( nActType ) + { + case CONTENT_TYPE_OUTLINE: + { + sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos(); + OSL_ENSURE(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(), + "outlinecnt changed"); + + // 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 += OUString::number( nVal ); + sEntry += "."; + } + } + sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false); + sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true); + bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable(); + bOutline = true; + } + } + break; + case CONTENT_TYPE_POSTIT: + case CONTENT_TYPE_INDEX: + case CONTENT_TYPE_REFERENCE : + // cannot inserted as URL or as koennen weder als URL noch als region + break; + case CONTENT_TYPE_URLFIELD: + sUrl = ((SwURLFieldContent*)pCnt)->GetURL(); + // no 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); + } + + bool bRet = false; + if(!sEntry.isEmpty()) + { + const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell(); + if(sUrl.isEmpty()) + { + if(pDocShell->HasName()) + { + SfxMedium* pMedium = pDocShell->GetMedium(); + sUrl = pMedium->GetURLObject().GetURLNoMark(); + // only if a primarily link shall be integrated. + bRet = true; + } + else if( nActType == CONTENT_TYPE_REGION || + nActType == CONTENT_TYPE_BOOKMARK ) + { + // For field and bookmarks a link is also allowed + // without a filename into its own document. + bRet = true; + } + else if(bIsConstant && + ( !::GetActiveView() || + pActiveShell != ::GetActiveView()->GetWrtShellPtr())) + { + // Urls of inactive views cannot dragged without + // file names, also. + bRet = false; + } + else + { + bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE; + rDragMode = DND_ACTION_MOVE; + } + + const OUString& rToken = pCnt->GetParent()->GetTypeToken(); + sUrl += "#"; + sUrl += sEntry; + if(!rToken.isEmpty()) + { + sUrl += OUString(cMarkSeparator); + sUrl += rToken; + } + } + else + bRet = true; + + if( bRet ) + { + // In Outlines of heading text must match + // the real number into the description. + if(bOutline) + sEntry = sOutlineText; + + { + NaviContentBookmark aBmk( sUrl, sEntry, + GetParentWindow()->GetRegionDropMode(), + pDocShell); + aBmk.Copy( rTransfer ); + } + + // An INetBookmark must a be delivered to foreign DocShells + if( pDocShell->HasName() ) + { + INetBookmark aBkmk( sUrl, sEntry ); + rTransfer.CopyINetBookmark( aBkmk ); + } + } + } + return bRet; +} + +// Switch the display to Root + +bool SwContentTree::ToggleToRoot() +{ + if(!bIsRoot) + { + SvTreeListEntry* 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 = true; + Display(bIsActive || bIsConstant); + } + } + else + { + nRootType = USHRT_MAX; + bIsRoot = false; + FindActiveTypeAndRemoveUserData(); + Display(bIsActive || bIsConstant); + if( bIsKeySpace ) + { + HideFocus(); + ShowFocus( oldRectangle); + bIsKeySpace = false; + } + } + pConfig->SetRootType( nRootType ); + GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot ? sal_True : sal_False); + return bIsRoot; +} + +// Check if the displayed content is valid. + +bool SwContentTree::HasContentChanged() +{ + +// - Run through the local array and the Treelistbox in parallel. +// - Are the records not expanded, they are discarded only in the array +// and the content type will be set as the new UserData. +// - Is the root mode is active only this will be updated. + +// Valid for the displayed content types is: +// the Memberlist will be erased and the membercount will be updated +// If content will be checked, the memberlists will be replenished +// at the same time. Once a difference occurs it will be only replenished +// no longer checked. Finally, the box is filled again. + + bool bRepaint = false; + bool bInvalidate = false; + + if(!bIsActive && ! bIsConstant) + { + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + if(aActiveContentArr[i]) + aActiveContentArr[i]->Invalidate(); + } + } + else if(bIsRoot) + { + bool bOutline = false; + SvTreeListEntry* pEntry = First(); + if(!pEntry) + bRepaint = true; + else + { + sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType(); + bOutline = nRootType == CONTENT_TYPE_OUTLINE; + SwContentType* pArrType = aActiveContentArr[nType]; + if(!pArrType) + bRepaint = true; + else + { + sal_uInt16 nSelLevel = USHRT_MAX; + + SvTreeListEntry* pFirstSel; + if(bOutline && + 0 != ( pFirstSel = FirstSelected()) && + lcl_IsContent(pFirstSel)) + { + nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel(); + SwWrtShell* pSh = GetWrtShell(); + sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); + if (nOutlinePos != USHRT_MAX && + pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel) + bRepaint = true; + } + + pArrType->Init(&bInvalidate); + pArrType->FillMemberList(); + pEntry->SetUserData((void*)pArrType); + if(!bRepaint) + { + if(GetChildCount(pEntry) != pArrType->GetMemberCount()) + bRepaint = 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); + OUString sEntryText = GetEntryText(pEntry); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && pCnt->GetName().isEmpty())) + bRepaint = true; + } + } + } + } + } + if( !bRepaint && bOutline ) + { + // find out where the cursor is + const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); + SvTreeListEntry* pFirstEntry = First(); + + while( 0 != (pFirstEntry = Next(pFirstEntry)) ) + { + if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos) + { + if(FirstSelected() != pFirstEntry) + { + Select(pFirstEntry); + MakeVisible(pFirstEntry); + } + } + } + + } + + } + else + { + SvTreeListEntry* pEntry = First(); + while ( pEntry ) + { + bool bNext = true; // at least a next must be + SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData(); + sal_uInt16 nType = pTreeType->GetType(); + sal_uInt16 nTreeCount = pTreeType->GetMemberCount(); + SwContentType* pArrType = aActiveContentArr[nType]; + if(!pArrType) + bRepaint = true; + else + { + pArrType->Init(&bInvalidate); + pEntry->SetUserData((void*)pArrType); + if(IsExpanded(pEntry)) + { + bool bLevelOrVisibiblityChanged = 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_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); + if((nType == CONTENT_TYPE_OUTLINE) && bLevelOrVisibiblityChanged) + bRepaint = true; + if(bLevelOrVisibiblityChanged) + bInvalidate = true; + + if(nChildCount != pArrType->GetMemberCount()) + bRepaint = true; + else + { + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + pEntry = Next(pEntry); + bNext = false; + const SwContent* pCnt = pArrType->GetMember(j); + pEntry->SetUserData((void*)pCnt); + OUString sEntryText = GetEntryText(pEntry); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && pCnt->GetName().isEmpty())) + bRepaint = true; + } + } + + } + else if(pEntry->HasChildren()) + { + // was the entry once opened, then must also the + // invisible records be examined. + // At least the user data must be updated. + bool bLevelOrVisibiblityChanged = 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); + bool bRemoveChildren = false; + sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); + if( nChildCount != pArrType->GetMemberCount() ) + { + bRemoveChildren = true; + } + else + { + SvTreeListEntry* pChild = FirstChild(pEntry); + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + const SwContent* pCnt = pArrType->GetMember(j); + pChild->SetUserData((void*)pCnt); + OUString sEntryText = GetEntryText(pChild); + if( sEntryText != pCnt->GetName() && + !(sEntryText == sSpace && pCnt->GetName().isEmpty())) + bRemoveChildren = true; + pChild = Next(pChild); + } + } + if(bRemoveChildren) + { + SvTreeListEntry* pChild = FirstChild(pEntry); + SvTreeListEntry* pRemove = pChild; + for(sal_uInt16 j = 0; j < nChildCount; j++) + { + pChild = Next(pRemove); + GetModel()->Remove(pRemove); + pRemove = pChild; + } + } + if(!nChildCount) + { + pEntry->EnableChildrenOnDemand(false); + InvalidateEntry(pEntry); + } + + } + else if((nTreeCount != 0) + != (pArrType->GetMemberCount()!=0)) + { + bRepaint = true; + } + } + // The Root-Entry has to be found now + while( pEntry && (bNext || GetParent(pEntry ) )) + { + pEntry = Next(pEntry); + bNext = false; + } + } + } + if(!bRepaint && bInvalidate) + Invalidate(); + return bRepaint; +} + +// Before any data will be deleted, the last active entry has to be found. +// After this the UserData will be deleted + +void SwContentTree::FindActiveTypeAndRemoveUserData() +{ + SvTreeListEntry* pEntry = FirstSelected(); + if(pEntry) + { + // If clear is called by TimerUpdate: + // Only for root can the validity of the UserData be guaranteed. + SvTreeListEntry* pParent; + while(0 != (pParent = GetParent(pEntry))) + pEntry = pParent; + if(pEntry->GetUserData() && lcl_IsContentType(pEntry)) + nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType(); + } + pEntry = First(); + while(pEntry) + { + pEntry->SetUserData(0); + pEntry = Next(pEntry); + } +} + +// After a file is dropped on the Navigator, +// the new shell will be set. + +void SwContentTree::SetHiddenShell(SwWrtShell* pSh) +{ + pHiddenShell = pSh; + bIsHidden = true; + bIsActive = bIsConstant = false; + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aHiddenContentArr[i]); + } + Display(bIsActive); + + GetParentWindow()->UpdateListBox(); +} + +// Document change - set new Shell + +void SwContentTree::SetActiveShell(SwWrtShell* pSh) +{ + if(bIsInternalDrag) + bDocChgdInDragging = true; + bool bClear = pActiveShell != pSh; + if(bIsActive && bClear) + { + pActiveShell = pSh; + FindActiveTypeAndRemoveUserData(); + Clear(); + } + else if(bIsConstant) + { + if(!lcl_FindShell(pActiveShell)) + { + pActiveShell = pSh; + bIsActive = true; + bIsConstant = false; + bClear = true; + } + } + // Only if it is the active view, the array will be deleted and + // the screen filled new. + if(bIsActive && bClear) + { + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aActiveContentArr[i]); + } + Display(true); + } +} + +// Set an open view as active. + +void SwContentTree::SetConstantShell(SwWrtShell* pSh) +{ + pActiveShell = pSh; + bIsActive = false; + bIsConstant = true; + FindActiveTypeAndRemoveUserData(); + for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) + { + DELETEZ(aActiveContentArr[i]); + } + Display(true); +} + +// Execute commands of the Navigator + +void SwContentTree::ExecCommand(sal_uInt16 nCmd, bool bModifier) +{ + bool nMove = false; + switch( nCmd ) + { + case FN_ITEM_DOWN: + case FN_ITEM_UP: + nMove = true; + //fall-through + 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); + SvTreeListEntry* 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); // If text selection != box selection + 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 ); + // Set cursor back to the current position + pShell->GotoOutline( nActPos + nDir); + } + else if(bModifier && pFirstEntry) + { + sal_uInt16 nActEndPos = nActPos; + SvTreeListEntry* 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) + { + // If the last entry is to be moved it is over! + if(pEntry && CONTENT_TYPE_OUTLINE == + ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()) + { + // pEntry now points to the following entry of the last + // selected entry. + nDest = nActEndPos; + nDest++; + // here needs to found the next record after next. + // The selection must be inserted in front of. + while(pEntry ) + { + pEntry = Next(pEntry); + // nDest++ may only executed if pEntry != 0 + if(pEntry && nDest++ && + ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()|| + CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())) + { + nDest--; + break; + } + } + nDir = nDest - nActEndPos; + // If no entry was found which corresponds the condition + // of the previously paste, it needs to be pushed slightly less. + } + 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 ); + //Set cursor back to the current position + pShell->GotoOutline( nActPos + nDir); + } + } + } + else + { + if( !pShell->IsProtectedOutlinePara() ) + pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 ); + } + + pShell->ClearMark(); + pShell->Pop(false); // Cursor is now back at the current superscription. + pShell->EndAllAction(); + if(aActiveContentArr[CONTENT_TYPE_OUTLINE]) + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(true); + if(!bIsRoot) + { + const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); + SvTreeListEntry* pFirst = First(); + + while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) + { + if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos) + { + Select(pFirst); + MakeVisible(pFirst); + } + } + } + } + } + } +} + +void SwContentTree::ShowTree() +{ + aUpdTimer.Start(); + SvTreeListBox::Show(); +} + +// folded together will not be geidled + +void SwContentTree::HideTree() +{ + aUpdTimer.Stop(); + SvTreeListBox::Hide(); +} + +// No idle with focus or while dragging. + +IMPL_LINK_NOARG(SwContentTree, TimerUpdate) +{ + // No update while drag and drop. + // Query view because the Navigator is cleared too late. + SwView* pView = GetParentWindow()->GetCreateView(); + if( (!HasFocus() || bViewHasChanged) && + !bIsInDrag && !bIsInternalDrag && pView && + pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() ) + { + bViewHasChanged = false; + bIsIdleClear = 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(true); + } + } + else if(!pView && bIsActive && !bIsIdleClear) + { + if(pActiveShell) + SetActiveShell(0); + Clear(); + bIsIdleClear = true; + } + return 0; +} + +DragDropMode SwContentTree::NotifyStartDrag( + TransferDataContainer& rContainer, + SvTreeListEntry* 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 = false; + bIsInternalDrag = true; + return eMode; +} +// After the drag the current paragraph will be moved w i t h the children. + +TriState SwContentTree::NotifyMoving( SvTreeListEntry* pTarget, + SvTreeListEntry* pEntry, SvTreeListEntry*& , 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 && // Not all layers are displayed. + nTargetPos != USHRT_MAX) + { + SvTreeListEntry* pNext = Next(pTarget); + if(pNext) + nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1; + else + nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1; + + } + + OSL_ENSURE( pEntry && + lcl_IsContent(pEntry),"Source == 0 or Source has no Content" ); + GetParentWindow()->MoveOutline( nSourcePos, + nTargetPos, + true); + + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(true); + } + //TreeListBox will be reloaded from the document + return TRISTATE_FALSE; +} + +// After the drag the current paragraph will be moved w i t h o u t the children. + +TriState SwContentTree::NotifyCopying( SvTreeListEntry* pTarget, + SvTreeListEntry* pEntry, SvTreeListEntry*& , 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 && // Not all layers are displayed. + nTargetPos != USHRT_MAX) + { + SvTreeListEntry* pNext = Next(pTarget); + if(pNext) + nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1; + else + nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1; + + } + + OSL_ENSURE( pEntry && + lcl_IsContent(pEntry),"Source == 0 or Source has no Content" ); + GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, false); + + //TreeListBox will be reloaded from the document + aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); + Display(true); + } + return TRISTATE_FALSE; +} + +// No drop before the first entry - it's a SwContentType + +bool SwContentTree::NotifyAcceptDrop( SvTreeListEntry* pEntry) +{ + return pEntry != 0; +} + +// If a Ctrl + DoubleClick are executed in an open area, +// then the base function of the control is to be called. + +void SwContentTree::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Point aPos( rMEvt.GetPosPixel()); + SvTreeListEntry* pEntry = GetEntry( aPos, true ); + if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) + Control::MouseButtonDown( rMEvt ); + else + SvTreeListBox::MouseButtonDown( rMEvt ); +} + +// Update immediately + +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(true); + } + } + else if(bIsActive) + Clear(); + SvTreeListBox::GetFocus(); +} + +void SwContentTree::KeyInput(const KeyEvent& rEvent) +{ + const KeyCode aCode = rEvent.GetKeyCode(); + if(aCode.GetCode() == KEY_RETURN) + { + SvTreeListEntry* pEntry = FirstSelected(); + if ( pEntry ) + { + switch(aCode.GetModifier()) + { + case KEY_MOD2: + // Switch boxes + GetParentWindow()->ToggleTree(); + break; + case KEY_MOD1: + // Switch RootMode + 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()) + { + SvTreeListEntry* pEntry = FirstSelected(); + if(pEntry && + lcl_IsContent(pEntry) && + ((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() && + !pActiveShell->GetView().GetDocShell()->IsReadOnly()) + { + EditEntry(pEntry, EDIT_MODE_DELETE); + bViewHasChanged = true; + GetParentWindow()->UpdateListBox(); + TimerUpdate(&aUpdTimer); + GrabFocus(); + } + } + //Make KEY_SPACE has same function as DoubleClick , + //and realize multi-selection . + else if(aCode.GetCode() == KEY_SPACE && 0 == aCode.GetModifier()) + { + + SvTreeListEntry* pEntry = GetCurEntry(); + if( GetChildCount( pEntry ) == 0 ) + bIsKeySpace = true; + Point tempPoint = GetEntryPosition( pEntry );//Change from "GetEntryPos" to "GetEntryPosition" for acc migration + oldRectangle = GetFocusRect( pEntry,tempPoint.Y() ); + + if(pEntry) + { + if(bIsActive || bIsConstant) + { + if(bIsConstant) + { + pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop(); + } + + SwContent* pCnt = (SwContent*)pEntry->GetUserData(); + + sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); + switch(nJumpType) + { + case CONTENT_TYPE_DRAWOBJECT: + { + SdrView* pDrawView = pActiveShell->GetDrawView(); + if (pDrawView) + { + pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration + + SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); + SdrPage* pPage = pDrawModel->GetPage(0); + sal_uInt32 nCount = pPage->GetObjCount(); + bool hasObjectMarked = false; + + SdrObject* pObject = NULL; + pObject = GetDrawingObjectsByContent( pCnt ); + if( pObject ) + { + SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/); + if( pPV ) + { + bool bUnMark = pDrawView->IsObjMarked(pObject); + pDrawView->MarkObj( pObject, pPV, bUnMark); + + } + } + for( sal_uInt32 i=0; i< nCount; i++ ) + { + SdrObject* pTemp = pPage->GetObj(i); + bool bMark = pDrawView->IsObjMarked(pTemp); + switch( pTemp->GetObjIdentifier() ) + { + case OBJ_GRUP: + case OBJ_TEXT: + case OBJ_TEXTEXT: + case OBJ_wegFITTEXT: + case OBJ_LINE: + case OBJ_RECT: + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + case OBJ_CAPTION: + case OBJ_CUSTOMSHAPE: + if( bMark ) + hasObjectMarked = true; + break; + default: + if ( bMark ) + { + SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/); + if (pPV) + { + pDrawView->MarkObj(pTemp, pPV, true); + } + } + } + //mod end + } + if ( !hasObjectMarked ) + { + SwEditWin& pEditWindow = + pActiveShell->GetView().GetEditWin(); + if( &pEditWindow ) + { + KeyCode tempKeycode( KEY_ESCAPE ); + KeyEvent rKEvt( 0 , tempKeycode ); + ((Window*)&pEditWindow)->KeyInput( rKEvt ); + + } + //rView.GetEditWin().GrabFocus(); + } + } + } + break; + } + + bViewHasChanged = true; + } + } + + } + else + SvTreeListBox::KeyInput(rEvent); + +} + +void SwContentTree::RequestHelp( const HelpEvent& rHEvt ) +{ + bool bCallBase = true; + if( rHEvt.GetMode() & HELPMODE_QUICK ) + { + Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); + SvTreeListEntry* pEntry = GetEntry( aPos ); + if( pEntry ) + { + sal_uInt16 nType; + bool bBalloon = false; + bool bContent = false; + void* pUserData = pEntry->GetUserData(); + if(lcl_IsContentType(pEntry)) + nType = ((SwContentType*)pUserData)->GetType(); + else + { + nType = ((SwContent*)pUserData)->GetParent()->GetType(); + bContent = true; + } + OUString sEntry; + bool bRet = false; + if(bContent) + { + switch( nType ) + { + case CONTENT_TYPE_URLFIELD: + sEntry = ((SwURLFieldContent*)pUserData)->GetURL(); + bRet = true; + break; + + case CONTENT_TYPE_POSTIT: + sEntry = ((SwPostItContent*)pUserData)->GetName(); + bRet = true; + if(Help::IsBalloonHelpEnabled()) + bBalloon = true; + break; + case CONTENT_TYPE_OUTLINE: + sEntry = ((SwOutlineContent*)pUserData)->GetName(); + bRet = true; + break; + case CONTENT_TYPE_GRAPHIC: + sEntry = ((SwGraphicContent*)pUserData)->GetLink(); +#if OSL_DEBUG_LEVEL > 1 + sEntry += " "; + sEntry += OUString::number( + ((SwGraphicContent*)pUserData)->GetYPos()); +#endif + bRet = true; + break; +#if OSL_DEBUG_LEVEL > 1 + case CONTENT_TYPE_TABLE: + case CONTENT_TYPE_FRAME: + sEntry = OUString::number( + ((SwContent*)pUserData)->GetYPos() ); + bRet = true; + break; +#endif + } + if(((SwContent*)pUserData)->IsInvisible()) + { + if(!sEntry.isEmpty()) + sEntry += ", "; + sEntry += sInvisible; + bRet = true; + } + } + else + { + sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount(); + sEntry = OUString::number(nMemberCount); + sEntry += " "; + sEntry += nMemberCount == 1 + ? ((SwContentType*)pUserData)->GetSingleName() + : ((SwContentType*)pUserData)->GetName(); + bRet = true; + } + if(bRet) + { + SvLBoxTab* pTab; + SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); + if (pItem && SV_ITEM_ID_LBOXSTRING == pItem->GetType()) + { + 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 = false; + } + } + else + { + Help::ShowQuickHelp( this, Rectangle(), OUString(), 0 ); + bCallBase = false; + } + } + } + if( bCallBase ) + Window::RequestHelp( rHEvt ); +} + +void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) +{ + SvTreeListEntry* 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; + // Edit entry + 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; + } + //Display + default: + 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 = false; + Display(nSelectedPopupEntry == 1); + } + } + } + GetParentWindow()->UpdateListBox(); +} + +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); +} + +// Mode Change: Show dropped Doc + +void SwContentTree::ShowHiddenShell() +{ + if(pHiddenShell) + { + bIsConstant = false; + bIsActive = false; + Display(false); + } +} + +// Mode Change: Show active view + +void SwContentTree::ShowActualView() +{ + bIsActive = true; + bIsConstant = false; + Display(true); + GetParentWindow()->UpdateListBox(); +} + +// Here the buttons for moving outlines are en-/disabled. +bool SwContentTree::Select( SvTreeListEntry* pEntry, bool bSelect ) +{ + if(!pEntry) + return false; + bool bEnable = false; + SvTreeListEntry* pParentEntry = GetParent(pEntry); + while(pParentEntry && (!lcl_IsContentType(pParentEntry))) + { + pParentEntry = GetParent(pParentEntry); + } + if (!bIsLastReadOnly) + { + if (!IsVisible()) + bEnable = true; + else if (pParentEntry) + { + if ((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) || + (lcl_IsContent(pEntry) && + ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)) + { + bEnable = 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); +} + +void SwContentTree::SetRootType(sal_uInt16 nType) +{ + nRootType = nType; + bIsRoot = true; + pConfig->SetRootType( nRootType ); +} + +OUString SwContentType::RemoveNewline(const OUString& rEntry) +{ + if (rEntry.isEmpty()) + return rEntry; + + OUStringBuffer aEntry(rEntry); + for (sal_Int32 i = 0; i < rEntry.getLength(); ++i) + if(aEntry[i] == 10 || aEntry[i] == 13) + aEntry[i] = 0x20; + + return aEntry.makeStringAndClear(); +} + +void SwContentTree::EditEntry(SvTreeListEntry* 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(); + OUString sTable = SW_RES(STR_TABLE_NAME); + SwRewriter aRewriterTableName; + aRewriterTableName.AddRule(UndoArg1, SW_RES(STR_START_QUOTE)); + aRewriterTableName.AddRule(UndoArg2, pCnt->GetName()); + aRewriterTableName.AddRule(UndoArg3, SW_RES(STR_END_QUOTE)); + sTable = aRewriterTableName.Apply(sTable); + + SwRewriter aRewriter; + aRewriter.AddRule(UndoArg1, 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(); + } + } + 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(); + OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); + + AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg(this, xNamed, xNameAccess); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + if(xSecond.is()) + pDlg->SetAlternativeAccess( xSecond, xThird); + + OUString sForbiddenChars; + if(CONTENT_TYPE_BOOKMARK == nType) + { + sForbiddenChars = "/\\@:*?\";,.#"; + } + else if(CONTENT_TYPE_TABLE == nType) + { + sForbiddenChars = " .<>"; + } + pDlg->SetForbiddenChars(sForbiddenChars); + pDlg->Execute(); + delete pDlg; + } +} + +void SwContentTree::GotoContent(SwContent* pCnt) +{ + pActiveShell->EnterStdMode(); + + bool bSel = 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 = 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, true, 1, false); + pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, true ); + } + + } + break; + case CONTENT_TYPE_REFERENCE: + { + pActiveShell->GotoRefMark(pCnt->GetName()); + } + break; + case CONTENT_TYPE_INDEX: + { + const OUString sName(pCnt->GetName()); + if (!pActiveShell->GotoNextTOXBase(&sName)) + pActiveShell->GotoPrevTOXBase(&sName); + } + 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: + { + SwPosition aPos = *pActiveShell->GetCrsr()->GetPoint(); + 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); + // #i51726# - all drawing objects can be named now + if (pTemp->GetName().equals(pCnt->GetName())) + { + SdrPageView* pPV = pDrawView->GetSdrPageView(); + if( pPV ) + { + pDrawView->MarkObj( pTemp, pPV ); + } + } + } + pActiveShell->GetNavigationMgr().addEntry(aPos); + } + } + break; + } + if(bSel) + { + pActiveShell->HideCrsr(); + pActiveShell->EnterSelFrmMode(); + } + SwView& rView = pActiveShell->GetView(); + rView.StopShellTimer(); + rView.GetPostItMgr()->SetActiveSidebarWin(0); + rView.GetEditWin().GrabFocus(); +} + +// Now even the matching text::Bookmark +NaviContentBookmark::NaviContentBookmark() + : + nDocSh(0), + nDefDrag( REGION_MODE_NONE ) +{ +} + +NaviContentBookmark::NaviContentBookmark( const OUString &rUrl, + const OUString& rDesc, + sal_uInt16 nDragType, + const SwDocShell* pDocSh ) : + aUrl( rUrl ), + aDescr(rDesc), + nDocSh((sal_IntPtr)pDocSh), + nDefDrag( nDragType ) +{ +} + +void NaviContentBookmark::Copy( TransferDataContainer& rData ) const +{ + rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding(); + + OString sStrBuf(OUStringToOString(aUrl, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) + + OUStringToOString(aDescr, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) + + OString::number(nDefDrag) + OString(NAVI_BOOKMARK_DELIM) + + OString::number(nDocSh)); + rData.CopyByteString(SOT_FORMATSTR_ID_SONLK, sStrBuf); +} + +bool NaviContentBookmark::Paste( TransferableDataHelper& rData ) +{ + OUString sStr; + bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr ); + if( bRet ) + { + sal_Int32 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; +} + +class SwContentLBoxString : public SvLBoxString +{ +public: + SwContentLBoxString( SvTreeListEntry* pEntry, sal_uInt16 nFlags, + const OUString& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {} + + virtual void Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, + const SvTreeListEntry* pEntry) SAL_OVERRIDE; +}; + +void SwContentTree::InitEntry(SvTreeListEntry* pEntry, + const OUString& rStr ,const Image& rImg1,const Image& rImg2, + SvLBoxButtonKind eButtonKind) +{ + sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2" + 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 ); +} + +void SwContentLBoxString::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, + const SvTreeListEntry* pEntry) +{ + if(lcl_IsContent(pEntry) && + ((SwContent *)pEntry->GetUserData())->IsInvisible()) + { + Font aOldFont( rDev.GetFont()); + Font aFont(aOldFont); + Color aCol( COL_LIGHTGRAY ); + aFont.SetColor( aCol ); + rDev.SetFont( aFont ); + rDev.DrawText( rPos, GetText() ); + rDev.SetFont( aOldFont ); + } + // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this + /* + else if (pEntry->IsMarked()) + { + rDev.DrawText( rPos, GetText() ); + XubString str; + str = XubString::CreateFromAscii("*"); + Point rPosStar(rPos.X()-6,rPos.Y()); + Font aOldFont( rDev.GetFont()); + Font aFont(aOldFont); + Color aCol( aOldFont.GetColor() ); + aCol.DecreaseLuminance( 200 ); + aFont.SetColor( aCol ); + rDev.SetFont( aFont ); + rDev.DrawText( rPosStar, str); + rDev.SetFont( aOldFont ); + } + */ + else + SvLBoxString::Paint( rPos, rDev, pView, pEntry); +} + +void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + FindActiveTypeAndRemoveUserData(); + + bIsImageListInitialized = false; + Display(true); + } + SvTreeListBox::DataChanged( rDCEvt ); +} + +sal_Int32 SwContentTree::GetEntryRealChildrenNum( SvTreeListEntry* pParent ) const +{ + // ist es ein Inhaltstyp? + if(lcl_IsContentType(pParent)) + { + if(!pParent->HasChildren()) + { + SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); + return pCntType->GetMemberCount(); + } + } + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx new file mode 100644 index 000000000000..eefa7911978a --- /dev/null +++ b/sw/source/uibase/utlui/glbltree.cxx @@ -0,0 +1,1376 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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 <vcl/graphicfilter.hxx> +#include <vcl/settings.hxx> + +#include <svtools/treelistentry.hxx> +#include <sfx2/docinsert.hxx> +#include <sfx2/filedlghelper.hxx> + +#include <sfx2/app.hxx> +#include <swmodule.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <docsh.hxx> +#include <content.hxx> +#include <edglbldc.hxx> +#include <section.hxx> +#include <tox.hxx> +#include <cnttab.hxx> +#include <navipi.hxx> +#include <navicont.hxx> +#include <edtwin.hxx> +#include <uitool.hxx> + +#include <cmdid.h> +#include <helpid.h> +#include <navipi.hrc> +#include <utlui.hrc> +#include <comcore.hrc> +#include <globals.hrc> +#include "swabstdlg.hxx" + +using namespace ::com::sun::star::uno; + +// Context menu for GlobalTree +#define CTX_INSERT_ANY_INDEX 10 +#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 for 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: push to left +#define GLBL_TABPOS_SUB 5 + +const SfxObjectShell* SwGlobalTree::pShowShell = 0; +static const char* 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 +}; + +class SwGlobalFrameListener_Impl : public SfxListener +{ + bool bValid; +public: + SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) : + bValid(true) + { + StartListening(rFrame); + } + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE; + + bool IsValid() const {return bValid;} +}; + +void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) +{ + if( rHint.ISA(SfxSimpleHint) && + (((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING)) + bValid = false; +} + +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 ( false ), + bLastEntryEmphasis ( false ), + bIsImageListInitialized ( 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(); +} + +SwGlobalTree::~SwGlobalTree() +{ + delete pSwGlblDocContents; + delete pDocInserter; +} + +sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + sal_Int8 nRet = DND_ACTION_NONE; + SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible(); + if(pEmphasisEntry) + { + ImplShowTargetEmphasis( Prev(pEmphasisEntry), false ); + pEmphasisEntry = 0; + } + else if(bLastEntryEmphasis && pLast) + { + ImplShowTargetEmphasis( pLast, false); + } + + SvTreeListEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel); + if( bIsInternalDrag ) + { + SvTreeListEntry* pDummy = 0; + sal_uLong nInsertionPos = TREELIST_APPEND; + NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos ); + } + else + { + TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); + + OUString 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_uLong nEntryCount = GetEntryCount(); + + // Get data + FileList aFileList; + aData.GetFileList( FORMAT_FILE_LIST, aFileList ); + for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; ) + { + sFileName = aFileList.GetFile(n); + InsertRegion(pCnt, &sFileName); + // The list of contents must be newly fetched after inserting, + // to not work on an old content. + if(n) + { + pActiveShell->GetGlobalDocContent(*pTempContents); + // If the file was successfully inserted, + // then the next content must also be fetched. + if(nEntryCount < pTempContents->size()) + { + nEntryCount++; + nAbsContPos++; + pCnt = (*pTempContents)[ nAbsContPos ]; + } + } + } + delete pTempContents; + } + else if( !(sFileName = + SwNavigationPI::CreateDropFileName( aData )).isEmpty()) + { + INetURLObject aTemp(sFileName); + GraphicDescriptor aDesc(aTemp); + if( !aDesc.Detect() ) // accept no graphics + { + nRet = rEvt.mnAction; + InsertRegion(pCnt, &sFileName); + } + } + } + bLastEntryEmphasis = false; + return nRet; + +} + +sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + sal_Int8 nRet = rEvt.mnAction; + + //initiate scrolling + GetDropTarget( rEvt.maPosPixel ); + SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible(); + if( rEvt.mbLeaving ) + { + if( pEmphasisEntry ) + { + ImplShowTargetEmphasis( Prev(pEmphasisEntry), false ); + pEmphasisEntry = 0; + } + else if(bLastEntryEmphasis && pLast) + { + ImplShowTargetEmphasis( pLast, false); + } + bLastEntryEmphasis = false; + } + else + { + SvTreeListEntry* 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), false ); + else if(pLast && bLastEntryEmphasis && pDropEntry) + { + ImplShowTargetEmphasis( pLast, false); + bLastEntryEmphasis = false; + } + + if(pDropEntry) + ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet ); + else if(pLast) + { + ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet ); + bLastEntryEmphasis = true; + } + pEmphasisEntry = pDropEntry; + } + return nRet; +} + +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]); + + //disabling if applicable + 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; +} + +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_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(); + } +} + +sal_uInt16 SwGlobalTree::GetEnableFlags() const +{ + SvTreeListEntry* pEntry = FirstSelected(); + sal_uLong nSelCount = GetSelectionCount(); + sal_uLong nEntryCount = GetEntryCount(); + SvTreeListEntry* 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; +} + +void SwGlobalTree::RequestHelp( const HelpEvent& rHEvt ) +{ + bool bParent = true; + Update(true); + Display(true); + if( rHEvt.GetMode() & HELPMODE_QUICK ) + { + Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); + SvTreeListEntry* pEntry = GetEntry( aPos ); + const SwGlblDocContent* pCont = pEntry ? + (const SwGlblDocContent*)pEntry->GetUserData() : 0; + if( pCont && GLBLDOC_SECTION == pCont->GetType()) + { + bParent = false; + SvLBoxTab* pTab; + SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); + if (pItem && SV_ITEM_ID_LBOXSTRING == pItem->GetType()) + { + const SwSection* pSect = pCont->GetSection(); + OUString sEntry = pSect->GetLinkFileName().getToken(0, sfx2::cTokenSeparator); + if(!pSect->IsConnectFlag()) + sEntry = aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST] + sEntry; + 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); +} + +void SwGlobalTree::SelectHdl() +{ + + sal_uLong nSelCount = GetSelectionCount(); + SvTreeListEntry* pSel = FirstSelected(); + sal_uLong nAbsPos = pSel ? GetModel()->GetAbsPos(pSel) : 0; + SwNavigationPI* pNavi = GetParentWindow(); + 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 < GetEntryCount() - 1 && !bReadonly); + +} + +void SwGlobalTree::DeselectHdl() +{ + SelectHdl(); +} + +DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& , + SvTreeListEntry* pEntry ) +{ + bIsInternalDrag = true; + pDDSource = pEntry; + return SV_DRAGDROP_CTRL_MOVE; +} + +sal_IntPtr SwGlobalTree::GetTabPos( SvTreeListEntry*, SvLBoxTab* pTab) +{ + return pTab->GetPos() - GLBL_TABPOS_SUB; +} + +TriState SwGlobalTree::NotifyMoving( SvTreeListEntry* pTarget, + SvTreeListEntry* pSource, + SvTreeListEntry*&, + sal_uLong& + ) +{ + SvTreeList* _pModel = GetModel(); + sal_uLong nSource = _pModel->GetAbsPos(pSource); + sal_uLong nDest = pTarget ? _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->size(); + + if( pActiveShell->MoveGlobalDocContent( + *pSwGlblDocContents, nSource, nSource + 1, nDest ) && + Update( false )) + Display(); + + return TRISTATE_FALSE; +} + +TriState SwGlobalTree::NotifyCopying( SvTreeListEntry* /*pTarget*/, + SvTreeListEntry* /*pEntry*/, + SvTreeListEntry*& /*rpNewParent*/, + sal_uLong& /*rNewChildPos*/ + ) +{ + return TRISTATE_FALSE; +} + +bool SwGlobalTree::NotifyAcceptDrop( SvTreeListEntry* pEntry) +{ + return pEntry != 0; +} + +void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt ) +{ + if( 1 == GetSelectionCount() ) + SvTreeListBox::StartDrag( nAction, rPt ); +} + +void SwGlobalTree::DragFinished( sal_Int8 nAction ) +{ + SvTreeListBox::DragFinished( nAction ); + bIsInternalDrag = false; +} + +// If a Ctrl+DoubleClick is executed in an empty area, +// then the base function of the control should be called. + +void SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Point aPos( rMEvt.GetPosPixel()); + SvTreeListEntry* pEntry = GetEntry( aPos, true ); + if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) + Control::MouseButtonDown( rMEvt ); + else + SvTreeListBox::MouseButtonDown( rMEvt ); +} + +void SwGlobalTree::GetFocus() +{ + if(Update( false )) + Display(); + SvTreeListBox::GetFocus(); +} + +void SwGlobalTree::KeyInput(const KeyEvent& rKEvt) +{ + const KeyCode aCode = rKEvt.GetKeyCode(); + if(aCode.GetCode() == KEY_RETURN) + { + switch(aCode.GetModifier()) + { + case KEY_MOD2: + // Switch boxes + GetParentWindow()->ToggleTree(); + break; + } + } + else + SvTreeListBox::KeyInput(rKEvt); +} + +void SwGlobalTree::Clear() +{ + pEmphasisEntry = 0; + SvTreeListBox::Clear(); +} + +void SwGlobalTree::Display(bool bOnlyUpdateUserData) +{ + if(!bIsImageListInitialized) + { + aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP)); + bIsImageListInitialized = true; + } + size_t nCount = pSwGlblDocContents->size(); + if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->size()) + { + SvTreeListEntry* pEntry = First(); + for (size_t i = 0; i < nCount && pEntry; i++) + { + SwGlblDocContent* pCont = (*pSwGlblDocContents)[i]; + pEntry->SetUserData(pCont); + pEntry = Next(pEntry); + assert(pEntry || i == nCount - 1); + } + } + else + { + SetUpdateMode( false ); + SvTreeListEntry* pOldSelEntry = FirstSelected(); + OUString sEntryName; // Name of the entry + sal_uLong nSelPos = TREELIST_ENTRY_NOTFOUND; + if(pOldSelEntry) + { + sEntryName = GetEntryText(pOldSelEntry); + nSelPos = GetModel()->GetAbsPos(pOldSelEntry); + } + Clear(); + if(!pSwGlblDocContents) + Update( false ); + + SvTreeListEntry* pSelEntry = 0; + for( size_t i = 0; i < nCount; i++) + { + SwGlblDocContent* pCont = (*pSwGlblDocContents)[i]; + OUString 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; + } + SvTreeListEntry* pEntry = InsertEntry(sEntry, aImage, aImage, + 0, false, TREELIST_APPEND, pCont); + if(sEntry == sEntryName) + { + pSelEntry = pEntry; + } + } + if(pSelEntry) + { + Select(pSelEntry); + } + else if(nSelPos != TREELIST_ENTRY_NOTFOUND && nSelPos < nCount) + { + Select(GetEntry(nSelPos)); + } + else if(nCount) + Select(First()); + else + SelectHdl(); + SetUpdateMode( true ); + } +} + +void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const OUString* pFileName ) +{ + Sequence< OUString > aFileNames; + if ( !pFileName ) + { + pDefParentWin = Application::GetDefDialogParent(); + Application::SetDefDialogParent( this ); + delete pDocInserter; + pDocInserter = new ::sfx2::DocumentInserter( + OUString("swriter"), true ); + pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) ); + } + else if ( !pFileName->isEmpty() ) + { + aFileNames.realloc(1); + INetURLObject aFileName; + aFileName.SetSmartURL( *pFileName ); + aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE ); + InsertRegion( pCont, aFileNames ); + } +} + +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( false )) + Display(); + } +} + +IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu) +{ + ExcecuteContextMenuAction( pMenu->GetCurItemId()); + return sal_True; +} + +void SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) +{ + SvTreeListEntry* pEntry = FirstSelected(); + SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0; + // If a RequestHelp is called during the dialogue, + // then the content gets lost. Because of that a copy + // is created in which only the DocPos is set correctly. + 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: + { + // Two passes: first update the areas, then the directories. + SvTreeListEntry* 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(true); + if(CTX_UPDATE_ALL == nSelectedPopupEntry) + nSlot = FN_UPDATE_TOX; + pCont = 0; + } + break; + case CTX_EDIT: + { + OSL_ENSURE(pCont, "edit without entry ? " ); + EditContent(pCont); + } + break; + case CTX_EDIT_LINK: + { + OSL_ENSURE(pCont, "edit without entry ? " ); + SfxStringItem aName(FN_EDIT_REGION, + pCont->GetSection()->GetSectionName()); + rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L); + } + break; + case CTX_DELETE: + { + // If several entries selected, then after each delete the array + // must be refilled. So you do not have to remember anything, + // deleting begins at the end. + SvTreeListEntry* pSelEntry = LastSelected(); + SwGlblDocContents* pTempContents = 0; + pActiveShell->StartAction(); + while(pSelEntry) + { + pActiveShell->DeleteGlobalDocContent( + pTempContents ? *pTempContents : *pSwGlblDocContents, + GetModel()->GetAbsPos(pSelEntry)); + pSelEntry = PrevSelected(pSelEntry); + if(pSelEntry) + { + delete pTempContents; + pTempContents = new SwGlblDocContents; + pActiveShell->GetGlobalDocContent(*pTempContents); + } + } + delete pTempContents; + pActiveShell->EndAction(); + pCont = 0; + } + break; + case CTX_INSERT_ANY_INDEX: + { + 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(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( + this, aSet, + *pActiveShell, + 0, + USHRT_MAX, + true); + OSL_ENSURE(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; + // Creating a new doc + SfxStringItem aFactory(SID_NEWDOCDIRECT, + SwDocShell::Factory().GetFilterContainer()->GetName()); + + const SfxFrameItem* pItem = (SfxFrameItem*) + rDispatch.Execute(SID_NEWDOCDIRECT, + SFX_CALLMODE_SYNCHRON, &aFactory, 0L); + + // save at + 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(); + OUString sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)); + // Insert the area with the Doc-Name + // Bring the own Doc in the foreground + if(aFrmListener.IsValid() && !sNewFile.isEmpty()) + { + pGlobFrm->ToTop(); + // Due to the update the entries are invalid + if(nEntryPos != (sal_uLong)-1) + { + Update( 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(); // Empty document + pActiveShell->Up( false, 1 ); + } + pActiveShell->GetView().GetEditWin().GrabFocus(); + } + break; + case CTX_UPDATE: + pCont = 0; + break; + default:; + // here nothing happens + } + if(pCont) + GotoContent(pCont); + if(nSlot) + rDispatch.Execute(nSlot); + if(Update( false )) + Display(); + if ( bDeleteContentCopy ) + delete pContCopy; +} + +IMPL_LINK_NOARG(SwGlobalTree, Timeout) +{ + if(!HasFocus() && Update( false )) + Display(); + return 0; +} + +void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont) +{ + pActiveShell->EnterStdMode(); + + switch( pCont->GetType() ) + { + case GLBLDOC_UNKNOWN: + pActiveShell->GotoGlobalDocContent(*pCont); + break; + case GLBLDOC_TOXBASE: + { + const OUString sName = pCont->GetTOX()->GetTOXName(); + if (!pActiveShell->GotoNextTOXBase(&sName)) + pActiveShell->GotoPrevTOXBase(&sName); + } + break; + case GLBLDOC_SECTION: + break; + } + +} + +void SwGlobalTree::ShowTree() +{ + aUpdateTimer.Start(); + SvTreeListBox::Show(); +} + +void SwGlobalTree::HideTree() +{ + aUpdateTimer.Stop(); + SvTreeListBox::Hide(); +} + +void SwGlobalTree::ExecCommand(sal_uInt16 nCmd) +{ + SvTreeListEntry* pEntry = FirstSelected(); + OSL_ENSURE(pEntry, "It explodes in the next moment"); + if(FN_GLOBAL_EDIT == nCmd) + { + const SwGlblDocContent* pCont = (const SwGlblDocContent*) + pEntry->GetUserData(); + EditContent(pCont); + } + else + { + if(GetSelectionCount() == 1) + { + bool bMove = false; + sal_uLong nSource = GetModel()->GetAbsPos(pEntry); + sal_uLong nDest = nSource; + switch(nCmd) + { + case FN_ITEM_DOWN: + { + sal_uLong nEntryCount = 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( false )) + Display(); + } + } +} + +bool SwGlobalTree::Update(bool bHard) +{ + SwView* pActView = GetParentWindow()->GetCreateView(); + bool bRet = 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 = true; + pActiveShell->GetGlobalDocContent(*pSwGlblDocContents); + } + else + { + bool bCopy = false; + SwGlblDocContents* pTempContents = new SwGlblDocContents; + pActiveShell->GetGlobalDocContent(*pTempContents); + if(pTempContents->size() != pSwGlblDocContents->size() || + pTempContents->size() != GetEntryCount()) + { + bRet = true; + bCopy = true; + } + else + { + for(size_t i = 0; i < pTempContents->size() && !bCopy; i++) + { + SwGlblDocContent* pLeft = (*pTempContents)[i]; + SwGlblDocContent* pRight = (*pSwGlblDocContents)[i]; + GlobalDocContentType eType = pLeft->GetType(); + SvTreeListEntry* pEntry = GetEntry(i); + OUString sTemp = GetEntryText(pEntry); + if ( + eType != pRight->GetType() || + ( + eType == GLBLDOC_SECTION && + pLeft->GetSection()->GetSectionName() != sTemp + ) || + ( + eType == GLBLDOC_TOXBASE && + pLeft->GetTOX()->GetTitle() != sTemp + ) + ) + { + bCopy = bRet = true; + } + } + } + if(bCopy || bHard) + { + pSwGlblDocContents->DeleteAndDestroyAll(); + pSwGlblDocContents->insert( *pTempContents ); + pTempContents->clear(); + + } + delete pTempContents; + } + + } + else + { + Clear(); + if(pSwGlblDocContents) + pSwGlblDocContents->DeleteAndDestroyAll(); + } + // FIXME: Implement a test for changes! + return bRet; +} + +void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont) +{ + const OUString sFileName(pCont->GetSection()->GetLinkFileName().getToken(0, + sfx2::cTokenSeparator)); + bool bFound = false; + const SfxObjectShell* pCurr = SfxObjectShell::GetFirst(); + while( !bFound && pCurr ) + { + if(pCurr->GetMedium() && + pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI) == sFileName) + { + bFound = 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, false); + SfxStringItem aTargetFrameName( SID_TARGETNAME, "_blank" ); + SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle()); + pActiveShell->GetView().GetViewFrame()->GetDispatcher()-> + Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, + &aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L); + } +} + +IMPL_LINK_NOARG( SwGlobalTree, DoubleClickHdl) +{ + SvTreeListEntry* pEntry = GetCurEntry(); + SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); + if(pCont->GetType() == GLBLDOC_SECTION) + OpenDoc(pCont); + else + { + GotoContent(pCont); + pActiveShell->GetView().GetEditWin().GrabFocus(); + } + return 0; +} + +IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG) +{ + const SfxObjectShell* pShell = SwGlobalTree::GetShowShell(); + SfxViewFrame* pFirst = pShell ? SfxViewFrame::GetFirst(pShell) : NULL; + if (pFirst) + pFirst->ToTop(); + SwGlobalTree::SetShowShell(0); + return 0; +} + +void SwGlobalTree::InitEntry(SvTreeListEntry* pEntry, + const OUString& rStr ,const Image& rImg1,const Image& rImg2, + SvLBoxButtonKind eButtonKind) +{ + sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2" + 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 ); +} + +void SwLBoxString::Paint( + const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, + const SvTreeListEntry* pEntry) +{ + SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); + if(pCont->GetType() == GLBLDOC_SECTION && + !(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, pView, pEntry); +} + +void SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt ) +{ + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + aEntryImages = ImageList(SW_RES(IMG_NAVI_ENTRYBMP)); + Update(true); + } + SvTreeListBox::DataChanged( rDCEvt ); +} + +void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles ) +{ + sal_Int32 nFiles = _rFiles.getLength(); + if ( nFiles ) + { + bool bMove = false; + if ( !_pContent ) + { + SvTreeListEntry* pLast = (SvTreeListEntry*)LastVisible(); + _pContent = (SwGlblDocContent*)pLast->GetUserData(); + bMove = true; + } + OUString sFilePassword; + sal_uLong nEntryCount = 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 + size_t nAnchorContent = pSwGlblDocContents->size() - 1; + if ( !bMove ) + { + for (size_t nContent = 0; nContent < pSwGlblDocContents->size(); + ++nContent) + { + if( *_pContent == *(*pSwGlblDocContents)[ 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; + OSL_ENSURE(aTempContents.size() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed"); + if ( aTempContents.size() > (nAnchorContent + nFile) ) + pAnchorContent = aTempContents[nAnchorContent + nFile]; + else + pAnchorContent = aTempContents.back(); + OUString sFileName(pFileNames[nFile]); + INetURLObject aFileUrl; + aFileUrl.SetSmartURL( sFileName ); + OUString sSectionName(aFileUrl.GetLastName( + INetURLObject::DECODE_UNAMBIGUOUS).getToken(0, sfx2::cTokenSeparator)); + sal_uInt16 nSectCount = rSh.GetSectionFmtCount(); + OUString sTempSectionName(sSectionName); + sal_uInt16 nAddNumber = 0; + sal_uInt16 nCount = 0; + // if applicable: add index if the range name is already in use. + while ( nCount < nSectCount ) + { + const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount); + if ((rFmt.GetSection()->GetSectionName() == sTempSectionName) + && rFmt.IsInNodesArr()) + { + nCount = 0; + nAddNumber++; + sTempSectionName = sSectionName + ":" + OUString::number( 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( false ); + rSh.MoveGlobalDocContent( + *pSwGlblDocContents, nEntryCount, nEntryCount + nFiles, nEntryCount - nFiles ); + } + rSh.EndAction(); + Update( 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->size() ); + OUString* pFileNames = aFileNames.getArray(); + sal_Int32 nPos = 0; + for ( size_t i = 0, n = pMedList->size(); i < n; ++i ) + { + SfxMedium* pMed = pMedList->at( i ); + OUString sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); + sFileName += OUString(sfx2::cTokenSeparator); + sFileName += pMed->GetFilter()->GetFilterName(); + sFileName += OUString(sfx2::cTokenSeparator); + pFileNames[nPos++] = sFileName; + } + delete pMedList; + InsertRegion( pDocContent, aFileNames ); + DELETEZ( pDocContent ); + } + } + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx new file mode 100644 index 000000000000..a9e1d11aeccd --- /dev/null +++ b/sw/source/uibase/utlui/gloslst.cxx @@ -0,0 +1,418 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <tools/urlobj.hxx> +#include <vcl/dialog.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <vcl/lstbox.hxx> +#include <svl/fstathelper.hxx> +#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> + +#include <vector> + +#include <utlui.hrc> + +#define STRING_DELIM (char)0x0A +#define GLOS_TIMEOUT 30000 // update every 30 seconds +#define FIND_MAX_GLOS 20 + +struct TripleString +{ + OUString sGroup; + OUString sBlock; + OUString sShort; +}; + +class SwGlossDecideDlg : public ModalDialog +{ + OKButton* m_pOk; + ListBox* m_pListLB; + + DECL_LINK(DoubleClickHdl, void*); + DECL_LINK(SelectHdl, void*); + + public: + SwGlossDecideDlg(Window* pParent); + ListBox& GetListBox() {return *m_pListLB;} +}; + +SwGlossDecideDlg::SwGlossDecideDlg(Window* pParent) + : ModalDialog(pParent, "SelectAutoTextDialog", + "modules/swriter/ui/selectautotextdialog.ui") +{ + get(m_pOk, "ok"); + get(m_pListLB, "treeview"); + m_pListLB->set_height_request(m_pListLB->GetTextHeight() * 10); + m_pListLB->SetDoubleClickHdl(LINK(this, SwGlossDecideDlg, DoubleClickHdl)); + m_pListLB->SetSelectHdl(LINK(this, SwGlossDecideDlg, SelectHdl)); +} + +IMPL_LINK_NOARG(SwGlossDecideDlg, DoubleClickHdl) +{ + EndDialog(RET_OK); + return 0; +} + +IMPL_LINK_NOARG(SwGlossDecideDlg, SelectHdl) +{ + m_pOk->Enable(LISTBOX_ENTRY_NOTFOUND != m_pListLB->GetSelectEntryPos()); + return 0; +} + +SwGlossaryList::SwGlossaryList() : + bFilled(false) +{ + SvtPathOptions aPathOpt; + sPath = aPathOpt.GetAutoTextPath(); + SetTimeout(GLOS_TIMEOUT); +} + +SwGlossaryList::~SwGlossaryList() +{ + ClearGroups(); +} + +// If the GroupName is already known, then only rShortName +// will be filled. Otherwise also rGroupName will be set and +// on demand asked for the right group. + +bool SwGlossaryList::GetShortName(const OUString& rLongName, + OUString& rShortName, OUString& rGroupName ) +{ + if(!bFilled) + Update(); + + std::vector<TripleString> aTripleStrings; + + sal_uInt16 nCount = aGroupArr.size(); + sal_uInt16 nFound = 0; + for(sal_uInt16 i = 0; i < nCount; i++ ) + { + AutoTextGroup* pGroup = aGroupArr[i]; + if(!rGroupName.isEmpty() && rGroupName != pGroup->sName) + continue; + + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + OUString sLong = pGroup->sLongNames.getToken(j, STRING_DELIM); + if(rLongName != sLong) + continue; + + TripleString pTriple; + pTriple.sGroup = pGroup->sName; + pTriple.sBlock = sLong; + pTriple.sShort = pGroup->sShortNames.getToken(j, STRING_DELIM); + aTripleStrings.push_back(pTriple); + ++nFound; + } + } + + bool bRet = false; + nCount = aTripleStrings.size(); + if(1 == nCount) + { + const TripleString& pTriple(aTripleStrings.front()); + rShortName = pTriple.sShort; + rGroupName = pTriple.sGroup; + bRet = true; + } + else if(1 < nCount) + { + SwGlossDecideDlg aDlg(0); + OUString sTitle = aDlg.GetText() + " " + aTripleStrings.front().sBlock; + aDlg.SetText(sTitle); + + ListBox& rLB = aDlg.GetListBox(); + for(std::vector<TripleString>::const_iterator i = aTripleStrings.begin(); i != aTripleStrings.end(); ++i) + rLB.InsertEntry(i->sGroup.getToken(0, GLOS_DELIM)); + + rLB.SelectEntryPos(0); + if(RET_OK == aDlg.Execute() && + LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectEntryPos()) + { + const TripleString& pTriple(aTripleStrings[rLB.GetSelectEntryPos()]); + rShortName = pTriple.sShort; + rGroupName = pTriple.sGroup; + bRet = true; + } + else + bRet = false; + } + return bRet; +} + +sal_uInt16 SwGlossaryList::GetGroupCount() +{ + if(!bFilled) + Update(); + return aGroupArr.size(); +} + +OUString SwGlossaryList::GetGroupName(sal_uInt16 nPos, bool bNoPath) +{ + OSL_ENSURE(aGroupArr.size() > nPos, "group not available"); + if(nPos < aGroupArr.size()) + { + AutoTextGroup* pGroup = aGroupArr[nPos]; + OUString sRet = pGroup->sName; + if(bNoPath) + sRet = sRet.getToken(0, GLOS_DELIM); + return sRet; + } + return OUString(); +} + +OUString SwGlossaryList::GetGroupTitle(sal_uInt16 nPos) +{ + OSL_ENSURE(aGroupArr.size() > nPos, "group not available"); + if(nPos < aGroupArr.size()) + { + AutoTextGroup* pGroup = aGroupArr[nPos]; + return pGroup->sTitle; + } + return OUString(); +} + +sal_uInt16 SwGlossaryList::GetBlockCount(sal_uInt16 nGroup) +{ + OSL_ENSURE(aGroupArr.size() > nGroup, "group not available"); + if(nGroup < aGroupArr.size()) + { + AutoTextGroup* pGroup = aGroupArr[nGroup]; + return pGroup->nCount; + } + return 0; +} + +OUString SwGlossaryList::GetBlockLongName(sal_uInt16 nGroup, sal_uInt16 nBlock) +{ + OSL_ENSURE(aGroupArr.size() > nGroup, "group not available"); + if(nGroup < aGroupArr.size()) + { + AutoTextGroup* pGroup = aGroupArr[nGroup]; + return pGroup->sLongNames.getToken(nBlock, STRING_DELIM); + } + return OUString(); +} + +OUString SwGlossaryList::GetBlockShortName(sal_uInt16 nGroup, sal_uInt16 nBlock) +{ + OSL_ENSURE(aGroupArr.size() > nGroup, "group not available"); + if(nGroup < aGroupArr.size()) + { + AutoTextGroup* pGroup = aGroupArr[nGroup]; + return pGroup->sShortNames.getToken(nBlock, STRING_DELIM); + } + return OUString(); +} + +void SwGlossaryList::Update() +{ + if(!IsActive()) + Start(); + + SvtPathOptions aPathOpt; + OUString sTemp( aPathOpt.GetAutoTextPath() ); + if(sTemp != sPath) + { + sPath = sTemp; + bFilled = false; + ClearGroups(); + } + SwGlossaries* pGlossaries = ::GetGlossaries(); + const std::vector<OUString> & rPathArr = pGlossaries->GetPathArray(); + const OUString sExt( SwGlossaries::GetExtension() ); + if(!bFilled) + { + sal_uInt16 nGroupCount = pGlossaries->GetGroupCnt(); + for(sal_uInt16 i = 0; i < nGroupCount; i++) + { + OUString sGrpName = pGlossaries->GetGroupName(i); + sal_uInt16 nPath = (sal_uInt16)sGrpName.getToken(1, GLOS_DELIM).toInt32(); + if( static_cast<size_t>(nPath) < rPathArr.size() ) + { + AutoTextGroup* pGroup = new AutoTextGroup; + pGroup->sName = sGrpName; + + FillGroup(pGroup, pGlossaries); + OUString sName = rPathArr[nPath] + "/" + + pGroup->sName.getToken(0, GLOS_DELIM) + sExt; + FStatHelper::GetModifiedDateTimeOfFile( sName, + &pGroup->aDateModified, + &pGroup->aDateModified ); + + aGroupArr.insert( aGroupArr.begin(), pGroup ); + } + } + bFilled = true; + } + else + { + for( size_t nPath = 0; nPath < rPathArr.size(); nPath++ ) + { + std::vector<OUString> aFoundGroupNames; + std::vector<OUString> aFiles; + std::vector<DateTime*> aDateTimeArr; + + SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles, + &sExt, &aDateTimeArr ); + for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles ) + { + const OUString aTitle = aFiles[ nFiles ]; + ::DateTime* pDT = (::DateTime*) aDateTimeArr[ static_cast<sal_uInt16>(nFiles) ]; + + OUString sName( aTitle.copy( 0, aTitle.getLength() - sExt.getLength() )); + + aFoundGroupNames.push_back(sName); + sName += OUString(GLOS_DELIM) + OUString::number( static_cast<sal_uInt16>(nPath) ); + AutoTextGroup* pFound = FindGroup( sName ); + if( !pFound ) + { + pFound = new AutoTextGroup; + pFound->sName = sName; + FillGroup( pFound, pGlossaries ); + pFound->aDateModified = *pDT; + + aGroupArr.push_back(pFound); + } + else if( pFound->aDateModified < *pDT ) + { + FillGroup(pFound, pGlossaries); + pFound->aDateModified = *pDT; + } + + // don't need any more these pointers + delete pDT; + } + + sal_uInt16 nArrCount = aGroupArr.size(); + for( sal_uInt16 i = nArrCount; i; --i) + { + // maybe remove deleted groups + AutoTextGroup* pGroup = aGroupArr[i - 1]; + sal_uInt16 nGroupPath = (sal_uInt16)pGroup->sName.getToken( 1, + GLOS_DELIM).toInt32(); + // Only the groups will be checked which are registered + // for the current subpath. + if( nGroupPath == static_cast<sal_uInt16>(nPath) ) + { + bool bFound = false; + OUString sCompareGroup = pGroup->sName.getToken(0, GLOS_DELIM); + for(std::vector<OUString>::const_iterator j = aFoundGroupNames.begin(); j != aFoundGroupNames.end() && !bFound; ++j) + bFound = (sCompareGroup == *j); + + if(!bFound) + { + aGroupArr.erase(aGroupArr.begin() + i - 1); + delete pGroup; + } + } + } + } + } +} + +void SwGlossaryList::Timeout() +{ + // Only update automatically if a SwView has the focus. + if(::GetActiveView()) + Update(); +} + +AutoTextGroup* SwGlossaryList::FindGroup(const OUString& rGroupName) +{ + for(sal_uInt16 i = 0; i < aGroupArr.size(); i++) + { + AutoTextGroup* pRet = aGroupArr[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 = OUString(); + if(pBlock) + pGroup->sTitle = pBlock->GetName(); + + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + pGroup->sLongNames += pBlock->GetLongName(j); + pGroup->sLongNames += OUString(STRING_DELIM); + pGroup->sShortNames += pBlock->GetShortName(j); + pGroup->sShortNames += OUString(STRING_DELIM); + } + pGlossaries->PutGroupDoc(pBlock); +} + +// Give back all (not exceeding FIND_MAX_GLOS) found modules +// with matching beginning. + +bool SwGlossaryList::HasLongName(const OUString& rBegin, std::vector<OUString> *pLongNames) +{ + if(!bFilled) + Update(); + sal_uInt16 nFound = 0; + sal_uInt16 nCount = aGroupArr.size(); + sal_Int32 nBeginLen = rBegin.getLength(); + const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); + + for(sal_uInt16 i = 0; i < nCount; i++ ) + { + AutoTextGroup* pGroup = aGroupArr[i]; + for(sal_uInt16 j = 0; j < pGroup->nCount; j++) + { + OUString sBlock = pGroup->sLongNames.getToken(j, STRING_DELIM); + if( nBeginLen + 1 < sBlock.getLength() && + rSCmp.isEqual( sBlock.copy(0, nBeginLen), rBegin )) + { + pLongNames->push_back( sBlock ); + nFound++; + if(FIND_MAX_GLOS == nFound) + break; + } + } + } + return nFound > 0; +} + +void SwGlossaryList::ClearGroups() +{ + sal_uInt16 nCount = aGroupArr.size(); + for( sal_uInt16 i = 0; i < nCount; ++i ) + delete aGroupArr[ i ]; + + aGroupArr.clear(); + bFilled = false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx new file mode 100644 index 000000000000..44dc6762b69a --- /dev/null +++ b/sw/source/uibase/utlui/initui.cxx @@ -0,0 +1,342 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <config_features.h> + +#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> + +#include <utlui.hrc> +#include <initui.hrc> +#include <comcore.hrc> +#include <authfld.hxx> +#include <dbmgr.hxx> +#include <unotools/syslocale.hxx> + +#include <unomid.h> + +// Global Pointer + +SwGlossaries* pGlossaries = 0; + +// Provides all needed paths. Is initialized by UI. +SwGlossaryList* pGlossaryList = 0; + +namespace +{ + +enum CachedStringID +{ + OldGrfCat, + OldTabCat, + OldFrmCat, + OldDrwCat, + CurrGlosGroup, + CachedStrings +}; + +OUString *StringCache[CachedStrings] = {0}; + +inline OUString GetCachedString(CachedStringID id) +{ + return StringCache[id] ? *StringCache[id] : OUString(); +} + +inline void SetCachedString(CachedStringID id, const OUString& sStr) +{ + if (StringCache[id]) + { + *StringCache[id] = sStr; + } + else + { + StringCache[id] = new OUString(sStr); + } +} + +void ClearStringCache() +{ + for (int i=0; i<CachedStrings; ++i) + { + delete StringCache[i]; + } +} + +} + +OUString GetOldGrfCat() +{ + return GetCachedString(OldGrfCat); +} + +void SetOldGrfCat(const OUString& sStr) +{ + SetCachedString(OldGrfCat, sStr); +} + +OUString GetOldTabCat() +{ + return GetCachedString(OldTabCat); +} + +void SetOldTabCat(const OUString& sStr) +{ + SetCachedString(OldTabCat, sStr); +} + +OUString GetOldFrmCat() +{ + return GetCachedString(OldFrmCat); +} + +void SetOldFrmCat(const OUString& sStr) +{ + SetCachedString(OldFrmCat, sStr); +} + +OUString GetOldDrwCat() +{ + return GetCachedString(OldDrwCat); +} + +void SetOldDrwCat(const OUString& sStr) +{ + SetCachedString(OldDrwCat, sStr); +} + +OUString GetCurrGlosGroup() +{ + return GetCachedString(CurrGlosGroup); +} + +void SetCurrGlosGroup(const OUString& sStr) +{ + SetCachedString(CurrGlosGroup, sStr); +} + +namespace +{ + +std::vector<OUString>* pAuthFieldNameList = 0; +std::vector<OUString>* pAuthFieldTypeList = 0; + +} + +// Finish UI + +void _FinitUI() +{ +#if HAVE_FEATURE_DBCONNECTIVITY + SwDBManager::RemoveDbtoolsClient(); +#endif + delete SwViewShell::GetShellRes(); + SwViewShell::SetShellRes( 0 ); + + SwEditWin::_FinitStaticData(); + + DELETEZ(pGlossaries); + + delete SwFieldType::pFldNames; + + ClearStringCache(); + delete pGlossaryList; + delete pAuthFieldNameList; + delete pAuthFieldTypeList; + +} + +// Initialise + +void _InitUI() +{ + // ShellResource gives the CORE the possibility to work with resources. + SwViewShell::SetShellRes( new ShellResource ); + 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 ) ), + // #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)), + aTOXCitationName( SW_RES(STR_TOX_CITATION)), + aLinkCtrlClick(SW_RESSTR(STR_LINK_CTRL_CLICK)), + aLinkClick(SW_RESSTR(STR_LINK_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 ); + OUString aModStr( aModifiedCode.GetName() ); + aModStr = aModStr.replaceFirst(aCode.GetName(), OUString()); + aModStr = aModStr.replaceAll("+", OUString()); + aLinkCtrlClick = aLinkCtrlClick.replaceAll("%s", aModStr); + + for(sal_uInt16 i = 0; i < nCount; ++i) + aDocInfoLst.push_back(OUString(SW_RESSTR(FLD_DOCINFO_BEGIN + i))); + + FreeResource(); +} + +ShellResource::~ShellResource() +{ + delete pAutoFmtNameLst; +} + +OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode) +{ + OUString sRet; + + switch (eMode) + { + case NORMAL_PAGE: + sRet = sPageDescName; + break; + case FIRST_PAGE: + sRet = sPageDescFirstName; + break; + case FOLLOW_PAGE: + sRet = sPageDescFollowName; + break; + } + + return sRet.replaceFirst( "$(ARG1)", OUString::number( nNo )); +} + +SwGlossaries* GetGlossaries() +{ + if (!pGlossaries) + pGlossaries = new SwGlossaries; + return (pGlossaries); +} + +bool HasGlossaryList() +{ + return pGlossaryList != 0; +} + +SwGlossaryList* GetGlossaryList() +{ + if(!pGlossaryList) + pGlossaryList = new SwGlossaryList(); + + return pGlossaryList; +} + +struct ImpAutoFmtNameListLoader : public Resource +{ + ImpAutoFmtNameListLoader( std::vector<OUString>& rLst ); +}; + +void ShellResource::_GetAutoFmtNameLst() const +{ + assert(!pAutoFmtNameLst); + pAutoFmtNameLst = new std::vector<OUString>; + pAutoFmtNameLst->reserve(STR_AUTOFMTREDL_END); + ImpAutoFmtNameListLoader aTmp(*pAutoFmtNameLst); +} + +ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<OUString>& rLst ) + : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) ) +{ + for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n ) + { + OUString p(ResId(n + 1, *pSwResMgr)); + if(STR_AUTOFMTREDL_TYPO == n) + { +#ifdef WNT + // For Windows, a special treatment is necessary because MS has + // forgotten some characters in the dialog font here. + p = p.replaceFirst("%1", ",,"); + p = p.replaceFirst("%2", "''"); +#else + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rLclD = aSysLocale.GetLocaleData(); + // With real operating systems it also works without special handling. + p = p.replaceFirst("%1", rLclD.getDoubleQuotationMarkStart()); + p = p.replaceFirst("%2", rLclD.getDoubleQuotationMarkEnd()); +#endif + } + rLst.insert(rLst.begin() + n, p); + } + FreeResource(); +} + +OUString SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType) +{ + if(!pAuthFieldNameList) + { + pAuthFieldNameList = new std::vector<OUString>; + pAuthFieldNameList->reserve(AUTH_FIELD_END); + for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i) + pAuthFieldNameList->push_back(SW_RES(STR_AUTH_FIELD_START + i)); + } + return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)]; +} + +OUString SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType) +{ + if(!pAuthFieldTypeList) + { + pAuthFieldTypeList = new std::vector<OUString>; + pAuthFieldTypeList->reserve(AUTH_TYPE_END); + for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i) + pAuthFieldTypeList->push_back(SW_RES(STR_AUTH_TYPE_START + i)); + } + return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)]; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/initui.hrc b/sw/source/uibase/utlui/initui.hrc new file mode 100644 index 000000000000..c368dc4e625f --- /dev/null +++ b/sw/source/uibase/utlui/initui.hrc @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _INITUI_HRC +#define _INITUI_HRC + +// Local Resources for the 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_LINK_CTRL_CLICK 28 +#define STR_LINK_CLICK 29 +#define STR_GETREFFLD_REFITEMNOTFOUND 30 +#define STR_DURATION_FORMAT 31 +#define STR_TOX_CITATION 32 +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/initui.src b/sw/source/uibase/utlui/initui.src new file mode 100644 index 000000000000..999b27b79fbf --- /dev/null +++ b/sw/source/uibase/utlui/initui.src @@ -0,0 +1,418 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "globals.hrc" +#include "utlui.hrc" +#include "helpid.h" +#include "initui.hrc" + +// Error 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 **" ; + }; + String STR_CALC_VARNFND + { + Text [ en-US ] = "** Variable not found **" ; + }; + String STR_CALC_OVERFLOW + { + Text [ en-US ] = "** Overflow **" ; + }; + 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_CITATION + { + Text [ en-US ] = "Citation"; + }; + + 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_LINK_CTRL_CLICK + { + Text [ en-US ] = "%s-Click to follow link"; + }; + String STR_LINK_CLICK + { + Text [ en-US ] = "Click to follow link"; + }; + + // SubType DocInfo + + String FLD_DOCINFO_TITEL + { + Text [ en-US ] = "Title" ; + }; + String FLD_DOCINFO_THEMA + { + Text [ en-US ] = "Subject" ; + }; + String FLD_DOCINFO_KEYS + { + 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" ; + }; + + 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"; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/navicfg.cxx b/sw/source/uibase/utlui/navicfg.cxx new file mode 100644 index 000000000000..ca1cd6504469 --- /dev/null +++ b/sw/source/uibase/utlui/navicfg.cxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <swtypes.hxx> +#include <navicfg.hxx> +#include <swcont.hxx> +#include <osl/diagnose.h> +#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; + +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; +} + +SwNavigationConfig::SwNavigationConfig() : + utl::ConfigItem("Office.Writer/Navigator"), + nRootType(0xffff), + nSelectedPos(0), + nOutlineLevel(MAXLEVEL), + nRegionMode(REGION_MODE_NONE), + nActiveBlock(0), + bIsSmall(false), + bIsGlobalActive(true) +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(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; + } + } + } + } +} + +SwNavigationConfig::~SwNavigationConfig() +{ +} + +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< OUString >& ) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx new file mode 100644 index 000000000000..f4e7830319e2 --- /dev/null +++ b/sw/source/uibase/utlui/navipi.cxx @@ -0,0 +1,1385 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <string> +#include <comphelper/string.hxx> +#include <svl/urlbmk.hxx> +#include <svl/stritem.hxx> +#include <vcl/graphicfilter.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 <vcl/settings.hxx> +#include <swtypes.hxx> +#include <swmodule.hxx> +#include <view.hxx> +#include <navicfg.hxx> +#include <wrtsh.hxx> +#include <docsh.hxx> +#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> +#include <cmdid.h> +#include <helpid.h> +#include <ribbar.hrc> +#include <navipi.hrc> +#include <utlui.hrc> + +#include "access.hrc" + +#include <unomid.h> + +#define PAGE_CHANGE_TIMEOUT 1000 + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; + +SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView ) + +// Filter the control characters out of the Outline-Entry + +OUString SwNavigationPI::CleanEntry(const OUString& rEntry) +{ + if (rEntry.isEmpty()) + return rEntry; + + OUStringBuffer aEntry(rEntry); + for (sal_Int32 i = 0; i < rEntry.getLength(); ++i) + if(aEntry[i] == 10 || aEntry[i] == 9) + aEntry[i] = 0x20; + + return aEntry.makeStringAndClear(); +} + +// Execution of the drag operation with and without the children. + +void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, + bool bWithChildren) +{ + 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 (bWithChildren) + rSh.MakeOutlineSel(nSource, nSource, true); + // While moving, the selected children does not counting. + sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL); + if(bWithChildren && nMove > 1 && + nLastOutlinePos < nTarget) + { + if(!rSh.IsCrsrPtAtEnd()) + rSh.SwapPam(); + nMove -= nLastOutlinePos - nSource; + } + if(!bWithChildren || nMove < 1 || nLastOutlinePos < nTarget ) + rSh.MoveOutlinePara( nMove ); + rSh.ClearMark(); + rSh.GotoOutline( nSource + nMove); + FillBox(); + } + +} + +// After goto cancel the status frame selection + +static void lcl_UnSelectFrm(SwWrtShell *pSh) +{ + if (pSh->IsFrmSelected()) + { + pSh->UnSelectFrm(); + pSh->LeaveSelFrmMode(); + } +} + +// Select the document view + +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; +} + +// Filling of the list box for outline view or documents +// The PI will be set to full size + +void SwNavigationPI::FillBox() +{ + if(pContentWrtShell) + { + aContentTree.SetHiddenShell( pContentWrtShell ); + aContentTree.Display( false ); + } + else + { + SwView *pView = GetCreateView(); + if(!pView) + { + aContentTree.SetActiveShell(0); + } + else if( pView != pActContView) + { + SwWrtShell* pWrtShell = pView->GetWrtShellPtr(); + aContentTree.SetActiveShell(pWrtShell); + } + else + aContentTree.Display( 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); + } +} + +// Select handler of the toolboxes + +IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox ) +{ + const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); + SwView *pView = GetCreateView(); + if (!pView) + return 1; + SwWrtShell &rSh = pView->GetWrtShell(); + // Get MouseModifier for Outline-Move + + // Standard: sublevels are taken + // do not take sublevels with Ctrl + bool bOutlineWithChildren = ( KEY_MOD1 != pBox->GetModifier()); + int nFuncId = 0; + bool bFocusToDoc = 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!=NULL && pContextWin->GetFloatingWindow()!=NULL) + { + if(_IsZoomedIn() ) + { + _ZoomOut(); + } + else + { + _ZoomIn(); + } + } + return sal_True; + // Functions that will trigger a direct action. + + case FN_SELECT_FOOTER: + { + rSh.MoveCrsr(); + const sal_uInt16 eType = rSh.GetFrmType(0,false); + if (eType & FRMTYPE_FOOTER) + { + if (rSh.EndPg()) + nFuncId = FN_END_OF_PAGE; + } + else if (rSh.GotoFooterTxt()) + nFuncId = FN_TO_FOOTER; + bFocusToDoc = true; + } + break; + case FN_SELECT_HEADER: + { + rSh.MoveCrsr(); + const sal_uInt16 eType = rSh.GetFrmType(0,false); + if (eType & FRMTYPE_HEADER) + { + if (rSh.SttPg()) + nFuncId = FN_START_OF_PAGE; + } + else if (rSh.GotoHeaderTxt()) + nFuncId = FN_TO_HEADER; + bFocusToDoc = true; + } + break; + case FN_SELECT_FOOTNOTE: + { + rSh.MoveCrsr(); + const sal_uInt16 eFrmType = rSh.GetFrmType(0,false); + // Jump from the footnote to the anchor. + if (eFrmType & FRMTYPE_FOOTNOTE) + { + if (rSh.GotoFtnAnchor()) + nFuncId = FN_FOOTNOTE_TO_ANCHOR; + } + // Otherwise, jump to the first footnote text; + // go to the next footnote if this is not possible; + // if this is also not possible got to the footnote before. + 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 = 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, bOutlineWithChildren); + } + break; + case FN_GLOBAL_SWITCH: + { + ToggleTree(); + pConfig->SetGlobalActive(IsGlobalMode()); + } + break; + case FN_GLOBAL_SAVE_CONTENT: + { + 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; +} + +// Click handler of the toolboxes + +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; +} + +IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox ) +{ + const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); + switch (nCurrItemId) + { + case FN_CREATE_NAVIGATION: + { + CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), true, this); + } + 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, true ); + pMenu->Execute( pBox, + pBox->GetItemRect(FN_DROP_REGION), + POPUPMENU_EXECUTE_DOWN ); + pBox->SetItemDown( nCurrItemId, 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, OUString::number(i - 100) ); + pMenu->SetHelpId( i, HID_NAVI_OUTLINES ); + } + pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 ); + pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); + pBox->SetItemDown( nCurrItemId, true ); + pMenu->Execute( pBox, + pBox->GetItemRect(FN_OUTLINE_LEVEL), + POPUPMENU_EXECUTE_DOWN ); + pBox->SetItemDown( nCurrItemId, false ); + delete pMenu; + pBox->EndSelection(); + pBox->Invalidate(); + } + break; + } + return sal_True; +} + +SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) : + SwHelpToolBox(pParent, rResId) +{} + +void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt) +{ + if(rEvt.GetButtons() == MOUSE_LEFT && + FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel())) + { + ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), false, this); + } + else + SwHelpToolBox::MouseButtonDown(rEvt); +} + +void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, bool bSetFocus, Window *pParent) +{ + Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface(); + SwScrollNaviPopup* pPopup = new + SwScrollNaviPopup(FN_SCROLL_NAVIGATION, xFrame, pParent); + + 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(); + } +} + +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); +} + +// Action-Handler Edit: +// Switches to the page if the structure view is not turned on. + +IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit ) +{ + SwView *pView = GetCreateView(); + if (pView) + { + if(aPageChgTimer.IsActive()) + aPageChgTimer.Stop(); + pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), true); + pCreateView->GetEditWin().GrabFocus(); + pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE); + } + return 0; +} + +// If the page can be set here, the maximum is set. + +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; +} + +bool SwNavigationPI::Close() +{ + SfxViewFrame* pVFrame = pCreateView->GetViewFrame(); + pVFrame->GetBindings().Invalidate(SID_NAVIGATOR); + pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR); + return true; +} + +// Setting of an automatic mark + +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->getAllMarksBegin(); + ppMark != pMarkAccess->getAllMarksEnd(); + ++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(), OUString(), OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER); + SwView::SetActMark( nAutoMarkIdx ); + + if(++nAutoMarkIdx == MAX_MARKS) + nAutoMarkIdx = 0; +} + +void SwNavigationPI::GotoPage() +{ + if (pContextWin && pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp()) + _ZoomIn(); + if(IsGlobalMode()) + ToggleTree(); + UsePage(0); + GetPageEdit().GrabFocus(); +} + +void SwNavigationPI::_ZoomOut() +{ + if (_IsZoomedIn()) + { + FloatingWindow* pFloat = pContextWin!=NULL ? pContextWin->GetFloatingWindow() : NULL; + bIsZoomedIn = false; + Size aSz(GetOutputSizePixel()); + aSz.Height() = nZoomOut; + Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel(); + ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size( + aMinOutSizePixel.Width(),nZoomOutInit)); + if (pFloat != NULL) + pFloat->SetOutputSizePixel(aSz); + FillBox(); + if(IsGlobalMode()) + { + aGlobalTree.ShowTree(); + } + else + { + aContentTree.ShowTree(); + aDocListBox.Show(); + } + SvTreeListEntry* pFirst = aContentTree.FirstSelected(); + if(pFirst) + aContentTree.Select(pFirst, true); // Enable toolbox + pConfig->SetSmall( false ); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX); + } +} + +void SwNavigationPI::_ZoomIn() +{ + if (pContextWin != NULL) + { + FloatingWindow* pFloat = pContextWin->GetFloatingWindow(); + if (pFloat && + (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp()))) + { + aContentTree.HideTree(); + aDocListBox.Hide(); + aGlobalTree.HideTree(); + bIsZoomedIn = 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); + SvTreeListEntry* pFirst = aContentTree.FirstSelected(); + if(pFirst) + aContentTree.Select(pFirst, true); // Enable toolbox + pConfig->SetSmall( true ); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, false); + } + } +} + +void SwNavigationPI::Resize() +{ + Window* pParent = GetParent(); + if( !_IsZoomedIn() ) + { + Size aNewSize (pParent->GetOutputSizePixel()); + + SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(pParent); + if (pDockingParent != NULL) + { + FloatingWindow* pFloat = pDockingParent->GetFloatingWindow(); + //change the minimum width depending on the dock status + Size aMinOutSizePixel = pDockingParent->GetMinOutputSizePixel(); + if( pFloat) + { + aNewSize = pFloat->GetOutputSizePixel(); + aMinOutSizePixel.Width() = nWishWidth; + aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit; + } + else + { + aMinOutSizePixel.Width() = 0; + aMinOutSizePixel.Height() = 0; + } + pDockingParent->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 starts on to the top and goes all the way down. + 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); + } +} + +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)), + 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(false), + bIsZoomedIn(false), + bPageCtrlsVisible(false), + bGlobalMode(false) +{ + GetCreateView(); + InitImageList(); + + aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX ); + aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX); + aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX ); + aDocListBox.SetDropDownLineCount(9); + + nDocLBIniHeight = aDocListBox.GetSizePixel().Height(); + nZoomOutInit = nZoomOut = Resource::ReadShortRes(); + + // Insert the numeric field in the toolbox. + NumEditAction* pEdit = new NumEditAction( + &aContentToolBox, SW_RES(NF_PAGE )); + pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction)); + pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus)); + pEdit->SetAccessibleName(pEdit->GetQuickHelpText()); + pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); + pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); + + bPageCtrlsVisible = true; + + // Double separators are not allowed, so you have to + // determine the suitable size differently. + 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; + + // The left and right margins around the toolboxes should be equal. + nWishWidth = aContentToolboxSize.Width(); + nWishWidth += 2 * aContentToolBox.GetPosPixel().X(); + + DockingWindow* pDockingParent = dynamic_cast<DockingWindow*>(pParent); + if (pDockingParent != NULL) + { + FloatingWindow* pFloat = pDockingParent->GetFloatingWindow(); + Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0); + pDockingParent->SetMinOutputSizePixel(aMinSize); + SetOutputSizePixel( Size( nWishWidth, nZoomOutInit)); + + SfxDockingWindow* pSfxDockingParent = dynamic_cast<SfxDockingWindow*>(pParent); + if (pSfxDockingParent != NULL) + { + Size aTmpParentSize(pSfxDockingParent->GetSizePixel()); + if (aTmpParentSize.Width() < aMinSize.Width() + || aTmpParentSize.Height() < aMinSize.Height()) + { + if (pSfxDockingParent->GetFloatingWindow() + && ! pSfxDockingParent->GetFloatingWindow()->IsRollUp()) + { + pSfxDockingParent->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(true); + aContentTree.ShowTree(); + aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, true); + +// TreeListBox for global document + 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, 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]); + + if (pContextWin == NULL) + { + // When the context window is missing then the navigator is + // displayed in the sidebar. While the navigator could change + // its size, the sidebar can not, and the navigator would just + // waste space. Therefore hide this button. + aContentToolBox.RemoveItem(aContentToolBox.GetItemPos(FN_SHOW_CONTENT_BOX)); + } +} + +SwNavigationPI::~SwNavigationPI() +{ + if(IsGlobalDoc() && !IsGlobalMode()) + { + SwView *pView = GetCreateView(); + SwWrtShell &rSh = pView->GetWrtShell(); + if( !rSh.IsAllProtect() ) + pView->GetDocShell()->SetReadOnlyUI(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); +} + +void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow ) +{ + pPopupWindow = pWindow; + pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl )); + pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow )); +} + +IMPL_LINK_NOARG(SwNavigationPI, PopupModeEndHdl) +{ + 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; +} + +IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow ) +{ + if ( pWindow == pFloatingWindow ) + pFloatingWindow = 0; + else + pPopupWindow = 0; + + return 1; +} + +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); + 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(); + } +} + +// Get the numeric field from the toolbox. + +NumEditAction& SwNavigationPI::GetPageEdit() +{ + return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER); +} + +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; + +} + +// Notification on modified 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( false )) + aGlobalTree.Display(); + else + // If no update is needed, then paint at least, + // because of the red entries for the broken links. + aGlobalTree.Invalidate(); + } + } + } + } + } +} + +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; +} + +void SwNavigationPI::UpdateListBox() +{ + aDocListBox.SetUpdateMode(false); + aDocListBox.Clear(); + SwView *pActView = GetCreateView(); + 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(); + // #i53333# don't show help pages here + if ( !pDoc->IsHelpDocument() ) + { + OUString sEntry = pDoc->GetTitle(); + sEntry += " ("; + 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]); // "Active Window" + nCount++; + + if(aContentTree.GetHiddenWrtShell()) + { + OUString sEntry = aContentTree.GetHiddenWrtShell()->GetView(). + GetDocShell()->GetTitle(); + sEntry += " ("; + sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST]; + sEntry += ")"; + aDocListBox.InsertEntry(sEntry); + bDisable = false; + } + if(aContentTree.IsActiveView()) + { + //Either the name of the current Document or "Active Document". + 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(true); +} + +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()); + OSL_ENSURE(pContentView, "no SwView"); + if(pContentView) + pContentWrtShell = pContentView->GetWrtShellPtr(); + else + pContentWrtShell = 0; + pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell()); + FillBox(); + aContentTree.Update(); + } + } + return 0; +} + +OUString SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData ) +{ + OUString 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( aEmptyOUStr, aEmptyOUStr ); + rData.GetINetBookmark( nFmt, aBkmk ); + sFileName = aBkmk.GetURL(); + } + if( !sFileName.isEmpty() ) + { + sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE ); + } + return sFileName; +} + +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; + OUString sFileName; + if( !aContentTree.IsInDrag() && + !(sFileName = SwNavigationPI::CreateDropFileName( aData )).isEmpty() ) + { + INetURLObject aTemp( sFileName ); + GraphicDescriptor aDesc( aTemp ); + if( !aDesc.Detect() ) // accept no graphics + { + if( -1 == sFileName.indexOf('#') + && (sContentFileName.isEmpty() || sContentFileName != sFileName )) + { + nRet = rEvt.mnAction; + sFileName = comphelper::string::stripEnd(sFileName, 0); + sContentFileName = sFileName; + if(pxObjectShell) + { + aContentTree.SetHiddenShell( 0 ); + (*pxObjectShell)->DoClose(); + DELETEZ( pxObjectShell); + } + SfxStringItem aFileItem(SID_FILE_NAME, sFileName ); + SfxStringItem aOptionsItem( SID_OPTIONS, OUString("HRC") ); + SfxLinkItem aLink( SID_DONELINK, + LINK( this, SwNavigationPI, DoneLink ) ); + GetActiveView()->GetViewFrame()->GetDispatcher()->Execute( + SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, + &aFileItem, &aOptionsItem, &aLink, 0L ); + } + } + } + return nRet; +} + +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 = aContentImageList; + + aContentToolBox.SetItemImage( FN_DROP_REGION, rImgLst.GetImage(nDropId)); +} + +bool SwNavigationPI::ToggleTree() +{ + bool bRet = true; + bool bGlobalDoc = IsGlobalDoc(); + if(!IsGlobalMode() && bGlobalDoc) + { + SetUpdateMode(false); + if(_IsZoomedIn()) + _ZoomOut(); + aGlobalTree.ShowTree(); + aGlobalToolBox.Show(); + aContentTree.HideTree(); + aContentToolBox.Hide(); + aDocListBox.Hide(); + SetGlobalMode(true); + SetUpdateMode(true); + } + else + { + aGlobalTree.HideTree(); + aGlobalToolBox.Hide(); + if(!_IsZoomedIn()) + { + aContentTree.ShowTree(); + aContentToolBox.Show(); + aDocListBox.Show(); + } + bRet = false; + SetGlobalMode(false); + } + return bRet; +} + +bool SwNavigationPI::IsGlobalDoc() const +{ + bool bRet = false; + SwView *pView = GetCreateView(); + if(pView) + { + SwWrtShell &rSh = pView->GetWrtShell(); + bRet = rSh.IsGlobalDoc(); + } + return bRet; +} + +IMPL_LINK_NOARG(SwNavigationPI, ChangePageHdl) +{ + EditAction(&GetPageEdit()); + GetPageEdit().GrabFocus(); + return 0; +} + +IMPL_LINK_NOARG(SwNavigationPI, PageEditModifyHdl) +{ + if(aPageChgTimer.IsActive()) + aPageChgTimer.Stop(); + aPageChgTimer.Start(); + return 0; +} + +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; +} + +SwNavigationChild::SwNavigationChild( Window* pParent, + sal_uInt16 nId, + SfxBindings* _pBindings, + SfxChildWinInfo* ) + : SfxChildWindowContext( nId ) +{ + SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent ); + SetWindow( pNavi ); + _pBindings->Invalidate(SID_NAVIGATOR); + + 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, true); + } + pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); + pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) ); + + if(GetFloatingWindow() && pNaviConfig->IsSmall()) + { + pNavi->_ZoomIn(); + } +} + +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 ); + } +} + +void SwNavigationPI::InitImageList() +{ + sal_uInt16 k; + + ImageList& rImgLst = 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)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/navipi.hrc b/sw/source/uibase/utlui/navipi.hrc new file mode 100644 index 000000000000..651cd0dba506 --- /dev/null +++ b/sw/source/uibase/utlui/navipi.hrc @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#define IL_CONTENT 7 +#define FT_PAGE 10 +#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 for the context menu of the content tree +#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) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/navipi.src b/sw/source/uibase/utlui/navipi.src new file mode 100644 index 000000000000..cf9ec60cb605 --- /dev/null +++ b/sw/source/uibase/utlui/navipi.src @@ -0,0 +1,484 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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 ( 282 , 59 ) ; + Hide = TRUE ; + Text [ en-US ] = "Navigator" ; + ExtraData = + { + 198; + }; +#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 + }; + 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 ; + HelpID = HID_NAVI_TBX2 ; + Text [ en-US ] = "Back" ; + }; + ToolBoxItem + { + Identifier = FN_DOWN ; + HelpID = HID_NAVI_TBX3 ; + Text [ en-US ] = "Forward" ; + }; + ToolBoxItem + { + Identifier = FN_DROP_REGION ; + HelpID = HID_NAVI_TBX4 ; + DropDown = TRUE ; + Text [ en-US ] = "Drag Mode" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_UP ; + HelpID = HID_NAVI_TBX5 ; + Text [ en-US ] = "Promote Chapter" ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_DOWN ; + 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 ; + Text [ en-US ] = "Set Reminder" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_HEADER ; + HelpID = HID_NAVI_TBX10 ; + Text [ en-US ] = "Header" ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_FOOTER ; + HelpID = HID_NAVI_TBX11 ; + Text [ en-US ] = "Footer" ; + }; + ToolBoxItem + { + Identifier = FN_SELECT_FOOTNOTE ; + HelpID = HID_NAVI_TBX12 ; + Text [ en-US ] = "Anchor<->Text" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_OUTLINE_LEVEL ; + HelpID = HID_NAVI_TBX13 ; + Text [ en-US ] = "Heading Levels Shown" ; + DropDown = TRUE ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_LEFT ; + HelpID = HID_NAVI_TBX14 ; + Text [ en-US ] = "Promote Level" ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_RIGHT ; + 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 ; + 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 ; + Text [ en-US ] = "Move Up" ; + }; + ToolBoxItem + { + Identifier = FN_ITEM_DOWN ; + HelpID = HID_NAVI_TBX23 ; + 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 as 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 + { + Text [ en-US ] = "Insert as Hyperlink" ; + }; + String ST_LINK_REGION + { + Text [ en-US ] = "Insert as Link" ; + }; + String ST_COPY_REGION + { + 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 + { + 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 + { + 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 + { + 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 +}; + +String STR_ACCESS_TL_GLOBAL +{ + Text [ en-US ] = "Global View"; +}; +String STR_ACCESS_TL_CONTENT +{ + Text [ en-US ] = "Content View"; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx new file mode 100644 index 000000000000..55ac0d15725d --- /dev/null +++ b/sw/source/uibase/utlui/numfmtlb.cxx @@ -0,0 +1,488 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <hintids.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> +#include <editeng/unolingu.hxx> +#include <unotools/localedatawrapper.hxx> +#include <i18nlangtag/lang.h> +#include <svl/zformat.hxx> +#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 + +/** + * Description: + * nFormatType: Display the formats of this Type + * nDefFmt: Select this format and possibly insert it + */ + +NumFormatListBox::NumFormatListBox(Window* pWin, WinBits nStyle) : + ListBox ( pWin, nStyle ), + nCurrFormatType (-1), + nStdEntry (0), + bOneArea (false), + nDefFormat (0), + pVw (0), + pOwnFormatter (0), + bShowLanguageControl(false), + bUseAutomaticLanguage(true) +{ + Init(NUMBERFORMAT_NUMBER, true); +} + +extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNumFormatListBox(Window *pParent, VclBuilder::stringmap &rMap) +{ + WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK; + + bool bDropdown = VclBuilder::extractDropdown(rMap); + + if (bDropdown) + nBits |= WB_DROPDOWN; + else + nBits |= WB_BORDER; + + NumFormatListBox* pListBox = new NumFormatListBox(pParent, nBits|WB_SIMPLEMODE); + + if (bDropdown) + pListBox->EnableAutoSize(true); + + return pListBox; +} + +void NumFormatListBox::Init(short nFormatType, bool bUsrFmts) +{ + SwView *pView = GetView(); + + if (pView) + eCurLanguage = pView->GetWrtShell().GetCurLang(); + else + eCurLanguage = SvtSysLocale().GetLanguageTag().getLanguageType(); + + if (bUsrFmts == false) + { + pOwnFormatter = new SvNumberFormatter(comphelper::getProcessComponentContext(), eCurLanguage); + } + + SetFormatType(nFormatType); + SetDefFormat(nDefFormat); + + SetSelectHdl(LINK(this, NumFormatListBox, SelectHdl)); +} + +NumFormatListBox::~NumFormatListBox() +{ + delete pOwnFormatter; +} + +SwView* NumFormatListBox::GetView() +{ + if( pVw ) + return pVw; + return ::GetActiveView(); +} + +void NumFormatListBox::SetFormatType(const short nFormatType) +{ + if (nCurrFormatType == -1 || + (nCurrFormatType & nFormatType) == 0) // there are mixed formats, like for example DateTime + { + SvNumberFormatter* pFormatter; + + if( pOwnFormatter ) + pFormatter = pOwnFormatter; + else + { + SwView *pView = GetView(); + OSL_ENSURE(pView, "no view found"); + if(!pView) + return; + SwWrtShell &rSh = pView->GetWrtShell(); + pFormatter = rSh.GetNumberFormatter(); + } + + Clear(); // Remove all entries from the Listbox + + 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: + OSL_FAIL("what a format?"); + break; + } + + const SvNumberformat* pFmt; + sal_uInt16 nPos, i = 0; + sal_uLong nFormat; + Color* pCol; + double fVal = GetDefValue( nFormatType ); + OUString 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 ) + { + pFormatter->GetOutputString( "\"ABC\"", 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; + } +} + +void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt) +{ + if (nDefFmt == ULONG_MAX) + { + nDefFormat = nDefFmt; + return; + } + + SvNumberFormatter* pFormatter; + if (pOwnFormatter) + pFormatter = pOwnFormatter; + else + { + SwView *pView = GetView(); + OSL_ENSURE(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; + } + } + + // No entry found: + double fValue = GetDefValue(nType); + OUString sValue; + Color* pCol = 0; + + if (nType == NUMBERFORMAT_TEXT) + { + pFormatter->GetOutputString("\"ABC\"", 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); + bool bSysLang = false; + if( eCurLanguage == GetAppLanguage() ) + bSysLang = 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 += SW_RES(RID_STR_SYSTEM); + } + + nPos = InsertEntry(sValue, nPos); // Insert as first numeric entry + SetEntryData(nPos, (void*)nDefFmt); + SelectEntryPos(nPos); + nDefFormat = GetFormat(); +} + +sal_uLong NumFormatListBox::GetFormat() const +{ + sal_Int32 nPos = GetSelectEntryPos(); + + return (sal_uLong)GetEntryData(nPos); +} + +IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox ) +{ + sal_uInt16 nPos = pBox->GetSelectEntryPos(); + OUString 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(); + OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); + + SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aCoreSet, + GetView()->GetViewFrame()->GetFrame().GetFrameInterface(), + RC_DLG_SWNUMFMTDLG ); + OSL_ENSURE(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, 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, false, &pItem )) + { + bUseAutomaticLanguage = ((const SfxBoolItem*)pItem)->GetValue(); + } + } + else + SetDefFormat(nFormat); + + delete pDlg; + } + return 0; +} + +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; + + 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; +} + +void NumFormatListBox::Clear() +{ + ListBox::Clear(); + nCurrFormatType = -1; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/prcntfld.cxx b/sw/source/uibase/utlui/prcntfld.cxx new file mode 100644 index 000000000000..cd4863753d10 --- /dev/null +++ b/sw/source/uibase/utlui/prcntfld.cxx @@ -0,0 +1,287 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "prcntfld.hxx" + +PercentField::PercentField() + : m_pField(NULL) + , nRefValue(0) + , nOldMax(0) + , nOldMin(0) + , nOldSpinSize(0) + , nOldBaseValue(0) + , nLastPercent(-1) + , nLastValue(-1) + , nOldDigits(0) + , eOldUnit(FUNIT_NONE) + , bLockAutoCalculation(false) +{ +} + +void PercentField::set(MetricField *pField) +{ + m_pField = pField; + nOldSpinSize = m_pField->GetSpinSize(); + nRefValue = DenormalizePercent(m_pField->GetMax(FUNIT_TWIP)); + nOldDigits = m_pField->GetDecimalDigits(); + m_pField->SetCustomUnitText(OUString('%')); +} + +void PercentField::SetRefValue(sal_Int64 nValue) +{ + sal_Int64 nRealValue = GetRealValue(eOldUnit); + + nRefValue = nValue; + + if (!bLockAutoCalculation && (m_pField->GetUnit() == FUNIT_CUSTOM)) + SetPrcntValue(nRealValue, eOldUnit); +} + +void PercentField::ShowPercent(bool bPercent) +{ + if ((bPercent && m_pField->GetUnit() == FUNIT_CUSTOM) || + (!bPercent && m_pField->GetUnit() != FUNIT_CUSTOM)) + return; + + sal_Int64 nOldValue; + + if (bPercent) + { + sal_Int64 nAktWidth, nPercent; + + nOldValue = GetValue(); + + eOldUnit = m_pField->GetUnit(); + nOldDigits = m_pField->GetDecimalDigits(); + nOldMin = m_pField->GetMin(); + nOldMax = m_pField->GetMax(); + nOldSpinSize = m_pField->GetSpinSize(); + nOldBaseValue = m_pField->GetBaseValue(); + m_pField->SetUnit(FUNIT_CUSTOM); + m_pField->SetDecimalDigits( 0 ); + + nAktWidth = m_pField->ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + // round to 0.5 percent + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + + m_pField->SetMin(std::max(static_cast< sal_Int64 >(1), nPercent)); + m_pField->SetMax(100); + m_pField->SetSpinSize(5); + m_pField->SetBaseValue(0); + if (nOldValue != nLastValue) + { + nAktWidth = m_pField->ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + m_pField->SetValue(nPercent); + nLastPercent = nPercent; + nLastValue = nOldValue; + } + else + m_pField->SetValue(nLastPercent); + } + else + { + sal_Int64 nOldPercent = GetValue(FUNIT_CUSTOM); + + nOldValue = Convert(GetValue(), m_pField->GetUnit(), eOldUnit); + + m_pField->SetUnit(eOldUnit); + m_pField->SetDecimalDigits(nOldDigits); + m_pField->SetMin(nOldMin); + m_pField->SetMax(nOldMax); + m_pField->SetSpinSize(nOldSpinSize); + m_pField->SetBaseValue(nOldBaseValue); + + if (nOldPercent != nLastPercent) + { + SetPrcntValue(nOldValue, eOldUnit); + nLastPercent = nOldPercent; + nLastValue = nOldValue; + } + else + SetPrcntValue(nLastValue, eOldUnit); + } +} + +void PercentField::SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM) + m_pField->SetValue(Convert(nNewValue, eInUnit, m_pField->GetUnit())); + else + { + // Overwrite output value, do not restore later + sal_Int64 nPercent, nAktWidth; + if(eInUnit == FUNIT_TWIP) + { + nAktWidth = m_pField->ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP); + } + else + { + sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit); + nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + } + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + m_pField->SetValue(nPercent); + } +} + +void PercentField::SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + if (m_pField->GetUnit() == FUNIT_CUSTOM) + nOldBaseValue = m_pField->ConvertValue(nNewValue, 0, nOldDigits, eInUnit, eOldUnit); + else + m_pField->SetBaseValue(nNewValue, eInUnit); +} + +sal_Int64 PercentField::GetValue(FieldUnit eOutUnit) +{ + return Convert(m_pField->GetValue(), m_pField->GetUnit(), eOutUnit); +} + +void PercentField::SetMin(sal_Int64 nNewMin, FieldUnit eInUnit) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM) + m_pField->SetMin(nNewMin, eInUnit); + else + { + if (eInUnit == FUNIT_NONE) + eInUnit = eOldUnit; + nOldMin = Convert(nNewMin, eInUnit, eOldUnit); + + sal_Int64 nPercent = Convert(nNewMin, eInUnit, FUNIT_CUSTOM); + m_pField->SetMin(std::max( static_cast< sal_Int64 >(1), nPercent)); + } +} + +void PercentField::SetMax(sal_Int64 nNewMax, FieldUnit eInUnit) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM) + m_pField->SetMax(nNewMax, eInUnit); + else + { + if (eInUnit == FUNIT_NONE) + eInUnit = eOldUnit; + } +} + +sal_Int64 PercentField::NormalizePercent(sal_Int64 nValue) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM) + nValue = m_pField->Normalize(nValue); + else + nValue = nValue * ImpPower10(nOldDigits); + return nValue; +} + +sal_Int64 PercentField::DenormalizePercent(sal_Int64 nValue) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM) + nValue = m_pField->Denormalize(nValue); + else + { + sal_Int64 nFactor = ImpPower10(nOldDigits); + nValue = ((nValue+(nFactor/2)) / nFactor); + } + return nValue; +} + +bool PercentField::IsValueModified() +{ + if (m_pField->GetUnit() == FUNIT_CUSTOM) + return true; + else + return m_pField->IsValueModified(); +} + +void PercentField::SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM || eInUnit == FUNIT_CUSTOM) + m_pField->SetUserValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()),FUNIT_NONE); + else + { + // Overwrite output value, do not restore later + sal_Int64 nPercent, nAktWidth; + if (eInUnit == FUNIT_TWIP) + { + nAktWidth = m_pField->ConvertValue(nNewValue, 0, nOldDigits, FUNIT_TWIP, FUNIT_TWIP); + } + else + { + sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit); + nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eOldUnit, FUNIT_TWIP); + } + nPercent = ((nAktWidth * 10) / nRefValue + 5) / 10; + m_pField->SetUserValue(nPercent,FUNIT_NONE); + } +} + +sal_Int64 PercentField::ImpPower10(sal_uInt16 n) +{ + sal_Int64 nValue = 1; + + for (sal_uInt16 i=0; i < n; ++i) + nValue *= 10; + + return nValue; +} + +sal_Int64 PercentField::GetRealValue(FieldUnit eOutUnit) +{ + if (m_pField->GetUnit() != FUNIT_CUSTOM) + return GetValue(eOutUnit); + else + return Convert(GetValue(), m_pField->GetUnit(), eOutUnit); +} + +sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) +{ + if (eInUnit == eOutUnit || + (eInUnit == FUNIT_NONE && eOutUnit == m_pField->GetUnit()) || + (eOutUnit == FUNIT_NONE && eInUnit == m_pField->GetUnit())) + return nValue; + + if (eInUnit == FUNIT_CUSTOM) + { + // Convert to metric + sal_Int64 nTwipValue = (nRefValue * nValue + 50) / 100; + + if (eOutUnit == FUNIT_TWIP) // Only convert if necessary + return NormalizePercent(nTwipValue); + else + return m_pField->ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FUNIT_TWIP, eOutUnit); + } + + if (eOutUnit == FUNIT_CUSTOM) + { + // Convert to percent + sal_Int64 nAktWidth; + nValue = DenormalizePercent(nValue); + + if (eInUnit == FUNIT_TWIP) // Only convert if necessary + nAktWidth = nValue; + else + nAktWidth = m_pField->ConvertValue(nValue, 0, nOldDigits, eInUnit, FUNIT_TWIP); + // Round to 0.5 percent + return ((nAktWidth * 1000) / nRefValue + 5) / 10; + } + + return m_pField->ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/shdwcrsr.cxx b/sw/source/uibase/utlui/shdwcrsr.cxx new file mode 100644 index 000000000000..6e30e2ff21f5 --- /dev/null +++ b/sw/source/uibase/utlui/shdwcrsr.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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, bool bLeft ) +{ + long nLineDiff = ( nHeight / 2 ); + long nLineDiffHalf = nLineDiff / 2; + + // Dot above + Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3), + rPt.Y() + nLineDiffHalf ); + // Dot below + 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. The Line: + pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1), + Point( rPt.X(), rPt.Y() - 2 + nHeight )); + + // 2. The Triangle + if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the right + DrawTri( rPt, nHeight, false ); + if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the left + DrawTri( rPt, nHeight, 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 ) ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/tmplctrl.cxx b/sw/source/uibase/utlui/tmplctrl.cxx new file mode 100644 index 000000000000..0f774e395fbc --- /dev/null +++ b/sw/source/uibase/utlui/tmplctrl.cxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svl/style.hxx> +#include <vcl/menu.hxx> +#include <svl/stritem.hxx> +#include <sfx2/dispatch.hxx> +#include <vcl/status.hxx> + +#include "wrtsh.hxx" +#include "view.hxx" +#include "swmodule.hxx" +#include "cmdid.h" +#include "docsh.hxx" +#include "tmplctrl.hxx" + +SFX_IMPL_STATUSBAR_CONTROL( SwTemplateControl, SfxStringItem ); + +class SwTemplatePopup_Impl : public PopupMenu +{ +public: + SwTemplatePopup_Impl(); + + sal_uInt16 GetCurId() const { return nCurId; } + +private: + sal_uInt16 nCurId; + + virtual void Select() SAL_OVERRIDE; +}; + +SwTemplatePopup_Impl::SwTemplatePopup_Impl() : + PopupMenu(), + nCurId(USHRT_MAX) +{ +} + +void SwTemplatePopup_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(), OUString() ); + 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() ).isEmpty() ) + { + CaptureMouse(); + SwTemplatePopup_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) + { + // looks a bit awkward, but another way is not possible + 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(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx new file mode 100644 index 000000000000..a819ffc9f087 --- /dev/null +++ b/sw/source/uibase/utlui/uiitems.cxx @@ -0,0 +1,317 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <editeng/itemtype.hxx> +#include <unosett.hxx> + +#include "swtypes.hxx" +#include "cmdid.h" +#include "uiitems.hxx" + +#include "utlui.hrc" +#include "attrdesc.hrc" +#include <unomid.h> +#include <numrule.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +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 ); +} + +bool SwPageFtnInfoItem::operator==( const SfxPoolItem& rAttr ) const +{ + OSL_ENSURE( Which() == rAttr.Which(), "no equal attributes" ); + return ( aFtnInfo == ((SwPageFtnInfoItem&)rAttr).GetPageFtnInfo()); +} + +SfxItemPresentation SwPageFtnInfoItem::GetPresentation +( + SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + OUString& rText, + const IntlWrapper* pIntl +) const +{ + switch ( ePres ) + { + case SFX_ITEM_PRESENTATION_NONE: + rText = OUString(); + 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 ) + " " + + ::GetMetricText( nHght, eCoreUnit, ePresUnit, pIntl ) + " " + + ::GetSvxString( ::GetMetricId( ePresUnit ) ); + } + return ePres; + } + default:; //prevent warning + } + return SFX_ITEM_PRESENTATION_NONE; +} + +bool SwPageFtnInfoItem::QueryValue( Any& rVal, sal_uInt8 nMemberId ) const +{ + bool bRet = true; + switch(nMemberId & ~CONVERT_TWIPS) + { + case MID_FTN_HEIGHT : rVal <<= (sal_Int32)convertTwipToMm100(aFtnInfo.GetHeight());break; + case MID_LINE_WEIGHT : rVal <<= (sal_Int16)convertTwipToMm100(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)convertTwipToMm100(aFtnInfo.GetTopDist());break; + case MID_LINE_FOOTNOTE_DIST: rVal <<= (sal_Int32)convertTwipToMm100(aFtnInfo.GetBottomDist());break; + case MID_FTN_LINE_STYLE : + { + switch ( aFtnInfo.GetLineStyle( ) ) + { + default: + case table::BorderLineStyle::NONE : rVal <<= sal_Int8(0); break; + case table::BorderLineStyle::SOLID: rVal <<= sal_Int8(1); break; + case table::BorderLineStyle::DOTTED: rVal <<= sal_Int8(2); break; + case table::BorderLineStyle::DASHED: rVal <<= sal_Int8(3); break; + } + break; + } + default: + bRet = false; + } + return bRet; +} + +bool SwPageFtnInfoItem::PutValue(const Any& rVal, sal_uInt8 nMemberId) +{ + sal_Int32 nSet32 = 0; + bool bRet = 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 = false; + else + { + nSet32 = convertMm100ToTwip(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(convertMm100ToTwip(nSet)); + else + bRet = false; + } + break; + case MID_LINE_RELWIDTH : + { + sal_Int8 nSet = 0; + rVal >>= nSet; + if(nSet < 0) + bRet = 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 = false; + } + case MID_FTN_LINE_STYLE: + { + ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::NONE; + sal_Int8 nSet = 0; + rVal >>= nSet; + switch ( nSet ) + { + case 1: eStyle = table::BorderLineStyle::SOLID; break; + case 2: eStyle = table::BorderLineStyle::DOTTED; break; + case 3: eStyle = table::BorderLineStyle::DASHED; break; + default: break; + } + aFtnInfo.SetLineStyle( eStyle ); + } + break; + default: + bRet = false; + } + return bRet; +} + +SwPtrItem::SwPtrItem( const sal_uInt16 nId, void* pPtr ) : + SfxPoolItem( nId ), + pMisc(pPtr) +{ +} + +// Copy constructor + +SwPtrItem::SwPtrItem( const SwPtrItem& rItem ) : SfxPoolItem( rItem ) +{ + pMisc = rItem.pMisc; +} + +// Cloning + +SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwPtrItem( *this ); +} + +bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const +{ + OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" ); + const SwPtrItem& rItem = (SwPtrItem&)rAttr; + return ( pMisc == rItem.pMisc ); +} + +// SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists + +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 ); +} + +bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const +{ + OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" ); + return *pRule == *((SwUINumRuleItem&)rAttr).pRule; +} + +bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const +{ + uno::Reference< container::XIndexReplace >xRules = new SwXNumberingRules(*pRule); + rVal.setValue(&xRules, cppu::UnoType<container::XIndexReplace>::get()); + return true; +} +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 true; +} + +SwBackgroundDestinationItem::SwBackgroundDestinationItem(sal_uInt16 _nWhich, sal_uInt16 nValue) : + SfxUInt16Item(_nWhich, nValue) +{ +} + +SfxPoolItem* SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwBackgroundDestinationItem(Which(), GetValue()); +} + +SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) : + SfxPoolItem( nId ), + m_pPaM(pPaM) +{ +} + +SwPaMItem::SwPaMItem( const SwPaMItem& rItem ) : SfxPoolItem( rItem ) +{ + m_pPaM = rItem.m_pPaM; +} + +SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SwPaMItem( *this ); +} + +bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const +{ + OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" ); + const SwPaMItem& rItem = (SwPaMItem&)rAttr; + return ( m_pPaM == rItem.m_pPaM ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx new file mode 100644 index 000000000000..b3e62598e4f0 --- /dev/null +++ b/sw/source/uibase/utlui/uitool.cxx @@ -0,0 +1,815 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <hintids.hxx> + +#include <osl/diagnose.h> +#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> +#include <editeng/tstpitem.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/shaditem.hxx> +#include <editeng/sizeitem.hxx> +#include <editeng/brushitem.hxx> +#include <svx/pageitem.hxx> +#include <editeng/lrspitem.hxx> +#include <svl/style.hxx> +#include <vcl/lstbox.hxx> +#include <unotools/localedatawrapper.hxx> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URLTransformer.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> +#include <docsh.hxx> +#include <wrtsh.hxx> +#include <swmodule.hxx> +#include <view.hxx> +#include <uitool.hxx> +#include <frmatr.hxx> +#include <paratr.hxx> +#include <fmtcol.hxx> +#include <poolfmt.hxx> +#include "usrpref.hxx" + +#include <cmdid.h> +#include <globals.hrc> +#include <utlui.hrc> +#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; + +// General list of string pointer + +// Switch metric + +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); +} + +// Set boxinfo attribute + +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, + true, &pBoxInfo)) + aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; + + // Table variant: If more than one table cells are selected + rSh.GetCrsr(); //So that GetCrsrCnt() returns the right thing + aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1); + // Always show the distance field + aBoxInfo.SetDist (true); + // Set minimal size in tables and paragraphs + aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL)); + // Set always the default distance + aBoxInfo.SetDefDist (MIN_BORDER_DIST); + // Single lines can have only in tables DontCare-Status + aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode()); + + rSet.Put(aBoxInfo); +} + +void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) +{ + // Background + { + const SfxPoolItem *pTmpBrush; + if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, true, &pTmpBrush ) ) + { + SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); + aTmpBrush.SetWhich( RES_BACKGROUND ); + rSet.Put( aTmpBrush ); + } + else + rSet.ClearItem(RES_BACKGROUND); + } + + if( nMode == CONV_ATTR_STD ) + { + // Border + const SfxPoolItem *pTmpItem; + if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_BOX, true, &pTmpItem ) ) + { + SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) ); + aTmpBox.SetWhich( RES_BOX ); + rSet.Put( aTmpBox ); + } + else + rSet.ClearItem(RES_BOX); + + // Border shadow + if( SFX_ITEM_SET == rSet.GetItemState( RES_CHRATR_SHADOW, false, &pTmpItem ) ) + { + SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) ); + aTmpShadow.SetWhich( RES_SHADOW ); + rSet.Put( aTmpShadow ); + } + else + rSet.ClearItem( RES_SHADOW ); + } +} + +void ConvertAttrGenToChar(SfxItemSet& rSet, const sal_uInt8 nMode) +{ + // Background + { + const SfxPoolItem *pTmpBrush; + if( SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, false, &pTmpBrush ) ) + { + SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); + aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); + rSet.Put( aTmpBrush ); + } + rSet.ClearItem( RES_BACKGROUND ); + } + + if( nMode == CONV_ATTR_STD ) + { + // Border + const SfxPoolItem *pTmpItem; + if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, false, &pTmpItem ) ) + { + SvxBoxItem aTmpBox( *((SvxBoxItem*)pTmpItem) ); + aTmpBox.SetWhich( RES_CHRATR_BOX ); + rSet.Put( aTmpBox ); + } + rSet.ClearItem( RES_BOX ); + + // Border shadow + if( SFX_ITEM_SET == rSet.GetItemState( RES_SHADOW, false, &pTmpItem ) ) + { + SvxShadowItem aTmpShadow( *((SvxShadowItem*)pTmpItem) ); + aTmpShadow.SetWhich( RES_CHRATR_SHADOW ); + rSet.Put( aTmpShadow ); + } + rSet.ClearItem( RES_SHADOW ); + } +} + +// Fill header footer + +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); + + // Convert size + SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE, + rSize.GetSize().Width(), + rSize.GetSize().Height()); + aSet.Put(aFrmSize); + pFmt->SetFmtAttr(aSet); +} + +/// Convert from UseOnPage to SvxPageUsage. +UseOnPage lcl_convertUseToSvx(UseOnPage nUse) +{ + UseOnPage nRet = nsUseOnPage::PD_NONE; + if ((nUse & nsUseOnPage::PD_LEFT) == nsUseOnPage::PD_LEFT) + nRet |= SVX_PAGE_LEFT; + if ((nUse & nsUseOnPage::PD_RIGHT) == nsUseOnPage::PD_RIGHT) + nRet |= SVX_PAGE_RIGHT; + if ((nUse & nsUseOnPage::PD_ALL) == nsUseOnPage::PD_ALL) + nRet |= SVX_PAGE_ALL; + if ((nUse & nsUseOnPage::PD_MIRROR) == nsUseOnPage::PD_MIRROR) + nRet |= SVX_PAGE_MIRROR; + return nRet; +} + +/// Convert from SvxPageUsage to UseOnPage. +UseOnPage lcl_convertUseFromSvx(UseOnPage nUse) +{ + UseOnPage nRet = nsUseOnPage::PD_NONE; + if ((nUse & SVX_PAGE_LEFT) == SVX_PAGE_LEFT) + nRet |= nsUseOnPage::PD_LEFT; + if ((nUse & SVX_PAGE_RIGHT) == SVX_PAGE_RIGHT) + nRet |= nsUseOnPage::PD_RIGHT; + if ((nUse & SVX_PAGE_ALL) == SVX_PAGE_ALL) + nRet |= nsUseOnPage::PD_ALL; + if ((nUse & SVX_PAGE_MIRROR) == SVX_PAGE_MIRROR) + nRet |= nsUseOnPage::PD_MIRROR; + return nRet; +} + +// PageDesc <-> convert into sets and back + +void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ) +{ + SwFrmFmt& rMaster = rPageDesc.GetMaster(); + int nFirstShare = -1; + + // Transfer all general frame attributes + 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) + rPageDesc.SetUseOn( lcl_convertUseFromSvx((UseOnPage) nUse) ); + rPageDesc.SetLandscape(rPageItem.IsLandscape()); + SvxNumberType aNumType; + aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) ); + rPageDesc.SetNumType(aNumType); + } + // Size + 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); + } + // Evaluate header attributes + const SfxPoolItem* pItem; + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET, + false, &pItem ) ) + { + const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet(); + const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON); + + if(rHeaderOn.GetValue()) + { + // Take over values + if(!rMaster.GetHeader().IsActive()) + rMaster.SetFmtAttr(SwFmtHeader(true)); + + // Pick out everything and adapt the header format + SwFmtHeader aHeaderFmt(rMaster.GetHeader()); + SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt(); + OSL_ENSURE(pHeaderFmt != 0, "no header format"); + + ::FillHdFt(pHeaderFmt, rHeaderSet); + + rPageDesc.ChgHeaderShare(((const SfxBoolItem&) + rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); + if (nFirstShare < 0) + { + rPageDesc.ChgFirstShare(((const SfxBoolItem&) + rHeaderSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); + nFirstShare = rPageDesc.IsFirstShared() ? 1 : 0; + } + } + else + { + // Disable header + if(rMaster.GetHeader().IsActive()) + { + rMaster.SetFmtAttr(SwFmtHeader(false)); + rPageDesc.ChgHeaderShare(false); + } + } + } + + // Evaluate footer attributes + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET, + false, &pItem ) ) + { + const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet(); + const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON); + + if(rFooterOn.GetValue()) + { + // Take over values + if(!rMaster.GetFooter().IsActive()) + rMaster.SetFmtAttr(SwFmtFooter(true)); + + // Pick out everything and adapt the footer format + SwFmtFooter aFooterFmt(rMaster.GetFooter()); + SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt(); + OSL_ENSURE(pFooterFmt != 0, "no footer format"); + + ::FillHdFt(pFooterFmt, rFooterSet); + + rPageDesc.ChgFooterShare(((const SfxBoolItem&) + rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue()); + if (nFirstShare < 0) + { + rPageDesc.ChgFirstShare(((const SfxBoolItem&) + rFooterSet.Get(SID_ATTR_PAGE_SHARED_FIRST)).GetValue()); + nFirstShare = rPageDesc.IsFirstShared() ? 1 : 0; + } + } + else + { + // Disable footer + if(rMaster.GetFooter().IsActive()) + { + rMaster.SetFmtAttr(SwFmtFooter(false)); + rPageDesc.ChgFooterShare(false); + } + } + } + + // Footnotes + + if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO, + false, &pItem ) ) + rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() ); + + // Columns + + // Register compliant + + if(SFX_ITEM_SET == rSet.GetItemState( + SID_SWREGISTER_MODE, false, &pItem)) + { + bool bSet = ((const SfxBoolItem*)pItem)->GetValue(); + if(!bSet) + rPageDesc.SetRegisterFmtColl(0); + else if(SFX_ITEM_SET == rSet.GetItemState( + SID_SWREGISTER_COLLECTION, false, &pItem)) + { + const OUString& 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 ( true )); + rPageDesc.SetRegisterFmtColl( pColl ); + } + } +} + +void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet) +{ + const SwFrmFmt& rMaster = rPageDesc.GetMaster(); + + // Page data + SvxPageItem aPageItem(SID_ATTR_PAGE); + aPageItem.SetDescName(rPageDesc.GetName()); + aPageItem.SetPageUsage(lcl_convertUseToSvx(rPageDesc.GetUseOn())); + aPageItem.SetLandscape(rPageDesc.GetLandscape()); + aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType()); + rSet.Put(aPageItem); + + // Size + SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize()); + rSet.Put(aSizeItem); + + // Maximum size + SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT)); + rSet.Put(aMaxSizeItem); + + // Margins, border and the other stuff. + rSet.Put(rMaster.GetAttrSet()); + + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + const SfxPoolItem *pBoxInfo; + if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, + true, &pBoxInfo) ) + aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo; + + aBoxInfo.SetTable( false ); + // Show always the distance field + aBoxInfo.SetDist( true); + // Set minimal size in tables and paragraphs + aBoxInfo.SetMinDist( false ); + // Set always the default distance + aBoxInfo.SetDefDist( MIN_BORDER_DIST ); + // Single lines can have only in tables DontCare-Status + aBoxInfo.SetValid( VALID_DISABLE ); + rSet.Put( aBoxInfo ); + + SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, OUString()); + 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(); + OSL_ENSURE(pHeaderFmt != 0, "no header format"); + + // HeaderInfo, margins, background, border + SfxItemSet aHeaderSet( *rSet.GetPool(), + SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, + SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0); + + // Dynamic or fixed height + SfxBoolItem aOn(SID_ATTR_PAGE_ON, 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); + + // Left equal right + SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared()); + aHeaderSet.Put(aShared); + SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared()); + aHeaderSet.Put(aFirstShared); + + // Size + SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); + aHeaderSet.Put(aSize); + + // Shifting frame attributes + aHeaderSet.Put(pHeaderFmt->GetAttrSet()); + aHeaderSet.Put( aBoxInfo ); + + // Create SetItem + 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(); + OSL_ENSURE(pFooterFmt != 0, "no footer format"); + + // FooterInfo, margins, background, border + SfxItemSet aFooterSet( *rSet.GetPool(), + SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED, + SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST, + SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0); + + // Dynamic or fixed height + SfxBoolItem aOn(SID_ATTR_PAGE_ON, 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); + + // Left equal right + SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared()); + aFooterSet.Put(aShared); + SfxBoolItem aFirstShared(SID_ATTR_PAGE_SHARED_FIRST, rPageDesc.IsFirstShared()); + aFooterSet.Put(aFirstShared); + + // Size + SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize())); + aFooterSet.Put(aSize); + + // Shifting Frame attributes + aFooterSet.Put(pFooterFmt->GetAttrSet()); + aFooterSet.Put( aBoxInfo ); + + // Create SetItem + SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet); + rSet.Put(aSetItem); + } + + // Integrate footnotes + SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo(); + SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo); + rSet.Put(aFtnItem); + + // Register compliant + 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())); + +} + +// Set DefaultTabs + +void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs) +{ + if( rTabs.Count() ) + return; + { + SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT ); + rTabs.Insert( aSwTabStop ); + } +} + +// Distance between two 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; +} + +// Inquire if in the set is a Sfx-PageDesc combination present and return it. +void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet ) +{ + const SfxPoolItem* pItem; + SwFmtPageDesc aPgDesc; + + bool bChanged = false; + // Page number + if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem)) + { + aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue()); + bChanged = true; + } + if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem )) + { + const OUString& rDescName = ((SvxPageModelItem*)pItem)->GetValue(); + if( !rDescName.isEmpty() ) // No name -> disable PageDesc! + { + // Delete only, if PageDesc will be enabled! + rSet.ClearItem( RES_BREAK ); + SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName( + rDescName, true ); + if( pDesc ) + aPgDesc.RegisterToPageDesc( *pDesc ); + } + rSet.ClearItem( SID_ATTR_PARA_MODEL ); + bChanged = true; + } + else + { + SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC ); + rShell.GetCurAttr( aCoreSet ); + if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) ) + { + if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) + { + aPgDesc.RegisterToPageDesc( *((SwFmtPageDesc*)pItem)->GetPageDesc() ); + } + } + } + + if(bChanged) + rSet.Put( aPgDesc ); +} + +// Inquire if in the set is a Sfx-PageDesc combination present and return it. +void SwToSfxPageDescAttr( SfxItemSet& rCoreSet ) +{ + const SfxPoolItem* pItem = 0; + OUString aName; + ::boost::optional<sal_uInt16> oNumOffset; + bool bPut = true; + switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) ) + { + case SFX_ITEM_SET: + { + if( ((SwFmtPageDesc*)pItem)->GetPageDesc() ) + { + aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName(); + oNumOffset = ((SwFmtPageDesc*)pItem)->GetNumOffset(); + } + rCoreSet.ClearItem( RES_PAGEDESC ); + // Page number + } + break; + + case SFX_ITEM_AVAILABLE: + break; + + default: + bPut = false; + } + + // TODO for now always pass a page number to cui, it can't make a + // difference between 0 and no page number at the moment. + { + SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, oNumOffset ? oNumOffset.get() : 0 ); + rCoreSet.Put( aPageNum ); + } + + if(bPut) + rCoreSet.Put( SvxPageModelItem( aName, true, SID_ATTR_PARA_MODEL ) ); +} + +// Determine metric + +FieldUnit GetDfltMetric(bool bWeb) +{ + return SW_MOD()->GetUsrPref(bWeb)->GetMetric(); +} + +// Determine metric + +void SetDfltMetric( FieldUnit eMetric, bool bWeb ) +{ + SW_MOD()->ApplyUserMetric(eMetric, bWeb); +} + +sal_Int32 InsertStringSorted(const OUString& rEntry, ListBox& rToFill, sal_Int32 nOffset ) +{ + CollatorWrapper& rCaseColl = ::GetAppCaseCollator(); + const sal_Int32 nCount = rToFill.GetEntryCount(); + while (nOffset < nCount) + { + if( 0 < rCaseColl.compareString( rToFill.GetEntry(nOffset), rEntry )) + break; + ++nOffset; + } + return rToFill.InsertEntry(rEntry, nOffset); +} + +void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault) +{ + const sal_Int32 nOffset = rToFill.GetEntryCount() > 0 ? 1 : 0; + SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool(); + pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL); + SwDoc* pDoc = pDocSh->GetDoc(); + const SfxStyleSheetBase* pBase = pPool->First(); + OUString sStandard; + SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard ); + while(pBase) + { + if(bWithDefault || pBase->GetName() != sStandard) + { + const sal_Int32 nPos = bSorted + ? InsertStringSorted(pBase->GetName(), rToFill, nOffset ) + : rToFill.InsertEntry(pBase->GetName()); + sal_IntPtr 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(size_t i = 0; i < pFmts->size(); ++i) + { + const SwCharFmt* pFmt = (*pFmts)[i]; + if(pFmt->IsDefault()) + continue; + const OUString& rName = pFmt->GetName(); + if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND) + { + const sal_Int32 nPos = bSorted + ? InsertStringSorted(rName, rToFill, nOffset ) + : rToFill.InsertEntry(rName); + sal_IntPtr nPoolId = USHRT_MAX; + rToFill.SetEntryData( nPos, (void*) (nPoolId)); + } + } +}; + +SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent, + SwWrtShell* pSh ) +{ + // To get the width is slightly more complicated. + 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) + { + if ( 0 == pSh->GetFlyFrmFmt() ) + { + nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width(); + } + else + { + nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width(); + } + } + else + { + OSL_FAIL("where to get the actual width from?"); + } + const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace(); + nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft()); + } + } + if (pPercent) + *pPercent = pFmt->GetFrmSize().GetWidthPercent(); + return nWidth; +} + +OUString GetAppLangDateTimeString( const DateTime& rDT ) +{ + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData(); + OUString sRet = rAppLclData.getDate( rDT ) + " " + rAppLclData.getTime( rDT, false, false ); + return sRet; +} + +// Add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value + +bool HasCharUnit( bool bWeb) +{ + return SW_MOD()->GetUsrPref(bWeb)->IsApplyCharUnit(); +} + +void SetApplyCharUnit(bool bApplyChar, bool bWeb) +{ + SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb); +} + +bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId ) +{ + bool bRet = false; + sal_uInt16 nItemCount = rMenu.GetItemCount(); + OUString sCommand; + for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem) + { + PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) ); + if(pPopup) + { + sCommand = pPopup->GetItemCommand(nId); + if(!sCommand.isEmpty()) + break; + } + } + if(!sCommand.isEmpty()) + { + 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( util::URLTransformer::create(::comphelper::getProcessComponentContext() ) ); + xTrans->parseStrict( aURL ); + uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); + if( xDisp.is() ) + { + uno::Sequence< beans::PropertyValue > aSeq; + xDisp->dispatch( aURL, aSeq ); + bRet = true; + } + } + return bRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx new file mode 100644 index 000000000000..8875d35b73a3 --- /dev/null +++ b/sw/source/uibase/utlui/unotools.cxx @@ -0,0 +1,565 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <swtypes.hxx> +#include <globals.hrc> +#include <misc.hrc> + +#include <utlui.hrc> +#include <unotools.hrc> +#include <unotools.hxx> +#include <unoprnms.hxx> +#include <i18nutil/unicode.hxx> +#include <osl/diagnose.h> +#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vcl/settings.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/Toolkit.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; + +const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl"; +const sal_Char cFactory[] = "private:factory/swriter"; + +bool SwOneExampleFrame::bShowServiceNotAvailableMessage = true; + +SwOneExampleFrame::SwOneExampleFrame( Window& rWin, + sal_uInt32 nFlags, + const Link* pInitializedLink, + const OUString* pURL ) : + aTopWindow(&rWin, this), + aMenuRes(SW_RES(RES_FRMEX_MENU)), + pModuleView(SW_MOD()->GetView()), + nStyleFlags(nFlags), + bIsInitialized(false), + bServiceAvailable(false) +{ + if (pURL && !pURL->isEmpty()) + sArgumentURL = *pURL; + + aTopWindow.SetPosSizePixel(Point(0, 0), rWin.GetSizePixel()); + + if( pInitializedLink ) + aInitializedLink = *pInitializedLink; + + // the controller is asynchronously set + aLoadedTimer.SetTimeoutHdl(LINK(this, SwOneExampleFrame, TimeoutHdl)); + aLoadedTimer.SetTimeout(200); + + CreateControl(); + + aTopWindow.Show(); +} + +void SwOneExampleFrame::CreateErrorMessage(Window* pParent) +{ + if(SwOneExampleFrame::bShowServiceNotAvailableMessage) + { + OUString sInfo(SW_RES(STR_SERVICE_UNAVAILABLE)); + sInfo += OUString(cFrameControl); + InfoBox(pParent, sInfo).Execute(); + SwOneExampleFrame::bShowServiceNotAvailableMessage = false; + } +} + +SwOneExampleFrame::~SwOneExampleFrame() +{ + DisposeControl(); +} + +void SwOneExampleFrame::CreateControl() +{ + if(_xControl.is()) + return ; + uno::Reference< lang::XMultiServiceFactory > + xMgr = comphelper::getProcessServiceFactory(); + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + uno::Reference< uno::XInterface > xInst = xMgr->createInstance( "com.sun.star.frame.FrameControl" ); + _xControl = uno::Reference< awt::XControl >(xInst, uno::UNO_QUERY); + if(_xControl.is()) + { + uno::Reference< awt::XWindowPeer > xParent( aTopWindow.GetComponentInterface() ); + + uno::Reference< awt::XToolkit > xToolkit( awt::Toolkit::create(xContext), uno::UNO_QUERY_THROW ); + + _xControl->createPeer( xToolkit, xParent ); + + uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); + xWin->setVisible(sal_False); + Size aWinSize(aTopWindow.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 + OUString sTempURL(cFactory); + if(!sArgumentURL.isEmpty()) + sTempURL = sArgumentURL; + aURL <<= sTempURL; + + uno::Sequence<beans::PropertyValue> aSeq(3); + beans::PropertyValue* pValues = aSeq.getArray(); + pValues[0].Name = "ReadOnly"; + sal_Bool bTrue = sal_True; + pValues[0].Value.setValue(&bTrue, ::getBooleanCppuType()); + pValues[1].Name = "OpenFlags"; + pValues[1].Value <<= OUString("-RB"); + pValues[2].Name = "Referer"; + pValues[2].Value <<= OUString("private:user"); + uno::Any aArgs; + aArgs.setValue(&aSeq, ::getCppuType((uno::Sequence<beans::PropertyValue>*)0)); + + xPrSet->setPropertyValue( "LoaderArguments", aArgs ); + //save and set readonly??? + + xPrSet->setPropertyValue("ComponentURL", aURL); + + aLoadedTimer.Start(); + bServiceAvailable = true; + } +} + +void SwOneExampleFrame::DisposeControl() +{ + _xCursor = 0; + if(_xControl.is()) + _xControl->dispose(); + _xControl = 0; + _xModel = 0; + _xController = 0; +} + +static void disableScrollBars(uno::Reference< beans::XPropertySet > xViewProps, + bool bEnableOnlineMode) +{ + //the scrollbar logic is kind of busted looking in writer, when the hori scrollbar + //property is changed then the hori scrollbar is enabled if the property is + //true or browse (online) mode is enabled. So... + //disable online mode + //turn off scrollbars + //turn back on online mode if that's what we want + //which subverts the (dodgy/buggy) scrollbar setting + + //To reproduce this problem, in edit->autotext and click through + //the examples and see if the preview gets a horizontal scrollbar + uno::Any aFalseSet(uno::makeAny(sal_False)); + xViewProps->setPropertyValue(UNO_NAME_SHOW_ONLINE_LAYOUT, aFalseSet); + + xViewProps->setPropertyValue(UNO_NAME_SHOW_HORI_SCROLL_BAR, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_VERT_SCROLL_BAR, aFalseSet); + + if (bEnableOnlineMode) + { + xViewProps->setPropertyValue(UNO_NAME_SHOW_ONLINE_LAYOUT, uno::makeAny(sal_True)); + } +} + +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("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("LayoutManager"); + aValue >>= xLayoutManager; + if ( xLayoutManager.is() ) + xLayoutManager->setVisible( sal_False ); + } + catch (const 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(UNO_NAME_SHOW_BREAKS, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_DRAWINGS, aTrueSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_FIELD_COMMANDS, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_GRAPHICS, aTrueSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_HIDDEN_PARAGRAPHS, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_HIDDEN_TEXT, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_HORI_RULER, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_PARA_BREAKS, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_PROTECTED_SPACES, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_SOFT_HYPHENS, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_SPACES, aFalseSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_TABLES, aTrueSet); + xViewProps->setPropertyValue(UNO_NAME_SHOW_TABSTOPS, aFalseSet); + xViewProps->setPropertyValue(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(UNO_NAME_ZOOM_TYPE, aZoom); + } + else + { + uno::Any aZoom; + aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; + xViewProps->setPropertyValue(UNO_NAME_ZOOM_TYPE, aZoom); + + sal_Int16 nZoomValue = 50; + if(EX_SHOW_BUSINESS_CARDS == nStyleFlags) + { + nZoomValue = 80; + } + aZoom <<= nZoomValue; + xViewProps->setPropertyValue(UNO_NAME_ZOOM_VALUE, aZoom); + } + + // set onlinelayout property after setting the zoom + disableScrollBars(xViewProps, (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) != 0); + bIsInitialized = true; + } + + uno::Reference< text::XTextDocument > xDoc(_xModel, uno::UNO_QUERY); + uno::Reference< text::XText > xText = xDoc->getText(); + _xCursor = xText->createTextCursor(); + + //From here, a cursor is defined, which goes through the template, + //and overwrites the template words where it is necessary. + + 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(); + + do + { + if (pSh->GetCurWord() == "HEADING1") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING1)); + } + else if (pSh->GetCurWord() == "ENTRY1") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY1)); + } + else if (pSh->GetCurWord() == "HEADING11") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING11)); + } + else if (pSh->GetCurWord() == "ENTRY11") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY11)); + } + else if (pSh->GetCurWord() == "HEADING12") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_HEADING12)); + } + else if (pSh->GetCurWord() == "ENTRY12") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_ENTRY12)); + } + else if (pSh->GetCurWord() == "TABLE1") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_TABLE1)); + } + else if (pSh->GetCurWord() == "IMAGE1") + { + pSh->Overwrite(SW_RESSTR(STR_IDXEXAMPLE_IDXTXT_IMAGE1)); + } + else + {;} + } + while(pSh->Right(sal_uInt16(1), sal_uInt16(1), true)); + } + } + + uno::Reference< beans::XPropertySet > xCrsrProp(_xCursor, uno::UNO_QUERY); + uno::Any aPageStyle = xCrsrProp->getPropertyValue(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( "PageStyles" ); + uno::Reference< container::XNameContainer > xPFamily; + + if( EX_SHOW_DEFAULT_PAGE != nStyleFlags + && (aPFamily >>= xPFamily) && !sPageStyle.isEmpty() ) + { + 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(UNO_NAME_SIZE); + awt::Size aPSize; + aSize >>= aPSize; + //TODO: set page width to card width + aPSize.Width = 10000; + aSize.setValue(&aPSize, ::cppu::UnoType<awt::Size>::get()); + xPProp->setPropertyValue(UNO_NAME_SIZE, aSize); + + uno::Any aZero; aZero <<= (sal_Int32)0; + xPProp->setPropertyValue(UNO_NAME_LEFT_MARGIN, aZero); + xPProp->setPropertyValue(UNO_NAME_RIGHT_MARGIN, aZero); + } + + uno::Reference< awt::XWindow > xWin( _xControl, uno::UNO_QUERY ); + Size aWinSize(aTopWindow.GetOutputSizePixel()); + xWin->setPosSize( 0, 0, aWinSize.Width(), aWinSize.Height(), awt::PosSize::SIZE ); + + // can only be done here - the SFX changes the ScrollBar values + disableScrollBars(xViewProps, (nStyleFlags&EX_SHOW_ONLINE_LAYOUT) != 0); + + if (aInitializedLink.IsSet()) + 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(); + + xWin->setVisible( sal_True ); + aTopWindow.Show(); + + 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; +} + +void SwOneExampleFrame::ClearDocument( 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(); + pSh->KillPams(); + pSh->ClearMark(); + pDoc->ClearDoc(); + pSh->ClearUpCrsrs(); + + if( aLoadedTimer.IsActive() || !bStartUpdateTimer ) + { + pSh->EndAllAction(); + pSh->UnlockPaint(); + } + if( bStartUpdateTimer ) + aLoadedTimer.Start(); + } + else + { + _xCursor->gotoStart(sal_False); + _xCursor->gotoEnd(sal_True); + _xCursor->setString(OUString()); + } + } +} + +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(UNO_NAME_ZOOM_VALUE); + sal_Int16 nZoom = 0; + aZoom >>= nZoom; + + for (sal_uInt16 i = 0; + i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i) + { + OUString sTemp = unicode::formatPercent(nZoomValues[i], + Application::GetSettings().GetUILanguageTag()); + 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 ); + +} + +IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu ) +{ + sal_uInt16 nId = pMenu->GetCurItemId(); + if ((nId > ITEM_ZOOM) && + (nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0]))))) + { + 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(UNO_NAME_ZOOM_VALUE, aZoom); + aZoom <<= (sal_Int16)view::DocumentZoomType::BY_VALUE; + xViewProps->setPropertyValue(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; +}; + +SwFrmCtrlWindow::SwFrmCtrlWindow(Window* pParent, SwOneExampleFrame* pFrame) + : VclEventBox(pParent) + , pExampleFrame(pFrame) +{ + set_expand(true); + set_fill(true); +} + +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:; + } +} + +Size SwFrmCtrlWindow::GetOptimalSize() const +{ + return LogicToPixel(Size(82, 124), MapMode(MAP_APPFONT)); +} + +void SwFrmCtrlWindow::Resize() +{ + VclEventBox::Resize(); + pExampleFrame->ClearDocument(true); +} + +MenuResource::MenuResource(const ResId& rResId) : + Resource(rResId), + aMenuArray(ResId(1,*rResId.GetResMgr())) +{ + FreeResource(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/unotools.hrc b/sw/source/uibase/utlui/unotools.hrc new file mode 100644 index 000000000000..da2555a7eb97 --- /dev/null +++ b/sw/source/uibase/utlui/unotools.hrc @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _UNOTOOLS_HRC +#define _UNOTOOLS_HRC + +#define ST_MENU_ZOOM 1 +#define ST_MENU_UP 2 +#define ST_MENU_DOWN 3 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/unotools.src b/sw/source/uibase/utlui/unotools.src new file mode 100644 index 000000000000..0bd6b2108226 --- /dev/null +++ b/sw/source/uibase/utlui/unotools.src @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools.hrc" +#include <utlui.hrc> +#include <globals.hrc> +#include <helpid.h> + +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; > ; + }; + }; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx new file mode 100644 index 000000000000..633af0550e22 --- /dev/null +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -0,0 +1,194 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <viewlayoutctrl.hxx> + +#include <vcl/status.hxx> +#include <vcl/image.hxx> +#include <svl/eitem.hxx> +#include <svx/viewlayoutitem.hxx> +#include <utlui.hrc> +#include <swtypes.hxx> + +SFX_IMPL_STATUSBAR_CONTROL( SwViewLayoutControl, SvxViewLayoutItem ); + +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; +}; + +SwViewLayoutControl::SwViewLayoutControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : + SfxStatusBarControl( _nSlotId, _nId, rStb ), + mpImpl( new SwViewLayoutControl_Impl ) +{ + mpImpl->mnState = 0; + + mpImpl->maImageSingleColumn = Image( SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN) ); + mpImpl->maImageSingleColumn_Active = Image( SW_RES(IMG_VIEWLAYOUT_SINGLECOLUMN_ACTIVE) ); + mpImpl->maImageAutomatic = Image( SW_RES(IMG_VIEWLAYOUT_AUTOMATIC) ); + mpImpl->maImageAutomatic_Active = Image( SW_RES(IMG_VIEWLAYOUT_AUTOMATIC_ACTIVE) ); + mpImpl->maImageBookMode = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE) ); + mpImpl->maImageBookMode_Active = Image( SW_RES(IMG_VIEWLAYOUT_BOOKMODE_ACTIVE) ); + + if ( rStb.GetDPIScaleFactor() > 1) + { + Image arr[6] = {mpImpl->maImageSingleColumn, mpImpl->maImageSingleColumn_Active, + mpImpl->maImageAutomatic, mpImpl->maImageAutomatic_Active, + mpImpl->maImageBookMode, mpImpl->maImageBookMode_Active}; + + for (int i = 0; i < 6; i++) + { + BitmapEx b = arr[i].GetBitmapEx(); + //Don't scale width, no space. + b.Scale(1.0, rStb.GetDPIScaleFactor(), BMP_SCALE_FAST); + arr[i] = Image(b); + } + + mpImpl->maImageSingleColumn = arr[0]; + mpImpl->maImageSingleColumn_Active = arr[1]; + + mpImpl->maImageAutomatic = arr[2]; + mpImpl->maImageAutomatic_Active = arr[3]; + + mpImpl->maImageBookMode = arr[4]; + mpImpl->maImageBookMode_Active = arr[5]; + } + +} + +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(), OUString() ); + else + { + OSL_ENSURE( 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(); + + const Rectangle aControlRect = getControlRect(); + + const bool bSingleColumn = 0 == mpImpl->mnState; + const bool bAutomatic = 1 == mpImpl->mnState; + const bool bBookMode = 2 == mpImpl->mnState; + + const long nImageWidthSum = mpImpl->maImageSingleColumn.GetSizePixel().Width() + + mpImpl->maImageAutomatic.GetSizePixel().Width() + + mpImpl->maImageBookMode.GetSizePixel().Width(); + + const long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + const long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height())/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() += mpImpl->maImageSingleColumn.GetSizePixel().Width(); + pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic ); + + // draw bookmode image: + aRect.Left() += mpImpl->maImageAutomatic.GetSizePixel().Width(); + pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode ); +} + +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 nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); + const long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); + const long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); + const long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; + + 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 = "ViewLayout"; + aArgs[0].Value = a; + + execute( aArgs ); + + return true; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/wordcountctrl.cxx b/sw/source/uibase/utlui/wordcountctrl.cxx new file mode 100644 index 000000000000..498de51ceb3c --- /dev/null +++ b/sw/source/uibase/utlui/wordcountctrl.cxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "wordcountctrl.hxx" +#include <svl/stritem.hxx> + +SFX_IMPL_STATUSBAR_CONTROL(SwWordCountStatusBarControl, SfxStringItem); + +SwWordCountStatusBarControl::SwWordCountStatusBarControl( + sal_uInt16 _nSlotId, + sal_uInt16 _nId, + StatusBar& rStb) : + SfxStatusBarControl(_nSlotId, _nId, rStb) +{ +} + +SwWordCountStatusBarControl::~SwWordCountStatusBarControl() +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/utlui/zoomctrl.cxx b/sw/source/uibase/utlui/zoomctrl.cxx new file mode 100644 index 000000000000..ac592474eb80 --- /dev/null +++ b/sw/source/uibase/utlui/zoomctrl.cxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "hintids.hxx" + +#include <vcl/status.hxx> +#include <sfx2/app.hxx> +#include <svl/stritem.hxx> +#include <sfx2/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 = OUString(); + SvxZoomStatusBarControl::StateChanged(nSID, eState, pState); + } +} + +void SwZoomControl::Paint( const UserDrawEvent& rUsrEvt ) +{ + if(sPreviewZoom.isEmpty()) + SvxZoomStatusBarControl::Paint(rUsrEvt); + else + GetStatusBar().SetItemText( GetId(), sPreviewZoom ); +} + +void SwZoomControl::Command( const CommandEvent& rCEvt ) +{ + if(sPreviewZoom.isEmpty()) + SvxZoomStatusBarControl::Command(rCEvt); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |