summaryrefslogtreecommitdiff
path: root/sw/source/ui/uiview
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/uiview')
-rw-r--r--sw/source/ui/uiview/formatclipboard.cxx617
-rw-r--r--sw/source/ui/uiview/makefile.mk90
-rw-r--r--sw/source/ui/uiview/pview.cxx2715
-rw-r--r--sw/source/ui/uiview/pview.hrc72
-rw-r--r--sw/source/ui/uiview/pview.src490
-rw-r--r--sw/source/ui/uiview/scroll.cxx160
-rw-r--r--sw/source/ui/uiview/srcview.cxx960
-rw-r--r--sw/source/ui/uiview/swcli.cxx171
-rw-r--r--sw/source/ui/uiview/uivwimp.cxx345
-rw-r--r--sw/source/ui/uiview/view.cxx1943
-rw-r--r--sw/source/ui/uiview/view.hrc91
-rw-r--r--sw/source/ui/uiview/view.src376
-rw-r--r--sw/source/ui/uiview/view0.cxx562
-rw-r--r--sw/source/ui/uiview/view1.cxx219
-rwxr-xr-xsw/source/ui/uiview/view2.cxx2452
-rw-r--r--sw/source/ui/uiview/viewcoll.cxx98
-rw-r--r--sw/source/ui/uiview/viewdlg.cxx98
-rw-r--r--sw/source/ui/uiview/viewdlg2.cxx241
-rw-r--r--sw/source/ui/uiview/viewdraw.cxx849
-rw-r--r--sw/source/ui/uiview/viewfunc.hxx68
-rwxr-xr-xsw/source/ui/uiview/viewling.cxx1005
-rw-r--r--sw/source/ui/uiview/viewmdi.cxx754
-rw-r--r--sw/source/ui/uiview/viewport.cxx1384
-rw-r--r--sw/source/ui/uiview/viewprt.cxx375
-rw-r--r--sw/source/ui/uiview/viewsrch.cxx821
-rwxr-xr-xsw/source/ui/uiview/viewstat.cxx530
-rw-r--r--sw/source/ui/uiview/viewtab.cxx1848
27 files changed, 19334 insertions, 0 deletions
diff --git a/sw/source/ui/uiview/formatclipboard.cxx b/sw/source/ui/uiview/formatclipboard.cxx
new file mode 100644
index 000000000000..3c77dc41d4d6
--- /dev/null
+++ b/sw/source/ui/uiview/formatclipboard.cxx
@@ -0,0 +1,617 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include "formatclipboard.hxx"
+
+
+#include <hintids.hxx>
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#include <format.hxx>
+#include <charfmt.hxx>
+#include <fmtcol.hxx>
+#include <frmfmt.hxx>
+#include <docstyle.hxx>
+#include <fchrfmt.hxx>
+#include <pam.hxx>
+// header for class SdrView
+#include <svx/svdview.hxx>
+//SvxBrushItem
+#include <editeng/brshitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <frmatr.hxx>
+// header for class SvxBoxInfoItem
+#include <editeng/boxitem.hxx>
+// header for class SvxFmtBreakItem
+#include <editeng/brkitem.hxx>
+// header for class SwFmtLayoutSplit
+#include <fmtlsplt.hxx>
+// header for class SvxFmtKeepItem
+#include <editeng/keepitem.hxx>
+// header for class SvxFrameDirectionItem
+#include <editeng/frmdiritem.hxx>
+#include <paratr.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtrowsplt.hxx>
+#include <swundo.hxx> // fuer die UndoIds
+#include <boost/shared_ptr.hpp>
+
+//#define FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES 1
+
+#ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
+#include <cellatr.hxx>
+#endif
+
+/*--------------------------------------------------------------------
+ --------------------------------------------------------------------*/
+
+namespace
+{
+#define FORMAT_PAINTBRUSH_FRAME_IDS \
+RES_FRMATR_BEGIN, RES_FILL_ORDER, \
+/* no RES_FRM_SIZE */ \
+RES_PAPER_BIN, RES_SURROUND, \
+/* no RES_VERT_ORIENT */ \
+/* no RES_HORI_ORIENT */ \
+/* no RES_ANCHOR */ \
+RES_BACKGROUND, RES_SHADOW, \
+/* no RES_FRMMACRO */ \
+RES_COL, RES_KEEP, \
+/* no RES_URL */ \
+RES_EDIT_IN_READONLY, RES_LAYOUT_SPLIT, \
+/* no RES_CHAIN */ \
+RES_TEXTGRID, RES_FRMATR_END-1,
+
+#define FORMAT_PAINTBRUSH_PARAGRAPH_IDS \
+RES_PARATR_BEGIN, RES_PARATR_END -1, \
+RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END -1, \
+FORMAT_PAINTBRUSH_FRAME_IDS \
+FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART, \
+FN_NUMBER_NEWSTART_AT, FN_NUMBER_NEWSTART_AT,
+
+SfxItemSet* lcl_CreateEmptyItemSet( int nSelectionType, SfxItemPool& rPool
+ , bool bNoCharacterFormats = false, bool bNoParagraphFormats = false )
+{
+ SfxItemSet* pItemSet = 0;
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ {
+ pItemSet = new SfxItemSet(rPool,
+ FORMAT_PAINTBRUSH_FRAME_IDS
+ 0);
+ }
+ else if( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ //is handled different
+ }
+ else if( nSelectionType == nsSelectionType::SEL_TBL )
+ {
+ pItemSet = new SfxItemSet(rPool,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW, //SID_ATTR_BORDER_OUTER is inbetween
+ RES_BACKGROUND, RES_SHADOW, //RES_BOX is inbetween
+ SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
+ RES_BREAK, RES_BREAK,
+ RES_PAGEDESC, RES_PAGEDESC,
+ RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
+ RES_ROW_SPLIT, RES_ROW_SPLIT,
+ RES_KEEP, RES_KEEP,
+ RES_FRAMEDIR, RES_FRAMEDIR,
+ FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE,
+ FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION,
+ FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
+#ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
+ RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
+#endif
+ 0);
+ }
+ else if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ if( bNoCharacterFormats )
+ pItemSet = new SfxItemSet(rPool,
+ FORMAT_PAINTBRUSH_PARAGRAPH_IDS
+ 0);
+ else if( bNoParagraphFormats )
+ pItemSet = new SfxItemSet(rPool,
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ 0);
+ else
+ pItemSet = new SfxItemSet(rPool,
+ RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
+ FORMAT_PAINTBRUSH_PARAGRAPH_IDS
+ 0);
+ }
+ return pItemSet;
+}
+
+void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
+{
+ SvxBrushItem aBrush( RES_BACKGROUND );
+ rSh.GetBoxBackground(aBrush);
+ rSet.Put( aBrush );
+ if(rSh.GetRowBackground(aBrush))
+ rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
+ else
+ rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
+ rSh.GetTabBackground(aBrush);
+ rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
+
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ rSet.Put(aBoxInfo);
+ rSh.GetTabBorders( rSet );
+
+ SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ if(rSh.GetBoxDirection( aBoxDirection ))
+ rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION);
+
+ rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
+
+ rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
+
+ SwFrmFmt *pFrmFmt = rSh.GetTableFmt();
+ if(pFrmFmt)
+ {
+ rSet.Put( pFrmFmt->GetShadow() );
+ rSet.Put( pFrmFmt->GetBreak() );
+ rSet.Put( pFrmFmt->GetPageDesc() );
+ rSet.Put( pFrmFmt->GetLayoutSplit() );
+ rSet.Put( pFrmFmt->GetKeep() );
+ rSet.Put( pFrmFmt->GetFrmDir() );
+ }
+
+ SwFmtRowSplit* pSplit = 0;
+ rSh.GetRowSplit(pSplit);
+ if(pSplit)
+ rSet.Put(*pSplit);
+
+ //-- numberformat in cells
+#ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
+ rSh.GetTblBoxFormulaAttrs( rSet ); //RES_BOXATR_FORMAT
+#endif
+}
+
+void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh )
+{
+ const SfxPoolItem* pItem = 0;
+ BOOL bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
+ SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
+ pItem = 0;
+ BOOL bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, FALSE, &pItem );
+ const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, FALSE, &pRowItem );
+ bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, FALSE, &pTableItem );
+
+ if(bBackground)
+ {
+ if(pItem)
+ rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
+ if(pRowItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetRowBackground(aBrush);
+ }
+ if(pTableItem)
+ {
+ SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
+ aBrush.SetWhich(RES_BACKGROUND);
+ rSh.SetTabBackground( aBrush );
+ }
+ }
+ if(bBorder)
+ rSh.SetTabBorders( rSet );
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, FALSE, &pItem) )
+ rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
+
+ SwFrmFmt* pFrmFmt = rSh.GetTableFmt();
+ if(pFrmFmt)
+ {
+ //RES_SHADOW
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_SHADOW), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_BREAK
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_BREAK), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_PAGEDESC
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_PAGEDESC), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_LAYOUT_SPLIT
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_LAYOUT_SPLIT), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_KEEP
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_KEEP), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+
+ //RES_FRAMEDIR
+ pItem=0;
+ rSet.GetItemState(rSet.GetPool()->GetWhich(RES_FRAMEDIR), FALSE, &pItem);
+ if(pItem)
+ pFrmFmt->SetFmtAttr( *pItem );
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, FALSE, &pItem) )
+ {
+ SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
+ aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pItem)->GetValue());
+ rSh.SetBoxDirection(aDirection);
+ }
+
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, FALSE, &pItem))
+ rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
+
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, FALSE, &pItem) )
+ rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pItem));
+
+ //-- numberformat in cells
+#ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
+ if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMAT, FALSE, &pItem ))
+ {
+ SfxItemSet aBoxSet( *rSet.GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
+ aBoxSet.Put( SwTblBoxNumFormat( ((SfxUInt32Item*)pItem)->GetValue() ));
+ rSh.SetTblBoxFormulaAttrs( aBoxSet );
+
+ }
+#endif
+}
+}//end anonymous namespace
+
+SwFormatClipboard::SwFormatClipboard()
+ : m_nSelectionType(0)
+ , m_pItemSet(0)
+ , m_pTableItemSet(0)
+ , m_bPersistentCopy(false)
+{
+}
+SwFormatClipboard::~SwFormatClipboard()
+{
+ if(m_pItemSet)
+ delete m_pItemSet;
+ if(m_pTableItemSet)
+ delete m_pTableItemSet;
+}
+
+bool SwFormatClipboard::HasContent() const
+{
+ return m_pItemSet!=0
+ || m_pTableItemSet != 0
+ || m_aCharStyle.Len()
+ || m_aParaStyle.Len()
+ ;
+}
+bool SwFormatClipboard::HasContentForThisType( int nSelectionType ) const
+{
+ if( !HasContent() )
+ return false;
+
+ if( m_nSelectionType == nSelectionType )
+ return true;
+
+ if( ( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ &&
+ ( m_nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ )
+ return true;
+
+ if( nSelectionType & nsSelectionType::SEL_TXT && m_nSelectionType & nsSelectionType::SEL_TXT )
+ return true;
+
+ return false;
+}
+
+bool SwFormatClipboard::CanCopyThisType( int nSelectionType ) const
+{
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF
+ | nsSelectionType::SEL_TXT | nsSelectionType::SEL_DRW | nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS ) )
+ return true;
+ return false;
+}
+
+void SwFormatClipboard::Copy( SwWrtShell& rWrtShell, SfxItemPool& rPool, bool bPersistentCopy )
+{
+ this->Erase();
+ m_bPersistentCopy = bPersistentCopy;
+
+ int nSelectionType = rWrtShell.GetSelectionType();
+ SfxItemSet* pItemSet = lcl_CreateEmptyItemSet( nSelectionType, rPool );
+
+ rWrtShell.StartAction();
+ rWrtShell.Push();
+ if( nSelectionType == nsSelectionType::SEL_TXT )
+ {
+ SwPaM* pCrsr = rWrtShell.GetCrsr();
+ //select one character only to get the attributes of this single character only
+ BOOL bHasSelection = pCrsr->HasMark();
+ BOOL bForwardSelection = FALSE;
+
+ if(!bHasSelection) //check for and handle multiselections
+ {
+ if( pCrsr->GetPrev() != pCrsr && pCrsr->GetPrev() != 0)
+ {
+ pCrsr = (SwPaM*)pCrsr->GetPrev();
+ bForwardSelection = (*pCrsr->GetPoint()) > (*pCrsr->GetMark());
+ bHasSelection = true;
+ pCrsr->DeleteMark();
+ pCrsr->SetMark();
+ rWrtShell.KillPams();
+ pCrsr = rWrtShell.GetCrsr();
+ }
+ }
+ else
+ bForwardSelection = (*pCrsr->GetPoint()) > (*pCrsr->GetMark());
+ pCrsr->DeleteMark();
+ pCrsr->SetMark();
+
+ if( !bHasSelection && rWrtShell.IsInRightToLeftText() )
+ bForwardSelection = !bForwardSelection;
+
+ if( !( !bHasSelection && rWrtShell.IsEndPara() ) )
+ pCrsr->Move( bForwardSelection ? fnMoveBackward : fnMoveForward );
+ }
+
+ if(pItemSet)
+ {
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ rWrtShell.GetFlyFrmAttr(*pItemSet);
+ else
+ {
+ rWrtShell.GetCurAttr(*pItemSet);
+
+ // additional numbering properties for paragraph styles
+ if( nSelectionType & nsSelectionType::SEL_TXT && rWrtShell.GetCurNumRule() )
+ {
+ SfxBoolItem aStart(FN_NUMBER_NEWSTART, rWrtShell.IsNumRuleStart());
+ pItemSet->Put(aStart);
+ SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT, rWrtShell.GetNodeNumStart());
+ pItemSet->Put(aStartAt);
+ }
+ }
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ SdrView* pDrawView = rWrtShell.GetDrawView();
+ if(pDrawView)
+ {
+ BOOL bOnlyHardAttr = TRUE;
+ if( pDrawView->AreObjectsMarked() )
+ {
+ pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
+ //remove attributes defining the type/data of custom shapes
+ pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_ENGINE);
+ pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_DATA);
+ pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_GEOMETRY);
+ pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL);
+ }
+ }
+ }
+ if( nSelectionType & nsSelectionType::SEL_TBL_CELLS )//only copy table attributes if really cells are selected (not only text in tables)
+ {
+ m_pTableItemSet = lcl_CreateEmptyItemSet( nsSelectionType::SEL_TBL, rPool );
+ lcl_getTableAttributes( *m_pTableItemSet, rWrtShell );
+ }
+
+ m_nSelectionType = nSelectionType;
+ m_pItemSet = pItemSet;
+
+ if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ SwFmt* pFmt = rWrtShell.GetCurCharFmt();
+ if( pFmt )
+ m_aCharStyle = pFmt->GetName();
+
+ pFmt = rWrtShell.GetCurTxtFmtColl();
+ if( pFmt )
+ m_aParaStyle = pFmt->GetName();
+ }
+ rWrtShell.Pop(FALSE);
+ rWrtShell.EndAction();
+}
+typedef boost::shared_ptr< SfxPoolItem > SfxPoolItemSharedPtr;
+typedef std::vector< SfxPoolItemSharedPtr > ItemVector;
+// #144857# collect all PoolItems from the applied styles
+void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyleAttrSet )
+{
+ const USHORT* pRanges = rStyleAttrSet.GetRanges();
+ while( *pRanges )
+ {
+ for ( USHORT nWhich = *pRanges; nWhich <= *(pRanges+1); ++nWhich )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rStyleAttrSet.GetItemState( nWhich, sal_False, &pItem ) )
+ {
+ rItemVector.push_back( SfxPoolItemSharedPtr( pItem->Clone() ) );
+ }
+ }
+ pRanges += 2;
+ }
+}
+// #144857# remove all items that are inherited from the styles
+void lcl_RemoveEqualItems( SfxItemSet& rTemplateItemSet, ItemVector& rItemVector )
+{
+ ItemVector::iterator aEnd = rItemVector.end();
+ ItemVector::iterator aIter = rItemVector.begin();
+ while( aIter != aEnd )
+ {
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == rTemplateItemSet.GetItemState( (*aIter)->Which(), sal_True, &pItem ) &&
+ *pItem == *(*aIter) )
+ {
+ rTemplateItemSet.ClearItem( (*aIter)->Which() );
+ }
+ ++aIter;
+ }
+}
+
+void SwFormatClipboard::Paste( SwWrtShell& rWrtShell, SfxStyleSheetBasePool* pPool
+ , bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ int nSelectionType = rWrtShell.GetSelectionType();
+ if( !this->HasContentForThisType(nSelectionType) )
+ {
+ if(!m_bPersistentCopy)
+ this->Erase();
+ return;
+ }
+
+ rWrtShell.StartAction();
+ rWrtShell.StartUndo(UNDO_INSATTR);
+
+ ItemVector aItemVector;
+ if(pPool) //to find the styles we need the pool
+ {
+ if( nSelectionType & nsSelectionType::SEL_TXT )
+ {
+ if(m_aCharStyle.Len() && !bNoCharacterFormats )
+ {
+ SwDocStyleSheet* pStyle = (SwDocStyleSheet*)pPool->Find(m_aCharStyle, SFX_STYLE_FAMILY_CHAR);
+ if( pStyle )
+ {
+ SwFmtCharFmt aFmt(pStyle->GetCharFmt());
+ // #144857# collect items from character style
+ lcl_AppendSetItems( aItemVector, aFmt.GetCharFmt()->GetAttrSet());
+ USHORT nFlags=0; //(nMode & KEY_SHIFT) ? SETATTR_DONTREPLACE : SETATTR_DEFAULT;
+ rWrtShell.SetAttr( aFmt, nFlags );
+ }
+ }
+ if(m_aParaStyle.Len() && !bNoParagraphFormats )
+ {
+ SwDocStyleSheet* pStyle = (SwDocStyleSheet*)pPool->Find(m_aParaStyle, SFX_STYLE_FAMILY_PARA);
+ if( pStyle )
+ {
+ // #144857# collect items from paragraph style
+ lcl_AppendSetItems( aItemVector, pStyle->GetCollection()->GetAttrSet());
+ rWrtShell.SetTxtFmtColl( pStyle->GetCollection() );
+ }
+ }
+ }
+ }
+ if(m_pItemSet)
+ {
+ if( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ SdrView* pDrawView = rWrtShell.GetDrawView();
+ if(pDrawView)
+ {
+ BOOL bReplaceAll = TRUE;
+ pDrawView->SetAttrToMarked(*m_pItemSet, bReplaceAll);
+ }
+ }
+ else
+ {
+ SfxItemSet* pTemplateItemSet = lcl_CreateEmptyItemSet(
+ nSelectionType, *m_pItemSet->GetPool()
+ , bNoCharacterFormats, bNoParagraphFormats );
+ if(pTemplateItemSet)
+ {
+ pTemplateItemSet->Put( *m_pItemSet );
+ // #144857# only _set_ attributes that differ from style attributes should be applied - the style is applied anyway
+ lcl_RemoveEqualItems( *pTemplateItemSet, aItemVector );
+
+ if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
+ rWrtShell.SetFlyFrmAttr(*pTemplateItemSet);
+ else
+ {
+ rWrtShell.SetAttr(*pTemplateItemSet);
+
+ // additional numbering properties for paragraph styles
+ if( nSelectionType & nsSelectionType::SEL_TXT && rWrtShell.GetCurNumRule() )
+ {
+ if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART) )
+ {
+ BOOL bStart = ((SfxBoolItem&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART)).GetValue();
+ USHORT nNumStart = USHRT_MAX;
+ if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+ {
+ nNumStart = ((SfxUInt16Item&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+ if(USHRT_MAX != nNumStart)
+ bStart = FALSE;
+ }
+ rWrtShell.SetNumRuleStart(bStart);
+ rWrtShell.SetNodeNumStart(nNumStart);
+ }
+ else if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
+ {
+ USHORT nNumStart = ((SfxUInt16Item&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
+ rWrtShell.SetNodeNumStart(nNumStart);
+ rWrtShell.SetNumRuleStart(FALSE);
+ }
+ }
+ }
+ delete pTemplateItemSet;
+ }
+ }
+ }
+
+ if( m_pTableItemSet && nSelectionType & (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS) )
+ lcl_setTableAttributes( *m_pTableItemSet, rWrtShell );
+
+ rWrtShell.EndUndo(UNDO_INSATTR);
+ rWrtShell.EndAction();
+
+ if(!m_bPersistentCopy)
+ this->Erase();
+}
+
+void SwFormatClipboard::Erase()
+{
+ m_nSelectionType = 0;
+ if(m_pItemSet)
+ {
+ delete m_pItemSet;
+ m_pItemSet = 0;
+ }
+ if(m_pTableItemSet)
+ {
+ delete m_pTableItemSet;
+ m_pTableItemSet = 0;
+ }
+ if( m_aCharStyle.Len() )
+ m_aCharStyle.Erase();
+ if( m_aParaStyle.Len() )
+ m_aParaStyle.Erase();
+
+ m_bPersistentCopy = false;
+}
diff --git a/sw/source/ui/uiview/makefile.mk b/sw/source/ui/uiview/makefile.mk
new file mode 100644
index 000000000000..337ee85da580
--- /dev/null
+++ b/sw/source/ui/uiview/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=uiview
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ view.src \
+ pview.src
+
+EXCEPTIONSFILES= \
+ $(SLO)$/formatclipboard.obj \
+ $(SLO)$/srcview.obj \
+ $(SLO)$/swcli.obj \
+ $(SLO)$/uivwimp.obj \
+ $(SLO)$/view.obj \
+ $(SLO)$/view0.obj \
+ $(SLO)$/view1.obj \
+ $(SLO)$/view2.obj \
+ $(SLO)$/viewdraw.obj \
+ $(SLO)$/viewport.obj \
+ $(SLO)$/viewprt.obj \
+ $(SLO)$/viewsrch.obj \
+ $(SLO)$/viewling.obj \
+ $(SLO)$/viewmdi.obj \
+
+SLOFILES = \
+ $(SLO)$/view0.obj \
+ $(SLO)$/view.obj \
+ $(SLO)$/view1.obj \
+ $(SLO)$/view2.obj \
+ $(SLO)$/viewcoll.obj \
+ $(SLO)$/viewdlg2.obj \
+ $(SLO)$/viewdlg.obj \
+ $(SLO)$/viewdraw.obj \
+ $(SLO)$/viewling.obj \
+ $(SLO)$/viewmdi.obj \
+ $(SLO)$/pview.obj \
+ $(SLO)$/viewport.obj \
+ $(SLO)$/viewstat.obj \
+ $(SLO)$/viewtab.obj \
+ $(SLO)$/viewprt.obj \
+ $(SLO)$/viewsrch.obj \
+ $(SLO)$/scroll.obj \
+ $(SLO)$/swcli.obj \
+ $(SLO)$/srcview.obj \
+ $(SLO)$/uivwimp.obj \
+ $(SLO)$/formatclipboard.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(SRS)$/uiview.srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx
new file mode 100644
index 000000000000..d499add5ad53
--- /dev/null
+++ b/sw/source/ui/uiview/pview.cxx
@@ -0,0 +1,2715 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include <sfx2/objface.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/help.hxx>
+#include <vcl/cmdevt.hxx>
+#include <vcl/button.hxx>
+#include <svtools/printdlg.hxx>
+#include <svl/whiter.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/progress.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/stddlg.hxx>
+#include <editeng/paperinf.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/svdview.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/zoomslideritem.hxx>
+#ifndef _SVX_SVXIDS_HRC //autogen
+#include <svx/svxids.hrc>
+#endif
+
+
+#include <swwait.hxx>
+#include <globdoc.hxx>
+#include <wdocsh.hxx>
+#include <pvprtdat.hxx>
+#include <swmodule.hxx>
+#include <modcfg.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <doc.hxx>
+#include <pview.hxx>
+#include <view.hxx>
+#include <textsh.hxx>
+#include <scroll.hxx>
+#include <swprtopt.hxx>
+#include <docstat.hxx>
+#include <usrpref.hxx>
+#include <viewfunc.hxx>
+
+
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _GLOBALS_HRC
+#include <globals.hrc>
+#endif
+#ifndef _POPUP_HRC
+#include <popup.hrc>
+#endif
+#ifndef _PVIEW_HRC
+#include <pview.hrc>
+#endif
+
+#define SwPagePreView
+#include <sfx2/msg.hxx>
+#include <swslots.hxx>
+// OD 12.12.2002 #103492#
+#include <pagepreviewlayout.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <vos/mutex.hxx>
+
+using namespace ::com::sun::star;
+
+
+SFX_IMPL_VIEWFACTORY(SwPagePreView, SW_RES(STR_NONAME))
+{
+ SFX_VIEW_REGISTRATION(SwDocShell);
+ SFX_VIEW_REGISTRATION(SwWebDocShell);
+ SFX_VIEW_REGISTRATION(SwGlobalDocShell);
+}
+
+SFX_IMPL_INTERFACE(SwPagePreView, SfxViewShell, SW_RES(RID_PVIEW_TOOLBOX))
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
+ SFX_VISIBILITY_CLIENT|SFX_VISIBILITY_FULLSCREEN|
+ SFX_VISIBILITY_READONLYDOC,
+ SW_RES(RID_PVIEW_TOOLBOX));
+}
+
+
+TYPEINIT1(SwPagePreView,SfxViewShell)
+
+#define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
+
+#define MIN_PREVIEW_ZOOM 25
+#define MAX_PREVIEW_ZOOM 600
+/* */
+/* -----------------26.11.2002 10:41-----------------
+ *
+ * --------------------------------------------------*/
+USHORT lcl_GetNextZoomStep(USHORT nCurrentZoom, BOOL bZoomIn)
+{
+ static USHORT aZoomArr[] =
+ {
+ 25, 50, 75, 100, 150, 200, 400, 600
+ };
+ const sal_uInt16 nZoomArrSize = sizeof(aZoomArr)/sizeof(USHORT);
+ if(bZoomIn)
+ for(int i = nZoomArrSize - 1; i >= 0; --i)
+ {
+ if(nCurrentZoom > aZoomArr[i] || !i)
+ return aZoomArr[i];
+ }
+ else
+ for(int i = 0; i < nZoomArrSize; ++i)
+ {
+ if(nCurrentZoom < aZoomArr[i])
+ return aZoomArr[i];
+ }
+ return bZoomIn ? MAX_PREVIEW_ZOOM : MIN_PREVIEW_ZOOM;
+};
+/* -----------------02.12.2002 09:11-----------------
+ *
+ * --------------------------------------------------*/
+void lcl_InvalidateZoomSlots(SfxBindings& rBindings)
+{
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN, SID_ATTR_ZOOMSLIDER, FN_PREVIEW_ZOOM, FN_STAT_ZOOM,
+ 0
+ };
+ rBindings.Invalidate( aInval );
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+// erstmal der Zoom-Dialog
+
+class SwPreViewZoomDlg : public SvxStandardDialog
+{
+ FixedText aRowLbl;
+ NumericField aRowEdit;
+ FixedText aColLbl;
+ NumericField aColEdit;
+
+ OKButton aOkBtn;
+ CancelButton aCancelBtn;
+ HelpButton aHelpBtn;
+
+ virtual void Apply();
+
+public:
+ SwPreViewZoomDlg( SwPagePreViewWin& rParent );
+ ~SwPreViewZoomDlg();
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwPreViewZoomDlg::SwPreViewZoomDlg( SwPagePreViewWin& rParent ) :
+ SvxStandardDialog( &rParent, SW_RES(DLG_PAGEPREVIEW_ZOOM) ),
+ aRowLbl(this,SW_RES(FT_ROW)),
+ aRowEdit(this,SW_RES(ED_ROW)),
+ aColLbl(this,SW_RES(FT_COL)),
+ aColEdit(this,SW_RES(ED_COL)),
+ aOkBtn(this,SW_RES(BT_OK)),
+ aCancelBtn(this,SW_RES(BT_CANCEL)),
+ aHelpBtn(this,SW_RES(BT_HELP))
+{
+ FreeResource();
+
+ aRowEdit.SetValue( rParent.GetRow() );
+ aColEdit.SetValue( rParent.GetCol() );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+ SwPreViewZoomDlg::~SwPreViewZoomDlg() {}
+
+
+void SwPreViewZoomDlg::Apply()
+{
+ ((SwPagePreViewWin*)GetParent())->CalcWish(
+ BYTE(aRowEdit.GetValue()),
+ BYTE(aColEdit.GetValue()) );
+}
+
+/* */
+/* -----------------20.08.98 15:25-------------------
+ * Vorschau fuer den Seitendruck
+ * --------------------------------------------------*/
+struct PrintSettingsStruct;
+class PrtPrvWindow : public Window
+{
+ const PrintSettingsStruct& rSettings;
+
+ virtual void Paint(const Rectangle&);
+public :
+ PrtPrvWindow(Window* pParent, const ResId& rResId, const PrintSettingsStruct& rSett) :
+ Window(pParent, rResId), rSettings(rSett){}
+};
+/*--------------------------------------------------------------------
+ Beschreibung: Optionen fuer das Drucken der Preview
+ --------------------------------------------------------------------*/
+struct PrintSettingsStruct
+{
+ Size aPageMaxSize; // groesste Seite
+ Size aPrtSize; // Papiergroesse
+ Size aPrvPrtSize; // Groesse innerhalb der LRTB-Raender
+ Size aGridSize; // Groesse fuer jede Seite, enthaelt je
+ // die Haelfte von H- und V-Distance
+
+ long nLeft;
+ long nRight;
+ long nTop;
+ long nBottom;
+ long nHori;
+ long nVert;
+
+ USHORT nRows;
+ USHORT nCols;
+
+ BOOL bPrinterLandscape; // Ausrichtung
+};
+
+class SwPreviewPrintOptionsDialog : public SvxStandardDialog
+{
+ FixedLine aRowColFL;
+ FixedText aRowsFT;
+ NumericField aRowsNF;
+ FixedText aColsFT;
+ NumericField aColsNF;
+
+ FixedLine aMarginFL;
+ FixedText aLSpaceFT;
+ MetricField aLSpaceMF;
+ FixedText aRSpaceFT;
+ MetricField aRSpaceMF;
+ FixedText aTSpaceFT;
+ MetricField aTSpaceMF;
+ FixedText aBSpaceFT;
+ MetricField aBSpaceMF;
+ FixedLine aDistanceFL;
+ FixedText aHSpaceFT;
+ MetricField aHSpaceMF;
+ FixedText aVSpaceFT;
+ MetricField aVSpaceMF;
+
+ RadioButton aLandscapeRB;
+ RadioButton aPortraitRB;
+ FixedLine aOrientationFL;
+
+ PrtPrvWindow aPreviewWin;
+
+ OKButton aOkBtn;
+ CancelButton aCancelBtn;
+ HelpButton aHelpBtn;
+
+ PushButton aStandardPB;
+
+ SwPagePreView& rPreView;
+ SwPagePreViewWin& rParentWin;
+ PrintSettingsStruct aSettings;
+/* Size aPageMaxSize;
+ Size aPrtSize;
+
+ BOOL bOrientation;
+*/
+ BOOL bStandard;
+
+ virtual void Apply();
+ void FillControls(SwPagePreViewPrtData& rData);
+
+ DECL_LINK( ModifyHdl, Edit* );
+ DECL_LINK( StandardHdl, PushButton* );
+
+public:
+ SwPreviewPrintOptionsDialog(SwPagePreViewWin& rParent, SwPagePreView& rView);
+ ~SwPreviewPrintOptionsDialog();
+};
+
+/* -----------------19.08.98 13:35-------------------
+ *
+ * --------------------------------------------------*/
+SwPreviewPrintOptionsDialog::SwPreviewPrintOptionsDialog( SwPagePreViewWin& rParent, SwPagePreView& rView ) :
+ SvxStandardDialog( &rParent, SW_RES(DLG_PAGEPREVIEW_PRINTOPTIONS) ),
+ aRowColFL(this,SW_RES( FL_ROWCOL)),
+ aRowsFT(this,SW_RES( FT_ROWS)),
+ aRowsNF(this,SW_RES( NF_ROWS)),
+ aColsFT(this,SW_RES( FT_COLS)),
+ aColsNF(this,SW_RES( NF_COLS)),
+ aMarginFL(this,SW_RES( FL_MARGINS)),
+ aLSpaceFT(this,SW_RES( FT_LMARGIN)),
+ aLSpaceMF(this,SW_RES( MF_LMARGIN)),
+ aRSpaceFT(this,SW_RES( FT_RMARGIN)),
+ aRSpaceMF(this,SW_RES( MF_RMARGIN)),
+ aTSpaceFT(this,SW_RES( FT_TMARGIN)),
+ aTSpaceMF(this,SW_RES( MF_TMARGIN)),
+ aBSpaceFT(this,SW_RES( FT_BMARGIN)),
+ aBSpaceMF(this,SW_RES( MF_BMARGIN)),
+ aDistanceFL(this,SW_RES(FL_DISTANCE)),
+ aHSpaceFT(this,SW_RES( FT_HMARGIN)),
+ aHSpaceMF(this,SW_RES( MF_HMARGIN)),
+ aVSpaceFT(this,SW_RES( FT_VMARGIN)),
+ aVSpaceMF(this,SW_RES( MF_VMARGIN)),
+ aLandscapeRB(this,SW_RES( RB_LANDSCAPE)),
+ aPortraitRB(this,SW_RES( RB_PORTRAIT)),
+ aOrientationFL(this,SW_RES( FL_ORIENTATION)),
+ aPreviewWin(this,SW_RES( WIN_PREVIEW), aSettings),
+ aOkBtn(this,SW_RES(BT_OK)),
+ aCancelBtn(this,SW_RES(BT_CANCEL)),
+ aHelpBtn(this,SW_RES(BT_HELP)),
+ aStandardPB(this,SW_RES(PB_STANDARD)),
+ rPreView(rView),
+ rParentWin(rParent),
+ bStandard(TRUE)
+{
+ FreeResource();
+ ViewShell& rViewSh = *rPreView.GetViewShell();
+ // OD 18.12.2002 #103492#
+ aSettings.aPageMaxSize = rViewSh.PagePreviewLayout()->GetMaxPageSize();
+ SfxPrinter* pPrinter = rViewSh.getIDocumentDeviceAccess()->getPrinter( true );
+ aSettings.aPrtSize = pPrinter->GetPaperSize();
+ //#97682# make sure that no division by zero occurs
+ if(!aSettings.aPrtSize.Width() || !aSettings.aPrtSize.Height())
+ aSettings.aPrtSize = SvxPaperInfo::GetPaperSize(PAPER_A4);
+ aSettings.bPrinterLandscape = pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE;
+
+
+ SwDocShell* pDocShell = rPreView.GetDocShell();
+ const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != PTR_CAST(SwWebDocShell, pDocShell));
+ FieldUnit eFieldUnit = pUsrPref->GetMetric();
+ ::SetFieldUnit( aLSpaceMF, eFieldUnit );
+ ::SetFieldUnit( aRSpaceMF, eFieldUnit );
+ ::SetFieldUnit( aTSpaceMF, eFieldUnit );
+ ::SetFieldUnit( aBSpaceMF, eFieldUnit );
+ ::SetFieldUnit( aHSpaceMF, eFieldUnit );
+ ::SetFieldUnit( aVSpaceMF, eFieldUnit );
+
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwPagePreViewPrtData aData;
+ if(pDoc->GetPreViewPrtData())
+ {
+ aData = *pDoc->GetPreViewPrtData();
+ bStandard = FALSE;
+ }
+ else
+ {
+ // Orientation der PreviewData an den Drucker anpassen
+ aData.SetLandscape(aSettings.bPrinterLandscape);
+ aData.SetRow(rParent.GetRow());
+ aData.SetCol(rParent.GetCol());
+ }
+ FillControls(aData);
+
+ aLSpaceMF.SaveValue();
+ aRSpaceMF.SaveValue();
+ aTSpaceMF.SaveValue();
+ aBSpaceMF.SaveValue();
+ aHSpaceMF.SaveValue();
+ aVSpaceMF.SaveValue();
+ aRowsNF.SaveValue();
+ aColsNF.SaveValue();
+ aLandscapeRB.SaveValue();
+ aPortraitRB.SaveValue();
+
+ aStandardPB.SetClickHdl(LINK(this, SwPreviewPrintOptionsDialog, StandardHdl));
+ Link aLk = LINK(this, SwPreviewPrintOptionsDialog, ModifyHdl);
+ aLSpaceMF.SetUpHdl(aLk);
+ aRSpaceMF.SetUpHdl(aLk);
+ aTSpaceMF.SetUpHdl(aLk);
+ aBSpaceMF.SetUpHdl(aLk);
+ aHSpaceMF.SetUpHdl(aLk);
+ aVSpaceMF.SetUpHdl(aLk);
+ aRowsNF.SetUpHdl(aLk);
+ aColsNF.SetUpHdl(aLk);
+ aLSpaceMF.SetDownHdl(aLk);
+ aRSpaceMF.SetDownHdl(aLk);
+ aTSpaceMF.SetDownHdl(aLk);
+ aBSpaceMF.SetDownHdl(aLk);
+ aHSpaceMF.SetDownHdl(aLk);
+ aVSpaceMF.SetDownHdl(aLk);
+ aRowsNF.SetDownHdl(aLk);
+ aColsNF.SetDownHdl(aLk);
+ aLSpaceMF.SetLoseFocusHdl(aLk);
+ aRSpaceMF.SetLoseFocusHdl(aLk);
+ aTSpaceMF.SetLoseFocusHdl(aLk);
+ aBSpaceMF.SetLoseFocusHdl(aLk);
+ aHSpaceMF.SetLoseFocusHdl(aLk);
+ aVSpaceMF.SetLoseFocusHdl(aLk);
+ aRowsNF.SetLoseFocusHdl(aLk);
+ aColsNF.SetLoseFocusHdl(aLk);
+ aLandscapeRB.SetClickHdl(aLk);
+ aPortraitRB.SetClickHdl(aLk);
+
+ ModifyHdl(0);
+ if(bStandard)
+ StandardHdl(&aStandardPB);
+}
+
+
+/* -----------------19.08.98 13:36-------------------
+ *
+ * --------------------------------------------------*/
+SwPreviewPrintOptionsDialog::~SwPreviewPrintOptionsDialog()
+{
+}
+/* -----------------12.11.98 11:32-------------------
+ *
+ * --------------------------------------------------*/
+void SwPreviewPrintOptionsDialog::FillControls(SwPagePreViewPrtData& rData)
+{
+ aLSpaceMF.SetValue(aLSpaceMF.Normalize(rData.GetLeftSpace() ), FUNIT_TWIP);
+ aRSpaceMF.SetValue(aRSpaceMF.Normalize(rData.GetRightSpace() ), FUNIT_TWIP);
+ aTSpaceMF.SetValue(aTSpaceMF.Normalize(rData.GetTopSpace() ), FUNIT_TWIP);
+ aBSpaceMF.SetValue(aBSpaceMF.Normalize(rData.GetBottomSpace()), FUNIT_TWIP);
+ aHSpaceMF.SetValue(aHSpaceMF.Normalize(rData.GetHorzSpace() ), FUNIT_TWIP);
+ aVSpaceMF.SetValue(aVSpaceMF.Normalize(rData.GetVertSpace() ), FUNIT_TWIP);
+ aRowsNF.SetValue(rData.GetRow());
+ aColsNF.SetValue(rData.GetCol());
+ aSettings.bPrinterLandscape ? aLandscapeRB.Check() : aPortraitRB.Check();
+ // wenn Drucker und Einstellungen nicht uebereinstimmen, dann Seiten tauschen
+ if( rData.GetLandscape() != aSettings.bPrinterLandscape )
+ {
+ Size aTmp(aSettings.aPrtSize.Height(), aSettings.aPrtSize.Width());
+ aSettings.aPrtSize = aTmp;
+ aSettings.bPrinterLandscape = !aSettings.bPrinterLandscape;
+ // nochmal setzen, denn auch wenn nur die Default-Orientierung dem Drucker
+ // angepasst wurde, sollen die Einstellungen gespeichert werden
+ aSettings.bPrinterLandscape ? aLandscapeRB.Check() : aPortraitRB.Check();
+ }
+ aLandscapeRB.SaveValue();
+ aPortraitRB.SaveValue();
+
+ aSettings.nLeft = rData.GetLeftSpace() ;
+ aSettings.nRight = rData.GetRightSpace() ;
+ aSettings.nTop = rData.GetTopSpace() ;
+ aSettings.nBottom = rData.GetBottomSpace();
+ aSettings.nHori = rData.GetHorzSpace() ;
+ aSettings.nVert = rData.GetVertSpace() ;
+ aSettings.nRows = rData.GetRow() ;
+ aSettings.nCols = rData.GetCol() ;
+ aSettings.aPrvPrtSize = aSettings.aPrtSize ;
+}
+
+/* -----------------19.08.98 14:31-------------------
+ *
+ * --------------------------------------------------*/
+void SwPreviewPrintOptionsDialog::Apply()
+{
+
+ SwDoc* pDoc = rPreView.GetDocShell()->GetDoc();
+ if(bStandard)
+ pDoc->SetPreViewPrtData(0);
+ else if( aLSpaceMF.GetSavedValue() != aLSpaceMF.GetText() ||
+ aRSpaceMF.GetSavedValue() != aRSpaceMF.GetText() ||
+ aTSpaceMF.GetSavedValue() != aTSpaceMF.GetText() ||
+ aBSpaceMF.GetSavedValue() != aBSpaceMF.GetText() ||
+ aHSpaceMF.GetSavedValue() != aHSpaceMF.GetText() ||
+ aVSpaceMF.GetSavedValue() != aVSpaceMF.GetText() ||
+ aRowsNF.GetSavedValue() != aRowsNF.GetText() ||
+ aColsNF.GetSavedValue() != aColsNF.GetText() ||
+ aLandscapeRB.GetSavedValue() != aLandscapeRB.IsChecked() ||
+ aPortraitRB.GetSavedValue() != aPortraitRB.IsChecked() )
+ {
+ SwPagePreViewPrtData aData;
+ if(pDoc->GetPreViewPrtData())
+ aData = *pDoc->GetPreViewPrtData();
+ aData.SetLeftSpace( static_cast< ULONG >(aLSpaceMF.Denormalize(aLSpaceMF.GetValue(FUNIT_TWIP))) );
+ aData.SetRightSpace( static_cast< ULONG >(aRSpaceMF.Denormalize(aRSpaceMF.GetValue(FUNIT_TWIP))) );
+ aData.SetTopSpace( static_cast< ULONG >(aTSpaceMF.Denormalize(aTSpaceMF.GetValue(FUNIT_TWIP))) );
+ aData.SetBottomSpace( static_cast< ULONG >(aBSpaceMF.Denormalize(aBSpaceMF.GetValue(FUNIT_TWIP))) );
+
+ aData.SetHorzSpace( static_cast< ULONG >(aHSpaceMF.Denormalize(aHSpaceMF.GetValue(FUNIT_TWIP))) );
+ aData.SetVertSpace( static_cast< ULONG >(aVSpaceMF.Denormalize(aVSpaceMF.GetValue(FUNIT_TWIP))) );
+ aData.SetRow((BYTE)aRowsNF.GetValue());
+ aData.SetCol((BYTE)aColsNF.GetValue());
+ aData.SetLandscape(aLandscapeRB.IsChecked());
+
+ ViewShell& rViewSh = *rPreView.GetViewShell();
+ SfxPrinter* pPrinter = rViewSh.getIDocumentDeviceAccess()->getPrinter( true );
+ if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE)
+ != aData.GetLandscape())
+ pPrinter->SetOrientation(aData.GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+
+
+ pDoc->SetPreViewPrtData(&aData);
+
+ }
+}
+/* -----------------20.08.98 08:48-------------------
+ *
+ * --------------------------------------------------*/
+IMPL_LINK( SwPreviewPrintOptionsDialog, ModifyHdl, Edit*, pEdit )
+{
+ if(bStandard && pEdit)
+ {
+ aLSpaceMF.SetUserValue(aLSpaceMF.GetValue());
+ aRSpaceMF.SetUserValue(aRSpaceMF.GetValue());
+ aTSpaceMF.SetUserValue(aTSpaceMF.GetValue());
+ aBSpaceMF.SetUserValue(aBSpaceMF.GetValue());
+ aHSpaceMF.SetUserValue(aHSpaceMF.GetValue());
+ aVSpaceMF.SetUserValue(aVSpaceMF.GetValue());
+ aRowsNF. SetUserValue(aRowsNF .GetValue());
+ aColsNF. SetUserValue(aColsNF .GetValue());
+
+ bStandard = FALSE;
+ }
+ BOOL bOrientChanged = aSettings.bPrinterLandscape != aLandscapeRB.IsChecked();;
+ if(pEdit == &aLSpaceMF)
+ aSettings.nLeft = static_cast< long >(aLSpaceMF.Denormalize(aLSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aRSpaceMF)
+ aSettings.nRight = static_cast< long >(aRSpaceMF.Denormalize(aRSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aTSpaceMF)
+ aSettings.nTop = static_cast< long >(aTSpaceMF.Denormalize(aTSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aBSpaceMF)
+ aSettings.nBottom = static_cast< long >(aBSpaceMF.Denormalize(aBSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aHSpaceMF)
+ aSettings.nHori = static_cast< long >(aHSpaceMF.Denormalize(aHSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aVSpaceMF)
+ aSettings.nVert = static_cast< long >(aVSpaceMF.Denormalize(aVSpaceMF.GetValue(FUNIT_TWIP)));
+ else if(pEdit == &aRowsNF)
+ aSettings.nRows = (USHORT)aRowsNF.GetValue();
+ else if(pEdit == &aColsNF)
+ aSettings.nCols = (USHORT)aColsNF.GetValue();
+ else if(pEdit == (Edit*)&aLandscapeRB)
+ aSettings.bPrinterLandscape = aLandscapeRB.IsChecked();
+ else if(pEdit == (Edit*)&aPortraitRB)
+ aSettings.bPrinterLandscape = aLandscapeRB.IsChecked();
+
+ if(bOrientChanged)
+ {
+ Size aTmp(aSettings.aPrtSize.Height(), aSettings.aPrtSize.Width());
+ aSettings.aPrtSize = aTmp;
+ }
+
+
+ aSettings.aPrvPrtSize = Size(aSettings.aPrtSize.Width() - aSettings.nRight - aSettings.nLeft,
+ aSettings.aPrtSize.Height() - aSettings.nTop - aSettings.nBottom);
+ aSettings.aGridSize = Size(aSettings.aPrvPrtSize.Width() / aSettings.nCols,
+ aSettings.aPrvPrtSize.Height() / aSettings.nRows );
+ // was fehlt noch: Orientation auswerten, minimalrand ausrechnen, Beispiel fuettern
+
+
+ //am Ende Maximalwerte setzen
+ long n20Percent = aSettings.aPrtSize.Width() / 5;
+ aLSpaceMF.SetMax(aLSpaceMF.Normalize(aSettings.aPrtSize.Width() - aSettings.nRight - n20Percent), FUNIT_TWIP);
+ aRSpaceMF.SetMax(aRSpaceMF.Normalize(aSettings.aPrtSize.Width() - aSettings.nLeft - n20Percent), FUNIT_TWIP);
+ n20Percent = aSettings.aPrtSize.Height() / 5;
+ aTSpaceMF.SetMax(aTSpaceMF.Normalize(aSettings.aPrtSize.Height() - aSettings.nBottom - n20Percent), FUNIT_TWIP);
+ aBSpaceMF.SetMax(aBSpaceMF.Normalize(aSettings.aPrtSize.Height() - aSettings.nTop - n20Percent), FUNIT_TWIP);
+
+ long n80Percent = aSettings.aPrvPrtSize.Width() * 4 / 5;
+ aHSpaceMF.SetMax(aHSpaceMF.Normalize(n80Percent / aSettings.nRows), FUNIT_TWIP);
+ n80Percent = aSettings.aPrvPrtSize.Height()* 4 / 5;
+ aVSpaceMF.SetMax(aVSpaceMF.Normalize(n80Percent / aSettings.nCols), FUNIT_TWIP);
+ aHSpaceMF.Enable(aSettings.nCols > 1);
+ aVSpaceMF.Enable(aSettings.nRows > 1);
+ aRowsNF.SetMin(1);// nur damit auch nach Standard wieder der Inhalt angezeigt wird
+ aColsNF.SetMin(1);
+
+
+ aPreviewWin.Invalidate();
+ return 0;
+}
+/* -----------------28.08.98 14:59-------------------
+ *
+ * --------------------------------------------------*/
+IMPL_LINK( SwPreviewPrintOptionsDialog, StandardHdl, PushButton*, EMPTYARG )
+{
+ SetUpdateMode(TRUE);
+ SwPagePreViewPrtData aData;
+ aData.SetRow(rParentWin.GetRow());
+ aData.SetCol(rParentWin.GetCol());
+ FillControls(aData);
+ bStandard = TRUE;
+ aLSpaceMF.SetText(aEmptyStr);
+ aRSpaceMF.SetText(aEmptyStr);
+ aTSpaceMF.SetText(aEmptyStr);
+ aBSpaceMF.SetText(aEmptyStr);
+ aHSpaceMF.SetText(aEmptyStr);
+ aVSpaceMF.SetText(aEmptyStr);
+ aPreviewWin.Invalidate();
+ SetUpdateMode(FALSE);
+ return 0;
+}
+/* -----------------20.08.98 15:28-------------------
+ * Preview anzeigen
+ * --------------------------------------------------*/
+void PrtPrvWindow::Paint(const Rectangle&)
+{
+ Size aWinSize(GetOutputSizePixel());
+ long nWidth = rSettings.aPrtSize.Width();
+ long nHeight = rSettings.aPrtSize.Height();
+ BOOL bHoriValid = (aWinSize.Width() * 100 / aWinSize.Height()) <
+ (rSettings.aPrtSize.Width() * 100/ rSettings.aPrtSize.Height());
+ Fraction aXScale( aWinSize.Width(), Max( nWidth , 1L ) );
+ Fraction aYScale( aWinSize.Height(), Max( nHeight, 1L ) );
+ MapMode aMapMode( GetMapMode() );
+ aMapMode.SetScaleX( bHoriValid ? aXScale : aYScale);
+ aMapMode.SetScaleY( bHoriValid ? aXScale : aYScale);
+ SetMapMode( aMapMode );
+
+ aWinSize = GetOutputSize();
+
+ Point aOffset(0,0);
+ if(bHoriValid)
+ aOffset.Y() = (aWinSize.Height() - rSettings.aPrtSize.Height()) / 2;
+ else
+ aOffset.X() = (aWinSize.Width() - rSettings.aPrtSize.Width()) / 2;;
+
+
+ BOOL bUseSystemColors = SvtAccessibilityOptions().GetIsForPagePreviews()
+ && GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ //der weisse Seitenhintergrund
+ Rectangle aRect(aOffset, rSettings.aPrtSize);
+ if(bUseSystemColors)
+ {
+ SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
+ SetLineColor( SwViewOption::GetFontColor() );
+ }
+ else
+ {
+ SetFillColor( Color( COL_WHITE ) );
+ SetLineColor(Color( COL_BLACK ) );
+ }
+
+ DrawRect(aRect);
+
+ Point aTL(aOffset);
+ aTL.X() += rSettings.nLeft;
+ aTL.Y() += rSettings.nTop;
+
+ Size aPrvPageSize((rSettings.aPrvPrtSize.Width() - (rSettings.nCols - 1) * rSettings.nHori) / rSettings.nCols,
+ (rSettings.aPrvPrtSize.Height() - (rSettings.nRows - 1) * rSettings.nVert) / rSettings.nRows);
+ // jetzt muss noch das unterschiedliche Groessenverhaeltnis berechnet werden, um es an
+ // der richtigen Seite abzuziehen.
+ //...
+ long nSourceScale = rSettings.aPageMaxSize.Width() * 100 / rSettings.aPageMaxSize.Height();
+ long nDestScale = aPrvPageSize.Width() * 100 / aPrvPageSize.Height() ;
+ if(nSourceScale > nDestScale) // die Seite ist relativ breiter als das vorhandene Rechteck
+ {
+ aPrvPageSize.Height() = aPrvPageSize.Width() * 100 / nSourceScale;
+ }
+ else
+ {
+ aPrvPageSize.Width() = aPrvPageSize.Height() * nSourceScale / 100;
+ }
+
+ if(bUseSystemColors)
+ SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
+ else
+ SetFillColor( Color( COL_GRAY ) );
+
+
+ aRect = Rectangle(aTL, aPrvPageSize);
+ for(USHORT i = 0; i < rSettings.nRows; i++)
+ {
+ for(USHORT j = 0; j < rSettings.nCols; j++)
+ {
+ DrawRect(aRect);
+ aRect.Move(aPrvPageSize.Width() + rSettings.nHori, 0);
+ }
+
+ aRect.Move( 0, aPrvPageSize.Height() + rSettings.nVert);
+ aRect.SetPos(Point(aTL.X(), aRect.TopLeft().Y()));
+ }
+ //rSettings;
+}
+
+/* */
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+// alles fuers SwPagePreViewWin
+
+
+SwPagePreViewWin::SwPagePreViewWin( Window *pParent, SwPagePreView& rPView )
+ : Window( pParent, WinBits( WB_CLIPCHILDREN) ),
+ mpViewShell( 0 ),
+ mrView( rPView ),
+ mbCalcScaleForPreviewLayout( true ),
+ maPaintedPreviewDocRect( Rectangle(0,0,0,0) )
+{
+ SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611#
+ SetHelpId(HID_PAGEPREVIEW);
+ SetFillColor( GetBackground().GetColor() );
+ SetLineColor( GetBackground().GetColor());
+ SetMapMode( MapMode(MAP_TWIP) );
+
+ const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(FALSE);
+ mnRow = pUsrPref->GetPagePrevRow(); // 1 Zeile
+ mnCol = pUsrPref->GetPagePrevCol(); // 1 Spalte
+ // OD 24.03.2003 #108282# - member <mnVirtPage> no longer exists.
+ mnSttPage = USHRT_MAX;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwPagePreViewWin::~SwPagePreViewWin()
+{
+ if( mpViewShell )
+ delete mpViewShell;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreViewWin::Paint( const Rectangle& rRect )
+{
+ if( !mpViewShell || !mpViewShell->GetLayout() )
+ return;
+
+ if( USHRT_MAX == mnSttPage ) // wurde noch nie berechnet ? (Init-Phase!)
+ {
+ // das ist die Size, auf die ich mich immer beziehe
+ if( !maPxWinSize.Height() || !maPxWinSize.Width() )
+ maPxWinSize = GetOutputSizePixel();
+
+ Rectangle aRect( LogicToPixel( rRect ));
+ mpPgPrevwLayout->Prepare( 1, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( 1 );
+ mpPgPrevwLayout->Paint( PixelToLogic( aRect ) );
+ SetPagePreview(mnRow, mnCol);
+ }
+ else
+ {
+ MapMode aMM( GetMapMode() );
+ aMM.SetScaleX( maScale );
+ aMM.SetScaleY( maScale );
+ SetMapMode( aMM );
+ mpPgPrevwLayout->Paint( rRect );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+void SwPagePreViewWin::CalcWish( BYTE nNewRow, BYTE nNewCol )
+{
+ if( !mpViewShell || !mpViewShell->GetLayout() )
+ return;
+
+ USHORT nOldCol = mnCol;
+ // OD 02.12.2002 #103492# - update <mnRow> and <mnCol>.
+ mnRow = nNewRow;
+ mnCol = nNewCol;
+ USHORT nPages = mnRow * mnCol,
+ nLastSttPg = mrView.GetPageCount()+1 > nPages
+ ? mrView.GetPageCount()+1 - nPages : 0;
+ if( mnSttPage > nLastSttPg )
+ mnSttPage = nLastSttPg;
+
+ mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( mnSttPage );
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+
+ // falls an der Spaltigkeit gedreht wurde, so muss der Sonderfall
+ // Einspaltig beachtet und ggfs. der Scrollbar korrigiert werden
+ if( (1 == nOldCol) ^ (1 == mnCol) )
+ mrView.ScrollDocSzChg();
+
+ // Sortierung muss eingehalten werden!!
+ // OD 24.03.2003 #108282# - additional invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ SID_ATTR_ZOOM, SID_ZOOM_OUT, SID_ZOOM_IN,
+ FN_PREVIEW_ZOOM,
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, FN_STAT_ZOOM,
+ FN_SHOW_TWO_PAGES, FN_SHOW_MULTIPLE_PAGES,
+ 0
+ };
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ rBindings.Update( FN_SHOW_TWO_PAGES );
+ rBindings.Update( FN_SHOW_MULTIPLE_PAGES );
+ // OD 18.12.2002 #103492# - adjust scrollbars
+ mrView.ScrollViewSzChg();
+}
+/*--------------------------------------------------------------------
+ Beschreibung:, mnSttPage is Absolute
+ --------------------------------------------------------------------*/
+
+
+int SwPagePreViewWin::MovePage( int eMoveMode )
+{
+ // soviele Seiten hoch
+ USHORT nPages = mnRow * mnCol;
+ USHORT nNewSttPage = mnSttPage;
+ // OD 04.12.2002 #103492#
+ USHORT nPageCount = mrView.GetPageCount();
+ USHORT nDefSttPg = GetDefSttPage();
+ // OD 06.12.2002 #103492#
+ bool bPaintPageAtFirstCol = true;
+
+ switch( eMoveMode )
+ {
+ case MV_PAGE_UP:
+ {
+ const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
+ const sal_uInt16 nNewAbsSttPage = nRelSttPage - nPages > 0 ?
+ mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage - nPages ) :
+ nDefSttPg;
+ nNewSttPage = nNewAbsSttPage;
+
+ const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
+ const sal_uInt16 nNewRelSelPage = nRelSelPage - nPages > 0 ?
+ nRelSelPage - nPages :
+ 1;
+ SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewRelSelPage ) );
+
+ break;
+ }
+ case MV_PAGE_DOWN:
+ {
+ const sal_uInt16 nRelSttPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( mnSttPage );
+ const sal_uInt16 nNewAbsSttPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSttPage + nPages );
+ nNewSttPage = nNewAbsSttPage < nPageCount ? nNewAbsSttPage : nPageCount;
+
+ const sal_uInt16 nRelSelPage = mpPgPrevwLayout->ConvertAbsoluteToRelativePageNum( SelectedPage() );
+ const sal_uInt16 nNewAbsSelPage = mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nRelSelPage + nPages );
+ SetSelectedPage( nNewAbsSelPage < nPageCount ? nNewAbsSelPage : nPageCount );
+
+ break;
+ }
+ case MV_DOC_STT:
+ nNewSttPage = nDefSttPg;
+ SetSelectedPage( mpPgPrevwLayout->ConvertRelativeToAbsolutePageNum( nNewSttPage ? nNewSttPage : 1 ) );
+ break;
+ case MV_DOC_END:
+ // OD 03.12.2002 #103492# - correct calculation of new start page.
+ nNewSttPage = nPageCount;
+ SetSelectedPage( nPageCount );
+ break;
+ // OD 12.12.2002 #103492# - add new move mode
+ case MV_SELPAGE:
+ // <nNewSttPage> and <SelectedPage()> are already set.
+ // OD 20.02.2003 #107369# - not start at first column, only if the
+ // complete preview layout columns doesn't fit into window.
+ if ( !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() )
+ bPaintPageAtFirstCol = false;
+ break;
+ case MV_SCROLL:
+ // OD 17.01.2003 #103492# - check, if paint page at first column
+ // has to be avoided
+ if ( !mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() ||
+ !mpPgPrevwLayout->DoesPreviewLayoutColsFitIntoWindow() )
+ bPaintPageAtFirstCol = false;
+ break;
+ case MV_NEWWINSIZE:
+ // OD 18.12.2002 #103492# - nothing special to do.
+ break;
+ case MV_CALC:
+ // OD 18.12.2002 #103492# - re-init page preview layout.
+ mpPgPrevwLayout->ReInit();
+
+ // OD 03.12.2002 #103492# - correct calculation of new start page.
+ if( nNewSttPage > nPageCount )
+ nNewSttPage = nPageCount;
+
+ // OD 18.12.2002 #103492# - correct selected page number
+ if( SelectedPage() > nPageCount )
+ SetSelectedPage( nNewSttPage ? nNewSttPage : 1 );
+ }
+
+ mpPgPrevwLayout->Prepare( nNewSttPage, Point(0,0), maPxWinSize,
+ nNewSttPage,
+ maPaintedPreviewDocRect, bPaintPageAtFirstCol );
+ if( nNewSttPage == mnSttPage &&
+ eMoveMode != MV_SELPAGE )
+ return FALSE;
+
+ SetPagePreview(mnRow, mnCol);
+ mnSttPage = nNewSttPage;
+
+ // OD 24.03.2003 #108282# - additional invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreViewWin::SetWinSize( const Size& rNewSize )
+{
+ // die Size wollen wir aber immer in Pixel-Einheiten haben
+ maPxWinSize = LogicToPixel( rNewSize );
+
+ if( USHRT_MAX == mnSttPage )
+ {
+ mnSttPage = GetDefSttPage();
+ SetSelectedPage( GetDefSttPage() );
+ }
+
+ if ( mbCalcScaleForPreviewLayout )
+ {
+ mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ maScale = GetMapMode().GetScaleX();
+ }
+ mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ if ( mbCalcScaleForPreviewLayout )
+ {
+ SetSelectedPage( mnSttPage );
+ mbCalcScaleForPreviewLayout = false;
+ }
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreViewWin::GetStatusStr( String& rStr, USHORT nPageCnt ) const
+{
+ // OD 24.03.2003 #108282# - show physical and virtual page number of
+ // selected page, if it's visible.
+ sal_uInt16 nPageNum;
+ if ( mpPgPrevwLayout->IsPageVisible( mpPgPrevwLayout->SelectedPage() ) )
+ {
+ nPageNum = mpPgPrevwLayout->SelectedPage();
+ }
+ else
+ {
+ nPageNum = mnSttPage > 1 ? mnSttPage : 1;
+ }
+ sal_uInt16 nVirtPageNum = mpPgPrevwLayout->GetVirtPageNumByPageNum( nPageNum );
+ if( nVirtPageNum && nVirtPageNum != nPageNum )
+ {
+ rStr += String::CreateFromInt32( nVirtPageNum );
+ rStr += ' ';
+ }
+ rStr += String::CreateFromInt32( nPageNum );
+ rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
+ rStr += String::CreateFromInt32( nPageCnt );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreViewWin::KeyInput( const KeyEvent &rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ USHORT nKey = rKeyCode.GetCode();
+ BOOL bHandled = FALSE;
+ if(!rKeyCode.GetModifier())
+ {
+ USHORT nSlot = 0;
+ switch(nKey)
+ {
+ case KEY_ADD : nSlot = SID_ZOOM_OUT; break;
+ case KEY_ESCAPE: nSlot = FN_CLOSE_PAGEPREVIEW; break;
+ case KEY_SUBTRACT : nSlot = SID_ZOOM_IN; break;
+ }
+ if(nSlot)
+ {
+ bHandled = TRUE;
+ mrView.GetViewFrame()->GetDispatcher()->Execute(
+ nSlot, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+ if( !bHandled && !mrView.KeyInput( rKEvt ) )
+ Window::KeyInput( rKEvt );
+}
+
+/******************************************************************************
+ * Beschreibung:
+ ******************************************************************************/
+
+void SwPagePreViewWin::Command( const CommandEvent& rCEvt )
+{
+ BOOL bCallBase = TRUE;
+ switch( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ mrView.GetViewFrame()->GetDispatcher()->ExecutePopup();
+ bCallBase = FALSE;
+ break;
+
+ case COMMAND_WHEEL:
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( pData )
+ {
+ const CommandWheelData aDataNew(pData->GetDelta(),pData->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL,
+ pData->GetMode(),pData->GetModifier(),pData->IsHorz(), pData->IsDeltaPixel());
+ const CommandEvent aEvent( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),rCEvt.IsMouseEvent(),&aDataNew);
+ bCallBase = !mrView.HandleWheelCommands( aEvent );
+ }
+ else
+ bCallBase = !mrView.HandleWheelCommands( rCEvt );
+ }
+ break;
+ default:
+ // OD 17.12.2002 #103492# - delete assertion
+ ;
+ }
+
+ if( bCallBase )
+ Window::Command( rCEvt );
+}
+
+void SwPagePreViewWin::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // OD 17.12.2002 #103492# - consider single-click to set selected page
+ if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) )
+ {
+ Point aPrevwPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+ Point aDocPos;
+ bool bPosInEmptyPage;
+ sal_uInt16 nNewSelectedPage;
+ bool bIsDocPos =
+ mpPgPrevwLayout->IsPrevwPosInDocPrevwPage( aPrevwPos,
+ aDocPos, bPosInEmptyPage, nNewSelectedPage );
+ if ( bIsDocPos && rMEvt.GetClicks() == 2 )
+ {
+ // close page preview, set new cursor position and switch to
+ // normal view.
+ String sNewCrsrPos( String::CreateFromInt32( aDocPos.X() ));
+ ((( sNewCrsrPos += ';' )
+ += String::CreateFromInt32( aDocPos.Y() )) )
+ += ';';
+ mrView.SetNewCrsrPos( sNewCrsrPos );
+
+ SfxViewFrame *pTmpFrm = mrView.GetViewFrame();
+ pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
+ SFX_CALLMODE_ASYNCHRON );
+ }
+ else if ( bIsDocPos || bPosInEmptyPage )
+ // OD 2004-03-04 #i20684# - add missing parenthesis
+ {
+ // show clicked page as the selected one
+ mpPgPrevwLayout->MarkNewSelectedPage( nNewSelectedPage );
+ GetViewShell()->ShowPreViewSelection( nNewSelectedPage );
+ // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
+ if ( mpPgPrevwLayout->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ mrView.SetVScrollbarThumbPos( nNewSelectedPage );
+ }
+ // OD 24.03.2003 #108282# - invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ }
+ }
+}
+
+/******************************************************************************
+ * Beschreibung: Userprefs bzw Viewoptions setzen
+ ******************************************************************************/
+
+
+void SwPagePreViewWin::SetPagePreview( BYTE nRow, BYTE nCol )
+{
+ SwMasterUsrPref *pOpt = (SwMasterUsrPref *)SW_MOD()->GetUsrPref(FALSE);
+
+ if (nRow != pOpt->GetPagePrevRow() || nCol != pOpt->GetPagePrevCol())
+ {
+ pOpt->SetPagePrevRow( nRow );
+ pOpt->SetPagePrevCol( nCol );
+ pOpt->SetModified();
+
+ //Scrollbar updaten!
+ mrView.ScrollViewSzChg();
+ }
+}
+
+/** get selected page in document preview
+
+ OD 13.12.2002 #103492#
+
+ @author OD
+*/
+sal_uInt16 SwPagePreViewWin::SelectedPage() const
+{
+ return mpPgPrevwLayout->SelectedPage();
+}
+
+/** set selected page number in document preview
+
+ OD 13.12.2002 #103492#
+
+ @author OD
+*/
+void SwPagePreViewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum )
+{
+ mpPgPrevwLayout->SetSelectedPage( _nSelectedPageNum );
+}
+
+/** method to enable/disable book preview
+
+ OD 2004-03-05 #i18143#
+
+ @author OD
+*/
+bool SwPagePreViewWin::SetBookPreviewMode( const bool _bBookPreview )
+{
+ return mpPgPrevwLayout->SetBookPreviewMode( _bBookPreview,
+ mnSttPage,
+ maPaintedPreviewDocRect );
+}
+
+void SwPagePreViewWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ switch( rDCEvt.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
+ // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
+ // Resize-Handler aber auch die Groesse der ScrollBars aus
+ // den Settings abgefragt werden.
+ if( rDCEvt.GetFlags() & SETTINGS_STYLE )
+ mrView.InvalidateBorder(); //Scrollbarbreiten
+ //#106746# zoom has to be disabled if Accessibility support is switched on
+ lcl_InvalidateZoomSlots(mrView.GetViewFrame()->GetBindings());
+ break;
+
+ case DATACHANGED_PRINTER:
+ case DATACHANGED_DISPLAY:
+ case DATACHANGED_FONTS:
+ case DATACHANGED_FONTSUBSTITUTION:
+ mrView.GetDocShell()->UpdateFontList(); //Fontwechsel
+ if ( mpViewShell->GetWin() )
+ mpViewShell->GetWin()->Invalidate();
+ break;
+ }
+}
+
+/** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
+
+ OD 04.03.2003 #107369#
+
+ @author OD
+*/
+void SwPagePreView::_ExecPgUpAndPgDown( const bool _bPgUp,
+ SfxRequest* _pReq )
+{
+ SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
+ // check, if top/bottom of preview is *not* already visible.
+ if( pPagePrevwLay->GetWinPagesScrollAmount( _bPgUp ? -1 : 1 ) != 0 )
+ {
+ if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() &&
+ pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() )
+ {
+ const int eMvMode = _bPgUp ?
+ SwPagePreViewWin::MV_PAGE_UP :
+ SwPagePreViewWin::MV_PAGE_DOWN;
+ if ( ChgPage( eMvMode, TRUE ) )
+ aViewWin.Invalidate();
+ }
+ else
+ {
+ SwTwips nScrollAmount;
+ sal_uInt16 nNewSelectedPageNum = 0;
+ const sal_uInt16 nVisPages = aViewWin.GetRow() * aViewWin.GetCol();
+ if( _bPgUp )
+ {
+ if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( -1 );
+ if ( (aViewWin.SelectedPage() - nVisPages) > 0 )
+ nNewSelectedPageNum = aViewWin.SelectedPage() - nVisPages;
+ else
+ nNewSelectedPageNum = 1;
+ }
+ else
+ nScrollAmount = - Min( aViewWin.GetOutputSize().Height(),
+ aViewWin.GetPaintedPreviewDocRect().Top() );
+ }
+ else
+ {
+ if ( pPagePrevwLay->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ nScrollAmount = pPagePrevwLay->GetWinPagesScrollAmount( 1 );
+ if ( (aViewWin.SelectedPage() + nVisPages) <= mnPageCount )
+ nNewSelectedPageNum = aViewWin.SelectedPage() + nVisPages;
+ else
+ nNewSelectedPageNum = mnPageCount;
+ }
+ else
+ nScrollAmount = Min( aViewWin.GetOutputSize().Height(),
+ ( pPagePrevwLay->GetPrevwDocSize().Height() -
+ aViewWin.GetPaintedPreviewDocRect().Bottom() ) );
+ }
+ aViewWin.Scroll( 0, nScrollAmount );
+ if ( nNewSelectedPageNum != 0 )
+ {
+ aViewWin.SetSelectedPage( nNewSelectedPageNum );
+ }
+ ScrollViewSzChg();
+ // OD 24.03.2003 #108282# - additional invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ aViewWin.Invalidate();
+ }
+ }
+
+ if ( _pReq )
+ _pReq->Done();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+// dann mal alles fuer die SwPagePreView
+void SwPagePreView::Execute( SfxRequest &rReq )
+{
+ int eMvMode;
+ BYTE nRow = 1;
+ BOOL bRetVal = FALSE;
+ bool bRefresh = true;
+
+ switch(rReq.GetSlot())
+ {
+ case FN_REFRESH_VIEW:
+ case FN_STAT_PAGE:
+ case FN_STAT_ZOOM:
+ break;
+
+ case FN_SHOW_MULTIPLE_PAGES:
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 2 )
+ {
+ BYTE nCols = (BYTE)((SfxUInt16Item &)pArgs->Get(
+ SID_ATTR_TABLE_COLUMN)).GetValue();
+ BYTE nRows = (BYTE)((SfxUInt16Item &)pArgs->Get(
+ SID_ATTR_TABLE_ROW)).GetValue();
+ aViewWin.CalcWish( nRows, nCols );
+
+ }
+ else
+ SwPreViewZoomDlg( aViewWin ).Execute();
+
+ }
+ break;
+ case FN_SHOW_BOOKVIEW:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ bool bBookPreview = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_SHOW_BOOKVIEW, FALSE, &pItem ) )
+ {
+ bBookPreview = static_cast< const SfxBoolItem* >( pItem )->GetValue();
+ ( ( SwViewOption* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview );
+ // cast is not gentleman like, but it's common use in writer and in this case
+ }
+ if ( aViewWin.SetBookPreviewMode( bBookPreview ) )
+ {
+ // book preview mode changed. Thus, adjust scrollbars and
+ // invalidate corresponding states.
+ ScrollViewSzChg();
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, FN_SHOW_BOOKVIEW, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ aViewWin.Invalidate();
+ }
+
+ }
+ break;
+ case FN_SHOW_TWO_PAGES:
+ aViewWin.CalcWish( nRow, 2 );
+ break;
+
+ case FN_PREVIEW_ZOOM:
+ case SID_ATTR_ZOOM:
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ AbstractSvxZoomDialog *pDlg = 0;
+ if(!pArgs)
+ {
+ SfxItemSet aCoreSet(GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SvxZoomItem aZoom( (SvxZoomType)pVOpt->GetZoomType(),
+ pVOpt->GetZoom() );
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200|
+ SVX_ZOOM_ENABLE_WHOLEPAGE);
+ aCoreSet.Put( aZoom );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ }
+
+ pDlg->SetLimits( MINZOOM, MAXZOOM );
+
+ if( pDlg->Execute() != RET_CANCEL )
+ pArgs = pDlg->GetOutputItemSet();
+ }
+ if( pArgs )
+ {
+ enum SvxZoomType eType = SVX_ZOOM_PERCENT;
+ USHORT nZoomFactor = USHRT_MAX;
+ if(SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOM, TRUE, &pItem))
+ {
+ eType = ((const SvxZoomItem *)pItem)->GetType();
+ nZoomFactor = ((const SvxZoomItem *)pItem)->GetValue();
+ }
+ else if(SFX_ITEM_SET == pArgs->GetItemState(FN_PREVIEW_ZOOM, TRUE, &pItem))
+ nZoomFactor = ((const SfxUInt16Item *)pItem)->GetValue();
+ if(USHRT_MAX != nZoomFactor)
+ SetZoom(eType, nZoomFactor);
+ }
+ delete pDlg;
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER :
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, TRUE, &pItem ) )
+ {
+ const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
+ }
+ }
+ break;
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ enum SvxZoomType eType = SVX_ZOOM_PERCENT;
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SetZoom(eType,
+ lcl_GetNextZoomStep(pVOpt->GetZoom(), SID_ZOOM_IN == rReq.GetSlot()));
+ }
+ break;
+ case FN_CHAR_LEFT:
+ case FN_CHAR_RIGHT:
+ case FN_LINE_UP:
+ case FN_LINE_DOWN:
+ {
+ SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
+ sal_uInt16 nNewSelectedPage;
+ sal_uInt16 nNewStartPage;
+ Point aNewStartPos;
+ sal_Int16 nHoriMove = 0;
+ sal_Int16 nVertMove = 0;
+ switch(rReq.GetSlot())
+ {
+ case FN_CHAR_LEFT: nHoriMove = -1; break;
+ case FN_CHAR_RIGHT: nHoriMove = 1; break;
+ case FN_LINE_UP: nVertMove = -1; break;
+ case FN_LINE_DOWN: nVertMove = 1; break;
+ }
+ pPagePrevwLay->CalcStartValuesForSelectedPageMove( nHoriMove, nVertMove,
+ nNewSelectedPage, nNewStartPage, aNewStartPos );
+ if ( aViewWin.SelectedPage() != nNewSelectedPage )
+ {
+ if ( pPagePrevwLay->IsPageVisible( nNewSelectedPage ) )
+ {
+ pPagePrevwLay->MarkNewSelectedPage( nNewSelectedPage );
+ // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
+ SetVScrollbarThumbPos( nNewSelectedPage );
+ bRefresh = false;
+ }
+ else
+ {
+ aViewWin.SetSelectedPage( nNewSelectedPage );
+ aViewWin.SetSttPage( nNewStartPage );
+ int nRet = ChgPage( SwPagePreViewWin::MV_SELPAGE, TRUE );
+ bRefresh = 0 != nRet;
+ }
+ GetViewShell()->ShowPreViewSelection( nNewSelectedPage );
+ // OD 24.03.2003 #108282# - invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ rReq.Done();
+ }
+ else
+ {
+ bRefresh = false;
+ }
+ break;
+ }
+ case FN_PAGEUP:
+ case FN_PAGEDOWN:
+ {
+ _ExecPgUpAndPgDown( rReq.GetSlot() == FN_PAGEUP, &rReq );
+ break;
+ }
+ case FN_START_OF_LINE:
+ case FN_START_OF_DOCUMENT:
+ aViewWin.SetSelectedPage( 1 );
+ eMvMode = SwPagePreViewWin::MV_DOC_STT; bRetVal = TRUE; goto MOVEPAGE;
+ case FN_END_OF_LINE:
+ case FN_END_OF_DOCUMENT:
+ aViewWin.SetSelectedPage( mnPageCount );
+ eMvMode = SwPagePreViewWin::MV_DOC_END; bRetVal = TRUE; goto MOVEPAGE;
+MOVEPAGE:
+ {
+ int nRet = ChgPage( eMvMode, TRUE );
+ // return value fuer Basic
+ if(bRetVal)
+ rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), nRet == 0));
+
+ bRefresh = 0 != nRet;
+ rReq.Done();
+ }
+ break;
+
+ case FN_PRINT_PAGEPREVIEW:
+ {
+ const SwPagePreViewPrtData* pPPVPD = aViewWin.GetViewShell()->GetDoc()->GetPreViewPrtData();
+ // die Sache mit der Orientation
+ if(pPPVPD)
+ {
+ SfxPrinter* pPrinter = GetPrinter( TRUE );
+ if((pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE)
+ != pPPVPD->GetLandscape())
+ pPrinter->SetOrientation(pPPVPD->GetLandscape() ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+ }
+ ::SetAppPrintOptions( aViewWin.GetViewShell(), FALSE );
+ bNormalPrint = FALSE;
+ USHORT nPrtSlot = SID_PRINTDOC;
+ rReq.SetSlot( nPrtSlot );
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ rReq.SetSlot( FN_PRINT_PAGEPREVIEW );
+ return;
+ }
+ case SID_PRINTDOCDIRECT:
+ case SID_PRINTDOC:
+ ::SetAppPrintOptions( aViewWin.GetViewShell(), FALSE );
+ bNormalPrint = TRUE;
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ return;
+ case FN_CLOSE_PAGEPREVIEW:
+ case SID_PRINTPREVIEW:
+ // print preview is now always in the same frame as the tab view
+ // -> always switch this frame back to normal view
+ // (ScTabViewShell ctor reads stored view data)
+ GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, 0, 0, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case FN_INSERT_BREAK:
+ {
+ USHORT nSelPage = aViewWin.SelectedPage();
+ //if a dummy page is selected (e.g. a non-existing right/left page)
+ //the direct neighbor is used
+ if(GetViewShell()->IsDummyPage( nSelPage ) && GetViewShell()->IsDummyPage( --nSelPage ))
+ nSelPage +=2;
+ SetNewPage( nSelPage );
+ SfxViewFrame *pTmpFrm = GetViewFrame();
+ pTmpFrm->GetBindings().Execute( SID_VIEWSHELL0, NULL, 0,
+ SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ default:
+ ASSERT(!this, falscher Dispatcher);
+ return;
+ }
+
+ if( bRefresh )
+ aViewWin.Invalidate();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::GetState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter(rSet);
+ BYTE nRow = 1;
+ USHORT nWhich = aIter.FirstWhich();
+ ASSERT(nWhich, leeres Set);
+ SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
+ //#106746# zoom has to be disabled if Accessibility support is switched on
+ // MT 2010/01, see #110498#
+ BOOL bZoomEnabled = TRUE; // !Application::GetSettings().GetMiscSettings().GetEnableATToolSupport();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_START_OF_DOCUMENT:
+ {
+ if ( pPagePrevwLay->IsPageVisible( 1 ) )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_END_OF_DOCUMENT:
+ {
+ if ( pPagePrevwLay->IsPageVisible( mnPageCount ) )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_PAGEUP:
+ {
+ if( pPagePrevwLay->GetWinPagesScrollAmount( -1 ) == 0 )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case FN_PAGEDOWN:
+ {
+ if( pPagePrevwLay->GetWinPagesScrollAmount( 1 ) == 0 )
+ rSet.DisableItem(nWhich);
+ break;
+ }
+
+ case FN_STAT_PAGE:
+ {
+ String aStr( sPageStr );
+ aViewWin.GetStatusStr( aStr, mnPageCount );
+ rSet.Put( SfxStringItem( nWhich, aStr) );
+ }
+ break;
+
+ case SID_ATTR_ZOOM:
+ case FN_STAT_ZOOM:
+ {
+ if(bZoomEnabled)
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ SvxZoomItem aZoom((SvxZoomType)pVOpt->GetZoomType(),
+ pVOpt->GetZoom());
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ rSet.Put( aZoom );
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER :
+ {
+ if(bZoomEnabled)
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ const USHORT nCurrentZoom = pVOpt->GetZoom();
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+ rSet.Put( aZoomSliderItem );
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_PREVIEW_ZOOM:
+ {
+ if(bZoomEnabled)
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ rSet.Put(SfxUInt16Item(nWhich, pVOpt->GetZoom()));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_ZOOM_IN:
+ case SID_ZOOM_OUT:
+ {
+ const SwViewOption* pVOpt = GetViewShell()->GetViewOptions();
+ if(!bZoomEnabled || (SID_ZOOM_OUT == nWhich && pVOpt->GetZoom() >= MAX_PREVIEW_ZOOM)||
+ (SID_ZOOM_IN == nWhich && pVOpt->GetZoom() <= MIN_PREVIEW_ZOOM))
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case FN_SHOW_MULTIPLE_PAGES:
+ //should never be disabled
+ break;
+ case FN_SHOW_BOOKVIEW:
+ {
+ BOOL b = GetViewShell()->GetViewOptions()->IsPagePrevBookview();
+ rSet.Put(SfxBoolItem(nWhich, b));
+ }
+ break;
+
+ case FN_SHOW_TWO_PAGES:
+ if( 2 == aViewWin.GetCol() && nRow == aViewWin.GetRow() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FN_PRINT_PAGEPREVIEW:
+ // hat den gleichen Status wie das normale Drucken
+ {
+ const SfxPoolItem* pItem;
+ SfxItemSet aSet( *rSet.GetPool(), SID_PRINTDOC, SID_PRINTDOC );
+ GetSlotState( SID_PRINTDOC, SfxViewShell::GetInterface(), &aSet );
+ if( SFX_ITEM_DISABLED == aSet.GetItemState( SID_PRINTDOC,
+ FALSE, &pItem ))
+ rSet.DisableItem( nWhich );
+ else if( SFX_ITEM_SET == aSet.GetItemState( SID_PRINTDOC,
+ FALSE, &pItem ))
+ {
+ ((SfxPoolItem*)pItem)->SetWhich( FN_PRINT_PAGEPREVIEW );
+ rSet.Put( *pItem );
+ }
+ }
+ break;
+
+ case SID_PRINTPREVIEW:
+ rSet.Put( SfxBoolItem( nWhich, TRUE ) );
+ break;
+
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::StateUndo(SfxItemSet& rSet)
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::Init(const SwViewOption * pPrefs)
+{
+ if ( GetViewShell()->HasDrawView() )
+ GetViewShell()->GetDrawView()->SetAnimationEnabled( FALSE );
+
+ bNormalPrint = TRUE;
+
+ // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
+ // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
+ // nicht in der SFX-Verwaltung bekannt ist.
+
+ if( !pPrefs )
+ pPrefs = SW_MOD()->GetUsrPref(FALSE);
+
+ // die Felder aktualisieren
+ // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
+ // In den Methoden wird auf die akt. Shell abgefragt!
+ SwEditShell* pESh = (SwEditShell*)GetViewShell();
+ BOOL bIsModified = pESh->IsModified();
+
+
+ SwViewOption aOpt( *pPrefs );
+ aOpt.SetPagePreview(TRUE);
+ aOpt.SetTab( FALSE );
+ aOpt.SetBlank( FALSE );
+ aOpt.SetHardBlank( FALSE );
+ aOpt.SetParagraph( FALSE );
+ aOpt.SetLineBreak( FALSE );
+ aOpt.SetPageBreak( FALSE );
+ aOpt.SetColumnBreak( FALSE );
+ aOpt.SetSoftHyph( FALSE );
+ aOpt.SetFldName( FALSE );
+ aOpt.SetPostIts( FALSE );
+ aOpt.SetShowHiddenChar( FALSE );
+ aOpt.SetShowHiddenField( FALSE );
+ aOpt.SetShowHiddenPara( FALSE );
+ aOpt.SetViewHRuler( FALSE );
+ aOpt.SetViewVRuler( FALSE );
+ aOpt.SetGraphic( TRUE );
+ aOpt.SetTable( TRUE );
+ aOpt.SetSnap( FALSE );
+ aOpt.SetGridVisible( FALSE );
+ GetViewShell()->ApplyViewOptions( aOpt );
+ GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
+
+ // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print
+ SwPrtOptions aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) );
+ aPrintOptions.MakeOptions( false );
+ GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions );
+
+ IDocumentSettingAccess* pIDSA = pESh->getIDocumentSettingAccess();
+ if( pIDSA->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ pIDSA->set(IDocumentSettingAccess::BROWSE_MODE, false);
+ pESh->CheckBrowseView( TRUE );
+ }
+
+ GetViewShell()->CalcLayout();
+ DocSzChgd( GetViewShell()->GetDocSize() );
+
+ if( !bIsModified )
+ pESh->ResetModified();
+
+ pVScrollbar->ExtendedShow(pPrefs->IsViewVScrollBar());
+ pHScrollbar->ExtendedShow(pPrefs->IsViewHScrollBar());
+ pScrollFill->Show(pPrefs->IsViewVScrollBar() && pPrefs->IsViewHScrollBar());
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwPagePreView::SwPagePreView(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
+ SfxViewShell( pViewFrame, SWVIEWFLAGS ),
+ aViewWin( &pViewFrame->GetWindow(), *this ),
+ nNewPage(USHRT_MAX),
+ pHScrollbar(0),
+ pVScrollbar(0),
+ pPageUpBtn(0),
+ pPageDownBtn(0),
+ pScrollFill(new ScrollBarBox( &pViewFrame->GetWindow(),
+ pViewFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
+ mnPageCount( 0 ),
+ // OD 09.01.2003 #106334#
+ mbResetFormDesignMode( false ),
+ mbFormDesignModeToReset( false )
+{
+ SetName(String::CreateFromAscii("PageView" ));
+ SetWindow( &aViewWin );
+ SetHelpId(SW_PAGEPREVIEW);
+ _CreateScrollbar( TRUE );
+ _CreateScrollbar( FALSE );
+
+ SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
+ if ( !pOldSh )
+ {
+ //Gibt es schon eine Sicht auf das Dokument?
+ SfxViewFrame *pF = SfxViewFrame::GetFirst( pObjShell );
+ if ( pF == pViewFrame )
+ pF = SfxViewFrame::GetNext( *pF, pObjShell );
+ if ( pF )
+ pOldSh = pF->GetViewShell();
+ }
+
+ ViewShell *pVS, *pNew;
+
+ if( pOldSh && pOldSh->IsA( TYPE( SwPagePreView ) ) )
+ pVS = ((SwPagePreView*)pOldSh)->GetViewShell();
+ else
+ {
+ if( pOldSh && pOldSh->IsA( TYPE( SwView ) ) )
+ {
+ pVS = ((SwView*)pOldSh)->GetWrtShellPtr();
+ // save the current ViewData of the previous SwView
+ pOldSh->WriteUserData( sSwViewData, FALSE );
+ }
+ else
+ pVS = GetDocShell()->GetWrtShell();
+ if( pVS )
+ {
+ // setze die akt. Seite als die erste
+ USHORT nPhysPg, nVirtPg;
+ ((SwCrsrShell*)pVS)->GetPageNum( nPhysPg, nVirtPg, /*FALSE*/TRUE, FALSE );
+ if( 1 != aViewWin.GetCol() && 1 == nPhysPg )
+ --nPhysPg;
+ aViewWin.SetSttPage( nPhysPg );
+ }
+ }
+
+ // OD 09.01.2003 #106334# - for form shell remember design mode of draw view
+ // of previous view shell
+ if ( pVS && pVS->HasDrawView() )
+ {
+ mbResetFormDesignMode = true;
+ mbFormDesignModeToReset = pVS->GetDrawView()->IsDesignMode();
+ }
+
+ if( pVS )
+ pNew = new ViewShell( *pVS, &aViewWin, 0, VSHELLFLAG_ISPREVIEW );
+ else
+ pNew = new ViewShell(
+ *((SwDocShell*)pViewFrame->GetObjectShell())->GetDoc(),
+ &aViewWin, 0, 0, VSHELLFLAG_ISPREVIEW );
+
+ aViewWin.SetViewShell( pNew );
+ pNew->SetSfxViewShell( this );
+ Init();
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+ SwPagePreView::~SwPagePreView()
+{
+ SetWindow( 0 );
+
+ delete pScrollFill;
+ delete pHScrollbar;
+ delete pVScrollbar;
+ delete pPageUpBtn;
+ delete pPageDownBtn;
+
+/* SfxObjectShell* pDocSh = GetDocShell();
+ for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocSh );
+ pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) )
+ if( pFrame != GetViewFrame() )
+ {
+ // es gibt noch eine weitere Sicht auf unser Dokument, also
+ // aktiviere dieses
+ pFrame->GetFrame().Appear();
+ break;
+ }
+*/}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwDocShell* SwPagePreView::GetDocShell()
+{
+ return PTR_CAST(SwDocShell, GetViewFrame()->GetObjectShell());
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+int SwPagePreView::_CreateScrollbar( BOOL bHori )
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+ SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
+
+ ASSERT( !*ppScrollbar, "vorher abpruefen!" )
+
+ if( !bHori )
+ {
+
+ pPageUpBtn = new ImageButton(pMDI, SW_RES( BTN_PAGEUP ) );
+ pPageUpBtn->SetHelpId(FN_PAGEUP);
+ pPageDownBtn = new ImageButton(pMDI, SW_RES( BTN_PAGEDOWN ) );
+ pPageDownBtn->SetHelpId(FN_PAGEDOWN);
+ Link aLk( LINK( this, SwPagePreView, BtnPage ) );
+ pPageUpBtn->SetClickHdl( aLk );
+ pPageDownBtn->SetClickHdl( aLk );
+ pPageUpBtn->Show();
+ pPageDownBtn->Show();
+ }
+
+ *ppScrollbar = new SwScrollbar( pMDI, bHori );
+
+ ScrollDocSzChg();
+ (*ppScrollbar)->EnableDrag( TRUE );
+ (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwPagePreView, EndScrollHdl ));
+
+
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwPagePreView, ScrollHdl ));
+
+ InvalidateBorder();
+ (*ppScrollbar)->ExtendedShow();
+ return 1;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+/*
+ * Button-Handler
+ */
+IMPL_LINK_INLINE_START( SwPagePreView, BtnPage, Button *, pButton )
+{
+ // OD 04.03.2003 #107369# - use new helper method to perform page up
+ // respectively page down.
+ _ExecPgUpAndPgDown( pButton == pPageUpBtn );
+ return 0;
+}
+IMPL_LINK_INLINE_END( SwPagePreView, BtnPage, Button *, pButton )
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+int SwPagePreView::ChgPage( int eMvMode, int bUpdateScrollbar )
+{
+ Rectangle aPixVisArea( aViewWin.LogicToPixel( aVisArea ) );
+ int bChg = aViewWin.MovePage( eMvMode ) ||
+ eMvMode == SwPagePreViewWin::MV_CALC ||
+ eMvMode == SwPagePreViewWin::MV_NEWWINSIZE;
+ aVisArea = aViewWin.PixelToLogic( aPixVisArea );
+
+ if( bChg )
+ {
+ // Statusleiste updaten
+ String aStr( sPageStr );
+ aViewWin.GetStatusStr( aStr, mnPageCount );
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+
+ if( bUpdateScrollbar )
+ {
+ ScrollViewSzChg();
+
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT,
+ FN_PAGEUP, FN_PAGEDOWN, 0
+ };
+ rBindings.Invalidate( aInval );
+ }
+ rBindings.SetState( SfxStringItem( FN_STAT_PAGE, aStr ) );
+ }
+ return bChg;
+}
+
+
+/* */
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+// ab hier alles aus der SwView uebernommen
+
+
+void SwPagePreView::CalcAndSetBorderPixel( SvBorder &rToFill, BOOL /*bInner*/ )
+{
+// const long nAdd = bInner ? 0 : ScrollBar::GetWindowOverlapPixel();
+ const StyleSettings &rSet = aViewWin.GetSettings().GetStyleSettings();
+ const long nTmp = rSet.GetScrollBarSize();// - nAdd;
+ if ( pVScrollbar->IsVisible( FALSE ))
+ rToFill.Right() = nTmp;
+ if ( pHScrollbar->IsVisible( FALSE ) )
+ rToFill.Bottom() = nTmp;
+ SetBorderPixel( rToFill );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::InnerResizePixel( const Point &rOfst, const Size &rSize )
+{
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, TRUE );
+ Rectangle aRect( rOfst, rSize );
+ aRect += aBorder;
+ ViewResizePixel( aViewWin, aRect.TopLeft(), aRect.GetSize(),
+ aViewWin.GetOutputSizePixel(),
+ TRUE,
+ *pVScrollbar, *pHScrollbar, pPageUpBtn, pPageDownBtn, 0,
+ *pScrollFill );
+
+ //EditWin niemals einstellen!
+ //VisArea niemals einstellen!
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::OuterResizePixel( const Point &rOfst, const Size &rSize )
+{
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, FALSE );
+ ViewResizePixel( aViewWin, rOfst, rSize, aViewWin.GetOutputSizePixel(),
+ FALSE, *pVScrollbar,
+ *pHScrollbar, pPageUpBtn, pPageDownBtn, 0, *pScrollFill );
+
+ //EditWin niemals einstellen!
+
+ Size aTmpSize( aViewWin.GetOutputSizePixel() );
+ Point aBottomRight( aViewWin.PixelToLogic( Point( aTmpSize.Width(), aTmpSize.Height() ) ) );
+ SetVisArea( Rectangle( Point(), aBottomRight ) );
+
+ //Aufruf der DocSzChgd-Methode der Scrollbars ist noetig, da vom maximalen
+ //Scrollrange immer die halbe Hoehe der VisArea abgezogen wird.
+ if ( pVScrollbar &&
+ aTmpSize.Width() > 0 && aTmpSize.Height() > 0 )
+ {
+ ScrollDocSzChg();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::SetVisArea( const Rectangle &rRect, BOOL bUpdateScrollbar )
+{
+ const Point aTopLeft(AlignToPixel(rRect.TopLeft()));
+ const Point aBottomRight(AlignToPixel(rRect.BottomRight()));
+ Rectangle aLR(aTopLeft,aBottomRight);
+
+ if(aLR == aVisArea)
+ return;
+ // keine negative Position, keine neg. Groesse
+
+ if(aLR.Top() < 0)
+ {
+ aLR.Bottom() += Abs(aLR.Top());
+ aLR.Top() = 0;
+ }
+
+ if(aLR.Left() < 0)
+ {
+ aLR.Right() += Abs(aLR.Left());
+ aLR.Left() = 0;
+ }
+ if(aLR.Right() < 0) aLR.Right() = 0;
+ if(aLR.Bottom() < 0) aLR.Bottom() = 0;
+ if(aLR == aVisArea ||
+ // JP 29.10.97: Bug 45173 - Leeres Rechteck nicht beachten
+ ( 0 == aLR.Bottom() - aLR.Top() && 0 == aLR.Right() - aLR.Left() ) )
+ return;
+
+ if( aLR.Left() > aLR.Right() || aLR.Top() > aLR.Bottom() )
+ return;
+
+ //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
+ //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
+ //umgerechnet werden.
+ //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
+ //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
+ //lediglich (in Dokumentkoordinaten) vorgemerkt.
+ if( GetViewShell()->ActionPend() )
+ aViewWin.Update();
+
+ // setze am View-Win die aktuelle Size
+ aVisArea = aLR;
+ aViewWin.SetWinSize( aLR.GetSize() );
+ // OD 18.12.2002 #103492# - use new mode
+ ChgPage( SwPagePreViewWin::MV_NEWWINSIZE, bUpdateScrollbar );
+
+ aViewWin.Invalidate();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+IMPL_LINK( SwPagePreView, ScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if(!GetViewShell())
+ return 0;
+ if( !pScrollbar->IsHoriScroll() &&
+ pScrollbar->GetType() == SCROLL_DRAG &&
+ Help::IsQuickHelpEnabled() &&
+ GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
+ {
+ // wieviele Seiten scrollen ??
+ String sStateStr(sPageStr);
+ USHORT nThmbPos = (USHORT)pScrollbar->GetThumbPos();
+ if( 1 == aViewWin.GetCol() || !nThmbPos )
+ ++nThmbPos;
+ sStateStr += String::CreateFromInt32( nThmbPos );
+ Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
+ pScrollbar->GetPosPixel());
+ aPos.Y() = pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y();
+ Size aSize = pScrollbar->GetSizePixel();
+ Rectangle aRect;
+ aRect.Left() = aPos.X() -8;
+ aRect.Right() = aRect.Left();
+ aRect.Top() = aPos.Y();
+ aRect.Bottom() = aRect.Top();
+
+ Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
+ QUICKHELP_RIGHT|QUICKHELP_VCENTER);
+
+ }
+ else
+ EndScrollHdl( pScrollbar );
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+IMPL_LINK( SwPagePreView, EndScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if(!GetViewShell())
+ return 0;
+
+ // OD 04.03.2003 #107369# - boolean to avoid unnecessary invalidation of the window.
+ bool bInvalidateWin = true;
+
+ if( !pScrollbar->IsHoriScroll() ) // scroll vertically
+ {
+ if ( Help::IsQuickHelpEnabled() )
+ Help::ShowQuickHelp(pScrollbar, Rectangle(), aEmptyStr, 0);
+ if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
+ {
+ // wieviele Seiten scrollen ??
+ USHORT nThmbPos = (USHORT)pScrollbar->GetThumbPos();
+ // OD 05.12.2002 #103492# - adjust to new preview functionality
+ if( nThmbPos != aViewWin.SelectedPage() )
+ {
+ // OD 17.01.2003 #103492# - consider case that page <nThmbPos>
+ // is already visible
+ SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
+ if ( pPagePrevwLay->IsPageVisible( nThmbPos ) )
+ {
+ pPagePrevwLay->MarkNewSelectedPage( nThmbPos );
+ // OD 04.03.2003 #107369# - invalidation of window is unnecessary
+ bInvalidateWin = false;
+ }
+ else
+ {
+ // OD 17.01.2003 #103492# - consider whether layout columns
+ // fit or not.
+ if ( !pPagePrevwLay->DoesPreviewLayoutColsFitIntoWindow() )
+ {
+ aViewWin.SetSttPage( nThmbPos );
+ aViewWin.SetSelectedPage( nThmbPos );
+ ChgPage( SwPagePreViewWin::MV_SCROLL, FALSE );
+ // OD 20.01.2003 #103492# - update scrollbars
+ ScrollViewSzChg();
+ }
+ else
+ {
+ // OD 04.03.2003 #107369# - correct scroll amount
+ const sal_Int16 nPageDiff = nThmbPos - aViewWin.SelectedPage();
+ const sal_uInt16 nVisPages = aViewWin.GetRow() * aViewWin.GetCol();
+ sal_Int16 nWinPagesToScroll = nPageDiff / nVisPages;
+ if ( nPageDiff % nVisPages )
+ {
+ // decrease/increase number of preview pages to scroll
+ nPageDiff < 0 ? --nWinPagesToScroll : ++nWinPagesToScroll;
+ }
+ aViewWin.SetSelectedPage( nThmbPos );
+ aViewWin.Scroll( 0, pPagePrevwLay->GetWinPagesScrollAmount( nWinPagesToScroll ) );
+ }
+ }
+ // OD 17.01.2003 #103492# - update accessibility
+ GetViewShell()->ShowPreViewSelection( nThmbPos );
+ }
+ else
+ {
+ // OD 04.03.2003 #107369# - invalidation of window is unnecessary
+ bInvalidateWin = false;
+ }
+ }
+ else
+ {
+ long nThmbPos = pScrollbar->GetThumbPos();
+ aViewWin.Scroll(0, nThmbPos - aViewWin.GetPaintedPreviewDocRect().Top());
+ }
+ }
+ else
+ {
+ long nThmbPos = pScrollbar->GetThumbPos();
+ aViewWin.Scroll(nThmbPos - aViewWin.GetPaintedPreviewDocRect().Left(), 0);
+ }
+ // OD 24.03.2003 #108282# - additional invalidate page status.
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ FN_START_OF_DOCUMENT, FN_END_OF_DOCUMENT, FN_PAGEUP, FN_PAGEDOWN,
+ FN_STAT_PAGE, 0
+ };
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( aInval );
+ // OD 04.03.2003 #107369# - control invalidation of window
+ if ( bInvalidateWin )
+ {
+ aViewWin.Invalidate();
+ }
+ return 0;
+}
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+Point SwPagePreView::AlignToPixel(const Point &rPt) const
+{
+ return aViewWin.PixelToLogic( aViewWin.LogicToPixel( rPt ) );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::DocSzChgd( const Size &rSz )
+{
+ if( aDocSz == rSz )
+ return;
+
+ aDocSz = rSz;
+
+ // --> OD 2009-08-20 #i96726#
+ // Due to the multiple page layout it is needed to trigger recalculation
+ // of the page preview layout, even if the count of pages is not changing.
+ mnPageCount = GetViewShell()->GetNumPages();
+
+ if( aVisArea.GetWidth() )
+ {
+ ChgPage( SwPagePreViewWin::MV_CALC, TRUE );
+ ScrollDocSzChg();
+
+ aViewWin.Invalidate();
+ }
+ // <--
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::ScrollViewSzChg()
+{
+ if(!GetViewShell())
+ return ;
+ if(pVScrollbar)
+ {
+ if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
+ {
+ //vertical scrolling by row
+ // OD 04.12.2002 #103492# - adjust to new preview functionality
+ USHORT nVisPages = aViewWin.GetRow() * aViewWin.GetCol();
+ pVScrollbar->SetVisibleSize( nVisPages );
+ // OD 19.02.2003 #107369# - set selected page as scroll bar position,
+ // if it is visible.
+ SwPagePreviewLayout* pPagePrevwLay = GetViewShell()->PagePreviewLayout();
+ if ( pPagePrevwLay->IsPageVisible( aViewWin.SelectedPage() ) )
+ {
+ pVScrollbar->SetThumbPos( aViewWin.SelectedPage() );
+ }
+ else
+ {
+ pVScrollbar->SetThumbPos( aViewWin.GetSttPage() );
+ }
+ pVScrollbar->SetLineSize( aViewWin.GetCol() );
+ pVScrollbar->SetPageSize( nVisPages );
+ // calculate and set scrollbar range
+ Range aScrollbarRange( 1, mnPageCount );
+ // increase range by one, because left-top-corner is left blank.
+ ++aScrollbarRange.Max();
+ // OD 17.01.2003 #103492# - increase range in order to access all pages
+ aScrollbarRange.Max() += ( nVisPages - 1 );
+ pVScrollbar->SetRange( aScrollbarRange );
+ }
+ else //vertical scrolling by pixel
+ {
+ const Rectangle& rDocRect = aViewWin.GetPaintedPreviewDocRect();
+ const Size& rPreviewSize =
+ GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
+ pVScrollbar->SetRangeMax(rPreviewSize.Height()) ;
+ long nVisHeight = rDocRect.GetHeight();
+ pVScrollbar->SetVisibleSize( nVisHeight );
+ pVScrollbar->SetThumbPos( rDocRect.Top() );
+ pVScrollbar->SetLineSize( nVisHeight / 10 );
+ pVScrollbar->SetPageSize( nVisHeight / 2 );
+ }
+ }
+ if(pHScrollbar)
+ {
+ const Rectangle& rDocRect = aViewWin.GetPaintedPreviewDocRect();
+ const Size& rPreviewSize =
+ GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
+ long nVisWidth = 0;
+ long nThumb = 0;
+ Range aRange(0,0);
+
+ if(rDocRect.GetWidth() < rPreviewSize.Width())
+ {
+ nVisWidth = rDocRect.GetWidth();
+ nThumb = rDocRect.Left();
+ aRange = Range(0, rPreviewSize.Width());
+ }
+ pHScrollbar->SetRange( aRange );
+ pHScrollbar->SetVisibleSize( nVisWidth );
+ pHScrollbar->SetThumbPos( nThumb );
+ pHScrollbar->SetLineSize( nVisWidth / 10 );
+ pHScrollbar->SetPageSize( nVisWidth / 2 );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwPagePreView::ScrollDocSzChg()
+{
+ ScrollViewSzChg();
+}
+
+
+/* */
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+// alles zum Thema Drucken
+
+SfxPrinter* SwPagePreView::GetPrinter( BOOL bCreate )
+{
+ return aViewWin.GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+USHORT SwPagePreView::SetPrinter( SfxPrinter *pNew, USHORT nDiffFlags, bool )
+{
+ ViewShell &rSh = *GetViewShell();
+ SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
+ SwEditShell &rESh = (SwEditShell&)rSh; //Buh...
+ if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags )
+ {
+ rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
+ if( nDiffFlags & SFX_PRINTER_PRINTER )
+ rESh.SetModified();
+ }
+ if ( ( nDiffFlags & SFX_PRINTER_OPTIONS ) == SFX_PRINTER_OPTIONS )
+ ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, FALSE );
+
+ const BOOL bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? TRUE : FALSE;
+ const BOOL bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? TRUE : FALSE;
+ if ( bChgOri || bChgSize )
+ {
+ rESh.StartAllAction();
+ if ( bChgOri )
+ rSh.ChgAllPageOrientation( USHORT(pNew->GetOrientation()) );
+ if ( bChgSize )
+ {
+ Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
+ rSh.ChgAllPageSize( aSz );
+ }
+ if( !bNormalPrint )
+ aViewWin.CalcWish( aViewWin.GetRow(), aViewWin.GetCol() );
+ rESh.SetModified();
+ rESh.EndAllAction();
+
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
+ SID_RULER_BORDERS, SID_RULER_PAGE_POS, 0
+ };
+#ifdef DBG_UTIL
+ {
+ const USHORT* pPtr = aInval + 1;
+ do {
+ ASSERT( *(pPtr - 1) < *pPtr, "falsche Sortierung!" );
+ } while( *++pPtr );
+ }
+#endif
+
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SfxTabPage* SwPagePreView::CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions )
+{
+ return ::CreatePrintOptionsPage( pParent, rOptions, !bNormalPrint );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+PrintDialog* SwPagePreView::CreatePrintDialog( Window *pParent )
+{
+ PrintDialog *pDlg = ::CreatePrintDialog( pParent, 1, 0 );
+ pDlg->DisableRange( PRINTDIALOG_SELECTION );
+ return pDlg;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+// OD 18.12.2002 #103492# - no longer needed ??
+Size SwPagePreView::GetOptimalSizePixel() const
+{
+ ASSERT( false, "overloaded virtual method <SwPagePreView::GetOptimalSizePixel()> needed ??" )
+ return Size( -1, -1 );
+/*
+ //JP 09.06.99: was wird hier errechnet ?????
+// ALT:
+// SfxApplicationWindow* pWin = SFX_APPWINDOW ;
+// Rectangle aRect = pWin->GetClientAreaPixel();
+
+ Window& rWin = GetViewFrame()->GetWindow();
+ Rectangle aRect( Point(0, 0), rWin.GetOutputSizePixel() );
+ Size aMaxSize( aRect.GetWidth(), aRect.GetHeight() );
+ Size aInSize = rWin.GetOutputSizePixel();
+ Size aOutSize = rWin.GetSizePixel();
+ USHORT nXBorder = USHORT(aOutSize.Width() - aInSize.Width());
+ USHORT nYBorder = USHORT(aOutSize.Height() - aInSize.Height());
+ aMaxSize.Width() -= nXBorder;
+ //'auf Verdacht' etwas vom Border abziehen (Menue)
+ nYBorder -= (nYBorder - nXBorder) / 2;
+ aMaxSize.Height() -= nYBorder;
+ //mit der max. moeglichen Outputsize guenstigstes Verhaeltnis ausrechnen
+ aViewWin.GetOptimalSize(aMaxSize);
+ // Border wieder dazuzaehlen
+ aMaxSize.Height() += nYBorder;
+ aMaxSize.Width() += nXBorder;
+ return aMaxSize;
+*/
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+// OD 12.12.2002 #103492#
+void SwPagePreViewWin::SetViewShell( ViewShell* pShell )
+{
+ mpViewShell = pShell;
+ if ( mpViewShell && mpViewShell->IsPreView() )
+ {
+ mpPgPrevwLayout = mpViewShell->PagePreviewLayout();
+ }
+}
+
+void SwPagePreViewWin::RepaintCoreRect( const SwRect& rRect )
+{
+ // OD 2004-03-04 #i24183#
+ if ( mpPgPrevwLayout->PreviewLayoutValid() )
+ {
+ mpPgPrevwLayout->Repaint( Rectangle( rRect.Pos(), rRect.SSize() ) );
+ }
+}
+
+/** method to adjust preview to a new zoom factor
+
+ OD 02.12.2002 #103492#
+ OD 24.09.2003 #i19975# - also consider zoom type - adding parameter <_eZoomType>
+*/
+void SwPagePreViewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor,
+ const SvxZoomType _eZoomType )
+{
+ // OD 24.09.2003 #i19975# - consider zoom type
+ if ( _eZoomType == SVX_ZOOM_WHOLEPAGE )
+ {
+ mnRow = 1;
+ mnCol = 1;
+ mpPgPrevwLayout->Init( mnCol, mnRow, maPxWinSize, true );
+ mpPgPrevwLayout->Prepare( mnSttPage, Point(0,0), maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ SetSelectedPage( mnSttPage );
+ SetPagePreview(mnRow, mnCol);
+ maScale = GetMapMode().GetScaleX();
+ }
+ else if ( _nZoomFactor != 0 )
+ {
+ // calculate new scaling and set mapping mode appropriately.
+ Fraction aNewScale( _nZoomFactor, 100 );
+ MapMode aNewMapMode = GetMapMode();
+ aNewMapMode.SetScaleX( aNewScale );
+ aNewMapMode.SetScaleY( aNewScale );
+ SetMapMode( aNewMapMode );
+
+ // calculate new start position for preview paint
+ Size aNewWinSize = PixelToLogic( maPxWinSize );
+ Point aNewPaintStartPos =
+ mpPgPrevwLayout->GetPreviewStartPosForNewScale( aNewScale, maScale, aNewWinSize );
+
+ // remember new scaling and prepare preview paint
+ // Note: paint of preview will be performed by a corresponding invalidate
+ // due to property changes.
+ maScale = aNewScale;
+ mpPgPrevwLayout->Prepare( 0, aNewPaintStartPos, maPxWinSize,
+ mnSttPage, maPaintedPreviewDocRect );
+ }
+
+}
+/* -----------------04.12.2002 10:46-----------------
+ * pixel scrolling - horizontally always or vertically
+ * when less than the desired number of rows fits into
+ * the view
+ * --------------------------------------------------*/
+void SwPagePreViewWin::Scroll(long nXMove, long nYMove, USHORT /*nFlags*/)
+{
+ maPaintedPreviewDocRect.Move(nXMove, nYMove);
+ mpPgPrevwLayout->Prepare( 0, maPaintedPreviewDocRect.TopLeft(),
+ maPxWinSize, mnSttPage,
+ maPaintedPreviewDocRect );
+
+}
+
+BOOL SwPagePreView::HandleWheelCommands( const CommandEvent& rCEvt )
+{
+ BOOL bOk = FALSE;
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
+ {
+ if(!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
+ {
+ USHORT nFactor = GetViewShell()->GetViewOptions()->GetZoom();
+ const USHORT nOffset = 10;
+ if( 0L > pWData->GetDelta() )
+ {
+ nFactor -= nOffset;
+ if(nFactor < MIN_PREVIEW_ZOOM)
+ nFactor = MIN_PREVIEW_ZOOM;
+ }
+ else
+ {
+ nFactor += nOffset;
+ if(nFactor > MAX_PREVIEW_ZOOM)
+ nFactor = MAX_PREVIEW_ZOOM;
+ }
+ SetZoom(SVX_ZOOM_PERCENT, nFactor);
+ }
+ bOk = TRUE;
+ }
+ else
+ bOk = aViewWin.HandleScrollCommand( rCEvt, pHScrollbar, pVScrollbar );
+ return bOk;
+}
+
+
+uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SwPagePreViewWin::CreateAccessible()
+{
+ vos::OGuard aGuard(Application::GetSolarMutex()); // this should have
+ // happend already!!!
+
+ DBG_ASSERT( GetViewShell() != NULL, "We need a view shell" );
+ return GetViewShell()->CreateAccessiblePreview();
+}
+
+/* -----------------------------06.05.2002 13:18------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwPagePreView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
+{
+ GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions);
+}
+/* -----------------------------2002/06/26 14:30------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwPagePreView::ShowHScrollbar(sal_Bool bShow)
+{
+ pHScrollbar->Show(bShow);
+ InvalidateBorder();
+}
+
+/* -----------------------------2002/06/26 14:30------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwPagePreView::ShowVScrollbar(sal_Bool bShow)
+{
+ pVScrollbar->Show(bShow);
+ InvalidateBorder();
+}
+
+/* -----------------25.11.2002 16:36-----------------
+ *
+ * --------------------------------------------------*/
+void SwPagePreView::SetZoom(SvxZoomType eType, USHORT nFactor)
+{
+ ViewShell& rSh = *GetViewShell();
+ SwViewOption aOpt(*rSh.GetViewOptions());
+ // OD 16.12.2002 #103492# - perform action only on changes of zoom or zoom type.
+ if ( aOpt.GetZoom() != nFactor ||
+ aOpt.GetZoomType() != eType )
+ {
+ aOpt.SetZoom(nFactor);
+ aOpt.SetZoomType(eType);
+ rSh.ApplyViewOptions( aOpt );
+ lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
+ // OD 02.12.2002 #103492#
+ // OD 24.09.2003 #i19975# - also consider zoom type
+ aViewWin.AdjustPreviewToNewZoom( nFactor, eType );
+ ScrollViewSzChg();
+ }
+}
+
+/** adjust position of vertical scrollbar
+
+ OD 19.02.2003 #107369
+
+ @author OD
+*/
+void SwPagePreView::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos )
+{
+ if ( pVScrollbar )
+ {
+ pVScrollbar->SetThumbPos( _nNewThumbPos );
+ }
+}
diff --git a/sw/source/ui/uiview/pview.hrc b/sw/source/ui/uiview/pview.hrc
new file mode 100644
index 000000000000..3724789431ed
--- /dev/null
+++ b/sw/source/ui/uiview/pview.hrc
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "view.hrc"
+
+#define FT_COL 1
+#define FT_ROW 2
+#define ED_COL 4
+#define ED_ROW 5
+
+#define BT_OK 20
+#define BT_CANCEL 21
+#define BT_HELP 22
+
+// Grenzwerte fuers Zooming (werden auch im piew.cxx benutzt!)
+#define PVIEW_MIN_ROW 1
+#define PVIEW_MAX_ROW 10
+#define PVIEW_MIN_COL 1
+#define PVIEW_MAX_COL 20
+
+//Dialog Druckoptionen
+#define FL_ROWCOL 1
+#define FT_ROWS 2
+#define NF_ROWS 3
+#define FT_COLS 4
+#define NF_COLS 5
+#define FL_MARGINS 6
+#define FL_DISTANCE 7
+#define FL_ORIENTATION 8
+
+#define WIN_PREVIEW 11
+
+
+#define FT_LMARGIN 12
+#define MF_LMARGIN 13
+#define FT_RMARGIN 14
+#define MF_RMARGIN 15
+#define FT_TMARGIN 16
+#define MF_TMARGIN 17
+#define FT_BMARGIN 18
+#define MF_BMARGIN 19
+#define FT_HMARGIN 20
+#define MF_HMARGIN 21
+#define FT_VMARGIN 22
+#define MF_VMARGIN 23
+#define PB_STANDARD 24
+
+#define RB_LANDSCAPE 24
+#define RB_PORTRAIT 25
diff --git a/sw/source/ui/uiview/pview.src b/sw/source/ui/uiview/pview.src
new file mode 100644
index 000000000000..53f672dbdb60
--- /dev/null
+++ b/sw/source/ui/uiview/pview.src
@@ -0,0 +1,490 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+#include "pview.hrc"
+#include "helpid.h"
+#include "cmdid.h"
+ModalDialog DLG_PAGEPREVIEW_PRINTOPTIONS
+{
+ HelpID = HID_DLG_PRV_PRT_OPTIONS ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Size = MAP_APPFONT ( 312 , 131 ) ;
+ FixedLine FL_ROWCOL
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+
+ Text [ en-US ] = "Distribution";
+ };
+ FixedText FT_ROWS
+ {
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "Ro~ws";
+ };
+ NumericField NF_ROWS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 45 , 14 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = PVIEW_MIN_ROW ;
+ Maximum = PVIEW_MAX_ROW ;
+ Value = 1 ;
+ First = PVIEW_MIN_COL ;
+ Last = PVIEW_MAX_COL ;
+ };
+ FixedText FT_COLS
+ {
+ Pos = MAP_APPFONT ( 84 , 15 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Columns";
+ };
+ NumericField NF_COLS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 117 , 14 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = PVIEW_MIN_COL ;
+ Maximum = PVIEW_MAX_COL ;
+ Value = 1 ;
+ First = PVIEW_MIN_COL ;
+ Last = PVIEW_MAX_COL ;
+ };
+ FixedLine FL_MARGINS
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+
+ Text [ en-US ] = "Margins";
+ };
+ FixedText FT_LMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 44 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "L~eft";
+ };
+ MetricField MF_LMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 45 , 43 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedText FT_RMARGIN
+ {
+ Pos = MAP_APPFONT ( 84 , 44 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Right";
+ };
+ MetricField MF_RMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 117 , 43 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedText FT_TMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 59 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Top";
+ };
+ MetricField MF_TMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 45 , 58 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedText FT_BMARGIN
+ {
+ Pos = MAP_APPFONT ( 84 , 59 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Bottom";
+ };
+ MetricField MF_BMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 117 , 58 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedLine FL_DISTANCE
+ {
+ Pos = MAP_APPFONT ( 6 , 76 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+
+ Text [ en-US ] = "Spacing";
+ };
+ FixedText FT_HMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 88 ) ;
+ Size = MAP_APPFONT ( 30 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "Hori~zontal";
+ };
+
+ MetricField MF_HMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 45 , 87 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedText FT_VMARGIN
+ {
+ Pos = MAP_APPFONT ( 84 , 88 ) ;
+ Size = MAP_APPFONT ( 32 , 10 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "~Vertically";
+ };
+
+ MetricField MF_VMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 117 , 87 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 1 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ First = 0 ;
+ Last = 2000 ;
+ };
+ FixedLine FL_ORIENTATION
+ {
+ Pos = MAP_APPFONT ( 6 , 102 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+ Text [ en-US ] = "Format";
+ };
+ RadioButton RB_LANDSCAPE
+ {
+ Pos = MAP_APPFONT ( 12 , 113 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ Text [ en-US ] = "~Landscape";
+ };
+ RadioButton RB_PORTRAIT
+ {
+ Pos = MAP_APPFONT ( 84 , 113 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ Text [ en-US ] = "P~ortrait";
+ };
+ Window WIN_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 162 , 7 ) ;
+ Size = MAP_APPFONT ( 90 , 113 ) ;
+ };
+
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 258 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 258 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 258 , 49 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_STANDARD
+ {
+ Pos = MAP_APPFONT ( 258 , 66 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Default";
+ };
+ Text [ en-US ] = "Print Options";
+};
+ModalDialog DLG_PAGEPREVIEW_ZOOM
+{
+ HelpID = HID_PPREV_ZOOM ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 141 , 69 ) ;
+ Text [ en-US ] = "Multiple Pages" ;
+ Moveable = TRUE ;
+ FixedText FT_COL
+ {
+ Pos = MAP_APPFONT ( 12 , 34 ) ;
+ Size = MAP_APPFONT ( 27 , 10 ) ;
+ Text [ en-US ] = "~Columns" ;
+ Left = TRUE ;
+ };
+ FixedText FT_ROW
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 27 , 10 ) ;
+ Text [ en-US ] = "~Rows" ;
+ Left = TRUE ;
+ };
+ NumericField ED_COL
+ {
+ Border = TRUE ;
+ Size = MAP_APPFONT ( 28 , 12 ) ;
+ Pos = MAP_APPFONT ( 48 , 34 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = PVIEW_MIN_COL ;
+ Maximum = PVIEW_MAX_COL ;
+ Value = 1 ;
+ First = PVIEW_MIN_COL ;
+ Last = PVIEW_MAX_COL ;
+ };
+ NumericField ED_ROW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 48 , 13 ) ;
+ Size = MAP_APPFONT ( 28 , 12 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = PVIEW_MIN_ROW ;
+ Maximum = PVIEW_MAX_ROW ;
+ Value = 1 ;
+ First = PVIEW_MIN_ROW ;
+ Last = PVIEW_MAX_ROW ;
+ };
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 88 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 88 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 88 , 49 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+String RID_PVIEW_TOOLBOX
+{
+ Text [ en-US ] = "Page Preview" ;
+};
+ToolBox RID_PVIEW_TOOLBOX
+{
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ LineSpacing = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ Customize = TRUE ;
+ HelpID = HID_PVIEW_TOOLBOX ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FN_PAGEUP ;
+ HelpID = FN_PAGEUP ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_PAGEDOWN ;
+ HelpID = FN_PAGEDOWN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_START_OF_DOCUMENT ;
+ HelpID = FN_START_OF_DOCUMENT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_END_OF_DOCUMENT ;
+ HelpID = FN_END_OF_DOCUMENT ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = FN_SHOW_TWO_PAGES ;
+ HelpID = FN_SHOW_TWO_PAGES ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SHOW_MULTIPLE_PAGES ;
+ HelpID = FN_SHOW_MULTIPLE_PAGES ;
+ DropDown = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SHOW_BOOKVIEW ;
+ HelpID = FN_SHOW_BOOKVIEW ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ZOOM_OUT;
+ HelpID = SID_ZOOM_OUT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ZOOM_IN;
+ HelpID = SID_ZOOM_IN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_PREVIEW_ZOOM;
+ HelpID = HID_PREVIEW_ZOOM ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_WIN_FULLSCREEN ;
+ HelpID = SID_WIN_FULLSCREEN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_PRINT_PAGEPREVIEW ;
+ HelpID = FN_PRINT_PAGEPREVIEW ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = FN_CLOSE_PAGEPREVIEW;
+ HelpID = SID_PRINTPREVIEW;
+ };
+ };
+ Scroll = TRUE ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sw/source/ui/uiview/scroll.cxx b/sw/source/ui/uiview/scroll.cxx
new file mode 100644
index 000000000000..c8ecc2d92607
--- /dev/null
+++ b/sw/source/ui/uiview/scroll.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "swtypes.hxx"
+#include "swrect.hxx"
+#include "scroll.hxx"
+
+#define SCROLL_LINE_SIZE 250
+
+
+SwScrollbar::SwScrollbar( Window *pWin, BOOL bHoriz ) :
+ ScrollBar( pWin,
+ WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
+ bHori( bHoriz ),
+ bAuto( FALSE ),
+ bThumbEnabled( TRUE ),
+ bVisible(FALSE),
+ bSizeSet(FALSE)
+{
+ // SSA: --- RTL --- no mirroring for horizontal scrollbars
+ if( bHoriz )
+ EnableRTL( FALSE );
+}
+
+
+ SwScrollbar::~SwScrollbar() {}
+
+/*------------------------------------------------------------------------
+ Beschreibung: wird nach einer Aenderung der Dokumentgroesse gerufen, um den
+ Range des Scrollbars neu einzustellen.
+------------------------------------------------------------------------*/
+
+void SwScrollbar::DocSzChgd( const Size &rSize )
+{
+ aDocSz = rSize;
+ SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
+ const ULONG nVisSize = GetVisibleSize();
+ SetLineSize( SCROLL_LINE_SIZE );
+// SetLineSize( nVisSize * 10 / 100 );
+ SetPageSize( nVisSize * 77 / 100 );
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung: wird nach einer Veraenderung des sichtbaren Ausschnittes
+ gerufen.
+------------------------------------------------------------------------*/
+
+
+void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
+{
+ long nThumb, nVisible;
+ if( bHori )
+ {
+ nThumb = rRect.Left();
+ nVisible = rRect.GetWidth();
+ }
+ else
+ {
+ nThumb = rRect.Top();
+ nVisible = rRect.GetHeight();
+ }
+
+ SetVisibleSize( nVisible );
+ DocSzChgd(aDocSz);
+ if ( bThumbEnabled )
+ SetThumbPos( nThumb );
+ if(bAuto)
+ AutoShow();
+}
+
+/*-----------------10/21/97 02:48pm-----------------
+
+--------------------------------------------------*/
+void SwScrollbar::ExtendedShow( BOOL bSet )
+{
+ bVisible = bSet;
+ if( (!bSet || !bAuto) && IsUpdateMode() && bSizeSet)
+ ScrollBar::Show(bSet);
+}
+
+/*-----------------10/21/97 03:23pm-----------------
+
+--------------------------------------------------*/
+void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
+{
+ ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
+ bSizeSet = TRUE;
+ if(bVisible)
+ ExtendedShow();
+
+}
+
+
+/*-----------------14.04.98 11:38-------------------
+
+--------------------------------------------------*/
+void SwScrollbar::SetAuto(BOOL bSet)
+{
+ if(bAuto != bSet)
+ {
+ bAuto = bSet;
+
+ // automatisch versteckt - dann anzeigen
+ if(!bAuto && bVisible && !ScrollBar::IsVisible())
+ ExtendedShow(TRUE);
+ else if(bAuto)
+ AutoShow(); // oder automatisch verstecken
+ }
+}
+/*-----------------14.04.98 11:43-------------------
+
+--------------------------------------------------*/
+void SwScrollbar::AutoShow()
+{
+ long nVis = GetVisibleSize();
+ long nLen = GetRange().Len();
+ {
+ if( nVis >= nLen - 1)
+ {
+ if(ScrollBar::IsVisible())
+ ScrollBar::Show(FALSE);
+ }
+ else if ( !ScrollBar::IsVisible() &&
+ (!bHori || nVis) ) //Optimierung fuer Browser.
+ //Horizontaler Scrollbar per
+ //default aus.
+ {
+ ScrollBar::Show(TRUE);
+ }
+ }
+}
diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx
new file mode 100644
index 000000000000..801ecba22c73
--- /dev/null
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -0,0 +1,960 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <hintids.hxx>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <unotools/tempfile.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/print.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/metric.hxx>
+#include <svtools/ctrltool.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/undo.hxx>
+#include <svtools/txtcmp.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/saveopt.hxx>
+#include <svtools/transfer.hxx>
+#include <svx/svxids.hrc>
+#include <svtools/htmlcfg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/prnmon.hxx>
+#include <sfx2/docfile.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/srchdlg.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/flstitem.hxx>
+#include "editeng/unolingu.hxx"
+#include <sfx2/sfxhtml.hxx>
+#include <swtypes.hxx>
+#include <swmodule.hxx>
+#include <docsh.hxx>
+#include <wdocsh.hxx>
+#include <srcview.hxx>
+#include <viewfunc.hxx>
+#include <doc.hxx>
+#include <sfx2/msg.hxx>
+#include <shellio.hxx>
+
+#include <cmdid.h> // FN_ ...
+#include <helpid.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <popup.hrc>
+#include <web.hrc>
+#include <view.hrc>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <sfx2/filedlghelper.hxx>
+#define SwSrcView
+#define SearchSettings
+#define _ExecSearch Execute
+#define _StateSearch GetState
+#include <svx/svxslots.hxx>
+#include "swslots.hxx"
+
+#include <unomid.h>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::sfx2;
+using ::rtl::OUString;
+using ::com::sun::star::util::SearchOptions;
+
+
+#define SWSRCVIEWFLAGS ( SFX_VIEW_CAN_PRINT|\
+ SFX_VIEW_NO_NEWWINDOW )
+
+#define SRC_SEARCHOPTIONS (0xFFFF & ~(SEARCH_OPTIONS_FORMAT|SEARCH_OPTIONS_FAMILIES|SEARCH_OPTIONS_SEARCH_ALL))
+
+// Druckraender -> wie Basic - Ide
+#define LMARGPRN 1700
+#define RMARGPRN 900
+#define TMARGPRN 2000
+#define BMARGPRN 1000
+#define BORDERPRN 300
+
+
+
+SFX_IMPL_VIEWFACTORY(SwSrcView, SW_RES(STR_NONAME))
+{
+ SFX_VIEW_REGISTRATION(SwWebDocShell);
+}
+
+
+SFX_IMPL_INTERFACE( SwSrcView, SfxViewShell, SW_RES(0) )
+{
+ SFX_POPUPMENU_REGISTRATION(SW_RES(MN_SRCVIEW_POPUPMENU));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
+ SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SW_RES(RID_WEBTOOLS_TOOLBOX) );
+ SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
+}
+
+TYPEINIT1(SwSrcView, SfxViewShell)
+
+/*-----------------18.11.96 08.05-------------------
+
+--------------------------------------------------*/
+
+
+void lcl_PrintHeader( OutputDevice &rOutDev, USHORT nPages, USHORT nCurPage, const String& rTitle )
+{
+ short nLeftMargin = LMARGPRN;
+ Size aSz = rOutDev.GetOutputSize();
+ short nBorder = BORDERPRN;
+
+ Color aOldFillColor( rOutDev.GetFillColor() );
+ Font aOldFont( rOutDev.GetFont() );
+
+ rOutDev.SetFillColor( Color(COL_TRANSPARENT) );
+
+ Font aFont( aOldFont );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ rOutDev.SetFont( aFont );
+
+ long nFontHeight = rOutDev.GetTextHeight();
+
+ // 1.Border => Strich, 2+3 Border = Freiraum.
+ long nYTop = TMARGPRN-3*nBorder-nFontHeight;
+
+ long nXLeft = nLeftMargin-nBorder;
+ long nXRight = aSz.Width()-RMARGPRN+nBorder;
+
+ rOutDev.DrawRect( Rectangle(
+ Point( nXLeft, nYTop ),
+ Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
+
+
+ long nY = TMARGPRN-2*nBorder;
+ Point aPos( nLeftMargin, nY );
+ rOutDev.DrawText( aPos, rTitle );
+ if ( nPages != 1 )
+ {
+ aFont.SetWeight( WEIGHT_NORMAL );
+ rOutDev.SetFont( aFont );
+ String aPageStr( C2S(" [") );
+ aPageStr += String( SW_RES( STR_PAGE ) );
+ aPageStr += ' ';
+ aPageStr += String::CreateFromInt32( nCurPage );
+ aPageStr += ']';
+ aPos.X() += rOutDev.GetTextWidth( rTitle );
+ rOutDev.DrawText( aPos, aPageStr );
+ }
+
+
+ nY = TMARGPRN-nBorder;
+
+ rOutDev.DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
+
+ rOutDev.SetFont( aOldFont );
+ rOutDev.SetFillColor( aOldFillColor );
+}
+/* -----------------13.11.2003 16:24-----------------
+
+ --------------------------------------------------*/
+rtl_TextEncoding lcl_GetStreamCharSet(rtl_TextEncoding eLoadEncoding)
+{
+ rtl_TextEncoding eRet = eLoadEncoding;
+ if(RTL_TEXTENCODING_DONTKNOW == eRet)
+ {
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ const sal_Char *pCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( pHtmlOptions->GetTextEncoding() );
+ eRet = rtl_getTextEncodingFromMimeCharset( pCharSet );
+ }
+ return eRet;
+}
+/*-----------------18.11.96 08.21-------------------
+
+--------------------------------------------------*/
+
+void lcl_ConvertTabsToSpaces( String& rLine )
+{
+ if ( rLine.Len() )
+ {
+ USHORT nPos = 0;
+ USHORT nMax = rLine.Len();
+ while ( nPos < nMax )
+ {
+ if ( rLine.GetChar(nPos) == '\t' )
+ {
+ // Nicht 4 Blanks, sondern an 4er TabPos:
+ String aBlanker;
+ aBlanker.Fill( ( 4 - ( nPos % 4 ) ), ' ' );
+ rLine.Erase( nPos, 1 );
+ rLine.Insert( aBlanker, nPos );
+ nMax = rLine.Len();
+ }
+ nPos++; // Nicht optimal, falls Tab, aber auch nicht verkehrt...
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, SfxViewShell*) :
+ SfxViewShell( pViewFrame, SWSRCVIEWFLAGS ),
+ aEditWin( &pViewFrame->GetWindow(), this ),
+ pSearchItem(0),
+ bSourceSaved(FALSE),
+ eLoadEncoding(RTL_TEXTENCODING_DONTKNOW)
+{
+ Init();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwSrcView::~SwSrcView()
+{
+ SwDocShell* pDocShell = GetDocShell();
+ DBG_ASSERT(PTR_CAST(SwWebDocShell, pDocShell), "Wieso keine WebDocShell?");
+ const TextSelection& rSel = aEditWin.GetTextView()->GetSelection();
+ ((SwWebDocShell*)pDocShell)->SetSourcePara( static_cast< USHORT >( rSel.GetStart().GetPara() ) );
+
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ ::rtl::OUString url = xDocProps->getAutoloadURL();
+ sal_Int32 delay = xDocProps->getAutoloadSecs();
+ pDocShell->SetAutoLoad(INetURLObject(url), delay,
+ (delay != 0) || !url.equalsAscii(""));
+// EndListening(*GetViewFrame());
+ EndListening(*pDocShell);
+ delete pSearchItem;
+}
+
+/*-----------------24.04.97 10:37-------------------
+
+--------------------------------------------------*/
+void SwSrcView::SaveContentTo(SfxMedium& rMed)
+{
+ SvStream* pOutStream = rMed.GetOutStream();
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );//, EE_FORMAT_TEXT);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::Init()
+{
+ SetHelpId(SW_SRC_VIEWSHELL);
+ SetName(C2S("Source"));
+ SetWindow( &aEditWin );
+ SwDocShell* pDocShell = GetDocShell();
+ // wird das Doc noch geladen, dann muss die DocShell das Load
+ // anwerfen, wenn das Laden abgeschlossen ist
+ if(!pDocShell->IsLoading())
+ Load(pDocShell);
+ else
+ {
+ aEditWin.SetReadonly(TRUE);
+ }
+
+// StartListening(*GetViewFrame());
+ StartListening(*pDocShell,TRUE);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SwDocShell* SwSrcView::GetDocShell()
+{
+ SfxObjectShell* pObjShell = GetViewFrame()->GetObjectShell();
+ return PTR_CAST(SwDocShell, pObjShell);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::SaveContent(const String& rTmpFile)
+{
+ SfxMedium aMedium( rTmpFile, STREAM_WRITE, TRUE);
+ SvStream* pOutStream = aMedium.GetOutStream();
+ pOutStream->SetStreamCharSet( lcl_GetStreamCharSet(eLoadEncoding) );
+ aEditWin.Write(*pOutStream);//, EE_FORMAT_TEXT);
+ aMedium.Commit();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::Execute(SfxRequest& rReq)
+{
+ USHORT nSlot = rReq.GetSlot();
+ TextView* pTextView = aEditWin.GetTextView();
+ switch( nSlot )
+ {
+ case SID_SAVEASDOC:
+ {
+ SvtPathOptions aPathOpt;
+ // filesave dialog with autoextension
+ FileDialogHelper aDlgHelper(
+ TemplateDescription::FILESAVE_AUTOEXTENSION,
+ TemplateDescription::FILESAVE_SIMPLE );
+ uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
+// pFileDlg->SetHelpId(HID_FILEDLG_SRCVIEW);
+ uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
+
+ // search for an html filter for export
+ SfxFilterContainer* pFilterCont = GetObjectShell()->GetFactory().GetFilterContainer();
+ const SfxFilter* pFilter =
+ pFilterCont->GetFilter4Extension( C2S("html"), SFX_FILTER_EXPORT );
+ if ( pFilter )
+ {
+ // filter found -> use its uiname and wildcard
+ const String& rUIName = pFilter->GetUIName();
+ const WildCard& rCard = pFilter->GetWildcard();
+ xFltMgr->appendFilter( rUIName, rCard() );
+ xFltMgr->setCurrentFilter( rUIName ) ;
+ }
+ else
+ {
+ // filter not found
+ String sHtml(C2S("HTML"));
+ xFltMgr->appendFilter( sHtml, C2S("*.html;*.htm") );
+ xFltMgr->setCurrentFilter( sHtml ) ;
+ }
+
+ xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
+ if( aDlgHelper.Execute() == ERRCODE_NONE)
+ {
+ SfxMedium aMedium( xFP->getFiles().getConstArray()[0],
+ STREAM_WRITE | STREAM_SHARE_DENYNONE,
+ FALSE );
+ SvStream* pOutStream = aMedium.GetOutStream();
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );
+ aMedium.Commit();
+ }
+ }
+ break;
+ case SID_SAVEDOC:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ SfxMedium* pMed = 0;
+ if(pDocShell->HasName())
+ pMed = pDocShell->GetMedium();
+ else
+ {
+ SfxBoolItem* pItem = (SfxBoolItem*)pDocShell->ExecuteSlot(rReq, pDocShell->GetInterface());
+ if(pItem && pItem->GetValue())
+ pMed = pDocShell->GetMedium();
+ }
+ if(pMed)
+ {
+ SvStream* pOutStream = pMed->GetOutStream();
+ pOutStream->Seek(0);
+ pOutStream->SetStreamSize(0);
+ pOutStream->SetStreamCharSet(lcl_GetStreamCharSet(eLoadEncoding));
+ aEditWin.Write( *pOutStream );
+ pMed->CloseOutStream();
+ pMed->Commit();
+ pDocShell->GetDoc()->ResetModified();
+ SourceSaved();
+ aEditWin.ClearModifyFlag();
+ }
+ }
+ break;
+ case FID_SEARCH_NOW:
+ {
+ const SfxItemSet* pTmpArgs = rReq.GetArgs();
+
+ USHORT nWhich = pTmpArgs->GetWhichByPos( 0 );
+ DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
+ const SfxPoolItem& rItem = pTmpArgs->Get( nWhich );
+ SetSearchItem( (const SvxSearchItem&)rItem);
+ StartSearchAndReplace( (const SvxSearchItem&)rItem, FALSE, rReq.IsAPI() );
+ if(aEditWin.IsModified())
+ GetDocShell()->GetDoc()->SetModified();
+ }
+ break;
+ case FN_REPEAT_SEARCH:
+ {
+ SvxSearchItem* pSrchItem = GetSearchItem();
+ if(pSrchItem)
+ {
+ StartSearchAndReplace( *pSrchItem, FALSE, rReq.IsAPI() );
+ if(aEditWin.IsModified())
+ GetDocShell()->GetDoc()->SetModified();
+ }
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ {
+ SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
+ }
+ break;
+ case SID_UNDO:
+ pTextView->Undo();
+ GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ break;
+ case SID_REDO:
+ pTextView->Redo();
+ GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ break;
+ case SID_REPEAT:
+ break;
+ case SID_CUT:
+ if(pTextView->HasSelection())
+ pTextView->Cut();
+ break;
+ case SID_COPY:
+ if(pTextView->HasSelection())
+ pTextView->Copy();
+ break;
+ case SID_PASTE:
+ pTextView->Paste();
+ break;
+ case SID_SELECTALL:
+ pTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
+ break;
+ }
+ aEditWin.Invalidate();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::GetState(SfxItemSet& rSet)
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ TextView* pTextView = aEditWin.GetTextView();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_SAVEASDOC:
+ rSet.Put(SfxStringItem(nWhich, String(SW_RES(STR_SAVEAS_SRC))));
+ break;
+ case SID_SAVEDOC:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ if(!pDocShell->IsModified())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ break;
+ case SID_TABLE_CELL:
+ {
+ String aPos( SW_RES(STR_SRCVIEW_ROW) );
+ TextSelection aSel = pTextView->GetSelection();
+ aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 );
+ aPos +=C2S(" : ");
+ aPos += String(SW_RES(STR_SRCVIEW_COL));
+ aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 );
+ SfxStringItem aItem( nWhich, aPos );
+ rSet.Put( aItem );
+ }
+ break;
+ case SID_SEARCH_OPTIONS:
+ {
+ USHORT nOpt = SRC_SEARCHOPTIONS;
+ if(GetDocShell()->IsReadOnly())
+ nOpt &= ~(SEARCH_OPTIONS_REPLACE|SEARCH_OPTIONS_REPLACE_ALL);
+
+ rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOpt) );
+ }
+ break;
+ case SID_SEARCH_ITEM:
+ {
+ String sSelected;
+ if ( !pTextView->HasSelection() )
+ {
+ const TextSelection& rSel = pTextView->GetSelection();
+ sSelected = aEditWin.GetTextEngine()->GetWord( rSel.GetStart());
+ }
+ else
+ {
+ sSelected = pTextView->GetSelected();
+ }
+ SvxSearchItem * pSrchItem = GetSearchItem();
+ pSrchItem->SetSearchString( sSelected );
+ rSet.Put( *pSrchItem );
+ }
+ break;
+ case FN_REPEAT_SEARCH:
+ {
+ if(!GetSearchItem())
+ rSet.DisableItem(nWhich);
+ };
+ break;
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ SfxUndoManager& rMgr = pTextView->GetTextEngine()->GetUndoManager();
+ USHORT nCount = 0;
+ if(nWhich == SID_UNDO)
+ {
+ nCount = rMgr.GetUndoActionCount();
+ if(nCount)
+ {
+ String aStr(ResId( STR_UNDO, *SFX_APP()->GetSfxResManager() ));;
+ aStr += rMgr.GetUndoActionComment(--nCount);
+ rSet.Put(SfxStringItem(nWhich, aStr));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ nCount = rMgr.GetRedoActionCount();
+ if(nCount)
+ {
+ String aStr(ResId( STR_REDO, *SFX_APP()->GetSfxResManager() ));;
+ aStr += rMgr.GetRedoActionComment(--nCount);
+ rSet.Put(SfxStringItem(nWhich,aStr));
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_MAIL_SENDDOCASPDF:
+ case SID_MAIL_SENDDOC :
+ case SID_EXPORTDOCASPDF:
+ case SID_DIRECTEXPORTDOCASPDF:
+ case SID_EXPORTDOC:
+ case SID_REPEAT:
+ case SID_BROWSER_MODE:
+ case FN_PRINT_LAYOUT:
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_CUT:
+ case SID_COPY:
+ if(!pTextView->HasSelection())
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PASTE:
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &aEditWin) );
+ BOOL bDisable = !aDataHelper.GetXTransferable().is() ||
+ 0 == aDataHelper.GetFormatCount();
+ if( bDisable )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SvxSearchItem* SwSrcView::GetSearchItem()
+{
+ if(!pSearchItem)
+ {
+ pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
+ }
+ return pSearchItem;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::SetSearchItem( const SvxSearchItem& rItem )
+{
+ delete pSearchItem;
+ pSearchItem = (SvxSearchItem*)rItem.Clone();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
+ BOOL bFromStart,
+ BOOL bApi,
+ BOOL bRecursive)
+{
+ ExtTextView* pTextView = aEditWin.GetTextView();
+ TextSelection aSel;
+ TextPaM aPaM;
+
+ BOOL bForward = !rSearchItem.GetBackward();
+ BOOL bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM );
+
+ if( !bForward )
+ aPaM = TextPaM( (ULONG)-1, (USHORT)-1 );
+
+ if( bFromStart )
+ {
+ aSel = pTextView->GetSelection();
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ));
+ }
+
+ util::SearchOptions aSearchOpt( rSearchItem.GetSearchOptions() );
+ aSearchOpt.Locale = SvxCreateLocale(
+ static_cast< LanguageType >( GetAppLanguage() ) );
+
+ USHORT nFound;
+ BOOL bAll = FALSE;
+ switch( rSearchItem.GetCommand() )
+ {
+ case SVX_SEARCHCMD_FIND:
+ case SVX_SEARCHCMD_FIND_ALL:
+ nFound = pTextView->Search( aSearchOpt, bForward );
+ break;
+
+ case SVX_SEARCHCMD_REPLACE_ALL: bAll = TRUE;
+ case SVX_SEARCHCMD_REPLACE:
+ nFound = pTextView->Replace( aSearchOpt, bAll, bForward );
+ break;
+
+ default:
+ nFound = 0;
+ }
+
+ if( !nFound )
+ {
+ BOOL bNotFoundMessage = FALSE;
+ if(!bRecursive)
+ {
+ if(!bFromStart)
+ {
+ bNotFoundMessage = bAtStart;
+ }
+ else
+ {
+ bNotFoundMessage = TRUE;
+ pTextView->SetSelection( aSel );
+ }
+ }
+ else if(bAtStart)
+ {
+ bNotFoundMessage = TRUE;
+ }
+
+
+ if(!bApi)
+ {
+ if(bNotFoundMessage)
+ {
+ InfoBox( 0, SW_RES(MSG_NOT_FOUND)).Execute();
+ }
+ else if(!bRecursive && RET_YES ==
+ QueryBox(0, SW_RES( bForward ? MSG_SEARCH_END
+ : MSG_SEARCH_START)).Execute())
+ {
+ pTextView->SetSelection( TextSelection( aPaM, aPaM ) );
+ StartSearchAndReplace( rSearchItem, FALSE, FALSE, TRUE );
+ }
+ }
+ }
+ return nFound;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool )
+{
+ SwDocShell* pDocSh = GetDocShell();
+ if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags )
+ {
+ pDocSh->GetDoc()->setPrinter( pNew, true, true );
+ if ( nDiffFlags & SFX_PRINTER_PRINTER )
+ pDocSh->SetModified();
+ }
+ if ( nDiffFlags & SFX_PRINTER_OPTIONS )
+ ::SetPrinter( pDocSh->getIDocumentDeviceAccess(), pNew, TRUE );
+
+ const BOOL bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? TRUE : FALSE;
+ const BOOL bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? TRUE : FALSE;
+ if ( bChgOri || bChgSize )
+ {
+ pDocSh->SetModified();
+ }
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate )
+{
+ return GetDocShell()->GetDoc()->getPrinter( bCreate );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+sal_Int32 SwSrcView::PrintSource(
+ OutputDevice *pOutDev,
+ sal_Int32 nPage,
+ bool bCalcNumPagesOnly )
+{
+ if (!pOutDev || nPage <= 0)
+ return 0;
+
+ //! this a lgorithm for printing the n-th page is very poor since it
+ //! needs to go over the text of all previous pages to get to the correct one.
+ //! But since HTML source code is expected to be just a small number of pages
+ //! even this poor algorithm should be enough...
+
+ pOutDev->Push();
+
+ TextEngine* pTextEngine = aEditWin.GetTextEngine();
+ pOutDev->SetMapMode( MAP_100TH_MM );
+ Font aFont( aEditWin.GetOutWin()->GetFont() );
+ Size aSize( aFont.GetSize() );
+ aSize = aEditWin.GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM );
+ aFont.SetSize( aSize );
+ aFont.SetColor( COL_BLACK );
+ pOutDev->SetFont( aFont );
+
+ String aTitle( GetViewFrame()->GetWindow().GetText() );
+
+ USHORT nLineHeight = (USHORT) pOutDev->GetTextHeight(); // etwas mehr.
+ USHORT nParaSpace = 10;
+
+ Size aPaperSz = pOutDev->GetOutputSize();
+ aPaperSz.Width() -= (LMARGPRN + RMARGPRN);
+ aPaperSz.Height() -= (TMARGPRN + BMARGPRN);
+
+ // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
+ USHORT nLinespPage = (USHORT) (aPaperSz.Height() / nLineHeight);
+ USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pOutDev->GetTextWidth( 'X' ));
+ USHORT nParas = static_cast< USHORT >( pTextEngine->GetParagraphCount() );
+
+ USHORT nPages = (USHORT) (nParas / nLinespPage + 1 );
+ USHORT nCurPage = 1;
+
+ // Header drucken...
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle );
+ const Point aStartPos( LMARGPRN, TMARGPRN );
+ Point aPos( aStartPos );
+ for ( USHORT nPara = 0; nPara < nParas; ++nPara )
+ {
+ String aLine( pTextEngine->GetText( nPara ) );
+ lcl_ConvertTabsToSpaces( aLine );
+ USHORT nLines = aLine.Len() / nCharspLine + 1;
+ for ( USHORT nLine = 0; nLine < nLines; ++nLine )
+ {
+ String aTmpLine( aLine, nLine * nCharspLine, nCharspLine );
+ aPos.Y() += nLineHeight;
+ if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN - nLineHeight/2 ) )
+ {
+ ++nCurPage;
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle );
+ aPos = aStartPos;
+ }
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ pOutDev->DrawText( aPos, aTmpLine );
+ }
+ aPos.Y() += nParaSpace;
+ }
+
+ pOutDev->Pop();
+
+ DBG_ASSERT( bCalcNumPagesOnly || nPage <= nCurPage, "page number out of range" );
+ return nCurPage;
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA(SfxSimpleHint) &&
+ (
+ ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_MODECHANGED ||
+ (
+ ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_TITLECHANGED &&
+ !GetDocShell()->IsReadOnly() && aEditWin.IsReadonly()
+ )
+ )
+ )
+ {
+ // Broadcast kommt nur einmal!
+ const SwDocShell* pDocSh = GetDocShell();
+ const BOOL bReadonly = pDocSh->IsReadOnly();
+ aEditWin.SetReadonly(bReadonly);
+ }
+ SfxViewShell::Notify(rBC, rHint);
+}
+
+/*-----------------19.04.97 10:19-------------------
+
+--------------------------------------------------*/
+void SwSrcView::Load(SwDocShell* pDocShell)
+{
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ const sal_Char *pCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( pHtmlOptions->GetTextEncoding() );
+ rtl_TextEncoding eDestEnc = rtl_getTextEncodingFromMimeCharset( pCharSet );
+
+ aEditWin.SetReadonly(pDocShell->IsReadOnly());
+ aEditWin.SetTextEncoding(eDestEnc);
+ SfxMedium* pMedium = pDocShell->GetMedium();
+
+ const SfxFilter* pFilter = pMedium->GetFilter();
+ BOOL bHtml = pFilter && pFilter->GetUserData().EqualsAscii("HTML");
+ BOOL bDocModified = pDocShell->IsModified();
+ if(bHtml && !bDocModified && pDocShell->HasName())
+ {
+ SvStream* pStream = pMedium->GetInStream();
+ if(pStream && 0 == pStream->GetError() )
+ {
+ rtl_TextEncoding eHeaderEnc =
+ SfxHTMLParser::GetEncodingByHttpHeader(
+ pDocShell->GetHeaderAttributes() );
+ if( RTL_TEXTENCODING_DONTKNOW == eHeaderEnc )
+ {
+ const sal_Char *pTmpCharSet =
+ rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 );
+ eHeaderEnc = rtl_getTextEncodingFromMimeCharset( pTmpCharSet );
+ }
+ if( RTL_TEXTENCODING_DONTKNOW != eHeaderEnc &&
+ eDestEnc != eHeaderEnc )
+ {
+ eDestEnc = eHeaderEnc;
+ aEditWin.SetTextEncoding(eDestEnc);
+ }
+ pStream->SetStreamCharSet( eDestEnc );
+ pStream->Seek(0);
+ TextEngine* pTextEngine = aEditWin.GetTextEngine();
+ pTextEngine->EnableUndo(FALSE);
+ aEditWin.Read(*pStream);//, EE_FORMAT_TEXT);
+ pTextEngine->EnableUndo(TRUE);
+ }
+ else
+ {
+ Window *pTmpWindow = &GetViewFrame()->GetWindow();
+ InfoBox(pTmpWindow, SW_RES(MSG_ERR_SRCSTREAM)).Execute();
+ }
+ }
+ else
+ {
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ String sFileURL( aTempFile.GetURL() );
+ SvtSaveOptions aOpt;
+
+ {
+ SfxMedium aMedium( sFileURL,STREAM_READWRITE, TRUE );
+ SwWriter aWriter( aMedium, *pDocShell->GetDoc() );
+ WriterRef xWriter;
+ ::GetHTMLWriter(aEmptyStr, aMedium.GetBaseURL( true ), xWriter);
+ String sWriteName = pDocShell->HasName() ?
+ pMedium->GetName() :
+ (const String&) sFileURL;
+ ULONG nRes = aWriter.Write(xWriter, &sWriteName);
+ if(nRes)
+ {
+ ErrorHandler::HandleError(ErrCode(nRes));
+ aEditWin.SetReadonly(TRUE);
+ }
+ aMedium.Commit();
+ SvStream* pInStream = aMedium.GetInStream();
+ pInStream->Seek(0);
+ pInStream->SetStreamCharSet( eDestEnc );
+
+
+ aEditWin.Read(*pInStream);//, EE_FORMAT_TEXT);
+ }
+ }
+ aEditWin.ClearModifyFlag();
+
+ eLoadEncoding = eDestEnc;
+
+ if(bDocModified)
+ pDocShell->SetModified();// das Flag wird zwischendurch zurueckgesetzt
+ // AutoLoad abschalten
+ pDocShell->SetAutoLoad(INetURLObject(), 0, FALSE);
+ DBG_ASSERT(PTR_CAST(SwWebDocShell, pDocShell), "Wieso keine WebDocShell?");
+ USHORT nLine = ((SwWebDocShell*)pDocShell)->GetSourcePara();
+ aEditWin.SetStartLine(nLine);
+ aEditWin.GetTextEngine()->ResetUndo();
+ aEditWin.GetOutWin()->GrabFocus();
+}
+
+
diff --git a/sw/source/ui/uiview/swcli.cxx b/sw/source/ui/uiview/swcli.cxx
new file mode 100644
index 000000000000..6da603c893b3
--- /dev/null
+++ b/sw/source/ui/uiview/swcli.cxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+
+
+#include <wrtsh.hxx>
+#include <swtypes.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <edtwin.hxx>
+#include <swcli.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+
+using namespace com::sun::star;
+
+SwOleClient::SwOleClient( SwView *pView, SwEditWin *pWin, const svt::EmbeddedObjectRef& xObj ) :
+ SfxInPlaceClient( pView, pWin, xObj.GetViewAspect() ), bInDoVerb( FALSE ),
+ bOldCheckForOLEInCaption( pView->GetWrtShell().IsCheckForOLEInCaption() )
+{
+ SetObject( xObj.GetObject() );
+}
+
+void SwOleClient::RequestNewObjectArea( Rectangle& aLogRect )
+{
+ //Der Server moechte die Clientgrosse verandern.
+ //Wir stecken die Wunschgroesse in die Core. Die Attribute des Rahmens
+ //werden auf den Wunschwert eingestellt. Dieser Wert wird also auch an
+ //den InPlaceClient weitergegeben.
+ //Die Core aktzeptiert bzw. formatiert die eingestellten Werte nicht
+ //zwangslaeufig. Wenn der Ole-Frm formatiert wurde wird das CalcAndSetScale()
+ //der WrtShell gerufen. Dort wird ggf. die Scalierung des SwOleClient
+ //eingestellt.
+
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+
+ rSh.StartAllAction();
+
+ // the aLogRect will get the preliminary size now
+ aLogRect.SetSize( rSh.RequestObjectResize( SwRect( aLogRect ), GetObject() ) );
+
+ // the EndAllAction() call will trigger CalcAndSetScale() call,
+ // so the embedded object must get the correct size before
+ if ( aLogRect.GetSize() != GetScaledObjArea().GetSize() )
+ {
+ // size has changed, so first change visual area of the object before we resize its view
+ // without this the object always would be scaled - now it has the choice
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ MapMode aObjectMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
+ MapMode aClientMap( GetEditWin()->GetMapMode().GetMapUnit() );
+
+ Size aNewObjSize( Fraction( aLogRect.GetWidth() ) / GetScaleWidth(),
+ Fraction( aLogRect.GetHeight() ) / GetScaleHeight() );
+
+ // convert to logical coordinates of the embedded object
+ Size aNewSize = GetEditWin()->LogicToLogic( aNewObjSize, &aClientMap, &aObjectMap );
+ GetObject()->setVisualAreaSize( GetAspect(), awt::Size( aNewSize.Width(), aNewSize.Height() ) );
+ }
+
+ rSh.EndAllAction();
+
+ SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() )),
+ aPrt( rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, GetObject() ));
+ aLogRect.SetPos( aPrt.Pos() + aFrm.Pos() );
+ aLogRect.SetSize( aPrt.SSize() );
+}
+
+void SwOleClient::ObjectAreaChanged()
+{
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+ SwRect aFrm( rSh.GetAnyCurRect( RECT_FLY_EMBEDDED, 0, GetObject() )),
+ aPrt( rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, 0, GetObject() ));
+ if ( !aFrm.IsOver( rSh.VisArea() ) )
+ rSh.MakeVisible( aFrm );
+}
+
+void SwOleClient::ViewChanged()
+{
+ if ( bInDoVerb )
+ return;
+
+ if ( GetAspect() == embed::Aspects::MSOLE_ICON )
+ {
+ // the iconified object seems not to need such a scaling handling
+ // since the replacement image and the size a completely controlled by the container
+ // TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
+ return;
+ }
+
+ SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+
+ //Einstellen der Groesse des Objektes in der Core. Die Scalierung muss
+ //beruecksichtigt werden. Rueckwirkung auf das Objekt werden von
+ //CalcAndSetScale() der WrtShell beruecksichtig, wenn die Groesse/Pos des
+ //Rahmens in der Core sich veraendert.
+
+ // TODO/LEAN: getMapUnit can switch object to running state
+ awt::Size aSz;
+ try
+ {
+ aSz = GetObject()->getVisualAreaSize( GetAspect() );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // Nothing will be done
+ }
+ catch( uno::Exception& )
+ {
+ // this is an error
+ OSL_ENSURE( sal_False, "Something goes wrong on requesting object size!\n" );
+ }
+
+ Size aVisSize( aSz.Width, aSz.Height );
+
+ // Bug 24833: solange keine vernuenftige Size vom Object kommt,
+ // kann nichts skaliert werden
+ if( !aVisSize.Width() || !aVisSize.Height() )
+ return;
+
+ // first convert to TWIPS before scaling, because scaling factors are calculated for
+ // the TWIPS mapping and so they will produce the best results if applied to TWIPS based
+ // coordinates
+ const MapMode aMyMap ( MAP_TWIP );
+ const MapMode aObjMap( VCLUnoHelper::UnoEmbed2VCLMapUnit( GetObject()->getMapUnit( GetAspect() ) ) );
+ aVisSize = OutputDevice::LogicToLogic( aVisSize, aObjMap, aMyMap );
+
+ aVisSize.Width() = Fraction( aVisSize.Width() ) * GetScaleWidth();
+ aVisSize.Height()= Fraction( aVisSize.Height() ) * GetScaleHeight();
+
+ SwRect aRect( Point( LONG_MIN, LONG_MIN ), aVisSize );
+ rSh.LockView( TRUE ); //Scrollen im EndAction verhindern
+ rSh.StartAllAction();
+ rSh.RequestObjectResize( aRect, GetObject() );
+ rSh.EndAllAction();
+ rSh.LockView( FALSE );
+}
+
+void SwOleClient::MakeVisible()
+{
+ const SwWrtShell &rSh = ((SwView*)GetViewShell())->GetWrtShell();
+ rSh.MakeObjVisible( GetObject() );
+}
diff --git a/sw/source/ui/uiview/uivwimp.cxx b/sw/source/ui/uiview/uivwimp.cxx
new file mode 100644
index 000000000000..20dc6035dc36
--- /dev/null
+++ b/sw/source/ui/uiview/uivwimp.cxx
@@ -0,0 +1,345 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <cmdid.h>
+#include "globals.hrc"
+
+#include <tools/shl.hxx>
+#include <com/sun/star/scanner/XScannerManager.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <sfx2/docinsert.hxx>
+#include <sfx2/request.hxx>
+#include <uivwimp.hxx>
+#include <wview.hxx>
+#include <unotxvw.hxx>
+#include <unodispatch.hxx>
+#include <swmodule.hxx>
+#include <swdtflvr.hxx>
+#include <edtwin.hxx>
+#include <mmconfigitem.hxx>
+
+#include <view.hrc>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::scanner;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::datatransfer::clipboard;
+
+/* -----------------02.06.98 15:31-------------------
+ *
+ * --------------------------------------------------*/
+SwView_Impl::SwView_Impl(SwView* pShell) :
+ pxXTextView(new uno::Reference<view::XSelectionSupplier>),
+ pView(pShell),
+ eShellMode(SHELL_MODE_TEXT),
+ pConfigItem(0),
+ nMailMergeRestartPage(0),
+ bMailMergeSourceView(sal_True),
+ m_pDocInserter(NULL),
+ m_pRequest(NULL),
+ m_bSelectObject(false),
+ m_bEditingPositionSet(false)
+{
+ *pxXTextView = new SwXTextView(pView);
+ xDisProvInterceptor = new SwXDispatchProviderInterceptor(*pView);
+}
+
+/*-----------------13.12.97 09:51-------------------
+
+--------------------------------------------------*/
+SwView_Impl::~SwView_Impl()
+{
+ Reference<XUnoTunnel> xDispTunnel(xDisProvInterceptor, UNO_QUERY);
+ SwXDispatchProviderInterceptor* pInterceptor = 0;
+ if(xDispTunnel.is() &&
+ 0 != (pInterceptor = reinterpret_cast< SwXDispatchProviderInterceptor * >(
+ sal::static_int_cast< sal_IntPtr >(
+ xDispTunnel->getSomething(SwXDispatchProviderInterceptor::getUnoTunnelId())))))
+ {
+ pInterceptor->Invalidate();
+ }
+ view::XSelectionSupplier* pTextView = pxXTextView->get();
+ ((SwXTextView*)pTextView)->Invalidate();
+ delete pxXTextView;
+ if( xScanEvtLstnr.is() )
+ pScanEvtLstnr->ViewDestroyed();
+ if( xClipEvtLstnr.is() )
+ {
+ pClipEvtLstnr->AddRemoveListener( FALSE );
+ pClipEvtLstnr->ViewDestroyed();
+ }
+ delete pConfigItem;
+
+ delete m_pDocInserter;
+ delete m_pRequest;
+}
+
+/*-----------------13.12.97 09:54-------------------
+
+--------------------------------------------------*/
+void SwView_Impl::SetShellMode(ShellModes eSet)
+{
+ eShellMode = eSet;
+}
+/*-----------------13.12.97 09:59-------------------
+
+--------------------------------------------------*/
+view::XSelectionSupplier* SwView_Impl::GetUNOObject()
+{
+ return pxXTextView->get();
+}
+/* -----------------02.06.98 15:29-------------------
+ *
+ * --------------------------------------------------*/
+SwXTextView* SwView_Impl::GetUNOObject_Impl()
+{
+ view::XSelectionSupplier* pTextView = pxXTextView->get();
+ return ((SwXTextView*)pTextView);
+}
+/* -----------------------------29.05.00 09:04--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView_Impl::ExecuteScan( SfxRequest& rReq )
+{
+ USHORT nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_TWAIN_SELECT:
+ {
+ BOOL bDone = FALSE;
+ Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
+
+ if( xScanMgr.is() )
+ {
+ try
+ {
+ const Sequence< ScannerContext >
+ aContexts( xScanMgr->getAvailableScanners() );
+
+ if( aContexts.getLength() )
+ {
+ ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
+ bDone = xScanMgr->configureScanner( aContext );
+ }
+ }
+ catch(...)
+ {
+ }
+
+ }
+ if( bDone )
+ rReq.Done();
+ else
+ {
+ rReq.Ignore();
+// KA 04.07.2002
+// InfoBox( 0, SW_RES(MSG_SCAN_NOSOURCE) ).Execute();
+ }
+ }
+ break;
+
+ case SID_TWAIN_TRANSFER:
+ {
+ BOOL bDone = FALSE;
+
+ Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
+ if( xScanMgr.is() )
+ {
+ SwScannerEventListener& rListener = GetScannerEventListener();
+ try
+ {
+ const Sequence< scanner::ScannerContext >aContexts( xScanMgr->getAvailableScanners() );
+ if( aContexts.getLength() )
+ {
+ Reference< XEventListener > xLstner = &rListener;
+ xScanMgr->startScan( aContexts.getConstArray()[ 0 ], xLstner );
+ bDone = TRUE;
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+
+ if( !bDone )
+ {
+ InfoBox( 0, SW_RES(MSG_SCAN_NOSOURCE) ).Execute();
+ rReq.Ignore();
+ }
+ else
+ {
+ rReq.Done();
+ SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TWAIN_SELECT );
+ rBind.Invalidate( SID_TWAIN_TRANSFER );
+ }
+ }
+ break;
+ }
+}
+
+/* -----------------------------29.05.00 08:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwScannerEventListener& SwView_Impl::GetScannerEventListener()
+{
+ if(!xScanEvtLstnr.is())
+ xScanEvtLstnr = pScanEvtLstnr = new SwScannerEventListener(*pView);
+ return *pScanEvtLstnr;
+}
+
+
+void SwView_Impl::AddClipboardListener()
+{
+ if(!xClipEvtLstnr.is())
+ {
+ xClipEvtLstnr = pClipEvtLstnr = new SwClipboardChangeListener( *pView );
+ pClipEvtLstnr->AddRemoveListener( TRUE );
+ }
+}
+/* -----------------3/31/2003 11:42AM----------------
+
+ --------------------------------------------------*/
+void SwView_Impl::Invalidate()
+{
+ GetUNOObject_Impl()->Invalidate();
+ Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY);
+ if(xTunnel.is())
+
+ {
+ SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >(
+ sal::static_int_cast< sal_IntPtr >(
+ xTunnel->getSomething(SwTransferable::getUnoTunnelId())));
+ if(pTransferable)
+ pTransferable->Invalidate();
+ }
+}
+/* -----------------3/31/2003 12:40PM----------------
+
+ --------------------------------------------------*/
+void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
+{
+ //prevent removing of the non-referenced SwTransferable
+ rTransferable.m_refCount++;;
+ {
+ xTransferable = Reference<XUnoTunnel> (&rTransferable);
+ }
+ rTransferable.m_refCount--;
+}
+
+void SwView_Impl::StartDocumentInserter( const String& rFactory, const Link& rEndDialogHdl )
+{
+ delete m_pDocInserter;
+ m_pDocInserter = new ::sfx2::DocumentInserter( 0, rFactory );
+ m_pDocInserter->StartExecuteModal( rEndDialogHdl );
+}
+
+SfxMedium* SwView_Impl::CreateMedium()
+{
+ return m_pDocInserter->CreateMedium();
+}
+
+void SwView_Impl::InitRequest( const SfxRequest& rRequest )
+{
+ delete m_pRequest;
+ m_pRequest = new SfxRequest( rRequest );
+}
+
+// ------------------------- SwScannerEventListener ---------------------
+
+SwScannerEventListener::~SwScannerEventListener()
+{
+}
+
+void SAL_CALL SwScannerEventListener::disposing( const EventObject& rEventObject) throw(uno::RuntimeException)
+{
+ vos::OGuard aGuard(Application::GetSolarMutex());
+#if defined WIN || defined WNT || defined UNX
+ if( pView )
+ pView->ScannerEventHdl( rEventObject );
+#endif
+}
+
+// ------------------------- SwClipboardChangeListener ---------------------
+
+SwClipboardChangeListener::~SwClipboardChangeListener()
+{
+}
+
+void SAL_CALL SwClipboardChangeListener::disposing( const EventObject& /*rEventObject*/ )
+ throw ( RuntimeException )
+{
+}
+
+void SAL_CALL SwClipboardChangeListener::changedContents( const CLIP_NMSPC::ClipboardEvent& rEventObject )
+ throw ( RuntimeException )
+
+{
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ if( pView )
+ {
+ {
+ TransferableDataHelper aDataHelper( rEventObject.Contents );
+ SwWrtShell& rSh = pView->GetWrtShell();
+
+ pView->nLastPasteDestination = SwTransferable::GetSotDestination( rSh );
+ pView->bPasteState = aDataHelper.GetXTransferable().is() &&
+ SwTransferable::IsPaste( rSh, aDataHelper );
+
+ pView->bPasteSpecialState = aDataHelper.GetXTransferable().is() &&
+ SwTransferable::IsPasteSpecial( rSh, aDataHelper );
+ }
+
+ SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_PASTE );
+ rBind.Invalidate( SID_PASTE_SPECIAL );
+ rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+}
+
+void SwClipboardChangeListener::AddRemoveListener( BOOL bAdd )
+{
+ pView->AddRemoveClipboardListener( Reference< XClipboardListener >( this ), bAdd );
+}
+
+
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
new file mode 100644
index 000000000000..4396ff03807c
--- /dev/null
+++ b/sw/source/ui/uiview/view.cxx
@@ -0,0 +1,1943 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <stdlib.h>
+#include <hintids.hxx>
+#include <rtl/logfile.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/inputctx.hxx>
+#include <basic/sbxobj.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/undoopt.hxx>
+#include <unotools/lingucfg.hxx>
+#include <svtools/printdlg.hxx>
+#include <unotools/useroptions.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/app.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/protitem.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <unotxvw.hxx>
+#include <cmdid.h>
+#include <swhints.hxx>
+#include <swmodule.hxx>
+#include <inputwin.hxx>
+#include <chartins.hxx>
+#include <uivwimp.hxx>
+#include <uitool.hxx>
+#include <edtwin.hxx>
+#include <textsh.hxx>
+#include <listsh.hxx>
+#include <tabsh.hxx>
+#include <grfsh.hxx>
+#include <mediash.hxx>
+#include <docsh.hxx>
+#include <frmsh.hxx>
+#include <olesh.hxx>
+#include <drawsh.hxx>
+#include <drawbase.hxx>
+#include <drformsh.hxx>
+#include <drwtxtsh.hxx>
+#include <beziersh.hxx>
+#include <globdoc.hxx>
+#include <scroll.hxx>
+#include <globdoc.hxx>
+#include <navipi.hxx>
+#include <gloshdl.hxx>
+#include <usrpref.hxx>
+#include <srcview.hxx>
+#include <doc.hxx>
+#include <drawdoc.hxx>
+#include <wdocsh.hxx>
+#include <wview.hxx>
+#include <workctrl.hxx>
+#include <wrtsh.hxx>
+#include <barcfg.hxx>
+#include <pview.hxx>
+#include <swdtflvr.hxx>
+#include <view.hrc>
+#include <globdoc.hrc>
+#include <frmui.hrc>
+#include <cfgitems.hxx>
+#include <prtopt.hxx>
+#include <swprtopt.hxx>
+#include <linguistic/lngprops.hxx>
+#include <editeng/unolingu.hxx>
+//#include <sfx2/app.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/scanner/ScannerContext.hpp>
+#include <com/sun/star/scanner/XScannerManager.hpp>
+#include <toolkit/unohlp.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <xmloff/xmluconv.hxx>
+
+#include "formatclipboard.hxx"
+#include <PostItMgr.hxx>
+#include <annotsh.hxx>
+
+#include <fldbas.hxx>
+
+#include <unomid.h>
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::scanner;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+extern sal_Bool bNoInterrupt; // in mainwn.cxx
+
+#define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT| \
+ SFX_VIEW_HAS_PRINTOPTIONS)
+
+/*--------------------------------------------------------------------
+ Beschreibung: Statics
+ --------------------------------------------------------------------*/
+
+int bDocSzUpdated = 1;
+
+SvxSearchItem* SwView::pSrchItem = 0;
+
+sal_uInt16 SwView::nInsertCtrlState = FN_INSERT_TABLE;
+sal_uInt16 SwView::nWebInsertCtrlState = FN_INSERT_TABLE;
+sal_uInt16 SwView::nInsertObjectCtrlState = SID_INSERT_DIAGRAM;
+
+sal_Bool SwView::bExtra = sal_False;
+sal_Bool SwView::bFound = sal_False;
+sal_Bool SwView::bJustOpened = sal_False;
+
+
+SvxSearchDialog* SwView::pSrchDlg = 0;
+SearchAttrItemList* SwView::pSrchList = 0;
+SearchAttrItemList* SwView::pReplList = 0;
+
+DBG_NAME(viewhdl)
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+inline SfxDispatcher &SwView::GetDispatcher()
+{
+ return *GetViewFrame()->GetDispatcher();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwView::ImpSetVerb( int nSelType )
+{
+ sal_Bool bResetVerbs = bVerbsActive;
+ if ( !GetViewFrame()->GetFrame().IsInPlace() &&
+ (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType )
+ {
+ if ( !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) )
+ {
+ if ( nSelType & nsSelectionType::SEL_OLE )
+ {
+ SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
+ bVerbsActive = sal_True;
+ bResetVerbs = sal_False;
+ }
+ }
+ }
+ if ( bResetVerbs )
+ {
+ SetVerbs( 0 );
+ bVerbsActive = sal_False;
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description:
+ called by the SwEditWin when it gets the focus
+ --------------------------------------------------------------------*/
+
+void SwView::GotFocus() const
+{
+ // if we got the focus, and the form shell *is* on the top of the dispatcher
+ // stack, then we need to rebuild the stack (the form shell doesn't belong to
+ // the top then)
+ const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
+ SfxShell* pTopShell = rDispatcher.GetShell( 0 );
+ FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
+ if ( pAsFormShell )
+ {
+ pAsFormShell->ForgetActiveControl();
+ const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
+ }
+ else if ( mpPostItMgr )
+ {
+ SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell );
+ if ( pAsAnnotationShell )
+ {
+ mpPostItMgr->SetActiveSidebarWin(0);
+ const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description:
+ called by the FormShell when a form control is focused. This is
+ a request to put the form shell on the top of the dispatcher
+ stack
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SwView, FormControlActivated, FmFormShell*, EMPTYARG )
+{
+ // if a form control has been activated, and the form shell is not on the top
+ // of the dispatcher stack, then we need to activate it
+ const SfxDispatcher& rDispatcher = GetDispatcher();
+ const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
+ const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
+ if ( !pAsFormShell )
+ {
+ // if we're editing text currently, cancel this
+ SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : NULL;
+ if ( pSdrView && pSdrView->IsTextEdit() )
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
+ }
+
+ return 0L;
+}
+
+void SwView::SelectShell()
+{
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//
+// Achtung: SelectShell fuer die WebView mitpflegen
+//
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ if(bInDtor)
+ return;
+ // Entscheidung, ob UpdateTable gerufen werden muss
+ sal_Bool bUpdateTable = sal_False;
+ const SwFrmFmt* pCurTableFmt = pWrtShell->GetTableFmt();
+ if(pCurTableFmt && pCurTableFmt != pLastTableFormat)
+ {
+ bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden
+ }
+ pLastTableFormat = pCurTableFmt;
+
+ //SEL_TBL und SEL_TBL_CELLS koennen verodert sein!
+ int nNewSelectionType = (pWrtShell->GetSelectionType()
+ & ~nsSelectionType::SEL_TBL_CELLS);
+
+ if ( pFormShell && pFormShell->IsActiveControl() )
+ nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL;
+
+ if ( nNewSelectionType == nSelectionType )
+ {
+ GetViewFrame()->GetBindings().InvalidateAll( sal_False );
+ if ( nSelectionType & nsSelectionType::SEL_OLE ||
+ nSelectionType & nsSelectionType::SEL_GRF )
+ //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
+ ImpSetVerb( nNewSelectionType );
+ }
+ else
+ {
+
+ SfxDispatcher &rDispatcher = GetDispatcher();
+ SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig();
+
+ // DELETEZ(pxSelectionObj); //Selektionsobjekt loeschen
+ if ( pShell )
+ {
+ rDispatcher.Flush(); // alle gecachten Shells wirklich loeschen
+
+ //Zur alten Selektion merken welche Toolbar sichtbar war
+ USHORT nId = static_cast< USHORT >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT ));
+ if ( nId )
+ pBarCfg->SetTopToolbar( nSelectionType, nId );
+
+ SfxShell *pSfxShell;
+ for ( sal_uInt16 i = 0; sal_True; ++i )
+ {
+ pSfxShell = rDispatcher.GetShell( i );
+ if ( pSfxShell->ISA( SwBaseShell )
+ || pSfxShell->ISA( SwDrawTextShell )
+ || pSfxShell->ISA( svx::ExtrusionBar )
+ || pSfxShell->ISA( svx::FontworkBar )
+ || pSfxShell->ISA( SwAnnotationShell )
+ )
+ {
+ rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE );
+ }
+ else if ( pSfxShell->ISA( FmFormShell ) )
+ {
+ rDispatcher.Pop( *pSfxShell );
+ }
+ else
+ break;
+ }
+ }
+
+ BOOL bInitFormShell = sal_False;
+ if (!pFormShell)
+ {
+ bInitFormShell = sal_True;
+ pFormShell = new FmFormShell( this );
+ pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) );
+ StartListening(*pFormShell);
+ }
+
+ BOOL bSetExtInpCntxt = sal_False;
+ nSelectionType = nNewSelectionType;
+ ShellModes eShellMode;
+
+ if ( !( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) )
+ rDispatcher.Push( *pFormShell );
+
+ if ( nSelectionType & nsSelectionType::SEL_OLE )
+ {
+ eShellMode = SHELL_MODE_OBJECT;
+ pShell = new SwOleShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_FRM
+ || nSelectionType & nsSelectionType::SEL_GRF)
+ {
+ eShellMode = SHELL_MODE_FRAME;
+ pShell = new SwFrameShell( *this );
+ rDispatcher.Push( *pShell );
+ if(nSelectionType & nsSelectionType::SEL_GRF )
+ {
+ eShellMode = SHELL_MODE_GRAPHIC;
+ pShell = new SwGrfShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_DRW )
+ {
+ eShellMode = SHELL_MODE_DRAW;
+ pShell = new SwDrawShell( *this );
+ rDispatcher.Push( *pShell );
+
+ if ( nSelectionType & nsSelectionType::SEL_BEZ )
+ {
+ eShellMode = SHELL_MODE_BEZIER;
+ pShell = new SwBezierShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ else if( nSelectionType & nsSelectionType::SEL_MEDIA )
+ {
+ eShellMode = SHELL_MODE_MEDIA;
+ pShell = new SwMediaShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+
+ if (nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE)
+ {
+ eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE;
+ pShell = new svx::ExtrusionBar(this);
+ rDispatcher.Push( *pShell );
+ }
+ if (nSelectionType & nsSelectionType::SEL_FONTWORK)
+ {
+ eShellMode = SHELL_MODE_FONTWORK;
+ pShell = new svx::FontworkBar(this);
+ rDispatcher.Push( *pShell );
+ }
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_DRW_FORM )
+ {
+ eShellMode = SHELL_MODE_DRAW_FORM;
+ pShell = new SwDrawFormShell( *this );
+
+ rDispatcher.Push( *pShell );
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_DRW_TXT )
+ {
+ bSetExtInpCntxt = sal_True;
+ eShellMode = SHELL_MODE_DRAWTEXT;
+ rDispatcher.Push( *(new SwBaseShell( *this )) );
+ pShell = new SwDrawTextShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ else if ( nSelectionType & nsSelectionType::SEL_POSTIT )
+ {
+ eShellMode = SHELL_MODE_POSTIT;
+ pShell = new SwAnnotationShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ else
+ {
+ bSetExtInpCntxt = sal_True;
+ eShellMode = SHELL_MODE_TEXT;
+ sal_uInt32 nHelpId = 0;
+ if ( nSelectionType & nsSelectionType::SEL_NUM )
+ {
+ eShellMode = SHELL_MODE_LIST_TEXT;
+ pShell = new SwListShell( *this );
+ nHelpId = pShell->GetHelpId();
+ rDispatcher.Push( *pShell );
+ }
+ pShell = new SwTextShell(*this);
+ if(nHelpId)
+ pShell->SetHelpId(nHelpId);
+ rDispatcher.Push( *pShell );
+ if ( nSelectionType & nsSelectionType::SEL_TBL )
+ {
+ eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
+ : SHELL_MODE_TABLE_TEXT;
+ pShell = new SwTableShell( *this );
+ rDispatcher.Push( *pShell );
+ }
+ }
+
+ if ( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL )
+ rDispatcher.Push( *pFormShell );
+
+ pViewImpl->SetShellMode(eShellMode);
+ ImpSetVerb( nSelectionType );
+
+ if( !GetDocShell()->IsReadOnly() )
+ {
+ if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
+ bSetExtInpCntxt = sal_False;
+
+ InputContext aCntxt( GetEditWin().GetInputContext() );
+ aCntxt.SetOptions( bSetExtInpCntxt
+ ? (aCntxt.GetOptions() |
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ))
+ : (aCntxt.GetOptions() & ~
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT )) );
+ GetEditWin().SetInputContext( aCntxt );
+ }
+
+ //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
+ //aktiviert war
+ //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
+ //kein Performance-Problem
+ // TODO/LATER: maybe now the Flush() command is superfluous?!
+ rDispatcher.Flush();
+
+ Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
+ aPnt = GetEditWin().PixelToLogic(aPnt);
+ GetEditWin().UpdatePointer(aPnt);
+
+ SdrView* pDView = GetWrtShell().GetDrawView();
+ if ( bInitFormShell && pDView )
+ pFormShell->SetView(PTR_CAST(FmFormView, pDView));
+
+ }
+ //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
+ if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
+ GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
+
+ //jetzt das Tabellen-Update
+ if(bUpdateTable)
+ pWrtShell->UpdateTable();
+
+ GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+}
+
+//Zusammenspiel: AttrChangedNotify() und TimeoutHdl.
+//Falls noch Actions offen sind keine Aktualisierung, da der
+//Cursor auf der Core-Seite im Wald stehen kann.
+//Da wir aber keine Stati mehr liefern koennen und wollen locken wir
+//stattdessen den Dispatcher.
+
+
+
+extern "C"
+{
+ int lcl_CmpIds( const void *pFirst, const void *pSecond)
+ {
+ return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond);
+ }
+}
+
+
+
+IMPL_LINK( SwView, AttrChangedNotify, SwWrtShell *, EMPTYARG )
+{
+ if ( GetEditWin().IsChainMode() )
+ GetEditWin().SetChainMode( sal_False );
+
+ //Opt: Nicht wenn PaintLocked. Beim Unlock wird dafuer nocheinmal ein
+ //Notify ausgeloest.
+ if( !pWrtShell->IsPaintLocked() && !bNoInterrupt &&
+ GetDocShell()->IsReadOnly() )
+ _CheckReadonlyState();
+
+ // JP 19.01.99: Cursor in Readonly Bereichen
+ if( !pWrtShell->IsPaintLocked() && !bNoInterrupt )
+ _CheckReadonlySelection();
+
+ if( !bAttrChgNotified )
+ {
+ if ( pWrtShell->BasicActionPend() || bNoInterrupt ||
+ GetDispatcher().IsLocked() || //do not confuse the SFX
+ GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
+ {
+ bAttrChgNotified = sal_True;
+ aTimer.Start();
+
+ const SfxPoolItem *pItem;
+ if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()->
+ GetItemState( SID_HIDDEN, sal_False, &pItem ) ||
+ !((SfxBoolItem*)pItem)->GetValue() )
+ {
+ GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
+ bAttrChgNotifiedWithRegistrations = sal_True;
+ }
+
+ }
+ else
+ SelectShell();
+
+ }
+
+ //#i6193#, change ui if cursor is at a SwPostItField
+ if (mpPostItMgr)
+ {
+ // --> OD 2008-06-19 #i90516#
+ // only perform the code that is needed to determine, if at the
+ // actual cursor position is a post-it field
+// SwRect aFldRect;
+// SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
+// if( pWrtShell->GetContentAtPos( pWrtShell->GetCrsrDocPos(), aCntntAtPos, FALSE, &aFldRect ) )
+// {
+// const SwField* pFld = aCntntAtPos.aFnd.pFld;
+// if (pFld->Which()== RES_POSTITFLD)
+// {
+// mpPostItMgr->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld));
+// }
+// else
+// mpPostItMgr->SetShadowState(0);
+// }
+// else
+// mpPostItMgr->SetShadowState(0);
+ mpPostItMgr->SetShadowState( pWrtShell->GetPostItFieldAtCursor() );
+ }
+
+ return 0;
+}
+
+
+
+IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG )
+{
+ DBG_PROFSTART(viewhdl);
+
+ if( pWrtShell->BasicActionPend() || bNoInterrupt )
+ {
+ aTimer.Start();
+ DBG_PROFSTOP(viewhdl);
+ return 0;
+ }
+
+ if ( bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ bAttrChgNotifiedWithRegistrations = sal_False;
+ }
+
+ _CheckReadonlyState();
+ _CheckReadonlySelection();
+
+ BOOL bOldUndo = pWrtShell->DoesUndo();
+ pWrtShell->DoUndo( FALSE );
+ SelectShell();
+ pWrtShell->DoUndo( bOldUndo );
+ bAttrChgNotified = sal_False;
+ GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+
+ DBG_PROFSTOP(viewhdl);
+ return 0;
+}
+
+void SwView::_CheckReadonlyState()
+{
+ SfxDispatcher &rDis = GetDispatcher();
+ //Um erkennen zu koennen ob bereits disabled ist!
+ SfxItemState eStateRO, eStateProtAll;
+ const SfxPoolItem *pItem;
+ // JP 29.04.97: von einem nur uns bekannten Slot den Status abfragen.
+ // Ansonsten kennen andere den Slot; wie z.B. die BasidIde
+ eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
+ eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
+ sal_Bool bChgd = sal_False;
+
+ if ( !pWrtShell->IsCrsrReadonly() )
+ {
+ static sal_uInt16 aROIds[] =
+ {
+ SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE,
+ SID_UNDO,
+ SID_REDO, SID_REPEAT, SID_PASTE,
+ SID_PASTE_UNFORMATTED,
+ SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT,
+ SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK,
+ SID_CHARMAP, FN_INSERT_SOFT_HYPHEN,
+ FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK,
+ FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG,
+ FN_DELETE_SENT, FN_DELETE_BACK_SENT, FN_DELETE_WORD,
+ FN_DELETE_BACK_WORD, FN_DELETE_LINE, FN_DELETE_BACK_LINE,
+ FN_DELETE_PARA, FN_DELETE_BACK_PARA, FN_DELETE_WHOLE_LINE,
+ FN_CALCULATE, FN_FORMAT_RESET,
+ FN_POSTIT, FN_JAVAEDIT, SID_ATTR_PARA_ADJUST_LEFT,
+ SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
+ SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20,
+ SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR_BACKGROUND,
+ SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, SID_ATTR_CHAR_COLOR_EXT,
+ SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_WEIGHT, SID_ATTR_CHAR_POSTURE,
+ SID_ATTR_CHAR_OVERLINE,
+ SID_ATTR_CHAR_UNDERLINE, SID_ATTR_FLASH, SID_ATTR_CHAR_STRIKEOUT,
+ FN_UNDERLINE_DOUBLE, SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_SHADOWED,
+ SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_ESCAPEMENT, FN_SET_SUPER_SCRIPT,
+ FN_SET_SUB_SCRIPT, SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_LANGUAGE,
+ SID_ATTR_CHAR_KERNING, SID_CHAR_DLG, SID_ATTR_CHAR_WORDLINEMODE,
+ FN_GROW_FONT_SIZE, FN_SHRINK_FONT_SIZE, FN_TXTATR_INET,
+ FN_FORMAT_DROPCAPS, SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_LINESPACE,
+ SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_KEEP, SID_ATTR_PARA_WIDOWS,
+ SID_ATTR_PARA_ORPHANS,
+ SID_ATTR_PARA_MODEL, SID_PARA_DLG,
+ FN_SELECT_PARA, SID_DEC_INDENT,
+ SID_INC_INDENT
+ };
+ static sal_Bool bFirst = sal_True;
+ if ( bFirst )
+ {
+ qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+ bFirst = sal_False;
+ }
+ if ( SFX_ITEM_DISABLED == eStateRO )
+ {
+ rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
+ bChgd = sal_True;
+ }
+ }
+ else if( pWrtShell->IsAllProtect() )
+ {
+ if ( SFX_ITEM_DISABLED == eStateProtAll )
+ {
+ static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
+ static sal_Bool bAllProtFirst = sal_True;
+ if ( bAllProtFirst )
+ {
+ qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
+ bAllProtFirst = sal_False;
+ }
+ rDis.SetSlotFilter( sal_Bool(2),
+ sizeof(aAllProtIds)/sizeof(sal_uInt16),
+ aAllProtIds );
+ bChgd = sal_True;
+ }
+ }
+ else if ( SFX_ITEM_DISABLED != eStateRO ||
+ SFX_ITEM_DISABLED != eStateProtAll )
+ {
+ bChgd = sal_True;
+ rDis.SetSlotFilter();
+ }
+ if ( bChgd )
+ GetViewFrame()->GetBindings().InvalidateAll(sal_True);
+}
+
+void SwView::_CheckReadonlySelection()
+{
+ sal_uInt32 nDisableFlags = 0;
+ SfxDispatcher &rDis = GetDispatcher();
+
+ if( pWrtShell->HasReadonlySel() &&
+ ( !pWrtShell->GetDrawView() ||
+ !pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
+ nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
+
+ if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
+ (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
+ {
+ // zusaetzlich am Window den InputContext umsetzen, damit in
+ // japanischen / chinesischen Versionen die externe Eingabe
+ // ab-/angeschaltet wird. Das aber nur wenn auch die richtige
+ // Shell auf dem Stack steht.
+ switch( pViewImpl->GetShellMode() )
+ {
+ case SHELL_MODE_TEXT:
+ case SHELL_MODE_LIST_TEXT:
+ case SHELL_MODE_TABLE_TEXT:
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ {
+//JP 22.01.99: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
+// den Font von der akt. Einfuegeposition setzen, also ausserhalb
+// dieses if's. Aber TH wertet den Font zur Zeit nicht aus und
+// das besorgen erscheint mir hier zu teuer zu sein.
+// Ausserdem haben wir keinen Font, sondern nur Attribute aus denen
+// die Textformatierung dann den richtigen Font zusammen baut.
+
+ InputContext aCntxt( GetEditWin().GetInputContext() );
+ aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
+ ? (aCntxt.GetOptions() & ~
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT ))
+ : (aCntxt.GetOptions() |
+ ( INPUTCONTEXT_TEXT |
+ INPUTCONTEXT_EXTTEXTINPUT )) );
+ GetEditWin().SetInputContext( aCntxt );
+ }
+ break;
+ default:
+ ;
+ }
+
+ }
+
+ if( nDisableFlags != rDis.GetDisableFlags() )
+ {
+ rDis.SetDisableFlags( nDisableFlags );
+ GetViewFrame()->GetBindings().InvalidateAll( sal_True );
+ }
+}
+
+
+SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
+ : SfxViewShell( _pFrame, SWVIEWFLAGS ),
+
+ aPageStr( SW_RES( STR_PAGE )),
+ nNewPage(USHRT_MAX),
+ pNumRuleNodeFromDoc(0), // #i23726#
+ pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
+ pWrtShell(0),
+ pShell(0),
+ pFormShell(0),
+ pHScrollbar(0),
+ pVScrollbar(0),
+ pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
+ pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
+ SVXRULER_SUPPORT_TABS |
+ SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
+ SVXRULER_SUPPORT_BORDERS |
+ SVXRULER_SUPPORT_NEGATIVE_MARGINS|
+ SVXRULER_SUPPORT_REDUCED_METRIC,
+ GetViewFrame()->GetBindings(),
+ WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)),
+ pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
+ SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
+ SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
+ GetViewFrame()->GetBindings(),
+ WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )),
+ pTogglePageBtn(0),
+ pPageUpBtn(0),
+ pPageDownBtn(0),
+ pNaviBtn(0),
+ pGlosHdl(0),
+ pDrawActual(0),
+ pLastTableFormat(0),
+ pFormatClipboard(new SwFormatClipboard()),
+ mpPostItMgr(0),
+ nSelectionType( INT_MAX ),
+ nPageCnt(0),
+ nDrawSfxId( USHRT_MAX ),
+ nFormSfxId( USHRT_MAX ),
+ nLastPasteDestination( 0xFFFF ),
+ nLeftBorderDistance( 0 ),
+ nRightBorderDistance( 0 ),
+ bInMailMerge(FALSE),
+ bInDtor(FALSE),
+ bOldShellWasPagePreView(FALSE)
+{
+ // OD 18.12.2002 #103492# - According to discussion with MBA and further
+ // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
+ // if function "New Window" is performed to open an additional view beside
+ // an already existing one.
+ // If the view is switch from one to another, the 'old' view is given by
+ // parameter <pOldSh>.
+
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwView::SwView" );
+
+ bCenterCrsr = bTopCrsr = bAllwaysShowSel = bTabColFromDoc = bTabRowFromDoc =
+ bSetTabColFromDoc = bSetTabRowFromDoc = bAttrChgNotified = bAttrChgNotifiedWithRegistrations =
+ bVerbsActive = bDrawRotate = bInOuterResizePixel = bInInnerResizePixel =
+ bPasteState = bPasteSpecialState = bMakeSelectionVisible = sal_False;
+
+ bShowAtResize = bDrawSelMode = bDocSzUpdated = sal_True;
+
+ _CreateScrollbar( TRUE );
+ _CreateScrollbar( FALSE );
+
+ pViewImpl = new SwView_Impl(this);
+ SetName(C2S("View"));
+ SetWindow( pEditWin );
+
+ aTimer.SetTimeout( 120 );
+
+ SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
+ BOOL bOldModifyFlag = pDocSh->IsEnableSetModified();
+ if(bOldModifyFlag)
+ pDocSh->EnableSetModified( sal_False );
+ ASSERT( pDocSh, "View ohne DocShell." );
+ SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
+
+ const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
+ SwViewOption aUsrPref( *pUsrPref);
+
+ //! get lingu options without loading lingu DLL
+ SvtLinguOptions aLinguOpt;
+
+ SvtLinguConfig().GetOptions( aLinguOpt );
+
+ aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
+
+ sal_Bool bOldShellWasSrcView = FALSE;
+
+ // OD 18.12.2002 #103492# - determine, if there is an existing view for
+ // document
+ SfxViewShell* pExistingSh = 0;
+ if ( pOldSh )
+ pExistingSh = pOldSh;
+ else
+ {
+ SfxViewFrame *pF = SfxViewFrame::GetFirst( pDocSh );
+ if( pF == _pFrame )
+ pF = SfxViewFrame::GetNext( *pF, pDocSh );
+ if( pF )
+ pExistingSh = pF->GetViewShell();
+ }
+
+ // determine type of existing view
+ if( pExistingSh &&
+ pExistingSh->IsA( TYPE( SwPagePreView ) ) )
+ {
+ sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData();
+ sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos();
+ nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage();
+ bOldShellWasPagePreView = TRUE;
+ }
+ else if( pExistingSh &&
+ pExistingSh->IsA( TYPE( SwSrcView ) ) )
+ bOldShellWasSrcView = TRUE;
+
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" );
+ if(PTR_CAST( SwView, pExistingSh))
+ {
+ pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->pWrtShell,
+ pEditWin, *this);
+//MA: Das kann doch nur zu einem GPF fuehren!
+// nSelectionType = ((SwView*)pOldSh)->nSelectionType;
+ }
+ else
+ {
+ SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
+
+ if( !bOldShellWasSrcView && pWebDShell && !bOldShellWasPagePreView )
+ rDoc.set(IDocumentSettingAccess::BROWSE_MODE, true);
+
+ //Fuer den BrowseMode wollen wir keinen Factor uebernehmen.
+ if( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
+ {
+ aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
+ aUsrPref.SetZoom( 100 );
+ }
+ if(pDocSh->IsPreview())
+ {
+ aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
+ aUsrPref.SetViewLayoutBookMode( false );
+ aUsrPref.SetViewLayoutColumns( 1 );
+ }
+ pWrtShell = new SwWrtShell( rDoc, pEditWin, *this, &aUsrPref );
+ //#97610# creating an SwView from a SwPagePreView needs to
+ // add the ViewShell to the ring of the other ViewShell(s)
+ if(bOldShellWasPagePreView)
+ {
+ ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell();
+ pWrtShell->MoveTo(&rPreviewViewShell);
+ //#95521# to update the field command et.al. if necessary
+ const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions();
+ if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() ||
+ pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
+ pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
+ pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
+ rPreviewViewShell.ApplyViewOptions(aUsrPref);
+ // OD 09.01.2003 #106334# - reset design mode at draw view for form
+ // shell, if needed.
+ if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() &&
+ pWrtShell->HasDrawView() )
+ {
+ SdrView* pDrawView = pWrtShell->GetDrawView();
+ pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() );
+ }
+ }
+ }
+ RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
+
+ // --> OD 2005-02-11 #i38810# - assure that modified state of document
+ // isn't reset, if document is already modified.
+ const bool bIsDocModified = pWrtShell->GetDoc()->IsModified();
+ // <--
+
+ // JP 05.02.99: Bug 61495 - damit unter anderem das HLineal im
+ // ReadonlyFall nicht angezeigt wird
+ aUsrPref.SetReadonly( pWrtShell->GetViewOptions()->IsReadonly() );
+
+ //Kein Margin fuer OLE!
+ Size aBrwsBorder;
+ if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
+ aBrwsBorder = GetMargin();
+
+ pWrtShell->SetBrowseBorder( aBrwsBorder );
+
+ // Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber
+ // den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX
+ // sie wieder vom Stack!
+ sal_Bool bOld = bNoInterrupt;
+ bNoInterrupt = sal_True;
+
+ pHRuler->SetActive( sal_True );
+ pVRuler->SetActive( sal_True );
+
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if( pViewFrame->GetFrame().GetParentFrame())
+ {
+ aUsrPref.SetViewHRuler(sal_False);
+ aUsrPref.SetViewVRuler(sal_False);
+ }
+
+ StartListening( *pViewFrame, TRUE );
+ StartListening( *pDocSh, TRUE );
+
+ // Vom HLineal den ZOOM-Faktor einstellen
+ Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
+ pHRuler->SetZoom( aZoomFract );
+ pVRuler->SetZoom( aZoomFract );
+ pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
+ FieldUnit eMetric = pUsrPref->GetHScrollMetric();
+ pHRuler->SetUnit( eMetric );
+ eMetric = pUsrPref->GetVScrollMetric();
+ pVRuler->SetUnit( eMetric );
+
+ // DocShell setzen
+ pDocSh->SetView( this );
+ SW_MOD()->SetView( this );
+
+ mpPostItMgr = new SwPostItMgr(this);
+
+ // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
+ // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
+ // nicht in der SFX-Verwaltung bekannt ist.
+ DocSzChgd( pWrtShell->GetDocSize() );
+
+ // AttrChangedNotify Link setzen
+ pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
+
+ if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
+ //TODO/LATER: why a cast here?
+ //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
+ //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
+ !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
+ SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
+
+ SwEditShell::SetUndoActionCount(
+ static_cast< USHORT >( SW_MOD()->GetUndoOptions().GetUndoCount() ) );
+ pWrtShell->DoUndo( 0 != SwEditShell::GetUndoActionCount() );
+
+ const BOOL bBrowse = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+ SetNewWindowAllowed(!bBrowse);
+
+ ShowVScrollbar(aUsrPref.IsViewVScrollBar());
+ ShowHScrollbar(aUsrPref.IsViewHScrollBar());
+ pHScrollbar->SetAuto(bBrowse);
+ if( aUsrPref.IsViewHRuler() )
+ CreateTab();
+ if( aUsrPref.IsViewVRuler() )
+ CreateVLineal();
+
+ pWrtShell->SetUIOptions( aUsrPref );
+ pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
+ pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
+
+ if( pWrtShell->GetDoc()->IsUpdateExpFld() )
+ {
+ SET_CURR_SHELL( pWrtShell );
+ pWrtShell->StartAction();
+ pWrtShell->CalcLayout();
+ pWrtShell->GetDoc()->UpdateFlds(NULL, false);
+ pWrtShell->EndAction();
+ pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
+ }
+
+ // ggfs. alle Verzeichnisse updaten:
+ if( pWrtShell->GetDoc()->IsUpdateTOX() )
+ {
+ SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
+ Execute( aSfxRequest );
+ pWrtShell->GetDoc()->SetUpdateTOX( sal_False ); // wieder zurueck setzen
+ pWrtShell->SttEndDoc(TRUE);
+ }
+
+ // kein ResetModified, wenn es schone eine View auf dieses Doc gibt
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
+ // zur Zeit(360) wird die View erst nach dem Ctor eingetragen
+ // der folgende Ausdruck funktioniert auch, wenn sich das aendert
+ //JP 27.07.98: wenn per Undo nicht mehr die Modifizierung aufhebar ist,
+ // so setze das Modified NICHT zurueck.
+ // --> OD 2005-02-11 #i38810# - no reset of modified state, if document
+ // was already modified.
+ if ( !pWrtShell->GetDoc()->IsUndoNoResetModified() &&
+ ( !pFirst || pFirst == pVFrame ) &&
+ !bIsDocModified )
+ // <--
+ {
+ pWrtShell->ResetModified();
+ }
+
+ bNoInterrupt = bOld;
+
+ // wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden
+ if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
+ !pVFrame->GetChildWindow( SID_NAVIGATOR ))
+ {
+ SfxBoolItem aNavi(SID_NAVIGATOR, sal_True);
+ GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
+ }
+
+
+ /*uno::Reference< awt::XWindow > aTmpRef;
+ _pFrame->GetFrame().GetFrameInterface()->setComponent( aTmpRef,
+ pViewImpl->GetUNOObject_Impl());*/
+
+ uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame().GetFrameInterface();
+
+ uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame(
+ OUString::createFromAscii("_beamer"), frame::FrameSearchFlag::CHILDREN);
+ if(xBeamerFrame.is())
+ {
+ SwDBData aData = pWrtShell->GetDBData();
+ SW_MOD()->ShowDBObj( *this, aData );
+ }
+
+ // has anybody calls the attrchanged handler in the constructor?
+ if( bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ if( aTimer.IsActive() )
+ aTimer.Stop();
+ }
+
+ aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
+ bAttrChgNotified = bAttrChgNotifiedWithRegistrations = sal_False;
+ if(bOldModifyFlag)
+ pDocSh->EnableSetModified( sal_True );
+ InvalidateBorder();
+
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+SwView::~SwView()
+{
+ delete mpPostItMgr;
+ // --> OD 2009-03-10 #i100035#
+ mpPostItMgr = 0;
+ // <--
+
+ bInDtor = TRUE;
+ pEditWin->Hide(); // damit kein Paint Aerger machen kann!
+ // An der SwDocShell den Pointer auf die View ruecksetzen
+ SwDocShell* pDocSh = GetDocShell();
+ if( pDocSh && pDocSh->GetView() == this )
+ pDocSh->SetView( 0 );
+ if ( SW_MOD()->GetView() == this )
+ SW_MOD()->SetView( 0 );
+
+ if( aTimer.IsActive() && bAttrChgNotifiedWithRegistrations )
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+
+ //JP 27.11.00: Bug 80631 - the last view must end the text edit
+ SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : 0;
+ if( pSdrView && pSdrView->IsTextEdit() )
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ SetWindow( 0 );
+
+ pViewImpl->Invalidate();
+ EndListening(*GetViewFrame());
+ EndListening(*GetDocShell());
+ delete pScrollFill;
+ delete pWrtShell;
+ pWrtShell = 0; // Auf 0 setzen, damit folgende DToren nicht drauf zugreifen
+ pShell = 0;
+ delete pHScrollbar;
+ delete pVScrollbar;
+ delete pHRuler;
+ delete pVRuler;
+ delete pTogglePageBtn;
+ delete pPageUpBtn;
+ delete pNaviBtn;
+ delete pPageDownBtn;
+ delete pGlosHdl;
+ delete pViewImpl;
+ delete pEditWin;
+ delete pFormatClipboard;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: DocShell rausgrabbeln ueber das FrameWindow
+ --------------------------------------------------------------------*/
+
+
+SwDocShell* SwView::GetDocShell()
+{
+ SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
+ return PTR_CAST(SwDocShell, pDocShell);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: CursorPos merken
+ --------------------------------------------------------------------*/
+
+
+void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse )
+{
+ //Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed
+ //werden (nicht zu verwechseln mit dem BrowseMode).
+ //Die dann gespeicherten Daten sind nicht persistent!!
+
+ const SwRect& rRect = pWrtShell->GetCharRect();
+ const Rectangle& rVis = GetVisArea();
+
+ rUserData = String::CreateFromInt32( rRect.Left() );
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( rRect.Top() );
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( pWrtShell->GetViewOptions()->GetZoom() );
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( rVis.Left() );
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( rVis.Top() );
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Right());
+ rUserData += ';';
+ rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Bottom());
+ rUserData += ';';
+ rUserData += String::CreateFromInt32(
+ (sal_uInt16)pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
+ rUserData += ';';
+ rUserData += FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? '0' : '1';
+}
+/*--------------------------------------------------------------------
+ Beschreibung: CursorPos setzen
+ --------------------------------------------------------------------*/
+//#i43146# go to the last editing position when opening own files
+bool lcl_IsOwnDocument( SwView& rView )
+{
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps
+ = xDPS->getDocumentProperties();
+ String Created = xDocProps->getAuthor();
+ String Changed = xDocProps->getModifiedBy();
+ String FullName = SW_MOD()->GetUserOptions().GetFullName();
+ return FullName.Len() &&
+ (Changed.Len() && Changed == FullName ) ||
+ (!Changed.Len() && Created.Len() && Created == FullName );
+}
+
+
+void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
+{
+ if ( rUserData.GetTokenCount() > 1 &&
+ //Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
+ //Forward/Backward
+ (!pWrtShell->IsNewLayout() || pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) || bBrowse) )
+ {
+ //#i43146# go to the last editing position when opening own files
+ bool bIsOwnDocument = lcl_IsOwnDocument( *this );
+
+ SET_CURR_SHELL(pWrtShell);
+
+ sal_uInt16 nPos = 0;
+
+ // Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr.
+ // aufzurufen, denn welcher Parameter wird zuerst ausgewertet?
+ long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(),
+ nY = rUserData.GetToken( 0, ';', nPos ).ToInt32();
+ Point aCrsrPos( nX, nY );
+
+ sal_uInt16 nZoomFactor =
+ static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() );
+
+ long nLeft = rUserData.GetToken(0, ';', nPos ).ToInt32(),
+ nTop = rUserData.GetToken(0, ';', nPos ).ToInt32(),
+ nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(),
+ nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32();
+
+ const long nAdd = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if ( nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
+ {
+ pWrtShell->EnableSmooth( sal_False );
+
+ const Rectangle aVis( nLeft, nTop, nRight, nBottom );
+
+ sal_uInt16 nOff = 0;
+ SvxZoomType eZoom;
+ if( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32();
+ else
+ {
+ eZoom = SVX_ZOOM_PERCENT;
+ ++nOff;
+ }
+
+ sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32())
+ && pWrtShell->IsObjSelectable( aCrsrPos );
+
+ //#i33307# restore editing position
+ pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
+ // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
+ bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
+ pWrtShell->SetMacroExecAllowed( false );
+//!!! pb (11.08.2004): #i32536#
+// os: changed: The user data has to be read if the view is switched back from page preview
+//#i43146# go to the last editing position when opening own files
+ if(bOldShellWasPagePreView || bIsOwnDocument)
+ {
+ pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+ if( bSelectObj )
+ {
+ pWrtShell->SelectObj( aCrsrPos );
+ pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+
+ // OD 11.02.2003 #100556# - reset flag value
+ pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
+
+ // OD 08.04.2003 #108693# - set visible area before applying
+ // information from print preview. Otherwise, the applied information
+ // is lost.
+//!!! pb (11.08.2004): #i32536#
+// os: changed: The user data has to be read if the view is switched back from page preview
+//#i43146# go to the last editing position when opening own files
+ if(bOldShellWasPagePreView || bIsOwnDocument )
+ {
+ if ( bBrowse )
+ SetVisArea( aVis.TopLeft() );
+ else
+ SetVisArea( aVis );
+ }
+
+ //apply information from print preview - if available
+ if( sNewCrsrPos.Len() )
+ {
+ long nXTmp = sNewCrsrPos.GetToken( 0, ';' ).ToInt32(),
+ nYTmp = sNewCrsrPos.GetToken( 1, ';' ).ToInt32();
+ Point aCrsrPos2( nXTmp, nYTmp );
+ bSelectObj = pWrtShell->IsObjSelectable( aCrsrPos2 );
+
+ pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, FALSE );
+ if( bSelectObj )
+ {
+ pWrtShell->SelectObj( aCrsrPos2 );
+ pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
+ }
+ pWrtShell->MakeSelVisible();
+ sNewCrsrPos.Erase();
+ }
+ else if(USHRT_MAX != nNewPage)
+ {
+ pWrtShell->GotoPage(nNewPage, TRUE);
+ nNewPage = USHRT_MAX;
+ }
+
+ SelectShell();
+
+ pWrtShell->StartAction();
+ const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+ if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
+ SetZoom( eZoom, nZoomFactor);
+
+ pWrtShell->LockView( sal_True );
+ pWrtShell->EndAction();
+ pWrtShell->LockView( sal_False );
+ pWrtShell->EnableSmooth( sal_True );
+ }
+ }
+}
+
+void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ if(GetDocShell()->IsPreview())
+ return;
+ //#i43146# go to the last editing position when opening own files
+ bool bIsOwnDocument = lcl_IsOwnDocument( *this );
+ sal_Int32 nLength = rSequence.getLength();
+ if (nLength && (!pWrtShell->IsNewLayout() || pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) || bBrowse) )
+ {
+ SET_CURR_SHELL(pWrtShell);
+ const beans::PropertyValue *pValue = rSequence.getConstArray();
+ const SwRect& rRect = pWrtShell->GetCharRect();
+ const Rectangle &rVis = GetVisArea();
+ const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+
+ long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
+ long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
+ sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
+ sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
+ bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
+ sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
+
+ sal_Bool bSelectedFrame = ( pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
+ bGotViewLeft = sal_False, bGotViewTop = sal_False, bGotVisibleLeft = sal_False,
+ bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
+ bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
+ bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
+ bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
+
+ for (sal_Int16 i = 0 ; i < nLength; i++)
+ {
+ if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLeft" ) ) )
+ {
+ pValue->Value >>= nX;
+ nX = MM100_TO_TWIP( nX );
+ bGotViewLeft = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewTop" ) ) )
+ {
+ pValue->Value >>= nY;
+ nY = MM100_TO_TWIP( nY );
+ bGotViewTop = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleLeft" ) ) )
+ {
+ pValue->Value >>= nLeft;
+ nLeft = MM100_TO_TWIP( nLeft );
+ bGotVisibleLeft = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleTop" ) ) )
+ {
+ pValue->Value >>= nTop;
+ nTop = MM100_TO_TWIP( nTop );
+ bGotVisibleTop = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleRight" ) ) )
+ {
+ pValue->Value >>= nRight;
+ nRight = MM100_TO_TWIP( nRight );
+ bGotVisibleRight = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleBottom" ) ) )
+ {
+ pValue->Value >>= nBottom;
+ nBottom = MM100_TO_TWIP( nBottom );
+ bGotVisibleBottom = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomType" ) ) )
+ {
+ pValue->Value >>= nZoomType;
+ bGotZoomType = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomFactor" ) ) )
+ {
+ pValue->Value >>= nZoomFactor;
+ bGotZoomFactor = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutColumns" ) ) )
+ {
+ pValue->Value >>= nViewLayoutColumns;
+ bGotViewLayoutColumns = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutBookMode" ) ) )
+ {
+ bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
+ bGotViewLayoutBookMode = sal_True;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) )
+ {
+ pValue->Value >>= bSelectedFrame;
+ bGotIsSelectedFrame = sal_True;
+ }
+ pValue++;
+ }
+ if (bGotVisibleBottom)
+ {
+ Point aCrsrPos( nX, nY );
+ const long nAdd = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if (nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
+ {
+ pWrtShell->EnableSmooth( sal_False );
+ const Rectangle aVis( nLeft, nTop, nRight, nBottom );
+
+ sal_uInt16 nOff = 0;
+ SvxZoomType eZoom;
+ if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ eZoom = static_cast < SvxZoomType > ( nZoomType );
+ else
+ {
+ eZoom = SVX_ZOOM_PERCENT;
+ ++nOff;
+ }
+ if (bGotIsSelectedFrame)
+ {
+ sal_Bool bSelectObj = (sal_False != bSelectedFrame )
+ && pWrtShell->IsObjSelectable( aCrsrPos );
+
+ // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
+ bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
+ pWrtShell->SetMacroExecAllowed( false );
+//!!! pb (11.08.2004): #i32536#
+// os: changed: The user data has to be read if the view is switched back from page preview
+//#i43146# go to the last editing position when opening own files
+ //#i33307# restore editing position
+ pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
+ if(bOldShellWasPagePreView|| bIsOwnDocument)
+ {
+ pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+ if( bSelectObj )
+ {
+ pWrtShell->SelectObj( aCrsrPos );
+ pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+
+ // OD 11.02.2003 #100556# - reset flag value
+ pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
+ }
+ SelectShell();
+
+ // Set ViewLayoutSettings
+ const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
+ ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
+
+ const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
+ ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
+
+ // In case we have a 'fixed' view layout of 2 or more columns,
+ // we have to apply the view options *before* starting the action.
+ // Otherwsie the SetZoom function cannot work correctly, because
+ // the view layout hasn't been calculated.
+ const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
+ 1 < nViewLayoutColumns &&
+ bSetViewSettings &&
+ eZoom != SVX_ZOOM_PERCENT;
+
+
+ if ( !bZoomNeedsViewLayout )
+ pWrtShell->StartAction();
+
+ if ( bSetViewLayoutSettings )
+ SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
+
+ if ( bZoomNeedsViewLayout )
+ pWrtShell->StartAction();
+
+ if ( bSetViewSettings )
+ SetZoom( eZoom, nZoomFactor, sal_True );
+
+//!!! pb (11.08.2004): #i32536#
+// os: changed: The user data has to be read if the view is switched back from page preview
+//#i43146# go to the last editing position when opening own files
+ if(bOldShellWasPagePreView||bIsOwnDocument)
+ {
+ if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
+ {
+ Point aTopLeft(aVis.TopLeft());
+ //#i76699# make sure the document is still centered
+ const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
+ SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
+ if(nEditWidth > (aDocSz.Width() + lBorder ))
+ aTopLeft.X() = ( aDocSz.Width() + lBorder - nEditWidth ) / 2;
+ else
+ {
+ //check if the values are possible
+ long nXMax = pHScrollbar->GetRangeMax() - pHScrollbar->GetVisibleSize();
+ if( aTopLeft.X() > nXMax )
+ aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
+ }
+ SetVisArea( aTopLeft );
+ }
+ else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
+ SetVisArea( aVis );
+ }
+
+ pWrtShell->LockView( sal_True );
+ pWrtShell->EndAction();
+ pWrtShell->LockView( sal_False );
+ pWrtShell->EnableSmooth( sal_True );
+ }
+ }
+ }
+}
+#define NUM_VIEW_SETTINGS 12
+void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ const SwRect& rRect = pWrtShell->GetCharRect();
+ const Rectangle& rVis = GetVisArea();
+ Any aAny;
+
+ rSequence.realloc ( NUM_VIEW_SETTINGS );
+ sal_Int16 nIndex = 0;
+ beans::PropertyValue *pValue = rSequence.getArray();
+
+ sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
+ pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) );
+ OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
+ SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
+ pValue->Value <<= sBuffer.makeStringAndClear();
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLeft" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewTop" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleLeft" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleTop" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleRight" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleBottom" ) );
+ pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomType" ) );
+ const sal_Int16 nZoomType = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetZoomType());
+ pValue->Value <<= nZoomType;
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutColumns" ) );
+ const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetViewLayoutColumns());
+ pValue->Value <<= nViewLayoutColumns;
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutBookMode" ) );
+ const sal_Bool bIsViewLayoutBookMode = pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
+ pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomFactor" ) );
+ pValue->Value <<= static_cast < sal_Int16 > (pWrtShell->GetViewOptions()->GetZoom());
+ pValue++;nIndex++;
+
+ pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "IsSelectedFrame" ) );
+ const sal_Bool bIsSelected = FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? sal_False : sal_True;
+ pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
+ nIndex++;
+
+ if ( nIndex < NUM_VIEW_SETTINGS )
+ rSequence.realloc ( nIndex );
+}
+#undef NUM_VIEW_SETTINGS
+
+
+
+void SwView::ShowCursor( FASTBOOL bOn )
+{
+ //JP 10.10.2001: Bug 90461 - don't scroll the cursor into the visible area
+ BOOL bUnlockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( TRUE ); //lock visible section
+
+ if( !bOn )
+ pWrtShell->HideCrsr();
+ else if( !pWrtShell->IsFrmSelected() && !pWrtShell->IsObjSelected() )
+ pWrtShell->ShowCrsr();
+
+ if( bUnlockView )
+ pWrtShell->LockView( FALSE );
+}
+
+
+
+ErrCode SwView::DoVerb( long nVerb )
+{
+ if ( !GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ const int nSel = rSh.GetSelectionType();
+ if ( nSel & nsSelectionType::SEL_OLE )
+ rSh.LaunchOLEObj( nVerb );
+ }
+ return ERRCODE_NONE;
+}
+
+/*-----------------17.02.98 13:33-------------------
+ nur sal_True fuer eine Textselektion zurueck geben
+--------------------------------------------------*/
+sal_Bool SwView::HasSelection( sal_Bool bText ) const
+{
+ return bText ? GetWrtShell().SwCrsrShell::HasSelection()
+ : GetWrtShell().HasSelection();
+}
+
+/*-----------------09/16/97 09:50am-----------------
+
+--------------------------------------------------*/
+
+String SwView::GetSelectionText( sal_Bool bCompleteWrds )
+{
+ return GetSelectionTextParam( bCompleteWrds, sal_True );
+}
+
+/*-----------------09/16/97 09:50am-----------------
+
+--------------------------------------------------*/
+String SwView::GetSelectionTextParam( sal_Bool bCompleteWrds,
+ sal_Bool bEraseTrail )
+{
+ String sReturn;
+ if( bCompleteWrds && !GetWrtShell().HasSelection() )
+ GetWrtShell().SelWrd();
+
+ GetWrtShell().GetSelectedText( sReturn );
+ if( bEraseTrail )
+ sReturn.EraseTrailingChars();
+ return sReturn;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+SwGlossaryHdl* SwView::GetGlosHdl()
+{
+ if(!pGlosHdl)
+ pGlosHdl = new SwGlossaryHdl(GetViewFrame(), pWrtShell);
+ return pGlosHdl;
+}
+
+/*-----------------05.09.96 15.50-------------------
+
+--------------------------------------------------*/
+
+
+
+void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ BOOL bCallBase = sal_True;
+ if ( rHint.ISA(SfxSimpleHint) )
+ {
+ sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
+ switch ( nId )
+ {
+ // --> OD 2005-03-03 #i43775# - sub shells will be destroyed by the
+ // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
+ case SFX_HINT_DYING:
+ {
+ if ( &rBC == GetViewFrame() )
+ {
+ ResetSubShell();
+ }
+ }
+ break;
+ // <--
+ case SFX_HINT_MODECHANGED:
+ {
+ // Modalmodus-Umschaltung?
+ sal_Bool bModal = GetDocShell()->IsInModalMode();
+ pHRuler->SetActive( !bModal );
+ pVRuler->SetActive( !bModal );
+ }
+
+ /* kein break hier */
+
+ case SFX_HINT_TITLECHANGED:
+ if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
+
+ if ( rSh.GetViewOptions()->IsViewVRuler() )
+ CreateVLineal();
+ else
+ KillVLineal();
+ if ( rSh.GetViewOptions()->IsViewHRuler() )
+ CreateTab();
+ else
+ KillTab();
+ bool bReadonly = GetDocShell()->IsReadOnly();
+ //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode
+ if( !bReadonly )
+ {
+ SwDrawDocument * pDrawDoc = 0;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
+ {
+ if( !pDrawDoc->GetOpenInDesignMode() )
+ break;// don't touch the design mode
+ }
+ }
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
+ GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
+ &aItem, 0L );
+ }
+ break;
+
+ case SW_BROADCAST_DRAWVIEWS_CREATED:
+ {
+ bCallBase = sal_False;
+ if ( GetFormShell() )
+ {
+ GetFormShell()->SetView(
+ PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
+ GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
+ &aItem, 0L );
+ }
+ }
+ break;
+ }
+ }
+ else if(rHint.ISA(FmDesignModeChangedHint))
+ {
+ sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
+ if (!bDesignMode && GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+ AttrChangedNotify(pWrtShell);
+ }
+ }
+
+ if ( bCallBase )
+ SfxViewShell::Notify(rBC, rHint);
+}
+
+/*-----------------02.12.96 12:36-------------------
+
+--------------------------------------------------*/
+#if defined WIN || defined WNT || defined UNX
+
+void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
+{
+ uno::Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
+ if( xScanMgr.is() )
+ {
+ const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
+ const ScanError eError = xScanMgr->getError( aContext );
+
+ if( ScanError_ScanErrorNone == eError )
+ {
+ const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
+
+ if( xBitmap.is() )
+ {
+ const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
+
+ if( !!aScanBmp )
+ {
+ Graphic aGrf(aScanBmp);
+ pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf );
+ }
+ }
+ }
+ }
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_TWAIN_SELECT );
+ rBind.Invalidate( SID_TWAIN_TRANSFER );
+}
+#endif
+
+/*-----------------04.03.97 15:07-------------------
+
+--------------------------------------------------*/
+
+
+void SwView::StopShellTimer()
+{
+ if(aTimer.IsActive())
+ {
+ aTimer.Stop();
+ if ( bAttrChgNotifiedWithRegistrations )
+ {
+ GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
+ bAttrChgNotifiedWithRegistrations = sal_False;
+ }
+ SelectShell();
+ bAttrChgNotified = sal_False;
+ }
+}
+
+/*-----------------09/03/97 04:12pm-----------------
+
+--------------------------------------------------*/
+sal_uInt16 SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
+{
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
+ if( pVFrame->GetDispatcher()->IsLocked() )
+ pVFrame->GetDispatcher()->Lock(sal_False);
+
+ sal_uInt16 nRet;
+ if ( pFormShell &&
+ sal_True != (nRet = pFormShell->PrepareClose( bUI, bForBrowsing )) )
+
+ {
+ return nRet;
+ }
+ return SfxViewShell::PrepareClose( bUI, bForBrowsing );
+}
+
+
+
+ // status methods for clipboard.
+ // Status changes now notified from the clipboard.
+BOOL SwView::IsPasteAllowed()
+{
+ USHORT nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
+ if( nLastPasteDestination != nPasteDestination )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is() )
+ {
+ bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
+ bPasteSpecialState = SwTransferable::IsPasteSpecial(
+ *pWrtShell, aDataHelper );
+ }
+ else
+ bPasteState = bPasteSpecialState = FALSE;
+
+ if( 0xFFFF == nLastPasteDestination ) // the init value
+ pViewImpl->AddClipboardListener();
+ nLastPasteDestination = nPasteDestination;
+ }
+ return bPasteState;
+}
+
+BOOL SwView::IsPasteSpecialAllowed()
+{
+ if ( pFormShell && pFormShell->IsActiveControl() )
+ return FALSE;
+
+ USHORT nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
+ if( nLastPasteDestination != nPasteDestination )
+ {
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard(
+ &GetEditWin()) );
+ if( aDataHelper.GetXTransferable().is() )
+ {
+ bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
+ bPasteSpecialState = SwTransferable::IsPasteSpecial(
+ *pWrtShell, aDataHelper );
+ }
+ else
+ bPasteState = bPasteSpecialState = FALSE;
+
+ if( 0xFFFF == nLastPasteDestination ) // the init value
+ pViewImpl->AddClipboardListener();
+ }
+ return bPasteSpecialState;
+}
+/* -----------------------------12.07.01 13:25--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::NotifyDBChanged()
+{
+ GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Drucken
+ --------------------------------------------------------------------*/
+
+/* -----------------------------28.10.02 13:25--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxObjectShellRef & SwView::GetTmpSelectionDoc()
+{
+ return GetViewImpl()->GetTmpSelectionDoc();
+}
+/* -----------------------------31.10.02 13:25--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxObjectShellRef & SwView::GetOrCreateTmpSelectionDoc()
+{
+ SfxObjectShellRef &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc();
+ if (!rxTmpDoc.Is())
+ {
+ SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl();
+ rxTmpDoc = pImpl->BuildTmpSelectionDoc(
+ GetViewImpl()->GetEmbeddedObjRef() );
+ }
+ return rxTmpDoc;
+}
+/* -----------------3/31/2003 12:39PM----------------
+
+ --------------------------------------------------*/
+void SwView::AddTransferable(SwTransferable& rTransferable)
+{
+ GetViewImpl()->AddTransferable(rTransferable);
+}
+
+/* --------------------------------------------------*/
+
+void SwPrtOptions::MakeOptions( BOOL bWeb )
+{
+ *this = *SW_MOD()->GetPrtOptions(bWeb);
+
+ nCopyCount = 1;
+ bCollate = FALSE;
+ bPrintSelection = FALSE;
+ bJobStartet = FALSE;
+
+ aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
+ aMulti.SelectAll();
+ aMulti.Select( 0, FALSE );
+}
+
diff --git a/sw/source/ui/uiview/view.hrc b/sw/source/ui/uiview/view.hrc
new file mode 100644
index 000000000000..8697a7e4ed63
--- /dev/null
+++ b/sw/source/ui/uiview/view.hrc
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _VIEW_HRC
+#define _VIEW_HRC
+
+#include "rcid.hrc"
+
+// BTN -------------------------------------------------------------------
+
+#define BTN_PAGEDOWN (RC_VIEW_BEGIN)
+#define BTN_PAGEUP (RC_VIEW_BEGIN + 1)
+
+// STR -------------------------------------------------------------------
+
+#define STR_NUM_LEVEL (RC_VIEW_BEGIN + 3)
+#define STR_NUM_OUTLINE (RC_VIEW_BEGIN + 4)
+
+#define STR_ERROR_NOLANG (RC_VIEW_BEGIN + 6)
+
+#define STR_EDIT_FOOTNOTE (RC_VIEW_BEGIN + 14)
+
+//#define RID_PVIEW_TOOLBOX (RC_VIEW_BEGIN + 15)
+#define MSG_NOT_FOUND (RC_VIEW_BEGIN + 16)
+#define MSG_SEARCH_START (RC_VIEW_BEGIN + 17)
+#define MSG_SEARCH_END (RC_VIEW_BEGIN + 18)
+#define MSG_INDEX_OVERFLOW (RC_VIEW_BEGIN + 19)
+#define STR_NB_REPLACED (RC_VIEW_BEGIN + 20)
+#define MSG_SCAN_NOSOURCE (RC_VIEW_BEGIN + 21)
+
+#define STR_SRCVIEW_ROW (RC_VIEW_BEGIN + 22)
+#define STR_SRCVIEW_COL (RC_VIEW_BEGIN + 23)
+#define STR_SAVEAS_SRC (RC_VIEW_BEGIN + 24)
+
+#define MSG_NO_MERGE_ENTRY (RC_VIEW_BEGIN + 25)
+
+#define STR_PRINT_TITLE (RC_VIEW_BEGIN + 26)
+#define STR_PRINT_MSG (RC_VIEW_BEGIN + 27)
+#define STR_PRINT_ALL (RC_VIEW_BEGIN + 28)
+#define STR_PRINT_SELECTION (RC_VIEW_BEGIN + 29)
+#define STR_READONLY_SEL (RC_VIEW_BEGIN + 30)
+
+#define RID_PVIEW_TOOLBOX (RC_VIEW_BEGIN + 31)
+#define STR_WEBOPTIONS (RC_VIEW_BEGIN + 32)
+#define STR_TEXTOPTIONS (RC_VIEW_BEGIN + 33)
+// MSG -------------------------------------------------------------------
+
+#define MSG_ERR_INSERT_GLOS (RC_VIEW_BEGIN)
+
+#define MSG_ERR_NO_FAX (RC_VIEW_BEGIN + 5)
+#define MSG_ERR_SRCSTREAM (RC_VIEW_BEGIN + 6)
+
+// DLG -------------------------------------------------------------------
+
+#define DLG_SPECIAL_FORCED (RC_VIEW_BEGIN)
+#define DLG_PAGEPREVIEW_ZOOM (RC_VIEW_BEGIN + 1)
+#define DLG_PAGEPREVIEW_PRINTOPTIONS (RC_VIEW_BEGIN + 2)
+
+// Ueberlaufpruefung -----------------------------------------------------
+
+#define VIEW_ACT_END STR_EDIT_FOOTNOTE
+
+#if VIEW_ACT_END > RC_VIEW_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif
+
diff --git a/sw/source/ui/uiview/view.src b/sw/source/ui/uiview/view.src
new file mode 100644
index 000000000000..9cf4f910f183
--- /dev/null
+++ b/sw/source/ui/uiview/view.src
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+#include <svx/globlmn.hrc>
+#include "view.hrc"
+#include "shells.hrc"
+#include "globals.hrc"
+#include "popup.hrc"
+#include "helpid.h"
+#include "cmdid.h"
+ImageButton BTN_PAGEUP
+{
+ SVLOOK = TRUE ;
+ HIDE = TRUE ;
+ RectStyle = TRUE ;
+ SmallStyle = TRUE ;
+ SYMBOL = IMAGEBUTTON_PAGEUP ;
+};
+ImageButton BTN_PAGEDOWN
+{
+ SVLOOK = TRUE ;
+ HIDE = TRUE ;
+ RectStyle = TRUE ;
+ SmallStyle = TRUE ;
+ SYMBOL = IMAGEBUTTON_PAGEDOWN ;
+};
+QueryBox DLG_WRAP
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_YES ;
+ Message [ en-US ] = "Do you want to continue checking at the beginning of the document?" ;
+};
+QueryBox DLG_BODY
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+ Message [ en-US ] = "Do you want to check the main text?" ;
+};
+QueryBox DLG_PRT_FIELDNAME
+{
+ BUTTONS = WB_YES_NO_CANCEL ;
+ DEFBUTTON = WB_DEF_CANCEL ;
+ Message [ en-US ] = "Show field commands option is checked.\nDo you want to print the document with field names?" ;
+};
+QueryBox DLG_SPECIAL
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+ Message [ en-US ] = "Do you want check the special regions?" ;
+};
+QueryBox DLG_THESAURUS
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+ Message [ en-US ] = "This word appears in the list of words you want to avoid! Start thesaurus?" ;
+};
+QueryBox DLG_SPECIAL_FORCED
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+ Message [ en-US ] = "Check special regions is deactivated. Check anyway?" ;
+};
+QueryBox MSG_SEARCH_END
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "%PRODUCTNAME Writer has searched to the end of the document. Do you want to continue at the beginning?" ;
+};
+QueryBox MSG_SEARCH_START
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "%PRODUCTNAME Writer has searched to the beginning of the document. Do you want to continue at the end?" ;
+};
+InfoBox MSG_NO_MERGE_ENTRY
+{
+ Message [ en-US ] = "Could not merge documents." ;
+};
+InfoBox MSG_ERR_INSERT_GLOS
+{
+ Message [ en-US ] = "AutoText could not be created." ;
+};
+InfoBox MSG_ERR_SRCSTREAM
+{
+ Message [ en-US ] = "The source cannot be loaded." ;
+};
+InfoBox MSG_ERR_NO_FAX
+{
+ Message [ en-US ] = "No fax printer has been set under Tools/Options/%1/Print." ;
+};
+String STR_WEBOPTIONS
+{
+ Text [ en-US ] = "HTML document";
+};
+String STR_TEXTOPTIONS
+{
+ Text [ en-US ] = "Text document";
+};
+InfoBox MSG_NOT_FOUND
+{
+ Message [ en-US ] = "Search key not found." ;
+};
+InfoBox MSG_INDEX_OVERFLOW
+{
+ Message [ en-US ] = "found." ;
+};
+InfoBox MSG_SCAN_NOSOURCE
+{
+ Message [ en-US ] = "Source not specified." ;
+};
+String STR_NUM_LEVEL
+{
+ Text [ en-US ] = "Level " ;
+};
+//#outline level,zhaojianwei
+String STR_NUM_OUTLINE
+{
+ Text [ en-US ] = "Outline ";
+};//<-end,zhaojianwei
+// <--
+String STR_ERROR_NOLANG
+{
+ Text [ en-US ] = "No language is selected in the proofed section." ;
+};
+String STR_EDIT_FOOTNOTE
+{
+ Text [ en-US ] = "Edit Footnote/Endnote" ;
+};
+String STR_NB_REPLACED
+{
+ Text [ en-US ] = "Search key replaced XX times." ;
+};
+String RID_TOOLS_TOOLBOX
+{
+ Text [ en-US ] = "Main Toolbar" ;
+};
+String STR_SRCVIEW_ROW
+{
+ Text [ en-US ] = "Row " ;
+};
+String STR_SRCVIEW_COL
+{
+ Text [ en-US ] = "Column " ;
+};
+String STR_PRINT_TITLE
+{
+ Text [ en-US ] = "Printing selection";
+};
+String STR_PRINT_MSG
+{
+ Text [ en-US ] = "Do you want to print the selection or the entire document?";
+};
+String STR_PRINT_ALL
+{
+ Text [ en-US ] = "All";
+};
+String STR_PRINT_SELECTION
+{
+ Text [ en-US ] = "Selection";
+};
+String STR_READONLY_SEL
+{
+ Text [ en-US ] = "read-only";
+};
+String STR_SAVEAS_SRC
+{
+ Text [ en-US ] = "~Export source..." ;
+};
+String MN_SRCVIEW_POPUPMENU
+{
+ Text [ en-US ] = "HTML source" ;
+};
+
+ToolBox RID_TOOLS_TOOLBOX
+{
+ HelpID = HID_TOOLS_TOOLBOX ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ LineSpacing = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ Customize = TRUE ;
+ MenuStrings = TRUE ;
+ Scroll = TRUE ;
+ Align = BOXALIGN_LEFT ;
+ Hide = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_CTRL ;
+ HelpID = HID_INSERT_CTRL ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_FIELD_CTRL ;
+ HelpID = HID_INSERT_FIELD_CTRL ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_OBJ_CTRL ;
+ HelpID = HID_INSERT_OBJ_CTRL ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ ITEM_TOOLBAR_INSERT_DRAW
+ };
+ ToolBoxItem
+ {
+ ITEM_FORM_CONFIG
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_GLOSSARY_DLG ;
+ HelpID = FN_GLOSSARY_DLG ;
+ DropDown = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_CAPTION;
+ HelpID = FN_INSERT_CAPTION ;
+ Hide = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_IDX_ENTRY_DLG;
+ HelpId = FN_INSERT_IDX_ENTRY_DLG;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_INSERT_REF_FIELD;
+ HelpID = FN_INSERT_REF_FIELD ;
+ Hide = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SHADOWCURSOR ;
+ HelpID = FN_SHADOWCURSOR ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_SPELL_GRAMMAR_DIALOG;
+ HelpID = FN_SPELL_GRAMMAR_DIALOG;
+ };
+ ToolBoxItem
+ {
+ ITEM_TOOLBAR_AUTOSPELL_CHECK
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_HYPHENATE_OPT_DLG;
+ HelpID = FN_HYPHENATE_OPT_DLG;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_THESAURUS;
+ HelpID = SID_THESAURUS;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_SEARCH_DLG ;
+ HelpID = SID_SEARCH_DLG ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_VIEW_DATA_SOURCE_BROWSER ;
+ HelpID = SID_VIEW_DATA_SOURCE_BROWSER ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_ZOOM;
+ HelpID = SID_ATTR_ZOOM ;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_VIEW_META_CHARS ;
+ HelpID = FN_VIEW_META_CHARS ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_VIEW_FIELDNAME ;
+ HelpID = FN_VIEW_FIELDNAME ;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = FN_VIEW_GRAPHIC ;
+ HelpID = FN_VIEW_GRAPHIC ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_BROWSER_MODE ;
+ HelpID = SID_BROWSER_MODE ;
+ };
+ };
+};
+Menu MN_SRCVIEW_POPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SOURCEVIEW ;
+ HelpID = HID_SOURCEVIEW ;
+ Text [ en-US ] = "HTML Source" ;
+ };
+ };
+};
diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx
new file mode 100644
index 000000000000..9d905a4c3443
--- /dev/null
+++ b/sw/source/ui/uiview/view0.cxx
@@ -0,0 +1,562 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "hintids.hxx"
+#include <vcl/graph.hxx>
+#include <svx/galbrws.hxx>
+#include <svl/srchitem.hxx>
+#include <SwSpellDialogChildWindow.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/linguprops.hxx>
+#include <unotools/lingucfg.hxx>
+#include <viewopt.hxx>
+#include <globals.h>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <svx/srchdlg.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <uivwimp.hxx>
+#include <avmedia/mediaplayer.hxx>
+#include <swmodule.hxx>
+
+#include <sfx2/objface.hxx>
+#include <navipi.hxx>
+#include <wrtsh.hxx>
+#include "doc.hxx"
+#include "view.hxx"
+#include "basesh.hxx"
+#include "docsh.hxx"
+#include "globals.hrc"
+#include "cmdid.h" // FN_ ...
+#include "globdoc.hxx"
+#include "wview.hxx"
+#include "shells.hrc"
+
+#define OLEObjects
+#define SwView
+#define SearchAttributes
+#define ReplaceAttributes
+#define SearchSettings
+#define _ExecSearch ExecSearch
+#define _StateSearch StateSearch
+#define Frames
+#define Graphics
+#define Tables
+#define Controls
+#define GlobalContents
+#define Text
+#define Frame
+#define Graphic
+#define Object
+#define Draw
+#define TextDrawText
+#define TextInTable
+#define ListInText
+#define ListInTable
+#define WebTextInTable
+#define WebListInText
+#define WebListInTable
+#define TextPage
+#include <sfx2/msg.hxx>
+#include <svx/svxslots.hxx>
+#include "swslots.hxx"
+#include <PostItMgr.hxx>
+
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+#include <unotools/moduleoptions.hxx>
+
+#include <IDocumentSettingAccess.hxx>
+
+#include <unomid.h>
+
+
+SFX_IMPL_VIEWFACTORY(SwView, SW_RES(STR_NONAME))
+{
+ if ( SvtModuleOptions().IsWriter() )
+ {
+ SFX_VIEW_REGISTRATION(SwDocShell);
+ SFX_VIEW_REGISTRATION(SwGlobalDocShell);
+ }
+}
+
+SFX_IMPL_INTERFACE( SwView, SfxViewShell, SW_RES(RID_TOOLS_TOOLBOX) )
+{
+ SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR);
+ SFX_CHILDWINDOW_REGISTRATION(SID_TASKPANE);
+ SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(FN_REDLINE_ACCEPT);
+ SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG);
+ SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(::avmedia::MediaPlayer::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD_DATA_ONLY);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_SYNC_LABELS, CHILDWIN_LABEL );
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_CHILDWINDOW, CHILDWIN_MAILMERGE);
+// SFX_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_SENDMAIL_CHILDWINDOW);
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
+ SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SW_RES(RID_TOOLS_TOOLBOX) );
+}
+
+TYPEINIT1(SwView,SfxViewShell)
+
+/*-----------------13.12.97 11:06-------------------
+
+--------------------------------------------------*/
+ShellModes SwView::GetShellMode()
+{
+ return pViewImpl->GetShellMode();
+}
+
+/*-----------------13.12.97 11:28-------------------
+
+--------------------------------------------------*/
+view::XSelectionSupplier* SwView::GetUNOObject()
+{
+ return pViewImpl->GetUNOObject();
+}
+/* -----------------------------06.05.2002 13:18------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
+{
+ pWrtShell->ApplyAccessiblityOptions(rAccessibilityOptions);
+ //to enable the right state of the selection cursor in readonly documents
+ if(GetDocShell()->IsReadOnly())
+ pWrtShell->ShowCrsr();
+
+}
+/*-- 26.05.2004 09:14:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SwView::SetMailMergeConfigItem(SwMailMergeConfigItem* pConfigItem,
+ sal_uInt16 nRestart, sal_Bool bIsSource)
+{
+ pViewImpl->SetMailMergeConfigItem(pConfigItem, nRestart, bIsSource);
+ UIFeatureChanged();
+}
+/*-- 26.05.2004 09:14:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SwMailMergeConfigItem* SwView::GetMailMergeConfigItem()
+{
+ return pViewImpl->GetMailMergeConfigItem();
+}
+/*-- 26.05.2004 09:14:25---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_uInt16 SwView::GetMailMergeRestartPage() const
+{
+ return pViewImpl->GetMailMergeRestartPage();
+}
+/*-- 03.09.2004 11:56:33---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool SwView::IsMailMergeSourceView() const
+{
+ return pViewImpl->IsMailMergeSourceView();
+}
+/*-- 12.04.2006 11:51:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool lcl_IsViewMarks( const SwViewOption& rVOpt )
+{
+ return rVOpt.IsHardBlank() &&
+ rVOpt.IsSoftHyph() &&
+ SwViewOption::IsFieldShadings();
+}
+void lcl_SetViewMarks(SwViewOption& rVOpt, sal_Bool bOn )
+{
+ rVOpt.SetHardBlank(bOn);
+ rVOpt.SetSoftHyph(bOn);
+ SwViewOption::SetAppearanceFlag(
+ VIEWOPT_FIELD_SHADINGS, bOn, TRUE);
+}
+
+void lcl_SetViewMetaChars( SwViewOption& rVOpt, sal_Bool bOn)
+{
+ rVOpt.SetViewMetaChars( bOn );
+ if(bOn && !(rVOpt.IsParagraph() ||
+ rVOpt.IsTab() ||
+ rVOpt.IsLineBreak() ||
+ rVOpt.IsShowHiddenChar() ||
+ rVOpt.IsBlank()))
+ {
+ rVOpt.SetParagraph(bOn);
+ rVOpt.SetTab(bOn);
+ rVOpt.SetLineBreak(bOn);
+ rVOpt.SetBlank(bOn);
+ rVOpt.SetShowHiddenChar(bOn);
+ }
+}
+
+/*--------------------------------------------------------------------
+ State of view options
+ --------------------------------------------------------------------*/
+void SwView::StateViewOptions(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SfxBoolItem aBool;
+ const SwViewOption* pOpt = GetWrtShell().GetViewOptions();
+ const IDocumentSettingAccess* pIDSA = GetDocShell()->getIDocumentSettingAccess();
+
+ while(nWhich)
+ {
+ sal_Bool bReadonly = GetDocShell()->IsReadOnly();
+ sal_Bool bBrowse = pIDSA ? pIDSA->get( IDocumentSettingAccess::BROWSE_MODE ) : sal_False;
+ if ( bReadonly && nWhich != FN_VIEW_GRAPHIC )
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ switch(nWhich)
+ {
+ case FN_RULER:
+ {
+ if(!pOpt->IsViewHRuler(TRUE) && !pOpt->IsViewVRuler(TRUE))
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( pOpt->IsViewAnyRuler());
+ }
+ break;
+ case FN_VIEW_BOUNDS:
+ aBool.SetValue( SwViewOption::IsDocBoundaries()); break;
+ case FN_VIEW_GRAPHIC:
+ aBool.SetValue( !pOpt->IsGraphic() ); break;
+ case FN_VIEW_FIELDS:
+ aBool.SetValue( SwViewOption::IsFieldShadings() ); break;
+ case FN_VIEW_FIELDNAME:
+ aBool.SetValue( pOpt->IsFldName() ); break;
+ case FN_VIEW_MARKS:
+ aBool.SetValue( lcl_IsViewMarks(*pOpt) ); break;
+ case FN_VIEW_META_CHARS:
+ aBool.SetValue( pOpt->IsViewMetaChars() ); break;
+ case FN_VIEW_TABLEGRID:
+ aBool.SetValue( SwViewOption::IsTableBoundaries() ); break;
+ case FN_VIEW_NOTES:
+ {
+ aBool.SetValue( pOpt->IsPostIts());
+ if (!GetPostItMgr()->HasNotes())
+ {
+ aBool.SetWhich( nWhich );
+ rSet.Put( aBool );
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ break;
+ }
+ case FN_VIEW_HIDDEN_PARA:
+ aBool.SetValue( pOpt->IsShowHiddenPara()); break;
+ case SID_GRID_VISIBLE:
+ aBool.SetValue( pOpt->IsGridVisible() ); break;
+ case SID_GRID_USE:
+ aBool.SetValue( pOpt->IsSnap() ); break;
+ case SID_HELPLINES_MOVE:
+ aBool.SetValue( pOpt->IsCrossHair() ); break;
+ case FN_VIEW_SMOOTH_SCROLL:
+ aBool.SetValue( pOpt->IsSmoothScroll()); break;
+ case FN_VLINEAL:
+ aBool.SetValue( 0 != StatVLineal() ); break;
+ case FN_HSCROLLBAR:
+ if(bBrowse)
+ {
+ rSet.DisableItem(nWhich);
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( IsHScrollbarVisible() ); break;
+ case FN_VSCROLLBAR:
+ aBool.SetValue( IsVScrollbarVisible() ); break;
+ case SID_AUTOSPELL_CHECK:
+ aBool.SetValue( pOpt->IsOnlineSpell() );
+ break;
+ case FN_SHADOWCURSOR:
+ if (pIDSA == 0 || pIDSA->get( IDocumentSettingAccess::BROWSE_MODE ))
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = 0;
+ }
+ else
+ aBool.SetValue( pOpt->IsShadowCursor() );
+ break;
+
+ }
+
+ if( nWhich )
+ {
+ aBool.SetWhich( nWhich );
+ rSet.Put( aBool );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/*--------------------------------------------------------------------
+ execute view options
+ --------------------------------------------------------------------*/
+void SwView::ExecViewOptions(SfxRequest &rReq)
+{
+ SwViewOption* pOpt = new SwViewOption( *GetWrtShell().GetViewOptions() );
+ sal_Bool bModified = GetWrtShell().IsModified();
+
+ int eState = STATE_TOGGLE;
+ sal_Bool bSet = sal_False;
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ const SfxPoolItem* pAttr=NULL;
+
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlot , sal_False, &pAttr ))
+ {
+ bSet = ((SfxBoolItem*)pAttr)->GetValue();
+ eState = bSet ? STATE_ON : STATE_OFF;
+ }
+
+ BOOL bFlag = STATE_ON == eState;
+ uno::Reference< beans::XPropertySet > xLngProp( ::GetLinguPropertySet() );
+
+ switch ( nSlot )
+ {
+ case FN_VIEW_GRAPHIC:
+
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsGraphic();
+ pOpt->SetGraphic( bFlag );
+ break;
+
+ case FN_VIEW_FIELDS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsFieldShadings() ;
+ SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bFlag, TRUE );
+ break;
+
+ case FN_VIEW_BOUNDS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsDocBoundaries();
+ SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bFlag, TRUE );
+ break;
+
+ case SID_GRID_VISIBLE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsGridVisible();
+
+ pOpt->SetGridVisible( bFlag );
+ break;
+
+ case SID_GRID_USE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsSnap();
+
+ pOpt->SetSnap( bFlag );
+ break;
+
+ case SID_HELPLINES_MOVE:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsCrossHair();
+
+ pOpt->SetCrossHair( bFlag );
+ break;
+
+ case FN_VIEW_NOTES:
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsPostIts();
+
+ GetPostItMgr()->SetLayout();
+ pOpt->SetPostIts( bFlag );
+ if (pOpt->IsPostIts())
+ GetPostItMgr()->CheckMetaText();
+ break;
+
+ case FN_VIEW_HIDDEN_PARA:
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsShowHiddenPara();
+
+ pOpt->SetShowHiddenPara( bFlag );
+ break;
+
+ case FN_VIEW_SMOOTH_SCROLL:
+
+ if ( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsSmoothScroll();
+
+ pOpt->SetSmoothScroll( bFlag );
+ break;
+
+
+ case FN_VLINEAL:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewVRuler();
+
+ pOpt->SetViewVRuler( bFlag );
+ break;
+
+ case FN_VSCROLLBAR:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewVScrollBar();
+
+ pOpt->SetViewVScrollBar( bFlag );
+ break;
+
+ case FN_HSCROLLBAR:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewHScrollBar();
+
+ pOpt->SetViewHScrollBar( bFlag );
+ break;
+ case FN_RULER:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewAnyRuler();
+
+ pOpt->SetViewAnyRuler( bFlag );
+ break;
+
+ case FN_VIEW_TABLEGRID:
+ if( STATE_TOGGLE == eState )
+ bFlag = !SwViewOption::IsTableBoundaries();
+ SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bFlag, TRUE );
+ break;
+
+ case FN_VIEW_FIELDNAME:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsFldName() ;
+
+ pOpt->SetFldName( bFlag );
+ break;
+ case FN_VIEW_MARKS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !lcl_IsViewMarks(*pOpt) ;
+
+ lcl_SetViewMarks( *pOpt, bFlag );
+ break;
+ case FN_VIEW_META_CHARS:
+ if( STATE_TOGGLE == eState )
+ bFlag = !pOpt->IsViewMetaChars();
+
+ lcl_SetViewMetaChars( *pOpt, bFlag );
+ break;
+ case SID_AUTOSPELL_CHECK:
+ if( STATE_TOGGLE == eState )
+ bFlag = bSet = !pOpt->IsOnlineSpell();
+
+ pOpt->SetOnlineSpell(bSet);
+ {
+ uno::Any aVal( &bSet, ::getCppuBooleanType() );
+ String aPropName( C2S(UPN_IS_SPELL_AUTO) );
+
+ SvtLinguConfig aCfg;
+ aCfg.SetProperty( aPropName, aVal );
+
+ if (xLngProp.is())
+ xLngProp->setPropertyValue( aPropName, aVal );
+
+ // for the time being we do not have a specific option for grammarchecking.
+ // thus we'll use the one for spell checking...
+ if (bSet)
+ {
+ SwDocShell *pDocSh = GetDocShell();
+ SwDoc *pDoc = pDocSh? pDocSh->GetDoc() : NULL;
+
+ // right now we don't have view options for automatic grammar checking. Thus...
+ sal_Bool bIsAutoGrammar = sal_False;
+ aCfg.GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
+
+ if (pDoc && bIsAutoGrammar)
+ StartGrammarChecking( *pDoc );
+ }
+ }
+ break;
+ case FN_SHADOWCURSOR:
+ if( STATE_TOGGLE == eState )
+ bFlag = bSet = !pOpt->IsShadowCursor();
+
+ pOpt->SetShadowCursor(bSet);
+ break;
+
+ default:
+ ASSERT(sal_False, Falsche Request-Methode);
+ return;
+ }
+
+ // UserPrefs setzen Request als bearbeitet kennzeichnen
+ sal_Bool bWebView = 0 != dynamic_cast<const SwWebView*>(this);
+ SwWrtShell &rSh = GetWrtShell();
+ rSh.StartAction();
+ SwModule* pModule = SW_MOD();
+ if( !(*rSh.GetViewOptions() == *pOpt ))
+ {
+ rSh.ApplyViewOptions( *pOpt );
+
+ //Die UsrPref muessen als Modified gekennzeichnet werden.
+ //call for initialization
+ pModule->GetUsrPref(bWebView);
+ pModule->CheckSpellChanges( pOpt->IsOnlineSpell(), sal_False, sal_False, sal_False );
+ }
+ //OS: Modified wieder zuruecksetzen, weil Ansicht/Felder
+ // das Doc modified setzt.
+ if( !bModified )
+ rSh.ResetModified();
+
+ pModule->ApplyUsrPref( *pOpt, this, bWebView ? VIEWOPT_DEST_WEB : VIEWOPT_DEST_TEXT );
+
+ //mod #i6193# let postits know about new spellcheck setting
+ if ( nSlot == SID_AUTOSPELL_CHECK )
+ GetPostItMgr()->SetSpellChecking();
+
+ const BOOL bLockedView = rSh.IsViewLocked();
+ rSh.LockView( TRUE ); //lock visible section
+ GetWrtShell().EndAction();
+ rSh.LockView( bLockedView );
+
+ delete pOpt;
+ Invalidate(rReq.GetSlot());
+ if(!pArgs)
+ rReq.AppendItem(SfxBoolItem(nSlot, (BOOL)bFlag));
+ rReq.Done();
+}
+
+IMPL_LINK( SwView, HtmlOptionsHdl, void*, EMPTYARG )
+{
+ // Invalidierung, falls blinkender Text erlaubt/verboten wurde
+ GetViewFrame()->GetBindings().Invalidate(SID_DRAW_TEXT_MARQUEE);
+ return 0;
+}
diff --git a/sw/source/ui/uiview/view1.cxx b/sw/source/ui/uiview/view1.cxx
new file mode 100644
index 000000000000..208a9c27ebdc
--- /dev/null
+++ b/sw/source/ui/uiview/view1.cxx
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/ruler.hxx>
+#include <idxmrk.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <viewopt.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _GLOBDOC_HXX
+#include <globdoc.hxx>
+#endif
+#include <navipi.hxx>
+#include <fldwrap.hxx>
+#ifndef _REDLNDLG_HXX
+#include <redlndlg.hxx>
+#endif
+#include <dpage.hxx>
+#include <edtwin.hxx>
+#include "formatclipboard.hxx"
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+// header for class SfxRequest
+#include <sfx2/request.hxx>
+
+#include <sfx2/viewfrm.hxx>
+
+extern int bDocSzUpdated;
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwView::Activate(BOOL bMDIActivate)
+{
+ // aktuelle View anmelden an der DocShell
+ // die View bleibt solange an der DocShell
+ // aktiv bis Sie zerstoert wird oder durch Activate eine
+ // neue gesetzt wird
+ SwDocShell* pDocSh = GetDocShell();
+ if(pDocSh)
+ pDocSh->SetView(this);
+ SwModule* pSwMod = SW_MOD();
+ pSwMod->SetView(this);
+
+ // Dokumentgroesse hat sich geaendert
+ if(!bDocSzUpdated)
+ DocSzChgd(aDocSz);
+
+ // #b6330459# make selection visible
+ if(bMakeSelectionVisible)
+ {
+ pWrtShell->MakeSelVisible();
+ bMakeSelectionVisible = sal_False;
+ }
+ pHRuler->SetActive( TRUE );
+ pVRuler->SetActive( TRUE );
+
+ if ( bMDIActivate )
+ {
+ pWrtShell->ShGetFcs(FALSE); // Selektionen sichtbar
+
+ if( sSwViewData.Len() )
+ {
+ ReadUserData( sSwViewData, FALSE );
+ sSwViewData.Erase();
+ }
+
+ AttrChangedNotify(pWrtShell);
+
+ // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
+ USHORT nId = SwFldDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
+ if (pWrp)
+ pWrp->ReInitDlg(GetDocShell());
+
+ // RedlineDlg ggf neu initialisieren
+ nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
+ if (pRed)
+ pRed->ReInitDlg(GetDocShell());
+
+ // reinit IdxMarkDlg
+ nId = SwInsertIdxMarkWrapper::GetChildWindowId();
+ SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
+ if (pIdxMrk)
+ pIdxMrk->ReInitDlg(*pWrtShell);
+
+ // reinit AuthMarkDlg
+ nId = SwInsertAuthMarkWrapper::GetChildWindowId();
+ SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
+ GetChildWindow(nId);
+ if (pAuthMrk)
+ pAuthMrk->ReInitDlg(*pWrtShell);
+ }
+ else
+ //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
+ AttrChangedNotify(pWrtShell);
+
+ SfxViewShell::Activate(bMDIActivate);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+void SwView::Deactivate(BOOL bMDIActivate)
+{
+ extern BOOL bFlushCharBuffer ;
+ // Befinden sich noch Zeichen im Input Buffer?
+ if( bFlushCharBuffer )
+ GetEditWin().FlushInBuffer();
+
+ if( bMDIActivate )
+ {
+ pWrtShell->ShLooseFcs(); // Selektionen unsichtbar
+
+ pHRuler->SetActive( FALSE );
+ pVRuler->SetActive( FALSE );
+ }
+ SfxViewShell::Deactivate(bMDIActivate);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwView::MarginChanged()
+{
+ GetWrtShell().SetBrowseBorder( GetMargin() );
+}
+
+/*--------------------------------------------------------------------
+ --------------------------------------------------------------------*/
+
+void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
+{
+ if(!pFormatClipboard)
+ return;
+
+ if( pFormatClipboard->HasContent() )
+ {
+ pFormatClipboard->Erase();
+
+ SwApplyTemplate aTemplate;
+ GetEditWin().SetApplyTemplate(aTemplate);
+ }
+ else
+ {
+ bool bPersistentCopy = false;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ {
+ bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
+ SID_FORMATPAINTBRUSH)).GetValue());
+ }
+
+ pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
+
+ SwApplyTemplate aTemplate;
+ aTemplate.pFormatClipboard = pFormatClipboard;
+ GetEditWin().SetApplyTemplate(aTemplate);
+ }
+ GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+}
+
+void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
+{
+ if(!pFormatClipboard)
+ return;
+
+ bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
+ rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
+ if(!bHasContent)
+ {
+ if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+ }
+}
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
new file mode 100755
index 000000000000..3a7003ff7bca
--- /dev/null
+++ b/sw/source/ui/uiview/view2.cxx
@@ -0,0 +1,2452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <svtools/filter.hxx>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
+
+#define _SVSTDARR_STRINGSSORTDTOR
+#include <svl/svstdarr.hxx>
+#include <svl/aeitem.hxx>
+
+#include <SwStyleNameMapper.hxx>
+#include <docary.hxx>
+#include <hintids.hxx>
+#include <SwRewriter.hxx>
+#include <undobj.hxx>
+#include <swundo.hxx>
+#include <caption.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/sfxdlg.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/sfxhelp.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/viewlayoutitem.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svtools/xwindowitem.hxx>
+#include <svx/htmlmode.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svtools/txtcmp.hxx>
+#include "editeng/unolingu.hxx"
+#include <vcl/msgbox.hxx>
+#include <editeng/tstpitem.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <editeng/sizeitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/whiter.hxx>
+#include <svl/ptitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <tools/errinf.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/svdview.hxx>
+#include <swtypes.hxx>
+#include <swwait.hxx>
+#include <redlndlg.hxx>
+#include <view.hxx>
+#include <uivwimp.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <basesh.hxx>
+#include <swmodule.hxx>
+#include <uitool.hxx>
+#include <shellio.hxx>
+#include <fmtinfmt.hxx>
+#include <mdiexp.hxx>
+#include <drawbase.hxx>
+#include <frmmgr.hxx>
+#include <pagedesc.hxx>
+#include <section.hxx>
+#include <usrpref.hxx>
+#include <IMark.hxx>
+#include <navipi.hxx>
+#include <tox.hxx>
+#include <workctrl.hxx>
+#include <scroll.hxx>
+#include <edtwin.hxx>
+#include <wview.hxx>
+#include <textsh.hxx>
+#include <tabsh.hxx>
+#include <listsh.hxx>
+#include <cmdid.h>
+#include <comcore.hrc>
+#include <poolfmt.hrc>
+#include <statstr.hrc>
+#include <swerror.h>
+#include <globals.hrc>
+#include <shells.hrc>
+#include <web.hrc>
+#include <view.hrc>
+#include <app.hrc>
+#include <fmtclds.hxx>
+#include <helpid.h>
+#include <svtools/templdlg.hxx>
+#include <dbconfig.hxx>
+#include <dbmgr.hxx>
+
+#include <PostItMgr.hxx>
+
+#include <ndtxt.hxx> //#outline level,added by zhaojianwei
+
+#include <comphelper/processfactory.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "swabstdlg.hxx"
+#include "globals.hrc"
+#include <envelp.hrc>
+#include <fmthdft.hxx>
+#include <svx/ofaitem.hxx>
+#include <unomid.h>
+
+const char __FAR_DATA sStatusDelim[] = " : ";
+const char __FAR_DATA sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
+
+using ::rtl::OUString;
+using namespace sfx2;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::scanner;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ui::dialogs;
+
+
+static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, USHORT nWhichId )
+{
+ if (nWhichId == RES_CHRATR_LANGUAGE ||
+ nWhichId == RES_CHRATR_CJK_LANGUAGE ||
+ nWhichId == RES_CHRATR_CTL_LANGUAGE)
+ {
+ rWrtSh.StartAction();
+ rWrtSh.LockView( TRUE );
+ rWrtSh.Push();
+
+ // prepare to apply new language to all text in document
+ rWrtSh.SelAll();
+ rWrtSh.ExtendedSelectAll();
+
+ // set language attribute to default for all text
+ SvUShortsSort aAttribs;
+ aAttribs.Insert( nWhichId );
+ rWrtSh.ResetAttr( &aAttribs );
+
+ rWrtSh.Pop( FALSE );
+ rWrtSh.LockView( FALSE );
+ rWrtSh.EndAction();
+ }
+}
+
+/*---------------------------------------------------------------------------
+ Beschreibung: String fuer die Seitenanzeige in der Statusbar basteln.
+ ----------------------------------------------------------------------------*/
+
+String SwView::GetPageStr( USHORT nPg, USHORT nLogPg,
+ const String& rDisplay )
+{
+ String aStr( aPageStr );
+ if( rDisplay.Len() )
+ aStr += rDisplay;
+ else
+ aStr += String::CreateFromInt32(nLogPg);
+
+ if( nLogPg && nLogPg != nPg )
+ {
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" "));
+ aStr += String::CreateFromInt32(nPg);
+ }
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
+ aStr += String::CreateFromInt32( GetWrtShell().GetPageCnt() );
+
+ return aStr;
+}
+
+
+int SwView::InsertGraphic( const String &rPath, const String &rFilter,
+ BOOL bLink, GraphicFilter *pFlt,
+ Graphic* pPreviewGrf, BOOL bRule )
+{
+ SwWait aWait( *GetDocShell(), TRUE );
+
+ Graphic aGrf;
+ int nRes = GRFILTER_OK;
+ if ( pPreviewGrf )
+ aGrf = *pPreviewGrf;
+ else
+ {
+ if( !pFlt )
+ pFlt = GraphicFilter::GetGraphicFilter();
+ nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ );
+ }
+
+ if( GRFILTER_OK == nRes )
+ {
+ SwFlyFrmAttrMgr aFrmMgr( TRUE, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
+
+ SwWrtShell &rSh = GetWrtShell();
+ rSh.StartAction();
+ if( bLink )
+ {
+ SwDocShell* pDocSh = GetDocShell();
+ INetURLObject aTemp(
+ pDocSh->HasName() ?
+ pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
+ rtl::OUString());
+
+ String sURL = URIHelper::SmartRel2Abs(
+ aTemp, rPath, URIHelper::GetMaybeFileHdl() );
+
+ rSh.Insert( sURL,
+ rFilter, aGrf, &aFrmMgr, bRule );
+ }
+ else
+ rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr );
+ // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
+ rSh.EndAction();
+ }
+ return nRes;
+}
+
+
+BOOL SwView::InsertGraphicDlg( SfxRequest& rReq )
+{
+#ifndef ENABLE_PROP_WITHOUTLINK
+#define ENABLE_PROP_WITHOUTLINK 0x08
+#endif
+
+ BOOL bReturn = FALSE;
+ SwDocShell* pDocShell = GetDocShell();
+ USHORT nHtmlMode = ::GetHtmlMode(pDocShell);
+ // im HTML-Mode nur verknuepft einfuegen
+ FileDialogHelper* pFileDlg = new FileDialogHelper( SFXWB_GRAPHIC | SFXWB_SHOWSTYLES );
+ pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
+ pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
+ uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
+ uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
+ if(nHtmlMode & HTMLMODE_ON)
+ {
+ sal_Bool bTrue = sal_True;
+ Any aVal(&bTrue, ::getBooleanCppuType());
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
+ xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
+ }
+
+ SvStringsSortDtor aFormats;
+ SwDoc* pDoc = pDocShell->GetDoc();
+ const USHORT nArrLen = pDoc->GetFrmFmts()->Count();
+ USHORT i;
+ for( i = 0; i < nArrLen; i++ )
+ {
+ SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ];
+ if(pFmt->IsDefault() || pFmt->IsAuto())
+ continue;
+ String *pFormat = new String(pFmt->GetName());
+ aFormats.Insert(pFormat);
+ }
+
+ // pool formats
+ //
+ const SvStringsDtor& rFrmPoolArr = SwStyleNameMapper::GetFrmFmtUINameArray();
+ for( i = 0; i < rFrmPoolArr.Count(); i++ )
+ {
+ String *pFormat = new String(*rFrmPoolArr[i]);
+ if (!aFormats.Insert(pFormat))
+ delete pFormat;
+ }
+
+ Sequence<OUString> aListBoxEntries(aFormats.Count());
+ OUString* pEntries = aListBoxEntries.getArray();
+ sal_Int16 nSelect = 0;
+ String sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
+ for(i = 0; i < aFormats.Count(); ++i)
+ {
+ pEntries[i] = *aFormats[i];
+ if(pEntries[i].equals(sGraphicFormat))
+ nSelect = i;
+ }
+ try
+ {
+ Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
+
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::ADD_ITEMS , aTemplates );
+
+ Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
+ xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("control acces failed");
+ }
+
+ SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , sal_False );
+ BOOL bShowError = !pName;
+ if( pName || ERRCODE_NONE == pFileDlg->Execute() )
+ {
+
+ String aFileName, aFilterName;
+ if ( pName )
+ {
+ aFileName = pName->GetValue();
+ SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , sal_False );
+ if ( pFilter )
+ aFilterName = pFilter->GetValue();
+ }
+ else
+ {
+ aFileName = pFileDlg->GetPath();
+ aFilterName = pFileDlg->GetCurrentFilter();
+ rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
+
+ sal_Bool bAsLink = sal_False;
+ if(nHtmlMode & HTMLMODE_ON)
+ bAsLink = sal_True;
+ else
+ {
+ try
+ {
+ Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
+ DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
+ bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
+ Any aTemplateValue = xCtrlAcc->getValue(
+ ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::GET_SELECTED_ITEM );
+ OUString sTmpl;
+ aTemplateValue >>= sTmpl;
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("control acces failed");
+ }
+ }
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
+ }
+
+ SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , sal_False );
+ SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , sal_False );
+
+ sal_Bool bAsLink = sal_False;
+ if( nHtmlMode & HTMLMODE_ON )
+ bAsLink = sal_True;
+ else
+ {
+ if ( rReq.GetArgs() )
+ {
+ if ( pAsLink )
+ bAsLink = pAsLink->GetValue();
+ if ( pStyle && pStyle->GetValue().Len() )
+ sGraphicFormat = pStyle->GetValue();
+ }
+ else
+ {
+ Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
+ DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
+ bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
+ Any aTemplateValue = xCtrlAcc->getValue(
+ ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
+ ListboxControlActions::GET_SELECTED_ITEM );
+ OUString sTmpl;
+ aTemplateValue >>= sTmpl;
+ if( sTmpl.getLength() )
+ sGraphicFormat = sTmpl;
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
+ }
+ }
+
+ SwWrtShell& rSh = GetWrtShell();
+ rSh.LockPaint();
+ rSh.StartAction();
+
+ /// #111827#
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME)));
+
+ rSh.StartUndo(UNDO_INSERT, &aRewriter);
+
+ int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() );
+
+ // Format ist ungleich Current Filter, jetzt mit auto. detection
+ if( nError == GRFILTER_FORMATERROR )
+ nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() );
+ if ( rSh.IsFrmSelected() )
+ {
+ SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
+ if(!pFmt)
+ pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
+ pDocShell->GetDoc()->GetDfltFrmFmt(),
+ TRUE, FALSE);
+ rSh.SetFrmFmt( pFmt );
+ }
+
+ RESOURCE_TYPE nResId = 0;
+ switch( nError )
+ {
+ case GRFILTER_OPENERROR:
+ nResId = STR_GRFILTER_OPENERROR;
+ break;
+ case GRFILTER_IOERROR:
+ nResId = STR_GRFILTER_IOERROR;
+ break;
+ case GRFILTER_FORMATERROR:
+ nResId = STR_GRFILTER_FORMATERROR;
+ break;
+ case GRFILTER_VERSIONERROR:
+ nResId = STR_GRFILTER_VERSIONERROR;
+ break;
+ case GRFILTER_FILTERERROR:
+ nResId = STR_GRFILTER_FILTERERROR;
+ break;
+ case GRFILTER_TOOBIG:
+ nResId = STR_GRFILTER_TOOBIG;
+ break;
+ }
+
+ rSh.EndAction();
+ rSh.UnlockPaint();
+ if( nResId )
+ {
+ if( bShowError )
+ {
+ InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId ));
+ aInfoBox.Execute();
+ }
+ rReq.Ignore();
+ }
+ else
+ {
+ // set the specific graphic attrbutes to the graphic
+ bReturn = TRUE;
+ AutoCaption( GRAPHIC_CAP );
+ rReq.Done();
+ }
+
+ rSh.EndUndo(UNDO_INSERT); // wegen moegl. Shellwechsel
+ }
+
+ delete pFileDlg;
+
+ return bReturn;
+}
+
+
+void __EXPORT SwView::Execute(SfxRequest &rReq)
+{
+ USHORT nSlot = rReq.GetSlot();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ BOOL bIgnore = FALSE;
+ switch( nSlot )
+ {
+ case SID_CREATE_SW_DRAWVIEW:
+ // --> OD 2005-08-08 #i52858# - method name changed
+ pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
+ // <--
+ break;
+
+ case FN_LINE_NUMBERING_DLG:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog( DLG_LINE_NUMBERING, *this);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ case FN_EDIT_LINK_DLG:
+ EditLinkDlg();
+ break;
+ case FN_REFRESH_VIEW:
+ GetEditWin().Invalidate();
+ break;
+ case FN_PAGEUP:
+ case FN_PAGEUP_SEL:
+ case FN_PAGEDOWN:
+ case FN_PAGEDOWN_SEL:
+ {
+ Rectangle aVis( GetVisArea() );
+ SwEditWin& rTmpWin = GetEditWin();
+ if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
+ PageUpCrsr(FN_PAGEUP_SEL == nSlot);
+ else
+ PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
+
+ rReq.SetReturnValue(SfxBoolItem(nSlot,
+ aVis != GetVisArea()));
+ //#i42732# - notify the edit window that from now on we do not use the input language
+ rTmpWin.SetUseInputLanguage( sal_False );
+ }
+ break;
+ case FN_REDLINE_ON:
+ {
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem ))
+ {
+ IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
+ Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
+ if( aPasswd.getLength() )
+ {
+ DBG_ASSERT( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
+ // xmlsec05: new password dialog
+ Window* pParent;
+ const SfxPoolItem* pParentItem;
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+ else
+ pParent = &GetViewFrame()->GetWindow();
+ SfxPasswordDialog aPasswdDlg( pParent );
+ aPasswdDlg.SetMinLen( 1 );
+ //#i69751# the result of Execute() can be ignored
+ aPasswdDlg.Execute();
+ String sNewPasswd( aPasswdDlg.GetPassword() );
+ Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
+ SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
+ if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
+ pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
+ else
+ { // xmlsec05: message box for wrong password
+ break;
+ }
+ }
+
+ USHORT nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0;
+ USHORT nMode = pWrtShell->GetRedlineMode();
+ pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+ }
+ }
+ break;
+ case FN_REDLINE_PROTECT :
+ {
+ IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
+ Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem )
+ && ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
+ break;
+
+ // xmlsec05: new password dialog
+ // message box for wrong password
+ Window* pParent;
+ const SfxPoolItem* pParentItem;
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+ else
+ pParent = &GetViewFrame()->GetWindow();
+ SfxPasswordDialog aPasswdDlg( pParent );
+ aPasswdDlg.SetMinLen( 1 );
+ if(!aPasswd.getLength())
+ aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
+ if (aPasswdDlg.Execute())
+ {
+ USHORT nOn = nsRedlineMode_t::REDLINE_ON;
+ String sNewPasswd( aPasswdDlg.GetPassword() );
+ Sequence <sal_Int8> aNewPasswd =
+ pIDRA->GetRedlinePassword();
+ SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
+ if(!aPasswd.getLength())
+ {
+ pIDRA->SetRedlinePassword(aNewPasswd);
+ }
+ else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
+ {
+ pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
+ nOn = 0;
+ }
+ USHORT nMode = pIDRA->GetRedlineMode();
+ pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
+ rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
+ }
+ else
+ bIgnore = TRUE;
+ }
+ break;
+ case FN_REDLINE_SHOW:
+
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem))
+ {
+ USHORT nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
+ & pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
+ if( ((const SfxBoolItem*)pItem)->GetValue() )
+ nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
+
+ pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
+ }
+ break;
+ case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
+ case FN_REDLINE_ACCEPT:
+ GetViewFrame()->ToggleChildWindow(nSlot);
+ break;
+ case FN_REDLINE_ACCEPT_DIRECT:
+ case FN_REDLINE_REJECT_DIRECT:
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
+ Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True );
+ if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) )
+ {
+ USHORT nCount = pWrtShell->GetRedlineCount();
+ for( USHORT nRedline = 0; nRedline < nCount; ++nRedline )
+ {
+ const SwRedline& rRedline = pWrtShell->GetRedline( nRedline );
+ if( *aCntntAtPos.aFnd.pRedl == rRedline )
+ {
+ if( FN_REDLINE_ACCEPT_DIRECT == nSlot )
+ pWrtShell->AcceptRedline( nRedline );
+ else
+ pWrtShell->RejectRedline( nRedline );
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case SID_DOCUMENT_COMPARE:
+ case SID_DOCUMENT_MERGE:
+ {
+ String sFileName, sFilterName;
+ INT16 nVersion = 0;
+ bool bHasFileName = false;
+ pViewImpl->SetParam( 0 );
+
+ if( pArgs )
+ {
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, FALSE, &pItem ))
+ sFileName = ((const SfxStringItem*)pItem)->GetValue();
+ bHasFileName = ( sFileName.Len() > 0 );
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, FALSE, &pItem ))
+ sFilterName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, FALSE, &pItem ))
+ {
+ nVersion = ((const SfxInt16Item *)pItem)->GetValue();
+ pViewImpl->SetParam( nVersion );
+ }
+ }
+
+ pViewImpl->InitRequest( rReq );
+ long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
+
+ if ( bHasFileName )
+ {
+ rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
+
+ if (nFound > 0) // Redline-Browser anzeigen
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
+
+ // RedlineDlg neu initialisieren
+ USHORT nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)
+ pVFrame->GetChildWindow(nId);
+ if (pRed)
+ pRed->ReInitDlg(GetDocShell());
+ }
+ }
+ else
+ bIgnore = TRUE;
+ }
+ break;
+ case FN_SYNC_LABELS:
+ case FN_MAILMERGE_CHILDWINDOW:
+ GetViewFrame()->ShowChildWindow(nSlot, TRUE);
+ break;
+ case FN_ESCAPE:
+ {
+ if ( pWrtShell->HasDrawView() && pWrtShell->GetDrawView()->IsDragObj() )
+ {
+ pWrtShell->BreakDrag();
+ pWrtShell->EnterSelFrmMode();
+ }
+ else if ( pWrtShell->IsDrawCreate() )
+ {
+ GetDrawFuncPtr()->BreakCreate();
+ AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
+ }
+ else if ( pWrtShell->HasSelection() || IsDrawMode() )
+ {
+ SdrView *pSdrView = pWrtShell->HasDrawView() ? pWrtShell->GetDrawView() : 0;
+ if(pSdrView && pSdrView->AreObjectsMarked() &&
+ pSdrView->GetHdlList().GetFocusHdl())
+ {
+ ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
+ }
+ else
+ {
+ if(pSdrView)
+ {
+ LeaveDrawCreate();
+ Point aPt(LONG_MIN, LONG_MIN);
+ //go out of the frame
+ pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( SID_ATTR_SIZE );
+ }
+ pWrtShell->EnterStdMode();
+ AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
+ }
+ }
+ else if ( GetEditWin().GetApplyTemplate() )
+ {
+ GetEditWin().SetApplyTemplate(SwApplyTemplate());
+ }
+ else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() )
+ {
+ Escape();
+ }
+ else if ( GetEditWin().IsChainMode() )
+ {
+ GetEditWin().SetChainMode( FALSE );
+ }
+ else if( pWrtShell->GetFlyFrmFmt() )
+ {
+ const SwFrmFmt* pFmt = pWrtShell->GetFlyFrmFmt();
+ if(pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM ))
+ {
+ pWrtShell->HideCrsr();
+ pWrtShell->EnterSelFrmMode();
+ }
+ }
+ else
+ {
+ SfxBoolItem aItem( SID_WIN_FULLSCREEN, FALSE );
+ GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
+ bIgnore = TRUE;
+ }
+ }
+ break;
+ case SID_ATTR_BORDER_INNER:
+ case SID_ATTR_BORDER_OUTER:
+ case SID_ATTR_BORDER_SHADOW:
+ if(pArgs)
+ pWrtShell->SetAttr(*pArgs);
+ break;
+
+ case SID_ATTR_PAGE:
+ case SID_ATTR_PAGE_SIZE:
+ case SID_ATTR_PAGE_MAXSIZE:
+ case SID_ATTR_PAGE_PAPERBIN:
+ case SID_ATTR_PAGE_EXT1:
+ case FN_PARAM_FTN_INFO:
+ {
+ if(pArgs)
+ {
+ const USHORT nCurIdx = pWrtShell->GetCurPageDesc();
+ SwPageDesc aPageDesc( pWrtShell->GetPageDesc( nCurIdx ) );
+ ::ItemSetToPageDesc( *pArgs, aPageDesc );
+ // Den Descriptor der Core veraendern.
+ pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
+ }
+ }
+ break;
+ case FN_NAVIGATION_PI_GOTO_PAGE:
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+ if(!pCh)
+ {
+ pVFrame->ToggleChildWindow( SID_NAVIGATOR );
+ pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
+
+ }
+ ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage();
+ }
+ break;
+ case FN_EDIT_CURRENT_TOX:
+ {
+ GetViewFrame()->GetDispatcher()->Execute(
+ FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON);
+ }
+ break;
+ case FN_UPDATE_CUR_TOX:
+ {
+ const SwTOXBase* pBase = pWrtShell->GetCurTOX();
+ if(pBase)
+ {
+ pWrtShell->StartAction();
+ if(TOX_INDEX == pBase->GetType())
+ pWrtShell->ApplyAutoMark();
+ pWrtShell->UpdateTableOf( *pBase );
+ pWrtShell->EndAction();
+ }
+ }
+ break;
+ case FN_UPDATE_TOX:
+ {
+ pWrtShell->StartAction();
+ pWrtShell->EnterStdMode();
+ BOOL bOldCrsrInReadOnly = pWrtShell->IsReadOnlyAvailable();
+ pWrtShell->SetReadOnlyAvailable( TRUE );
+
+ for( USHORT i = 0; i < 2; ++i )
+ {
+ USHORT nCount = pWrtShell->GetTOXCount();
+ if( 1 == nCount )
+ ++i;
+
+ while( pWrtShell->GotoPrevTOXBase() )
+ ; // aufs erste Verzeichnis springen
+
+ // falls wir nicht mehr in einem stehen, dann zum naechsten
+ // springen.
+ const SwTOXBase* pBase = pWrtShell->GetCurTOX();
+ if( !pBase )
+ {
+ pWrtShell->GotoNextTOXBase();
+ pBase = pWrtShell->GetCurTOX();
+ }
+
+ BOOL bAutoMarkApplied = FALSE;
+ while( pBase )
+ {
+ if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
+ {
+ pWrtShell->ApplyAutoMark();
+ bAutoMarkApplied = TRUE;
+ }
+ // JP 15.07.96: das pBase wird nur fuer die Schnittstelle
+ // benoetigt. Muss mal umgetstellt werden!!!
+ pWrtShell->UpdateTableOf( *pBase );
+
+ if( pWrtShell->GotoNextTOXBase() )
+ pBase = pWrtShell->GetCurTOX();
+ else
+ pBase = 0;
+ }
+ }
+ pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
+ pWrtShell->EndAction();
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, FALSE, &pItem))
+ {
+ const USHORT nCurIdx = pWrtShell->GetCurPageDesc();
+ SwPageDesc aDesc( pWrtShell->GetPageDesc( nCurIdx ));
+ SwFrmFmt& rMaster = aDesc.GetMaster();
+ rMaster.SetFmtAttr(*pItem);
+ pWrtShell->ChgPageDesc( nCurIdx, aDesc);
+ }
+ }
+ break;
+ case SID_CLEARHISTORY:
+ {
+ pWrtShell->DelAllUndoObj();
+ }
+ break;
+ case SID_UNDO:
+ {
+ pShell->ExecuteSlot(rReq);
+ }
+ break;
+ case FN_INSERT_CTRL:
+ case FN_INSERT_OBJ_CTRL:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem))
+ {
+ USHORT nValue = ((SfxUInt16Item*)pItem)->GetValue();
+ switch ( nSlot )
+ {
+ case FN_INSERT_CTRL:
+ {
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ if(bWeb)
+ SwView::nWebInsertCtrlState = nValue;
+ else
+ SwView::nInsertCtrlState = nValue;
+ }
+ break;
+ case FN_INSERT_OBJ_CTRL: SwView::nInsertObjectCtrlState = nValue ;break;
+ }
+
+ }
+ GetViewFrame()->GetBindings().Invalidate( nSlot );
+ }
+ break;
+#if defined WIN || defined WNT || defined UNX
+ case SID_TWAIN_SELECT:
+ case SID_TWAIN_TRANSFER:
+ GetViewImpl()->ExecuteScan( rReq );
+ break;
+#endif
+
+ case SID_ATTR_DEFTABSTOP:
+ {
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, FALSE, &pItem))
+ {
+ SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
+ USHORT nTab = ((const SfxUInt16Item*)pItem)->GetValue();
+ MakeDefTabs( nTab, aDefTabs );
+ pWrtShell->SetDefault( aDefTabs );
+ }
+ }
+ break;
+ case SID_ATTR_LANGUAGE :
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, FALSE, &pItem))
+ {
+ SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
+ pWrtShell->SetDefault( aLang );
+ lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_LANGUAGE );
+ }
+ break;
+ case SID_ATTR_CHAR_CTL_LANGUAGE:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, FALSE, &pItem))
+ {
+ pWrtShell->SetDefault( *pItem );
+ lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CTL_LANGUAGE );
+ }
+ break;
+ case SID_ATTR_CHAR_CJK_LANGUAGE:
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, FALSE, &pItem))
+ {
+ pWrtShell->SetDefault( *pItem );
+ lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CJK_LANGUAGE );
+ }
+ break;
+ case FN_SCROLL_NEXT_PREV:
+ if(pArgs && pArgs->GetItemState(FN_SCROLL_NEXT_PREV, FALSE, &pItem))
+ {
+ // call the handlers of PageUp/DownButtons, only
+ bool* pbNext = new bool ( ((const SfxBoolItem*)pItem)->GetValue() );
+ // #i75416# move the execution of the search to an asynchronously called static link
+ Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
+ }
+ break;
+ case SID_JUMPTOMARK:
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, FALSE, &pItem))
+ JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() );
+ break;
+ case SID_GALLERY :
+ GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_GALLERY);
+ break;
+ case SID_AVMEDIA_PLAYER :
+ GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_AVMEDIA_PLAYER);
+ break;
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ChildWindowExecute(rReq);
+ if(pVFrame->HasChildWindow(SID_BROWSER))
+ {
+ const SwDBData& rData = GetWrtShell().GetDBDesc();
+ SW_MOD()->ShowDBObj(*this, rData, FALSE);
+ }
+ }
+ break;
+ case FN_INSERT_FIELD_DATA_ONLY :
+ {
+ BOOL bShow = FALSE;
+ if( pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem ))
+ bShow = ((const SfxBoolItem*)pItem)->GetValue();
+ //GetViewFrame()->ShowChildWindow(nSlot, bShow && bInMailMerge);
+ if((bShow && bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
+ GetViewFrame()->ToggleChildWindow(nSlot);
+ //if fields have been succesfully inserted call the "real"
+ //mail merge dialog
+ SwWrtShell &rSh = GetWrtShell();
+ if(bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
+ {
+ SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
+ if (pNewDBMgr)
+ {
+ SwDBData aData;
+ aData = rSh.GetDBData();
+ rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
+ // das Mischen von DB-Feldern notwendig.
+ AttrChangedNotify( &rSh );
+ pNewDBMgr->SetMergeType( DBMGR_MERGE );
+
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pValues = aProperties.getArray();
+ pValues[0].Name = C2U("DataSourceName");
+ pValues[1].Name = C2U("Command");
+ pValues[2].Name = C2U("CommandType");
+ pValues[0].Value <<= aData.sDataSource;
+ pValues[1].Value <<= aData.sCommand;
+ pValues[2].Value <<= aData.nCommandType;
+ pNewDBMgr->ExecuteFormLetter(rSh, aProperties, TRUE);
+ }
+ }
+ bInMailMerge &= bShow;
+ GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
+ }
+ break;
+ case FN_QRY_MERGE:
+ {
+ BOOL bUseCurrentDocument = TRUE;
+ BOOL bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot);
+ if(bQuery)
+ {
+ SfxViewFrame* pTmpFrame = GetViewFrame();
+ SfxHelp::OpenHelpAgent( &pTmpFrame->GetFrame(), HID_MAIL_MERGE_SELECT );
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE,
+ &pTmpFrame->GetWindow());
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if(RET_OK == pDlg->Execute())
+ bUseCurrentDocument = pDlg->IsThisDocument();
+ else
+ break;
+ }
+ GenerateFormLetter(bUseCurrentDocument);
+ }
+ break;
+ case SID_RECHECK_DOCUMENT:
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
+ if( xGCIterator.is() )
+ {
+ xGCIterator->resetIgnoreRules();
+ }
+ // reset ignore lists
+ pDoc->SpellItAgainSam( sal_True, sal_False, sal_False );
+ // clear ignore dictionary
+ uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
+ if( xDictionary.is() )
+ xDictionary->clear();
+ // put cursor to the start of the document
+ pWrtShell->SttDoc();
+ }
+ // no break; - but call spell/grammar dialog
+ case FN_SPELL_GRAMMAR_DIALOG:
+ {
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if (rReq.GetArgs() != NULL)
+ pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
+ else
+ pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
+
+ pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
+ rReq.Ignore ();
+ }
+ break;
+ case SID_ALIGN_ANY_LEFT :
+ case SID_ALIGN_ANY_HCENTER :
+ case SID_ALIGN_ANY_RIGHT :
+ case SID_ALIGN_ANY_JUSTIFIED:
+ case SID_ALIGN_ANY_TOP :
+ case SID_ALIGN_ANY_VCENTER :
+ case SID_ALIGN_ANY_BOTTOM :
+ case SID_ALIGN_ANY_HDEFAULT :
+ case SID_ALIGN_ANY_VDEFAULT :
+ {
+ USHORT nAlias = 0;
+ if( nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
+ {
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
+ case SID_ALIGN_ANY_TOP : nAlias = FN_TABLE_VERT_NONE; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = FN_TABLE_VERT_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = FN_TABLE_VERT_BOTTOM; break;
+ }
+ }
+ else
+ {
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
+ }
+ }
+ //special handling for the draw shell
+ if(nAlias && (nSelectionType & (nsSelectionType::SEL_DRW)))
+ {
+ SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L);
+ }
+ else if(nAlias)
+ //these slots are either re-mapped to text or object alignment
+ GetViewFrame()->GetDispatcher()->Execute(
+ nAlias, SFX_CALLMODE_ASYNCHRON);
+ }
+ break;
+ case SID_RESTORE_EDITING_VIEW:
+ {
+ //#i33307# restore editing position
+ Point aCrsrPos;
+ bool bSelectObj;
+ if(pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
+ {
+ pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+ if( bSelectObj )
+ {
+ pWrtShell->SelectObj( aCrsrPos );
+ pWrtShell->EnterSelFrmMode( &aCrsrPos );
+ }
+ }
+ }
+ break;
+ case SID_INSERT_GRAPHIC:
+ {
+ rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
+ }
+ break;
+
+
+ default:
+ ASSERT(!this, falscher Dispatcher);
+ return;
+ }
+ if(!bIgnore)
+ rReq.Done();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: SeitenNr-Feld invalidieren
+ --------------------------------------------------------------------*/
+
+void SwView::UpdatePageNums(USHORT nPhyNum, USHORT nVirtNum, const String& rPgStr)
+{
+ String sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
+ const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.SetState( aTmp );
+ rBnd.Update( FN_STAT_PAGE );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Status der Stauszeile
+ --------------------------------------------------------------------*/
+
+
+void SwView::StateStatusLine(SfxItemSet &rSet)
+{
+ SwWrtShell& rShell = GetWrtShell();
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ ASSERT( nWhich, "leeres Set");
+
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case FN_STAT_PAGE:
+/*
+//JP 07.01.00: is a nice feature - show the selektion of DrawObjects
+ if( rShell.IsObjSelected()
+//??? || rShell.IsFrmSelected()
+ )
+ {
+ String sDisplay( rShell.GetDrawView()->GetMarkedObjectList().
+ GetDescriptionOfMarkedObjects() );
+ rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay ));
+ }
+ else
+*/ {
+ // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
+ USHORT nPage, nLogPage;
+ String sDisplay;
+ rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
+ rSet.Put( SfxStringItem( FN_STAT_PAGE,
+ GetPageStr( nPage, nLogPage, sDisplay) ));
+
+ USHORT nCnt = GetWrtShell().GetPageCnt();
+ if (nPageCnt != nCnt) // Basic benachrichtigen
+ {
+ nPageCnt = nCnt;
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), FALSE);
+ }
+ }
+ break;
+ case FN_STAT_TEMPLATE:
+ {
+ rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
+ rShell.GetCurPageStyle(FALSE)));
+
+ }
+ break;
+ case SID_ATTR_ZOOM:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
+ SvxZoomItem aZoom(eZoom, pVOpt->GetZoom());
+ if(pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ }
+ rSet.Put( aZoom );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_ZOOM );
+ }
+ break;
+ case SID_ATTR_VIEWLAYOUT:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ const USHORT nColumns = pVOpt->GetViewLayoutColumns();
+ const bool bBookMode = pVOpt->IsViewLayoutBookMode();
+ SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
+ rSet.Put( aViewLayout );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SwViewOption* pVOpt = rShell.GetViewOptions();
+ const USHORT nCurrentZoom = pVOpt->GetZoom();
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+
+ if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ {
+ const USHORT nColumns = pVOpt->GetViewLayoutColumns();
+ const bool bAutomaticViewLayout = 0 == nColumns;
+ const SwPostItMgr* pMgr = GetPostItMgr();
+
+ // snapping points:
+ // automatic mode: 1 Page, 2 Pages, 100%
+ // n Columns mode: n Pages, 100%
+ // n Columns book mode: nPages without gaps, 100%
+ const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
+ const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
+ Size aPageSize( aPageRect.SSize() );
+ aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
+ pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
+ 0;
+
+ Size aRootSize( aRootRect.SSize() );
+
+ const MapMode aTmpMap( MAP_TWIP );
+ const Size& rEditSize = GetEditWin().GetOutputSizePixel();
+ const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
+
+ const long nOf = DOCUMENTBORDER * 2L;
+ long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nTmpWidth += nOf;
+ aPageSize.Height() += nOf;
+ long nFac = aWindowSize.Width() * 100 / nTmpWidth;
+
+ long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
+ nFac = Min( nFac, nVisPercent );
+
+ aZoomSliderItem.AddSnappingPoint( nFac );
+
+ if ( bAutomaticViewLayout )
+ {
+ nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+ nFac = Min( nFac, nVisPercent );
+ aZoomSliderItem.AddSnappingPoint( nFac );
+ }
+ }
+
+ rSet.Put( aZoomSliderItem );
+ }
+ else
+ rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
+ }
+ break;
+ case SID_ATTR_POSITION:
+ case SID_ATTR_SIZE:
+ {
+ if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
+ SwBaseShell::_SetFrmMode( FLY_DRAG_END );
+ else
+ {
+ FlyMode eFrameMode = SwBaseShell::GetFrmMode();
+ if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
+ {
+ if ( nWhich == SID_ATTR_POSITION )
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION,
+ rShell.GetAnchorObjDiff()));
+ else
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
+ rShell.GetObjSize()));
+ }
+ }
+ }
+ break;
+ case SID_TABLE_CELL:
+
+ if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
+ {
+ // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
+ // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
+ // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
+ // in SID_ATTR_SIZE).
+ }
+ else
+ {
+ String sStr;
+ if( rShell.IsCrsrInTbl() )
+ {
+ // table name + cell coordinate
+ sStr = rShell.GetTableFmt()->GetName();
+ sStr += ':';
+ sStr += rShell.GetBoxNms();
+ }
+ else
+ {
+ const SwSection* pCurrSect = rShell.GetCurrSection();
+ if( pCurrSect )
+ {
+ switch( pCurrSect->GetType() )
+ {
+ case TOX_HEADER_SECTION:
+ case TOX_CONTENT_SECTION:
+ {
+ const SwTOXBase* pTOX = pWrtShell->GetCurTOX();
+ if( pTOX )
+ sStr = pTOX->GetTOXName();
+ else
+ {
+ ASSERT( !this,
+ "was ist das fuer ein Verzeichnis?" );
+ sStr = pCurrSect->GetSectionName();
+ }
+ }
+ break;
+ default:
+ sStr = pCurrSect->GetSectionName();
+ break;
+ }
+ }
+ }
+
+ //#outline level, removed by zhaojianwei
+ //const SwNumRule* pNumRule = rShell.GetCurNumRule();
+ //if (pNumRule) // Cursor in Numerierung
+ //{
+ // BYTE nNumLevel = rShell.GetNumLevel();
+ // if( IsShowNum(nNumLevel) && MAXLEVEL >
+ // ( nNumLevel = GetRealLevel( nNumLevel )) )
+ // {
+ // if( sStr.Len() )
+ // sStr.AppendAscii(sStatusDelim);
+ // sStr += SW_RESSTR(STR_NUM_LEVEL);
+ // sStr += String::CreateFromInt32( nNumLevel + 1 );
+ // if(!pNumRule->IsAutoRule())
+ // {
+ // SfxItemSet aSet(GetPool(),
+ // RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
+ // rShell.GetCurAttr(aSet);
+ // /* const SfxPoolItem* pItem; */
+ // if(SFX_ITEM_AVAILABLE <=
+ // aSet.GetItemState(RES_PARATR_NUMRULE, TRUE
+ // /*, &pItem */ ))
+ // {
+ // const String& rNumStyle =
+ // ((const SfxStringItem &)
+ // aSet.Get(RES_PARATR_NUMRULE)).GetValue();
+ // /* #i5116# GetItemState does not necessarily
+ // change pItem */
+ // // ((const SfxStringItem*)pItem)->GetValue();
+ // if(rNumStyle.Len())
+ // {
+ // sStr.AppendAscii(sStatusDelim);
+ // sStr += rNumStyle;
+ // }
+ // }
+ // }
+ // }
+ //}//<-removed end ,zhaojianwei
+
+ //-->#outline level,added by zhaojianwei
+ const SwNumRule* pNumRule = rShell.GetCurNumRule();
+ const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0;
+ //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle();
+
+ if (pNumRule && !bOutlineNum ) // Cursor in Numerierung
+ {
+ BYTE nNumLevel = rShell.GetNumLevel();
+ // --> OD 2008-04-02 #refactorlists#
+// if( IsShowNum(nNumLevel) && MAXLEVEL >
+// ( nNumLevel = GetRealLevel( nNumLevel )) )
+ if ( nNumLevel < MAXLEVEL )
+ // <--
+ {
+ if(!pNumRule->IsAutoRule())
+ {
+ SfxItemSet aSet(GetPool(),
+ RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
+ rShell.GetCurAttr(aSet);
+ /* const SfxPoolItem* pItem; */
+ if(SFX_ITEM_AVAILABLE <=
+ aSet.GetItemState(RES_PARATR_NUMRULE, TRUE
+ /*, &pItem */ ))
+ {
+ const String& rNumStyle =
+ ((const SfxStringItem &)
+ aSet.Get(RES_PARATR_NUMRULE)).GetValue();
+ /* #i5116# GetItemState does not necessarily
+ change pItem */
+ // ((const SfxStringItem*)pItem)->GetValue();
+ if(rNumStyle.Len())
+ {
+ if( sStr.Len() )
+ sStr.AppendAscii(sStatusDelim);
+ sStr += rNumStyle;
+ }
+ }
+ }
+ if( sStr.Len() )
+ sStr.AppendAscii(sStatusDelim);
+ sStr += SW_RESSTR(STR_NUM_LEVEL);
+ sStr += String::CreateFromInt32( nNumLevel + 1 );
+
+ }
+ }
+ const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
+ if( nOutlineLevel != 0 )
+ {
+ if( sStr.Len() )
+ sStr.AppendAscii(sStatusComma);
+ if( bOutlineNum )
+ {
+ sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
+ sStr.AppendAscii(sStatusDelim);
+ sStr += SW_RESSTR(STR_NUM_LEVEL);
+ }
+ else
+ sStr += SW_RESSTR(STR_NUM_OUTLINE);
+ sStr += String::CreateFromInt32( nOutlineLevel);
+ }
+ //<-end ,zhaojianwei
+
+ if( rShell.HasReadonlySel() )
+ {
+ if( sStr.Len() )
+ sStr.InsertAscii( sStatusDelim, 0 );
+ sStr.Insert( SW_RESSTR( STR_READONLY_SEL ), 0 );
+ }
+ if( sStr.Len() )
+ rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
+ }
+ break;
+ case FN_STAT_SELMODE:
+ {
+ if(rShell.IsStdMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
+ else if(rShell.IsAddMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
+ else if(rShell.IsBlockMode())
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
+ else
+ rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
+ break;
+ }
+ case SID_ATTR_INSERT:
+ if( rShell.IsRedlineOn() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Execute fuer die Stauszeile
+ --------------------------------------------------------------------*/
+
+
+void SwView::ExecuteStatusLine(SfxRequest &rReq)
+{
+ SwWrtShell &rSh = GetWrtShell();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem=NULL;
+ BOOL bUp = FALSE;
+ USHORT nWhich = rReq.GetSlot();
+ switch( nWhich )
+ {
+ case FN_STAT_PAGE:
+ {
+ GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ break;
+
+ case FN_STAT_BOOKMARK:
+ if ( pArgs )
+ {
+ if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, TRUE, &pItem))
+ {
+ const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
+ const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ if(nIdx < pMarkAccess->getBookmarksCount())
+ {
+ const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
+ rSh.EnterStdMode();
+ rSh.GotoMark( ppBookmark->get() );
+ }
+ else
+ OSL_ENSURE(false,
+ "SwView::ExecuteStatusLine(..)"
+ " - Ignoring out of range bookmark index");
+ }
+ }
+ break;
+
+ case FN_STAT_TEMPLATE:
+ {
+ GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ break;
+ case SID_ATTR_ZOOM:
+ {
+ if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
+ {
+ const SfxItemSet *pSet = 0;
+ AbstractSvxZoomDialog *pDlg = 0;
+ if ( pArgs )
+ pSet = pArgs;
+ else
+ {
+ const SwViewOption& rViewOptions = *rSh.GetViewOptions();
+ SfxItemSet aCoreSet(pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
+ SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
+
+ const bool bBrowseMode = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+ if( bBrowseMode )
+ {
+ aZoom.SetValueSet(
+ SVX_ZOOM_ENABLE_50|
+ SVX_ZOOM_ENABLE_75|
+ SVX_ZOOM_ENABLE_100|
+ SVX_ZOOM_ENABLE_150|
+ SVX_ZOOM_ENABLE_200);
+ }
+ aCoreSet.Put( aZoom );
+
+ // PAGES01
+ if ( !bBrowseMode )
+ {
+ const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
+ aCoreSet.Put( aViewLayout );
+ }
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ }
+
+ pDlg->SetLimits( MINZOOM, MAXZOOM );
+
+ if( pDlg->Execute() != RET_CANCEL )
+ pSet = pDlg->GetOutputItemSet();
+ }
+
+ // PAGES01
+ const SfxPoolItem* pViewLayoutItem = 0;
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, TRUE, &pViewLayoutItem))
+ {
+ const USHORT nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
+ const bool bBookMode = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
+ SetViewLayout( nColumns, bBookMode );
+ }
+
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, TRUE, &pItem))
+ {
+ enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
+ SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
+ }
+ bUp = TRUE;
+ if ( pItem )
+ rReq.AppendItem( *pItem );
+ rReq.Done();
+
+ delete pDlg;
+ }
+ }
+ break;
+
+ case SID_ATTR_VIEWLAYOUT:
+ {
+ if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
+ ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
+ {
+ // PAGES01
+ if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, TRUE, &pItem ))
+ {
+ const USHORT nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
+ const bool bBookMode = (0 == nColumns || 0 != (nColumns % 2)) ?
+ false :
+ ((const SvxViewLayoutItem *)pItem)->IsBookMode();
+
+ SetViewLayout( nColumns, bBookMode );
+ }
+
+ bUp = TRUE;
+ rReq.Done();
+
+ InvalidateRulerPos();
+ }
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
+ {
+ // PAGES01
+ if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, TRUE, &pItem ))
+ {
+ const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
+ }
+
+ bUp = TRUE;
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_ATTR_SIZE:
+ {
+ ULONG nId = FN_INSERT_FIELD;
+ if( rSh.IsCrsrInTbl() )
+ nId = FN_FORMAT_TABLE_DLG;
+ else if( rSh.GetCurTOX() )
+ nId = FN_INSERT_MULTI_TOX;
+ else if( rSh.GetCurrSection() )
+ nId = FN_EDIT_REGION;
+ else
+ {
+ const SwNumRule* pNumRule = rSh.GetCurNumRule();
+ if( pNumRule ) // Cursor in Numerierung
+ {
+ if( pNumRule->IsAutoRule() )
+ nId = FN_NUMBER_BULLETS;
+ else
+ {
+ // Dialog vom Gestalter starten ;-)
+ nId = 0;
+ }
+ }
+ else if( rSh.IsFrmSelected() )
+ nId = FN_FORMAT_FRAME_DLG;
+ else if( rSh.IsObjSelected() )
+ nId = SID_ATTR_TRANSFORM;
+ }
+ if( nId )
+ GetViewFrame()->GetDispatcher()->Execute(
+ static_cast< USHORT >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ }
+ break;
+
+ case FN_STAT_SELMODE:
+ {
+ if ( pArgs )
+ {
+ if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, TRUE, &pItem))
+ {
+ switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
+ {
+ case 0: rSh.EnterStdMode(); break;
+ case 1: rSh.EnterExtMode(); break;
+ case 2: rSh.EnterAddMode(); break;
+ case 3: rSh.EnterBlockMode(); break;
+ }
+ }
+ }
+ else
+ {
+
+ if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
+ rSh.ToggleExtMode();
+ else if ( rSh.IsExtMode() )
+ {
+ rSh.ToggleExtMode();
+ rSh.ToggleAddMode();
+ }
+ else if ( rSh.IsAddMode() )
+ {
+ rSh.ToggleAddMode();
+ rSh.ToggleBlockMode();
+ }
+ else
+ rSh.ToggleBlockMode();
+ }
+ bUp = TRUE;
+ break;
+ }
+ case FN_SET_ADD_MODE:
+ rSh.ToggleAddMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = TRUE;
+ break;
+ case FN_SET_BLOCK_MODE:
+ rSh.ToggleBlockMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = TRUE;
+ break;
+ case FN_SET_EXT_MODE:
+ rSh.ToggleExtMode();
+ nWhich = FN_STAT_SELMODE;
+ bUp = TRUE;
+ break;
+ case SID_ATTR_INSERT:
+ SwPostItMgr* pMgr = GetPostItMgr();
+ if ( pMgr && pMgr->HasActiveSidebarWin() )
+ {
+ pMgr->ToggleInsModeOnActiveSidebarWin();
+ }
+ else
+ rSh.ToggleInsMode();
+ bUp = TRUE;
+ break;
+
+ }
+ if ( bUp )
+ {
+ SfxBindings &rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate(nWhich);
+ rBnd.Update(nWhich);
+ }
+}
+
+void SwView::InsFrmMode(USHORT nCols)
+{
+ if ( pWrtShell->HasWholeTabSelection() )
+ {
+ SwFlyFrmAttrMgr aMgr( TRUE, pWrtShell, FRMMGR_TYPE_TEXT );
+
+ const SwFrmFmt &rPageFmt =
+ pWrtShell->GetPageDesc(pWrtShell->GetCurPageDesc()).GetMaster();
+ SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
+ const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
+ lWidth -= rLR.GetLeft() + rLR.GetRight();
+ aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
+ if(nCols > 1)
+ {
+ SwFmtCol aCol;
+ aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
+ aMgr.SetCol( aCol );
+ }
+ aMgr.InsertFlyFrm();
+ }
+ else
+ GetEditWin().InsFrm(nCols);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Links bearbeiten
+ --------------------------------------------------------------------*/
+
+void SwView::EditLinkDlg()
+{
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ delete pDlg;
+ }
+/*
+ SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow());
+ pDlg->SetShell(&GetWrtShell());
+ pDlg->Execute();
+
+ DELETEZ(pDlg);
+*/
+}
+
+BOOL SwView::JumpToSwMark( const String& rMark )
+{
+ BOOL bRet = FALSE;
+ if( rMark.Len() )
+ {
+ // wir wollen den Bookmark aber am oberen Rand haben
+ BOOL bSaveCC = IsCrsrAtCenter();
+ BOOL bSaveCT = IsCrsrAtTop();
+ SetCrsrAtTop( TRUE );
+
+ //JP 27.04.98: Bug 49786
+ // Damit in FrameSet auch gescrollt werden kann, muss die
+ // entsprechende Shell auch das Focus-Flag gesetzt haben!
+ BOOL bHasShFocus = pWrtShell->HasShFcs();
+ if( !bHasShFocus )
+ pWrtShell->ShGetFcs( FALSE );
+
+ const SwFmtINetFmt* pINet;
+ String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
+ INetURLObject::DECODE_WITH_CHARSET,
+ RTL_TEXTENCODING_UTF8 ));
+
+ xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeperator );
+ if( STRING_NOTFOUND != nPos )
+ while( STRING_NOTFOUND != ( nLastPos =
+ sMark.Search( cMarkSeperator, nPos + 1 )) )
+ nPos = nLastPos;
+
+ IDocumentMarkAccess::const_iterator_t ppMark;
+ IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
+ if( STRING_NOTFOUND != nPos &&
+ ( sCmp = sMark.Copy( nPos + 1 ) ).EraseAllChars().Len() )
+ {
+ String sName( sMark.Copy( 0, nPos ) );
+ sCmp.ToLowerAscii();
+ FlyCntType eFlyType = FLYCNTTYPE_ALL;
+
+ if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) )
+ {
+ pWrtShell->EnterStdMode();
+ bRet = pWrtShell->GotoRegion( sName );
+ }
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) )
+ {
+ pWrtShell->EnterStdMode();
+ bRet = pWrtShell->GotoOutline( sName );
+ }
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) )
+ eFlyType = FLYCNTTYPE_FRM;
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) )
+ eFlyType = FLYCNTTYPE_GRF;
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) )
+ eFlyType = FLYCNTTYPE_OLE;
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) )
+ {
+ pWrtShell->EnterStdMode();
+ bRet = pWrtShell->GotoTable( sName );
+ }
+ else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) )
+ {
+ // Normale Textsuche
+ pWrtShell->EnterStdMode();
+
+ SearchOptions aSearchOpt(
+ SearchAlgorithms_ABSOLUTE, 0,
+ sName, rtl::OUString(),
+ SvxCreateLocale( LANGUAGE_SYSTEM ),
+ 0,0,0,
+ TransliterationModules_IGNORE_CASE );
+
+ //todo/mba: assuming that notes shouldn't be searched
+ BOOL bSearchInNotes = FALSE;
+ if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
+ {
+ pWrtShell->EnterStdMode(); // Selektion wieder aufheben
+ bRet = TRUE;
+ }
+ }
+ else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
+ pWrtShell->GotoMark( ppMark->get(), FALSE, TRUE ), bRet = TRUE;
+ else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
+ bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
+
+ // fuer alle Arten von Flys
+ if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType ))
+ {
+ bRet = TRUE;
+ if( FLYCNTTYPE_FRM == eFlyType )
+ {
+ // TextFrames: Cursor in den Frame setzen
+ pWrtShell->UnSelectFrm();
+ pWrtShell->LeaveSelFrmMode();
+ }
+ else
+ {
+ pWrtShell->HideCrsr();
+ pWrtShell->EnterSelFrmMode();
+ }
+ }
+ }
+ else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
+ pWrtShell->GotoMark( ppMark->get(), FALSE, TRUE ), bRet = TRUE;
+ else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
+ bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
+
+ // #b6330459# make selection visible later
+ if ( aVisArea.IsEmpty() )
+ bMakeSelectionVisible = sal_True;
+
+ // ViewStatus wieder zurueck setzen
+ SetCrsrAtTop( bSaveCT, bSaveCC );
+
+ if( !bHasShFocus )
+ pWrtShell->ShLooseFcs();
+ }
+ return bRet;
+}
+
+// #i67305, #1367991: Undo after insert from file:
+// Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
+// Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
+// page styles with active header/footer => disabled for those documents
+
+sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
+{
+ sal_uInt16 nRet = 0;
+ sal_uInt16 nCnt = rDoc.GetPageDescCnt();
+ for( sal_uInt16 i = 0; i < nCnt; ++i )
+ {
+ const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
+ const SwFrmFmt& rMaster = rPageDesc.GetMaster();
+ const SfxPoolItem* pItem;
+ if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, FALSE, &pItem ) &&
+ ((SwFmtHeader*)pItem)->IsActive() ) ||
+ ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, FALSE, &pItem ) &&
+ ((SwFmtFooter*)pItem)->IsActive()) )
+ ++nRet;
+ }
+ return nRet; // number of page styles with active header/footer
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Links bearbeiten
+ --------------------------------------------------------------------*/
+
+void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
+{
+ pViewImpl->InitRequest( rRequest );
+ pViewImpl->SetParam( pItem ? 1 : 0 );
+ USHORT nSlot = rRequest.GetSlot();
+
+ if ( !pItem )
+ {
+ String sEmpty;
+ InsertDoc( nSlot, sEmpty, sEmpty );
+ }
+ else
+ {
+ String sFile, sFilter;
+ sFile = ( (const SfxStringItem *)pItem )->GetValue();
+ if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, TRUE, &pItem ) )
+ sFilter = ( (const SfxStringItem *)pItem )->GetValue();
+
+ bool bHasFileName = ( sFile.Len() > 0 );
+ long nFound = InsertDoc( nSlot, sFile, sFilter );
+
+ if ( bHasFileName )
+ {
+ rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ rRequest.Done();
+ }
+ }
+}
+
+long SwView::InsertDoc( USHORT nSlotId, const String& rFileName, const String& rFilterName, INT16 nVersion )
+{
+ SfxMedium* pMed = 0;
+ SwDocShell* pDocSh = GetDocShell();
+
+ if( rFileName.Len() )
+ {
+ SfxObjectFactory& rFact = pDocSh->GetFactory();
+ const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
+ if ( !pFilter )
+ {
+ pMed = new SfxMedium(rFileName, STREAM_READ, TRUE, 0, 0 );
+ SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
+ pMed->UseInteractionHandler( TRUE );
+ ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, FALSE );
+ if ( nErr )
+ DELETEZ(pMed);
+ else
+ pMed->SetFilter( pFilter );
+ }
+ else
+ pMed = new SfxMedium(rFileName, STREAM_READ, TRUE, pFilter, 0);
+ }
+ else
+ {
+ String sFactory = String::CreateFromAscii( pDocSh->GetFactory().GetShortName() );
+ pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
+ return -1;
+ }
+
+ if( !pMed )
+ return -1;
+
+ return InsertMedium( nSlotId, pMed, nVersion );
+}
+
+long SwView::InsertMedium( USHORT nSlotId, SfxMedium* pMedium, INT16 nVersion )
+{
+ BOOL bInsert = FALSE, bCompare = FALSE, bMerge = FALSE;
+ long nFound = 0;
+ SwDocShell* pDocSh = GetDocShell();
+
+ switch( nSlotId )
+ {
+ case SID_DOCUMENT_MERGE: bMerge = TRUE; break;
+ case SID_DOCUMENT_COMPARE: bCompare = TRUE; break;
+ case SID_INSERTDOC: bInsert = TRUE; break;
+
+ default:
+ ASSERT( !this, "Unbekannte SlotId!" );
+ bInsert = TRUE;
+ nSlotId = SID_INSERTDOC;
+ break;
+ }
+
+ if( bInsert )
+ {
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetViewFrame()->GetBindings().GetRecorder();
+ if ( xRecorder.is() )
+ {
+ SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
+ aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
+ if(pMedium->GetFilter())
+ aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
+ aRequest.Done();
+ }
+
+ SfxObjectShellRef aRef( pDocSh );
+
+ sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
+ // #i16722# aborted?
+ if(nError != ERRCODE_NONE)
+ {
+ delete pMedium;
+ return -1;
+ }
+ pDocSh->RegisterTransfer( *pMedium );
+ pMedium->DownLoad(); // ggfs. den DownLoad anstossen
+ if( aRef.Is() && 1 < aRef->GetRefCount() ) // noch gueltige Ref?
+ {
+ SwReader* pRdr;
+ Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, pWrtShell );
+ if( pRead ||
+ (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
+ {
+ sal_uInt16 nUndoCheck = 0;
+ SwDoc *pDoc = pDocSh->GetDoc();
+ if( pRead && pDocSh->GetDoc() )
+ nUndoCheck = lcl_PageDescWithHeader( *pDoc );
+ ULONG nErrno;
+ { //Scope for SwWait-Object, to be able to execute slots
+ //outside this scope.
+ SwWait aWait( *GetDocShell(), TRUE );
+ pWrtShell->StartAllAction();
+ if ( pWrtShell->HasSelection() )
+ pWrtShell->DelRight(); // Selektionen loeschen
+ if( pRead )
+ {
+ nErrno = pRdr->Read( *pRead ); // und Dokument einfuegen
+ delete pRdr;
+ }
+ else
+ {
+ sal_Bool bUndo = pDoc->DoesUndo();
+ pDoc->DoUndo( sal_False );
+ nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR;
+ pDoc->DoUndo( bUndo );
+ }
+
+ }
+
+ // ggfs. alle Verzeichnisse updaten:
+ if( pWrtShell->IsUpdateTOX() )
+ {
+ SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
+ Execute( aReq );
+ pWrtShell->SetUpdateTOX( FALSE ); // wieder zurueck setzen
+ }
+
+ if( pDoc )
+ { // Disable Undo for .sdw (136991) or
+ // if the number of page styles with header/footer has changed (#i67305)
+ if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
+ pDoc->DelAllUndoObj();
+ }
+
+ pWrtShell->EndAllAction();
+ if( nErrno )
+ {
+ ErrorHandler::HandleError( nErrno );
+ nFound = IsError( nErrno ) ? -1 : 0;
+ }
+ else
+ nFound = 0;
+ }
+ }
+ }
+ else
+ {
+ SfxObjectShellRef xDocSh;
+
+extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh,
+ const String& rFileName, const String& rPasswd,
+ String& rFilter, INT16 nVersion,
+ SwDocShell* pDestSh );
+
+ String sFltNm;
+ int nRet = lcl_FindDocShell( xDocSh, pMedium->GetName(), aEmptyStr,
+ sFltNm, nVersion, pDocSh );
+ if( nRet )
+ {
+ SwWait aWait( *GetDocShell(), TRUE );
+ pWrtShell->StartAllAction();
+
+ pWrtShell->EnterStdMode(); // Selektionen loeschen
+
+ if( bCompare )
+ nFound = pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
+ else
+ nFound = pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
+
+ pWrtShell->EndAllAction();
+
+ if (!bCompare && !nFound)
+ {
+ Window* pWin = &GetEditWin();
+ InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
+ }
+ }
+ if( 2 == nRet && xDocSh.Is() )
+ xDocSh->DoClose();
+ }
+
+ delete pMedium;
+ return nFound;
+}
+/* -----------------05.02.2003 12:06-----------------
+ *
+ * --------------------------------------------------*/
+void SwView::EnableMailMerge(BOOL bEnable )
+{
+ bInMailMerge = bEnable;
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
+ rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
+}
+/*
+*/
+namespace
+{
+ sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext )
+ {
+ Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
+
+ return ( !aNames.getLength()
+ || ( ( 1 == aNames.getLength() )
+ && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
+ )
+ );
+ }
+}
+
+/* -----------------27.11.2002 12:12-----------------
+ *
+ * --------------------------------------------------*/
+
+class SwMergeSourceWarningBox_Impl : public ModalDialog
+{
+ FixedInfo aMessageFI;
+ OKButton aOK;
+ CancelButton aCancel;
+
+ FixedImage aWarnImage;
+ public:
+ SwMergeSourceWarningBox_Impl( Window* pParent ) :
+ ModalDialog( pParent, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE ) ),
+ aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE ) ),
+ aOK( this, SW_RES( PB_MERGE_OK ) ),
+ aCancel( this, SW_RES( PB_MERGE_CANCEL ) ),
+ aWarnImage( this, SW_RES( IMG_MERGE ) )
+ {
+ FreeResource();
+ SetText( Application::GetDisplayName() );
+ const Image& rImg = WarningBox::GetStandardImage();
+ aWarnImage.SetImage( rImg );
+ Size aImageSize( rImg.GetSizePixel() );
+ aImageSize.Width() += 4;
+ aImageSize.Height() += 4;
+ aWarnImage.SetSizePixel( aImageSize );
+
+ aImageSize.Width() += aWarnImage.GetPosPixel().X();
+ Size aSz(GetSizePixel());
+ aSz.Width() += aImageSize.Width();
+ SetSizePixel(aSz);
+
+ Point aPos(aMessageFI.GetPosPixel());
+ aPos.X() += aImageSize.Width();
+ aMessageFI.SetPosPixel( aPos );
+
+ aPos = aOK.GetPosPixel();
+ aPos.X() += aImageSize.Width();
+ aOK.SetPosPixel( aPos );
+ aPos = aCancel.GetPosPixel();
+ aPos.X() += aImageSize.Width();
+ aCancel.SetPosPixel( aPos );
+
+ }
+
+ String GetMessText() const { return aMessageFI.GetText(); }
+ void SetMessText( const String& rText ) { aMessageFI.SetText( rText ); }
+};
+
+
+
+
+void SwView::GenerateFormLetter(BOOL bUseCurrentDocument)
+{
+ if(bUseCurrentDocument)
+ {
+ if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
+ {
+ //check availability of data sources (except biblio source)
+ uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ uno::Reference<XNameAccess> xDBContext;
+ if( xMgr.is() )
+ {
+ uno::Reference<XInterface> xInstance = xMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ));
+ xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
+ }
+ if(!xDBContext.is())
+ return ;
+ BOOL bCallAddressPilot = FALSE;
+ if ( lcl_NeedAdditionalDataSource( xDBContext ) )
+ {
+ // no data sources are available - create a new one
+ WarningBox aWarning(
+ &GetViewFrame()->GetWindow(),
+ SW_RES(MSG_DATA_SOURCES_UNAVAILABLE));
+ // no cancel allowed
+ if ( RET_OK != aWarning.Execute() )
+ return;
+ bCallAddressPilot = TRUE;
+ }
+ else
+ {
+ //take an existing data source or create a new one?
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(
+ DLG_MERGE_FIELD_CONNECTIONS,
+ &GetViewFrame()->GetWindow());
+ DBG_ASSERT(pConnectionsDlg, "Dialogdiet fail!");
+ if(RET_OK == pConnectionsDlg->Execute())
+ bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
+ else
+ return;
+
+ }
+ if(bCallAddressPilot)
+ {
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON);
+ if ( lcl_NeedAdditionalDataSource( xDBContext ) )
+ // no additional data source has been created
+ // -> assume that the user has cancelled the pilot
+ return;
+ }
+
+ //call insert fields with database field page available, only
+ SfxViewFrame* pVFrame = GetViewFrame();
+ //at first hide the default field dialog if currently visible
+ pVFrame->SetChildWindow(FN_INSERT_FIELD, FALSE);
+ //enable the status of the db field dialog - it is disabled in the status method
+ //to prevent creation of the dialog without mail merge active
+ EnableMailMerge();
+ //then show the "Data base only" field dialog
+ SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, TRUE);
+ pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
+ SFX_CALLMODE_SYNCHRON, &aOn, 0L);
+ return;
+ }
+ else
+ {
+ // check whether the
+ String sSource;
+ if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
+ {
+ SwMergeSourceWarningBox_Impl aWarning( &GetViewFrame()->GetWindow());
+ String sTmp(aWarning.GetMessText());
+ sTmp.SearchAndReplaceAscii("%1", sSource);
+ aWarning.SetMessText(sTmp);
+ if(RET_OK == aWarning.Execute())
+ {
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ return ;
+ }
+ }
+ SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
+
+ SwDBData aData;
+ SwWrtShell &rSh = GetWrtShell();
+ aData = rSh.GetDBData();
+ rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
+ // das Mischen von DB-Feldern notwendig.
+ AttrChangedNotify( &rSh );
+ pNewDBMgr->SetMergeType( DBMGR_MERGE );
+
+ if (pNewDBMgr)
+ {
+ Sequence<PropertyValue> aProperties(3);
+ PropertyValue* pValues = aProperties.getArray();
+ pValues[0].Name = C2U("DataSourceName");
+ pValues[1].Name = C2U("Command");
+ pValues[2].Name = C2U("CommandType");
+ pValues[0].Value <<= aData.sDataSource;
+ pValues[1].Value <<= aData.sCommand;
+ pValues[2].Value <<= aData.nCommandType;
+ pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, TRUE);
+ }
+ }
+ else
+ {
+ //call documents and template dialog
+ SfxApplication* pSfxApp = SFX_APP();
+ Window* pTopWin = pSfxApp->GetTopWindow();
+ SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin );
+ pDocTemplDlg->SelectTemplateFolder();
+
+ int nRet = pDocTemplDlg->Execute();
+ sal_Bool bNewWin = sal_False;
+ if ( nRet == RET_OK )
+ {
+ if ( pTopWin != pSfxApp->GetTopWindow() )
+ {
+ // the dialogue opens a document -> a new TopWindow appears
+ pTopWin = pSfxApp->GetTopWindow();
+ bNewWin = sal_True;
+ }
+ }
+
+ delete pDocTemplDlg;
+ if ( bNewWin )
+ // after the destruction of the dialogue its parent comes to top,
+ // but we want that the new document is on top
+ pTopWin->ToTop();
+
+// return;
+ }
+}
+
+IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ SfxMedium* pMed = pViewImpl->CreateMedium();
+ if ( pMed )
+ {
+ USHORT nSlot = pViewImpl->GetRequest()->GetSlot();
+ long nFound = InsertMedium( nSlot, pMed, pViewImpl->GetParam() );
+
+ if ( SID_INSERTDOC == nSlot )
+ {
+ if ( pViewImpl->GetParam() == 0 )
+ {
+ pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ pViewImpl->GetRequest()->Ignore();
+ }
+ else
+ {
+ pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
+ pViewImpl->GetRequest()->Done();
+ }
+ }
+ else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
+ {
+ pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
+
+ if ( nFound > 0 ) // Redline-Browser anzeigen
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
+
+ // RedlineDlg neu initialisieren
+ USHORT nId = SwRedlineAcceptChild::GetChildWindowId();
+ SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
+ if ( pRed )
+ pRed->ReInitDlg( GetDocShell() );
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+void SwView::ExecuteScan( SfxRequest& rReq )
+{
+ if (pViewImpl)
+ pViewImpl->ExecuteScan(rReq) ;
+}
+
diff --git a/sw/source/ui/uiview/viewcoll.cxx b/sw/source/ui/uiview/viewcoll.cxx
new file mode 100644
index 000000000000..e5f9350277ee
--- /dev/null
+++ b/sw/source/ui/uiview/viewcoll.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "cmdid.h"
+#include "uiitems.hxx"
+#include <tools/list.hxx>
+#include <vcl/window.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/stritem.hxx>
+#include <rsc/rscsfx.hxx>
+
+
+#include "errhdl.hxx"
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+
+
+void SwView::ExecColl(SfxRequest &rReq)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ USHORT nWhich = rReq.GetSlot();
+ switch( nWhich )
+ {
+ case FN_SET_PAGE:
+ {
+ DBG_ASSERT(!this, "Not implemented");
+ }
+ break;
+ case FN_SET_PAGE_STYLE:
+ {
+ if( pArgs )
+ {
+ if (pArgs &&
+ SFX_ITEM_SET == pArgs->GetItemState( nWhich , TRUE, &pItem ))
+ {
+ if( ((SfxStringItem*)pItem)->GetValue() !=
+ GetWrtShell().GetCurPageStyle(FALSE) )
+ {
+ SfxStringItem aName(SID_STYLE_APPLY,
+ ((SfxStringItem*)pItem)->GetValue());
+ SfxUInt16Item aFamItem( SID_STYLE_FAMILY,
+ SFX_STYLE_FAMILY_PAGE);
+ SwPtrItem aShell(FN_PARAM_WRTSHELL, GetWrtShellPtr());
+ SfxRequest aReq(SID_STYLE_APPLY, 0, GetPool());
+ aReq.AppendItem(aName);
+ aReq.AppendItem(aFamItem);
+ aReq.AppendItem(aShell);
+ GetCurShell()->ExecuteSlot(aReq);
+ }
+ }
+ }
+ else
+ {
+ SfxRequest aReq(FN_FORMAT_PAGE_DLG, 0, GetPool());
+ GetCurShell()->ExecuteSlot(aReq);
+ }
+ }
+ break;
+ default:
+ ASSERT(FALSE, falscher CommandProcessor fuer Dispatch);
+ return;
+ }
+}
+
+
+
diff --git a/sw/source/ui/uiview/viewdlg.cxx b/sw/source/ui/uiview/viewdlg.cxx
new file mode 100644
index 000000000000..8c19c454b6ac
--- /dev/null
+++ b/sw/source/ui/uiview/viewdlg.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include "hintids.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <editeng/tstpitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/request.hxx>
+
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "viewopt.hxx"
+#include "uitool.hxx"
+#include "cmdid.h"
+#include <sfx2/tabdlg.hxx>
+
+#include "pagedesc.hxx"
+
+
+void SwView::ExecDlg(SfxRequest &rReq)
+{
+ ModalDialog *pDialog = 0;
+ //Damit aus dem Basic keine Dialoge fuer Hintergrund-Views aufgerufen werden:
+ const SfxPoolItem* pItem = 0;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ USHORT nSlot = rReq.GetSlot();
+ if(pArgs)
+ pArgs->GetItemState( GetPool().GetWhich(nSlot), FALSE, &pItem );
+
+ switch ( nSlot )
+ {
+ case FN_CHANGE_PAGENUM:
+ {
+ if ( pItem )
+ {
+ USHORT nValue = ((SfxUInt16Item *)pItem)->GetValue();
+ USHORT nOldValue = pWrtShell->GetPageOffset();
+ USHORT nPage, nLogPage;
+ pWrtShell->GetPageNum( nPage, nLogPage,
+ pWrtShell->IsCrsrVisible(), FALSE);
+
+ if(nValue != nOldValue || nValue != nLogPage)
+ {
+ if(!nOldValue)
+ pWrtShell->SetNewPageOffset( nValue );
+ else
+ pWrtShell->SetPageOffset( nValue );
+ }
+ }
+ }
+ break;
+
+ default:
+ ASSERT(!this, falscher Dispatcher);
+ return;
+ }
+
+ if( pDialog )
+ {
+ pDialog->Execute();
+ delete pDialog;
+ }
+}
+
+
+
diff --git a/sw/source/ui/uiview/viewdlg2.cxx b/sw/source/ui/uiview/viewdlg2.cxx
new file mode 100644
index 000000000000..bbff2271e9fa
--- /dev/null
+++ b/sw/source/ui/uiview/viewdlg2.cxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+
+
+#include <fldmgr.hxx>
+#include <expfld.hxx>
+#include <modcfg.hxx>
+
+#include <tools/shl.hxx>
+
+#include "swmodule.hxx"
+#include "view.hxx"
+#include "wview.hxx"
+#include "wrtsh.hxx"
+#include "cmdid.h"
+#include "caption.hxx"
+#include "poolfmt.hxx"
+#include "edtwin.hxx"
+#include <SwStyleNameMapper.hxx>
+
+#include "swabstdlg.hxx"
+#include "frmui.hrc"
+#include "misc.hrc"
+
+#include "view.hrc"
+
+extern String* pOldGrfCat;
+extern String* pOldTabCat;
+extern String* pOldFrmCat;
+extern String* pOldDrwCat;
+
+/* -----------------06.11.98 13:45-------------------
+ *
+ * --------------------------------------------------*/
+
+void SwView::ExecDlgExt(SfxRequest &rReq)
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+
+ switch ( rReq.GetSlot() )
+ {
+ case FN_INSERT_CAPTION:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
+
+ VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION );
+ DBG_ASSERT(pDialog, "Dialogdiet fail!");
+ if ( pDialog )
+ {
+ pDialog->Execute();
+ delete pDialog;
+ }
+ break;
+ }
+ case FN_EDIT_FOOTNOTE:
+ {
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE,
+ pMDI, *pWrtShell, TRUE );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+
+ pDlg->SetHelpId(FN_EDIT_FOOTNOTE);
+ pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
+ pDlg->Execute();
+ delete pDlg;
+ break;
+ }
+ }
+}
+
+/* -----------------06.11.98 14:53-------------------
+ *
+ * --------------------------------------------------*/
+
+void SwView::AutoCaption(const USHORT nType, const SvGlobalName *pOleId)
+{
+ SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ if (pModOpt->IsInsWithCaption(bWeb))
+ {
+ const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
+ if (pOpt && pOpt->UseCaption() == TRUE)
+ InsertCaption(pOpt);
+ }
+}
+
+/* -----------------06.11.98 12:58-------------------
+ *
+ * --------------------------------------------------*/
+
+void SwView::InsertCaption(const InsCaptionOpt *pOpt)
+{
+ if (!pOpt)
+ return;
+
+ const String &rName = pOpt->GetCategory();
+
+ // Existiert Pool-Vorlage gleichen Namens?
+ SwWrtShell &rSh = GetWrtShell();
+ if(rName.Len())
+ {
+ USHORT nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
+ if( USHRT_MAX != nPoolId )
+ rSh.GetTxtCollFromPool(nPoolId);
+ // Pool-Vorlage existiert nicht: Existiert sie am Dokument?
+ else if( !rSh.GetParaStyle(rName) )
+ {
+ // Sie existiert auch nicht am Dokument: erzeugen
+ SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
+ rSh.MakeTxtFmtColl(rName, pDerivedFrom);
+ }
+ }
+
+ SelectionType eType = rSh.GetSelectionType();
+ if (eType & nsSelectionType::SEL_OLE)
+ eType = nsSelectionType::SEL_GRF;
+
+ // SwLabelType
+ const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
+ eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
+ eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
+ eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
+ LTYPE_OBJECT;
+
+ SwFldMgr aMgr(&rSh);
+ SwSetExpFieldType* pFldType =
+ (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
+ if (!pFldType && rName.Len() )
+ {
+ // Neuen Feldtypen erzeugen
+ SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
+ aMgr.InsertFldType(aSwSetExpFieldType);
+ pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
+ }
+
+ if (!pOpt->IgnoreSeqOpts())
+ {
+ if (pFldType)
+ {
+ pFldType->SetDelimiter(pOpt->GetSeparator());
+ pFldType->SetOutlineLvl( static_cast< BYTE >(pOpt->GetLevel()) );
+ }
+ }
+
+ USHORT nID = USHRT_MAX;
+ SwFieldType* pType = 0;
+ const USHORT nCount = aMgr.GetFldTypeCount();
+ if( rName.Len() )
+ {
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ pType = aMgr.GetFldType(USHRT_MAX, i);
+ String aTmpName( pType->GetName() );
+ if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
+ {
+ nID = i;
+ break;
+ }
+ }
+ }
+ rSh.StartAllAction();
+
+ GetWrtShell().InsertLabel( eT,
+ pOpt->GetCaption(),
+ !pOpt->IgnoreSeqOpts() ? aEmptyStr : pOpt->GetSeparator(),
+ pOpt->GetNumSeparator(),
+ !pOpt->GetPos(),
+ nID,
+ pOpt->GetCharacterStyle(),
+ pOpt->CopyAttributes() );
+ // Nummernformat setzen
+ if(pType)
+ ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
+
+ rSh.UpdateExpFlds( TRUE );
+
+ rSh.EndAllAction();
+
+ if ( rSh.IsFrmSelected() )
+ {
+ GetEditWin().StopInsFrm();
+ rSh.EnterSelFrmMode();
+ }
+
+ // Kategorie merken
+ String** ppStr = 0;
+ if (eType & nsSelectionType::SEL_GRF)
+ ppStr = &pOldGrfCat;
+ else if( eType & nsSelectionType::SEL_TBL)
+ ppStr = &pOldTabCat;
+ else if( eType & nsSelectionType::SEL_FRM)
+ ppStr = &pOldFrmCat;
+ else if( eType == nsSelectionType::SEL_TXT)
+ ppStr = &pOldFrmCat;
+ else if( eType & nsSelectionType::SEL_DRW)
+ ppStr = &pOldDrwCat;
+
+ if( ppStr )
+ {
+ if( !*ppStr )
+ *ppStr = new String( rName );
+ else
+ **ppStr = rName;
+ }
+}
+
+
diff --git a/sw/source/ui/uiview/viewdraw.cxx b/sw/source/ui/uiview/viewdraw.cxx
new file mode 100644
index 000000000000..abae753c1b56
--- /dev/null
+++ b/sw/source/ui/uiview/viewdraw.cxx
@@ -0,0 +1,849 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include "hintids.hxx"
+#include <svl/aeitem.hxx>
+#include <svl/itempool.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/fmview.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <doc.hxx>
+#include <editeng/langitem.hxx>
+#include <linguistic/lngprops.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/fontworkgallery.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editstat.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/printer.hxx>
+#include <svx/fmglob.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdoutl.hxx>
+
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "viewopt.hxx"
+#include "cmdid.h"
+#include "drawsh.hxx"
+#include "drwbassh.hxx"
+#include "beziersh.hxx"
+#include "conrect.hxx"
+#include "conpoly.hxx"
+#include "conarc.hxx"
+#include "conform.hxx"
+#include "concustomshape.hxx"
+#include "dselect.hxx"
+#include "edtwin.hxx"
+
+// #108784#
+#include <dcontact.hxx>
+
+// #108784#
+#include <svx/svdpagv.hxx>
+#include <svx/extrusionbar.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+/*--------------------------------------------------------------------
+ Beschreibung: Drawing-Ids ausfuehren
+ --------------------------------------------------------------------*/
+
+void SwView::ExecDraw(SfxRequest& rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ const SfxAllEnumItem* pEItem = 0;
+ const SfxStringItem* pStringItem = 0;
+ SdrView *pSdrView = pWrtShell->GetDrawView();
+ sal_Bool bDeselect = sal_False;
+
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), sal_False, &pItem))
+ {
+ pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
+ pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
+ }
+
+ if (SID_INSERT_DRAW == nSlotId && pEItem)
+ switch ( pEItem->GetValue() )
+ {
+ case SVX_SNAP_DRAW_SELECT: nSlotId = SID_OBJECT_SELECT; break;
+ case SVX_SNAP_DRAW_LINE: nSlotId = SID_DRAW_LINE; break;
+ case SVX_SNAP_DRAW_RECT: nSlotId = SID_DRAW_RECT; break;
+ case SVX_SNAP_DRAW_ELLIPSE: nSlotId = SID_DRAW_ELLIPSE; break;
+ case SVX_SNAP_DRAW_POLYGON_NOFILL: nSlotId = SID_DRAW_POLYGON_NOFILL; break;
+ case SVX_SNAP_DRAW_BEZIER_NOFILL: nSlotId = SID_DRAW_BEZIER_NOFILL; break;
+ case SVX_SNAP_DRAW_FREELINE_NOFILL: nSlotId = SID_DRAW_FREELINE_NOFILL; break;
+ case SVX_SNAP_DRAW_ARC: nSlotId = SID_DRAW_ARC; break;
+ case SVX_SNAP_DRAW_PIE: nSlotId = SID_DRAW_PIE; break;
+ case SVX_SNAP_DRAW_CIRCLECUT: nSlotId = SID_DRAW_CIRCLECUT; break;
+ case SVX_SNAP_DRAW_TEXT: nSlotId = SID_DRAW_TEXT; break;
+ case SVX_SNAP_DRAW_TEXT_VERTICAL: nSlotId = SID_DRAW_TEXT_VERTICAL; break;
+ case SVX_SNAP_DRAW_TEXT_MARQUEE: nSlotId = SID_DRAW_TEXT_MARQUEE; break;
+ case SVX_SNAP_DRAW_CAPTION: nSlotId = SID_DRAW_CAPTION; break;
+ case SVX_SNAP_DRAW_CAPTION_VERTICAL: nSlotId = SID_DRAW_CAPTION_VERTICAL; break;
+ }
+
+ if (nSlotId == SID_OBJECT_SELECT && nFormSfxId == nSlotId)
+ {
+ bDeselect = sal_True;
+ }
+ else if (nSlotId == SID_FM_CREATE_CONTROL)
+ {
+ SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
+ if( pIdentifierItem )
+ {
+ sal_uInt16 nNewId = pIdentifierItem->GetValue();
+ if (nNewId == nFormSfxId)
+ {
+ bDeselect = sal_True;
+ GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button soll rauspoppen
+ }
+ }
+ }
+ else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
+ {
+ FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
+ if ( pFormView )
+ {
+ SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
+ DBG_ASSERT( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
+ if( pDescriptorItem )
+ {
+ ::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
+ SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
+
+ if ( pObj )
+ {
+ Size aDocSize(pWrtShell->GetDocSize());
+ const SwRect& rVisArea = pWrtShell->VisArea();
+ Point aStartPos = rVisArea.Center();
+ if(rVisArea.Width() > aDocSize.Width())
+ aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
+ if(rVisArea.Height() > aDocSize.Height())
+ aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
+
+ //determine the size of the object
+ if(pObj->IsGroupObject())
+ {
+ const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
+ aStartPos.X() -= rBoundRect.GetWidth()/2;
+ aStartPos.Y() -= rBoundRect.GetHeight()/2;
+ }
+
+ // TODO: unmark all other
+ pWrtShell->EnterStdMode();
+ pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
+ }
+ }
+ }
+ }
+ else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
+ {
+ Window* pWin = &( pWrtShell->GetView().GetViewFrame()->GetWindow() );
+
+ if ( pWin )
+ pWin->EnterWait();
+
+ if( !pWrtShell->HasDrawView() )
+ pWrtShell->MakeDrawView();
+
+ pSdrView = pWrtShell->GetDrawView();
+ if ( pSdrView )
+ {
+ SdrObject* pObj = NULL;
+ svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
+ aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
+ aDlg.Execute();
+ if ( pObj )
+ {
+ Size aDocSize( pWrtShell->GetDocSize() );
+ const SwRect& rVisArea = pWrtShell->VisArea();
+ Point aPos( rVisArea.Center() );
+ Size aSize;
+ Size aPrefSize( pObj->GetSnapRect().GetSize() );
+
+ if( rVisArea.Width() > aDocSize.Width())
+ aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
+
+ if(rVisArea.Height() > aDocSize.Height())
+ aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
+
+ if( aPrefSize.Width() && aPrefSize.Height() )
+ {
+ if( pWin )
+ aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
+ else
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
+ }
+ else
+ aSize = Size( 2835, 2835 );
+
+ pWrtShell->EnterStdMode();
+ pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
+ rReq.Ignore ();
+ }
+ }
+ if( pWin )
+ pWin->LeaveWait();
+ }
+
+ if( nSlotId == SID_DRAW_CS_ID )
+ {
+ //deselect if same custom shape is selected again
+ SwDrawBase* pFuncPtr = GetDrawFuncPtr();
+ if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
+ {
+ ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
+ rtl::OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
+ rtl::OUString aOld = pConstCustomShape->GetShapeType();
+ if( aNew == aOld )
+ {
+ bDeselect = true;
+ }
+ }
+ }
+
+ //deselect if same shape is selected again (but different custom shapes do have same slot id)
+ if ( bDeselect || (nSlotId == nDrawSfxId &&
+ (!pStringItem || (pStringItem->GetValue() == sDrawCustom))
+ && (nSlotId != SID_DRAW_CS_ID) ) )
+ {
+ if (GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ }
+
+ if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
+ pWrtShell->EnterSelFrmMode(NULL);
+ LeaveDrawCreate();
+
+ GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+
+ AttrChangedNotify(pWrtShell);
+ return;
+ }
+
+ LeaveDrawCreate();
+
+ if (pWrtShell->IsFrmSelected())
+ pWrtShell->EnterStdMode(); // wegen Bug #45639
+
+ SwDrawBase* pFuncPtr = NULL;
+
+ switch (nSlotId)
+ {
+ case SID_OBJECT_SELECT:
+ case SID_DRAW_SELECT:
+ pFuncPtr = new DrawSelection(pWrtShell, pEditWin, this);
+ nDrawSfxId = nFormSfxId = SID_OBJECT_SELECT;
+ sDrawCustom.Erase();
+ break;
+
+ case SID_DRAW_LINE:
+ case SID_DRAW_RECT:
+ case SID_DRAW_ELLIPSE:
+ case SID_DRAW_TEXT:
+ case SID_DRAW_TEXT_VERTICAL:
+ case SID_DRAW_TEXT_MARQUEE:
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ pFuncPtr = new ConstRectangle(pWrtShell, pEditWin, this);
+ nDrawSfxId = nSlotId;
+ sDrawCustom.Erase();
+ break;
+
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_BEZIER_NOFILL:
+ case SID_DRAW_FREELINE_NOFILL:
+ pFuncPtr = new ConstPolygon(pWrtShell, pEditWin, this);
+ nDrawSfxId = nSlotId;
+ sDrawCustom.Erase();
+ break;
+
+ case SID_DRAW_ARC:
+ case SID_DRAW_PIE:
+ case SID_DRAW_CIRCLECUT:
+ pFuncPtr = new ConstArc(pWrtShell, pEditWin, this);
+ nDrawSfxId = nSlotId;
+ sDrawCustom.Erase();
+ break;
+
+ case SID_FM_CREATE_CONTROL:
+ {
+ SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
+ if( pIdentifierItem )
+ nSlotId = pIdentifierItem->GetValue();
+ pFuncPtr = new ConstFormControl(pWrtShell, pEditWin, this);
+ nFormSfxId = nSlotId;
+ }
+ break;
+
+ case SID_DRAWTBX_CS_BASIC :
+ case SID_DRAWTBX_CS_SYMBOL :
+ case SID_DRAWTBX_CS_ARROW :
+ case SID_DRAWTBX_CS_FLOWCHART :
+ case SID_DRAWTBX_CS_CALLOUT :
+ case SID_DRAWTBX_CS_STAR :
+ case SID_DRAW_CS_ID :
+ {
+ pFuncPtr = new ConstCustomShape(pWrtShell, pEditWin, this, rReq );
+ nDrawSfxId = nSlotId;
+ if ( nSlotId != SID_DRAW_CS_ID )
+ {
+ if ( pStringItem )
+ {
+ sDrawCustom = pStringItem->GetValue();
+ aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = sDrawCustom;
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSlotId );
+ rBind.Update( nSlotId );
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ static sal_uInt16 __READONLY_DATA aInval[] =
+ {
+ // Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
+ SID_ATTRIBUTES_AREA,
+ SID_INSERT_DRAW,
+ 0
+ };
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+
+ BOOL bEndTextEdit = TRUE;
+ if (pFuncPtr)
+ {
+ if (GetDrawFuncPtr())
+ {
+ GetDrawFuncPtr()->Deactivate();
+ SetDrawFuncPtr(NULL);
+ }
+
+ SetDrawFuncPtr(pFuncPtr);
+ AttrChangedNotify(pWrtShell);
+
+ pFuncPtr->Activate(nSlotId);
+ NoRotate();
+ if(rReq.GetModifier() == KEY_MOD1)
+ {
+ if(SID_OBJECT_SELECT == nDrawSfxId )
+ {
+ pWrtShell->GotoObj(TRUE);
+ }
+ else
+ {
+ pFuncPtr->CreateDefaultObject();
+ pFuncPtr->Deactivate();
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+ pWrtShell->EnterStdMode();
+ SdrView *pTmpSdrView = pWrtShell->GetDrawView();
+ const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
+ if(rMarkList.GetMarkCount() == 1 &&
+ (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
+ SID_DRAW_TEXT_MARQUEE == nSlotId ))
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ BeginTextEdit(pObj);
+ bEndTextEdit = FALSE;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
+ pWrtShell->EnterSelFrmMode(NULL);
+ }
+
+ if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
+ pSdrView->SdrEndTextEdit( sal_True );
+
+ AttrChangedNotify(pWrtShell);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Drawing beenden
+ --------------------------------------------------------------------*/
+
+
+
+void SwView::ExitDraw()
+{
+ NoRotate();
+
+ if(pShell)
+ {
+ //#126062 # the shell may be invalid at close/reload/SwitchToViewShell
+ SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
+ USHORT nIdx = 0;
+ SfxShell* pTest = 0;
+ do
+ {
+ pTest = pDispatch->GetShell(nIdx++);
+ }
+ while( pTest && pTest != this && pTest != pShell);
+ if(pTest == pShell &&
+ // don't call LeaveSelFrmMode() etc. for the below,
+ // because objects may still be selected:
+ !pShell->ISA(SwDrawBaseShell) &&
+ !pShell->ISA(SwBezierShell) &&
+ !pShell->ISA(svx::ExtrusionBar) &&
+ !pShell->ISA(svx::FontworkBar))
+ {
+ SdrView *pSdrView = pWrtShell->GetDrawView();
+
+ if (pSdrView && pSdrView->IsGroupEntered())
+ {
+ pSdrView->LeaveOneGroup();
+ pSdrView->UnmarkAll();
+ GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
+ }
+
+ if (GetDrawFuncPtr())
+ {
+ if (pWrtShell->IsSelFrmMode())
+ pWrtShell->LeaveSelFrmMode();
+ GetDrawFuncPtr()->Deactivate();
+
+ SetDrawFuncPtr(NULL);
+ LeaveDrawCreate();
+
+ GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
+ }
+ GetEditWin().SetPointer(Pointer(POINTER_TEXT));
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Rotate-Mode abschalten
+ --------------------------------------------------------------------*/
+
+
+
+void SwView::NoRotate()
+{
+ if (IsDrawRotate())
+ {
+ pWrtShell->SetDragMode(SDRDRAG_MOVE);
+ FlipDrawRotate();
+
+ const SfxBoolItem aTmp( SID_OBJECT_ROTATE, sal_False );
+ GetViewFrame()->GetBindings().SetState( aTmp );
+ }
+}
+
+/******************************************************************************
+ * Beschreibung: DrawTextEditMode einschalten
+ ******************************************************************************/
+
+sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
+{
+ SdrObject* pObj;
+ SdrPageView* pPV;
+ SwWrtShell *pSh = &GetWrtShell();
+ SdrView *pSdrView = pSh->GetDrawView();
+ ASSERT( pSdrView, "EnterDrawTextMode without DrawView?" );
+
+ sal_Bool bReturn = sal_False;
+
+ sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
+ pSdrView->SetHitTolerancePixel( 2 );
+
+ if( pSdrView->IsMarkedHit( aDocPos ) &&
+ !pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
+ pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
+
+ // #108784#
+ // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
+ //pObj->ISA( SdrTextObj ) &&
+ ( pObj->ISA( SdrTextObj ) ||
+ ( pObj->ISA(SwDrawVirtObj) &&
+ ((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
+
+ !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
+ {
+ bReturn = BeginTextEdit( pObj, pPV, pEditWin, sal_False );
+ }
+
+ pSdrView->SetHitTolerancePixel( nOld );
+
+ return bReturn;
+}
+
+/******************************************************************************
+ * Beschreibung: DrawTextEditMode einschalten
+ ******************************************************************************/
+sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
+ bool bIsNewObj, bool bSetSelectionToStart)
+{
+ SwWrtShell *pSh = &GetWrtShell();
+ SdrView *pSdrView = pSh->GetDrawView();
+ SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
+ uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() );
+ if (pOutliner)
+ {
+ pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
+ pOutliner->SetSpeller(xSpell);
+ uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
+ pOutliner->SetHyphenator( xHyphenator );
+ pSh->SetCalcFieldValueHdl(pOutliner);
+
+ sal_uInt32 nCntrl = pOutliner->GetControlWord();
+ nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
+ nCntrl |= EE_CNTRL_URLSFXEXECUTE;
+
+ const SwViewOption *pOpt = pSh->GetViewOptions();
+
+ if (SwViewOption::IsFieldShadings())
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ else
+ nCntrl &= ~EE_CNTRL_MARKFIELDS;
+
+ if (pOpt->IsOnlineSpell())
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+
+ pOutliner->SetControlWord(nCntrl);
+ const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
+ pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
+
+ if( bIsNewObj )
+ pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == nDrawSfxId ||
+ SID_DRAW_CAPTION_VERTICAL == nDrawSfxId );
+ // #i7672#
+ // No longer necessary, see text below
+ // Color aBackground(pSh->GetShapeBackgrd());
+ // pOutliner->SetBackgroundColor(aBackground);
+
+ // OD 09.12.2002 #103045# - set default horizontal text direction at outliner
+ EEHorizontalTextDirection aDefHoriTextDir =
+ pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
+ pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
+ }
+
+ // #108784#
+ // To allow editing the referenced object from a SwDrawVirtObj here
+ // the original needs to be fetched evenually. This ATM activates the
+ // text edit mode for the original object.
+ SdrObject* pToBeActivated = pObj;
+
+ // #108784#
+ // Always the original object is edited. To allow the TextEdit to happen
+ // where the VirtObj is positioned, on demand a occurring offset is set at
+ // the TextEdit object. That offset is used for creating and managing the
+ // OutlinerView.
+ Point aNewTextEditOffset(0, 0);
+
+ if(pObj->ISA(SwDrawVirtObj))
+ {
+ SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
+ pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
+ aNewTextEditOffset = pVirtObj->GetOffset();
+ }
+
+ // set in each case, thus it will be correct for all objects
+ ((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
+
+ sal_Bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, sal_True, pOutliner, 0, sal_False, sal_False, sal_False ));
+
+ // #i7672#
+ // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
+ // sets the background color, an own background color needs to be set
+ // after TextEditing was started. This is now done here.
+ if(bRet)
+ {
+ OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
+
+ if(pView)
+ {
+ Color aBackground(pSh->GetShapeBackgrd());
+ pView->SetBackgroundColor(aBackground);
+ }
+
+ // editing should start at the end of text, spell checking at the beginning ...
+ ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
+ if (bSetSelectionToStart)
+ aNewSelection = ESelection();
+ pView->SetSelection(aNewSelection);
+ }
+
+ return bRet;
+}
+
+/******************************************************************************
+ * Beschreibung: Ist ein DrawTextObjekt selektiert?
+ ******************************************************************************/
+
+
+
+sal_Bool SwView::IsTextTool() const
+{
+ sal_uInt16 nId;
+ sal_uInt32 nInvent;
+ SdrView *pSdrView = GetWrtShell().GetDrawView();
+ ASSERT( pSdrView, "IsTextTool without DrawView?" );
+
+ if (pSdrView->IsCreateMode())
+ pSdrView->SetCreateMode(sal_False);
+
+ pSdrView->TakeCurrentObj(nId,nInvent);
+ return (nInvent==SdrInventor);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+SdrView* SwView::GetDrawView() const
+{
+ return GetWrtShell().GetDrawView();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+sal_Bool SwView::IsBezierEditMode()
+{
+ return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+sal_Bool SwView::IsFormMode() const
+{
+ if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
+ {
+ return (GetDrawFuncPtr()->IsInsertForm());
+ }
+
+ return AreOnlyFormsSelected();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
+{
+ if (pDrawActual)
+ delete pDrawActual;
+ pDrawActual = pFuncPtr;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwView::SetSelDrawSlot()
+{
+ nDrawSfxId = SID_OBJECT_SELECT;
+ sDrawCustom.Erase();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+sal_Bool SwView::AreOnlyFormsSelected() const
+{
+ if ( GetWrtShell().IsFrmSelected() )
+ return sal_False;
+
+ sal_Bool bForm = sal_True;
+
+ SdrView* pSdrView = GetWrtShell().GetDrawView();
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ sal_uInt32 nCount = rMarkList.GetMarkCount();
+
+ if (nCount)
+ {
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ // Sind ausser Controls noch normale Draw-Objekte selektiert?
+ SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if (!HasOnlyObj(pSdrObj, FmFormInventor))
+ {
+ bForm = sal_False;
+ break;
+ }
+ }
+ }
+ else
+ bForm = sal_False;
+
+ return bForm;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
+{
+ sal_Bool bRet = sal_False;
+
+ if (pSdrObj->IsGroupObject())
+ {
+ SdrObjList* pList = pSdrObj->GetSubList();
+ sal_uInt32 nCnt = pList->GetObjCount();
+
+ for (sal_uInt32 i = 0; i < nCnt; i++)
+ if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
+ break;
+ }
+ else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
+ return sal_True;
+
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
+{
+ sal_Bool bRet = sal_False;
+
+ if (pSdrObj->IsGroupObject())
+ {
+ SdrObjList* pList = pSdrObj->GetSubList();
+ sal_uInt32 nCnt = pList->GetObjCount();
+
+ for (sal_uInt32 i = 0; i < nCnt; i++)
+ if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
+ break;
+ }
+ else if (eObjInventor == pSdrObj->GetObjInventor())
+ return sal_True;
+
+ return bRet;
+}
+
+
+//#i87414# mod
+IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
+{
+ if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
+ GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
+{
+ sal_Bool bRet = sal_False;
+ SdrView *pSdrView = pWrtShell->GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ Point aPos( GetEditWin().LogicToPixel( rPt ) );
+
+ if (pOLV->IsWrongSpelledWordAtPos( aPos ))
+ {
+ bRet = sal_True;
+ Link aLink = LINK(this, SwView, OnlineSpellCallback);
+ pOLV->ExecuteSpellPopup( aPos,&aLink );
+ }
+ return bRet;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+sal_Bool SwView::IsDrawTextHyphenate()
+{
+ SdrView *pSdrView = pWrtShell->GetDrawView();
+ sal_Bool bHyphenate = sal_False;
+
+ SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
+ EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ if( pSdrView->GetAttributes( aNewAttr ) &&
+ aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
+ bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
+ GetValue();
+
+ return bHyphenate;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+
+
+void SwView::HyphenateDrawText()
+{
+ SdrView *pSdrView = pWrtShell->GetDrawView();
+ sal_Bool bHyphenate = IsDrawTextHyphenate();
+
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
+ pSdrView->SetAttributes( aSet );
+ GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
+}
+
+
+
diff --git a/sw/source/ui/uiview/viewfunc.hxx b/sw/source/ui/uiview/viewfunc.hxx
new file mode 100644
index 000000000000..f04db152ec2f
--- /dev/null
+++ b/sw/source/ui/uiview/viewfunc.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _VIEWFUNC_HXX
+#define _VIEWFUNC_HXX
+#include <tools/solar.h>
+
+class ImageButton;
+class Point;
+class PrintDialog;
+class SfxItemSet;
+class SfxPrinter;
+class SfxTabPage;
+class Size;
+class SvxRuler;
+class SwScrollbar;
+class ViewShell;
+class Window;
+class SwWrtShell;
+
+// folgende Funktionen stehen im viewprt.cxx
+PrintDialog* CreatePrintDialog( Window* , USHORT, SwWrtShell* );
+void SetPrinter( IDocumentDeviceAccess*, SfxPrinter*, BOOL bWeb );
+SfxTabPage* CreatePrintOptionsPage( Window*, const SfxItemSet& );
+void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb );
+
+// folgende Funktionen stehen im viewport.cxx
+void ViewResizePixel( const Window &rRef,
+ const Point &rOfst,
+ const Size &rSize,
+ const Size &rEditSz,
+ const BOOL bInner,
+ SwScrollbar& rVScrollbar,
+ SwScrollbar& rHScrollbar,
+ ImageButton* pPageUpBtn,
+ ImageButton* pPageDownBtn,
+ ImageButton* pNaviBtn,
+ Window& rScrollBarBox,
+ SvxRuler* pVLineal = 0,
+ SvxRuler* pHLineal = 0,
+ BOOL bWebView = FALSE,
+ BOOL bVRulerRight = FALSE );
+
+
+#endif
diff --git a/sw/source/ui/uiview/viewling.cxx b/sw/source/ui/uiview/viewling.cxx
new file mode 100755
index 000000000000..b3f73f7c38e4
--- /dev/null
+++ b/sw/source/ui/uiview/viewling.cxx
@@ -0,0 +1,1005 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <hintids.hxx>
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_STRINGSDTOR
+#include <svl/svstdarr.hxx>
+#endif
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <linguistic/lngprops.hxx>
+#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/ehdl.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/dialmgr.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/svxerr.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/SpellPortions.hxx>
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <initui.hxx> // fuer SpellPointer
+#include <uitool.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <basesh.hxx>
+#include <docsh.hxx> // CheckSpellChanges
+#include <viewopt.hxx> // Viewoptions
+#include <swundo.hxx> // fuer Undo-Ids
+#include <hyp.hxx> // Trennung
+#include <olmenu.hxx> // PopupMenu fuer OnlineSpelling
+#include <pam.hxx> // Spelling: Multiselektion
+#include <edtwin.hxx>
+#include <crsskip.hxx>
+#include <ndtxt.hxx>
+#include <vcl/lstbox.hxx>
+#include <cmdid.h>
+#include <globals.hrc>
+#include <comcore.hrc> // STR_MULT_INTERACT_SPELL_WARN
+#include <view.hrc>
+#include <hhcwrp.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+#include <unotools/processfactory.hxx>
+
+#include <vcl/svapp.hxx>
+#include <rtl/ustring.hxx>
+
+#include <cppuhelper/bootstrap.hxx>
+#include "stmenu.hxx" // PopupMenu for smarttags
+#include <svx/dialogs.hrc>
+#include <svtools/langtab.hxx>
+#include <unomid.h>
+#include <IMark.hxx>
+#include <xmloff/odffields.hxx>
+
+#include <memory>
+#include <editeng/editerr.hxx>
+
+using namespace sw::mark;
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::smarttags;
+
+/*--------------------------------------------------------------------
+ Beschreibung: Lingu-Dispatcher
+ --------------------------------------------------------------------*/
+
+
+void SwView::ExecLingu(SfxRequest &rReq)
+{
+ switch(rReq.GetSlot())
+ {
+ case SID_THESAURUS:
+ StartThesaurus();
+ rReq.Ignore();
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
+ i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True );
+ break;
+ case SID_CHINESE_CONVERSION:
+ {
+ //open ChineseTranslationDialog
+ Reference< XComponentContext > xContext(
+ ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
+ if(xContext.is())
+ {
+ Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
+ if(xMCF.is())
+ {
+ Reference< ui::dialogs::XExecutableDialog > xDialog(
+ xMCF->createInstanceWithContext(
+ rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
+ , xContext), UNO_QUERY);
+ Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
+ if( xInit.is() )
+ {
+ // initialize dialog
+ Reference< awt::XWindow > xDialogParentWindow(0);
+ Sequence<Any> aSeq(1);
+ Any* pArray = aSeq.getArray();
+ PropertyValue aParam;
+ aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
+ aParam.Value <<= makeAny(xDialogParentWindow);
+ pArray[0] <<= makeAny(aParam);
+ xInit->initialize( aSeq );
+
+ //execute dialog
+ sal_Int16 nDialogRet = xDialog->execute();
+ if( RET_OK == nDialogRet )
+ {
+ //get some parameters from the dialog
+ sal_Bool bToSimplified = sal_True;
+ sal_Bool bUseVariants = sal_True;
+ sal_Bool bCommonTerms = sal_True;
+ Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
+ xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
+ xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ //execute translation
+ sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = GetEditWin().GetDefaultFont( DEFAULTFONT_CJK_TEXT,
+ nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+
+ // disallow formatting, updating the view, ... while
+ // converting the document. (saves time)
+ // Also remember the current view and cursor position for later
+ pWrtShell->StartAction();
+
+ // remember cursor position data for later restoration of the cursor
+ const SwPosition *pPoint = pWrtShell->GetCrsr()->GetPoint();
+ sal_Bool bRestoreCursor = pPoint->nNode.GetNode().IsTxtNode();
+ const SwNodeIndex aPointNodeIndex( pPoint->nNode );
+ xub_StrLen nPointIndex = pPoint->nContent.GetIndex();;
+
+ // since this conversion is not interactive the whole converted
+ // document should be undone in a single undo step.
+ pWrtShell->StartUndo( UNDO_OVERWRITE );
+
+ StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False );
+
+ pWrtShell->EndUndo( UNDO_OVERWRITE );
+
+ if (bRestoreCursor)
+ {
+ SwTxtNode *pTxtNode = aPointNodeIndex.GetNode().GetTxtNode();
+ // check for unexpected error case
+ DBG_ASSERT( pTxtNode && pTxtNode->GetTxt().Len() >= nPointIndex,
+ "text missing: corrupted node?" );
+ if (!pTxtNode || pTxtNode->GetTxt().Len() < nPointIndex)
+ nPointIndex = 0;
+ // restore cursor to its original position
+ pWrtShell->GetCrsr()->GetPoint()->nContent.Assign( pTxtNode, nPointIndex );
+ }
+
+ // enable all, restore view and cursor position
+ pWrtShell->EndAction();
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ break;
+ }
+ case FN_HYPHENATE_OPT_DLG:
+ HyphenateDocument();
+ break;
+ default:
+ ASSERT(!this, falscher Dispatcher);
+ return;
+ }
+}
+
+/*--------------------------------------------------------------------
+ Description: start language specific text conversion
+ --------------------------------------------------------------------*/
+
+void SwView::StartTextConversion(
+ LanguageType nSourceLang,
+ LanguageType nTargetLang,
+ const Font *pTargetFont,
+ sal_Int32 nOptions,
+ sal_Bool bIsInteractive )
+{
+ // do not do text conversion if it is active elsewhere
+ if (GetWrtShell().HasConvIter())
+ {
+ return;
+ }
+
+ SpellKontext(sal_True);
+
+ const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+ const sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ sal_Bool bOldIns = pWrtShell->IsInsMode();
+ pWrtShell->SetInsMode( sal_True );
+
+ sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
+ pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
+
+ sal_Bool bStart = bSelection || pWrtShell->IsStartOfDoc();
+ sal_Bool bOther = !bSelection && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
+
+ {
+ const uno::Reference< lang::XMultiServiceFactory > xMgr(
+ comphelper::getProcessServiceFactory() );
+ SwHHCWrapper aWrap( this, xMgr, nSourceLang, nTargetLang, pTargetFont,
+ nOptions, bIsInteractive,
+ bStart, bOther, bSelection );
+ aWrap.Convert();
+ }
+
+ pWrtShell->SetInsMode( bOldIns );
+ pVOpt->SetIdle( bOldIdle );
+ SpellKontext(sal_False);
+}
+
+/*--------------------------------------------------------------------
+ spellcheck and text conversion related stuff
+ --------------------------------------------------------------------*/
+
+void SwView::SpellStart( SvxSpellArea eWhich,
+ sal_Bool bStartDone, sal_Bool bEndDone,
+ SwConversionArgs *pConvArgs )
+{
+ Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() );
+ sal_Bool bIsWrapReverse = (!pConvArgs && xProp.is()) ?
+ *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_WRAP_REVERSE) ).getValue() : sal_False;
+
+ SwDocPositions eStart = DOCPOS_START;
+ SwDocPositions eEnde = DOCPOS_END;
+ SwDocPositions eCurr = DOCPOS_CURR;
+ switch ( eWhich )
+ {
+ case SVX_SPELL_BODY:
+ if( bIsWrapReverse )
+ eCurr = DOCPOS_END;
+ else
+ eCurr = DOCPOS_START;
+ break;
+ case SVX_SPELL_BODY_END:
+ if( bIsWrapReverse )
+ {
+ if( bStartDone )
+ eStart = DOCPOS_CURR;
+ eCurr = DOCPOS_END;
+ }
+ else if( bStartDone )
+ eCurr = DOCPOS_START;
+ break;
+ case SVX_SPELL_BODY_START:
+ if( !bIsWrapReverse )
+ {
+ if( bEndDone )
+ eEnde = DOCPOS_CURR;
+ eCurr = DOCPOS_START;
+ }
+ else if( bEndDone )
+ eCurr = DOCPOS_END;
+ break;
+ case SVX_SPELL_OTHER:
+ if( bIsWrapReverse )
+ {
+ eStart = DOCPOS_OTHERSTART;
+ eEnde = DOCPOS_OTHEREND;
+ eCurr = DOCPOS_OTHEREND;
+ }
+ else
+ {
+ eStart = DOCPOS_OTHERSTART;
+ eEnde = DOCPOS_OTHEREND;
+ eCurr = DOCPOS_OTHERSTART;
+ }
+ break;
+ default:
+ ASSERT( !this, "SpellStart with unknown Area" );
+ }
+ pWrtShell->SpellStart( eStart, eEnde, eCurr, pConvArgs );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Fehlermeldung beim Spelling
+ --------------------------------------------------------------------*/
+
+
+// Der uebergebene Pointer nLang ist selbst der Wert
+IMPL_LINK( SwView, SpellError, LanguageType *, pLang )
+{
+#if OSL_DEBUG_LEVEL > 1
+ sal_Bool bFocus = GetEditWin().HasFocus();
+#endif
+ sal_uInt16 nPend = 0;
+
+ if ( pWrtShell->ActionPend() )
+ {
+ pWrtShell->Push();
+ pWrtShell->ClearMark();
+ do
+ {
+ pWrtShell->EndAction();
+ ++nPend;
+ }
+ while( pWrtShell->ActionPend() );
+ }
+ LanguageType eLang = pLang ? *pLang : LANGUAGE_NONE;
+ String aErr(SvtLanguageTable::GetLanguageString( eLang ) );
+
+ SwEditWin &rEditWin = GetEditWin();
+#if OSL_DEBUG_LEVEL > 1
+ bFocus = rEditWin.HasFocus();
+#endif
+ sal_uInt16 nWaitCnt = 0;
+ while( rEditWin.IsWait() )
+ {
+ rEditWin.LeaveWait();
+ ++nWaitCnt;
+ }
+ if ( LANGUAGE_NONE == eLang )
+ ErrorHandler::HandleError( ERRCODE_SVX_LINGU_NOLANGUAGE );
+ else
+ ErrorHandler::HandleError( *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
+
+ while( nWaitCnt )
+ {
+ rEditWin.EnterWait();
+ --nWaitCnt;
+ }
+#if OSL_DEBUG_LEVEL > 1
+ bFocus = GetEditWin().HasFocus();
+#endif
+
+ if ( nPend )
+ {
+ while( nPend-- )
+ pWrtShell->StartAction();
+ pWrtShell->Combine();
+ }
+#if OSL_DEBUG_LEVEL > 1
+ if( !bFocus )
+ GetEditWin().GrabFocus();
+#endif
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Spelling beenden und Cursor wiederherstellen
+ --------------------------------------------------------------------*/
+
+
+void SwView::SpellEnd( SwConversionArgs *pConvArgs )
+{
+ pWrtShell->SpellEnd( pConvArgs );
+ if( pWrtShell->IsExtMode() )
+ pWrtShell->SetMark();
+}
+
+
+void SwView::HyphStart( SvxSpellArea eWhich )
+{
+ switch ( eWhich )
+ {
+ case SVX_SPELL_BODY:
+ pWrtShell->HyphStart( DOCPOS_START, DOCPOS_END );
+ break;
+ case SVX_SPELL_BODY_END:
+ pWrtShell->HyphStart( DOCPOS_CURR, DOCPOS_END );
+ break;
+ case SVX_SPELL_BODY_START:
+ pWrtShell->HyphStart( DOCPOS_START, DOCPOS_CURR );
+ break;
+ case SVX_SPELL_OTHER:
+ pWrtShell->HyphStart( DOCPOS_OTHERSTART, DOCPOS_OTHEREND );
+ break;
+ default:
+ ASSERT( !this, "HyphStart with unknown Area" );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Interaktive Trennung
+ --------------------------------------------------------------------*/
+
+
+void SwView::HyphenateDocument()
+{
+ // do not hyphenate if interactive hyphenationg is active elsewhere
+ if (GetWrtShell().HasHyphIter())
+ {
+ MessBox( 0, WB_OK, String( SW_RES( STR_HYPH_TITLE ) ),
+ String( SW_RES( STR_MULT_INTERACT_HYPH_WARN ) ) ).Execute();
+ return;
+ }
+
+ SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, aEmptyStr, pEditWin,
+ RID_SVXERRCTX, &DIALOG_MGR() );
+
+ Reference< XHyphenator > xHyph( ::GetHyphenator() );
+ if (!xHyph.is())
+ {
+ ErrorHandler::HandleError( ERRCODE_SVX_LINGU_LINGUNOTEXISTS );
+ return;
+ }
+
+ if (pWrtShell->GetSelectionType() & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_DRW))
+ {
+ // Silbentrennung in einem Draw-Objekt
+ HyphenateDrawText();
+ }
+ else
+ {
+ SwViewOption* pVOpt = (SwViewOption*)pWrtShell->GetViewOptions();
+ sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() );
+
+
+ pWrtShell->StartUndo(UNDO_INSATTR); // spaeter gueltig
+
+ sal_Bool bHyphSpecial = xProp.is() ?
+ *(sal_Bool*)xProp->getPropertyValue( C2U(UPN_IS_HYPH_SPECIAL) ).getValue() : sal_False;
+ sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
+ pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
+ sal_Bool bOther = pWrtShell->HasOtherCnt() && bHyphSpecial && !bSelection;
+ sal_Bool bStart = bSelection || ( !bOther && pWrtShell->IsStartOfDoc() );
+ sal_Bool bStop = sal_False;
+ if( !bOther && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY) && !bSelection )
+ // kein Sonderbereich eingeschaltet
+ {
+ // Ich will auch in Sonderbereichen trennen
+ QueryBox aBox( &GetEditWin(), SW_RES( DLG_SPECIAL_FORCED ) );
+ if( aBox.Execute() == RET_YES )
+ {
+ bOther = sal_True;
+ if (xProp.is())
+ {
+ sal_Bool bTrue = sal_True;
+ Any aTmp(&bTrue, ::getBooleanCppuType());
+ xProp->setPropertyValue( C2U(UPN_IS_HYPH_SPECIAL), aTmp );
+ }
+ }
+ else
+ bStop = sal_True; // Nein Es wird nicht getrennt
+ }
+
+ if( !bStop )
+ {
+ SwHyphWrapper aWrap( this, xHyph, bStart, bOther, bSelection );
+ aWrap.SpellDocument();
+ pWrtShell->EndUndo(UNDO_INSATTR);
+ }
+ pVOpt->SetIdle( bOldIdle );
+ }
+}
+
+/*--------------------------------------------------------------------
+ --------------------------------------------------------------------*/
+
+bool SwView::IsValidSelectionForThesaurus() const
+{
+ // must not be a multi-selection, and if it is a selection it needs
+ // to be within a single paragraph
+
+ const bool bMultiSel = pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
+ const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
+ return !bMultiSel && (!bSelection || pWrtShell->IsSelOnePara() );
+}
+
+
+String SwView::GetThesaurusLookUpText( bool bSelection ) const
+{
+ return bSelection ? pWrtShell->GetSelTxt() : pWrtShell->GetCurWord();
+}
+
+
+void SwView::InsertThesaurusSynonym( const String &rSynonmText, const String &rLookUpText, bool bSelection )
+{
+ sal_Bool bOldIns = pWrtShell->IsInsMode();
+ pWrtShell->SetInsMode( sal_True );
+
+ pWrtShell->StartAllAction();
+ pWrtShell->StartUndo(UNDO_DELETE);
+
+ if( !bSelection )
+ {
+ if(pWrtShell->IsEndWrd())
+ pWrtShell->Left(CRSR_SKIP_CELLS, FALSE, 1, FALSE );
+
+ pWrtShell->SelWrd();
+
+ // make sure the selection build later from the
+ // data below does not include footnotes and other
+ // "in word" character to the left and right in order
+ // to preserve those. Therefore count those "in words"
+ // in order to modify the selection accordingly.
+ const sal_Unicode* pChar = rLookUpText.GetBuffer();
+ xub_StrLen nLeft = 0;
+ while (pChar && *pChar++ == CH_TXTATR_INWORD)
+ ++nLeft;
+ pChar = rLookUpText.Len() ? rLookUpText.GetBuffer() + rLookUpText.Len() - 1 : 0;
+ xub_StrLen nRight = 0;
+ while (pChar && *pChar-- == CH_TXTATR_INWORD)
+ ++nRight;
+
+ // adjust existing selection
+ SwPaM *pCrsr = pWrtShell->GetCrsr();
+ pCrsr->GetPoint()->nContent/*.nIndex*/ -= nRight;
+ pCrsr->GetMark()->nContent/*.nIndex*/ += nLeft;
+ }
+
+ pWrtShell->Insert( rSynonmText );
+
+ pWrtShell->EndUndo(UNDO_DELETE);
+ pWrtShell->EndAllAction();
+
+ pWrtShell->SetInsMode( bOldIns );
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Thesaurus starten
+ --------------------------------------------------------------------*/
+
+
+void SwView::StartThesaurus()
+{
+ if (!IsValidSelectionForThesaurus())
+ return;
+
+ SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, aEmptyStr, pEditWin,
+ RID_SVXERRCTX, &DIALOG_MGR() );
+
+ // Sprache rausholen
+ //
+ LanguageType eLang = pWrtShell->GetCurLang();
+ if( LANGUAGE_SYSTEM == eLang )
+ eLang = GetAppLanguage();
+
+ if( eLang == LANGUAGE_DONTKNOW || eLang == LANGUAGE_NONE )
+ {
+ LanguageType nLanguage = LANGUAGE_NONE;
+ SpellError( &nLanguage );
+ return;
+ }
+
+ SwViewOption* pVOpt = (SwViewOption*)pWrtShell->GetViewOptions();
+ sal_Bool bOldIdle = pVOpt->IsIdle();
+ pVOpt->SetIdle( sal_False );
+
+ // get initial LookUp text
+ const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
+ String aTmp = GetThesaurusLookUpText( bSelection );
+
+ Reference< XThesaurus > xThes( ::GetThesaurus() );
+ AbstractThesaurusDialog *pDlg = NULL;
+
+ if ( !xThes.is() || !xThes->hasLocale( SvxCreateLocale( eLang ) ) )
+ SpellError( &eLang );
+ else
+ {
+ // create dialog
+ { //Scope for SwWait-Object
+ SwWait aWait( *GetDocShell(), sal_True );
+ // load library with dialog only on demand ...
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ pDlg = pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang );
+ }
+
+ if ( pDlg->Execute()== RET_OK )
+ InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
+ }
+
+ delete pDlg;
+
+ pVOpt->SetIdle( bOldIdle );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Online-Vorschlaege anbieten
+ *--------------------------------------------------------------------*/
+
+//!! Start of extra code for context menu modifying extensions
+struct ExecuteInfo
+{
+ uno::Reference< frame::XDispatch > xDispatch;
+ util::URL aTargetURL;
+ uno::Sequence< PropertyValue > aArgs;
+};
+
+class AsyncExecute
+{
+public:
+ DECL_STATIC_LINK( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo* );
+};
+
+IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
+{
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ try
+ {
+ // Asynchronous execution as this can lead to our own destruction!
+ // Framework can recycle our current frame and the layout manager disposes all user interface
+ // elements if a component gets detached from its frame!
+ pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
+ }
+ catch ( Exception& )
+ {
+ }
+
+ Application::AcquireSolarMutex( nRef );
+ delete pExecuteInfo;
+ return 0;
+}
+//!! End of extra code for context menu modifying extensions
+
+sal_Bool SwView::ExecSpellPopup(const Point& rPt)
+{
+ sal_Bool bRet = sal_False;
+ const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+ if( pVOpt->IsOnlineSpell() &&
+ !pWrtShell->IsSelection())
+ {
+ if (pWrtShell->GetSelectionType() & nsSelectionType::SEL_DRW_TXT)
+ bRet = ExecDrwTxtSpellPopup(rPt);
+ else if (!pWrtShell->IsSelFrmMode())
+ {
+ const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True );
+ pWrtShell->Push();
+ SwRect aToFill;
+
+ // decide which variant of the context menu to use...
+ // if neither spell checking nor grammar checking provides suggestions use the
+ // default context menu.
+ bool bUseGrammarContext = false;
+ Reference< XSpellAlternatives > xAlt( pWrtShell->GetCorrection(&rPt, aToFill) );
+ /*linguistic2::*/ProofreadingResult aGrammarCheckRes;
+ sal_Int32 nErrorPosInText = -1;
+ sal_Int32 nErrorInResult = -1;
+ uno::Sequence< rtl::OUString > aSuggestions;
+ bool bCorrectionRes = false;
+ if (!xAlt.is() || xAlt->getAlternatives().getLength() == 0)
+ {
+ bCorrectionRes = pWrtShell->GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, &rPt, aToFill );
+ ::rtl::OUString aMessageText;
+ if (nErrorInResult >= 0)
+ aMessageText = aGrammarCheckRes.aErrors[ nErrorInResult ].aShortComment;
+ // we like to use the grammar checking context menu if we either get
+ // some suggestions or at least a comment about the error found...
+ bUseGrammarContext = bCorrectionRes &&
+ (aSuggestions.getLength() > 0 || aMessageText.getLength() > 0);
+ }
+
+ // open respective context menu for spell check or grammar errors with correction suggestions...
+ if ((!bUseGrammarContext && xAlt.is()) ||
+ (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.getLength() > 0))
+ {
+ // get paragraph text
+ String aParaText;
+ SwPosition aPoint( *pWrtShell->GetCrsr()->GetPoint() );
+ const SwTxtNode *pNode = dynamic_cast< const SwTxtNode * >(
+ &aPoint.nNode.GetNode() );
+ if (pNode)
+ aParaText = pNode->GetTxt(); // this may include hidden text but that should be Ok
+ else
+ {
+ DBG_ERROR( "text node expected but not found" );
+ }
+
+ bRet = sal_True;
+ pWrtShell->SttSelect();
+ std::auto_ptr< SwSpellPopup > pPopup;
+ if (bUseGrammarContext)
+ {
+ sal_Int32 nPos = aPoint.nContent.GetIndex();
+ (void) nPos;
+ pPopup = std::auto_ptr< SwSpellPopup >(new SwSpellPopup( pWrtShell, aGrammarCheckRes, nErrorInResult, aSuggestions, aParaText ));
+ }
+ else
+ pPopup = std::auto_ptr< SwSpellPopup >(new SwSpellPopup( pWrtShell, xAlt, aParaText ));
+ ui::ContextMenuExecuteEvent aEvent;
+ const Point aPixPos = GetEditWin().LogicToPixel( rPt );
+
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( pEditWin );
+ aEvent.ExecutePosition.X = aPixPos.X();
+ aEvent.ExecutePosition.Y = aPixPos.Y();
+ Menu* pMenu = 0;
+
+ ::rtl::OUString sMenuName = ::rtl::OUString::createFromAscii(
+ bUseGrammarContext ? "private:resource/GrammarContextMenu" : "private:resource/SpellContextMenu");
+ if(TryContextMenuInterception( *pPopup, sMenuName, pMenu, aEvent ))
+ {
+
+ //! happy hacking for context menu modifying extensions of this
+ //! 'custom made' menu... *sigh* (code copied from sfx2 and framework)
+ if ( pMenu )
+ {
+ OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ USHORT nId = ((PopupMenu*)pMenu)->Execute(pEditWin, aPixPos);
+ OUString aCommand = ((PopupMenu*)pMenu)->GetItemCommand(nId);
+ if (aCommand.getLength() == 0 )
+ {
+ if(!ExecuteMenuCommand( *dynamic_cast<PopupMenu*>(pMenu), *GetViewFrame(), nId ))
+ pPopup->Execute(nId);
+ }
+ else
+ {
+ SfxViewFrame *pSfxViewFrame = GetViewFrame();
+ uno::Reference< frame::XFrame > xFrame;
+ if ( pSfxViewFrame )
+ xFrame = pSfxViewFrame->GetFrame().GetFrameInterface();
+ com::sun::star::util::URL aURL;
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider( xFrame, UNO_QUERY );
+ uno::Reference< lang::XMultiServiceFactory > xMgr( utl::getProcessServiceFactory(), uno::UNO_QUERY );
+
+ try
+ {
+ uno::Reference< frame::XDispatch > xDispatch;
+ uno::Reference< util::XURLTransformer > xURLTransformer;
+ if (xMgr.is())
+ {
+ xURLTransformer = uno::Reference< util::XURLTransformer >( xMgr->createInstance(
+ C2U("com.sun.star.util.URLTransformer")), UNO_QUERY);
+ }
+
+ aURL.Complete = aCommand;
+ xURLTransformer->parseStrict(aURL);
+ uno::Sequence< beans::PropertyValue > aArgs;
+ xDispatch = xDispatchProvider->queryDispatch( aURL, rtl::OUString(), 0 );
+
+
+ if (xDispatch.is())
+ {
+ // Execute dispatch asynchronously
+ ExecuteInfo* pExecuteInfo = new ExecuteInfo;
+ pExecuteInfo->xDispatch = xDispatch;
+ pExecuteInfo->aTargetURL = aURL;
+ pExecuteInfo->aArgs = aArgs;
+ Application::PostUserEvent( STATIC_LINK(0, AsyncExecute , ExecuteHdl_Impl), pExecuteInfo );
+ }
+ }
+ catch (Exception &)
+ {
+ }
+ }
+ }
+ else
+ {
+ pPopup->Execute( aToFill.SVRect(), pEditWin );
+ }
+ }
+ }
+
+ pWrtShell->Pop( sal_False );
+ pWrtShell->LockView( bOldViewLock );
+ }
+ }
+ return bRet;
+}
+
+/** Function: ExecSmartTagPopup
+
+ This function shows the popup menu for smarttag
+ actions.
+*/
+
+sal_Bool SwView::ExecSmartTagPopup( const Point& rPt )
+{
+ sal_Bool bRet = sal_False;
+ const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True );
+ pWrtShell->Push();
+
+
+ // get word that was clicked on
+ // This data structure maps a smart tag type string to the property bag
+ SwRect aToFill;
+ Sequence< rtl::OUString > aSmartTagTypes;
+ Sequence< Reference< container::XStringKeyMap > > aStringKeyMaps;
+ Reference<text::XTextRange> xRange;
+
+ pWrtShell->GetSmartTagTerm( rPt, aToFill, aSmartTagTypes, aStringKeyMaps, xRange);
+ if ( xRange.is() && aSmartTagTypes.getLength() )
+ {
+ bRet = sal_True;
+ pWrtShell->SttSelect();
+ SwSmartTagPopup aPopup( this, aSmartTagTypes, aStringKeyMaps, xRange );
+ aPopup.Execute( aToFill.SVRect(), pEditWin );
+ }
+
+ pWrtShell->Pop( sal_False );
+ pWrtShell->LockView( bOldViewLock );
+
+ return bRet;
+}
+
+
+
+class SwFieldPopup : public PopupMenu
+{
+public:
+ SwFieldPopup() {
+ InsertItem(1, ::rtl::OUString::createFromAscii("Hello"));
+ }
+};
+
+class SwFieldListBox : public ListBox
+{
+public:
+ SwFieldListBox(Window* pParent) : ListBox(pParent /*, WB_DROPDOWN*/) {
+ }
+
+ void *GetImplWin() {
+ return NULL; //FIXME!!!
+// return mpImplWin;
+ }
+
+protected:
+ virtual void LoseFocus() {
+// printf("ListBox: lose focus!!\n");
+ ListBox::LoseFocus();
+ }
+
+ virtual void Select() {
+// printf("SELECT!!! IsTravelSelect=%i\n", IsTravelSelect());
+ ListBox::Select();
+ }
+};
+
+class SwFieldDialog : public Dialog
+{
+private:
+ SwFieldListBox aListBox;
+ Edit aText;
+ int selection;
+
+ DECL_LINK( MyListBoxHandler, ListBox * );
+
+public:
+ SwFieldDialog(Window* parent, IFieldmark *fieldBM) : Dialog(parent, WB_BORDER | WB_SYSTEMWINDOW | WB_NOSHADOW ), aListBox(this), aText(this, WB_RIGHT | WB_READONLY), selection(-1) {
+
+ assert(fieldBM!=NULL);
+ if (fieldBM!=NULL) {
+ const IFieldmark::parameter_map_t* const pParameters = fieldBM->GetParameters();
+ IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(::rtl::OUString::createFromAscii(ODF_FORMDROPDOWN_LISTENTRY));
+ if(pListEntries != pParameters->end())
+ {
+ Sequence< ::rtl::OUString> vListEntries;
+ pListEntries->second >>= vListEntries;
+ for( ::rtl::OUString* pCurrent = vListEntries.getArray();
+ pCurrent != vListEntries.getArray() + vListEntries.getLength();
+ ++pCurrent)
+ {
+ aListBox.InsertEntry(*pCurrent);
+ }
+ }
+ }
+ Size lbSize=aListBox.GetOptimalSize(WINDOWSIZE_PREFERRED);
+ lbSize.Width()+=50;
+ lbSize.Height()+=20;
+ aListBox.SetSizePixel(lbSize);
+ aListBox.SetSelectHdl( LINK( this, SwFieldDialog, MyListBoxHandler ) );
+ aListBox.Show();
+ aText.SetText(rtl::OUString::createFromAscii("Cancel"));
+ Size tSize=aText.GetOptimalSize(WINDOWSIZE_PREFERRED);
+ aText.SetSizePixel(Size(lbSize.Width(), tSize.Height()));
+ aText.SetPosPixel(Point(0, lbSize.Height()));
+ aText.Show();
+ SetSizePixel(Size(lbSize.Width(), lbSize.Height()+tSize.Height()));
+// SetSizePixel(Size(200, 200));
+ }
+
+ int getSelection() {
+ return selection;
+ }
+protected:
+ /*
+ virtual void LoseFocus() {
+ printf("lose focus!!\n");
+ Dialog::LoseFocus();
+ printf("close:\n");
+ EndDialog(8);
+ }
+ */
+
+ virtual long PreNotify( NotifyEvent& rNEvt ) {
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS && aListBox.GetImplWin()==rNEvt.GetWindow()) {
+ EndDialog(8);
+ return 1;
+ }
+ if (rNEvt.GetType() == EVENT_KEYINPUT) {
+// printf("PreNotify::KEYINPUT\n");
+ }
+ return Dialog::PreNotify(rNEvt);
+ }
+};
+
+IMPL_LINK( SwFieldDialog, MyListBoxHandler, ListBox *, pBox )
+{
+// printf("### DROP DOWN SELECT... IsTravelSelect=%i\n", pBox->IsTravelSelect());
+ if (pBox->IsTravelSelect()) {
+ return 0;
+ } else {
+ this->selection=pBox->GetSelectEntryPos();
+ EndDialog(9); //@TODO have meaningfull returns...
+ return 1;
+ }
+}
+
+
+BOOL SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM )
+{
+ sal_Bool bRet = sal_False;
+ const sal_Bool bOldViewLock = pWrtShell->IsViewLocked();
+ pWrtShell->LockView( sal_True );
+ pWrtShell->Push();
+
+ bRet=sal_True;
+ const Point aPixPos = GetEditWin().LogicToPixel( rPt );
+
+ SwFieldDialog aFldDlg(pEditWin, fieldBM);
+ aFldDlg.SetPosPixel(pEditWin->OutputToScreenPixel(aPixPos));
+
+ /*short ret=*/aFldDlg.Execute();
+ sal_Int32 selection=aFldDlg.getSelection();
+ if (selection>=0) {
+ (*fieldBM->GetParameters())[::rtl::OUString::createFromAscii(ODF_FORMDROPDOWN_RESULT)] = makeAny(selection);
+ }
+
+ pWrtShell->Pop( sal_False );
+ pWrtShell->LockView( bOldViewLock );
+
+ return bRet;
+}
+
diff --git a/sw/source/ui/uiview/viewmdi.cxx b/sw/source/ui/uiview/viewmdi.cxx
new file mode 100644
index 000000000000..9dfa8e79ecfa
--- /dev/null
+++ b/sw/source/ui/uiview/viewmdi.cxx
@@ -0,0 +1,754 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include "hintids.hxx"
+#include <vcl/svapp.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/request.hxx>
+#include <swmodule.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#include <viewopt.hxx>
+#include <frmatr.hxx>
+#ifndef _WDOCSH_HXX
+#include <wdocsh.hxx>
+#endif
+#include <uitool.hxx>
+#include <edtwin.hxx>
+#include <pagedesc.hxx>
+#include <IMark.hxx>
+#include <fldbas.hxx>
+#include <workctrl.hxx>
+#include <usrpref.hxx>
+#include <scroll.hxx>
+#ifndef _WVIEW_HXX
+#include <wview.hxx>
+#endif
+
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _VIEW_HRC
+#include <view.hrc>
+#endif
+#ifndef _RIBBAR_HRC
+#include <ribbar.hrc>
+#endif
+#ifndef _HELPID_H
+#include <helpid.h>
+#endif
+#ifndef _GLOBALS_HRC
+#include <globals.hrc>
+#endif
+
+#include <IDocumentSettingAccess.hxx>
+#include <PostItMgr.hxx>
+
+USHORT SwView::nMoveType = NID_PGE;
+sal_Int32 SwView::nActMark = 0;
+
+
+#define VIEW_IMAGECOLOR COL_LIGHTBLUE
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, BOOL bViewOnly )
+{
+ _SetZoom( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
+}
+
+void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType,
+ short nFactor, BOOL bViewOnly )
+{
+ BOOL bUnLockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( TRUE );
+ pWrtShell->LockPaint();
+
+ {
+ ACT_KONTEXT(pWrtShell);
+
+ long nFac = nFactor;
+
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
+
+ const SwPageDesc &rDesc = pWrtShell->GetPageDesc( pWrtShell->GetCurPageDesc() );
+ const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
+ const SwViewOption *pOpt = pWrtShell->GetViewOptions();
+ long lLeftMargin = 0;
+
+ if( eZoomType != SVX_ZOOM_PERCENT )
+ {
+ const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
+
+ const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
+ const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) );
+ Size aPageSize( aPageRect.SSize() );
+ Size aRootSize( aRootRect.SSize() );
+
+ //mod #i6193# added sidebar width
+ SwPostItMgr* pPostItMgr = GetPostItMgr();
+ if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
+ aPageSize.Width() += pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth();
+
+ const MapMode aTmpMap( MAP_TWIP );
+ const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
+
+ if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() ) // gespiegelte Seiten
+ {
+ const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
+ aPageSize.Width() += Abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
+ }
+
+ if( SVX_ZOOM_OPTIMAL == eZoomType )
+ {
+ if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
+ {
+ lLeftMargin = long(rLRSpace.GetLeft()) + aPageRect.Left() + nLeftOfst;
+ }
+ else
+ {
+ aPageSize.Width() -= ( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 );
+ lLeftMargin = long(rLRSpace.GetLeft()) + aPageRect.Left() + nLeftOfst;
+ }
+ nFac = aWindowSize.Width() * 100 / aPageSize.Width();
+ }
+ else if(SVX_ZOOM_WHOLEPAGE == eZoomType || SVX_ZOOM_PAGEWIDTH == eZoomType )
+ {
+ const long nOf = DOCUMENTBORDER * 2L;
+ long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nTmpWidth += nOf;
+ aPageSize.Height() += nOf;
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+
+ if ( SVX_ZOOM_WHOLEPAGE == eZoomType )
+ {
+ long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
+ nFac = Min( nFac, nVisPercent );
+ }
+ }
+ else /*if( SVX_ZOOM_PAGEWIDTH_NOBORDER == eZoomType )*/
+ {
+ const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
+ nFac = aWindowSize.Width() * 100 / nTmpWidth;
+ }
+ }
+
+ nFac = Max( long( MINZOOM ), nFac );
+
+ SwViewOption aOpt( *pOpt );
+ if ( !GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
+ //View updaten.
+ if ( !bViewOnly &&
+ (USHORT(nFac) != pUsrPref->GetZoom() ||
+ BYTE (eZoomType) != pUsrPref->GetZoomType()) )
+ {
+ pUsrPref->SetZoom ( USHORT(nFac) );
+ pUsrPref->SetZoomType( eZoomType );
+ SW_MOD()->ApplyUsrPref( *pUsrPref,
+ bViewOnly ? this: 0,
+ bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
+ pUsrPref->SetModified();
+ }
+ if ( pOpt->GetZoom() != (USHORT) nFac )
+ {
+ aOpt.SetZoom ( USHORT(nFac) );
+ aOpt.SetReadonly(pOpt->IsReadonly());
+ pWrtShell->ApplyViewOptions( aOpt );
+ }
+ if ( eZoomType != SVX_ZOOM_PERCENT )
+ {
+ Point aPos;
+
+ if ( eZoomType == SVX_ZOOM_WHOLEPAGE )
+ aPos.Y() = pWrtShell->GetAnyCurRect(RECT_PAGE).Top() - DOCUMENTBORDER;
+ else
+ {
+ //sicherstellen, dass sich der Cursor im sichtbaren
+ //Bereich befindet, damit nur 1x gescrollt wird
+ aPos.X() = lLeftMargin;
+ const SwRect &rCharRect = pWrtShell->GetCharRect();
+ if ( rCharRect.Top() > GetVisArea().Bottom() ||
+ rCharRect.Bottom() < aPos.Y() )
+ aPos.Y() = rCharRect.Top() - rCharRect.Height();
+ else
+ aPos.Y() = GetVisArea().Top();
+ }
+ SetVisArea( aPos );
+ }
+ // OS: Notloesung - in CalcVisArea wird u.U. wieder SetZoom gerufen und
+ // dann werden falsche Werte eingestellt
+ ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
+ CalcVisArea( rEditSize ); //fuer das Neuberechnen des sichtbaren Bereiches
+ }
+ else if ( USHORT(nFac) != pOpt->GetZoom() )
+ {
+ aOpt.SetZoom ( USHORT(nFac) );
+ pWrtShell->ApplyViewOptions( aOpt );
+ }
+
+ const Fraction aFrac( nFac, 100 );
+ pVRuler->SetZoom( aFrac );
+ pVRuler->ForceUpdate();
+ pHRuler->SetZoom( aFrac );
+ pHRuler->ForceUpdate();
+ ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
+ }
+ pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ pWrtShell->LockView( FALSE );
+
+// if ( mpPostItMgr )
+// {
+// mpPostItMgr->Rescale();
+// mpPostItMgr->CalcRects();
+// mpPostItMgr->LayoutPostIts();
+// }
+
+// eZoom = eZoomType;
+}
+
+void SwView::SetViewLayout( USHORT nColumns, bool bBookMode, BOOL bViewOnly )
+{
+ const BOOL bUnLockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( TRUE );
+ pWrtShell->LockPaint();
+
+ {
+
+ ACT_KONTEXT(pWrtShell);
+
+ if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly )
+ {
+ const BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
+
+ //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
+ //View updaten.
+ if ( nColumns != pUsrPref->GetViewLayoutColumns() ||
+ bBookMode != pUsrPref->IsViewLayoutBookMode() )
+ {
+ pUsrPref->SetViewLayoutColumns( nColumns );
+ pUsrPref->SetViewLayoutBookMode( bBookMode );
+ SW_MOD()->ApplyUsrPref( *pUsrPref,
+ bViewOnly ? this: 0,
+ bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
+ pUsrPref->SetModified();
+ }
+ }
+
+ const SwViewOption *pOpt = pWrtShell->GetViewOptions();
+
+ if ( nColumns != pOpt->GetViewLayoutColumns() ||
+ bBookMode != pOpt->IsViewLayoutBookMode() )
+ {
+ SwViewOption aOpt( *pOpt );
+ aOpt.SetViewLayoutColumns( nColumns );
+ aOpt.SetViewLayoutBookMode( bBookMode );
+ pWrtShell->ApplyViewOptions( aOpt );
+ }
+
+ pVRuler->ForceUpdate();
+ pHRuler->ForceUpdate();
+
+ }
+
+ pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ pWrtShell->LockView( FALSE );
+
+ SfxBindings& rBnd = GetViewFrame()->GetBindings();
+ rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
+ rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
+}
+
+/*
+ * Scrollbar - Handler
+ */
+
+int SwView::_CreateScrollbar( BOOL bHori )
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+ SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
+
+ ASSERT( !*ppScrollbar, "vorher abpruefen!" )
+
+ if( !bHori )
+ CreatePageButtons( !bShowAtResize );
+
+ *ppScrollbar = new SwScrollbar( pMDI, bHori );
+ UpdateScrollbars();
+ if(bHori)
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
+ else
+ (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
+ (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
+
+ (*ppScrollbar)->EnableDrag( TRUE );
+
+ if(GetWindow())
+ InvalidateBorder();
+
+ // Scrollbar muss nochmals getestet werden, da im InvalidateBorder u.U. der
+ // Scrollbar wieder geloescht wurde
+ if ( !bShowAtResize && (*ppScrollbar))
+ (*ppScrollbar)->ExtendedShow();
+
+ return 1;
+}
+
+void SwView::CreatePageButtons(BOOL bShow)
+{
+ Window *pMDI = &GetViewFrame()->GetWindow();
+ pPageUpBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEUP ), TRUE );
+ pPageUpBtn->SetHelpId(HID_SCRL_PAGEUP);
+ pPageDownBtn = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEDOWN ), FALSE );
+ pPageDownBtn->SetHelpId(HID_SCRL_PAGEDOWN);
+ Reference< XFrame > xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
+ pNaviBtn = new SwNaviImageButton(pMDI, xFrame );
+ pNaviBtn->SetHelpId(HID_SCRL_NAVI);
+ Link aLk( LINK( this, SwView, BtnPage ) );
+ pPageUpBtn->SetClickHdl( aLk );
+ pPageDownBtn->SetClickHdl( aLk );
+ if(nMoveType != NID_PGE)
+ {
+ Color aColor(VIEW_IMAGECOLOR);
+ SetImageButtonColor(aColor);
+ }
+
+ if(bShow)
+ {
+ pPageUpBtn->Show();
+ pPageDownBtn->Show();
+ pNaviBtn->Show();
+ }
+};
+
+/*
+ * Button-Handler
+ */
+IMPL_LINK( SwView, BtnPage, Button *, pButton )
+{
+ // #i75416# move the execution of the search to an asynchronously called static link
+ bool* pbNext = new bool( (pButton == pPageDownBtn) );
+ Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
+ return 0;
+}
+/*-----------------20.06.97 10:46-------------------
+
+--------------------------------------------------*/
+IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext )
+{
+ if ( !pbNext )
+ return 0;
+ bool bNext = *pbNext;
+ SwWrtShell& rSh = pThis->GetWrtShell();
+ switch( nMoveType )
+ {
+ case NID_PGE:
+ bNext ? pThis->PhyPageDown() : pThis->PhyPageUp();
+ break;
+ case NID_TBL :
+ rSh.EnterStdMode();
+ if(bNext)
+ rSh.MoveTable(fnTableNext, fnTableStart);
+ else
+ rSh.MoveTable(fnTablePrev, fnTableStart);
+ break;
+ case NID_FRM :
+ case NID_GRF:
+ case NID_OLE:
+ {
+ USHORT eType = GOTOOBJ_FLY_FRM;
+ if(nMoveType == NID_GRF)
+ eType = GOTOOBJ_FLY_GRF;
+ else if(nMoveType == NID_OLE)
+ eType = GOTOOBJ_FLY_OLE;
+ BOOL bSuccess = bNext ?
+ rSh.GotoNextFly(eType) :
+ rSh.GotoPrevFly(eType);
+ if(bSuccess)
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ }
+ break;
+ case NID_DRW :
+ case NID_CTRL:
+ rSh.GotoObj(bNext,
+ nMoveType == NID_DRW ?
+ GOTOOBJ_DRAW_SIMPLE :
+ GOTOOBJ_DRAW_CONTROL);
+ break;
+ case NID_REG :
+ rSh.EnterStdMode();
+ if(bNext)
+ rSh.MoveRegion(fnRegionNext, fnRegionStart);
+ else
+ rSh.MoveRegion(fnRegionPrev, fnRegionStart);
+
+ break;
+ case NID_BKM :
+ rSh.EnterStdMode();
+ pThis->GetViewFrame()->GetDispatcher()->Execute(bNext ?
+ FN_NEXT_BOOKMARK :
+ FN_PREV_BOOKMARK);
+ break;
+ case NID_OUTL:
+ rSh.EnterStdMode();
+ bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
+ break;
+ case NID_SEL :
+ bNext ? rSh.GoNextCrsr() : rSh.GoPrevCrsr();
+ break;
+ case NID_FTN:
+ rSh.EnterStdMode();
+ bNext ?
+ rSh.GotoNextFtnAnchor() :
+ rSh.GotoPrevFtnAnchor();
+ break;
+ case NID_MARK:
+ {
+ // unselect
+ rSh.MoveCrsr();
+ rSh.EnterStdMode();
+
+ // collect navigator reminders
+ IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
+ ::std::vector< const ::sw::mark::IMark* > vNavMarks;
+ for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
+ ppMark != pMarkAccess->getMarksEnd();
+ ppMark++)
+ {
+ if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
+ vNavMarks.push_back(ppMark->get());
+ }
+
+ // move
+ if(vNavMarks.size())
+ {
+ if(bNext)
+ {
+ nActMark++;
+ if (nActMark >= MAX_MARKS || nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
+ nActMark = 0;
+ }
+ else
+ {
+ nActMark--;
+ if (nActMark < 0 || nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
+ nActMark = vNavMarks.size()-1;
+ }
+ rSh.GotoMark(vNavMarks[nActMark]);
+ }
+ }
+ break;
+ case NID_POSTIT:
+ {
+ sw::sidebarwindows::SwSidebarWin* pPostIt = pThis->GetPostItMgr()->GetActiveSidebarWin();
+ if (pPostIt)
+ pThis->GetPostItMgr()->SetActiveSidebarWin(0);
+ SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
+ if (rSh.MoveFldType(pFldType, bNext))
+ pThis->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
+ else
+ //first/last item
+ pThis->GetPostItMgr()->SetActiveSidebarWin(pPostIt);
+ }
+ break;
+ case NID_SRCH_REP:
+ if(pSrchItem)
+ {
+ BOOL bBackward = pSrchItem->GetBackward();
+ if(rSh.HasSelection() && !bNext == rSh.IsCrsrPtAtEnd())
+ rSh.SwapPam();
+ pSrchItem->SetBackward(!bNext);
+ SfxRequest aReq(FN_REPEAT_SEARCH, SFX_CALLMODE_SLOT, pThis->GetPool());
+ pThis->ExecSearch(aReq);
+ pSrchItem->SetBackward(bBackward);
+ }
+ break;
+ case NID_INDEX_ENTRY:
+ rSh.GotoNxtPrvTOXMark(bNext);
+ break;
+
+ case NID_TABLE_FORMULA:
+ rSh.GotoNxtPrvTblFormula( bNext );
+ break;
+
+ case NID_TABLE_FORMULA_ERROR:
+ rSh.GotoNxtPrvTblFormula( bNext, TRUE );
+ break;
+ }
+ pThis->pEditWin->GrabFocus();
+ delete pbNext;
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* SwView::CreateTab()
+|*
+|* Beschreibung
+|* Ersterstellung VB 29.05.91
+|* Letzte Aenderung OS 09.05.96
+|*
+*************************************************************************/
+
+int SwView::CreateTab()
+{
+ pHRuler->SetActive(GetFrame() && IsActive());
+
+ pHRuler->Show();
+ InvalidateBorder();
+ return 1;
+}
+
+/*************************************************************************
+|*
+|* SwView::KillTab()
+|*
+|* Beschreibung
+|* Ersterstellung VB 29.05.91
+|* Letzte Aenderung OS 09.05.96
+|*
+*************************************************************************/
+
+int SwView::KillTab()
+{
+ pHRuler->Hide();
+ InvalidateBorder();
+ return 1;
+}
+
+void SwView::ChangeTabMetric( FieldUnit eUnit )
+{
+ if(pHRuler->GetUnit() != eUnit )
+ {
+ pHRuler->SetUnit( eUnit );
+ pHRuler->Invalidate();
+ }
+}
+
+void SwView::ChangeVLinealMetric( FieldUnit eUnit )
+{
+ if(pVRuler->GetUnit() != eUnit)
+ {
+ pVRuler->SetUnit( eUnit );
+ pVRuler->Invalidate();
+ }
+}
+/* -----------------------------07.04.01 17:09--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::GetVLinealMetric(FieldUnit& eToFill) const
+{
+ eToFill = pVRuler->GetUnit();
+}
+/* -----------------------------07.04.01 17:09--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::GetHLinealMetric(FieldUnit& eToFill) const
+{
+ eToFill = pHRuler->GetUnit();
+}
+/*************************************************************************
+|*
+|* SwView::CreateVLineal()
+|*
+|* Beschreibung
+|* Ersterstellung VB 29.05.91
+|*
+*************************************************************************/
+
+int SwView::CreateVLineal()
+{
+ pHRuler->SetBorderPos( pVRuler->GetSizePixel().Width()-1 );
+
+ pVRuler->SetActive(GetFrame() && IsActive());
+ pVRuler->Show();
+ InvalidateBorder();
+ return 1;
+}
+
+/*************************************************************************
+|*
+|* SwView::KillVLineal()
+|*
+|* Beschreibung
+|* Ersterstellung VB 29.05.91
+|*
+*************************************************************************/
+
+int SwView::KillVLineal()
+{
+ pVRuler->Hide();
+ pHRuler->SetBorderPos( 0 );
+ InvalidateBorder();
+ return 1;
+}
+/*************************************************************************
+|*
+|* SwView::ExecRulerClick()
+|*
+|* Beschreibung
+|* Ersterstellung OS 15.06.95
+|* Letzte Aenderung
+|*
+*************************************************************************/
+
+IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler )
+{
+ USHORT nDefPage = 0;
+ switch( pRuler->GetClickType() )
+ {
+ case RULER_TYPE_DONTKNOW:
+ case RULER_TYPE_OUTSIDE:
+ case RULER_TYPE_INDENT:
+ case RULER_TYPE_MARGIN1:
+ case RULER_TYPE_MARGIN2:
+ nDefPage = TP_PARA_STD;
+ break;
+ default:
+ nDefPage = TP_TABULATOR;
+
+ }
+
+ SfxUInt16Item aDefPage(SID_PARA_DLG, nDefPage);
+ GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aDefPage, 0L );
+ return 0;
+}
+
+
+/*-----------------20.02.97 09:11-------------------
+
+--------------------------------------------------*/
+
+USHORT SwView::GetMoveType()
+{
+ return nMoveType;
+}
+/*-----------------20.02.97 09:11-------------------
+
+--------------------------------------------------*/
+
+void SwView::SetMoveType(USHORT nSet)
+{
+ BOOL bLastPage = nMoveType == NID_PGE;
+ nMoveType = nSet;
+ BOOL bNewPage = nMoveType == NID_PGE;
+ if(bNewPage != bLastPage)
+ {
+ Color aColor(bNewPage ? COL_BLACK : VIEW_IMAGECOLOR);
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
+ while( pView )
+ {
+ pView->SetImageButtonColor(aColor);
+ pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
+ }
+ }
+}
+
+/*-----------------20.06.97 11:18-------------------
+
+--------------------------------------------------*/
+void SwView::SetActMark(sal_Int32 nSet)
+{
+ nActMark = nSet;
+}
+
+/*-----------------15.03.97 10:53-------------------
+
+--------------------------------------------------*/
+
+void SwView::SetImageButtonColor(Color& rColor)
+{
+ if(pPageUpBtn)
+ {
+ pPageUpBtn->SetControlForeground(rColor);
+ pPageDownBtn->SetControlForeground(rColor);
+ }
+}
+/* -----------------------------2002/06/26 13:57------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::ShowHScrollbar(sal_Bool bShow)
+{
+ DBG_ASSERT(pHScrollbar, "Scrollbar invalid");
+ pHScrollbar->ExtendedShow(bShow);
+}
+/* -----------------------------2002/06/26 13:57------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SwView::IsHScrollbarVisible()const
+{
+ DBG_ASSERT(pHScrollbar, "Scrollbar invalid");
+ return pHScrollbar->IsVisible( FALSE ) || pHScrollbar->IsAuto();
+}
+/* -----------------------------2002/06/26 13:57------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwView::ShowVScrollbar(sal_Bool bShow)
+{
+ DBG_ASSERT(pVScrollbar, "Scrollbar invalid");
+ pVScrollbar->ExtendedShow(bShow);
+ pPageUpBtn->Show(bShow);
+ pPageDownBtn->Show(bShow);
+ pNaviBtn->Show(bShow);
+}
+/* -----------------------------2002/06/26 13:57------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool SwView::IsVScrollbarVisible()const
+{
+ DBG_ASSERT(pVScrollbar, "Scrollbar invalid");
+ return pVScrollbar->IsVisible( FALSE );
+}
+
+
diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx
new file mode 100644
index 000000000000..b343619f2ea8
--- /dev/null
+++ b/sw/source/ui/uiview/viewport.cxx
@@ -0,0 +1,1384 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include "hintids.hxx"
+#include <vcl/help.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/paperinf.hxx>
+#include <editeng/lrspitem.hxx>
+#include <sfx2/bindings.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <swmodule.hxx>
+#include <viewopt.hxx>
+#include <frmatr.hxx>
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#include <edtwin.hxx>
+#include <scroll.hxx>
+#ifndef _WVIEW_HXX
+#include <wview.hxx>
+#endif
+#include <usrpref.hxx>
+#include <pagedesc.hxx>
+#include <workctrl.hxx>
+#include <crsskip.hxx>
+
+#include <PostItMgr.hxx>
+
+#include <IDocumentSettingAccess.hxx>
+
+//Das SetVisArea der DocShell darf nicht vom InnerResizePixel gerufen werden.
+//Unsere Einstellungen muessen aber stattfinden.
+#ifndef WB_RIGHT_ALIGNED
+#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
+#endif
+
+static BOOL bProtectDocShellVisArea = FALSE;
+
+static USHORT nPgNum = 0;
+
+BOOL SwView::IsDocumentBorder()
+{
+ return GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ||
+ pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ||
+ SVX_ZOOM_PAGEWIDTH_NOBORDER == (SvxZoomType)pWrtShell->GetViewOptions()->GetZoomType();
+}
+
+inline long GetLeftMargin( SwView &rView )
+{
+ SvxZoomType eType = (SvxZoomType)rView.GetWrtShell().GetViewOptions()->GetZoomType();
+ long lRet = rView.GetWrtShell().GetAnyCurRect(RECT_PAGE_PRT).Left();
+ return eType == SVX_ZOOM_PERCENT ? lRet + DOCUMENTBORDER :
+ eType == SVX_ZOOM_PAGEWIDTH || eType == SVX_ZOOM_PAGEWIDTH_NOBORDER ? 0 :
+ lRet + DOCUMENTBORDER + nLeftOfst;
+}
+
+//-------------------------------------------------------------------------
+
+void lcl_GetPos(SwView* pView,
+ Point& rPos,
+ SwScrollbar* pScrollbar,
+ BOOL bBorder)
+{
+ SwWrtShell &rSh = pView->GetWrtShell();
+ const Size aDocSz( rSh.GetDocSize() );
+
+ const long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ BOOL bHori = pScrollbar->IsHoriScroll();
+
+ const long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0);
+ long Point:: *pPt = bHori ? &Point::nA : &Point::nB;
+ long Size:: *pSz = bHori ? &Size::nA : &Size::nB;
+
+ long lDelta = lPos - rSh.VisArea().Pos().*pPt;
+ const long lSize = aDocSz.*pSz + lBorder;
+ // Bug 11693: sollte rechts oder unten zuviel Wiese sein, dann muss
+ // diese von der VisArea herausgerechnet werden!
+ long nTmp = pView->GetVisArea().Right()+lDelta;
+ if ( bHori && nTmp > lSize )
+ lDelta -= nTmp - lSize;
+ nTmp = pView->GetVisArea().Bottom()+lDelta;
+ if ( !bHori && nTmp > lSize )
+ lDelta -= nTmp - lSize;
+
+ rPos.*pPt += lDelta;
+ if ( bBorder && rPos.*pPt < DOCUMENTBORDER )
+ rPos.*pPt = DOCUMENTBORDER;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Nullpunkt Lineal setzen
+ --------------------------------------------------------------------*/
+
+void SwView::InvalidateRulerPos()
+{
+ static USHORT __READONLY_DATA aInval[] =
+ {
+ SID_ATTR_PARA_LRSPACE, SID_RULER_BORDERS, SID_RULER_PAGE_POS,
+ SID_RULER_LR_MIN_MAX, SID_ATTR_LONG_ULSPACE, SID_ATTR_LONG_LRSPACE,
+ SID_RULER_BORDER_DISTANCE,
+ SID_ATTR_PARA_LRSPACE_VERTICAL, SID_RULER_BORDERS_VERTICAL,
+ SID_RULER_TEXT_RIGHT_TO_LEFT,
+ SID_RULER_ROWS, SID_RULER_ROWS_VERTICAL, FN_STAT_PAGE,
+ 0
+ };
+
+ GetViewFrame()->GetBindings().Invalidate(aInval);
+
+ DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
+ pHRuler->ForceUpdate();
+ pVRuler->ForceUpdate();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: begrenzt das Scrollen soweit, dass jeweils nur einen
+ viertel Bildschirm bis vor das Ende des Dokumentes
+ gescrollt werden kann.
+ --------------------------------------------------------------------*/
+
+long SwView::SetHScrollMax( long lMax )
+{
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ const long lSize = GetDocSz().Width() + lBorder - aVisArea.GetWidth();
+
+ // bei negativen Werten ist das Dokument vollstaendig sichtbar;
+ // in diesem Fall kein Scrollen
+ return Max( Min( lMax, lSize ), 0L );
+}
+
+
+long SwView::SetVScrollMax( long lMax )
+{
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ long lSize = GetDocSz().Height() + lBorder - aVisArea.GetHeight();
+ return Max( Min( lMax, lSize), 0L ); // siehe horz.
+}
+
+
+Point SwView::AlignToPixel(const Point &rPt) const
+{
+ return GetEditWin().PixelToLogic( GetEditWin().LogicToPixel( rPt ) );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Dokumentgroesse hat sich geaendert
+ --------------------------------------------------------------------*/
+
+void SwView::DocSzChgd(const Size &rSz)
+{
+
+extern int bDocSzUpdated;
+
+
+aDocSz = rSz;
+
+ if( !pWrtShell || aVisArea.IsEmpty() ) // keine Shell -> keine Aenderung
+ {
+ bDocSzUpdated = FALSE;
+ return;
+ }
+
+ //Wenn Text geloescht worden ist, kann es sein, dass die VisArea hinter
+ //den sichtbaren Bereich verweist
+ Rectangle aNewVisArea( aVisArea );
+ BOOL bModified = false;
+ SwTwips lGreenOffset = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
+ SwTwips lTmp = aDocSz.Width() + lGreenOffset;
+
+ if ( aNewVisArea.Right() >= lTmp )
+ {
+ lTmp = aNewVisArea.Right() - lTmp;
+ aNewVisArea.Right() -= lTmp;
+ aNewVisArea.Left() -= lTmp;
+ bModified = TRUE;
+ }
+
+ lTmp = aDocSz.Height() + lGreenOffset;
+ if ( aNewVisArea.Bottom() >= lTmp )
+ {
+ lTmp = aNewVisArea.Bottom() - lTmp;
+ aNewVisArea.Bottom() -= lTmp;
+ aNewVisArea.Top() -= lTmp;
+ bModified = TRUE;
+ }
+
+ if ( bModified )
+ SetVisArea( aNewVisArea, FALSE );
+
+ if ( UpdateScrollbars() && !bInOuterResizePixel && !bInInnerResizePixel &&
+ !GetViewFrame()->GetFrame().IsInPlace())
+ OuterResizePixel( Point(),
+ GetViewFrame()->GetWindow().GetOutputSizePixel() );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Visarea neu setzen
+ --------------------------------------------------------------------*/
+
+void SwView::SetVisArea( const Rectangle &rRect, BOOL bUpdateScrollbar )
+{
+ const Size aOldSz( aVisArea.GetSize() );
+
+ const Point aTopLeft( AlignToPixel( rRect.TopLeft() ));
+ const Point aBottomRight( AlignToPixel( rRect.BottomRight() ));
+ Rectangle aLR( aTopLeft, aBottomRight );
+
+ if( aLR == aVisArea )
+ return;
+
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+
+ // keine negative Position, keine neg. Groesse
+ if( aLR.Top() < lMin )
+ {
+ aLR.Bottom() += lMin - aLR.Top();
+ aLR.Top() = lMin;
+ }
+ if( aLR.Left() < lMin )
+ {
+ aLR.Right() += lMin - aLR.Left();
+ aLR.Left() = lMin;
+ }
+ if( aLR.Right() < 0 )
+ aLR.Right() = 0;
+ if( aLR.Bottom() < 0 )
+ aLR.Bottom() = 0;
+
+ if( aLR == aVisArea )
+ return;
+
+ const Size aSize( aLR.GetSize() );
+ if( aSize.Width() < 0 || aSize.Height() < 0 )
+ return;
+
+ //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
+ //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
+ //umgerechnet werden.
+ //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
+ //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
+ //lediglich (in Dokumentkoordinaten) vorgemerkt.
+ if ( pWrtShell && pWrtShell->ActionPend() )
+ pWrtShell->GetWin()->Update();
+
+ aVisArea = aLR;
+
+ const BOOL bOuterResize = bUpdateScrollbar && UpdateScrollbars();
+
+ if ( pWrtShell )
+ {
+ pWrtShell->VisPortChgd( aVisArea );
+ if ( aOldSz != pWrtShell->VisArea().SSize() &&
+ ( Abs(aOldSz.Width() - pWrtShell->VisArea().Width()) > 2 ||
+ Abs(aOldSz.Height() - pWrtShell->VisArea().Height()) > 2 ) )
+ pWrtShell->CheckBrowseView( FALSE );
+ }
+
+ if ( !bProtectDocShellVisArea )
+ {
+ //Wenn die Groesse der VisArea unveraendert ist, reichen wir die
+ //Groesse der VisArea vom InternalObject weiter. Damit soll der
+ //Transport von Fehlern vermieden werden.
+ Rectangle aVis( aVisArea );
+ if ( aVis.GetSize() == aOldSz )
+ aVis.SetSize( GetDocShell()->SfxObjectShell::GetVisArea(ASPECT_CONTENT).GetSize() );
+ // TODO/LATER: why casting?!
+ //GetDocShell()->SfxInPlaceObject::GetVisArea().GetSize() );
+
+ //Bei embedded immer mit Modify...
+ // TODO/LATER: why casting?!
+ GetDocShell()->SfxObjectShell::SetVisArea( aVis );
+ /*
+ if ( GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ GetDocShell()->SfxInPlaceObject::SetVisArea( aVis );
+ else
+ GetDocShell()->SvEmbeddedObject::SetVisArea( aVis );*/
+ }
+
+ SfxViewShell::VisAreaChanged( aVisArea );
+
+ InvalidateRulerPos();
+
+ SwEditWin::ClearTip();
+
+ if ( bOuterResize && !bInOuterResizePixel && !bInInnerResizePixel)
+ OuterResizePixel( Point(),
+ GetViewFrame()->GetWindow().GetOutputSizePixel() );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Pos VisArea setzen
+ --------------------------------------------------------------------*/
+
+void SwView::SetVisArea( const Point &rPt, BOOL bUpdateScrollbar )
+{
+ //einmal alignen, damit Brushes korrekt angesetzt werden.
+ //MA 31. May. 96: Das geht in der BrowseView schief, weil evlt.
+ //nicht das ganze Dokument sichtbar wird. Da der Inhalt in Frames
+ //passgenau ist, kann nicht aligned werden (bessere Idee?!?!)
+ //MA 29. Oct. 96 (fix: Bild.de, 200%) ganz ohne Alignment geht es nicht
+ //mal sehen wie weit wir mit der halben BrushSize kommen.
+ //TODO: why BRUSH_SIZE?
+ Point aPt( rPt );
+// const long nTmp = GetWrtShell().IsFrameView() ? BRUSH_SIZE/2 : BRUSH_SIZE;
+ const long nTmp = GetWrtShell().IsFrameView() ? 4 : 8;
+ aPt = GetEditWin().LogicToPixel( aPt );
+ aPt.X() -= aPt.X() % nTmp;
+ aPt.Y() -= aPt.Y() % nTmp;
+ aPt = GetEditWin().PixelToLogic( aPt );
+
+ if ( aPt == aVisArea.TopLeft() )
+ return;
+
+ const long lXDiff = aVisArea.Left() - aPt.X();
+ const long lYDiff = aVisArea.Top() - aPt.Y();
+ SetVisArea( Rectangle( aPt,
+ Point( aVisArea.Right() - lXDiff, aVisArea.Bottom() - lYDiff ) ),
+ bUpdateScrollbar);
+}
+
+
+void SwView::CheckVisArea()
+{
+ pHScrollbar->SetAuto( pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
+ !GetViewFrame()->GetFrame().IsInPlace() );
+ if ( IsDocumentBorder() )
+ {
+ if ( aVisArea.Left() != DOCUMENTBORDER ||
+ aVisArea.Top() != DOCUMENTBORDER )
+ {
+ Rectangle aNewVisArea( aVisArea );
+ aNewVisArea.Move( DOCUMENTBORDER - aVisArea.Left(),
+ DOCUMENTBORDER - aVisArea.Top() );
+ SetVisArea( aNewVisArea, TRUE );
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Sichtbaren Bereich berechnen
+
+ OUT Point *pPt: neue Position des sichtbaren
+ Bereiches
+ IN Rectangle &rRect: Rechteck, das sich innerhalb des neuen
+ sichtbaren Bereiches befinden soll
+ USHORT nRange optional exakte Angabe des Bereiches,
+ um den ggfs. gescrollt werden soll
+ --------------------------------------------------------------------*/
+
+void SwView::CalcPt( Point *pPt, const Rectangle &rRect,
+ USHORT nRangeX, USHORT nRangeY)
+{
+
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+
+ long nYScroll = GetYScroll();
+ long nDesHeight = rRect.GetHeight();
+ long nCurHeight = aVisArea.GetHeight();
+ nYScroll = Min(nYScroll, nCurHeight - nDesHeight); // wird es knapp, dann nicht zuviel scrollen
+ if(nDesHeight > nCurHeight) // die Hoehe reicht nicht aus, dann interessiert nYScroll nicht mehr
+ {
+ pPt->Y() = rRect.Top();
+ pPt->Y() = Max( lMin, pPt->Y() );
+ }
+ else if ( rRect.Top() < aVisArea.Top() ) //Verschiebung nach oben
+ {
+ pPt->Y() = rRect.Top() - (nRangeY != USHRT_MAX ? nRangeY : nYScroll);
+ pPt->Y() = Max( lMin, pPt->Y() );
+ }
+ else if( rRect.Bottom() > aVisArea.Bottom() ) //Verschiebung nach unten
+ {
+ pPt->Y() = rRect.Bottom() -
+ (aVisArea.GetHeight()) + ( nRangeY != USHRT_MAX ?
+ nRangeY : nYScroll );
+ pPt->Y() = SetVScrollMax( pPt->Y() );
+ }
+ long nXScroll = GetXScroll();
+ if ( rRect.Right() > aVisArea.Right() ) //Verschiebung nach rechts
+ {
+ pPt->X() = rRect.Right() -
+ (aVisArea.GetWidth()) +
+ (nRangeX != USHRT_MAX ? nRangeX : nXScroll);
+ pPt->X() = SetHScrollMax( pPt->X() );
+ }
+ else if ( rRect.Left() < aVisArea.Left() ) //Verschiebung nach links
+ {
+ pPt->X() = rRect.Left() - (nRangeX != USHRT_MAX ? nRangeX : nXScroll);
+ pPt->X() = Max( ::GetLeftMargin( *this ) + nLeftOfst, pPt->X() );
+ pPt->X() = Min( rRect.Left() - nScrollX, pPt->X() );
+ pPt->X() = Max( 0L, pPt->X() );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Scrolling
+ --------------------------------------------------------------------*/
+
+BOOL SwView::IsScroll( const Rectangle &rRect ) const
+{
+ return bCenterCrsr || bTopCrsr || !aVisArea.IsInside(rRect);
+}
+
+
+void SwView::Scroll( const Rectangle &rRect, USHORT nRangeX, USHORT nRangeY )
+{
+ if ( aVisArea.IsEmpty() )
+ return;
+
+ Rectangle aOldVisArea( aVisArea );
+ long nDiffY = 0;
+
+ Window* pCareWn = ViewShell::GetCareWin(GetWrtShell());
+ if ( pCareWn )
+ {
+ Rectangle aDlgRect( GetEditWin().PixelToLogic(
+ pCareWn->GetWindowExtentsRelative( &GetEditWin() ) ) );
+ // Nur, wenn der Dialog nicht rechts oder links der VisArea liegt:
+ if ( aDlgRect.Left() < aVisArea.Right() &&
+ aDlgRect.Right() > aVisArea.Left() )
+ {
+ // Falls wir nicht zentriert werden sollen, in der VisArea liegen
+ // und nicht vom Dialog ueberdeckt werden ...
+ if ( !bCenterCrsr && aOldVisArea.IsInside( rRect )
+ && ( rRect.Left() > aDlgRect.Right()
+ || rRect.Right() < aDlgRect.Left()
+ || rRect.Top() > aDlgRect.Bottom()
+ || rRect.Bottom() < aDlgRect.Top() ) )
+ return;
+
+ // Ist oberhalb oder unterhalb der Dialogs mehr Platz?
+ long nTopDiff = aDlgRect.Top() - aVisArea.Top();
+ long nBottomDiff = aVisArea.Bottom() - aDlgRect.Bottom();
+ if ( nTopDiff < nBottomDiff )
+ {
+ if ( nBottomDiff > 0 ) // Ist unterhalb ueberhaupt Platz?
+ { // dann verschieben wir die Oberkante und merken uns dies
+ nDiffY = aDlgRect.Bottom() - aVisArea.Top();
+ aVisArea.Top() += nDiffY;
+ }
+ }
+ else
+ {
+ if ( nTopDiff > 0 ) // Ist oberhalb ueberhaupt Platz?
+ aVisArea.Bottom() = aDlgRect.Top(); // Unterkante aendern
+ }
+ }
+ }
+
+ //s.o. !IsScroll()
+ if( !(bCenterCrsr || bTopCrsr) && aVisArea.IsInside( rRect ) )
+ {
+ aVisArea = aOldVisArea;
+ return;
+ }
+ //falls das Rechteck groesser als der sichtbare Bereich -->
+ //obere linke Ecke
+ Size aSize( rRect.GetSize() );
+ const Size aVisSize( aVisArea.GetSize() );
+ if( !aVisArea.IsEmpty() && (
+ aSize.Width() + GetXScroll() > aVisSize.Width() ||
+ aSize.Height()+ GetYScroll() > aVisSize.Height() ))
+ {
+ Point aPt( aVisArea.TopLeft() );
+ aSize.Width() = Min( aSize.Width(), aVisSize.Width() );
+ aSize.Height()= Min( aSize.Height(),aVisSize.Height());
+
+ CalcPt( &aPt, Rectangle( rRect.TopLeft(), aSize ),
+ static_cast< USHORT >((aVisSize.Width() - aSize.Width()) / 2),
+ static_cast< USHORT >((aVisSize.Height()- aSize.Height())/ 2) );
+
+ if( bTopCrsr )
+ {
+ const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPt.Y() = Min( Max( nBorder, rRect.Top() ),
+ aDocSz.Height() + nBorder -
+ aVisArea.GetHeight() );
+ }
+ aPt.Y() -= nDiffY;
+ aVisArea = aOldVisArea;
+ SetVisArea( aPt );
+ return;
+ }
+ if( !bCenterCrsr )
+ {
+ Point aPt( aVisArea.TopLeft() );
+ CalcPt( &aPt, rRect, nRangeX, nRangeY );
+
+ if( bTopCrsr )
+ {
+ const long nBorder = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPt.Y() = Min( Max( nBorder, rRect.Top() ),
+ aDocSz.Height() + nBorder -
+ aVisArea.GetHeight() );
+ }
+
+ aPt.Y() -= nDiffY;
+ aVisArea = aOldVisArea;
+ SetVisArea( aPt );
+ return;
+ }
+
+ //Cursor zentrieren
+ Point aPnt( aVisArea.TopLeft() );
+ // ... in Y-Richtung auf jeden Fall
+ aPnt.Y() += ( rRect.Top() + rRect.Bottom()
+ - aVisArea.Top() - aVisArea.Bottom() ) / 2 - nDiffY;
+ // ... in X-Richtung nur, wenn das Rechteck rechts oder links aus der
+ // VisArea hinausragt.
+ if ( rRect.Right() > aVisArea.Right() || rRect.Left() < aVisArea.Left() )
+ {
+ aPnt.X() += ( rRect.Left() + rRect.Right()
+ - aVisArea.Left() - aVisArea.Right() ) / 2;
+ aPnt.X() = SetHScrollMax( aPnt.X() );
+ const SwTwips lMin = IsDocumentBorder() ? DOCUMENTBORDER : 0;
+ aPnt.X() = Max( (GetLeftMargin( *this ) - lMin) + nLeftOfst, aPnt.X() );
+ }
+ aVisArea = aOldVisArea;
+ if( pCareWn )
+ { // Wenn wir nur einem Dialog ausweichen wollen, wollen wir nicht ueber
+ // das Ende des Dokument hinausgehen.
+ aPnt.Y() = SetVScrollMax( aPnt.Y() );
+ }
+ SetVisArea( aPnt );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Seitenweises Scrollen
+ Liefern den Wert, um den bei PageUp / -Down gescrollt werden soll
+ --------------------------------------------------------------------*/
+
+BOOL SwView::GetPageScrollUpOffset( SwTwips &rOff ) const
+{
+ if ( !aVisArea.Top() || !aVisArea.GetHeight() )
+ return FALSE;
+ long nYScrl = GetYScroll() / 2;
+ rOff = -(aVisArea.GetHeight() - nYScrl);
+ //nicht vor den Dokumentanfang scrollen
+ if( aVisArea.Top() - rOff < 0 )
+ rOff = rOff - aVisArea.Top();
+ else if( GetWrtShell().GetCharRect().Top() < (aVisArea.Top() + nYScrl))
+ rOff += nYScrl;
+ return TRUE;
+}
+
+
+BOOL SwView::GetPageScrollDownOffset( SwTwips &rOff ) const
+{
+ if ( !aVisArea.GetHeight() ||
+ (aVisArea.GetHeight() > aDocSz.Height()) )
+ return FALSE;
+ long nYScrl = GetYScroll() / 2;
+ rOff = aVisArea.GetHeight() - nYScrl;
+ //nicht hinter das Dokumentende scrollen
+ if ( aVisArea.Top() + rOff > aDocSz.Height() )
+ rOff = aDocSz.Height() - aVisArea.Bottom();
+ else if( GetWrtShell().GetCharRect().Bottom() >
+ ( aVisArea.Bottom() - nYScrl ))
+ rOff -= nYScrl;
+ return rOff > 0;
+}
+
+// Seitenweises Blaettern
+
+long SwView::PageUp()
+{
+ if (!aVisArea.GetHeight())
+ return 0;
+
+ Point aPos(aVisArea.TopLeft());
+ aPos.Y() -= aVisArea.GetHeight() - (GetYScroll() / 2);
+ aPos.Y() = Max(0L, aPos.Y());
+ SetVisArea( aPos );
+ return 1;
+}
+
+
+long SwView::PageDown()
+{
+ if ( !aVisArea.GetHeight() )
+ return 0;
+ Point aPos( aVisArea.TopLeft() );
+ aPos.Y() += aVisArea.GetHeight() - (GetYScroll() / 2);
+ aPos.Y() = SetVScrollMax( aPos.Y() );
+ SetVisArea( aPos );
+ return 1;
+}
+
+
+long SwView::PhyPageUp()
+{
+ //aktuell sichtbare Seite erfragen, nicht formatieren
+ USHORT nActPage = pWrtShell->GetNextPrevPageNum( FALSE );
+
+ if( USHRT_MAX != nActPage )
+ {
+ const Point aPt( aVisArea.Left(),
+ pWrtShell->GetPagePos( nActPage ).Y() );
+ Point aAlPt( AlignToPixel( aPt ) );
+ // falls ein Unterschied besteht, wurde abgeschnitten --> dann
+ // einen Pixel addieren, damit kein Rest der Vorgaengerseite
+ // sichtbar ist
+ if( aPt.Y() != aAlPt.Y() )
+ aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
+ SetVisArea( aAlPt );
+ }
+ return 1;
+}
+
+
+long SwView::PhyPageDown()
+{
+ //aktuell sichtbare Seite erfragen, nicht formatieren
+ USHORT nActPage = pWrtShell->GetNextPrevPageNum( TRUE );
+ // falls die letzte Dokumentseite sichtbar ist, nichts tun
+ if( USHRT_MAX != nActPage )
+ {
+ const Point aPt( aVisArea.Left(),
+ pWrtShell->GetPagePos( nActPage ).Y() );
+ Point aAlPt( AlignToPixel( aPt ) );
+ // falls ein Unterschied besteht, wurde abgeschnitten --> dann
+ // einen Pixel addieren, damit kein Rest der Vorgaengerseite sichtbar ist
+ if( aPt.Y() != aAlPt.Y() )
+ aAlPt.Y() += 3 * GetEditWin().PixelToLogic( Size( 0, 1 ) ).Height();
+ SetVisArea( aAlPt );
+ }
+ return 1;
+}
+
+
+long SwView::PageUpCrsr( BOOL bSelect )
+{
+ if ( !bSelect )
+ {
+ const USHORT eType = pWrtShell->GetFrmType(0,TRUE);
+ if ( eType & FRMTYPE_FOOTNOTE )
+ {
+ pWrtShell->MoveCrsr();
+ pWrtShell->GotoFtnAnchor();
+ pWrtShell->Right(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
+ return 1;
+ }
+ }
+
+ SwTwips lOff = 0;
+ if ( GetPageScrollUpOffset( lOff ) &&
+ (pWrtShell->IsCrsrReadonly() ||
+ !pWrtShell->PageCrsr( lOff, bSelect )) &&
+ PageUp() )
+ {
+ pWrtShell->ResetCursorStack();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+long SwView::PageDownCrsr(BOOL bSelect)
+{
+ SwTwips lOff = 0;
+ if ( GetPageScrollDownOffset( lOff ) &&
+ (pWrtShell->IsCrsrReadonly() ||
+ !pWrtShell->PageCrsr( lOff, bSelect )) &&
+ PageDown() )
+ {
+ pWrtShell->ResetCursorStack();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*------------------------------------------------------------------------
+ Beschreibung: Handler der Scrollbars
+------------------------------------------------------------------------*/
+
+IMPL_LINK( SwView, ScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if ( GetWrtShell().ActionPend() )
+ return 0;
+
+ if ( pScrollbar->GetType() == SCROLL_DRAG )
+ pWrtShell->EnableSmooth( FALSE );
+
+ if(!pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
+ pScrollbar->GetType() == SCROLL_DRAG)
+ {
+ //Hier wieder auskommentieren wenn das mitscrollen nicht gewuenscht ist.
+ // JP 21.07.00: the end scrollhandler invalidate the FN_STAT_PAGE,
+ // so we dont must do it agin.
+ EndScrollHdl(pScrollbar);
+
+ Point aPos( aVisArea.TopLeft() );
+ lcl_GetPos(this, aPos, pScrollbar, IsDocumentBorder());
+
+ USHORT nPhNum = 1;
+ USHORT nVirtNum = 1;
+
+ String sDisplay;
+ if(pWrtShell->GetPageNumber( aPos.Y(), FALSE, nPhNum, nVirtNum, sDisplay ))
+ {
+ // JP 21.07.00: the end scrollhandler invalidate the FN_STAT_PAGE,
+ // so we dont must do it agin.
+// if(!GetViewFrame()->GetFrame().IsInPlace())
+// S F X_BINDINGS().Update(FN_STAT_PAGE);
+
+ //QuickHelp:
+ if( pWrtShell->GetPageCnt() > 1 && Help::IsQuickHelpEnabled() )
+ {
+ if( !nPgNum || nPgNum != nPhNum )
+ {
+ Rectangle aRect;
+ aRect.Left() = pScrollbar->GetParent()->OutputToScreenPixel(
+ pScrollbar->GetPosPixel() ).X() -8;
+ aRect.Top() = pScrollbar->OutputToScreenPixel(
+ pScrollbar->GetPointerPosPixel() ).Y();
+ aRect.Right() = aRect.Left();
+ aRect.Bottom() = aRect.Top();
+
+ String sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay ));
+ SwContentAtPos aCnt( SwContentAtPos::SW_OUTLINE );
+ pWrtShell->GetContentAtPos( aPos, aCnt );
+ if( aCnt.sStr.Len() )
+ {
+ sPageStr += String::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( " - " ));
+ sPageStr.Insert( aCnt.sStr, 0, 80 );
+ sPageStr.SearchAndReplaceAll( '\t', ' ' );
+ sPageStr.SearchAndReplaceAll( 0x0a, ' ' );
+ }
+
+ Help::ShowQuickHelp( pScrollbar, aRect, sPageStr,
+ QUICKHELP_RIGHT|QUICKHELP_VCENTER);
+ }
+ nPgNum = nPhNum;
+ }
+ }
+ }
+ else
+ EndScrollHdl(pScrollbar);
+
+ if ( pScrollbar->GetType() == SCROLL_DRAG )
+ pWrtShell->EnableSmooth( TRUE );
+
+ return 0;
+}
+/*------------------------------------------------------------------------
+ Beschreibung: Handler der Scrollbars
+------------------------------------------------------------------------*/
+
+IMPL_LINK( SwView, EndScrollHdl, SwScrollbar *, pScrollbar )
+{
+ if ( !GetWrtShell().ActionPend() )
+ {
+ if(nPgNum)
+ {
+ nPgNum = 0;
+ Help::ShowQuickHelp(pScrollbar, Rectangle(), aEmptyStr, 0);
+ }
+ Point aPos( aVisArea.TopLeft() );
+ BOOL bBorder = IsDocumentBorder();
+ lcl_GetPos(this, aPos, pScrollbar, bBorder);
+ if ( bBorder && aPos == aVisArea.TopLeft() )
+ UpdateScrollbars();
+ else
+ SetVisArea( aPos, FALSE );
+
+ GetViewFrame()->GetBindings().Update(FN_STAT_PAGE);
+ }
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+
+ berechnet die Groesse von aVisArea abhaengig von der Groesse
+ des EditWin auf dem Schirm.
+
+ --------------------------------------------------------------------*/
+
+void SwView::CalcVisArea( const Size &rOutPixel )
+{
+ Point aTopLeft;
+ Rectangle aRect( aTopLeft, rOutPixel );
+ aTopLeft = GetEditWin().PixelToLogic( aTopLeft );
+ Point aBottomRight( GetEditWin().PixelToLogic( aRect.BottomRight() ) );
+
+ aRect.Left() = aTopLeft.X();
+ aRect.Top() = aTopLeft.Y();
+ aRect.Right() = aBottomRight.X();
+ aRect.Bottom() = aBottomRight.Y();
+
+ //Die Verschiebungen nach rechts und/oder unten koennen jetzt falsch
+ //sein (z.B. Zoom aendern, Viewgroesse aendern.
+ const long lBorder = IsDocumentBorder() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
+ if ( aRect.Left() )
+ {
+ const long lWidth = GetWrtShell().GetDocSize().Width() + lBorder;
+ if ( aRect.Right() > lWidth )
+ {
+ long lDelta = aRect.Right() - lWidth;
+ aRect.Left() -= lDelta;
+ aRect.Right() -= lDelta;
+ }
+ }
+ if ( aRect.Top() )
+ {
+ const long lHeight = GetWrtShell().GetDocSize().Height() + lBorder;
+ if ( aRect.Bottom() > lHeight )
+ {
+ long lDelta = aRect.Bottom() - lHeight;
+ aRect.Top() -= lDelta;
+ aRect.Bottom() -= lDelta;
+ }
+ }
+ SetVisArea( aRect );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); // for snapping points
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Bedienelemente neu anordnen
+ --------------------------------------------------------------------*/
+
+
+void SwView::CalcAndSetBorderPixel( SvBorder &rToFill, BOOL /*bInner*/ )
+{
+ BOOL bRightVRuler = pWrtShell->GetViewOptions()->IsVRulerRight();
+ if ( pVRuler->IsVisible() )
+ {
+ long nWidth = pVRuler->GetSizePixel().Width();
+ if(bRightVRuler)
+ rToFill.Right() = nWidth;
+ else
+ rToFill.Left() = nWidth;
+ }
+
+ DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
+ if ( pHRuler->IsVisible() )
+ rToFill.Top() = pHRuler->GetSizePixel().Height();
+
+ const StyleSettings &rSet = GetEditWin().GetSettings().GetStyleSettings();
+ const long nTmp = rSet.GetScrollBarSize();
+ if( pVScrollbar->IsVisible(FALSE) )
+ {
+ if(bRightVRuler)
+ rToFill.Left() = nTmp;
+ else
+ rToFill.Right() = nTmp;
+ }
+ //#i32913# in browse mode the visibility of the horizontal scrollbar
+ // depends on the content (fixed width tables may require a scrollbar)
+ if ( pHScrollbar->IsVisible(pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)) )
+ rToFill.Bottom() = nTmp;
+
+ SetBorderPixel( rToFill );
+}
+
+
+void ViewResizePixel( const Window &rRef,
+ const Point &rOfst,
+ const Size &rSize,
+ const Size &rEditSz,
+ const BOOL /*bInner*/,
+ SwScrollbar& rVScrollbar,
+ SwScrollbar& rHScrollbar,
+ ImageButton* pPageUpBtn,
+ ImageButton* pPageDownBtn,
+ ImageButton* pNaviBtn,
+ Window& rScrollBarBox,
+ SvxRuler* pVLineal,
+ SvxRuler* pHLineal,
+ BOOL bWebView,
+ BOOL bVRulerRight )
+{
+// ViewResizePixel wird auch von der PreView benutzt!!!
+
+ const BOOL bHLineal = pHLineal && pHLineal->IsVisible();
+ const long nHLinSzHeight = bHLineal ?
+ pHLineal->GetSizePixel().Height() : 0;
+ const BOOL bVLineal = pVLineal && pVLineal->IsVisible();
+ const long nVLinSzWidth = bVLineal ?
+ pVLineal->GetSizePixel().Width() : 0;
+ long nHBSzHeight2= rHScrollbar.IsVisible( FALSE ) || !rHScrollbar.IsAuto() ?
+ rRef.GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
+ long nHBSzHeight =
+ rHScrollbar.IsVisible(TRUE) || (rHScrollbar.IsVisible( FALSE ) && !rHScrollbar.IsAuto()) ?
+ nHBSzHeight2:0;
+ long nVBSzWidth = rVScrollbar.IsVisible(TRUE) || (rVScrollbar.IsVisible( FALSE ) && !rVScrollbar.IsAuto()) ?
+ rRef.GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
+
+ if(pVLineal)
+ {
+ WinBits nStyle = pVLineal->GetStyle()&~WB_RIGHT_ALIGNED;
+ Point aPos( rOfst.X(), rOfst.Y()+nHLinSzHeight );
+ if(bVRulerRight)
+ {
+ aPos.X() += rSize.Width() - nVLinSzWidth;
+ nStyle |= WB_RIGHT_ALIGNED;
+ }
+ Size aSize( nVLinSzWidth, rEditSz.Height() );
+ if(!aSize.Width())
+ aSize.Width() = pVLineal->GetSizePixel().Width();
+ pVLineal->SetStyle(nStyle);
+ pVLineal->SetPosSizePixel( aPos, aSize );
+ if(!pVLineal->IsVisible())
+ pVLineal->Resize();
+ }
+// Lineal braucht ein Resize, sonst funktioniert es nicht im unischtbaren Zustand
+ if(pHLineal)
+ {
+ Size aSize( rSize.Width(), nHLinSzHeight );
+ if ( nVBSzWidth && !bVRulerRight)
+ aSize.Width() -= nVBSzWidth;
+ if(!aSize.Height())
+ aSize.Height() = pHLineal->GetSizePixel().Height();
+ pHLineal->SetPosSizePixel( rOfst, aSize );
+// #46802 VCL ruft an unsichtbaren Fenstern kein Resize
+// fuer das Lineal ist das aber keine gute Idee
+ if(!pHLineal->IsVisible())
+ pHLineal->Resize();
+ }
+
+ // Scrollbars und SizeBox anordnen
+ Point aScrollFillPos;
+ {
+ Point aPos( rOfst.X(),
+ rOfst.Y()+rSize.Height()-nHBSzHeight );
+ if(bVRulerRight)
+ {
+ aPos.X() += nVBSzWidth;
+ }
+
+ Size aSize( rSize.Width(), nHBSzHeight2 );
+ if ( nVBSzWidth )
+ aSize.Width() -= nVBSzWidth;
+ rHScrollbar.SetPosSizePixel( aPos, aSize );
+ aScrollFillPos.Y() = aPos.Y();
+ }
+ {
+ Point aPos( rOfst.X()+rSize.Width()-nVBSzWidth,
+ rOfst.Y() );
+ Size aSize( nVBSzWidth, rSize.Height() );
+ if(bVRulerRight)
+ {
+ aPos.X() = rOfst.X();
+ if(bHLineal)
+ {
+ aPos.Y() += nHLinSzHeight;
+ aSize.Height() -= nHLinSzHeight;
+ }
+ }
+
+ Size aImgSz( nVBSzWidth, nVBSzWidth );
+
+ //#55949# wenn der Platz fuer Scrollbar und Page-Buttons zu klein wird, dann
+ // werden die Buttons versteckt
+ USHORT nCnt = pNaviBtn ? 3 : 2;
+ long nSubSize = (aImgSz.Width() * nCnt );
+ //
+ BOOL bHidePageButtons = aSize.Height() < ((bWebView ? 3 : 2) * nSubSize);
+ if(!bHidePageButtons)
+ aSize.Height() -= nSubSize;
+ else
+ aImgSz.Width() = 0; // kein Hide, weil das im Update Scrollbar missverstanden wird
+
+ if ( nHBSzHeight )
+ aSize.Height() -= nHBSzHeight;
+ rVScrollbar.SetPosSizePixel( aPos, aSize );
+
+ aPos.Y() += aSize.Height();
+ pPageUpBtn->SetPosSizePixel( aPos, aImgSz );
+ if(pNaviBtn)
+ {
+ aPos.Y() += aImgSz.Height();
+ pNaviBtn->SetPosSizePixel(aPos, aImgSz);
+ }
+
+ aPos.Y() += aImgSz.Height();
+ pPageDownBtn->SetPosSizePixel( aPos, aImgSz );
+
+
+ if( rHScrollbar.IsVisible( FALSE ) )
+ {
+ aScrollFillPos.X() = aPos.X();
+
+ rScrollBarBox.SetPosSizePixel( aScrollFillPos,
+ Size( nHBSzHeight, nVBSzWidth) );
+ }
+ }
+}
+
+
+void SwView::ShowAtResize()
+{
+ bShowAtResize = FALSE;
+ if ( pWrtShell->GetViewOptions()->IsViewHRuler() )
+ pHRuler->Show();
+}
+
+
+void SwView::InnerResizePixel( const Point &rOfst, const Size &rSize )
+{
+ Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
+ if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
+ {
+ SvBorder aBorder( GetBorderPixel() );
+ Size aSize( rSize );
+ aSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+ Size aObjSizePixel = GetWindow()->LogicToPixel( aObjSize, MAP_TWIP );
+ SfxViewShell::SetZoomFactor( Fraction( aSize.Width(), aObjSizePixel.Width() ),
+ Fraction( aSize.Height(), aObjSizePixel.Height() ) );
+ }
+
+ bInInnerResizePixel = TRUE;
+ const BOOL bHScrollVisible = pHScrollbar->IsVisible(TRUE);
+ const BOOL bVScrollVisible = pVScrollbar->IsVisible(TRUE);
+ BOOL bRepeat = FALSE;
+ do
+ {
+ Size aSz( rSize );
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, TRUE );
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ Size aViewSize( aSz );
+ Point aViewPos( rOfst );
+ aViewSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+ aViewSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aViewPos.X() += aBorder.Left();
+ aViewPos.Y() += aBorder.Top();
+ GetEditWin().SetPosSizePixel( aViewPos, aViewSize );
+ }
+ else
+ {
+ aSz.Height() += aBorder.Top() + aBorder.Bottom();
+ aSz.Width() += aBorder.Left() + aBorder.Right();
+ }
+
+ Size aEditSz( GetEditWin().GetOutputSizePixel() );
+ ViewResizePixel( GetEditWin(), rOfst, aSz, aEditSz, TRUE, *pVScrollbar,
+ *pHScrollbar, pPageUpBtn, pPageDownBtn,
+ pNaviBtn,
+ *pScrollFill, pVRuler, pHRuler,
+ 0 != PTR_CAST(SwWebView, this),
+ pWrtShell->GetViewOptions()->IsVRulerRight());
+ if ( bShowAtResize )
+ ShowAtResize();
+
+ if( pHRuler->IsVisible() || pVRuler->IsVisible() )
+ {
+ const Fraction& rFrac = GetEditWin().GetMapMode().GetScaleX();
+ USHORT nZoom = 100;
+ if (0 != rFrac.GetDenominator())
+ nZoom = USHORT(rFrac.GetNumerator() * 100L / rFrac.GetDenominator());
+
+ const Fraction aFrac( nZoom, 100 );
+ pVRuler->SetZoom( aFrac );
+ pHRuler->SetZoom( aFrac );
+ InvalidateRulerPos(); //Inhalt invalidieren.
+ }
+ //CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
+ //nicht mehr zum aktuell sichtbaren Bereich passen
+ pWrtShell->ResetCursorStack();
+
+ //EditWin niemals einstellen!
+
+ //VisArea einstellen, aber dort nicht das SetVisArea der DocShell rufen!
+ bProtectDocShellVisArea = TRUE;
+ CalcVisArea( aEditSz );
+ //visibility changes of the automatic horizontal scrollbar
+ //require to repeat the ViewResizePixel() call - but only once!
+ if(bRepeat)
+ bRepeat = FALSE;
+ else if(bHScrollVisible != pHScrollbar->IsVisible(TRUE) ||
+ bVScrollVisible != pVScrollbar->IsVisible(TRUE))
+ bRepeat = TRUE;
+ }while( bRepeat );
+ bProtectDocShellVisArea = FALSE;
+ bInInnerResizePixel = FALSE;
+}
+
+
+void SwView::OuterResizePixel( const Point &rOfst, const Size &rSize )
+{
+ // FME 22.08.2003 #i16909# - return, if no size (caused by minimize window).
+ if ( bInOuterResizePixel || ( !rSize.Width() && !rSize.Height() ) )
+ return;
+ bInOuterResizePixel = TRUE;
+
+// feststellen, ob Scrollbars angezeigt werden duerfen
+ BOOL bBrowse = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+ BOOL bShowH = FALSE,
+ bShowV = FALSE,
+ bAuto = FALSE,
+ bHAuto = bBrowse;
+ switch( GetScrollingMode() )
+ {
+ case SCROLLING_DEFAULT:
+ {
+ const SwViewOption *pVOpt = pWrtShell->GetViewOptions();
+ if ( !pVOpt->IsReadonly() || pVOpt->IsStarOneSetting() )
+ {
+ bShowH = pVOpt->IsViewHScrollBar();
+ bShowV = pVOpt->IsViewVScrollBar();
+ break;
+ }
+ }
+ /* kein break hier */
+ case SCROLLING_AUTO:
+ bAuto = bHAuto = TRUE;
+ bShowH = bShowV = TRUE;
+ break;
+ case SCROLLING_YES:
+ bShowH = bShowV = TRUE;
+ break;
+ case SCROLLING_NO:
+ bShowH = bShowV = bHAuto = FALSE;
+ break;
+ }
+ SwDocShell* pDocSh = GetDocShell();
+ BOOL bIsPreview = pDocSh->IsPreview();
+ if( bIsPreview )
+ {
+ bShowH = bShowV = bHAuto = bAuto = FALSE;
+ }
+ if(pHScrollbar->IsVisible(FALSE) != bShowH)
+ ShowHScrollbar(bShowH);
+ pHScrollbar->SetAuto( bHAuto );
+ if(pVScrollbar->IsVisible(FALSE) != bShowV)
+ ShowVScrollbar(bShowV);
+ pVScrollbar->SetAuto(bAuto);
+
+ SET_CURR_SHELL( pWrtShell );
+ BOOL bRepeat = FALSE;
+ long nCnt = 0;
+
+ BOOL bUnLockView = !pWrtShell->IsViewLocked();
+ pWrtShell->LockView( TRUE );
+ pWrtShell->LockPaint();
+
+ do {
+ ++nCnt;
+ const BOOL bScroll1 = pVScrollbar->IsVisible(TRUE);
+ const BOOL bScroll2 = pHScrollbar->IsVisible(TRUE);
+ SvBorder aBorder;
+ CalcAndSetBorderPixel( aBorder, FALSE );
+ const Size aEditSz( GetEditWin().GetOutputSizePixel() );
+ ViewResizePixel( GetEditWin(), rOfst, rSize, aEditSz, FALSE, *pVScrollbar,
+ *pHScrollbar, pPageUpBtn, pPageDownBtn,
+ pNaviBtn,
+ *pScrollFill, pVRuler, pHRuler,
+ 0 != PTR_CAST(SwWebView, this),
+ pWrtShell->GetViewOptions()->IsVRulerRight() );
+ if ( bShowAtResize )
+ ShowAtResize();
+
+ if( pHRuler->IsVisible() || pVRuler->IsVisible() )
+ InvalidateRulerPos(); //Inhalt invalidieren.
+
+ //CursorStack zuruecksetzen, da die Cursorpositionen fuer PageUp/-Down
+ //nicht mehr zum aktuell sichtbaren Bereich passen
+ pWrtShell->ResetCursorStack();
+
+ ASSERT( !GetEditWin().IsVisible() ||
+ (( aEditSz.Width() > 0 && aEditSz.Height() > 0 )
+ || !aVisArea.IsEmpty()), "Small world, isn't it?" );
+
+ //EditWin niemals einstellen!
+
+ //Die VisArea muss aber natuerlich eingestellt werden.
+ //jetzt ist auch der richtige Zeitpunkt den Zoom neu zu berechnen wenn
+ //es kein einfacher Faktor ist.
+ pWrtShell->StartAction();
+ CalcVisArea( aEditSz );
+
+ //Damit auch beim outplace editing die Seitenbreite sofort
+ //angepasst wird.
+ //TODO/LATER: is that still necessary?!
+ /*
+ if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ pDocSh->SetVisArea(
+ pDocSh->SfxInPlaceObject::GetVisArea() );*/
+ if ( pWrtShell->GetViewOptions()->GetZoomType() != SVX_ZOOM_PERCENT &&
+ !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ _SetZoom( aEditSz, (SvxZoomType)pWrtShell->GetViewOptions()->GetZoomType(), 100, TRUE );
+ pWrtShell->EndAction();
+
+ bRepeat = bScroll1 != pVScrollbar->IsVisible(TRUE);
+ if ( !bRepeat )
+ bRepeat = bScroll2 != pHScrollbar->IsVisible(TRUE);
+
+ //Nicht endlosschleifen. Moeglichst dann stoppen wenn die
+ //(Auto-)Scrollbars sichtbar sind.
+ if ( bRepeat &&
+ ( nCnt > 10 || ( nCnt > 3 && bHAuto && bAuto ) )
+ )
+ {
+ bRepeat = FALSE;
+ }
+
+ }while ( bRepeat );
+
+ if( pVScrollbar->IsVisible(FALSE) || pVScrollbar->IsAuto())
+ {
+ BOOL bShowButtons = pVScrollbar->IsVisible(TRUE);
+ if(pPageUpBtn && pPageUpBtn->IsVisible() != bShowButtons)
+ {
+ pPageUpBtn->Show(bShowButtons);
+ if(pPageDownBtn)
+ pPageDownBtn->Show(bShowButtons);
+ if(pNaviBtn)
+ pNaviBtn->Show(bShowButtons);
+ }
+ }
+
+ pWrtShell->UnlockPaint();
+ if( bUnLockView )
+ pWrtShell->LockView( FALSE );
+
+ bInOuterResizePixel = FALSE;
+
+ if ( mpPostItMgr )
+ {
+ mpPostItMgr->CalcRects();
+ mpPostItMgr->LayoutPostIts();
+ }
+}
+
+
+void SwView::SetZoomFactor( const Fraction &rX, const Fraction &rY )
+{
+ const Fraction &rFrac = rX < rY ? rX : rY;
+ SetZoom( SVX_ZOOM_PERCENT, (short) long(rFrac * Fraction( 100, 1 )) );
+
+ //Um Rundungsfehler zu minimieren lassen wir von der Basisklasse ggf.
+ //auch die krummen Werte einstellen
+ SfxViewShell::SetZoomFactor( rX, rY );
+}
+
+
+Size SwView::GetOptimalSizePixel() const
+{
+ Size aPgSize;
+ if ( pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ aPgSize = SvxPaperInfo::GetPaperSize(PAPER_A4);
+ else
+ {
+ aPgSize = GetWrtShell().GetAnyCurRect(RECT_PAGE).SSize();
+ aPgSize.Width() += DOCUMENTBORDER * 2;
+
+ const SwPageDesc &rDesc = pWrtShell->GetPageDesc( pWrtShell->GetCurPageDesc() );
+ if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() )
+ {
+ const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
+ const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
+ aPgSize.Width() += Abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
+ }
+ }
+ return GetEditWin().LogicToPixel( aPgSize );
+}
+
+
+BOOL SwView::UpdateScrollbars()
+{
+ BOOL bRet = FALSE;
+ if ( !aVisArea.IsEmpty() )
+ {
+ const BOOL bBorder = IsDocumentBorder();
+ Rectangle aTmpRect( aVisArea );
+ if ( bBorder )
+ {
+ Point aPt( DOCUMENTBORDER, DOCUMENTBORDER );
+ aPt = AlignToPixel( aPt );
+ aTmpRect.Move( -aPt.X(), -aPt.Y() );
+ }
+
+ Size aTmpSz( aDocSz );
+ const long lOfst = bBorder ? 0 : DOCUMENTBORDER * 2L;
+ aTmpSz.Width() += lOfst; aTmpSz.Height() += lOfst;
+
+ {
+ const BOOL bVScrollVisible = pVScrollbar->IsVisible(TRUE);
+ pVScrollbar->DocSzChgd( aTmpSz );
+ pVScrollbar->ViewPortChgd( aTmpRect );
+
+ BOOL bShowButtons = pVScrollbar->IsVisible(TRUE);
+ if(pPageUpBtn && pPageUpBtn->IsVisible() != bShowButtons)
+ {
+ pPageUpBtn->Show(bShowButtons);
+ if(pPageDownBtn)
+ pPageDownBtn->Show(bShowButtons);
+ if(pNaviBtn)
+ pNaviBtn->Show(bShowButtons);
+ }
+
+ if ( bVScrollVisible != pVScrollbar->IsVisible(TRUE) )
+ bRet = TRUE;
+ }
+ {
+ const BOOL bHScrollVisible = pHScrollbar->IsVisible(TRUE);
+ pHScrollbar->DocSzChgd( aTmpSz );
+ pHScrollbar->ViewPortChgd( aTmpRect );
+ if ( bHScrollVisible != pHScrollbar->IsVisible(TRUE) )
+ bRet = TRUE;
+ pScrollFill->Show(pHScrollbar->IsVisible(TRUE) && pVScrollbar->IsVisible(TRUE) );
+ }
+ }
+ return bRet;
+}
+
+
+void SwView::Move()
+{
+ if ( GetWrtShell().IsInSelect() )
+ GetWrtShell().EndSelect(); //#32427#
+ SfxViewShell::Move();
+}
+
+BOOL SwView::HandleWheelCommands( const CommandEvent& rCEvt )
+{
+ BOOL bOk = FALSE;
+ const CommandWheelData* pWData = rCEvt.GetWheelData();
+ if( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
+ {
+ USHORT nFact = pWrtShell->GetViewOptions()->GetZoom();
+ if( 0L > pWData->GetDelta() )
+ nFact = static_cast< USHORT >(Max( 20, nFact - 10 ));
+ else
+ nFact = static_cast< USHORT >(Min( 600, nFact + 10 ));
+
+ SetZoom( SVX_ZOOM_PERCENT, nFact );
+ bOk = TRUE;
+ }
+ else
+ {
+ if (pWData && (COMMAND_WHEEL_SCROLL==pWData->GetMode()) && (((ULONG)0xFFFFFFFF) == pWData->GetScrollLines()))
+ {
+ if (pWData->GetDelta()<0)
+ PhyPageDown();
+ else
+ PhyPageUp();
+ bOk = TRUE;
+ }
+ else
+ bOk = pEditWin->HandleScrollCommand( rCEvt,
+ pHScrollbar, pVScrollbar);
+ }
+ return bOk;
+}
+
+
diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx
new file mode 100644
index 000000000000..8721f425eb8d
--- /dev/null
+++ b/sw/source/ui/uiview/viewprt.cxx
@@ -0,0 +1,375 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <com/sun/star/text/NotePrintMode.hpp>
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_STRINGSDTOR
+#include <svl/svstdarr.hxx>
+#endif
+#include <sfx2/request.hxx>
+
+#include <sfx2/progress.hxx>
+#include <sfx2/app.hxx>
+#include <svl/flagitem.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/oldprintadaptor.hxx>
+#include <svtools/printdlg.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/prnmon.hxx>
+#include <editeng/paperinf.hxx>
+#include <sfx2/dispatch.hxx>
+#include <unotools/misccfg.hxx>
+#include <svx/prtqry.hxx>
+#include <svx/svdview.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/flagitem.hxx>
+#include <sfx2/linkmgr.hxx>
+
+#include <modcfg.hxx>
+#include <edtwin.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <docsh.hxx>
+#include <viewopt.hxx>
+#include <prtopt.hxx>
+#include <swprtopt.hxx>
+#include <fontcfg.hxx>
+#include <cfgitems.hxx>
+#include <dbmgr.hxx>
+#include <docstat.hxx>
+#include <viewfunc.hxx>
+#include <swmodule.hxx>
+#include <wview.hxx>
+#include <doc.hxx>
+#include <fldbas.hxx>
+
+#include <globals.hrc>
+#include <view.hrc>
+#include <app.hrc>
+#include <svl/eitem.hxx>
+#include <swwrtshitem.hxx>
+#include "swabstdlg.hxx"
+#include <svl/slstitm.hxx>
+
+#include <unomid.h>
+
+using namespace ::com::sun::star;
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Drucker an Sfx uebergeben
+ --------------------------------------------------------------------*/
+
+
+SfxPrinter* __EXPORT SwView::GetPrinter( BOOL bCreate )
+{
+ const IDocumentDeviceAccess* pIDDA = GetWrtShell().getIDocumentDeviceAccess();
+ SfxPrinter *pOld = pIDDA->getPrinter( false );
+ SfxPrinter *pPrt = pIDDA->getPrinter( bCreate );
+ if ( pOld != pPrt )
+ {
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ ::SetAppPrintOptions( &GetWrtShell(), bWeb );
+ }
+ return pPrt;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Druckerwechsel weitermelden
+ --------------------------------------------------------------------*/
+
+void SetPrinter( IDocumentDeviceAccess* pIDDA, SfxPrinter* pNew, BOOL bWeb )
+{
+ SwPrintOptions* pOpt = SW_MOD()->GetPrtOptions(bWeb);
+ if( !pOpt)
+ return;
+
+ // Applikationseigene Druckoptionen aus SfxPrinter auslesen
+ const SfxItemSet& rSet = pNew->GetOptions();
+
+ const SwAddPrinterItem* pAddPrinterAttr;
+ if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER, FALSE,
+ (const SfxPoolItem**)&pAddPrinterAttr ) )
+ {
+ if( pIDDA )
+ pIDDA->setPrintData( *pAddPrinterAttr );
+ if( pAddPrinterAttr->GetFax().getLength() )
+ pOpt->SetFaxName(pAddPrinterAttr->GetFax());
+ }
+}
+
+
+USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool )
+{
+ SwWrtShell &rSh = GetWrtShell();
+ SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
+ if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags )
+ {
+ rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
+ if ( nDiffFlags & SFX_PRINTER_PRINTER )
+ rSh.SetModified();
+ }
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ if ( nDiffFlags & SFX_PRINTER_OPTIONS )
+ ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, bWeb );
+
+ const BOOL bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? TRUE : FALSE;
+ const BOOL bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? TRUE : FALSE;
+ if ( bChgOri || bChgSize )
+ {
+ rSh.StartAllAction();
+ if ( bChgOri )
+ rSh.ChgAllPageOrientation( USHORT(pNew->GetOrientation()) );
+ if ( bChgSize )
+ {
+ Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
+ rSh.ChgAllPageSize( aSz );
+ }
+ rSh.SetModified();
+ rSh.EndAllAction();
+ InvalidateRulerPos();
+ }
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: TabPage fuer applikationsspezifische Druckoptionen
+ --------------------------------------------------------------------*/
+
+SfxTabPage* __EXPORT SwView::CreatePrintOptionsPage(Window* pParent,
+ const SfxItemSet& rSet)
+{
+ return ::CreatePrintOptionsPage( pParent, rSet, FALSE );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Druckerdialog
+ --------------------------------------------------------------------*/
+
+PrintDialog* CreatePrintDialog( Window* pParent, USHORT nPg, SwWrtShell* pSh )
+{
+ PrintDialog *pDlg = new PrintDialog( pParent, false );
+// pDlg->ChangeFirstPage( 1 );
+
+ if ( !nPg )
+ nPg = 1;
+// pDlg->ChangeLastPage( nPg );
+// pDlg->ChangeMaxPage( 9999 );
+ pDlg->EnableRange( PRINTDIALOG_FROMTO );
+
+ if (pSh && (pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected()))
+ pDlg->EnableRange( PRINTDIALOG_SELECTION );
+
+ pDlg->SetRangeText( String::CreateFromInt32(nPg) );
+ pDlg->EnableRange( PRINTDIALOG_RANGE );
+ pDlg->EnableCollate();
+ return pDlg;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+PrintDialog* __EXPORT SwView::CreatePrintDialog( Window* pParent )
+{
+ // AMA: Hier sollte vielleicht die virtuelle Seitennummer angezeigt werden,
+ // aber nur, wenn das Drucken virtuelle Seitennummern und nicht wie
+ // bisher (auch beim SWG 2.0) physikalische beachtet werden.
+ return ::CreatePrintDialog( pParent, GetWrtShell().GetPhyPageNum(), &GetWrtShell() );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Print-Dispatcher
+ --------------------------------------------------------------------*/
+
+void __EXPORT SwView::ExecutePrint(SfxRequest& rReq)
+{
+ BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
+ ::SetAppPrintOptions( &GetWrtShell(), bWeb );
+ switch (rReq.GetSlot())
+ {
+ case FN_FAX:
+ {
+ SwPrintOptions* pPrintOptions = SW_MOD()->GetPrtOptions(bWeb);
+ String sFaxName(pPrintOptions->GetFaxName());
+ if (sFaxName.Len())
+ {
+ SfxStringItem aPrinterName(SID_PRINTER_NAME, sFaxName);
+ SfxBoolItem aSilent( SID_SILENT, TRUE );
+ GetViewFrame()->GetDispatcher()->Execute( SID_PRINTDOC,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aPrinterName, &aSilent, 0L );
+ }
+ else
+ {
+ InfoBox aInfoBox(&GetEditWin(), SW_RES(MSG_ERR_NO_FAX));
+ String sMsg = aInfoBox.GetMessText();
+ USHORT nResNo = bWeb ? STR_WEBOPTIONS : STR_TEXTOPTIONS;
+ sMsg.SearchAndReplace(String::CreateFromAscii("%1"), String(SW_RES(nResNo)));
+ aInfoBox.SetMessText(sMsg);
+ aInfoBox.Execute();
+ SfxUInt16Item aDefPage(SID_SW_EDITOPTIONS, TP_OPTPRINT_PAGE);
+ GetViewFrame()->GetDispatcher()->Execute(SID_SW_EDITOPTIONS,
+ SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
+ &aDefPage, 0L );
+ }
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ {
+ SwWrtShell* pSh = &GetWrtShell();
+ SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE);
+ BOOL bSilent = pSilentItem ? pSilentItem->GetValue() : FALSE;
+ SFX_REQUEST_ARG(rReq, pPrintFromMergeItem, SfxBoolItem, FN_QRY_MERGE, FALSE);
+ if(pPrintFromMergeItem)
+ rReq.RemoveItem(FN_QRY_MERGE);
+ BOOL bFromMerge = pPrintFromMergeItem ? pPrintFromMergeItem->GetValue() : FALSE;
+ SwMiscConfig aMiscConfig;
+ bool bPrintSelection = false;
+ if(!bSilent && !bFromMerge &&
+ SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc())
+ {
+ QueryBox aBox( &GetEditWin(), SW_RES( MSG_PRINT_AS_MERGE ));
+ short nRet = aBox.Execute();
+ if(RET_YES == nRet)
+ {
+ SfxBoolItem aBool(FN_QRY_MERGE, TRUE);
+ GetViewFrame()->GetDispatcher()->Execute(
+ FN_QRY_MERGE, SFX_CALLMODE_ASYNCHRON, &aBool, 0L);
+ rReq.Ignore();
+ return;
+ }
+ }
+ else if( rReq.GetSlot() == SID_PRINTDOCDIRECT && ! bSilent )
+ {
+ if( /*!bIsAPI && */
+ ( pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected() ) )
+ {
+ short nBtn = SvxPrtQryBox(&GetEditWin()).Execute();
+ if( RET_CANCEL == nBtn )
+ return;;
+
+ if( RET_OK == nBtn )
+ bPrintSelection = true;
+ }
+ }
+
+ //#i61455# if master documentes are printed silently without loaded links then update the links now
+ if( bSilent && pSh->IsGlobalDoc() && !pSh->IsGlblDocSaveLinks() )
+ {
+ pSh->GetLinkManager().UpdateAllLinks( sal_False, sal_False, sal_False, 0 );
+ }
+ SfxRequest aReq( rReq );
+ SfxBoolItem aBool(SID_SELECTION, bPrintSelection);
+ aReq.AppendItem( aBool );
+ SfxViewShell::ExecuteSlot( aReq, SfxViewShell::GetInterface() );
+ return;
+ }
+ default:
+ ASSERT(!this, falscher Dispatcher);
+ return;
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Page Drucker/Zusaetze erzeugen fuer SwView und
+ SwPagePreview
+ --------------------------------------------------------------------*/
+
+SfxTabPage* CreatePrintOptionsPage( Window *pParent,
+ const SfxItemSet &rOptions, BOOL bPreview )
+{
+ SfxTabPage* pPage = NULL;
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( TP_OPTPRINT_PAGE );
+ if ( fnCreatePage )
+ pPage = (*fnCreatePage)( pParent, rOptions );
+ }
+ SfxAllItemSet aSet(*(rOptions.GetPool()));
+ aSet.Put (SfxBoolItem(SID_PREVIEWFLAG_TYPE, bPreview));
+ aSet.Put (SfxBoolItem(SID_FAX_LIST, sal_True));
+ pPage->PageCreated(aSet);
+ return pPage;
+}
+
+
+void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb )
+{
+ SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(bWeb);
+ const IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
+ SwPrintData* pShellPrintData = pIDDA->getPrintData();
+
+ if(pShellPrintData)
+ aPrtData = *pShellPrintData;
+
+ if( pIDDA->getPrinter( false ) )
+ {
+ // Applikationseigene Druckoptionen in SfxPrinter schiessen
+ SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
+ SfxItemSet aSet( pSh->GetAttrPool(),
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0 );
+
+ utl::MiscCfg aMisc;
+
+ if(bWeb)
+ aSet.Put(SfxUInt16Item(SID_HTML_MODE,
+ ::GetHtmlMode(((SwWrtShell*)pSh)->GetView().GetDocShell())));
+ aSet.Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN,
+ aMisc.IsNotFoundWarning() ));
+ aSet.Put(aAddPrinterItem);
+ aSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC,
+ (aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0) |
+ (aMisc.IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0 )));
+
+ pIDDA->getPrinter( true )->SetOptions( aSet );
+ }
+
+}
diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx
new file mode 100644
index 000000000000..57c7bd20623c
--- /dev/null
+++ b/sw/source/ui/uiview/viewsrch.cxx
@@ -0,0 +1,821 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <hintids.hxx>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <svx/pageitem.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#ifndef _T2XTCMP_HXX //autogen
+#include <svtools/txtcmp.hxx>
+#endif
+#include <svl/itempool.hxx>
+#include <svl/eitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/request.hxx>
+#include <svx/srchdlg.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include "editeng/unolingu.hxx"
+#include <swmodule.hxx>
+#include <swwait.hxx>
+#include <workctrl.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#include <swundo.hxx> // fuer Undo-Ids
+#include <uitool.hxx>
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+#ifndef _DOCSH_HXX
+#include <docsh.hxx>
+#endif
+
+#ifndef _VIEW_HRC
+#include <view.hrc>
+#endif
+#include <SwRewriter.hxx>
+#include <undobj.hxx>
+#ifndef _COMCORE_HRC
+#include <comcore.hrc>
+#endif
+
+#include "PostItMgr.hxx"
+
+using namespace com::sun::star;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::i18n;
+
+#define SRCH_ATTR_OFF 0
+#define SRCH_ATTR_ON 1
+#define SRCH_ATTR_SET 2
+
+/*--------------------------------------------------------------------
+ Beschreibung: Search Parameter
+ --------------------------------------------------------------------*/
+
+struct SwSearchOptions
+{
+ SwDocPositions eStart, eEnd;
+ BOOL bDontWrap;
+
+ SwSearchOptions( SwWrtShell* pSh, BOOL bBackward );
+};
+
+
+inline Window* GetParentWindow( SvxSearchDialog* pSrchDlg )
+{
+ Window* pWin;
+ if( pSrchDlg && pSrchDlg->IsVisible() )
+ pWin = LAYOUT_THIS_WINDOW (pSrchDlg);
+ else
+ pWin = 0;
+ return pWin;
+}
+
+
+/*-----------------12.04.97 13:04-------------------
+
+--------------------------------------------------*/
+
+
+void SwView::ExecSearch(SfxRequest& rReq, BOOL bNoMessage)
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ const USHORT nId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nId);
+ BOOL bQuiet = FALSE;
+ if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SEARCH_QUIET, FALSE, &pItem))
+ bQuiet = ((const SfxBoolItem*) pItem)->GetValue();
+
+ BOOL bApi = bQuiet | bNoMessage;
+
+ USHORT nSlot = rReq.GetSlot();
+ if (nSlot == FN_REPEAT_SEARCH && !pSrchItem)
+ {
+ if(bApi)
+ {
+ rReq.SetReturnValue(SfxBoolItem(nSlot, FALSE));
+ nSlot = 0;
+ }
+ }
+ if( pWrtShell->IsBlockMode() )
+ pWrtShell->LeaveBlockMode();
+ switch (nSlot)
+ {
+ // erstmal Nichts tun
+ case SID_SEARCH_ITEM:
+ {
+ delete pSrchItem;
+ pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+ }
+ break;
+
+ case FID_SEARCH_ON:
+ bJustOpened = TRUE;
+ GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM);
+ break;
+
+ case FID_SEARCH_OFF:
+ if(pArgs)
+ {
+ // Dialog abmelden
+ delete pSrchItem;
+ pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+
+ DELETEZ( pSrchList );
+ DELETEZ( pReplList );
+
+ if ( pWrp )
+ {
+ pSrchDlg = static_cast <SvxSearchDialog*> (pWrp->getDialog ());
+ // die Search / Replace -Items merken wir uns
+ const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
+ if( pList && pList->Count() )
+ pSrchList = new SearchAttrItemList( *pList );
+
+ if( 0 != (pList = pSrchDlg->GetReplaceItemList() ) &&
+ pList->Count() )
+ pReplList = new SearchAttrItemList( *pList );
+ }
+ }
+ break;
+
+ case FN_REPEAT_SEARCH:
+ case FID_SEARCH_NOW:
+ {
+ {
+ if(FID_SEARCH_NOW == nSlot && !rReq.IsAPI())
+ SwView::SetMoveType(NID_SRCH_REP);
+ if ( pWrp )
+ {
+ pSrchDlg = static_cast <SvxSearchDialog*> (pWrp->getDialog ());
+ }
+ else
+ pSrchDlg = 0;
+ }
+
+ if (pSrchDlg)
+ {
+ DELETEZ( pSrchList );
+ DELETEZ( pReplList );
+
+ const SearchAttrItemList* pList = pSrchDlg->GetSearchItemList();
+ if( pList && pList->Count() )
+ pSrchList = new SearchAttrItemList( *pList );
+
+ if( 0 != (pList = pSrchDlg->GetReplaceItemList() ) &&
+ pList->Count() )
+ pReplList = new SearchAttrItemList( *pList );
+ }
+
+ if (nSlot == FN_REPEAT_SEARCH)
+ {
+ ASSERT(pSrchItem, "Search-Item fehlt");
+ if( !pSrchItem )
+ pSrchItem = new SvxSearchItem(SID_SEARCH_ITEM);
+ }
+ else
+ {
+ // SearchItem aus Request besorgen
+ ASSERT(pArgs, "Args fehlen");
+ if ( pArgs )
+ {
+ delete pSrchItem;
+ pSrchItem = (SvxSearchItem*) pArgs->Get(SID_SEARCH_ITEM).Clone();
+ }
+ }
+ switch (pSrchItem->GetCommand())
+ {
+ case SVX_SEARCHCMD_FIND:
+ {
+ BOOL bRet = SearchAndWrap(bApi);
+ if( bRet )
+ Scroll(pWrtShell->GetCharRect().SVRect());
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ }
+ break;
+ case SVX_SEARCHCMD_FIND_ALL:
+ {
+ BOOL bRet = SearchAll();
+ if( !bRet )
+ {
+ if( !bApi )
+ {
+ Window* pParentWindow = GetParentWindow( pSrchDlg );
+ InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
+ }
+ bFound = FALSE;
+ }
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ }
+ break;
+ case SVX_SEARCHCMD_REPLACE:
+ {
+
+ // 1) Selektion ersetzen (nicht. wenn nur Attribute ersetzt
+ // werden sollen)
+//JP 27.04.95: warum ?
+// was ist, wenn man das gefundene nur attributieren will??
+
+ USHORT nCmd = SVX_SEARCHCMD_FIND;
+ if( pSrchItem->GetReplaceString().Len() ||
+ !pReplList )
+ {
+ // Verhindern, dass - falls der Suchstring im
+ // Ersetzungsstring enthalten ist - der ersetzte String
+ // noch einmal gefunden wird.
+
+ BOOL bBack = pSrchItem->GetBackward();
+ if (bBack)
+ pWrtShell->Push();
+ String aReplace( pSrchItem->GetReplaceString() );
+ SearchOptions aTmp( pSrchItem->GetSearchOptions() );
+ String *pBackRef = ReplaceBackReferences( aTmp, pWrtShell->GetCrsr() );
+ if( pBackRef )
+ pSrchItem->SetReplaceString( *pBackRef );
+ Replace();
+ if( pBackRef )
+ {
+ pSrchItem->SetReplaceString( aReplace );
+ delete pBackRef;
+ }
+ if (bBack)
+ {
+ pWrtShell->Pop();
+ pWrtShell->SwapPam();
+ }
+ }
+ else if( pReplList )
+ nCmd = SVX_SEARCHCMD_REPLACE;
+
+ // 2) Weiter suchen (ohne zu ersetzen!)
+
+ USHORT nOldCmd = pSrchItem->GetCommand();
+ pSrchItem->SetCommand( nCmd );
+ BOOL bRet = SearchAndWrap(bApi);
+ if( bRet )
+ Scroll( pWrtShell->GetCharRect().SVRect());
+ pSrchItem->SetCommand( nOldCmd );
+ rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
+ }
+ break;
+
+ case SVX_SEARCHCMD_REPLACE_ALL:
+ {
+ SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
+
+
+ if( !pSrchItem->GetSelection() )
+ {
+ // bestehende Selektionen aufheben,
+ // wenn nicht in selektierten Bereichen gesucht werden soll
+ (pWrtShell->*pWrtShell->fnKillSel)(0, FALSE);
+ if( DOCPOS_START == aOpts.eEnd )
+ pWrtShell->EndDoc();
+ else
+ pWrtShell->SttDoc();
+ }
+
+ bExtra = FALSE;
+ ULONG nFound;
+
+ { //Scope for SwWait-Object
+ SwWait aWait( *GetDocShell(), TRUE );
+ pWrtShell->StartAllAction();
+ nFound = FUNC_Search( aOpts );
+ pWrtShell->EndAllAction();
+ }
+ rReq.SetReturnValue(SfxBoolItem(nSlot, nFound != 0 && ULONG_MAX != nFound));
+ if( !nFound )
+ {
+ if( !bApi )
+ {
+ Window* pParentWindow = GetParentWindow( pSrchDlg );
+ InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
+ }
+ bFound = FALSE;
+ return;
+ }
+
+ if( !bApi && ULONG_MAX != nFound)
+ {
+ String aText( SW_RES( STR_NB_REPLACED ) );
+ const xub_StrLen nPos = aText.Search( String::CreateFromAscii("XX") );
+ aText.Erase( nPos, 2 );
+ aText.Insert( String::CreateFromInt32( nFound ), nPos );
+ Window* pParentWindow = GetParentWindow( pSrchDlg );
+ InfoBox( pParentWindow, aText ).Execute();
+ }
+ }
+ break;
+ }
+
+ uno::Reference< frame::XDispatchRecorder > xRecorder =
+ GetViewFrame()->GetBindings().GetRecorder();
+ //prevent additional dialogs in recorded macros
+ if ( xRecorder.is() )
+ rReq.AppendItem(SfxBoolItem(SID_SEARCH_QUIET, sal_True));
+
+ rReq.Done();
+ }
+ break;
+ case FID_SEARCH_SEARCHSET:
+ case FID_SEARCH_REPLACESET:
+ {
+ static const USHORT aNormalAttr[] =
+ {
+/* 0 */ RES_CHRATR_CASEMAP, RES_CHRATR_CASEMAP,
+/* 2 */ RES_CHRATR_COLOR, RES_CHRATR_POSTURE,
+/* 4 */ RES_CHRATR_SHADOWED, RES_CHRATR_WORDLINEMODE,
+/* 6 */ RES_CHRATR_BLINK, RES_CHRATR_BLINK,
+/* 8 */ RES_CHRATR_BACKGROUND, RES_CHRATR_BACKGROUND,
+/*10 */ RES_CHRATR_ROTATE, RES_CHRATR_ROTATE,
+/*12 */ RES_CHRATR_SCALEW, RES_CHRATR_RELIEF,
+// insert position for CJK/CTL attributes!
+/*14 */ RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
+/*16 */ RES_PARATR_REGISTER, RES_PARATR_REGISTER,
+/*18 */ RES_PARATR_VERTALIGN, RES_PARATR_VERTALIGN,
+/*20 */ RES_LR_SPACE, RES_UL_SPACE,
+/*22 */ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+/*24 */ 0
+ };
+
+ static const USHORT aCJKAttr[] =
+ {
+ RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_WEIGHT,
+ RES_CHRATR_EMPHASIS_MARK, RES_CHRATR_TWO_LINES,
+ RES_PARATR_SCRIPTSPACE, RES_PARATR_FORBIDDEN_RULES
+ };
+ static const USHORT aCTLAttr[] =
+ {
+ RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_WEIGHT
+ };
+
+ SvUShorts aArr( 0, 16 );
+ aArr.Insert( aNormalAttr,
+ sizeof( aNormalAttr ) / sizeof( aNormalAttr[0] ),
+ 0 );
+ if( SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
+ aArr.Insert( aCTLAttr,
+ sizeof( aCTLAttr ) / sizeof( aCTLAttr[0] ),
+ 14 );
+ SvtCJKOptions aCJKOpt;
+ if( aCJKOpt.IsAnyEnabled() )
+ aArr.Insert( aCJKAttr,
+ sizeof( aCJKAttr ) / sizeof( aCJKAttr[0] ),
+ 14 );
+
+ SfxItemSet aSet( pWrtShell->GetAttrPool(), aArr.GetData() );
+ USHORT nWhich = SID_SEARCH_SEARCHSET;
+
+ if ( FID_SEARCH_REPLACESET == nSlot )
+ {
+ nWhich = SID_SEARCH_REPLACESET;
+
+ if ( pReplList )
+ {
+ pReplList->Get( aSet );
+ DELETEZ( pReplList );
+ }
+ }
+ else if ( pSrchList )
+ {
+ pSrchList->Get( aSet );
+ DELETEZ( pSrchList );
+ }
+ rReq.SetReturnValue( SvxSetItem( nWhich, aSet ) );
+ }
+ break;
+ default:
+#ifdef DBG_UTIL
+ if(nSlot)
+ {
+ ByteString sStr( "nSlot: " );
+ sStr += ByteString::CreateFromInt32( nSlot );
+ sStr += " falscher Dispatcher (viewsrch.cxx)";
+ DBG_ERROR( sStr.GetBuffer() );
+ }
+#endif
+ return;
+ }
+}
+
+
+BOOL SwView::SearchAndWrap(BOOL bApi)
+{
+ SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
+
+ // Startposition der Suche fuer WrapAround merken
+ // Start- / EndAction wegen vielleicht bestehender Selektionen
+ // aus 'Suche alle'
+ pWrtShell->StartAllAction();
+ pWrtShell->Push();
+ // falls in selektierten Bereichen gesucht werden soll, duerfen sie
+ // nicht aufgehoben werden
+ if (!pSrchItem->GetSelection())
+ (pWrtShell->*pWrtShell->fnKillSel)(0, FALSE);
+
+ SwWait *pWait = new SwWait( *GetDocShell(), TRUE );
+ if( FUNC_Search( aOpts ) )
+ {
+ bFound = TRUE;
+ if(pWrtShell->IsSelFrmMode())
+ {
+ pWrtShell->UnSelectFrm();
+ pWrtShell->LeaveSelFrmMode();
+ }
+ pWrtShell->Pop();
+ pWrtShell->EndAllAction();
+ delete pWait;
+ return TRUE;
+ }
+ delete pWait, pWait = 0;
+
+ // Suchen in den Sonderbereichen, wenn keine
+ // Suche in Selektionen vorliegt. Bei Suche in Selektionen
+ // wird ohnehin in diesen Sonderbereichen gesucht
+ BOOL bHasSrchInOther = bExtra;
+ if (!pSrchItem->GetSelection() && !bExtra )
+ {
+ bExtra = TRUE;
+ if( FUNC_Search( aOpts ) )
+ {
+ bFound = TRUE;
+ pWrtShell->Pop();
+ pWrtShell->EndAllAction();
+ return TRUE;
+ }
+ bExtra = FALSE;
+ }
+ else
+ bExtra = !bExtra;
+
+ const USHORT nId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)GetViewFrame()->GetChildWindow(nId);
+ pSrchDlg = pWrp ? static_cast <SvxSearchDialog*> (pWrp->getDialog ()) : 0;
+
+ // falls Startposition am Dokumentende / -anfang
+ if (aOpts.bDontWrap)
+ {
+ pWrtShell->EndAllAction();
+ if( !bApi )
+ {
+ Window* pParentWindow = GetParentWindow( pSrchDlg );
+ InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
+ }
+ bFound = FALSE;
+ pWrtShell->Pop();
+ return FALSE;
+ }
+ pWrtShell->EndAllAction();
+ // noch mal mit WrapAround versuchen?
+
+ if( bApi || RET_NO == QueryBox( GetParentWindow( pSrchDlg ),
+ SW_RES( DOCPOS_START == aOpts.eEnd
+ ? MSG_SEARCH_START
+ : MSG_SEARCH_END )
+ ).Execute() )
+ {
+ bFound = FALSE;
+ pWrtShell->Pop();
+ return FALSE;
+ }
+ pWrtShell->StartAllAction();
+ pWrtShell->Pop(FALSE);
+ pWait = new SwWait( *GetDocShell(), TRUE );
+
+ BOOL bSrchBkwrd = DOCPOS_START == aOpts.eEnd;
+
+ aOpts.eEnd = bSrchBkwrd ? DOCPOS_START : DOCPOS_END;
+ aOpts.eStart = bSrchBkwrd ? DOCPOS_END : DOCPOS_START;
+
+ if (bHasSrchInOther)
+ {
+ pWrtShell->ClearMark();
+ if (bSrchBkwrd)
+ pWrtShell->EndDoc();
+ else
+ pWrtShell->SttDoc();
+ }
+
+ bFound = 0 != FUNC_Search( aOpts );
+ pWrtShell->EndAllAction();
+ delete pWait;
+ if ( bFound )
+ return bFound;
+ if(!bApi)
+ {
+ Window* pParentWindow = GetParentWindow( pSrchDlg );
+ InfoBox( pParentWindow, SW_RES(MSG_NOT_FOUND)).Execute();
+ }
+ return bFound = FALSE;
+}
+
+
+BOOL SwView::SearchAll(USHORT* pFound)
+{
+ SwWait aWait( *GetDocShell(), TRUE );
+ pWrtShell->StartAllAction();
+
+ SwSearchOptions aOpts( pWrtShell, pSrchItem->GetBackward() );
+
+ if (!pSrchItem->GetSelection())
+ {
+ // bestehende Selektionen aufheben,
+ // wenn nicht in selektierten Bereichen gesucht werden soll
+ (pWrtShell->*pWrtShell->fnKillSel)(0, FALSE);
+
+ if( DOCPOS_START == aOpts.eEnd )
+ pWrtShell->EndDoc();
+ else
+ pWrtShell->SttDoc();
+ }
+ bExtra = FALSE;
+ USHORT nFound = (USHORT)FUNC_Search( aOpts );
+ if(pFound)
+ *pFound = nFound;
+ bFound = 0 != nFound;
+
+ pWrtShell->EndAllAction();
+ return bFound;
+}
+
+
+void SwView::Replace()
+{
+ SwWait aWait( *GetDocShell(), TRUE );
+
+ pWrtShell->StartAllAction();
+
+ if( pSrchItem->GetPattern() ) // Vorlagen?
+ {
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UNDO_ARG1, pSrchItem->GetSearchString());
+ aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS));
+ aRewriter.AddRule(UNDO_ARG3, pSrchItem->GetReplaceString());
+
+ pWrtShell->StartUndo(UNDO_UI_REPLACE_STYLE, &aRewriter); // #111827#
+
+ pWrtShell->SetTxtFmtColl( pWrtShell->GetParaStyle(
+ pSrchItem->GetReplaceString(),
+ SwWrtShell::GETSTYLE_CREATESOME ));
+
+ pWrtShell->EndUndo(UNDO_UI_REPLACE_STYLE); // #111827#
+ }
+ else
+ {
+ if (GetPostItMgr()->HasActiveSidebarWin())
+ GetPostItMgr()->Replace(pSrchItem);
+ sal_Bool bReplaced = pWrtShell->SwEditShell::Replace( pSrchItem->GetReplaceString(),
+ pSrchItem->GetRegExp());
+
+ if( bReplaced && pReplList && pReplList->Count() && pWrtShell->HasSelection() )
+ {
+ SfxItemSet aReplSet( pWrtShell->GetAttrPool(),
+ aTxtFmtCollSetRange );
+ if( pReplList->Get( aReplSet ).Count() )
+ {
+ ::SfxToSwPageDescAttr( *pWrtShell, aReplSet );
+ pWrtShell->SwEditShell::SetAttr( aReplSet );
+ }
+ }
+ }
+
+ pWrtShell->EndAllAction();
+}
+
+
+
+SwSearchOptions::SwSearchOptions( SwWrtShell* pSh, BOOL bBackward )
+{
+ eStart = DOCPOS_CURR;
+ if( bBackward )
+ {
+ eEnd = DOCPOS_START;
+ bDontWrap = pSh->IsEndOfDoc();
+ }
+ else
+ {
+ eEnd = DOCPOS_END;
+ bDontWrap = pSh->IsStartOfDoc();
+ }
+}
+
+ULONG SwView::FUNC_Search( const SwSearchOptions& rOptions )
+{
+ BOOL bDoReplace = pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE ||
+ pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
+
+ int eRanges = pSrchItem->GetSelection() ?
+ FND_IN_SEL : bExtra ? FND_IN_OTHER : FND_IN_BODY;
+ if (pSrchItem->GetCommand() == SVX_SEARCHCMD_FIND_ALL ||
+ pSrchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
+ eRanges |= FND_IN_SELALL;
+
+ pWrtShell->SttSelect();
+
+ static USHORT __READONLY_DATA aSearchAttrRange[] = {
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+ 0 };
+
+ SfxItemSet aSrchSet( pWrtShell->GetAttrPool(), aSearchAttrRange);
+ if( pSrchList && pSrchList->Count() )
+ {
+ pSrchList->Get( aSrchSet );
+
+ /* -- Seitenumbruch mit Seitenvorlage */
+ ::SfxToSwPageDescAttr( *pWrtShell, aSrchSet );
+ }
+
+ SfxItemSet* pReplSet = 0;
+ if( bDoReplace && pReplList && pReplList->Count() )
+ {
+ pReplSet = new SfxItemSet( pWrtShell->GetAttrPool(),
+ aSearchAttrRange );
+ pReplList->Get( *pReplSet );
+
+ /* -- Seitenumbruch mit Seitenvorlage */
+ ::SfxToSwPageDescAttr( *pWrtShell, *pReplSet );
+
+ if( !pReplSet->Count() ) // schade, die Attribute
+ DELETEZ( pReplSet ); // kennen wir nicht
+ }
+
+ //
+ // build SearchOptions to be used
+ //
+ SearchOptions aSearchOpt( pSrchItem->GetSearchOptions() );
+ aSearchOpt.Locale = SvxCreateLocale( (USHORT)GetAppLanguage() );
+ if( !bDoReplace )
+ aSearchOpt.replaceString = aEmptyStr;
+
+ ULONG nFound;
+ if( aSrchSet.Count() || ( pReplSet && pReplSet->Count() ))
+ {
+ nFound = pWrtShell->SearchAttr(
+ aSrchSet,
+ !pSrchItem->GetPattern(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ pSrchItem->GetSearchString().Len() ? &aSearchOpt : 0,
+ pReplSet );
+ }
+ else if( pSrchItem->GetPattern() )
+ {
+ // Suchen (und ersetzen) von Vorlagen
+ const String sRplStr( pSrchItem->GetReplaceString() );
+ nFound = pWrtShell->SearchTempl( pSrchItem->GetSearchString(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ bDoReplace ? &sRplStr : 0 );
+ }
+ else
+ {
+ // Normale Suche
+ nFound = pWrtShell->SearchPattern(aSearchOpt, pSrchItem->GetNotes(),
+ rOptions.eStart,
+ rOptions.eEnd,
+ FindRanges(eRanges),
+ bDoReplace );
+ }
+ pWrtShell->EndSelect();
+ return nFound;
+}
+
+LAYOUT_NS Dialog* SwView::GetSearchDialog()
+{
+ const USHORT nId = SvxSearchDialogWrapper::GetChildWindowId();
+ SvxSearchDialogWrapper *pWrp = (SvxSearchDialogWrapper*)SfxViewFrame::Current()->GetChildWindow(nId);
+ if ( pWrp )
+ pSrchDlg = pWrp->getDialog ();
+ else
+ pSrchDlg = 0;
+ return pSrchDlg;
+}
+
+void SwView::StateSearch(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case SID_SEARCH_OPTIONS:
+ {
+ UINT16 nOpt = 0xFFFF;
+ if( GetDocShell()->IsReadOnly() )
+ nOpt &= ~( SEARCH_OPTIONS_REPLACE |
+ SEARCH_OPTIONS_REPLACE_ALL );
+ rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, nOpt));
+ }
+ break;
+ case SID_SEARCH_ITEM:
+ {
+ if ( !pSrchItem )
+ {
+ pSrchItem = new SvxSearchItem( SID_SEARCH_ITEM );
+ pSrchItem->SetFamily(SFX_STYLE_FAMILY_PARA);
+ pSrchItem->SetSearchString( pWrtShell->GetSelTxt() );
+ }
+
+ if( bJustOpened && pWrtShell->IsSelection() )
+ {
+ String aTxt;
+ if( 1 == pWrtShell->GetCrsrCnt() &&
+ ( aTxt = pWrtShell->SwCrsrShell::GetSelTxt() ).Len() )
+ {
+ pSrchItem->SetSearchString( aTxt );
+ pSrchItem->SetSelection( FALSE );
+ }
+ else
+ pSrchItem->SetSelection( TRUE );
+ }
+
+ bJustOpened = FALSE;
+ rSet.Put( *pSrchItem );
+ }
+ break;
+
+/* case SID_SEARCH_REPLACESET:
+ case SID_SEARCH_SEARCHSET:
+ {
+ static USHORT __READONLY_DATA aSearchAttrRange[] =
+ {
+ RES_CHRATR_CASEMAP, RES_CHRATR_POSTURE,
+ RES_CHRATR_SHADOWED, RES_CHRATR_WORDLINEMODE,
+ RES_PARATR_LINESPACING, RES_PARATR_HYPHENZONE,
+ RES_LR_SPACE, RES_UL_SPACE,
+ SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP,
+ 0
+ };
+
+ SfxItemSet aSet(pWrtShell->GetAttrPool(), aSearchAttrRange );
+ if( SID_SEARCH_REPLACESET==nWhich )
+ {
+ if( pReplList )
+ {
+ pReplList->Get( aSet );
+ DELETEZ( pReplList );
+ }
+ }
+ else if( pSrchList )
+ {
+ pSrchList->Get( aSet );
+ DELETEZ( pSrchList );
+ }
+ rSet.Put( SvxSetItem( nWhich, aSet ));
+ }
+ break;
+*/
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx
new file mode 100755
index 000000000000..b0d5f71744c9
--- /dev/null
+++ b/sw/source/ui/uiview/viewstat.cxx
@@ -0,0 +1,530 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <hintids.hxx>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objitem.hxx>
+#include <svl/imageitm.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/protitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <svx/htmlmode.hxx>
+#include <editeng/unolingu.hxx>
+#include <sfx2/msgpool.hxx>
+#include <swmodule.hxx>
+#include <tox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#ifndef _VIEW_HXX
+#include <view.hxx>
+#endif
+#include <wrtsh.hxx>
+#ifndef _BASESH_HXX
+#include <basesh.hxx>
+#endif
+#include <uitool.hxx>
+#include <viewopt.hxx>
+#include <tablemgr.hxx>
+#include <pagedesc.hxx>
+#ifndef _WVIEW_HXX
+#include <wview.hxx>
+#endif
+#include <globdoc.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/visitem.hxx>
+
+#ifndef _CMDID_H
+#include <cmdid.h>
+#endif
+
+#include <IDocumentRedlineAccess.hxx>
+
+using namespace ::com::sun::star;
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwView::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_uInt16 eFrmType = FRMTYPE_NONE;
+ int bGetFrmType = sal_False;
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+
+ while(nWhich)
+ {
+ switch(nWhich)
+ {
+ case FN_EDIT_LINK_DLG:
+ if( !pWrtShell->GetLinkManager().GetLinks().Count() )
+ rSet.DisableItem(nWhich);
+ else if( pWrtShell->IsSelFrmMode() &&
+ pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
+ rSet.DisableItem(nWhich);
+ break;
+
+ case FN_INSERT_CAPTION:
+ {
+ // Captions gibt's fuer Grafiken, OLE-Objekte, Rahmen und Tabellen
+ if( !bGetFrmType )
+ eFrmType = pWrtShell->GetFrmType(0,sal_True), bGetFrmType = sal_True;
+ if (! ( ((eFrmType & FRMTYPE_FLY_ANY) && nSelectionType != nsSelectionType::SEL_DRW_TXT)||
+ nSelectionType & nsSelectionType::SEL_TBL ||
+ nSelectionType & nsSelectionType::SEL_DRW) )
+ rSet.DisableItem(nWhich);
+ else if((pWrtShell->IsObjSelected()||pWrtShell->IsFrmSelected()) &&
+ (pWrtShell->IsSelObjProtected( FLYPROTECT_PARENT)||
+ pWrtShell->IsSelObjProtected( FLYPROTECT_CONTENT )))
+ rSet.DisableItem(nWhich);
+ else if( pWrtShell->IsTableMode() )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_EDIT_FOOTNOTE:
+ {
+ if( !pWrtShell->GetCurFtn() )
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case FN_CHANGE_PAGENUM:
+ {
+ sal_uInt16 nType = pWrtShell->GetFrmType(0,sal_True);
+ if( ( FRMTYPE_FLY_ANY | FRMTYPE_HEADER | FRMTYPE_FOOTER |
+ FRMTYPE_FOOTNOTE | FRMTYPE_DRAWOBJ ) & nType )
+ rSet.DisableItem(nWhich);
+ else
+ rSet.Put(SfxUInt16Item(nWhich, pWrtShell->GetPageOffset()));
+ }
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
+ break;
+ case SID_ATTR_PAGE:
+ case SID_ATTR_PAGE_SIZE:
+ case SID_ATTR_PAGE_PAPERBIN:
+ case RES_PAPER_BIN:
+ case FN_PARAM_FTN_INFO:
+ {
+ const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc();
+ const SwPageDesc& rDesc = pWrtShell->GetPageDesc( nCurIdx );
+ ::PageDescToItemSet( rDesc, rSet);
+ }
+ break;
+ case RES_BACKGROUND:
+ case SID_ATTR_BRUSH:
+ {
+ const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc();
+ const SwPageDesc& rDesc = pWrtShell->GetPageDesc( nCurIdx );
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ const SvxBrushItem& rBrush = (const SvxBrushItem&)
+ rMaster.GetFmtAttr(RES_BACKGROUND, sal_True);
+ rSet.Put(rBrush);
+ }
+ break;
+ case SID_CLEARHISTORY:
+ {
+ rSet.Put(SfxBoolItem(nWhich, pWrtShell->GetUndoIds() != UNDO_EMPTY));
+ }
+ break;
+ case SID_UNDO:
+ {
+ //JP 21.07.98: Bug 53429 - die muss noch nicht vorhanden sein
+ // also lasse sie mal anlegen:
+ if( !pShell )
+ SelectShell();
+
+ const SfxPoolItem* pState = pShell->GetSlotState(SID_UNDO);
+ if(pState)
+ rSet.Put(*pState);
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_INSERT_CTRL:
+ {
+ SfxImageItem aImgItem(nWhich, bWeb ? SwView::nWebInsertCtrlState : SwView::nInsertCtrlState);
+ SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
+ const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
+ if(pSlot && pSlot->IsMode( SFX_SLOT_IMAGEROTATION ))
+ {
+ if(pWrtShell->IsInVerticalText())
+ aImgItem.SetRotation(2700);
+ if(pWrtShell->IsInRightToLeftText())
+ aImgItem.SetMirrored(TRUE);
+ }
+ rSet.Put(aImgItem);
+ }
+ break;
+ case FN_INSERT_OBJ_CTRL:
+ if(bWeb)
+ rSet.DisableItem(nWhich);
+ else
+ {
+ SfxImageItem aImgItem(nWhich, SwView::nInsertObjectCtrlState);
+ SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
+ const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
+ if(pSlot && pSlot->IsMode( SFX_SLOT_IMAGEROTATION ))
+ {
+ if(pWrtShell->IsInVerticalText())
+ aImgItem.SetRotation(2700);
+ if(pWrtShell->IsInRightToLeftText())
+ aImgItem.SetMirrored(TRUE);
+ }
+ rSet.Put(aImgItem);
+ }
+ break;
+ case FN_UPDATE_TOX:
+ if(!pWrtShell->GetTOXCount())
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_EDIT_CURRENT_TOX:
+ case FN_UPDATE_CUR_TOX:
+ {
+ const SwTOXBase* pBase = 0;
+ if(0 == (pBase = pWrtShell->GetCurTOX()) ||
+ (FN_EDIT_CURRENT_TOX == nWhich && pBase->IsTOXBaseInReadonly()))
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_TWAIN_SELECT:
+ case SID_TWAIN_TRANSFER:
+#if defined WIN || defined WNT || defined UNX
+ {
+ if(!SW_MOD()->GetScannerManager().is())
+ rSet.DisableItem(nWhich);
+ }
+#endif
+ break;
+ case RES_PARATR_TABSTOP:
+ case SID_ATTR_DEFTABSTOP:
+ {
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)pWrtShell->
+ GetDefault(RES_PARATR_TABSTOP);
+ rSet.Put( SfxUInt16Item( nWhich,
+ (sal_uInt16)::GetTabDist(rDefTabs)));
+ }
+ break;
+ case SID_ATTR_LANGUAGE:
+ {
+ rSet.Put((const SvxLanguageItem&)
+ pWrtShell->GetDefault(RES_CHRATR_LANGUAGE), SID_ATTR_LANGUAGE);
+ }
+ break;
+ case RES_CHRATR_CJK_LANGUAGE:
+ rSet.Put((const SvxLanguageItem&)
+ pWrtShell->GetDefault(RES_CHRATR_CJK_LANGUAGE), RES_CHRATR_CJK_LANGUAGE);
+ break;
+ case RES_CHRATR_CTL_LANGUAGE:
+ rSet.Put((const SvxLanguageItem&)
+ pWrtShell->GetDefault(RES_CHRATR_CTL_LANGUAGE), RES_CHRATR_CTL_LANGUAGE);
+ break;
+ case FN_HYPHENATE_OPT_DLG:
+ {
+ sal_Bool bCheck = sal_False;
+
+ if (pWrtShell->GetSelectionType() & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_DRW))
+ bCheck = IsDrawTextHyphenate();
+ rSet.Put(SfxBoolItem(nWhich, bCheck));
+ }
+ break;
+ case FN_REDLINE_ON:
+ rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) );
+ break;
+ case FN_REDLINE_PROTECT :
+ rSet.Put( SfxBoolItem( nWhich, GetDocShell()->HasChangeRecordProtection() ) );
+ break;
+ case FN_REDLINE_SHOW:
+ {
+ sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ rSet.Put( SfxBoolItem( nWhich,
+ (pWrtShell->GetRedlineMode() & nMask) == nMask ));
+ }
+ break;
+ case SID_GALLERY :
+ case SID_AVMEDIA_PLAYER :
+ case FN_REDLINE_ACCEPT :
+ {
+ SfxViewFrame* pVFrame = GetViewFrame();
+ if (pVFrame->KnowsChildWindow(nWhich))
+ rSet.Put(SfxBoolItem( nWhich, pVFrame->HasChildWindow(nWhich)));
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case FN_REDLINE_ACCEPT_DIRECT:
+ case FN_REDLINE_REJECT_DIRECT:
+ {
+ SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
+ Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True );
+ if( !pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case SID_THESAURUS:
+ {
+ SwWrtShell &rSh = GetWrtShell();
+ if (2 <= rSh.GetCrsrCnt()) // multi selection?
+ rSet.DisableItem(nWhich);
+ else
+ {
+ LanguageType nLang = rSh.GetCurLang();
+
+ // disable "Thesaurus" (menu entry and key shortcut) if the
+ // language is not supported (by default it is enabled)
+ uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
+ if (!xThes.is() || nLang == LANGUAGE_NONE ||
+ !xThes->hasLocale( SvxCreateLocale( nLang ) ))
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ case SID_HANGUL_HANJA_CONVERSION:
+ case SID_CHINESE_CONVERSION:
+ {
+ if (!SvtCJKOptions().IsAnyEnabled())
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
+ rSet.DisableItem(nWhich);
+ }
+ else
+ GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
+ }
+ break;
+ case SID_MAIL_SCROLLBODY_PAGEDOWN:
+ {
+ const long nBottom = pWrtShell->GetDocSize().Height() + DOCUMENTBORDER;
+ const long nAct = GetVisArea().Bottom();
+ rSet.Put(SfxBoolItem(SID_MAIL_SCROLLBODY_PAGEDOWN, nAct < nBottom ));
+ }
+ break;
+
+ case SID_DOCUMENT_COMPARE:
+ case SID_DOCUMENT_MERGE:
+ if( GetDocShell()->IsA( SwGlobalDocShell::StaticType() ) ||
+// pWrtShell->IsAnySectionInDoc( sal_True, sal_True, sal_True )||
+ (SID_DOCUMENT_MERGE == nWhich && pWrtShell->getIDocumentRedlineAccess()->GetRedlinePassword().getLength()))
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, GetViewFrame()->HasChildWindow( SID_BROWSER ) ) );
+ break;
+ case SID_READONLY_MODE:
+ rSet.Put(SfxBoolItem(nWhich,
+ pWrtShell->HasReadonlySel()||GetDocShell()->IsReadOnly()));
+ break;
+ case SID_IMAGE_ORIENTATION:
+ {
+ SfxImageItem aImageItem(nWhich);
+ if(pWrtShell->IsInVerticalText())
+ aImageItem.SetRotation( 2700 );
+ if(pWrtShell->IsInRightToLeftText())
+ aImageItem.SetMirrored( TRUE );
+ rSet.Put(aImageItem);
+ }
+ break;
+ case FN_INSERT_FIELD_DATA_ONLY :
+ if(!bInMailMerge && !GetViewFrame()->HasChildWindow(nWhich))
+ rSet.DisableItem(nWhich);
+ break;
+ case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
+ break;
+ case FN_MAILMERGE_CHILDWINDOW:
+ {
+ if(!GetMailMergeConfigItem())
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_ALIGN_ANY_LEFT :
+ case SID_ALIGN_ANY_HCENTER :
+ case SID_ALIGN_ANY_RIGHT :
+ case SID_ALIGN_ANY_JUSTIFIED:
+ case SID_ALIGN_ANY_TOP :
+ case SID_ALIGN_ANY_VCENTER :
+ case SID_ALIGN_ANY_BOTTOM :
+ case SID_ALIGN_ANY_HDEFAULT :
+ case SID_ALIGN_ANY_VDEFAULT :
+ {
+ if( !pShell )
+ SelectShell();
+ USHORT nAlias = 0;
+ bool bDraw = false;
+ if( nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
+ {
+ switch( nWhich )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
+ case SID_ALIGN_ANY_TOP : nAlias = FN_TABLE_VERT_NONE; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = FN_TABLE_VERT_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = FN_TABLE_VERT_BOTTOM; break;
+ }
+ }
+ else if(nSelectionType & (nsSelectionType::SEL_DRW))
+ {
+ //the draw shell cannot provide a status per item - only one for SID_OBJECT_ALIGN
+ if(nWhich != SID_ALIGN_ANY_JUSTIFIED)
+ {
+ const SfxPoolItem* pItem = 0;
+ GetViewFrame()->GetDispatcher()->QueryState( SID_OBJECT_ALIGN, pItem );
+ if(pItem)
+ bDraw = true;
+ }
+ }
+ else
+ {
+ switch( nWhich )
+ {
+ case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
+ case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
+ case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
+ case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
+ case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
+ case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
+ }
+ }
+ //these slots are either re-mapped to text or object alignment
+ const SfxPoolItem* pState = 0;
+ if(nAlias)
+ GetViewFrame()->GetDispatcher()->QueryState( nAlias, pState );
+ if(pState)
+ rSet.Put(*pState, nWhich);
+ else if(!bDraw)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SwView::GetDrawState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
+
+ for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich;
+ nWhich = aIter.NextWhich() )
+ switch(nWhich)
+ {
+ case SID_INSERT_DRAW:
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SfxAllEnumItem aEnum(SID_INSERT_DRAW, nDrawSfxId);
+ if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
+ {
+ aEnum.DisableValue( SID_DRAW_CAPTION_VERTICAL );
+ aEnum.DisableValue( SID_DRAW_TEXT_VERTICAL );
+ }
+ rSet.Put(aEnum);
+ }
+ break;
+
+ case SID_SHOW_HIDDEN:
+ case SID_SHOW_FORMS:
+ rSet.DisableItem( nWhich );
+ // rSet.Put( SfxBoolItem(nWhich,sal_True ));
+ break;
+
+ case SID_DRAW_TEXT_MARQUEE:
+ if (::GetHtmlMode(GetDocShell()) & HTMLMODE_SOME_STYLES)
+ rSet.Put( SfxBoolItem(nWhich, nDrawSfxId == nWhich));
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_OBJECT_SELECT:
+ rSet.Put( SfxBoolItem(nWhich, nDrawSfxId == nWhich ||
+ nFormSfxId == nWhich));
+ break;
+
+ case SID_FONTWORK_GALLERY_FLOATER :
+ {
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DRAWTBX_CS_BASIC :
+ case SID_DRAWTBX_CS_SYMBOL :
+ case SID_DRAWTBX_CS_ARROW :
+ case SID_DRAWTBX_CS_FLOWCHART :
+ case SID_DRAWTBX_CS_CALLOUT :
+ case SID_DRAWTBX_CS_STAR :
+ {
+ if ( bWeb )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put(SfxStringItem(nWhich, aCurrShapeEnumCommand[ nWhich - SID_DRAWTBX_CS_BASIC ] ));
+ }
+ break;
+
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+sal_Bool SwView::HasUIFeature( sal_uInt32 nFeature )
+{
+ sal_Bool bRet = sal_False;
+ switch(nFeature)
+ {
+ case CHILDWIN_LABEL : bRet = pWrtShell->IsLabelDoc(); break;
+ case CHILDWIN_MAILMERGE : bRet = 0 != GetMailMergeConfigItem(); break;
+ }
+ return bRet;
+}
+
diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx
new file mode 100644
index 000000000000..44e314a7475b
--- /dev/null
+++ b/sw/source/ui/uiview/viewtab.cxx
@@ -0,0 +1,1848 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <tools/list.hxx>
+
+#include <hintids.hxx>
+#include "uitool.hxx"
+#include <sfx2/app.hxx>
+#include <svx/rulritem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <sfx2/request.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/protitem.hxx>
+#include <svl/rectitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <fmtfsize.hxx>
+#include <fmthdft.hxx>
+#include <fmtclds.hxx>
+#include <fmtornt.hxx>
+#include <frmatr.hxx>
+#include <edtwin.hxx>
+#include "view.hxx"
+#include "wrtsh.hxx"
+#include "basesh.hxx"
+#include "cmdid.h"
+#include "viewopt.hxx"
+#include "tabcol.hxx"
+#include "frmfmt.hxx" // FrameFormat
+#include "pagedesc.hxx" // Aktuelles Seitenformat
+#include "wview.hxx"
+#include "fmtcol.hxx"
+#include "section.hxx"
+
+// -> #i23726#
+#include "ndtxt.hxx"
+#include "pam.hxx"
+// <- #i23726#
+
+#include <IDocumentSettingAccess.hxx>
+
+using namespace ::com::sun::star;
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Debug-Methode
+ --------------------------------------------------------------------*/
+
+
+/*--------------------------------------------------------------------
+ Beschreibung: Columns eintueten
+ --------------------------------------------------------------------*/
+
+
+void lcl_FillSvxColumn(const SwFmtCol& rCol,
+ USHORT nTotalWidth,
+ SvxColumnItem& rColItem,
+ long nDistance)
+{
+ const SwColumns& rCols = rCol.GetColumns();
+ USHORT nWidth = 0;
+
+ BOOL bOrtho = rCol.IsOrtho() && rCols.Count();
+ long nInnerWidth = 0;
+ if( bOrtho )
+ {
+ nInnerWidth = nTotalWidth;
+ for ( USHORT i = 0; i < rCols.Count(); ++i )
+ {
+ SwColumn* pCol = rCols[i];
+ nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
+ }
+ if( nInnerWidth < 0 )
+ nInnerWidth = 0;
+ else
+ nInnerWidth /= rCols.Count();
+ }
+ for ( USHORT i = 0; i < rCols.Count(); ++i )
+ {
+ SwColumn* pCol = rCols[i];
+ const USHORT nStart = USHORT(pCol->GetLeft() + nWidth + nDistance);
+ if( bOrtho )
+ nWidth = static_cast< USHORT >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight());
+ else
+ nWidth = static_cast< USHORT >(nWidth + rCol.CalcColWidth(i, nTotalWidth));
+ const USHORT nEnd = USHORT(nWidth - pCol->GetRight() + nDistance);
+
+ SvxColumnDescription aColDesc(nStart, nEnd, TRUE);
+ rColItem.Append(aColDesc);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: ColumnItem in ColumnInfo ueberfuehren
+ --------------------------------------------------------------------*/
+
+
+void lcl_ConvertToCols(const SvxColumnItem& rColItem,
+ USHORT nTotalWidth,
+ SwFmtCol& rCols)
+{
+ ASSERT( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
+ // #126939# ruler executes that change the columns shortly after the selection has changed
+ // can result in a crash
+ if(rCols.GetNumCols() != rColItem.Count())
+ return;
+
+ USHORT nLeft = 0;
+ SwTwips nSumAll= 0; // Summiere alle Spalten und Raender auf
+
+ SwColumns& rArr = rCols.GetColumns();
+
+ // Tabcols der Reihe nach
+ for( USHORT i=0; i < rColItem.Count()-1; ++i )
+ {
+ DBG_ASSERT(rColItem[i+1].nStart >= rColItem[i].nEnd,"\201berlappende Spalten" );
+ USHORT nStart = static_cast< USHORT >(rColItem[i+1].nStart);
+ USHORT nEnd = static_cast< USHORT >(rColItem[i].nEnd);
+ if(nStart < nEnd)
+ nStart = nEnd;
+ const USHORT nDiff = nStart - nEnd;
+ const USHORT nRight = nDiff / 2;
+
+ USHORT nWidth = static_cast< USHORT >(rColItem[i].nEnd - rColItem[i].nStart);
+ nWidth += nLeft + nRight;
+
+ SwColumn* pCol = rArr[i];
+ pCol->SetWishWidth( USHORT(long(rCols.GetWishWidth()) * long(nWidth) /
+ long(nTotalWidth) ));
+ pCol->SetLeft( nLeft );
+ pCol->SetRight( nRight );
+ nSumAll += pCol->GetWishWidth();
+
+ nLeft = nRight;
+ }
+ rArr[rColItem.Count()-1]->SetLeft( nLeft );
+
+ //Die Differenz aus der Gesamtwunschbreite und der Summe der bisher berechneten
+ // Spalten und Raender sollte die Breite der letzten Spalte ergeben.
+ rArr[rColItem.Count()-1]->SetWishWidth( rCols.GetWishWidth() - (USHORT)nSumAll );
+
+ rCols.SetOrtho(FALSE, 0, 0 );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Tabs loeschen
+ --------------------------------------------------------------------*/
+
+
+void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
+{
+ // Def Tabs loeschen
+ for ( USHORT i = 0; i < rTabStops.Count(); )
+ {
+ // Hier auch den DefTab auf Null rausschmeissen
+ if ( SVX_TAB_ADJUST_DEFAULT == rTabStops[i].GetAdjustment() ||
+ rTabStops[i].GetTabPos() == 0 )
+ {
+ rTabStops.Remove(i);
+ continue;
+ }
+ ++i;
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Seitenrand umdrehen
+ --------------------------------------------------------------------*/
+
+
+void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
+{
+ USHORT nPhyPage, nVirPage;
+ GetWrtShell().GetPageNum( nPhyPage, nVirPage );
+
+ if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
+ {
+ long nTmp = rLRSpace.GetRight();
+ rLRSpace.SetRight( rLRSpace.GetLeft() );
+ rLRSpace.SetLeft( nTmp );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Wenn der Rahmenrand verschoben wird, sollen die
+ Spaltentrenner an der gleichen absoluten Position bleiben
+ --------------------------------------------------------------------*/
+
+
+void lcl_Scale(long& nVal, long nScale)
+{
+ nVal *= nScale;
+ nVal >>= 8;
+}
+
+void ResizeFrameCols(SwFmtCol& rCol,
+ long nOldWidth,
+ long nNewWidth,
+ long nLeftDelta )
+{
+ SwColumns& rArr = rCol.GetColumns();
+ long nWishSum = (long)rCol.GetWishWidth();
+ long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
+ long nNewWishWidth = nWishSum + nWishDiff;
+ if(nNewWishWidth > 0xffffl)
+ {
+ // wenn die Wunschbreite zu gross wird, dann muessen alle Werte passend skaliert werden
+ long nScale = (0xffffl << 8)/ nNewWishWidth;
+ for(USHORT i = 0; i < rArr.Count(); i++)
+ {
+ SwColumn* pCol = rArr.GetObject(i);
+ long nVal = pCol->GetWishWidth();
+ lcl_Scale(nVal, nScale);
+ pCol->SetWishWidth((USHORT) nVal);
+ nVal = pCol->GetLeft();
+ lcl_Scale(nVal, nScale);
+ pCol->SetLeft((USHORT) nVal);
+ nVal = pCol->GetRight();
+ lcl_Scale(nVal, nScale);
+ pCol->SetRight((USHORT) nVal);
+ }
+ lcl_Scale(nNewWishWidth, nScale);
+ lcl_Scale(nWishDiff, nScale);
+ }
+ rCol.SetWishWidth( (USHORT) (nNewWishWidth) );
+
+ if( nLeftDelta >= 2 || nLeftDelta <= -2)
+ rArr[0]->SetWishWidth(rArr[0]->GetWishWidth() + (USHORT)nWishDiff);
+ else
+ rArr[rArr.Count()-1]->SetWishWidth(rArr[rArr.Count()-1]->GetWishWidth() + (USHORT)nWishDiff);
+ //reset auto width
+ rCol.SetOrtho(FALSE, 0, 0 );
+}
+/*--------------------------------------------------------------------
+ Beschreibung: Hier werden alle Aenderungen der Tableiste
+ wieder in das Modell geschossen
+ --------------------------------------------------------------------*/
+
+
+void SwView::ExecTabWin( SfxRequest& rReq )
+{
+ SwWrtShell &rSh = GetWrtShell();
+ const USHORT nFrmType = rSh.IsObjSelected() ?
+ FRMTYPE_DRAWOBJ :
+ rSh.GetFrmType(0,TRUE);
+ const BOOL bFrmSelection = rSh.IsFrmSelected();
+ const BOOL bBrowse = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+
+
+ const USHORT nSlot = rReq.GetSlot();
+ const USHORT nDescId = rSh.GetCurPageDesc();
+ const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
+
+ const BOOL bVerticalWriting = rSh.IsInVerticalText();
+ const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
+ SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+
+ const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
+ SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+
+ const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
+
+ const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
+ const long nPageWidth = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
+ const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();
+
+ BOOL bUnlockView = FALSE;
+ rSh.StartAllAction();
+ BOOL bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_LONG_LRSPACE:
+ {
+ SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)rReq.GetArgs()->
+ Get( SID_ATTR_LONG_LRSPACE ) );
+ SvxLRSpaceItem aLR(RES_LR_SPACE);
+ if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
+ {
+ SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+
+ BOOL bRTL;
+ BOOL bVerticalFrame = (bFrmSelection && rSh.IsFrmVertical(TRUE, bRTL))|| (!bFrmSelection && bVerticalWriting);
+ long nDeltaX = bVerticalFrame ?
+ rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
+ rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
+
+ SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_HORI_ORIENT,
+ RES_COL, RES_COL, 0 );
+
+ if(bVerticalFrame)
+ {
+ SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+ aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+ aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
+ aSet.Put( aVertOrient );
+ }
+ else
+ {
+ SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
+ aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
+ aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
+ aSet.Put( aHoriOrient );
+ }
+
+ SwFmtFrmSize aSize( pFmt->GetFrmSize() );
+ long nOldWidth = (long) aSize.GetWidth();
+
+ if(aSize.GetWidthPercent())
+ {
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nPrtWidth = aRect.Width();
+ aSize.SetWidthPercent(BYTE((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
+ }
+ else
+ aSize.SetWidth( nPageWidth -
+ (aLongLR.GetLeft() + aLongLR.GetRight()));
+
+ if( nFrmType & FRMTYPE_COLUMN )
+ {
+ SwFmtCol aCol(pFmt->GetCol());
+
+ ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
+ aSet.Put(aCol);
+ }
+
+ aSet.Put( aSize );
+
+ rSh.StartAction();
+ rSh.Push();
+ rSh.SetFlyFrmAttr( aSet );
+ //die Rahmenselektion wieder aufheben
+ if(!bFrmSelection && rSh.IsFrmSelected())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.Pop();
+ rSh.EndAction();
+ }
+ else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+ // Seitenraender rausrechnen
+ long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
+ aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
+
+ nOld = rDesc.GetMaster().GetLRSpace().GetRight();
+ aLongLR.SetRight( nOld > (USHORT)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
+ aLR.SetLeft((USHORT)aLongLR.GetLeft());
+ aLR.SetRight((USHORT)aLongLR.GetRight());
+
+ if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
+ pHeaderFmt->SetFmtAttr( aLR );
+ else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
+ pFooterFmt->SetFmtAttr( aLR );
+ }
+ else if( nFrmType == FRMTYPE_DRAWOBJ)
+ {
+ SwRect aRect( rSh.GetObjRect() );
+ aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
+ aRect.Right( rPageRect.Right() - aLongLR.GetRight());
+ rSh.SetObjRect( aRect );
+ }
+ else if(bSect || rSh.IsDirectlyInSection())
+ {
+ //change the section indents and the columns if available
+ //at first determine the changes
+ SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+ aSectRect.Pos() += aTmpRect.Pos();
+ long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
+ long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
+ //change the LRSpaceItem of the section accordingly
+ const SwSection* pCurrSect = rSh.GetCurrSection();
+ const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+ SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
+ aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
+ aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+ aSet.Put(aLRTmp);
+ //change the first/last column
+ if(bSect)
+ {
+ SwFmtCol aCols( pSectFmt->GetCol() );
+ long nDiffWidth = nLeftDiff + nRightDiff;
+ ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
+ aSet.Put( aCols );
+ }
+ SwSectionData aData(*pCurrSect);
+ rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+ }
+ else
+ { // Seitenraender einstellen
+ aLR.SetLeft((USHORT)aLongLR.GetLeft());
+ aLR.SetRight((USHORT)aLongLR.GetRight());
+ SwapPageMargin( rDesc, aLR );
+ SwPageDesc aDesc( rDesc );
+ aDesc.GetMaster().SetFmtAttr( aLR );
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ }
+ break;
+ case SID_ATTR_LONG_ULSPACE:
+ {
+ SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)rReq.GetArgs()->
+ Get( SID_ATTR_LONG_ULSPACE ));
+
+ if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+ const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
+ const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
+
+ SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+ RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
+ //which of the orientation attributes is to be put depends on the frame's environment
+ BOOL bRTL;
+ if((bFrmSelection && rSh.IsFrmVertical(TRUE, bRTL))|| (!bFrmSelection && bVerticalWriting))
+ {
+ SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
+ aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
+ aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
+ aSet.Put( aHoriOrient );
+ }
+ else
+ {
+ SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+ aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+ aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
+ aSet.Put( aVertOrient );
+ }
+ SwFmtFrmSize aSize(pFmt->GetFrmSize());
+ if(aSize.GetHeightPercent())
+ {
+ SwRect aRect;
+ rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+ long nPrtHeight = aRect.Height();
+ aSize.SetHeightPercent(BYTE(nHeight * 100 /nPrtHeight));
+ }
+ else
+ aSize.SetHeight(nHeight );
+
+ aSet.Put( aSize );
+ rSh.SetFlyFrmAttr( aSet );
+ }
+ else if( nFrmType == FRMTYPE_DRAWOBJ )
+ {
+ SwRect aRect( rSh.GetObjRect() );
+ aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
+ aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
+ rSh.SetObjRect( aRect ) ;
+ }
+ else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
+ {
+ //change the section indents and the columns if available
+ //at first determine the changes
+ SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+ aSectRect.Pos() += aTmpRect.Pos();
+ const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
+ const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
+ //change the LRSpaceItem of the section accordingly
+ const SwSection* pCurrSect = rSh.GetCurrSection();
+ const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+ SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
+ aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
+ aLR.SetRight(aLR.GetRight() + nRightDiff);
+ SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+ aSet.Put(aLR);
+ //change the first/last column
+ if(bSect)
+ {
+ SwFmtCol aCols( pSectFmt->GetCol() );
+ long nDiffWidth = nLeftDiff + nRightDiff;
+ ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
+ aSet.Put( aCols );
+ }
+ SwSectionData aData(*pCurrSect);
+ rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+ }
+ else
+ { SwPageDesc aDesc( rDesc );
+
+ if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+
+ const BOOL bHead = nFrmType & FRMTYPE_HEADER ? TRUE : FALSE;
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ if ( bHead )
+ aUL.SetUpper( (USHORT)aLongULSpace.GetUpper() );
+ else
+ aUL.SetLower( (USHORT)aLongULSpace.GetLower() );
+ aDesc.GetMaster().SetFmtAttr( aUL );
+
+ if( bHead && pHeaderFmt || !bHead && pFooterFmt )
+ {
+ SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
+ pFooterFmt->GetFrmSize() );
+ aSz.SetHeightSizeType( ATT_FIX_SIZE );
+ aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
+ aLongULSpace.GetUpper() );
+ if ( bHead )
+ pHeaderFmt->SetFmtAttr( aSz );
+ else
+ pFooterFmt->SetFmtAttr( aSz );
+ }
+ }
+ else
+ {
+ SvxULSpaceItem aUL(RES_UL_SPACE);
+ aUL.SetUpper((USHORT)aLongULSpace.GetUpper());
+ aUL.SetLower((USHORT)aLongULSpace.GetLower());
+ aDesc.GetMaster().SetFmtAttr(aUL);
+ }
+
+ rSh.ChgPageDesc( nDescId, aDesc );
+ }
+ }
+ break;
+ case SID_ATTR_TABSTOP_VERTICAL:
+ case SID_ATTR_TABSTOP:
+ {
+ USHORT nWhich = GetPool().GetWhich(nSlot);
+ SvxTabStopItem aTabStops( (const SvxTabStopItem&)rReq.GetArgs()->
+ Get( nWhich ));
+ aTabStops.SetWhich(RES_PARATR_TABSTOP);
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
+
+ // Default-Tab an Pos 0
+ SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+ rSh.GetCurAttr( aSet );
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
+
+ if ( rLR.GetTxtFirstLineOfst() < 0 )
+ {
+ SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+ aTabStops.Insert( aSwTabStop );
+ }
+
+ // auffuellen mit Default-Tabs
+ USHORT nDef = ::GetTabDist( rDefTabs );
+ ::MakeDefTabs( nDef, aTabStops );
+
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+ if( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+ aTmp.Put(aTabStops);
+ rSh.AutoUpdatePara( pColl, aTmp );
+ }
+ else
+ rSh.SetAttr( aTabStops );
+ break;
+ }
+ case SID_ATTR_PARA_LRSPACE_VERTICAL:
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
+ GetArgs()->Get(nSlot));
+ if(nFrmType & FRMTYPE_FLY_ANY)
+ {
+ sal_Bool bFirstColumn = sal_True;
+ sal_Bool bLastColumn = sal_True;
+ if(nFrmType & FRMTYPE_COLUMN)
+ {
+ USHORT nCurFrameCol = rSh.GetCurColNum() - 1;
+ bFirstColumn = !nCurFrameCol;
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ const SwFmtCol* pCols = &pFmt->GetCol();
+ const SwColumns& rCols = pCols->GetColumns();
+ USHORT nColumnCount = rCols.Count();
+ bLastColumn = nColumnCount == nCurFrameCol + 1;
+ }
+ }
+ aParaMargin.SetRight( aParaMargin.GetRight() - nRightBorderDistance );
+ aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - nLeftBorderDistance );
+
+ aParaMargin.SetWhich( RES_LR_SPACE );
+ SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+
+ // #i23726#
+ if (pNumRuleNodeFromDoc)
+ {
+ // --> FME 2005-02-22 #i42922# Mouse move of numbering label
+ // has to consider the left indent of the paragraph
+ SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+ rSh.GetCurAttr( aSet );
+ const SvxLRSpaceItem& rLR =
+ static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
+ // <--
+
+ SwPosition aPos(*pNumRuleNodeFromDoc);
+ // --> OD 2008-06-09 #i90078#
+ rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
+ // <--
+ // --> OD 2005-02-18 #i42921# - invalidate state of indent in order
+ // to get a ruler update.
+ aParaMargin.SetWhich( nSlot );
+ GetViewFrame()->GetBindings().SetState( aParaMargin );
+ // <--
+ }
+ else if( pColl && pColl->IsAutoUpdateFmt() )
+ {
+ SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
+ aSet.Put(aParaMargin);
+ rSh.AutoUpdatePara( pColl, aSet);
+ }
+ else
+ rSh.SetAttr( aParaMargin );
+
+ if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
+ {
+ SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
+
+ rSh.GetCurAttr( aSet );
+ const SvxTabStopItem& rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
+
+ // Haben wir einen Tab an Stelle Null
+ USHORT i;
+
+ for ( i = 0; i < rTabStops.Count(); ++i )
+ if ( rTabStops[i].GetTabPos() == 0 )
+ break;
+
+ if ( i >= rTabStops.Count() )
+ {
+ // Kein DefTab
+ SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
+ aTabStops = rTabStops;
+
+ ::lcl_EraseDefTabs(aTabStops);
+
+ SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+ aTabStops.Insert(aSwTabStop);
+
+ const SvxTabStopItem& rDefTabs =
+ (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
+ USHORT nDef = ::GetTabDist(rDefTabs);
+ ::MakeDefTabs( nDef, aTabStops );
+
+ if( pColl && pColl->IsAutoUpdateFmt())
+ {
+ SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+ aSetTmp.Put(aTabStops);
+ rSh.AutoUpdatePara( pColl, aSetTmp );
+ }
+ else
+ rSh.SetAttr( aTabStops );
+ }
+ }
+ }
+ break;
+ case SID_RULER_BORDERS_VERTICAL:
+ case SID_RULER_BORDERS:
+ {
+ SvxColumnItem aColItem((const SvxColumnItem&)rReq.
+ GetArgs()->Get(nSlot));
+
+ if( bSetTabColFromDoc || !bSect && rSh.GetTableFmt() )
+ {
+ ASSERT(aColItem.Count(), "ColDesc ist leer!!");
+
+ const BOOL bSingleLine = ((const SfxBoolItem&)rReq.
+ GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
+
+ SwTabCols aTabCols;
+ if ( bSetTabColFromDoc )
+ rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
+ else
+ rSh.GetTabCols(aTabCols);
+
+ // linker Tabellenrand
+ long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
+ aTabCols.SetLeft( nBorder );
+
+ nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
+
+#ifdef DEBUG
+ long nTmp1 = nPageWidth;
+ long nTmp2 = aTabCols.GetLeftMin() + nBorder;
+ (void)nTmp1;
+ (void)nTmp2;
+#endif
+
+ if ( aColItem.GetRight() > 0 )
+ aTabCols.SetRight( nBorder );
+
+ // Tabcols der Reihe nach
+ // Die letzte Col wird durch den Rand definiert
+ //columns in right-to-left tables need to be mirrored
+ BOOL bIsTableRTL =
+ IsTabColFromDoc() ?
+ rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
+ : rSh.IsTableRightToLeft();
+ if(bIsTableRTL)
+ {
+ USHORT nColCount = aColItem.Count() - 1;
+ for ( USHORT i = 0; i < nColCount; ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[nColCount - i];
+ aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+ else
+ {
+ for ( USHORT i = 0; i < aColItem.Count()-1; ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i];
+ aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+
+ if ( bSetTabColFromDoc )
+ {
+ if( !rSh.IsViewLocked() )
+ {
+ bUnlockView = TRUE;
+ rSh.LockView( TRUE );
+ }
+ rSh.SetMouseTabCols( aTabCols, bSingleLine,
+ aTabColFromDocPos );
+ }
+ else
+ rSh.SetTabCols(aTabCols, bSingleLine);
+
+ }
+ else
+ {
+ if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
+ {
+ SwSectionFmt *pSectFmt = 0;
+ SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
+ if(bSect)
+ {
+ const SwSection *pSect = rSh.GetAnySection();
+ ASSERT( pSect, "Welcher Bereich?");
+ pSectFmt = pSect->GetFmt();
+ }
+ else
+ {
+ rSh.GetFlyFrmAttr( aSet );
+ }
+ SwFmtCol aCols(
+ bSect ?
+ pSectFmt->GetCol() :
+ (const SwFmtCol&)aSet.Get( RES_COL, FALSE ));
+ SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
+ const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
+ ::lcl_ConvertToCols( aColItem, USHORT(lWidth), aCols );
+ aSet.Put( aCols );
+ if(bSect)
+ rSh.SetSectionAttr( aSet, pSectFmt );
+ else
+ {
+ rSh.StartAction();
+ rSh.Push();
+ rSh.SetFlyFrmAttr( aSet );
+ //die Rahmenselektion wieder aufheben
+ if(!bFrmSelection && rSh.IsFrmSelected())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.Pop();
+ rSh.EndAction();
+ }
+ }
+ else
+ {
+ SwFmtCol aCols( rDesc.GetMaster().GetCol() );
+ const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
+ ::lcl_ConvertToCols( aColItem,
+ USHORT(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
+ aCols );
+ SwPageDesc aDesc( rDesc );
+ aDesc.GetMaster().SetFmtAttr( aCols );
+ rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
+ }
+ }
+ }
+ break;
+
+ case SID_RULER_ROWS :
+ case SID_RULER_ROWS_VERTICAL:
+ {
+ SvxColumnItem aColItem((const SvxColumnItem&)rReq.
+ GetArgs()->Get(nSlot));
+
+ if( bSetTabColFromDoc || !bSect && rSh.GetTableFmt() )
+ {
+ ASSERT(aColItem.Count(), "ColDesc ist leer!!");
+
+ SwTabCols aTabCols;
+ if ( bSetTabRowFromDoc )
+ rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
+ else
+ rSh.GetTabRows(aTabCols);
+
+ if ( bVerticalWriting )
+ {
+ aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
+ aTabCols.SetLeftMin(aColItem.GetLeft());
+ }
+ else
+ {
+ long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
+ aTabCols.SetRight( nBorder );
+ }
+
+ if(bVerticalWriting)
+ {
+ for ( USHORT i = aColItem.Count() - 1; i; --i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i - 1];
+ long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
+ aTabCols[i - 1] = nColumnPos;
+ aTabCols.SetHidden( i - 1, !rCol.bVisible );
+ }
+ }
+ else
+ {
+ for ( USHORT i = 0; i < aColItem.Count()-1; ++i )
+ {
+ const SvxColumnDescription& rCol = aColItem[i];
+ aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+ aTabCols.SetHidden( i, !rCol.bVisible );
+ }
+ }
+ BOOL bSingleLine = FALSE;
+ const SfxPoolItem* pSingleLine;
+ if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, FALSE, &pSingleLine))
+ bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
+ if ( bSetTabRowFromDoc )
+ {
+ if( !rSh.IsViewLocked() )
+ {
+ bUnlockView = TRUE;
+ rSh.LockView( TRUE );
+ }
+ rSh.SetMouseTabRows( aTabCols, bSingleLine, aTabColFromDocPos );
+ }
+ else
+ rSh.SetTabRows(aTabCols, bSingleLine);
+ }
+ }
+ break;
+
+ default:
+ ASSERT( !this, "Falsche SlotId");
+ }
+ rSh.EndAllAction();
+
+ if( bUnlockView )
+ rSh.LockView( FALSE );
+
+ bSetTabColFromDoc = bSetTabRowFromDoc = bTabColFromDoc = bTabRowFromDoc = FALSE;
+ SetNumRuleNodeFromDoc(NULL);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Hier wird der Status der Tableiste ermittelt
+ sprich alle relevanten Attribute an der CursorPos
+ werden der Tableiste uebermittelt
+ --------------------------------------------------------------------*/
+
+
+void SwView::StateTabWin(SfxItemSet& rSet)
+{
+ SwWrtShell &rSh = GetWrtShell();
+
+ const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &aTabColFromDocPos : 0;
+ const USHORT nFrmType = rSh.IsObjSelected()
+ ? FRMTYPE_DRAWOBJ
+ : rSh.GetFrmType( pPt, TRUE );
+
+ const BOOL bFrmSelection = rSh.IsFrmSelected();
+
+ const BOOL bBrowse = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+ // PageOffset/Begrenzer
+ const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
+ const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
+ const long nPageWidth = rPageRect.Width();
+ const long nPageHeight = rPageRect.Height();
+
+ const SwPageDesc& rDesc = rSh.GetPageDesc(
+ IsTabColFromDoc() || bTabRowFromDoc ?
+ rSh.GetMousePageDesc(aTabColFromDocPos) : rSh.GetCurPageDesc() );
+
+ const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrmDir();
+ const BOOL bVerticalWriting = rSh.IsInVerticalText();
+
+ //enable tab stop display on the rulers depending on the writing direction
+ WinBits nRulerStyle = pHRuler->GetStyle() & ~WB_EXTRAFIELD;
+ pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
+ nRulerStyle = pVRuler->GetStyle() & ~WB_EXTRAFIELD;
+ pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);
+
+ //#i24363# tab stops relative to indent
+ bool bRelative = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
+ pHRuler->SetTabsRelativeToIndent( bRelative );
+ pVRuler->SetTabsRelativeToIndent( bRelative );
+
+ SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
+ SwapPageMargin( rDesc, aPageLRSpace );
+
+ SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
+ RES_LR_SPACE, RES_UL_SPACE, 0 );
+ // --> OD 2008-01-17 #newlistlevelattrs#
+ // get also the list level indent values merged as LR-SPACE item, if needed.
+ rSh.GetCurAttr( aCoreSet, true );
+ // <--
+ SelectionType nSelType = rSh.GetSelectionType();
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ sal_Bool bPutContentProtection = sal_False;
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+// case RES_LR_SPACE:
+// case SID_ATTR_LRSPACE:
+ case SID_ATTR_LONG_LRSPACE:
+ {
+ SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
+ (long)aPageLRSpace.GetRight(),
+ SID_ATTR_LONG_LRSPACE);
+ if(bBrowse)
+ {
+ aLongLR.SetLeft(rPagePrtRect.Left());
+ aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
+ }
+ if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
+ !(nFrmType & FRMTYPE_COLSECT) )
+ {
+ SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
+ rDesc.GetMaster().GetHeader().GetHeaderFmt() :
+ rDesc.GetMaster().GetFooter().GetFooterFmt());
+ if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ {
+ SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
+ aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
+ const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
+ aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
+ aLongLR.SetRight( (nPageWidth -
+ (long)aRect.Right() + (long)aLR.GetRight()));
+ }
+ }
+ else
+ {
+ SwRect aRect;
+ if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
+ {
+ aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
+ aRect.Pos() += aTmpRect.Pos();
+ }
+
+ else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ else if( nFrmType & FRMTYPE_DRAWOBJ)
+ aRect = rSh.GetObjRect();
+
+ if( aRect.Width() )
+ {
+ // PAGES01
+ // make relative to page position:
+ aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
+ aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
+ }
+ }
+ if( nWhich == SID_ATTR_LONG_LRSPACE )
+ rSet.Put( aLongLR );
+ else
+ {
+ SvxLRSpaceItem aLR( aLongLR.GetLeft(),
+ aLongLR.GetRight(),
+ 0, 0,
+ nWhich);
+ rSet.Put(aLR);
+ }
+ break;
+ }
+ case SID_ATTR_LONG_ULSPACE:
+// case SID_ATTR_ULSPACE:
+// case RES_UL_SPACE:
+ {
+ // Rand Seite Oben Unten
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
+ (long)aUL.GetLower(),
+ SID_ATTR_LONG_ULSPACE);
+
+ if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ aLongUL.SetUpper((USHORT)(rRect.Top() - rPageRect.Top() ));
+ aLongUL.SetLower((USHORT)(rPageRect.Bottom() - rRect.Bottom() ));
+ }
+ else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
+ {
+ SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
+ aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
+ aLongUL.SetUpper( (USHORT)aRect.Top() );
+ aLongUL.SetLower( (USHORT)(nPageHeight - aRect.Bottom()) );
+ }
+ else if( nFrmType & FRMTYPE_DRAWOBJ)
+ {
+ const SwRect &rRect = rSh.GetObjRect();
+ aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
+ aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
+ }
+ else if(bBrowse)
+ {
+ aLongUL.SetUpper(rPagePrtRect.Top());
+ aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
+ }
+ if( nWhich == SID_ATTR_LONG_ULSPACE )
+ rSet.Put( aLongUL );
+ else
+ {
+ SvxULSpaceItem aULTmp((USHORT)aLongUL.GetUpper(),
+ (USHORT)aLongUL.GetLower(),
+ nWhich);
+ rSet.Put(aULTmp);
+ }
+ break;
+ }
+ case SID_ATTR_TABSTOP_VERTICAL :
+ case RES_PARATR_TABSTOP:
+ {
+ if ( ISA( SwWebView ) ||
+ IsTabColFromDoc() ||
+ IsTabRowFromDoc() ||
+ ( nSelType & nsSelectionType::SEL_GRF) ||
+ (nSelType & nsSelectionType::SEL_FRM) ||
+ (nSelType & nsSelectionType::SEL_OLE) ||
+ SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE)||
+ !bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich)||
+ bVerticalWriting && (RES_PARATR_TABSTOP == nWhich)
+ )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ SvxTabStopItem aTabStops((const SvxTabStopItem&)
+ aCoreSet.Get( RES_PARATR_TABSTOP ));
+
+ const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
+ rSh.GetDefault(RES_PARATR_TABSTOP);
+
+ DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
+ long nDefTabDist = ::GetTabDist(rDefTabs);
+ pHRuler->SetDefTabDist( nDefTabDist );
+ pVRuler->SetDefTabDist( nDefTabDist );
+ ::lcl_EraseDefTabs(aTabStops);
+ rSet.Put(aTabStops, nWhich);
+ }
+ break;
+ }
+ case SID_ATTR_PARA_LRSPACE_VERTICAL:
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ ||
+ !bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)||
+ bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich)
+ )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else
+ {
+ SvxLRSpaceItem aLR( RES_LR_SPACE );
+ if ( !IsTabColFromDoc() )
+ {
+ aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
+
+ // #i23726#
+ if (pNumRuleNodeFromDoc)
+ {
+ short nOffset = static_cast< short >(aLR.GetTxtLeft() +
+ // --> FME 2005-02-22 #i42922# Mouse move of numbering label
+ // has to consider the left indent of the paragraph
+ pNumRuleNodeFromDoc->GetLeftMarginWithNum( TRUE ) );
+ // <--
+
+ short nFLOffset;
+ pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
+
+ aLR.SetLeft( nOffset + nFLOffset );
+ }
+ }
+ aLR.SetWhich(nWhich);
+ rSet.Put(aLR);
+ }
+ break;
+ }
+ case SID_RULER_BORDER_DISTANCE:
+ {
+ nLeftBorderDistance = 0;
+ nRightBorderDistance = 0;
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ )
+ rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
+ else
+ {
+ SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
+ if(nFrmType & FRMTYPE_FLY_ANY)
+ {
+ if( IsTabColFromDoc() )
+ {
+ const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
+ aDistLR.SetLeft(rFlyPrtRect.Left());
+ aDistLR.SetRight(rFlyPrtRect.Left());
+ }
+ else
+ {
+ SfxItemSet aCoreSet2( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aCoreSet.Put( aBoxInfo );
+ rSh.GetFlyFrmAttr( aCoreSet );
+ const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
+ aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ //add the paragraph border distance
+ SfxItemSet aCoreSet1( GetPool(),
+ RES_BOX, RES_BOX,
+ 0 );
+ rSh.GetCurAttr( aCoreSet1 );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ }
+ rSet.Put(aDistLR);
+ nLeftBorderDistance = static_cast< USHORT >(aDistLR.GetLeft());
+ nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
+ }
+ else if ( IsTabColFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) )
+ {
+ SfxItemSet aCoreSet2( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+ aBoxInfo.SetTable(FALSE);
+ aBoxInfo.SetDist((BOOL) TRUE);
+ aCoreSet2.Put(aBoxInfo);
+ rSh.GetTabBorders( aCoreSet2 );
+ const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
+ aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ //add the border distance of the paragraph
+ SfxItemSet aCoreSet1( GetPool(),
+ RES_BOX, RES_BOX,
+ 0 );
+ rSh.GetCurAttr( aCoreSet1 );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ rSet.Put(aDistLR);
+ nLeftBorderDistance = static_cast< USHORT >(aDistLR.GetLeft());
+ nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
+ }
+ else if ( !rSh.IsDirectlyInSection() )
+ {
+ //get the page/header/footer border distance
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
+ aDistLR.SetLeft((USHORT)rBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((USHORT)rBox.GetDistance(BOX_LINE_RIGHT));
+
+ const SvxBoxItem* pBox = 0;
+ if(nFrmType & FRMTYPE_HEADER)
+ {
+ rMaster.GetHeader();
+ const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
+ SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+ if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
+ }
+ else if(nFrmType & FRMTYPE_FOOTER )
+ {
+ const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
+ SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+ if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+ pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
+ }
+ if(pBox)
+ {
+ aDistLR.SetLeft((USHORT)pBox->GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight((USHORT)pBox->GetDistance(BOX_LINE_RIGHT));
+ }
+
+ //add the border distance of the paragraph
+ SfxItemSet aCoreSetTmp( GetPool(),
+ RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+ rSh.GetCurAttr( aCoreSetTmp );
+ const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
+ aDistLR.SetLeft(aDistLR.GetLeft() + (USHORT)rParaBox.GetDistance(BOX_LINE_LEFT ));
+ aDistLR.SetRight(aDistLR.GetRight() + (USHORT)rParaBox.GetDistance(BOX_LINE_RIGHT));
+ rSet.Put(aDistLR);
+ nLeftBorderDistance = static_cast< USHORT >(aDistLR.GetLeft());
+ nRightBorderDistance = static_cast< USHORT >(aDistLR.GetRight());
+ }
+ }
+ }
+ break;
+ case SID_RULER_TEXT_RIGHT_TO_LEFT:
+ {
+ if ( nSelType & nsSelectionType::SEL_GRF ||
+ nSelType & nsSelectionType::SEL_FRM ||
+ nSelType & nsSelectionType::SEL_OLE ||
+ nFrmType == FRMTYPE_DRAWOBJ)
+ rSet.DisableItem(nWhich);
+ else
+ {
+ BOOL bFlag = rSh.IsInRightToLeftText();
+ rSet.Put(SfxBoolItem(nWhich, bFlag));
+ }
+ }
+ break;
+ case SID_RULER_BORDERS_VERTICAL:
+ case SID_RULER_BORDERS:
+ {
+ BOOL bFrameRTL;
+ BOOL bFrameHasVerticalColumns = rSh.IsFrmVertical(FALSE, bFrameRTL) && bFrmSelection;
+ BOOL bHasTable = ( IsTabColFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) );
+
+ BOOL bTableVertical = bHasTable && rSh.IsTableVertical();
+
+ if((SID_RULER_BORDERS_VERTICAL == nWhich) &&
+ ((bHasTable && !bTableVertical)||
+ (!bVerticalWriting && !bFrmSelection && !bHasTable ) || (bFrmSelection && !bFrameHasVerticalColumns)) ||
+ ((SID_RULER_BORDERS == nWhich) &&
+ ((bHasTable && bTableVertical)||
+ (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
+ rSet.DisableItem(nWhich);
+ else if ( bHasTable )
+ {
+ SwTabCols aTabCols;
+ USHORT nNum;
+ if ( 0 != ( bSetTabColFromDoc = IsTabColFromDoc() ) )
+ {
+ rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
+ nNum = rSh.GetCurMouseTabColNum( aTabColFromDocPos );
+ }
+ else
+ {
+ rSh.GetTabCols( aTabCols );
+ nNum = rSh.GetCurTabColNum();
+ if(rSh.IsTableRightToLeft())
+ nNum = aTabCols.Count() - nNum;
+ }
+
+ ASSERT(nNum <= aTabCols.Count(), "TabCol not found");
+ const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
+ const int nRgt = (USHORT)(bTableVertical ? nPageHeight : nPageWidth) -
+ (aTabCols.GetLeftMin() +
+ aTabCols.GetRight());
+
+ const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
+ const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);
+
+ SvxColumnItem aColItem(nNum, nL, nR);
+
+ USHORT nStart = 0,
+ nEnd;
+
+ //columns in right-to-left tables need to be mirrored
+ BOOL bIsTableRTL =
+ IsTabColFromDoc() ?
+ rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
+ : rSh.IsTableRightToLeft();
+ if(bIsTableRTL)
+ {
+ for ( USHORT i = aTabCols.Count(); i ; --i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
+ nEnd = (USHORT)aTabCols.GetRight();
+ nEnd = nEnd - (USHORT)rEntry.nPos;
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ (USHORT(aTabCols.GetRight() - rEntry.nMax)),
+ (USHORT(aTabCols.GetRight() - rEntry.nMin)),
+ !aTabCols.IsHidden(i - 1) );
+ aColItem.Append(aColDesc);
+ nStart = nEnd;
+ }
+ SvxColumnDescription aColDesc(nStart,
+ aTabCols.GetRight() - aTabCols.GetLeft(), TRUE);
+ aColItem.Append(aColDesc);
+ }
+ else
+ {
+ for ( USHORT i = 0; i < aTabCols.Count(); ++i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
+ nEnd = static_cast< USHORT >(rEntry.nPos - aTabCols.GetLeft());
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ nStart = nEnd;
+ }
+ SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
+ 0, 0,
+ TRUE);
+ aColItem.Append(aColDesc);
+ }
+ rSet.Put(aColItem, nWhich);
+ }
+ else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
+ {
+ // Aus Rahmen oder Seite ?
+ USHORT nNum = 0;
+ if(bFrmSelection)
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ if(pFmt)
+ nNum = pFmt->GetCol().GetNumCols();
+ }
+ else
+ nNum = rSh.GetCurColNum();
+
+ if(
+ //eigentlich sollte FRMTYPE_COLSECT nicht enthalten sein, wenn der Rahmen selektiert ist!
+ !bFrmSelection &&
+ nFrmType & FRMTYPE_COLSECT )
+ {
+ const SwSection *pSect = rSh.GetAnySection(FALSE, pPt);
+ ASSERT( pSect, "Welcher Bereich?");
+ if( pSect )
+ {
+ SwSectionFmt *pFmt = pSect->GetFmt();
+ const SwFmtCol& rCol = pFmt->GetCol();
+ if(rSh.IsInRightToLeftText())
+ nNum = rCol.GetColumns().Count() - nNum;
+ else
+ --nNum;
+ SvxColumnItem aColItem(nNum);
+ SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
+ const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
+
+ ::lcl_FillSvxColumn(rCol, USHORT(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);
+
+ if(bVerticalWriting)
+ {
+ aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
+ aRect.Pos().Y() -= rPageRect.Top();
+ aColItem.SetLeft ((USHORT)(aRect.Top()));
+ aColItem.SetRight((USHORT)(nPageHeight - aRect.Bottom() ));
+ }
+ else
+ {
+ aRect.Pos() += aTmpRect.Pos();
+
+ // PAGES01
+ // make relative to page position:
+ aColItem.SetLeft ((USHORT)( aRect.Left() - rPageRect.Left() ));
+ aColItem.SetRight((USHORT)( rPageRect.Right() - aRect.Right()));
+ }
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ }
+ else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+ {
+ // Spalten in Rahmen
+ if ( nNum )
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
+
+ const SwFmtCol& rCol = pFmt->GetCol();
+ if(rSh.IsInRightToLeftText())
+ nNum = rCol.GetColumns().Count() - nNum;
+ else
+ nNum--;
+ SvxColumnItem aColItem(nNum);
+ const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);
+
+ BOOL bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
+ const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
+ const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+ long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
+ ::lcl_FillSvxColumn(rCol, USHORT(lWidth), aColItem, nDist2);
+
+ SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
+ rSh.GetFlyFrmAttr( aFrameSet );
+
+ if(bUseVertical)
+ {
+ aColItem.SetLeft ((USHORT)(rRect.Top()- rPageRect.Top()));
+ aColItem.SetRight((USHORT)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
+ }
+ else
+ {
+ aColItem.SetLeft ((USHORT)(rRect.Left() - rPageRect.Left() ));
+ aColItem.SetRight((USHORT)(rPageRect.Right() - rRect.Right() ));
+ }
+
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ else
+ { // Spalten auf der Seite
+ const SwFrmFmt& rMaster = rDesc.GetMaster();
+ SwFmtCol aCol(rMaster.GetCol());
+ if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
+ nNum = aCol.GetColumns().Count() - nNum;
+ else
+ nNum--;
+
+ SvxColumnItem aColItem(nNum);
+ const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
+ const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
+ long nDist = rBox.GetDistance();
+ ::lcl_FillSvxColumn(aCol,
+ USHORT(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
+ aColItem, nDist);
+
+ if(bBrowse)
+ {
+ aColItem.SetLeft((USHORT)rPagePrtRect.Left());
+ aColItem.SetRight(USHORT(nPageWidth - rPagePrtRect.Right()));
+ }
+ else
+ {
+ aColItem.SetLeft (aPageLRSpace.GetLeft());
+ aColItem.SetRight(aPageLRSpace.GetRight());
+ }
+ aColItem.SetOrtho(aColItem.CalcOrtho());
+
+ rSet.Put(aColItem, nWhich);
+ }
+ }
+ else
+ rSet.DisableItem(nWhich);
+ break;
+ }
+ case SID_RULER_ROWS :
+ case SID_RULER_ROWS_VERTICAL:
+ {
+ BOOL bFrameRTL;
+ BOOL bFrameHasVerticalColumns = rSh.IsFrmVertical(FALSE, bFrameRTL) && bFrmSelection;
+
+ if((SID_RULER_ROWS == nWhich) &&
+ ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns)) ||
+ ((SID_RULER_ROWS_VERTICAL == nWhich) &&
+ ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
+ rSet.DisableItem(nWhich);
+ else if ( IsTabRowFromDoc() ||
+ ( rSh.GetTableFmt() && !bFrmSelection &&
+ !(nFrmType & FRMTYPE_COLSECT ) ) )
+ {
+ SwTabCols aTabCols;
+ //no current value necessary
+ USHORT nNum = 0;
+ if ( 0 != ( bSetTabRowFromDoc = IsTabRowFromDoc() ) )
+ {
+ rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
+ }
+ else
+ {
+ rSh.GetTabRows( aTabCols );
+ }
+
+// ASSERT(nNum <= aTabCols.Count(), "TabCol not found");
+ const int nLft = aTabCols.GetLeftMin();
+ const int nRgt = (USHORT)(bVerticalWriting ? nPageWidth : nPageHeight) -
+ (aTabCols.GetLeftMin() +
+ aTabCols.GetRight());
+
+ const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
+ const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);
+
+ SvxColumnItem aColItem(nNum, nL, nR);
+
+ USHORT nStart = 0,
+ nEnd;
+
+ for ( USHORT i = 0; i < aTabCols.Count(); ++i )
+ {
+ const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
+ if(bVerticalWriting)
+ {
+ nEnd = USHORT(aTabCols.GetRight() - rEntry.nPos);
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ }
+ else
+ {
+ nEnd = USHORT(rEntry.nPos - aTabCols.GetLeft());
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ USHORT(rEntry.nMin - aTabCols.GetLeft()), USHORT(rEntry.nMax - aTabCols.GetLeft()),
+ !aTabCols.IsHidden(i) );
+ aColItem.Append(aColDesc);
+ }
+ nStart = nEnd;
+ }
+ if(bVerticalWriting)
+ nEnd = static_cast< USHORT >(aTabCols.GetRight());
+ else
+ nEnd = static_cast< USHORT >(aTabCols.GetLeft());
+ // put a position protection when the last row cannot be moved
+ // due to a page break inside of a row
+ if(!aTabCols.IsLastRowAllowedToChange())
+ bPutContentProtection = sal_True;
+
+ SvxColumnDescription aColDesc( nStart, nEnd,
+ aTabCols.GetRight(), aTabCols.GetRight(),
+ FALSE );
+ aColItem.Append(aColDesc);
+
+ rSet.Put(aColItem, nWhich);
+ }
+ else
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_RULER_PAGE_POS:
+ {
+ // PAGES01
+ SvxPagePosSizeItem aPagePosSize(
+ Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);
+
+ rSet.Put(aPagePosSize);
+ break;
+ }
+ case SID_RULER_LR_MIN_MAX:
+ {
+ Rectangle aRectangle;
+ if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
+ ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
+ {
+ if( nFrmType & FRMTYPE_TABLE )
+ {
+ const USHORT nNum = rSh.GetCurTabColNum();
+ SwTabCols aTabCols;
+ rSh.GetTabCols( aTabCols );
+
+ const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
+ const int nRgt = (USHORT)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
+
+ const USHORT nL = static_cast< USHORT >(nLft > 0 ? nLft : 0);
+ const USHORT nR = static_cast< USHORT >(nRgt > 0 ? nRgt : 0);
+
+ aRectangle.Left() = nL;
+ if(nNum > 1)
+ aRectangle.Left() += aTabCols[nNum - 2];
+ if(nNum)
+ aRectangle.Left() += MINLAY;
+ if(aTabCols.Count() <= nNum + 1 )
+ aRectangle.Right() = nR;
+ else
+ aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);
+
+ if(nNum < aTabCols.Count())
+ aRectangle.Right() += MINLAY;
+ }
+ else
+ {
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
+ &rDesc.GetMaster().GetCol();
+ const SwColumns& rCols = pCols->GetColumns();
+ USHORT nNum = rSh.GetCurOutColNum();
+ USHORT nCount = Min(USHORT(nNum + 1), rCols.Count());
+ const SwRect aRect( rSh.GetAnyCurRect( pFmt
+ ? RECT_FLY_PRT_EMBEDDED
+ : RECT_PAGE_PRT, pPt ));
+ const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
+ ? RECT_FLY_EMBEDDED
+ : RECT_PAGE, pPt ));
+
+ //die Breite im Rahmen bzw. innerhalbe der Seitenraender
+ const USHORT nTotalWidth = (USHORT)aRect.Width();
+ //die gesamte Rahmenbreite - die Differenz ist der doppelte Abstand zum Rand
+ const USHORT nOuterWidth = (USHORT)aAbsRect.Width();
+ int nWidth = 0,
+ nStart = 0,
+ nEnd = 0;
+ aRectangle.Left() = 0;
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ SwColumn* pCol = rCols[i];
+ nStart = pCol->GetLeft() + nWidth;
+ if(i == nNum - 2)
+ aRectangle.Left() = nStart;
+ nWidth += pCols->CalcColWidth( i, nTotalWidth );
+ nEnd = nWidth - pCol->GetRight();
+ }
+ aRectangle.Right() = rPageRect.Right() - nEnd;
+ aRectangle.Left() -= rPageRect.Left();
+
+ if(nNum > 1)
+ {
+ aRectangle.Left() += MINLAY;
+ aRectangle.Left() += aRect.Left();
+ }
+ if(pFmt) //Bereich in Rahmen - hier darf man bis zum Rand
+ aRectangle.Left() = aRectangle.Right() = 0;
+ else
+ {
+ // das Rechteck an die richtige absolute Position verschieben
+ aRectangle.Left() += aAbsRect.Left();
+ aRectangle.Right() -= aAbsRect.Left();
+ // Abstand zur Umrandung mit einbeziehen
+ aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
+ }
+
+ if(nNum < rCols.Count())
+ {
+ aRectangle.Right() += MINLAY;
+ }
+ else
+ // rechts ist jetzt nur noch der Seitenrand
+ aRectangle.Right() = 0;
+
+
+ }
+ }
+ else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
+ !bFrmSelection )
+ {
+ BOOL bColumn;
+ if ( IsTabColFromDoc() )
+ bColumn = rSh.GetCurMouseColNum( aTabColFromDocPos ) != 0;
+ else
+ bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|
+ FRMTYPE_COLSECTOUTTAB)) ?
+ TRUE : FALSE;
+ if ( !bColumn )
+ {
+ if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
+ {
+ SwRect aRect( rSh.GetAnyCurRect(
+ RECT_FLY_PRT_EMBEDDED, pPt ) );
+ aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
+ pPt ).Pos();
+
+ aRectangle.Left() = aRect.Left() - rPageRect.Left();
+ aRectangle.Right() = rPageRect.Right() - aRect.Right();
+ }
+ else if( bBrowse )
+ {
+ aRectangle.Left() = rPagePrtRect.Left();
+ aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
+ }
+ else
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft();
+ aRectangle.Right() = aPageLRSpace.GetRight();
+ }
+ }
+ else
+ { //hier nur fuer Tabelle in mehrspaltigen Seiten und Rahmen
+ BOOL bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? TRUE : FALSE;
+ BOOL bFrame = (nFrmType & FRMTYPE_FLY_ANY) ? TRUE : FALSE;
+ BOOL bColSct = (nFrmType & ( bSectOutTbl
+ ? FRMTYPE_COLSECTOUTTAB
+ : FRMTYPE_COLSECT )
+ ) ? TRUE : FALSE;
+ //Damit man auch mit der Mouse ziehen kann,
+ //ohne in der Tabelle zu stehen
+ CurRectType eRecType = RECT_PAGE_PRT;
+ USHORT nNum = IsTabColFromDoc() ?
+ rSh.GetCurMouseColNum( aTabColFromDocPos ):
+ rSh.GetCurOutColNum();
+ const SwFrmFmt* pFmt = NULL;
+ if( bColSct )
+ {
+ eRecType = bSectOutTbl ? RECT_OUTTABSECTION
+ : RECT_SECTION;
+ const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
+ ASSERT( pSect, "Welcher Bereich?");
+ pFmt = pSect->GetFmt();
+ }
+ else if( bFrame )
+ {
+ pFmt = rSh.GetFlyFrmFmt();
+ eRecType = RECT_FLY_PRT_EMBEDDED;
+ }
+
+ const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
+ &rDesc.GetMaster().GetCol();
+ const SwColumns& rCols = pCols->GetColumns();
+ const USHORT nBorder = pFmt ? pFmt->GetBox().GetDistance() :
+ rDesc.GetMaster().GetBox().GetDistance();
+
+ /* RECT_FLY_PRT_EMBEDDED returns the relative position to
+ RECT_FLY_EMBEDDED
+ the absolute position must be added here
+ */
+ SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
+ if(RECT_FLY_PRT_EMBEDDED == eRecType)
+ aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
+ pPt ).Pos();
+
+ const USHORT nTotalWidth = (USHORT)aRect.Width();
+ //nStart und nEnd initialisieren fuer nNum == 0
+ int nWidth = 0,
+ nStart = 0,
+ nEnd = nTotalWidth;
+
+ if( nNum > rCols.Count() )
+ {
+ ASSERT( !this, "es wird auf dem falschen FmtCol gearbeitet!" );
+ nNum = rCols.Count();
+ }
+
+ for( USHORT i = 0; i < nNum; ++i )
+ {
+ SwColumn* pCol = rCols[i];
+ nStart = pCol->GetLeft() + nWidth;
+ nWidth += pCols->CalcColWidth( i, nTotalWidth );
+ nEnd = nWidth - pCol->GetRight();
+ }
+ if( bFrame | bColSct )
+ {
+ aRectangle.Left() = aRect.Left() - rPageRect.Left() + nStart;
+ aRectangle.Right() = nPageWidth - aRectangle.Left() - nEnd + nStart;
+ }
+ else if(!bBrowse)
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft() + nStart;
+ aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
+ }
+ else
+ {
+ long nLeft = rPagePrtRect.Left();
+ aRectangle.Left() = nStart + nLeft;
+ aRectangle.Right() = nPageWidth - nEnd - nLeft;
+ }
+ if(!bFrame)
+ {
+ aRectangle.Left() += nBorder;
+ aRectangle.Right() -= nBorder;
+ }
+ }
+ }
+ else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+ {
+ aRectangle.Left() = aPageLRSpace.GetLeft();
+ aRectangle.Right() = aPageLRSpace.GetRight();
+ }
+ else
+ aRectangle.Left() = aRectangle.Right() = 0;
+
+ SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
+ rSet.Put(aLR);
+ }
+ break;
+ case SID_RULER_PROTECT:
+ {
+ if(bFrmSelection)
+ {
+ BYTE nProtect = pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );
+
+ SvxProtectItem aProt(SID_RULER_PROTECT);
+ aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT) != 0);
+ aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE) != 0);
+ aProt.SetPosProtect ((nProtect & FLYPROTECT_POS) != 0);
+ rSet.Put(aProt);
+ }
+ else
+ {
+ SvxProtectItem aProtect(SID_RULER_PROTECT);
+ if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
+ {
+ aProtect.SetSizeProtect(TRUE);
+ aProtect.SetPosProtect(TRUE);
+ }
+ rSet.Put(aProtect);
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+ if(bPutContentProtection)
+ {
+ SvxProtectItem aProtect(SID_RULER_PROTECT);
+ aProtect.SetCntntProtect(TRUE);
+ rSet.Put(aProtect);
+ }
+}
+
+