Kaydet (Commit) 27fc6087 authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: fdo#78151 disable promote or demote outline levels in master view

it doesn't make sense in master view to do that

Change-Id: I838422f93131b8a92745a624738c5be3a7ed3459
üst 52871279
...@@ -253,88 +253,96 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) ...@@ -253,88 +253,96 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
bool bDisableRight = true; bool bDisableRight = true;
bool bDisableUp = true; bool bDisableUp = true;
bool bDisableDown = true; bool bDisableDown = true;
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (mpView->ISA(OutlineView)) //fdo#78151 it doesn't make sense to promote or demote outline levels in master view.
{ const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >(mpViewShell);
pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow( const bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
mpViewShell->GetActiveWindow());
}
bool bOutlineViewSh = mpViewShell->ISA(OutlineViewShell); if (!bInMasterView)
if (pOLV &&
( pOLV->GetOutliner()->GetMode() == OUTLINERMODE_OUTLINEOBJECT || bOutlineViewSh ) )
{ {
// Outliner at outline-mode OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
::Outliner* pOutl = pOLV->GetOutliner();
std::vector<Paragraph*> aSelList; if (mpView->ISA(OutlineView))
pOLV->CreateSelectionList(aSelList); {
Paragraph* pPara = aSelList.empty() ? NULL : *(aSelList.begin()); pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
mpViewShell->GetActiveWindow());
}
// find out if we are a OutlineView bool bOutlineViewSh = mpViewShell->ISA(OutlineViewShell);
bool bIsOutlineView(OUTLINERMODE_OUTLINEVIEW == pOLV->GetOutliner()->GetMode());
// This is ONLY for OutlineViews if (pOLV &&
if(bIsOutlineView) ( pOLV->GetOutliner()->GetMode() == OUTLINERMODE_OUTLINEOBJECT || bOutlineViewSh ) )
{ {
// allow move up if position is 2 or greater OR it // Outliner at outline-mode
// is a title object (and thus depth==1) ::Outliner* pOutl = pOLV->GetOutliner();
if(pOutl->GetAbsPos(pPara) > 1 || ( pOutl->HasParaFlag(pPara,PARAFLAG_ISPAGE) && pOutl->GetAbsPos(pPara) > 0 ) )
std::vector<Paragraph*> aSelList;
pOLV->CreateSelectionList(aSelList);
Paragraph* pPara = aSelList.empty() ? NULL : *(aSelList.begin());
// find out if we are a OutlineView
bool bIsOutlineView(OUTLINERMODE_OUTLINEVIEW == pOLV->GetOutliner()->GetMode());
// This is ONLY for OutlineViews
if(bIsOutlineView)
{ {
// not at top // allow move up if position is 2 or greater OR it
bDisableUp = false; // is a title object (and thus depth==1)
if(pOutl->GetAbsPos(pPara) > 1 || ( pOutl->HasParaFlag(pPara,PARAFLAG_ISPAGE) && pOutl->GetAbsPos(pPara) > 0 ) )
{
// not at top
bDisableUp = false;
}
} }
} else
else
{
// old behaviour for OUTLINERMODE_OUTLINEOBJECT
if(pOutl->GetAbsPos(pPara) > 0)
{ {
// not at top // old behaviour for OUTLINERMODE_OUTLINEOBJECT
bDisableUp = false; if(pOutl->GetAbsPos(pPara) > 0)
{
// not at top
bDisableUp = false;
}
} }
}
for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter) for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
{
pPara = *iter;
sal_Int16 nDepth = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) );
if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE )) )
{ {
// not minimum depth pPara = *iter;
bDisableLeft = false;
sal_Int16 nDepth = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) );
if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE )) )
{
// not minimum depth
bDisableLeft = false;
}
if( (nDepth < pOLV->GetOutliner()->GetMaxDepth() && ( !bOutlineViewSh || pOutl->GetAbsPos(pPara) != 0 )) ||
(bOutlineViewSh && (nDepth <= 0) && pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && pOutl->GetAbsPos(pPara) != 0) )
{
// not maximum depth and not at top
bDisableRight = false;
}
} }
if( (nDepth < pOLV->GetOutliner()->GetMaxDepth() && ( !bOutlineViewSh || pOutl->GetAbsPos(pPara) != 0 )) || if ( ( pOutl->GetAbsPos(pPara) < pOutl->GetParagraphCount() - 1 ) &&
(bOutlineViewSh && (nDepth <= 0) && pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && pOutl->GetAbsPos(pPara) != 0) ) ( pOutl->GetParagraphCount() > 1 || !bOutlineViewSh) )
{ {
// not maximum depth and not at top // not last paragraph
bDisableRight = false; bDisableDown = false;
} }
}
if ( ( pOutl->GetAbsPos(pPara) < pOutl->GetParagraphCount() - 1 ) && // disable when first para and 2nd is not a title
( pOutl->GetParagraphCount() > 1 || !bOutlineViewSh) ) pPara = aSelList.empty() ? NULL : *(aSelList.begin());
{
// not last paragraph
bDisableDown = false;
}
// disable when first para and 2nd is not a title
pPara = aSelList.empty() ? NULL : *(aSelList.begin());
if(!bDisableDown && bIsOutlineView if(!bDisableDown && bIsOutlineView
&& pPara && pPara
&& 0 == pOutl->GetAbsPos(pPara) && 0 == pOutl->GetAbsPos(pPara)
&& pOutl->GetParagraphCount() > 1 && pOutl->GetParagraphCount() > 1
&& !pOutl->HasParaFlag( pOutl->GetParagraph(1), PARAFLAG_ISPAGE ) ) && !pOutl->HasParaFlag( pOutl->GetParagraph(1), PARAFLAG_ISPAGE ) )
{ {
// Needs to be disabled // Needs to be disabled
bDisableDown = true; bDisableDown = true;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment